Repository navigation
Prevent duplicate run dispatches and preserve old journals (T34) - #184
Merged
Merged
Conversation
This was referenced Oct 13, 2026
erickb336
marked this pull request as ready for review
October 13, 2026 16:05
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.
Closes #183
Sage task T34
A run now receives only one dispatch within its project, even across owners, task labels, and completed work. An exact retry retains its old receipt. A proven initial dispatch failure permits a new attempt.
Older journals can contain duplicate initial dispatches. Those records remain readable and retain their bytes, but they cannot authorize another dispatch of that run. Continuations retain their existing replay checks. This is a component of #88 and #138; installed automatic Sage remains disabled.
Sources: packages/sage-core/admission.mjs and admission.md. Both provider bundles come from npm run build. No shared state-tool or Claude-hook changes.
Validation on 68254c1:
npm test -- --test-concurrency=1: 1,137 tests, 1,137 pass, 0 fail, 0 skipped. Every test and internal concurrency assertion ran.Baseline proof: the four new run-claim tests all fail behaviorally on detached main a0f6674. Main permits duplicate dispatches; the concurrency check observes two winners. The historical fixture was produced through that main commit's public API. Its test reads both old reservations, refuses a third duplicate, handles one failed and one completed reservation, and allows a different run without changing old bytes.
Existing test assertions are unchanged. Admission fixtures now give unrelated calls distinct run IDs. The composed native fixture gives the QA child its own run instead of reusing its lead's run. The first full run found this latter fixture error (1,136 pass, 1 fail); it was fixed before final validation. Review also found a worker startup cleanup gap; teardown now disconnects and awaits every owned worker.
Every test uses fake ps, pgrep and kill first on PATH. No attack strings run in a real shell. Not verified: real-model behavior, installed automatic Sage, current-logbook validation by the provider, or complete native policy composition. All local test suites and diagnostic processes have finished. No owned background workers remain.