Files
pipelines/docs/notes/session-export-handoff-gate.md
T

2.8 KiB

Session export handoff gate

Production model visits may publish their output to subsequent stages only after their exact recorded native session has settled and a complete, nonempty, nontruncated export file has passed normal-file and size verification. Ownership reads and final export attempts have bounded contexts independent of execution cancellation. Unconfirmed cleanup never exports or advances.

An export failure retains the computed step, outcome, target, output and file evidence. The run parks nonterminally in waiting, with export_pending_sequence identifying the computed visit and no finished_at. This is not a human decision or a model failure. A separate session_export_gates checkpoint is committed with the step and its existing durable export job. Model retry is refused for that checkpoint: recovery reads only the original session. Missing exact ownership cannot be reconstructed or guessed and remains blocked.

The checkpoint reserves the workspace durably even though no agent is executing. SessionExportReservations supplies those reservations to launch admission; PendingSessionExportGate(runID, sequence) identifies the exact quiescent visit eligible for export-only repair. Cancellation releases the reservation without discarding or replaying the computation, and prevents automatic continuation. The repair handler must permit waiting only when that predicate is true for the requested sequence; unrelated human/resource waits remain ineligible.

Both CLI wait paths keep waiting for export recovery; run --wait still pauses for genuine human decisions. Lifecycle events carry the same pending sequence, and a lifecycle frame with zero/absent sequence clears it. Status-less repair freshness frames leave it unchanged. Continuation is waiting -> running, never terminal -> running. Startup normalizes historical failed/interrupted export checkpoints back to waiting before clients attach.

After a successful automatic or manual repair, the worker re-verifies ownership (including backend/reference) and the actual file, then rebuilds memory, turn history and stage budgets from the recorded visits and follows the saved target. Starting the successor consumes the gate in the same transaction as BeginStep; terminal targets consume it with FinishRun. A restart before either transaction can resume the saved target, but never replays the completed owner. Cancellation, unconfirmed cleanup or an overlapping active workspace prevents continuation.

New repair files belong in the original private visit directory, not public handoff files. Historical public repair paths remain verifiable for compatibility. Only unowned injected test executors are exempt from native-session enforcement. An original computation failure routed directly to failure stays a failure even when its best-effort diagnostic export cannot be recovered.