You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
skip delayed orphan PID registration once a task has already reached a terminal state
add a regression test for the race where setStatus(..., 'complete') wins before the async getPidIdentity(...).then(...) append runs
add a patch changeset
Why
createTask() records orphan-reaper PID entries after an async process identity lookup. A very fast Copilot subprocess can become terminal before that lookup resolves. In that ordering, setStatus(...terminal...) has already removed the PID entry, but the delayed append can write the completed task back into the orphan PID file.
That leaves stale orphan-reaper state for a task that is no longer running. Checking the current task status immediately before append keeps the existing running/cancelling behavior while avoiding terminal-task resurrection in the pid file.
Validation
bun test tests/task-registry.test.ts tests/pid-file.test.ts
bun run test:unit
bun run typecheck
bun run lint
bun run build
npm pack --dry-run --json
Note: local bun test / bun run test:tui on my macOS+Bun 1.3.14 environment hits a Bun SIGTRAP after visible TUI tests start; the touched runtime/unit suites above pass and cover this change.
This PR is from a first-time contributor, so GitHub Actions CI has not yet been authorized to run on the codex/skip-terminal-pid-append branch. As part of today's autohealing pass I checked out the branch and ran the full local CI matrix against main's toolchain.
Local CI results
Check
Result
bun install
✅ clean (no peer warnings)
bun run typecheck
✅ clean
bun run lint
✅ clean (63 files)
bun run build
✅ clean
bun test tests/\*.test.ts
✅ 322 pass / 0 fail (1 new regression test added by this PR)
bun test tests/task-registry.test.ts
✅ 10 pass / 0 fail
bun test tests/pid-file.test.ts
✅ 25 pass / 0 fail
Change assessment
The diff adds a terminal-status guard before the deferred PID-file append in createTask() (src/runtime/task-registry.ts). When getPidIdentity(...) resolves after setStatus(..., 'complete' | 'failed' | 'cancelled', ...) has already removed the PID entry, the append is now skipped, preventing resurrection of an orphan-reaper entry for a task that's no longer running. The new test does not append to the PID file after a terminal transition wins the spawn race reproduces the race and asserts no stale entry appears. The changeset (.changeset/quiet-plants-train.md) is present and correct.
Note
This comment is a CI verification pass, not an approval — a maintainer still needs to approve workflow runs to trigger the hosted CI on this branch. No code changes were made here by the autohealing agent.
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
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
setStatus(..., 'complete')wins before the asyncgetPidIdentity(...).then(...)append runsWhy
createTask()records orphan-reaper PID entries after an async process identity lookup. A very fast Copilot subprocess can become terminal before that lookup resolves. In that ordering,setStatus(...terminal...)has already removed the PID entry, but the delayed append can write the completed task back into the orphan PID file.That leaves stale orphan-reaper state for a task that is no longer running. Checking the current task status immediately before append keeps the existing running/cancelling behavior while avoiding terminal-task resurrection in the pid file.
Validation
bun test tests/task-registry.test.ts tests/pid-file.test.tsbun run test:unitbun run typecheckbun run lintbun run buildnpm pack --dry-run --jsonNote: local
bun test/bun run test:tuion my macOS+Bun 1.3.14 environment hits a Bun SIGTRAP after visible TUI tests start; the touched runtime/unit suites above pass and cover this change.