Repository navigation
Closed
Labels
app/worktree-reaperinfra/worktree-reaperinfra/worktree-reaperarea/infraInfrastructure, deployment, and operationsInfrastructure, deployment, and operationskind/bugSomething isn't working (prefixed form of the classic bug label)Something isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)Ordinary priority (the default)source/creatorFiled by the new-issue-creator jobFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted testsQueue packet kind: bounded fix with reproduction and targeted tests
Description
worktree-reaper: run-log filename collides for same-second runs — the gate test suite fails 6/6 and a second run's audit log overwrites the first
Evidence (verified this run, laptop primary @ af0847d)
The reaper names its per-run decision log with second resolution plus the process id:
infra/worktree-reaper/bin/worktree_reaper.py:542—ts = time.strftime("%Y%m%dT%H%M%SZ", time.gmtime(int(now)))infra/worktree-reaper/bin/worktree_reaper.py:603—log_path = os.path.join(state_dir, "runs", f"run-{ts}-{os.getpid()}.jsonl"), opened"w"at :605.
Two runs started in the same second by the same process therefore share one
log path: the second run truncates and rewrites the first run's log.
The gate suite drives the reaper in-process
(infra/worktree-reaper/tests/test_worktree_reaper.py, ReaperRun.run),
and discovers a run's decisions by diffing the runs/ directory listing
before/after. When a run's log path already exists (same second, same pid),
the diff is empty and the run returns {} decisions, so assertions die with
KeyError on the tree path.
Reproduction (laptop, current main):
python3 -m unittest discover -s infra/worktree-reaper/tests— FAILED in
6 of 6 consecutive full-suite runs (1–2 errors each:test_03_reap_matrix
KeyError at test line 234 on the patch-equivalent tree,test_04_quiet_gate
KeyError at test line 253 on the fresh tree). Each test passes standalone.- Micro-repro with the suite's own harness: two
runner.run()calls in the
same second produced exactly one log file
(run-20261105T002713Z-57087.jsonl); the first run returned its tree's
decision, the second returned[]decisions while overwriting the file.
Why it matters
- The suite is the only gate-logic coverage for a tool that deletes
worktrees and branches, and it is effectively red whenever runs land in
the same second — so nobody can trust a green/red signal from it (it is
also not wired into any workflow, so the failure is invisible until a
human runs it by hand). - In production the same naming means two invocations that share a pid in
one second (pid reuse, wrapper re-exec) silently lose the first run's
audit log — the only record of what the reaper deleted and why.
Acceptance criteria
- Run-log filenames are unique per run even for same-second, same-process
invocations (e.g. sub-second component, monotonic sequence, or exclusive
create with a disambiguating suffix); a second run never truncates a
previous run's log. python3 -m unittest discover -s infra/worktree-reaper/testspasses 10
consecutive full-suite runs on the laptop.- A regression test (or the existing gate tests run back-to-back) covers
two runs in the same second both producing readable decision logs.
Metadata
Metadata
Assignees
Labels
app/worktree-reaperinfra/worktree-reaperinfra/worktree-reaperarea/infraInfrastructure, deployment, and operationsInfrastructure, deployment, and operationskind/bugSomething isn't working (prefixed form of the classic bug label)Something isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)Ordinary priority (the default)source/creatorFiled by the new-issue-creator jobFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted testsQueue packet kind: bounded fix with reproduction and targeted tests
Activity
developing-today commentedon Nov 5, 2026
CODE-1416
dezren39 commentedon Nov 5, 2026
🤖 Agent note · filed
run-{ts}-{pid}.jsonl(worktree_reaper.py:542/:603) has only second resolution, so same-second in-process runs share one path — the second run truncates the first run's audit log and the test harness's directory-diff read returns no decisions (KeyError in test_03_reap_matrix / test_04_quiet_gate). Micro-repro with the suite's own harness: two runs in one second produced one log file; the second returned zero decisions.issue-worktree-reaper-runlog-collision.mdin the goal's hidden_files.fix(worktree-reaper): unique run-log name per run (#5716) (#5718)
dezren39 commentedon Nov 5, 2026
🤖 Agent note · done
"x"), and residual clashes get a numeric suffix — a run can never truncate a previous run's audit log. NewRunLogCollisionTestspins two back-to-back runs both logging.issue-worktree-reaper-runlog-collision.mdin the goal's hidden_files.