fix(proxy): make durable bridge claim_session a real compare-and-set - #1643
fix(proxy): make durable bridge claim_session a real compare-and-set#1643Komzpa wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 396ffa75d0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
396ffa7 to
8ac3b87
Compare
8ac3b87 to
c38dc2b
Compare
3916b0f to
ab5d30f
Compare
|
The CAS fix itself looks correct and well-executed — moving the read, epoch computation, fenced
Minor: Happy to re-review once this is rebased down to the CAS-only delta; the core change is merge-ready on its merits. |
claim_sessionin durable_bridge_repository read the owner row, computed the next fencing epoch in Python, and only then enteredsqlite_writer_section()for theUPDATE ... WHERE id = ?— with no epoch predicate.with_for_update()is a real row lock on PostgreSQL but a no-op on SQLite, so two concurrent claims in one process mint the SAME epoch (reproduced 40/40 with no barrier on the production SQLite engine config). The loser'srelease_sessionthen closes the row the winner is serving, leaving a durable row that pairs one claim's account_id with another's latest_response_id.That corruption is upstream of the cross-account anchor guard (#1638): its
durable_lookup.account_idcheck reads the winner's account as the owner of the loser's response id, concludes "same account, safe to inject", and injects an anchor the account cannot resolve — the exact wedge. Fixing the CAS closes the wedge at its source.Fix: the read, epoch computation, CAS UPDATE (WHERE includes session id + observed owner instance + observed epoch), alias cleanup and commit now happen in one
sqlite_writer_section— the same patternrecord_recovery_attemptalready uses. PostgreSQL correctness unchanged.Regression reproduces the duplicate-epoch / split-anchor state on origin/main and passes with the fix; 521 tests green; openspec change added.