Repository navigation
surface updateIf and deleteIf version-fenced cas methods - #59
Merged
Merged
Conversation
fabracht
force-pushed
the
surface-updateif-deleteif
branch
from
October 22, 2026 18:53
6a2cf3f to
d8ba514
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #57 — surfaces the version-fenced compare-and-set writes through the TS adapter. The engine CAS (stitch-rs #47) shipped in
@laboverwire/stitch-wasm0.6.0, and the 0.6.4 floor bump already raised this package to^0.6.0, so this release only exposes the methods — no new engine floor needed.Changes
src/types.ts— addupdateIf/deleteIfto theStore<S>interface.updateIf(entity, id, fields, expectedVersion): Promise<number>— appliesfieldsonly if the row's server version still equalsexpectedVersion, resolves with the new version.deleteIf(entity, id, expectedVersion): Promise<void>— removes the row under the same fence.src/store.ts—StitchStore.updateIf/deleteIfforward through the existing#afterReadystartup gate to the wasmStore. No optimistic queueing is added, and no error-string matching: the adapter forwards the engine's rejection untouched.CHANGELOG.md—## 0.6.5.tests/integration/cas.test.ts(new) — contract tests.Contract
err.kind = 'preconditionFailed'— a stale-version failure surfaces as the engine's terminal error kind (distinct from the retryableconflict). The adapter forwards rejections untouched, so callers readerr.kinddirectly; no mapping layer.Verification (on real stitch-wasm 0.6.0)
npm run check— type-check + lint + format + 40/40 browser tests (was 38; +2 new).npm run buildclean.Known coverage gap
The CAS success path and the
preconditionFailed-on-stale-version path require a live broker round-trip, which this suite does not provide (it only uses an unroutable URL that never connects). The new tests therefore cover the online-only rejection contract; the full round-trip remains a broker-backed e2e gap.Closes #57.