Gate terminal lifecycle transitions with a coordinator#12856
Draft
vorporeal wants to merge 2 commits into
Draft
Conversation
This was referenced Jun 20, 2026
Contributor
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Jun 20, 2026
Co-Authored-By: Oz <oz-agent@warp.dev>
Co-Authored-By: Oz <oz-agent@warp.dev>
4b956c1 to
bc95293
Compare
d5c5fd1 to
1ea3538
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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
BlockLifecycleCoordinatorwith an exhaustive, pure transition planner over lifecycle phase, live snapshot, and incoming input.TerminalModelgathers 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
TerminalLifecycleRecoverydisabled by default. Transitions that would require state-mutating recovery remain ignored while that flag is off.Review guidance
Testing
cargo check -p warp --tests,./script/format, andgit diff --check.