Skip to content

add client-facing expected_version compare-and-set on update and delete - #134

Merged
fabracht merged 2 commits into
mainfrom
hold-reclaim-client-cas
Sep 6, 2026
Merged

fabracht merged 2 commits into
mainfrom
hold-reclaim-client-cas

Conversation

@fabracht

@fabracht fabracht commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a client-facing compare-and-set: a write may carry a reserved _expected_version in its payload, and the server rejects the operation if the row's current _version differs.
  • The rejection is terminal — PreconditionFailed (transport code 412), which the write-retry loops treat as non-retryable, distinct from an optimistic-concurrency Conflict that is retried.
  • Enforced identically in agent mode (update_with_expected/delete_with_expected) and in both cluster write paths (client-dispatched local-primary and forwarded).
  • _expected_version is stripped before validation and storage, so it never persists as a field; omitting it leaves behavior unchanged. Embedded (WASM) mode ignores it.
  • Second primitive of on-disconnect hold reclaim (docs/design/hold-reclaim.md): a janitor reclaims an abandoned hold with a delete guarded on the last-observed version, so a holder that renewed in the meantime is never clobbered.

Test plan

  • cargo make clippy — zero warnings across the workspace and the wasm target
  • cargo make test — core/agent/vault/cluster suites pass
  • agent terminal-CAS counter-test (retry loop does not defeat the precondition)
  • cluster_update_delete_expected_version_cas covers both cluster write paths

@fabracht
fabracht merged commit 18f2e02 into main Sep 6, 2026
9 checks passed
@fabracht
fabracht deleted the hold-reclaim-client-cas branch September 6, 2026 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant