persist: optimistic concurrency — conflict as a real result + 8 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
concurrency.sx: persist/append-expect refuses an append when the stream
advanced past the caller's expected seq, returning {:conflict :expected
:actual} instead of crashing or overwriting. persist/conflict? + accessors.
Phase 2 complete, 54/54.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -42,7 +42,7 @@ read models (feeds, indices, audit logs) update incrementally.
|
||||
|
||||
## Status (rolling)
|
||||
|
||||
`bash lib/persist/conformance.sh` → **28/28** (Phase 1 done)
|
||||
`bash lib/persist/conformance.sh` → **54/54** (Phases 1–2 done)
|
||||
|
||||
## Ground rules
|
||||
|
||||
@@ -96,7 +96,7 @@ lib/persist/backend.sx lib/persist/api.sx
|
||||
## Phase 2 — Projections + subscriptions
|
||||
- [x] `project.sx` — `(project stream step seed)`, incremental fold
|
||||
- [x] subscription hook — projection / kv read model re-runs on append
|
||||
- [ ] concurrency conflict surfaced as a real result, not a crash
|
||||
- [x] concurrency conflict surfaced as a real result, not a crash
|
||||
|
||||
## Phase 3 — Snapshots + replay
|
||||
- [ ] `snapshot.sx` — checkpoint a projection; replay = snapshot + tail
|
||||
@@ -113,6 +113,12 @@ feed/-log, flow store, mod/audit, search index, acl grants, identity sessions al
|
||||
become `persist` log or kv. Track each migration in that subsystem's plan.
|
||||
|
||||
## Progress log
|
||||
- **Phase 2c (54/54) — Phase 2 complete.** `concurrency.sx` — optimistic
|
||||
concurrency: `persist/append-expect b stream expected ...` refuses the append
|
||||
if the stream advanced past `expected`, returning a conflict VALUE
|
||||
`{:conflict true :expected :actual}` (never a crash, never a silent
|
||||
overwrite). `persist/conflict?` + accessors; caller re-reads actual and
|
||||
retries. 8 tests incl. two-writer race + retry.
|
||||
- **Phase 2b (46/46).** `subscribe.sx` — `persist/hub` wraps a backend with
|
||||
per-stream callbacks. `persist/publish` appends then fires subscribers
|
||||
`(backend stream event)`; direct `persist/append` bypasses them by design
|
||||
|
||||
Reference in New Issue
Block a user