goal-verification-divider.md 5.4 KB

Goal Verification Divider

Scope

Goal-mode completion verification is shown in the conversation as a compact synthetic divider. It is a post-turn boundary, not an assistant worklog item, so it must not be folded into the "worked for xxx" assistant history area.

The visible states are:

  • started: goal verification is running.
  • completed with passed: false: the goal is incomplete and the task continues.
  • completed with passed: true: the goal is complete and the task ends.
  • failed_closed with passed: true: the verifier infrastructure failed open, so the goal is complete and the task ends.
  • failed_closed with passed: false: legacy or explicit failed-closed data is treated as continuing.
  • cancelled: the verifier was interrupted, so the UI shows the interruption instead of completing the task.
  • malformed verifier JSON: the verifier attempt is invalid, but contracts fail open to passed: true and preserve the parse-failure reason.

Clicking the divider opens the summary panel. The divider text is generated by the UI from structured timeline metadata; verifier text is not rendered as assistant message content.

Persistence

The source of truth is the durable goal verifier lifecycle record. Runtime emits target_completion_verification lifecycle events with targetId, verificationId, status, goalIteration, optional anchorTurnId, optional anchorAssistantMessageId, and an optional verifier result. Those lifecycle facts must be recoverable after a cold restart.

The session reducer projects those events into targetCompletionVerificationTimeline. Bootstrap exposes that projection through runtime.goalVerificationTimeline, and the UI restores it into synthetic assistant messages when building a task snapshot.

Normal completed verifier summaries still come from the existing model_complete event with querySource: "target_completion_verification". Failed-closed and cancelled verifier lifecycles add their verification result to the summary ledger because those paths do not have a successful model_complete result; failed-open records keep passed: true, while cancelled records stay cancelled.

Iteration Ownership

Goal iteration count is owned by the verifier lifecycle. A new iteration is counted only when a target_completion_verification lifecycle is started. User interruptions, manual "continue" prompts, normal runtime turns, TodoWrite snapshots, and model-only goal-continuation turns must not advance the displayed goal iteration by themselves.

The UI row identity is goal:${targetId}:iteration:${goalIteration}. verificationId is a verifier attempt id and must not create another visible row for the same iteration. A started event and its terminal completed / failed / cancelled event update the same divider.

The divider is anchored after the assistant output that the verifier evaluates. New lifecycle events should include anchorTurnId and, when available, anchorAssistantMessageId. Old data without anchors may fall back to timeline time and nearest assistant output for compatibility only.

The UI may still create a local streaming assistant container when a model-only goal-continuation turn starts, so live chunks do not merge into the previous assistant message. That container uses a UI-only stream group and must not provide goalIteration. If a live lifecycle event lacks goalIteration for compatibility, the divider falls back to the existing verifier divider count, not to assistant message numbering.

Model-only goal-continuation turns can reuse the original user inputId across multiple automatic iterations. The projected goal_iteration_started event therefore carries the runtime turnId when available, and the UI uses turnId before inputId as the streaming boundary key. This keeps adjacent automatic iterations in separate assistant containers without changing visible input ownership or verifier-owned iteration numbering. Mirror/replay paths that do not have a turnId continue to fall back to inputId or traceId.

goalStats.iterationCount follows the same verifier lifecycle rule, but consumers must distinguish the last verified iteration from the currently open iteration. Before the first verifier, active-goal work is iteration 1. After verifier N fails and the goal continues, subsequent work belongs to iteration N+1 until the next verifier, even if the user sends visible prompts in between.

Todo groups describe where TodoWrite items first appeared. A todo remains under its original iteration when a later TodoWrite snapshot marks it complete; completion in a later iteration must not move it to that later iteration.

History Impact

No old task history file schema changes are required. Existing sessions keep their previous goal verification summaries, but they will not gain divider rows retroactively unless the event log contains the new lifecycle events.

New sessions persist the lifecycle facts, so refreshing, reopening history, and replayable recovery can restore the same divider status.

Remote Compatibility

The divider is projected from session runtime state and synthetic timeline chunks. It does not add a new renderer-local queue or relay-owned task state.

Desktop desktop-continuous keeps direct live delivery. Web remote web-remote-replayable restores the divider through the existing snapshot and replayable event paths, without moving session, stream, queue, or snapshot ownership into the relay or main process.