Skip to content

fix: preserve host-owned terminal identity during first mount - #23749

Open
nwparker wants to merge 7 commits into
mainfrom
nwparker/ci-runtime-owned-null-projection
Open

nwparker wants to merge 7 commits into
mainfrom
nwparker/ci-runtime-owned-null-projection

Conversation

@nwparker

@nwparker nwparker commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Linux flake validation is running; do not merge until it reports. The initial candidate failed 2/8 Linux repetitions. The follow-up also handles unmounted panes omitted from the transport graph while still explicitly present in the renderer session. Rebased onto main (was 64 commits behind); the stray commit that resurrected codex-structured-journal-provider-verdicts.ts after #23682 deleted it is dropped, so the merge conflict and the TS2307 typecheck failure it caused are gone.

Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​211 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​209
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​163 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​154

ELI5

Opening a workspace could create duplicate agent and Setup tabs even though their terminals were already running. Keep those terminals attached to their original panes while the screen catches up.

What Changed

The host preserves its existing terminal binding when the renderer publishes the same pane with an empty binding. It also retains an unmounted pane omitted from the transport graph when the renderer’s accepted current session still explicitly publishes that exact empty pane. Host-preserved session rows are excluded from that evidence. Preservation requires runtime ownership and an exact workspace, tab, and pane match. An explicit replacement, move to another pane, removed pane, or confirmed process exit still takes precedence.

Why

Linux binding traces showed activation creating extra tabs after an empty renderer projection made the host incorrectly report live terminals as orphaned. Fixing the host's ownership decision keeps all inventory readers consistent; delaying activation or weakening the identity assertions would leave the race intact.

Linked Issue

CI failure in live-background-terminal-mount-authority.spec.ts; baseline diagnostic run: https://github.com/stablyai/orca/actions/runs/36502710956 (five failures in eight runs).

Visual Proof

Before: Linux failure has five tabs after activation. After: macOS validation retains the three original tabs through input and remount checks. The unchanged E2E verifies exact tab, leaf, PTY, handle and process identity. Screenshots use different platform window sizes.

Before: duplicate terminal tabs

After: three original tabs and Setup input

Testing

  • Automated regression added: exact inventory equality across an empty projection (fails before the fix).
  • 1,365 runtime tests passed, one skipped; includes handle/incarnation fencing and removal, move, replacement, workspace mismatch, disconnected-host and confirmed-exit cases.
  • macOS hidden Electron first-mount authority E2E passed (18.3 seconds).
  • Node typecheck and changed-code quality gate passed; the extracted session-publication reader also passes all 18 targeted regression tests.
  • 9,600 runtime tests pass (932 files, 2 skipped) after the rebase; node typecheck, oxlint and the changed-code quality gate are clean.
  • Repeated Linux E2E pending: 8 repetitions on nwparker/ci-null-projection-repeat-v2 (https://github.com/stablyai/orca/actions/runs/36657752034). This is the gate — a single green repetition does not clear a 2/8 flake.

Terminal contract: host ownership survives a temporary renderer projection gap; no duplicate spawn or reminted identity. The oracle is full terminal inventory equality plus unchanged E2E identity/input/output assertions. Existing agent-session.provider-ownership first-mount coverage is the gate. Windows and live SSH validation remain gaps; runtime tests cover incarnation fencing and unverifiable host contact.

Review

No wire fields or opcodes change. Older clients receive the same existing terminal identity instead of a false orphan. No local-only paths, Git assumptions, or new polling; folder workspaces use the same exact workspace comparison. Each sync builds transient linear-time indexes of explicit incoming bindings and accepted empty session panes. An explicit session removal, replacement, or move supersedes retention; unchanged snapshot publications retain the same exact handle. Pane identity travels as one RuntimePaneIdentity object rather than three adjacent string arguments, so no call site can transpose pane, worktree and tab.

Agent skill upstream boundary

  • Not applicable; no upstream skill content copied.

Checklist

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Refactors terminal identity preservation during renderer reload.

The reviewed changes appear safe to merge once the pending repeated Linux E2E gate reports successfully.

Summary

The PR preserves host-owned PTY bindings when a renderer projection temporarily omits a binding or an unmounted pane, while retaining explicit replacement, removal, move, and exit behavior.

  • Adds runtime inventory regression coverage for those transitions.
  • Excludes the Codex capability probe from the E2E agent-launch count.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  R[Renderer graph and accepted session] --> S[Graph sync]
  H[Host-owned PTY records] --> S
  S --> M{Exact pane and workspace match?}
  M -->|Yes, no replacement or exit| K[Retain PTY identity]
  M -->|No| U[Use published binding or remove pane]
Loading

Reviews (9) · Last reviewed commit: "fix(test): stop counting the Codex --no-..."

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

syncWindowGraph now uses renderer-published pane data and runtime-owned PTYs to project terminal bindings and preserve qualifying stale leaves. New helpers collect published panes, resolve eligible runtime-owned PTYs, and choose projected PTY IDs. Tests cover projection and inventory behavior when panes are empty, unmounted, removed, replaced, or moved.

Priority: ➖ Normal

Merge Risk: 🟡 Moderate · up to 23095

A terminal moved to another pane could reappear in its old pane, producing duplicate terminal entries. Exclude PTYs already published by the accepted snapshot from runtime-owned retention before merging.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 23095

The change preserves existing terminals while requiring matching workspace, tab, and pane identity. Conflicting ownership, confirmed process exit, and explicit replacement or movement prevent the new preservation behavior. No introduced security bypass was established, but runtime validation remains pending.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The assessed sensitive outcomes are terminal-handle attachment, inventory identity, and association of terminal output with a pane within the publishing host runtime. The new automatic selection path is constrained to host records matching the requested worktree, tab, and pane.

Trust Boundaries and Controls

  • observed — Graph synchronization checks authoritative window identity and superseded renderer generation before the new projection logic. Automatic PTY selection additionally requires runtime-session ownership, matching identity, unambiguous ownership, and absence of an incoming claim for that PTY.
  • observed — Omitted-pane preservation cannot use host-preserved session rows as self-authorizing renderer evidence. The collector requires accepted renderer identity keys; acceptance records those keys from the fenced renderer snapshot before host-preserved rows are merged, and skips older same-epoch publications.

Resilience and Maintainability Implications

  • observed — Explicit incoming bindings take precedence over automatic projection. Stale aliases are released or invalidated when a PTY moves, and the new preservation path refuses ambiguous owners or PTYs already claimed elsewhere. Regression assertions exercise replacement, removal, and movement as counterevidence to indefinite stale attachment.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: preserving host-owned terminal identity during first mount.
Description check ✅ Passed The description covers the required explanation, change, rationale, linked failure, visual proof, testing, review, scope boundary, and checklist. It clearly identifies pending Linux validation and rem…
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Host preserves a runtime-owned PTY across an empty pane projection — syncWindowGraph now keeps existing.ptyId when the incoming graph publishes null for the exact same workspace/tab/pane, the PTY is runtimeSessionOwned, no incoming leaf claims that PTY, and its liveness verdict is not exited. Replacement, move, removed pane, and confirmed exit still take precedence.
  • Regression coverage — a new runtime-owned terminal projection gaps suite pins unverifiable retention; exited / different-workspace / replacement precedence; exact handle-and-surface equality across the gap; orphan-on-removal; and no duplicate binding on an explicit pane move.

Locally, the new suite passes (15/15) and 2 of its cases fail with the prod change reverted (so the tests have teeth); related runtime suites (47 tests across graph-sync, mobile-close preservation, pending registration, queued exit, headless placeholder surface, recorded-surface topology, recovery liveness) also pass.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

The new collectRendererPublishedEmptyTerminalPanes helper throws on non-UUID pane leaf IDs, which aborts the entire syncWindowGraph and fails 19 existing tests across graph-sync-mobile-snapshot-gating and graph-sync-deletion-fence. The two commits since the last Pullfrog review introduced it; details inline.

Reviewed changes

  • Added renderer-published-empty-terminal-panes.ts — collects the renderer's accepted empty (ptyId: null) panes and the PTYs its accepted publication still binds, so a mounting renderer's projection is not read as an orphan.
  • Wired host-side retention into syncWindowGraph — preserves a runtime-owned PTY when the incoming leaf publishes null for the exact same workspace/tab/pane, and retains an unmounted old leaf whose exact surface the renderer still publishes but omits from the transport graph.
  • Extended the regression suite — the removed / replaced / moved cases now assert a retained pane is released (and reported orphaned) only on explicit removal, with the persisted pane kept in place to prove stale renderer state cannot revive it.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

The newest commit does not compile and the retention feature it adds is inert. shouldPreservePublishedRuntimePane references an undeclared tabId (pnpm tc:node → TS2304), and the call site reads published.emptyPaneWorktrees with a key it was never stored under, so the unmounted-pane path always returns false. Three of the new suite's own tests fail as a result.

Reviewed changes

  • Extracted the retention helpers into runtime-owned-terminal-projection.ts — replaces the deleted renderer-published-empty-terminal-panes.ts and adds indexRuntimeOwnedPanePtys, resolveRetainedRuntimePtyId, createRuntimeOwnedPtyResolver, chooseProjectedPtyId, and shouldPreservePublishedRuntimePane.
  • Guarded the collector against non-UUID leaves — collectRendererPublishedEmptyTerminalPanes now only calls makePaneKey when isTerminalLeafId(tab.leafId), so the earlier stableLeafId must be a UUID throw no longer aborts syncWindowGraph.
  • Rewired syncWindowGraph onto the resolver — the leaf loop uses chooseProjectedPtyId; the old-leaf loop uses shouldPreservePublishedRuntimePane.
  • Added two it.each cases — adopting a host binding before a bound graph leaf exists, and refusing to choose between two live host owners of one pane.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Fixed the undeclared tabId — shouldPreservePublishedRuntimePane now declares tabId between worktreeId and ptyId, so pnpm tc:node passes.
  • Aligned the published-pane map key — collectRendererPublishedEmptyTerminalPanes now stores emptyPaneWorktrees under ${parentTabId}::${leafId}, the same getLeafKey form the old-leaf lookup uses, so the retention branch actually fires; the now-unused makePaneKey import is gone.
  • Test and comment touch-ups — the persisted-pane test re-marks the PTY runtime-owned after the first sync, and a Codex verdict module gains a one-line comment.

Verified locally at 16f0387: pnpm tc:node passes and terminal-list-surface-lost-orphan.test.ts passes 21/21, including the removed / replaced / moved cases that failed at 748af1c.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker nwparker closed this Sep 29, 2026
@nwparker nwparker reopened this Sep 29, 2026
max-lines is configured with skipComments, so the deleted rationale cost no
budget: restores the #18191 headless-placeholder paragraph, the reload-
preservation and host-certified-exit notes, and repairs two comments that were
truncated mid-sentence.

Replaces the three adjacent string params with a RuntimePaneIdentity object so
neither call site needs oxfmt-ignore and pane/worktree/tab cannot be transposed.
chooseProjectedPtyId now short-circuits before resolving, so an already-bound
leaf no longer computes a retention candidate it discards.
@nwparker
nwparker force-pushed the nwparker/ci-runtime-owned-null-projection branch from f962d37 to 2309519 Compare September 30, 2026 01:59

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Delta since the prior Pullfrog review (16f0387): the branch was rebased onto main and the retention helpers were refactored to bundle pane identity; no behavioral change.

  • Bundled pane identity into RuntimePaneIdentity — chooseProjectedPtyId and shouldPreservePublishedRuntimePane now take one { paneKey, worktreeId, tabId } object built by makeRuntimePaneIdentity, so the three adjacent string arguments can no longer be transposed.
  • Folded the retired resolver helper — resolveRetainedRuntimePtyId is inlined into createRuntimeOwnedPtyResolver, and indexRuntimeOwnedPanePtys is now module-private; no external callers import either.
  • Dropped the unrelated Codex verdict commit — the rebase removed the codex-structured-journal-provider-verdicts.ts touch that #23682 had deleted, eliminating the merge conflict and TS2307.
  • Restored the invariant comments — the graphSequence stamp-ordering and re-emit rationale comments return to their fuller form.

Equivalence holds: chooseProjectedPtyId returns incomingPtyId first, then resolver(pane, null); the old code passed incomingPtyId as currentPtyId but discarded the result whenever incoming was non-null, so the branch is identical. Both call sites build the identity from the same makeRuntimePaneKey, matching the collector's ${parentTabId}::${leafId} lookup key, so the prior key-mismatch bug stays fixed.

Verified locally at 2309519: pnpm tc:node passes and terminal-list-surface-lost-orphan.test.ts passes 21/21. All prior Pullfrog threads are resolved.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: b32eaabc-22ed-4c8d-a7b8-a28fcd1547d3

📥 Commits

Reviewing files that changed from the base of the PR and between f962d37 and 2309519.

📒 Files selected for processing (2)
  • src/main/runtime/orca-runtime-sync-window-graph.ts
  • src/main/runtime/runtime-owned-terminal-projection.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Comment on lines +114 to +118
const retainedRuntimePtyId = createRuntimeOwnedPtyResolver(
this.ptysById.values(),
(ptyId) => this.getPtyLivenessVerdict(ptyId)?.status === 'exited',
incomingPtyIds
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

# Locate snapshot acceptance and renderer graph production.
# Inspect whether publication updates host PTY ownership or excludes this combination.
rg -n -C 10 --type ts -g '!**/*.test.ts' \
  '^\s*(public\s+|protected\s+|private\s+)?syncMobileSessionTabs\s*\(' .

rg -n -C 6 --type ts -g '!**/*.test.ts' \
  '\bRuntimeRendererSyncWindowGraph\b|\bmobileSessionTabs\s*:' .

Repository: stablyai/orca

Length of output: 41633


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- sync window graph ---'
sed -n '1,240p' src/main/runtime/orca-runtime-sync-window-graph.ts
printf '%s\n' '--- mobile session tab sync ---'
sed -n '1,240p' src/main/runtime/orca-runtime-sync-mobile-session-tabs.ts
printf '%s\n' '--- graph publication definitions ---'
rg -n -C 12 --type ts --glob '!**/*.spec.ts' --glob '!**/__fixtures__/**' \
  'changedWorktrees|unchangedWorktreeIds|publication\.changed|publication\.unchangedWorktrees|syncMobileSessionTabs\(' src/main src/shared
printf '%s\n' '--- resolver and projection definitions ---'
rg -n -C 14 --type ts --glob '!**/*.spec.ts' --glob '!**/__fixtures__/**' \
  'createRuntimeOwnedPtyResolver|chooseProjectedPtyId|published\.boundPtyIds|boundPtyIds|lifecycleLeaves' src/main/runtime

Repository: stablyai/orca

Length of output: 42009


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- sync mobile session tabs continuation ---'
sed -n '120,300p' src/main/runtime/orca-runtime-sync-mobile-session-tabs.ts
printf '%s\n' '--- ownership release and PTY recording definitions ---'
rg -n -C 18 --type ts --glob '!**/*.spec.ts' --glob '!**/__fixtures__/**' \
  'releaseRuntimeSessionOwnershipForRendererRetiredTabs|recordPtyWorktree|runtimeSessionOwned|paneKey' src/main/runtime
printf '%s\n' '--- renderer publication construction ---'
rg -n -C 18 --type ts --glob '!**/*.spec.ts' --glob '!**/__fixtures__/**' \
  'function .*publication|publication =|changedWorktrees|unchangedWorktrees|mobileSessionTabs:' src/renderer src/main src/shared

Repository: stablyai/orca

Length of output: 45658


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- ownership release helper ---'
rg -n -C 35 --type ts --glob '!**/*.spec.ts' --glob '!**/__fixtures__/**' 'releaseRuntimeSessionOwnershipForRendererRetiredTabs' src/main/runtime
printf '%s\n' '--- ownership assignment and cleanup ---'
rg -n -C 12 --type ts --glob '!**/*.spec.ts' --glob '!**/__fixtures__/**' 'runtimeSessionOwned[[:space:]]*[:=]|runtimeSessionOwned|paneKey[[:space:]]*[:=]' src/main/runtime/orca-runtime\* src/main/runtime/runtime-owned-terminal-projection.ts
printf '%s\n' '--- renderer publication fields ---'
rg -n -C 20 --type ts --glob '!**/*.spec.ts' --glob '!**/__fixtures__/**' 'unchangedMobileSessionWorktrees|rendererTabIdentityKeys|publication\.changed|changedWorktrees' src/renderer src/main --glob '*.ts' --glob '*.tsx'

Repository: stablyai/orca

Length of output: 22259


🏁 Script executed:

#!/bin/bash
set -eu
sed -n '100,190p' src/main/runtime/orca-runtime-merge-preserved-headless-mobile-session-tabs.ts
printf '%s\n' '--- cleanup method definitions ---'
rg -n -C 20 --type ts --glob '!**/*.spec.ts' --glob '!**/__fixtures__/**' \
  'clearRuntimeSessionOwnershipForMobileTab|hasLiveRuntimeSessionOwnedPtyBinding' src/main/runtime

Repository: stablyai/orca

Length of output: 32284


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- shared graph contract ---'
rg -n -C 18 --type ts \
  'export (type|interface) Runtime(RendererSyncWindowGraph|SyncWindowGraph)|RuntimeRendererSyncWindowGraph|RuntimeSyncWindowGraph' src/shared
printf '%s\n' '--- renderer graph publication ---'
rg -n -C 20 --type ts --type tsx \
  'mobileSessionTabs|unchangedMobileSessionWorktrees|rendererGeneration|syncWindowGraph' src/renderer

Repository: stablyai/orca

Length of output: 6782


🏁 Script executed:

#!/bin/bash
set -eu
fd -i 'graph-publication\.ts$' .

Repository: stablyai/orca

Length of output: 218


🏁 Script executed:

#!/bin/bash
set -eu
wc -l src/renderer/src/runtime/sync-runtime-graph/graph-publication.ts
cat -n src/renderer/src/runtime/sync-runtime-graph/graph-publication.ts

Repository: stablyai/orca

Length of output: 11737


Exclude published PTYs from runtime-owned retention.

When an accepted mobile snapshot binds PTY P to a different pane, the renderer can still publish the old leaf with ptyId: null. The ownership record can still name the old pane. Since the resolver excludes only incoming leaf PTYs, chooseProjectedPtyId can bind P back to the old leaf. This creates a duplicate binding and defeats move precedence.

Suggested fix
-    const incomingPtyIds = new Set(lifecycleLeaves.map((leaf) => leaf.ptyId))
     const published = collectRendererPublishedEmptyTerminalPanes(
       graph,
       this.mobileSessionTabsByWorktree,
       this.acceptedRendererMobileSnapshotByWorktree
     )
+    const incomingPtyIds = new Set([
+      ...lifecycleLeaves
+        .map((leaf) => leaf.ptyId)
+        .filter((ptyId): ptyId is string => ptyId !== null),
+      ...published.boundPtyIds
+    ])

#23933 added a --help capability probe that runs on every Codex launch and is
deliberately uncached. This spec puts a fake codex on PATH that records every
invocation, so the probe landed in the spawn ledger and the first-mount
assertion saw two launches where one was expected.

Verified on plain main: 8/8 repetitions fail at spec line 617 with
[{args:['--help']}, {args:['--dangerously-bypass-approvals-and-sandbox',...]}],
so the breakage is independent of the retention change this branch makes.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new filter clears the spawn-ledger count, but the same probe is still recorded in signalLedgerPath, so the Linux gate fails at the signal assertion instead. Details inline.

Reviewed changes

Delta since the prior Pullfrog review (2309519): a single test-only commit, prod files unchanged.

  • Filtered the Codex --no-daemon probe out of the spawn ledger — readSpawnLedger() now drops the probe's exact ['--help'] invocation so the first-mount assertion counts one agent launch instead of two.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

.split(/\r?\n/)
.filter(Boolean)
.map((line) => JSON.parse(line) as SpawnEvent)
.filter(({ args }) => args.length !== 1 || args[0] !== '--help')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The probe this filter drops is also recorded on a second ledger, so the gate still fails. When the 5s runProcess timeout fires for ['--help'], the fake CLI's own SIGTERM handler appends {kind:'agent'} to signalLedgerPath; expect(readJsonLines(signalLedgerPath)).toHaveLength(0) at lines 712 and 841 therefore sees a probe entry. The spawn-ledger count is now clean, but the signal check is not.

Technical details
# Probe SIGTERM is written to the signal ledger

## Affected sites
- `tests/e2e/live-background-terminal-mount-authority.spec.ts:105` — new filter strips the probe from `readSpawnLedger()` only; the `signalLedgerPath` reads stay unfiltered.
- `tests/e2e/live-background-terminal-mount-authority.spec.ts:60` — the fake CLI registers `SIGINT`/`SIGHUP`/`SIGTERM` handlers that append `{kind:'agent', ...}` to `ORCA_E2E_SIGNAL_LEDGER`.
- `tests/e2e/live-background-terminal-mount-authority.spec.ts:712` and `:841` — `expect(readJsonLines(signalLedgerPath)).toHaveLength(0)`.
- `src/main/pty/codex-no-daemon-launch-command.ts:88-94` — the probe runs `program --help` with `timeoutMs: 5000`; the fake CLI never exits, so the timeout path kills it.
- `src/shared/child-process/run-process.ts:245` + `:310-316` — non-barrier timeout calls `terminate(child)` → `child.kill()` → `SIGTERM`, which the fake handler observes.
- `src/main/ipc/pty/runtime/spawn-options.ts:106-114` — the spawn awaits the probe before the agent PTY is created, so the ledger write lands before the spec reads it.

## Required outcome
- The probe must not contribute to `signalLedgerPath`. The exact-`['--help']` spawn filter is insufficient on its own.

## Suggested approach (optional)
- Filter the signal reads to the real agent/setup/canary pids (the probe pid is recorded in the spawn entry you already drop), or make the fake CLI skip signal-handler registration on the `--help` probe path.

## Evidence
- Simulated the spec's fake codex under a 5s kill: spawn ledger `{"args":["--help"]}` and signal ledger `{"kind":"agent","signal":"SIGTERM"}` are both written, because the process survives `SIGTERM` (handler installed) until the `SIGKILL` grace.

@nwparker

Copy link
Copy Markdown
Contributor Author

Linux validation: the retention fix works; a separate pre-existing defect still blocks the spec

Ran 8x repetitions on four branch variants to separate the failures. Line order matters: 617 < 663 < 673 < 712, and the spec stops at the first failure, so an early failure masks the later ones.

Variant @617 probe @663 inventory @673 input echo @712 agent SIGTERM
plain main 8/8 fail masked masked masked
main + spec fix pass 7/8 fail masked 1/1 fail
main + spec fix, 663 neutralized pass n/a 7/8 fail 1/1 fail
this PR + spec fix pass 0/8 fail 0/8 pass 7/8 fail

1. Spec was broken on main, not by this PR (fixed here)

#23933 added a --help --no-daemon capability probe that runs on every Codex launch and is deliberately uncached. This spec puts a fake codex on PATH that logs every invocation, so the probe landed in the spawn ledger and the first-mount assertion counted two launches. Plain main fails this 8/8. Fixed in 6894eb1 by excluding events whose args are exactly ["--help"]; a real launch always carries --dangerously-bypass-approvals-and-sandbox or resume, so the no-duplicate-spawn oracle is unchanged.

2. The retention fix does what it claims

With the probe fix in place, main fails the tab-inventory equality 7/8 and this PR fails it 0/8. Neutralizing that assertion on main moves the failure one step later to the input-echo check, where the PTY receives the typed marker but the visible tab never echoes it — input reaching a live PTY while the screen shows a different surface. This PR passes both. Two independent detections of the same duplicate-binding bug, both cleared.

3. Separate pre-existing defect at line 712 (not from this PR)

expect(readJsonLines(signalLedgerPath)).toHaveLength(0) receives [{kind:"agent", signal:"SIGTERM"}] — the host-owned agent process is terminated during first mount. main hits this on 2/2 of the runs that got far enough to reach it; it was invisible before only because the duplicate-binding bug failed the spec earlier. Fixing #2 unmasked it.

This needs its own investigation and fix. Until then the spec cannot go green, so this PR should not merge on a green-CI basis even though its own mechanism is validated.

Also done

Rebased onto main (was 64 commits behind) and dropped the commit that re-added codex-structured-journal-provider-verdicts.ts after #23682 deleted it — that was the sole cause of the merge conflict and the TS2307 typecheck failure. Restored the invariant comments the earlier revisions deleted (note max-lines is configured skipComments: true, so they cost no budget) and repaired two that were truncated mid-sentence. Pane identity now travels as one RuntimePaneIdentity object instead of three adjacent string arguments, which removed all three oxfmt-ignore directives. 9,600 runtime tests, node typecheck, oxlint and the changed-code quality gate all pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant