Repository navigation
fix(kernel): recover when a phase worker ends without its result block (#407) - #413
Merged
rochecompaan merged 7 commits intoNov 22, 2026
Conversation
…er-when-an-implementation-worker-finishes-w # Conflicts: # .patchmill/skills/patchmill-skill-pack.json # src/kernel/verify.ts
rochecompaan
marked this pull request as ready for review
November 22, 2026 17:26
rochecompaan
deleted the
agent/issue-407-recover-when-an-implementation-worker-finishes-w
branch
November 22, 2026 17:30
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.
Closes #407
Summary
A phase worker can end normally without its final fenced
jsonresult block. Before this change, Patchmill then stopped the run asneeds-infowithno result. This PR:output.mdwhen the message has none. The five failed runs (Prepare the kernel for control-plane mode #357, Add a local patchmill run loop for one runner per clone #398, Show an issue's spec, plan and mockups on the live web issue page #384, Show who is on a web issue page and who is typing #386, Include the issue slug in spec and plan branch names #377) did end their last message with a valid block, but the launcher parsed the proseoutput.mdreport instead.promptover the open RPC session (startPiRpcremindoption). Interactive runs useclient.resume(createWorkerLauncher). A non-zero exit, timeout, abort, error or truncated response, crash, or failed orhandledfirst prompt gets no reminder (Fail a phase when Pi exits abnormally after a done result #374).verifyOutcome, implementation phase only, exit 0, no timeout or abort): an open, ready PR on the right base that closes the issue counts asdone, with the warningthe worker ended without a result block, so Patchmill verified the ready pull request. An interactive run then enters the review wait. Otherwise the run stops asneeds-infowithThe worker ended without a result block[, also after a reminder]. The repository does not prove completion. <diagnostics>.Spec:
docs/specs/2026-11-22-issue-407-recover-when-an-implementation-worker-finishes-w-design.mdPlan:
docs/plans/2026-11-22-issue-407-recover-when-an-implementation-worker-finishes-w-plan.mdRulings
worker-launcher.ts(rebind, then theinterrupted()check, then stop the new id). The deadline and shutdown regression tests cover it. Cost if wrong: a shutdown during the reminder resume could leave a resumed worker running.completecompletions and falls back tooutput.md. Cost if wrong: an interactive worker whose last message has a stale block would be read from that block, not fromoutput.md.c274a36(parseAgentResult(text, { reminded })inresult.ts, one prompt classification inpi-rpc.ts).handledreminder prompt untested): accepted, fixed inc274a36with fake-Pireminder.promptErrorandreminder.handledtests.copySessionhandles both a new file and an appended file. Cost if wrong: the copied session misses the reminder turn, but the result text still comes from the completion.client.resumereturns a new id: accepted as is. Guidance resumes already rely on it. Cost if wrong: the reminder would return the first completion, which then falls back to the PR facts.resumeafter start: accepted as is. The spawn path has the same exposure. Cost if wrong: one orphan worker that the operator must stop.stopReasonof the last message: accepted as is. Onlycompletecompletions read it and a block must be closed to parse. Cost if wrong: a truncated message with a closed block is used.main:origin/main(Fail a phase when Pi exits abnormally after a done result #374, Implementation worker ends without a result while its reviewer is still running #388, Pi 1.6.0) is merged incaf982e.verifyOutcomekeeps the Fail a phase when Pi exits abnormally after a done result #374 abnormal-exit check for adoneresult and the missing-block fallback now also requires no signal.explainMissingResult(Implementation worker ends without a result while its reviewer is still running #388) now keys onmissing: trueand appends its cause to the new reason. Cost if wrong: a Implementation worker ends without a result while its reviewer is still running #388 diagnosis would not show in a missing-block stop.Deferred Minor findings
verify.ts: makemissingResultBlocka type predicate to drop the redundant!result.oknarrowing.worker-launcher.ts: useinterrupted()for both post-bind checks (after spawn and after resume).Validation
On the final head
caf982e:npm test: passed, 1703/1703.npm run lint(prettier, eslint, markdownlint): passed.npm run build: passed.patchmill-implementation/SKILL.mdcopies have sha256122b62b2…54eb1, which matches the manifest.Frontend review
Not applicable. The change is kernel, console worker launcher, envelope, and skill text, with no browser-visible UI.
Human Reviewer Callouts (Non-Blocking)
parseAgentResultmissing-block reason changes fromno resulttoThe worker ended without a result block.(plusmissing: true). Any external tooling that matches the old reason text in stop comments would break.parseJsonBlockkeepsno resultfor triage.donekeepsstatus: "invalid"in theresult.jsonsession record. The spec intends this..patchmill/skills/patchmill-skill-pack.json).