Skip to content

Close run-lifecycle races R1-R3, R5-R8 (#1430 Phase A) - #1609

Merged
currentbits merged 1 commit into
mainfrom
coder/p1-close-eight-run-lifecycle-races-doubl-fc27bb
Oct 12, 2026
Merged

currentbits merged 1 commit into
mainfrom
coder/p1-close-eight-run-lifecycle-races-doubl-fc27bb

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Phase A of #1430: targeted fixes with no lock. R4 and the Phase B transition lock are left for a follow-up.

Race Fix
R1 The orchestrator hop (pendingFork, /handoff-style dispatch) holds a preparing entry via holdForHop. A second send gets "already active", worker notices queue and flush when the hop clears, and Stop lands. If Stop hits mid-hop, a worker that slipped past stopCrew is stopped, and dispatch starts no more workers. Notices never take the fork path.
R2 Verify is an active entry {kind:"verify"}. Stop kills the command through a new signal option on runVerifyCommand, a start during verify is refused, and releaseVerify gates every status write on still owning the entry.
R3 The checkpoint is awaited before finishSuccessfulTurn. The duplicate drain at the end of notifyRunTerminal is removed, so the queued follow-up starts after the commit.
R5 A throw after the preparing entry is registered clears it and marks the thread failed (only while the entry is still ours and still preparing).
R6 codexSessionHeld counts a preparing entry on a Codex thread.
R7 git:mergeWorktree and git:removeWorktree refuse while runner.isRunning.
R8 steerRun throws instead of filing the steer row when the run changed during the send.

Behaviour notes

  • Verify and the orchestrator hop now count toward maxConcurrentRuns.
  • A Stop during the hop keeps the worker (stopped). The lead's prompt and fork event then appear after "Run stopped".
  • R7 checks the runner only, not a possibly stale working status, so a crash-stale status can't block manual cleanup.
  • R3 orders only the queued drain. A direct send during the checkpoint can still start right away; Phase B covers that.

Tests

There is one regression test per race in stop-during-prepare, orchestrator-threads, verify-gate, checkpoints, codex-writer-lock, orch-merge (R7) and codex (R8). All 10 fail on the pre-fix source. runner.test.js's sweep test now waits for the post-checkpoint sweep.

npm run test:electron (CI-like env, rebased on 3b650a5): 4664 pass, 6 fail. None of the failures come from this change:

  • store.test.js round-trip and automation-create-mcp GitHub trigger also fail on main.
  • The 4 Grok MCP config failures (grok.test.js / mcp-inject.test.js) pass when those files run alone, on this branch and on main.

Refs #1430

🤖 Generated with Claude Code

- R1: the orchestrator hop (pendingFork, /handoff etc.) holds a preparing
  entry; a second send bounces, notices queue, Stop lands and stops a
  worker that slipped past stopCrew. Notices never take the fork path.
- R2: verify is an `active` entry; Stop kills the command, starts bounce,
  and only the owning gate writes status.
- R3: await the checkpoint before finishSuccessfulTurn; drop the duplicate
  drain in notifyRunTerminal so the queued turn starts after the commit.
- R5: a throw after the preparing entry is registered clears it.
- R6: codexSessionHeld counts a preparing Codex launch.
- R7: git:mergeWorktree / git:removeWorktree refuse a running thread.
- R8: steerRun files no row when the run ended during the send.

R4 and the Phase B transition lock are not included.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-12T13:28:36.493441Z c07e696 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@currentbits
currentbits merged commit 10329b7 into main Oct 12, 2026
4 of 6 checks passed
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.

1 participant