Skip to content

Gate terminal lifecycle transitions with a coordinator#12856

Draft
vorporeal wants to merge 2 commits into
david/centralize-normal-lifecycle-mutationsfrom
david/add-block-lifecycle-coordinator
Draft

Gate terminal lifecycle transitions with a coordinator#12856
vorporeal wants to merge 2 commits into
david/centralize-normal-lifecycle-mutationsfrom
david/add-block-lifecycle-coordinator

Conversation

@vorporeal

@vorporeal vorporeal commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Description

Stack PR 5/8; depends on #12855.

Context

Centralizing mutations makes recovery implementable, but it does not by itself prevent invalid evidence from reaching those mutations. Lifecycle hooks still need one authority that understands the current phase, compares incoming evidence with live block state, and decides whether to apply, coalesce, reject, or eventually recover a transition. Command starts must pass through the same authority because accepting a duplicate or invalid start can also set controller state and write bytes to the PTY.

Approach

This PR introduces a private BlockLifecycleCoordinator with an exhaustive, pure transition planner over lifecycle phase, live snapshot, and incoming input. TerminalModel gathers the evidence, asks the coordinator for an action, applies that action through the centralized pipeline from #12855, and only then commits the next phase. Local, shared-session, bootstrap, and in-band start intents are routed through the same gate before model mutation or PTY writes.

Several safety rules apply unconditionally: duplicate or colliding completion identities are rejected, unsafe prompt-only evidence cannot reach mutation paths, repeated starts coalesce, and starts while already executing are rejected before bytes are written. The PR also adds structured, non-UGC, rate-limited diagnostics and introduces TerminalLifecycleRecovery disabled by default. Transitions that would require state-mutating recovery remain ignored while that flag is off.

Review guidance

  • Is every lifecycle hook and command-start entry point gated before it can mutate model/controller state or write PTY bytes?
  • Is the transition planner exhaustive, and does it reconcile stale coordinator state against the live snapshot conservatively?
  • Are unconditional safety rules independent of the recovery flag, while state-mutating recovery remains disabled?
  • Are diagnostics sufficiently useful, rate-limited, and free of user-generated content?

Testing

  • Added exhaustive transition-matrix and phase-reconciliation coverage.
  • Added telemetry allowlist/rate-limit, controller write-gating, shared-session, and normal-flow parity coverage.
  • Final-stack validation: cargo check -p warp --tests, ./script/format, and git diff --check.

vorporeal commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

vorporeal and others added 2 commits June 20, 2026 00:21
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
@vorporeal vorporeal force-pushed the david/centralize-normal-lifecycle-mutations branch from 4b956c1 to bc95293 Compare June 20, 2026 05:14
@vorporeal vorporeal force-pushed the david/add-block-lifecycle-coordinator branch from d5c5fd1 to 1ea3538 Compare June 20, 2026 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant