Skip to content

Claim at most one pending stamp per session (#162)#177

Merged
willwashburn merged 1 commit intomainfrom
worktree-issue-162-pending-stamp-cross-contamination
Apr 28, 2026
Merged

Claim at most one pending stamp per session (#162)#177
willwashburn merged 1 commit intomainfrom
worktree-issue-162-pending-stamp-cross-contamination

Conversation

@willwashburn
Copy link
Copy Markdown
Member

@willwashburn willwashburn commented Apr 28, 2026

Summary

Fixes #162. resolvePendingStampsForSession matched stamps by {harness, cwd, mtime ≥ spawnStart, sessionDirHint} and then looped over all matches for a single session — when two burn run codex (or two burn 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 via Object.assign.

The fix is option (1) from the issue: claim at most one stamp per session, taking the oldest (spawnStartTs ascending). 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

  • New regression test in packages/cli/src/pending-stamps.test.ts: two stamps (A, B) in the same cwd resolve against two distinct sessions; first session gets tag=A, second gets tag=B, both pending files are deleted, and the ledger has exactly one stamp line per session.
  • Confirmed the new test fails on main (without the fix) and passes with it.
  • pnpm run test:ts — 715/715 pass.

🤖 Generated with Claude Code


Open in Devin Review

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>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@willwashburn willwashburn merged commit 53eeda3 into main Apr 28, 2026
2 checks passed
@willwashburn willwashburn deleted the worktree-issue-162-pending-stamp-cross-contamination branch April 28, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cli: pending-stamp resolution cross-contaminates tags when two same-harness runs share a cwd

1 participant