Repository navigation
Local PTY inspection: degraded reads become unverifiable evidence, not agent exits - #16955
brennanb2025 wants to merge 9 commits into
Conversation
|
Verified push: this PR's reviewed head is exactly |
Independent adversarial review — head
|
| Consumer | Behaves wrongly? |
|---|---|
Completion monitor (agent-completion-process-monitor.ts:78) |
No — the fix's consumer; unverifiable → re-arm + backoff |
LocalPtyProvider.confirmForegroundProcess / fresh path |
No — fresh gate unchanged (new check is trivially satisfied when the fresh shell-row check passes) |
Daemon tracker scheduleRefresh (foreground-process-tracker.ts:139) |
No — drops available: false resolutions, so it now holds identity on never-contained tables (conservative); genuine exits still retire because the surviving shell row makes the table available |
Daemon tracker fresh confirm (:277) |
No — fresh path unchanged |
Runtime inspectTerminalProcess (orca-runtime.ts:22477) |
No — prefers controller inspectProcess, wire type already carries the optional field |
degraded-daemon-pty-provider.ts:191 |
No — gains evidence for local-owned ids (this is part of the fix's reach) |
| Daemon router / terminal-host / pre-v27 adapter composition | Unchanged — still evidence-less (sibling site, out of scope) |
Evidence-blind renderer consumers (codex-session-restart.ts:97, pane-serializer-settle.ts:154, agent-ready-wait.ts:95, paste/followup gating) |
No — steadier identity during blackouts is the conservative direction for all of them (restart eligibility additionally re-confirms with a fresh availability-strict scan) |
| Pre-evidence wire peers / old daemons | No — optional field ignored; legacy bytes proven identical |
Non-blocking notes (P2)
classifyLocalPtyChildProcesses's observed-non-shell override intentionally publisheshasChildProcesses: falsewith children evidencelive— legacy parity requires it, and the code comment says so, but it means the local leg cannot use the sharedbuildPtyProcessInspectionWireResult(which would forcehasChildProcesses: trueforlive). Fine as-is; worth remembering when the daemon leg adopts the contract.- POSIX cached-path availability accepts a child-only table (shell row lost) as an observation while the win32 inventory requires the root row. The asymmetry is justified (a descendant row is pane evidence, and the stricter form broke a legitimate existing behavior), but the divergence deserves the one-line comment it already has — no action.
- The e2e and provider-evidence suites duplicate ~100 lines of
vi.mockboilerplate; per-filevi.mockhoisting makes this hard to share. Not worth restructuring.
Test-to-prod ratio (768:149): thoroughness, not redundancy — the ablation matrix shows the unit pins and the e2e catch different reverts (the stable-cache fallback masks several hunks from the e2e), so the layers are each load-bearing. This is what the fix should look like written from scratch, given the legacy-parity constraint.
Perf reviewed by hand ($perf skill is disable-model-invocation for workers): one extra O(n) pass over already-parsed rows per cached scan, one fewer async hop in inspection, no new forks/timers/listeners, and degraded reads now engage the monitor's backoff (net fewer polls under load).
7702a7d to
a8c7202
Compare
Stack refresh + reviewRefresh (the stack was stale)This branch did not contain its own base. It has been rebased onto #16926's current head and force-pushed.
The two commits it was missing — Two notes for whoever picks the stack up next:
Do #16926's gates still fire under this change?A green composed tree proves nothing on its own, so I built the composed tree locally (#16926 + #16955 + #17003), reverted each gate individually, and checked that a test actually goes red.
The two monitor hunks are mutually redundant — each alone catches the out-of-contract verdict, so neither is independently pinned and reverting either one on its own stays green. The pair is covered; the individual arms are not. That is a coverage gap in #16926's test, not a defect here, and it means a future edit could silently delete one arm. Worth an independent pin in #16926. The two type-validation hunks are each independently pinned. Answering the composition questions directly: this PR's evidence satisfies #16926's type validation (every verdict it emits is in-contract, with Per-hunk ablation of this PREach production hunk reverted individually on the refreshed tree; every one is pinned.
Can a degraded local read still be published as an exit?In the agent-completion path, no. Every return site in Outside it, yes — and that is worth stating plainly. The one that does not is workspace cleanup:
This is pre-existing, is not introduced or worsened here, and is genuinely outside this PR's scope (it does not go through On the retained
|
Follow-up: how far each half of this change actually reachesA second review pass turned up something worth stating explicitly, because the two halves of this PR have very different reach. Both claims below I verified in the tree. The one-line guard has broad reach — including daemon-hosted panes. The new pane-membership check in The evidence-publishing half does not reach the default local pane. Worth noting because the PR's "when you'd hit this" framing reads as though the whole change covers local terminals generally. The behavioural fix does; the evidence contract does not, until #17003 lands. Two findings that belong to the base, not to this PRA degraded read now silently drops a pending-title completion. This is a false negative, never a false completion, so it is strictly the safe direction. But it is entirely renderer-side logic in the base branch — this PR touches no renderer file, it only newly exposes local panes to a path that already applies to relay/SSH panes, where the contract's own doc calls "could not ask" a normal steady state. Recommend raising it against #16926 rather than holding this PR. Nothing covers it today. Two smaller consequences of the same shape, both also safe-direction: a degraded pane no longer resets One test-hygiene note
But it hoists a For contrast, |
3ca44ad to
66abb42
Compare
a8c7202 to
82e2fde
Compare
A degraded local foreground read (failed or pane-less ps table, thrown scan) used to collapse into the same payload as an observed idle shell, and the agent-completion monitor read it as exit evidence. The local provider now implements inspectProcess with per-probe live/unverifiable/exited processEvidence (same contract as the relay leg), keeps legacy fields byte-identical, and the POSIX resolver stops claiming availability for cached tables that never contained the pane.
…nd read The comment described the pre-evidence hazard it no longer causes: the catch now publishes an `unverifiable` verdict, so the retained `?? null` legacy name (kept byte-identical for pre-evidence wire peers) can no longer read as an exit. Left as-is it invites a future reader to "fix" the legacy collapse and break that parity.
82e2fde to
abb7f33
Compare
…usal arms A gate ablation found the `unavailable` arm of the completion monitor free while its structurally identical out-of-contract twin was pinned. After an `unavailable` sample the pending exit could stop being discarded and nothing would notice: a pending exit would survive the gap and be confirmed by the next positive sample, so the two "consecutive" samples that dispatch a completion would be separated by a read that observed nothing. `unavailable` is strictly less evidence than an out-of-contract verdict, so if either arm deserves the re-arm it is this one. Its backoff charge was free for the same reason and is pinned here too, or an unreachable host gets polled at the active tier forever. Also pinned, each red with that arm reverted alone: the exit-1-is-not-absence timed-out check on both pgrep and ps, the ps spawn-failure staying unverifiable, `processName: null` from a completed scan reading as positive absence, an unowned pty reading as positive absence, and a pty replaced mid-scan staying unverifiable. `!result.signal` in subprocessRanAndMatchedNothing is left unpinned on purpose: Node reports `code` and `signal` mutually exclusively, so `code === 1` with a signal is not an input production emits, and a test for it would assert an unreachable branch.
… depends on Two cross-PR hazards found against #17024, both closed on the side that owns the code they depend on. 1. #17024 moves `RuntimeTerminalProcessInspection` into a new leaf module while this branch adds `processEvidence` to it in the old one. The merge conflicts, and the natural "keep ours — the type moved" resolution drops the field. It is optional and every reader guards it, so nothing at the call sites changes: `readPtyProcessInspectionEvidence` then promotes a host that could not answer to `observed` + `exited`, positive exit evidence from a read that observed nothing. The new test reads the field through the declared type, so the drop fails the typecheck at a named site, and asserts the real reader's output both with the evidence and without it. 2. `inspectPtyProviderProcess` falls back to composing `getForegroundProcess` + `hasChildProcesses` for a provider that has no `inspectProcess` of its own. Both coerce a degraded read to null/false with no way to say "could not ask", which is the idle a workspace-cleanup row gets swept up on. Pinned with the real LocalPtyProvider and no double: a degraded scan must reach the caller as `unverifiable` on both probes, and the same sample read through the legacy pair alone is shown reading as `exited`. Both go red with their arm reverted alone and stay green under the others.
…nnanb2025/local-inspection-unverifiable-r1
Greptile SummaryThe PR makes degraded local PTY process inspection explicitly unverifiable rather than treating probe failure as process exit.
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/main/providers/agent-foreground-process.ts | Distinguishes cached POSIX snapshots that contain no pane-related process rows from authoritative scans. |
| src/main/providers/local-pty-foreground-inspection.ts | Carries observed versus unverifiable foreground evidence while preserving the stable legacy process name. |
| src/main/providers/local-pty-process-evidence.ts | Defines local title-read and child-process evidence classification without coercing failed reads into exit evidence. |
| src/main/providers/local-pty-provider.ts | Adds provider-level process inspection that publishes foreground and child evidence alongside legacy fields. |
| tests/e2e/local-completion-evidence/local-inspection-unverifiable-completion.unit.test.ts | Exercises the local inspection-to-completion path and verifies degraded observations do not trigger completion. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[LocalPtyProvider.inspectProcess] --> B[Observe foreground process]
B --> C{Foreground scan available?}
C -->|No| D[Foreground evidence: unverifiable]
C -->|Yes| E[Foreground evidence: observed]
D --> F[Read PTY title and classify children]
E --> F
F --> G{Title and scan provide positive exit evidence?}
G -->|No| H[Children evidence: live or unverifiable]
G -->|Yes| I[Children evidence: exited]
H --> J[Completion monitor re-arms]
I --> K[Completion monitor confirms exit]
Reviews (5): Last reviewed commit: "Merge commit '91f761a706a2a0c65b985ea290..." | Re-trigger Greptile
`native-smoke (windows-latest)` fails ~4.5% of runs on `preserves a multiline argument through the compiled remote launcher` with "Test timed out in 15000ms" — on unrelated PRs, for reasons that have nothing to do with them. Across 176 sampled attempts it is the only red that job produced, and it hit seven different PRs in two days: #16900, #16904, #16915, #16955 (twice), #16979, #17014, #17085. The test is six process creations: powershell.exe forks csc.exe, then the freshly compiled orca.exe forks node.exe, twice. Hosted Windows runners periodically slow process creation down, and this test amplifies that far harder than anything else in the job. Comparing the 80 attempts where it ran under 3s against the 12 where it ran over 12s, its own median goes 2198ms -> 15917ms (7.2x) while the same file's powershell-only test moves 556 -> 686ms (1.2x), the cmd.exe and Git Bash process tests in the neighbouring file move 1.4x, and the other 35 files put together move 1.5x. Measured across those 176 attempts: 1881ms to 35438ms, p50 4264ms, correlation +0.881 with the job's total Vitest duration. 8 of 176 (4.5%) exceeded the 15s cap; 2 of 176 (1.1%) also exceeded the shared 30s testTimeout, so deleting the override and inheriting the config is not enough on its own. 60s clears all 176 with 1.7x headroom on the worst. This is slow, not hung. Every body here is synchronous spawnSync, so Vitest cannot interrupt one — the timer fires only after the body returns and the reported duration is real elapsed time. That is why a failure reads `× ... 22464ms` under `Test timed out in 15000ms`. The work finished; the stopwatch was short. Seven reruns at one identical head measured 2053 / 4680 / 5551 / 8732 / 13506 / 14868 / 21937ms — the last of those would have been red on code that had not changed. The 15s came from #8897, which raised this test off Vitest's built-in 5s default because the job then ran bare `pnpm vitest run`. #8909 landed 3h27m later and pointed the job at config/vitest.config.ts, which is the real fix for that. The constant stayed behind and has been the binding budget ever since.
…nnanb2025/local-inspection-unverifiable-r1
`native-smoke (windows-latest)` fails ~4.5% of runs on `preserves a multiline argument through the compiled remote launcher` with "Test timed out in 15000ms" — on unrelated PRs, for reasons that have nothing to do with them. Across 176 sampled attempts it is the only red that job produced, and it hit seven different PRs in two days: #16900, #16904, #16915, #16955 (twice), #16979, #17014, #17085. The test is six process creations: powershell.exe forks csc.exe, then the freshly compiled orca.exe forks node.exe, twice. Hosted Windows runners periodically slow process creation down, and this test amplifies that far harder than anything else in the job. Comparing the 80 attempts where it ran under 3s against the 12 where it ran over 12s, its own median goes 2198ms -> 15917ms (7.2x) while the same file's powershell-only test moves 556 -> 686ms (1.2x), the cmd.exe and Git Bash process tests in the neighbouring file move 1.4x, and the other 35 files put together move 1.5x. Measured across those 176 attempts: 1881ms to 35438ms, p50 4264ms, correlation +0.881 with the job's total Vitest duration. 8 of 176 (4.5%) exceeded the 15s cap; 2 of 176 (1.1%) also exceeded the shared 30s testTimeout, so deleting the override and inheriting the config is not enough on its own. 60s clears all 176 with 1.7x headroom on the worst. This is slow, not hung. Every body here is synchronous spawnSync, so Vitest cannot interrupt one — the timer fires only after the body returns and the reported duration is real elapsed time. That is why a failure reads `× ... 22464ms` under `Test timed out in 15000ms`. The work finished; the stopwatch was short. Seven reruns at one identical head measured 2053 / 4680 / 5551 / 8732 / 13506 / 14868 / 21937ms — the last of those would have been red on code that had not changed. The 15s came from #8897, which raised this test off Vitest's built-in 5s default because the job then ran bare `pnpm vitest run`. #8909 landed 3h27m later and pointed the job at config/vitest.config.ts, which is the real fix for that. The constant stayed behind and has been the binding budget ever since.
… observation onto the split modules main (#17206) cut local-pty-provider.ts from 1584 to 194 lines, moving getForegroundProcess into local-pty-foreground-inspection.ts. This branch had rewritten that same method into an observing form, so neither merge side was resolvable on its own. Ported rather than resolved: - local-pty-foreground-inspection.ts now exports observeLocalPtyForegroundProcess returning LocalForegroundObservation. getLocalPtyForegroundProcess stays as the collapsing wrapper, so every existing caller keeps the exact legacy value. - inspectProcess moves onto LocalPtyProvider and consumes the observation, which keeps the evidence type in local-pty-process-evidence.ts and out of the inspection module's import cycle. The verdict vocabulary crosses the new module boundary unchanged: foreground reads answer observed / unverifiable, children answer live / unverifiable / exited, and a degraded or thrown read stays unverifiable rather than collapsing into an exit.
`native-smoke (windows-latest)` fails ~4.5% of runs on `preserves a multiline argument through the compiled remote launcher` with "Test timed out in 15000ms" — on unrelated PRs, for reasons that have nothing to do with them. Across 176 sampled attempts it is the only red that job produced, and it hit seven different PRs in two days: #16900, #16904, #16915, #16955 (twice), #16979, #17014, #17085. The test is six process creations: powershell.exe forks csc.exe, then the freshly compiled orca.exe forks node.exe, twice. Hosted Windows runners periodically slow process creation down, and this test amplifies that far harder than anything else in the job. Comparing the 80 attempts where it ran under 3s against the 12 where it ran over 12s, its own median goes 2198ms -> 15917ms (7.2x) while the same file's powershell-only test moves 556 -> 686ms (1.2x), the cmd.exe and Git Bash process tests in the neighbouring file move 1.4x, and the other 35 files put together move 1.5x. Measured across those 176 attempts: 1881ms to 35438ms, p50 4264ms, correlation +0.881 with the job's total Vitest duration. 8 of 176 (4.5%) exceeded the 15s cap; 2 of 176 (1.1%) also exceeded the shared 30s testTimeout, so deleting the override and inheriting the config is not enough on its own. 60s clears all 176 with 1.7x headroom on the worst. This is slow, not hung. Every body here is synchronous spawnSync, so Vitest cannot interrupt one — the timer fires only after the body returns and the reported duration is real elapsed time. That is why a failure reads `× ... 22464ms` under `Test timed out in 15000ms`. The work finished; the stopwatch was short. Seven reruns at one identical head measured 2053 / 4680 / 5551 / 8732 / 13506 / 14868 / 21937ms — the last of those would have been red on code that had not changed. The 15s came from #8897, which raised this test off Vitest's built-in 5s default because the job then ran bare `pnpm vitest run`. #8909 landed 3h27m later and pointed the job at config/vitest.config.ts, which is the real fix for that. The constant stayed behind and has been the binding budget ever since.
* fix(ssh): fence stale kills and retired pane replay * fix(ssh): support cancellable interactive authentication * fix(ssh): await remote catalog before snapshot adoption * fix(pty): contain Windows ConPTY input failures * fix(power): avoid redundant macOS display blocking * perf(editor): narrow markdown override subscriptions * fix(quick-open): close directory handles after reads * refactor(linux): remove unused proc socket scanner * fix(usage): apply flat Sonnet 4.6 pricing * ci: prime Node next native test cache * docs(skills): resolve snapshot cleanup data path * fix(ssh): recover install locks after host reboot * test(ssh): recognize boot-aware install locks * test(ssh): prove previous-boot lock recovery live * test(wire): pin pre-metadata release coverage * fix(terminal): preserve remote tab ownership through recovery races * test(runtime): fence replaced terminal handles in agent guard * fix(ssh): preserve remote snapshot authority across polls * fix(pty): contain late ConPTY output EPIPE * test(pty): register Windows exit watcher before kill * fix: close SSH and tab readiness race gaps * fix(tabs): retain headless order and placeholder titles * fix(build): avoid parallel electron-vite config race * test(windows): avoid MSYS temp path rewriting * test(windows): avoid killing exited PTY * fix(pty): avoid late ConPTY input teardown race * fix(terminal): sync reconnect error ownership after commit * fix(runtime): use canonical worktree identity comparison * test(ssh): assert complete cold-hydration baseline * test(windows): invoke quoted retention fixture via PowerShell * test(windows): read ConPTY grid through mode con * fix(terminal): publish PTY replacements atomically * fix(terminal): infer stale identity on reattach * fix(terminal): fence stale pane PTY callbacks * fix(terminal): fence stale pane binds after rebind * fix(terminal): reject stale pane transport callbacks * fix(terminal): fence mirrored reattach spawn callbacks * fix(terminal): replace stale pane PTYs on remount * fix(ci): size the Windows launcher-compile test budget from measurement `native-smoke (windows-latest)` fails ~4.5% of runs on `preserves a multiline argument through the compiled remote launcher` with "Test timed out in 15000ms" — on unrelated PRs, for reasons that have nothing to do with them. Across 176 sampled attempts it is the only red that job produced, and it hit seven different PRs in two days: #16900, #16904, #16915, #16955 (twice), #16979, #17014, #17085. The test is six process creations: powershell.exe forks csc.exe, then the freshly compiled orca.exe forks node.exe, twice. Hosted Windows runners periodically slow process creation down, and this test amplifies that far harder than anything else in the job. Comparing the 80 attempts where it ran under 3s against the 12 where it ran over 12s, its own median goes 2198ms -> 15917ms (7.2x) while the same file's powershell-only test moves 556 -> 686ms (1.2x), the cmd.exe and Git Bash process tests in the neighbouring file move 1.4x, and the other 35 files put together move 1.5x. Measured across those 176 attempts: 1881ms to 35438ms, p50 4264ms, correlation +0.881 with the job's total Vitest duration. 8 of 176 (4.5%) exceeded the 15s cap; 2 of 176 (1.1%) also exceeded the shared 30s testTimeout, so deleting the override and inheriting the config is not enough on its own. 60s clears all 176 with 1.7x headroom on the worst. This is slow, not hung. Every body here is synchronous spawnSync, so Vitest cannot interrupt one — the timer fires only after the body returns and the reported duration is real elapsed time. That is why a failure reads `× ... 22464ms` under `Test timed out in 15000ms`. The work finished; the stopwatch was short. Seven reruns at one identical head measured 2053 / 4680 / 5551 / 8732 / 13506 / 14868 / 21937ms — the last of those would have been red on code that had not changed. The 15s came from #8897, which raised this test off Vitest's built-in 5s default because the job then ran bare `pnpm vitest run`. #8909 landed 3h27m later and pointed the job at config/vitest.config.ts, which is the real fix for that. The constant stayed behind and has been the binding budget ever since. * fix(terminal): fence stale remount reattach ownership * fix(terminal): reconcile mounted pane identity after replacement * fix(terminal): fence stale reattach fallback ownership * fix(terminal): fence deferred SSH reattach ownership * fix(terminal): fence stale split pane ownership callbacks * fix(terminal): keep stale spawns from consuming startup --------- Co-authored-by: Brennan Benson <[email protected]>
* fix(ssh): fence stale kills and retired pane replay * fix(ssh): support cancellable interactive authentication * fix(ssh): await remote catalog before snapshot adoption * fix(pty): contain Windows ConPTY input failures * fix(power): avoid redundant macOS display blocking * perf(editor): narrow markdown override subscriptions * fix(quick-open): close directory handles after reads * refactor(linux): remove unused proc socket scanner * fix(usage): apply flat Sonnet 4.6 pricing * ci: prime Node next native test cache * docs(skills): resolve snapshot cleanup data path * fix(ssh): recover install locks after host reboot * test(ssh): recognize boot-aware install locks * test(ssh): prove previous-boot lock recovery live * test(wire): pin pre-metadata release coverage * fix(terminal): preserve remote tab ownership through recovery races * test(runtime): fence replaced terminal handles in agent guard * fix(ssh): preserve remote snapshot authority across polls * fix(pty): contain late ConPTY output EPIPE * test(pty): register Windows exit watcher before kill * fix: close SSH and tab readiness race gaps * fix(tabs): retain headless order and placeholder titles * fix(build): avoid parallel electron-vite config race * test(windows): avoid MSYS temp path rewriting * test(windows): avoid killing exited PTY * fix(pty): avoid late ConPTY input teardown race * fix(terminal): sync reconnect error ownership after commit * fix(runtime): use canonical worktree identity comparison * test(ssh): assert complete cold-hydration baseline * test(windows): invoke quoted retention fixture via PowerShell * test(windows): read ConPTY grid through mode con * fix(terminal): publish PTY replacements atomically * fix(terminal): infer stale identity on reattach * fix(terminal): fence stale pane PTY callbacks * fix(terminal): fence stale pane binds after rebind * fix(terminal): reject stale pane transport callbacks * fix(terminal): fence mirrored reattach spawn callbacks * fix(terminal): replace stale pane PTYs on remount * fix(ci): size the Windows launcher-compile test budget from measurement `native-smoke (windows-latest)` fails ~4.5% of runs on `preserves a multiline argument through the compiled remote launcher` with "Test timed out in 15000ms" — on unrelated PRs, for reasons that have nothing to do with them. Across 176 sampled attempts it is the only red that job produced, and it hit seven different PRs in two days: stablyai#16900, stablyai#16904, stablyai#16915, stablyai#16955 (twice), stablyai#16979, stablyai#17014, stablyai#17085. The test is six process creations: powershell.exe forks csc.exe, then the freshly compiled orca.exe forks node.exe, twice. Hosted Windows runners periodically slow process creation down, and this test amplifies that far harder than anything else in the job. Comparing the 80 attempts where it ran under 3s against the 12 where it ran over 12s, its own median goes 2198ms -> 15917ms (7.2x) while the same file's powershell-only test moves 556 -> 686ms (1.2x), the cmd.exe and Git Bash process tests in the neighbouring file move 1.4x, and the other 35 files put together move 1.5x. Measured across those 176 attempts: 1881ms to 35438ms, p50 4264ms, correlation +0.881 with the job's total Vitest duration. 8 of 176 (4.5%) exceeded the 15s cap; 2 of 176 (1.1%) also exceeded the shared 30s testTimeout, so deleting the override and inheriting the config is not enough on its own. 60s clears all 176 with 1.7x headroom on the worst. This is slow, not hung. Every body here is synchronous spawnSync, so Vitest cannot interrupt one — the timer fires only after the body returns and the reported duration is real elapsed time. That is why a failure reads `× ... 22464ms` under `Test timed out in 15000ms`. The work finished; the stopwatch was short. Seven reruns at one identical head measured 2053 / 4680 / 5551 / 8732 / 13506 / 14868 / 21937ms — the last of those would have been red on code that had not changed. The 15s came from stablyai#8897, which raised this test off Vitest's built-in 5s default because the job then ran bare `pnpm vitest run`. stablyai#8909 landed 3h27m later and pointed the job at config/vitest.config.ts, which is the real fix for that. The constant stayed behind and has been the binding budget ever since. * fix(terminal): fence stale remount reattach ownership * fix(terminal): reconcile mounted pane identity after replacement * fix(terminal): fence stale reattach fallback ownership * fix(terminal): fence deferred SSH reattach ownership * fix(terminal): fence stale split pane ownership callbacks * fix(terminal): keep stale spawns from consuming startup --------- Co-authored-by: Brennan Benson <[email protected]>
|
Closing as superseded: a merged PR already covers this change. Main local inspection returns childProcessEvidence 'unverifiable' on degraded or replaced reads (src/main/providers/local-pty-provider.ts:162,177) via #20756 (3ec6193). Base #16926 closed unmerged; relay files deleted by (Stale-PR cleanup 2026-10-20, approved by Brennan. Reopen if something here is still missing on main.) |
Remediates coercion site 5 of the "failure becomes fact" class: local child-process inspection. Sibling PRs: #16900, #16908, #16926 (relay leg of this same monitor), #16932.
Stacked on #16926 (
brennanb2025/relay-completion-unverifiable-r1, live head91f761a706a2a0c65b985ea2903a0d0b7c9c79d0, re-resolved withgit ls-remote; an earlier revision of this page pinned2910404020, which the base branch has since moved past) — it defines theprocessEvidencecontract and the monitor's consumption of it. Merge #16926 first, then retarget/rebase this ontomain; this PR adds no hunks to the files #16926 owns (src/relay/pty-process-probes.ts, thepty-api.tsprocessEvidencehunk, daemon pid-publish paths are all untouched). Both halves re-verified at heada7ce56571ee14cbb0f99ae3f7b08654634d4f85a:91f761a706is an ancestor of this head, and of the 11 files this PR changes the only relay file ispty-process-probes.test.ts.ELI5
Orca watches each terminal to notice when your agent (Codex, Claude Code, …) finishes, by asking the operating system "what's running in this terminal?". On a busy machine that question can fail — the process list comes back without your terminal in it, or the lookup dies. The old code treated "I couldn't look" exactly like "I looked and the agent is gone", so a perfectly alive agent could be announced as done. Now the local inspection says "I couldn't tell" when it couldn't tell, and the watcher just checks again instead of concluding.
User-facing before/after
When you'd hit this: you run an agent in a local terminal (macOS/Linux/Windows, including WSL panes and the fallback path used when the terminal daemon is unreachable) while the machine is under heavy load — e.g. big builds, test fanouts, or many agent panes forking
ps/PowerShell scans at once. Exactly the moment you're most likely to be multitasking away from the pane.terminalIdleConfirmed) for an agent that is still working. If you trusted the notification and came back later, you found a half-finished run — or automations keyed on completion acted on a live terminal.The defect (verified real at
origin/main4f14d6d)LocalPtyProviderpublishes no evidence, so even with #16926's monitor the local leg collapses failures into facts:agent-foreground-process.ts(POSIX, cached-snapshot path): a table containing none of the pane (no shell row, no child rows) was treated asavailable: true→ "no agent" → the provider's last-recognized-agent cache was cleared by a scan that observed nothing.local-pty-provider.ts:1415(the sweep's cited catch): a thrown inspection fell back tocachedName ?? null— the comment itself admitted "null reads as an exit".hasChildProcessescoerces failures tofalse, andpty-process-inspection.ts:24-26merges these into{foregroundProcess: <shell>, hasChildProcesses: false}— byte-identical to positive exit evidence for the completion monitor.Pre-fix reproduction (real
LocalPtyProvider+ real completion coordinator/monitor, onlypsand node-pty mocked at the OS boundary) fails on the unfixed tree with a concrete false completion:A live codex, recorded as complete with "terminal idle confirmed", from two reads that observed nothing.
The fix (contract-first, same vocabulary as the relay leg)
LocalPtyProvider.inspectProcess()now publishesprocessEvidenceusing the sharedPtyProcessInspectionEvidencecontract from Keep relay completion evidence live/unverifiable/exited, never coerced #16926 — no parallel evidence type. LegacyforegroundProcess/hasChildProcesseskeep the exact pre-fix collapse (pinned by exact-equality tests), so old clients and evidence-blind consumers see identical values.observeForegroundProcess): completed scan →observed; degraded scan / thrown inspection / pty replaced mid-read →unverifiablewith a reason. Successful Windows job reads (confirmed/unproven) remain positive observations, preserving their legacy semantics.exitedwhen the foreground scan completed, because node-pty's POSIX title read silently falls back to the spawned shell name when the native read fails — under the same distress that degrades the scan, the title observes nothing.available: falsewhen the table contains neither the pane's shell row nor any direct child of it (the fresh path keeps its stricter historical shell-row requirement).live/unverifiable/exitedperdocs/reference/ssh-execution-boundary.md; loss of contact is never evidence of process death.Consumers audited (compile-unchanged check)
LocalPtyProvider.confirmForegroundProcess(fresh scan)foreground-process-tracker(scheduleRefresh)confirmForegroundProcess(fresh)resolveAgentForegroundProcessname-only callersavailableflips)getForegroundProcesscodex-session-restart, close-guard family,terminal-keydown-fit)inspectProcessAblation (re-measured at head
e3bdedfc8b)Suite: 5 files, 25 tests, all green at head —
src/main/providers/agent-foreground-process-snapshot-availability.test.ts,src/main/providers/local-pty-process-evidence.test.ts,src/main/providers/local-pty-provider-inspect-process-evidence.test.ts,src/renderer/src/runtime/runtime-terminal-inspection-evidence-passthrough.test.ts,tests/e2e/local-completion-evidence/local-inspection-unverifiable-completion.unit.test.ts.Each production hunk reverted individually, tree restored between runs.
unverifiableevidenceunverifiableevidenceobservedevidenceinspectProcessmethodThree of these numbers moved since the table was first written, all upward: the degraded-scan
row said 2 and reddens 3; the
inspectProcessrow said 5 and reddens 8; thedistress-coupling row said 4 and reddens 5. The suite grew between the first measurement
and head —
local-pty-provider-inspect-process-evidence.test.tsand the passthrough test camelater — so these are the same gates measured against more tests, not stronger gates.
Failing-first (measured at head
a7ce56571e)Every production file this PR changes reverted to #16926's live head
91f761a706, all tests kept,then the PR's own 7 changed test files run: 10 failed across 4 of the 7. Baseline at head,
same 7 files: 69 passed, 0 failed. Tree byte-verified mutated before each run and restored
--hardafter, serially.The reproduction quoted above is one of those 10 — the ablated tree emits that
terminalIdleConfirmed: trueassertion verbatim, not a paraphrase of it.Notes
node:child_processimports added; both only-shrinks ratchets and all baselines untouched (config/diff is empty).$perfskill is disable-model-invocation for workers, so this was reviewed by hand.terminal-host.inspectProcess) is the remaining evidence-less local leg; the hook-lane stubinspectProcessinagent-hook-completion-notifications.tspredates this PR.Author X handle: @BrennanKB5