Claim at most one pending stamp per session (#162)#177
Merged
willwashburn merged 1 commit intomainfrom Apr 28, 2026
Merged
Conversation
When two same-harness runs share a cwd, the resolver's
{harness, cwd, mtime, sessionDirHint} filter cannot disambiguate
their stamps. The previous loop applied every matching stamp to
whichever session ingested first, so concurrent runs lost their
tags. Take only the oldest match (FIFO by spawnStartTs) and leave
later stamps pending for later sessions.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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 #162.
resolvePendingStampsForSessionmatched stamps by{harness, cwd, mtime ≥ spawnStart, sessionDirHint}and then looped over all matches for a single session — when twoburn run codex(or twoburn run opencode) processes shared a cwd, both stamps satisfied the filter for whichever session ingested first, so the late session got nothing and the early session got both stamps' enrichment merged viaObject.assign.The fix is option (1) from the issue: claim at most one stamp per session, taking the oldest (
spawnStartTsascending). Each session consumes one stamp; later stamps stay pending until later sessions show up. FIFO is a defensible heuristic when the matcher cannot otherwise tell concurrent runs apart.Scope: only the same-harness + same-cwd concurrent case changes. Different cwds, different harnesses, and Claude (pre-allocated session IDs, no pending stamps) were already correct and remain unchanged. The stale-stamp-from-yesterday hazard mentioned in the issue is not addressed here — would need option (2) — but FIFO does mean a stale stamp is consumed by the next session in that cwd instead of every concurrent session at once.
Test plan
packages/cli/src/pending-stamps.test.ts: two stamps (A, B) in the same cwd resolve against two distinct sessions; first session getstag=A, second getstag=B, both pending files are deleted, and the ledger has exactly one stamp line per session.main(without the fix) and passes with it.pnpm run test:ts— 715/715 pass.🤖 Generated with Claude Code