Skip to content

Ticket #229: prompt immediately after adoption — verification ​

  • Date: 2026-11-11
  • Branch: ticket/229-adoption-race
  • Spec: parent #209; ticket #229 (found by #227)
  • ADRs: 0009, 0010
  • Unit gate: npm run verify (strict typecheck + full test suite)

Root cause ​

The adoption heads-up is a synthetic host turn. A prompt sent before that turn settles is steered into the same host execution: the host emits one session.execution.started, one session.inbox.delivered for each inbox, two assistant messages, and one session.execution.succeeded. Measured order on OpenCode 2.2.7:

synthetic enqueue -> execution.started -> synthetic delivered
-> user prompt enqueue -> text.started (heads-up answer)
-> text.ended -> prompt delivered
-> text.started (prompt answer) -> text.ended -> execution.succeeded

The ingestor attributed every new assistant message to the session's active turn, so the prompt's answer was appended to the heads-up turn. The single terminal event then settled only the heads-up turn; the prompt turn stayed native.phase: "queued" with its durable user row and no execution owner.

Fix ​

The service now tracks, per session and in memory only:

  • nativeExecutionTurns — the turns answer-ordered inside the current host execution;
  • nativeSteeredInboxes — queued turns the host delivered into an already-running execution.

When session.inbox.delivered names a queued native turn while another turn is answering, it becomes a steered candidate. The next new assistant message claims that turn (existing assistant-message identity still wins), and the turn joins the execution. At session.execution.succeeded, every open participant settles in answer order, each with its own exact durable agent row and replied phase. Failure and interruption settle the same participant set.

Candidates that never receive an assistant message are discarded at the terminal event, so a genuinely queued prompt still runs in its own later execution. Both maps are bounded by the session's live work and cleared on terminal, service stop, and turn cleanup.

Regression ​

src/v2/service.test.ts: ticket229: a prompt sent immediately after adoption settles as its own native turn. The test adopts an existing root session into a workspace group conversation, then replays the measured host order above. It asserts both turns settle replied, each owns exactly one assistant message id and one exact agent row (Heads-up answer., Prompt answer.), one durable user row belongs to the prompt turn, the cards are visible Work, and no row is shared or duplicated.

Live check ​

The #227 driver now prompts immediately after adoption instead of waiting for the heads-up to settle. npm run test:live:native-first on this branch:

  • adoption scenario: pass — the prompt turn settles replied with its own result while the synthetic heads-up settles separately;
  • main phase: 64/65 checks, restart phase: 16/16 checks;
  • the only remaining main-phase failure is attachment chip carries a size (pre-existing #228), and the recorded shadow-mode gap is #230.

This record therefore provides live evidence for #229; it does not claim #228 or #230.

Gate ​

npm run verify result on this branch: strict typecheck passed; 1799 tests passed, 0 failed, 0 skipped.

Released under the MIT License.