Repository navigation
fix(orch): prevent lost updates from concurrent store operations - #671
Open
rudycelekli wants to merge 1 commit into
Open
rudycelekli wants to merge 1 commit into
rudycelekli wants to merge 1 commit into
Conversation
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.
Concurrent operations on the same
orchstore handle can silently lose successful writes. In a filesystem reproduction, all 12 concurrentunits.addcalls resolved successfully while only one unit remained. The PID lock excludes other handles, but operations sharing the handle can still interleave their read/modify/write steps.Queue complete operations per handle, including reads and initialization. A failed operation does not block later work. Closing rejects new operations, waits for accepted work and then releases the existing PID lock. Regenerate the Claude harness copies from the source.
Validation: the Store suite passes 19 tests and 83 assertions. Identical tests against main produce 15 passes and four regression failures. Coverage includes units, ledger, gates, standing orders, inbox ordering, read-after-write, rejected writes, close ordering and existing cross-handle lock controls. Three CLI tests were filtered because their dependency is unavailable; no installation or full CLI validation was performed. Harness generation and drift checks pass. AI-assisted implementation and testing.
Note
Medium Risk
Changes core orch store concurrency and close ordering; incorrect queuing could still corrupt on-disk state or deadlock, but behavior is covered by new regression tests.
Overview
Fixes lost updates when multiple async calls share one
openStorehandle: the PID lock only blocks other processes, not interleaved read/modify/write on the same handle.store.tsbuilds the real implementation as an internalapi, then returns a wrapper thatenqueues every method (units, ledger, inbox, gates, frontier, standing, status,init) on a per-handle promise chain so operations run one at a time. Rejections do not stall the queue.closerejects new work withstore is closed, drains queued work, then releases the lock.orch.test.tsadds Store same-handle ordering tests for concurrent unit adds + read-after-write, parallel ledger/gate/standing updates, inbox push/drain/peek, duplicate-add rejection followed by a successful add, and close vs in-flight init/write.Reviewed by Cursor Bugbot for commit 0fb2edf. Bugbot is set up for automated code reviews on this repo. Configure here.