Repository navigation
fix(runtime): retire predecessor exit evidence on replacement - #32341
Merged
Merged
Conversation
When a PTY id is re-registered with a different, known incarnation, the handle was already invalidated but lastExitCode/lastExitCause (pty and leaves) still carried the predecessor exit, so a live replacement reported the old stop. Clear them at that same proven-replacement point. Same or unknown incarnation keeps the evidence (fail closed).
Clear predecessor exit evidence on the PTY and its indexed leaves when registration or provider spawn proves a different known incarnation owns it. Cover both paths so an earlier spawn cannot hide the transition from later registration. Keep same and uncertain incarnation evidence conservative. Adapted from Cubatica's original fix and regression cases in #24513; extend the coverage to spawn-first replacement on the current runtime modules. Co-authored-by: Cubatica <4414418+Cubatica@users.noreply.github.com>
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 3 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
8 of 9 tasks
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.
ELI5
A running replacement terminal could still report that its previous process had been stopped. Clear the previous process's exit details once Orca knows a different process owns the terminal.
What Changed
Retire
lastExitCodeandlastExitCausefrom the PTY and its indexed leaves at both existing proven-incarnation replacement transitions: registration and provider spawn. Spawn must be covered because it can change the incarnation before registration arrives.Before: stop incarnation A, reuse its PTY for known incarnation B, then
terminal showreports B connected with A'soperator_closecause. After: B has no exit cause until B exits. A delayed exit for A remains fenced. Same or missing identities retain the shipped conservative behavior.Why
Exit evidence belongs to the process incarnation that exited. The existing replacement branches already invalidate the predecessor's handle, but leave its exit evidence behind. The shared retirement operation adds 13 production lines and keeps the existing identity decisions.
This continues the original fix and regression cases by @Cubatica in #24513 (
f10eb5fe985be9007ddc20ed84c0401e08cf7eef), adapted to the current runtime modules and extended to the spawn-first path. The original commit remains in the history, and the adaptation includes coauthor credit.Linked Issue
Fixes #24950
Visual Proof
N/A — runtime exit provenance exposed by terminal summaries; no rendered UI changes.
Testing
Controlled red run on the current base with only the production fix removed: 2 failed, 17 passed. Both failures were the public summary inheriting
operator_close, once through registration and once through spawn. Final restored tree: 55/55 passed across exit provenance, handle incarnation, queued graph exit, and inventory lifecycle admission (160.56 seconds); an earlier fresh verification also passed 55/55.The new cases also inspect PTY/leaf evidence, reject a late predecessor exit, record the replacement's own exit, and retain evidence for same/missing/unknown identity.
The optional
ORCA_LAYOUT_OWNER=mainprovenance run passed 18 tests with one explicit skip (117.58 seconds): unknown-to-known registration already has a different policy in this unshipped mode. Both replacement paths pass. Fresh native node typecheck passed without diagnostics:Changed-code quality passed all six scans and the casting SAFETY check against
8d94ed06570a. Focused formatting/lint checks andgit diff --checkare clean. Full build and repository-wide test/lint suites were not run.Review
Independent adversarial source review found no blockers. It checked spawn-before-registration ordering, the inherited method placement, stale-exit fencing, indexed leaf access, identity preservation, and red regression evidence.
Merge risk: LOW. The original registration-only patch is incomplete on current code because an earlier spawn can consume the identity transition. Residual risk is live-provider/platform integration, which this deterministic runtime coverage does not establish.
Agent skill upstream boundary
Notes
Reliability invariant: a known replacement never inherits predecessor exit provenance; uncertain identity retains the existing policy. Oracle:
showTerminalreports the replacement connected under its own incarnation with no old exit cause, and later reports its own exit.No exact exit-provenance gate was found in
config/reliability-gates.jsonc; adjacentterminal-session.explicit-close-retirementcovers handle retirement and is not claimed as this invariant's gate. The regression file is the executable evidence. Red and green logs are retained with the local review artifacts; no new production diagnostics are needed.Cost is O(leaves for the replaced PTY) using the existing index. No new timer, RPC, subprocess, provider inventory scan, polling, or persistence work. No shell/path/platform operation changes. The unshipped main-layout path already differs on unknown-to-known registration; one preservation test explicitly skips only that pre-existing policy difference.
Checklist
pnpm lint, typecheck, test, and build matrix; targeted local gates above, CI covers the remainder.