Repository navigation
FIX-1690 (door): a person's message continues a coding run's session - #2544
Conversation
The harness manager builds a message door, `manager.messageDoor(board)`: a
public action that takes `{ message }` on a run's own session. It keeps the
turn, stops a running attempt through `ctx.session.stopRequest`, parks the
row for a turn (fenced to the stopped attempt's claim), and re-queues it.
The next attempt resumes the same coding session with the turn in its
prompt. A row waiting on a question or between attempts keeps the turn for
its next attempt; a never-started or finished task, or a harness that named
no session, is refused with a failed request.
Orchestration: `awaitReview({ forTurn: true })` parks only an in_progress
row and marks it; the claim after its unpark counts in `turnReentries` and
is not charged against `maxAttempts`.
Real-model goal goals/harness-manager/a-persons-turn-continues-its-session.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cnm5DbhFmkarpesBpPQ9Dq
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_5217831f-e2e1-4b96-a7c4-840d1ca70253) |
Second look + architecture review (read-only, no edits made)Overall the approach is sound: decide from server state only, keep the turn before the stop, fence the park to the stopped attempt's claim ticket, and share Worth fixing in this PR
Architecture notes (take as part of this PR only if cheap)
Checked and fine
I did not run the tests; this is a diff read only. Generated by Claude Code |
There was a problem hiding this comment.
Simplify review (parallel read-only pass)
Verdict: The three-way split (door.ts delivery + stop/park, turns.ts durable inbox, orchestration forTurn / turnReentries) is mostly earned, not an over-built design. The spec constraints (cross-session resume, refused vs kept lines, retry budget without burning maxAttempts, keep-before-stop crash safety) explain why “just append to session history” or “reuse the question inbox” would be thinner but wrong. The substrate changes mirror abandonments + shouldRetryOnFail discount — a good reuse of an existing pattern rather than a new mechanism.
I would not recommend collapsing this into a single manager.ts blob or folding turns into inbox; that trades file count for mixed lifecycles.
Where complexity could still shrink (non-blocking)
| Area | Suggestion | Confidence |
|---|---|---|
door.ts already-finished branch |
After line 180, row.status is non-terminal on the snapshot, so TERMINAL.has(row.status) at the fast path is unreachable — either re-read the row (or use parked.status from a later transition) or delete the branch and document that kept is intentional when the harness request ended first. |
High (logic) |
| Stop wait loop | Reuse harness-manager sleep(ms, signal) from workspace.ts instead of ad-hoc setTimeout; consider backoff or read-only request polling after the first stopRequest arm (v1 bounded poll is acceptable). |
Medium |
| DRY | Unify turnsRef / inboxRef / collectionRef resolvers; shared issuePhase prefix + 16-char hash helper with inbox; isTerminalStatus from orchestration instead of local TERMINAL set; harnessTaskInputSchema instead of local rowPayloadSchema. |
Medium |
| Tests | No coverage for stopRequest → already-finished or concurrent row settlement; takeTurns CAS/replay could use a small resource fake like inbox-fake. |
Medium |
linkedRow |
Full tasks.list() scan per message — fine for typical boards; if this becomes hot, index by run.sessionId or store taskId on the run row (orchestration run-link work is the natural home). |
Low until scale |
Performance (v1)
- Up to ~600
stopRequeststore touches per door message (100ms × 60s) is the main hot-path cost; acceptable for correctness if documented; not a reason to reject the approach. - Resource-backed
getOrCreateTaskCollection+ reconcilelist()per door delivery is inherited board cost, amplified but not introduced solely by this PR.
Alternative approaches considered
- Session-only continuation — fails retention, cross-session attempt, and refused-door semantics (
turns.tsheader is convincing). - Inbox channel for person messages — manager already separates failure / Q&A / person turn; conflating would complicate prompts and parks.
- Stop + unpark without
turnReentries— would spend retry budget; goal explicitly needs attempt 2 undermaxAttempts: 1. - Third-party retry/poll libraries — would fight CAS/resource model; not recommended.
Approval stance
No architectural blocker from this simplify lens. I'd like the already-finished / finished-first dead branch cleaned up or covered by a test before merge (small fix). Everything else reads as follow-up DRY and scale hardening.
(Automation: simplify review — no code changes pushed from this run.)
Sent by Cursor Automation: Review For Best Approach
There was a problem hiding this comment.
Code Snob. A smaller shape exists. Do not treat this as a behavior review.
Fold these three subtractions into this branch, then close #2545 unmerged after this PR lands. That POC does not merge.
- Delete
*-message-resultinpackages/harness-manager/src/door.ts. It only dropsrequeue..map(({ outcome, taskId }) => ({ outcome, taskId }))does the same thing, andmessageDoorOutputSchemastill validates the public{ outcome, taskId }. - In both
awaitReviewimplementations, make one transition call.forTurnstill forcesifAllowedandfrom: in_progress. Every other park still passes its options through. A helper shared across the two backings is longer than the two ternaries. - Delete the
finished-firstcheck in thealready-finishedbranch. Thatrowis the snapshot from before the stop, and a terminal snapshot already threwtask-finished. A finish during the stop is still refused when the fenced park declines.
Left alone on purpose: parkPatch / unparkPatch (the shared write), the turns collection (a different lifecycle from the inbox), and workspace.ts's private sleep (exporting it to wrap one setTimeout adds a surface, and abort-during-sleep would change the wait).
Same contract on the checks I ran: message-door 10 passed; fences 4 passed; turn-reentry 10 passed on both backings. The two-turn case also fails on this head (c36e84272) in that environment, same finished-first, so it does not distinguish the POC.
Sent by Cursor Automation: Code Snob
…r refused A second line whose door woke after the next attempt had already finished with it was refused as finished-first, though that attempt acted on it. And a door that refused after keeping its turn left the turn for a later attempt. Both are one fix: a refusal after the keep withdraws the turn with a conditional write against takeTurns; a turn an attempt already took answers continuing instead. Reproduced deterministically by holding the second door's stop until the row reads completed (red: finished-first), and by re-opening a row after a finished-first refusal (red: the later prompt carried the line). Controls: never withdraw, take withdrawn turns, withdraw ignoring delivery each fail. Review folds: POC #2545's single awaitReview call per backing and .map result; already-finished answers kept; isTerminalStatus over a local set; the stop wait backs off (100 ms to 1 s) on workspace's sleep; the re-queue step is typed without a cast; turns and the inbox share issuePhasePrefix and hashKeySegment; AwaitReviewOptions moved off TaskTransitionOptions' docblock; the unwired stopWaitMs is gone. V4 rerun on real Claude Code: PASS. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cnm5DbhFmkarpesBpPQ9Dq
|
Response to the second look (all in 24e5b16, which also merges main now that #2538 has landed; one correction in 829c2c2, marked below):
Rerun: harness-manager 187/187, orchestration 1577/1577, typecheck, knip and lint clean. V4 on real Claude Code passes again after these changes (same session on both attempts, fact file written). Generated by Claude Code |
…stored (BR-11) When the attempt finished on its own between the door's read and its stop, the door answered kept for a task that had already completed, so the person saw delivered and nothing would act on the line. The board this request resolved is a snapshot; a no-op conditional update reads the committed row and writes nothing. A settled row is refused finished-first (and the turn withdrawn); anything else stays kept, which is also what an Interrupt gets (BR-17). Red first: staged by holding the door's stop until the attempt settled. Controls: no fresh check, the snapshot instead, and an update that writes each fail. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cnm5DbhFmkarpesBpPQ9Dq
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_0fa15de6-7245-494f-92b1-0927f59db543) |
…ort (FIX-1690) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cnm5DbhFmkarpesBpPQ9Dq
|
@codex review this |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
… never not-delivered
- The door re-queues the row and dispatches the board's drain (an internal
entry the flow declares, `messageDoor({ drain })`) into the session that
claimed the row, so every message no longer moves the run one session deeper.
- A message between a claim and its run linking is kept for that attempt,
found by the run record's session (now written at the open).
- A failed re-queue or drain after the park, and a stop that outlasts the wait,
answer `kept` instead of failing the request. The lapse after a slow stop is
FIX-1705.
- conductor's `message` passes the tenant gate first, like every other action.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cnm5DbhFmkarpesBpPQ9Dq
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_75f37ad0-6475-4b46-8c29-cfa56924b7b9) |
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cnm5DbhFmkarpesBpPQ9Dq
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cnm5DbhFmkarpesBpPQ9Dq
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cnm5DbhFmkarpesBpPQ9Dq
Post-merge amendment of the retained closure spec (original review #2426): - names, paths and commands follow the Shift Manager rename (#2588) - leg c sweeps the promised set: message, reasoning, tool, code block and ask cards, plus the devtool page (#2532) - a4 targets eng.coder's running task session (FIX-1690: #2538/#2544/#2565) - Part 4's Inbox reply is graded on FIX-1690's test seat (#2525) - a2 runs without --devtool; Shift Manager serves its own (#2531) Recorded in DECISIONS -> How it got here, and a new EVOLUTION.md. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cnm5DbhFmkarpesBpPQ9Dq


The problem
A person can't talk to a coding run while it works. If they notice something mid-run, their only options are to wait for it to finish or to interrupt it. An interrupt throws away the conversation the run had built up.
What this does
This is the second of three PRs for FIX-1690. The harness manager now builds a message door: a public action a coding flow declares.
You send it
{ message }on the run's own session. What it does depends on the task's state:ctx.session.stopRequest), parks the row for a turn, re-queues it, and dispatches thedrainentry into the session that claimed the row. The next attempt runs in the run's own session again and resumes the same coding session with the message in its prompt. Answerscontinuingkept, never a failure that would invite a resendkeptkeptTurnRefused, so only a delivered message ever completes. A refused message is withdrawn, so no later attempt takes itA turn doesn't spend a retry. In orchestration,
awaitReview(id, note, { forTurn: true })marks the park. The claim after itsunparkis counted in a newturnReentriesfield and discounted frommaxAttempts, the same way an abandonment is.The DevForce/App Lab wiring and the composers come next, in
lab. This PR stops at the manager, the substrate and the conductor lab.What's asked of you
Nothing new. This implements the approved spec's S3–S7, with both forks resolved to the recommended answers: stop-and-continue for every harness, and a fixture seat for the App Lab goal (in
lab).There is one place where the build departs from the plan's mechanism. It does not change the promise, so it is listed under engineering calls and is not asked here.
Parts worth reviewing closely
For the code reviewer.
Who parks the stopped attempt (
packages/harness-manager/src/door.ts,continueRun). The plan expected the stopped attempt to park itself. It can't: a stopped request endsaborted, and its sequencer's rescue does not run. So the door parks the row instead:A stop that finds the attempt already over reads the row as stored (
storedStatus). The board this request resolved is a snapshot, so a row the attempt settled since still reads as running there. A no-op conditional update reads the committed row and writes nothing. A settled row is refused (BR-11); anything else is kept, which is what an Interrupt gets (BR-17).A refusal after the keep withdraws the turn (
turns.ts,withdrawTurn). It is a conditional write againsttakeTurns, so exactly one of them wins. If an attempt already took the turn, the door answerscontinuinginstead of refusing. This closes a race the review surfaced: a second line whose door woke after the next attempt had already finished with it was refusedfinished-first.The
forTurnpark runs only fromin_progress(resource-backed.ts/sequencer-backed.ts, one call each). Without this fence, a row that re-pended in the race threw an illegalpending → parkedtransition instead of declining.turns/**(packages/harness-manager/src/turns.ts). Each turn is a create-only row keyed by the request that kept it, and kept forattempts + 1. An attempt takes every undelivered, unwithdrawn turn up to its own number, oldest first, with a conditionaldeliveredTowrite. A replay of the same attempt reads the same set.My weak spot: the races are staged in the CI spec.
completed.Each is how a loaded machine can order things, made certain. None is a race that happened on its own.
Engineering calls
messageDoor({ drain, flowKind? })is a factory, not the bare property DOCS.md shows.drainnames aninternalentry that runs the board's drain. The door dispatches it into the row'sclaimedBysession, which is where the hand-off derives the run's session from. Draining in the door's own session (the first cut) put every next attempt one session deeper.flowKindis for a board drained by another flow, which is DevForce's case: the EM drains and hands off to the coder seat. If wrong: a rename, pre-1.0.continuing, because the attempt acted on it. Refusing would tell the person it didn't arrive.in_progress, so a repeat is idempotent. Adding a read-only request read to the session handle would widen the stop PR's API. The poll backs off instead.childSessionIdnames this session. The record now writes that at the attempt's open, not only at the verdict, because a stopped attempt never reaches the verdict. That fallback lists the user's run records, and only runs when no row links the session.keptafter the 60 s wait, but the row staysin_progressuntil its lease lapses, and that recovery counts an abandonment. The fix needs a substrate mark the recovery claim reads, so it is filed as FIX-1705 rather than done here.messagenow passes the tenant gate first, like every other conductor action.parkedForTurn,turnReentries,forTurn). The plan's S3 describes the concept the same way ("a park-for-turn reason", "re-entries after a turn"), andreadTurnReentriessays it mirrorsabandonments. A rename to a genericparkReasonis possible pre-1.0 if a second caller appears.docs-writer/docs-editorwere not run.Verification
V2,
packages/orchestration/test/collection/turn-reentry.test.ts: 10/10 tests, 5 cases on each of the two backings.maxAttempts − 1still retries after a turn.Controls:
maxAttempts − 1case fails on both backings.in_progressfence dropped, the decline case fails on both backings withIllegalTaskTransitionError: pending → parked.V3,
packages/harness-manager/test/message-door.spec.ts: 18/18 tests, all using the stub harness. Five were added in the second review round, and each was red one39b696c3:kept(red: refused "hasn't started")kept, the row stays parked for a turn, and the next re-queue runs the line (red: the request failed)kept, the row is queued, and the next drain runs the line in the same session (control: ignoring the refusal answerscontinuing)keptandcompleted(red: refusedstop-timeout)Controls for the round: draining in the door's own session fails the two-message case on the session id. A flow without the
resumeentry is refused bydefineFlow, naming the entry.labs/conductorgains a foreign-tenantmessagetest that is red without the gate. The earlier cases:continuing, notfinished-first(BR-10)Red before the fix:
c36e842, the BR-10 race case refused withThe task finished before your message reached it.c36e842, the BR-11 re-open put "too late" in attempt 2's prompt.24e5b160b, the BR-11 settled-before-the-stop case completed for a finished task.Controls:
already-finished, or the snapshot read instead: the BR-11 settled-before-the-stop case fails.One mutation does not fail the suite: keeping the turn for
attemptsinstead ofattempts + 1passes. The+1guards a race the stub can't stage (a turn kept before attempt N's prompt step ran).V4, real Claude Code (Agent SDK),
goals/harness-manager/a-persons-turn-continues-its-session/: PASS, four runs. The latest is on the second review round, with a new signal 6: read after delivery, the row's run link names the session the turn was sent into. Its control drains in the run's own session, and it FAILS at signal 6 only. (Thealready-finishedchange is off V4's path, which goes through the stop wait.)continuing.maxAttempts: 1.972ce899-…on the third run). The fourth was run without clearing the parent session's variables, so it reports the parent's id, as the caveat below says. Signal 3, the fact file, is the one that discriminates, and it passed.Control: with the resume feed returning null, the goal FAILS at its named signals. The sessions differ, the fact file is not written, and the row errored.
Running this goal inside a Claude Code session needs the parent session's variables cleared, or the SDK reports the parent's session id. The goal's README says how.
Fast checks:
pnpm typecheck: passes.pnpm knip:ci: clean.pnpm lint: clean.Files
packages/orchestration/src/tasks/schema/task.ts:parkedForTurnandturnReentries.packages/orchestration/src/tasks/collection/{internal,types,resource-backed,sequencer-backed}.ts,tasks/index.ts:AwaitReviewOptions.forTurn, thein_progressfence and the discount.packages/harness-manager/src/{door,turns,manager}.ts: the door, theturnscollection with withdrawal, and the prompt fold.packages/harness-manager/src/{workspace,inbox}.ts:issuePhasePrefixandhashKeySegment, now shared by turns and the inbox;sleepexported for the stop wait.labs/conductor/src/flow.ts:message, behind the tenant gate, and an internalresumedrain.packages/harness-manager/src/run-record.ts:childSessionIdwritten at the open;findRunRowBySession.goals/harness-manager/a-persons-turn-continues-its-session/: V4.fences.spec.ts, which now sweeps the new goal's spawns.apps/docs/docs/orchestration/harness-manager.md("Talking to a run", plus a Limits bullet)..changeset/harness-manager-message-door.md: orchestration and harness-manager, minor.Part of FIX-1690 (S3–S7) · spec:
specs/issues/FIX-1690/· spec PR #2525 · previous: #2538 (stop, merged) · next:lab. Based onmain; it carries onlydoor.🤖 Generated with Claude Code
https://claude.ai/code/session_01Cnm5DbhFmkarpesBpPQ9Dq