Skip to content

fix(terminal): stop leaking the Git credential guard into terminals Orca chose not to guard - #17014

Open
brennanb2025 wants to merge 6 commits into
mainfrom
brennanb2025/credential-guard-leak-r1
Open

brennanb2025 wants to merge 6 commits into
mainfrom
brennanb2025/credential-guard-leak-r1

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​755 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​754
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​342 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​333

ELI5

Orca deliberately turns off Git's "please type your username/password" prompt in
agent terminals, so an unattended agent can never hang forever on an invisible
prompt. It does that with a handful of environment variables.

Environment variables are inherited by every program a terminal starts. So when
applyTerminalGitCredentialPromptGuard looked at a new terminal and decided "this
one is a person, do not guard it"
— it returned right there, without removing the
guard variables the terminal had inherited from its parent. The decision was
right; the effect was never applied.

Result: a plain shell opened underneath a guarded agent pane silently kept
GIT_TERMINAL_PROMPT=0.

What you'd actually see

Before: in an ordinary terminal that happens to sit under a guarded pane, an
HTTPS git push / git fetch / git clone that needs credentials does not
prompt. It fails immediately:

fatal: could not read Username for 'https://github.com': terminal prompts disabled

Nothing in the UI explains why, and there is no way to work around what you cannot
see. Cached credentials keep working, so it shows up as intermittent auth failure
rather than an obvious misconfiguration.

After: the same terminal prompts normally:

Username for 'https://github.com':

When you'd hit it: any terminal that inherits a guarded environment — a shell
launched from inside an agent pane, an Orca process started from one, or a daemon /
SSH relay whose own process environment carries the guard.

The crux: telling Orca's guard apart from your own setting

If you genuinely exported GIT_TERMINAL_PROMPT=0 yourself, deleting it would be its
own bug. On main this was not distinguishable: the existing
ORCA_INTERNAL_TERMINAL_GIT_CREDENTIAL_GUARD_POLICY marker is deleted on every path
before the shell ever starts, so a guarded pane exports the guard values with no
Orca provenance at all.

So this PR adds the lever. When the guard is applied it stamps
ORCA_INTERNAL_TERMINAL_GIT_CREDENTIAL_GUARD_RESTORE — a small JSON record of the
values that were there before the guard ran. An unguarded terminal undoes exactly
those and nothing else, and a variable that no longer holds the guard's own value is
left alone. No marker → nothing is touched, so a user's own export survives, and a
pane guarded by an older host behaves exactly as it does today.

Guard variables handled (the full set from gitCredentialPromptGuardEnv)

Variable Guard writes Undo
GIT_TERMINAL_PROMPT 0 restore prior value, or delete
GCM_INTERACTIVE never restore prior value, or delete
GIT_ASKPASS prior, else '' delete only when the guard blanked it
SSH_ASKPASS prior, else '' delete only when the guard blanked it
GIT_CONFIG_COUNT / GIT_CONFIG_KEY_n / GIT_CONFIG_VALUE_n appends credential.interactive=false, credential.guiPrompt=false remove Orca's pair at or above the recorded append base, renumber the rest, rewrite COUNT
WSLENV registers the guard keys for WSL remove only tokens the guard added

The indexed protocol is positional, so a partial strip corrupts it. Orca's pair is
removed and the remainder renumbered as one operation; if the protocol is already
ambiguous (readValidGitConfigEnvCount returns null) it is left completely
intact
rather than half-stripped. Both are tested.

WSLENV also carries the new provenance marker, so a variable stripped on the
Windows side is stripped in the guest too rather than arriving guarded.

Where it is applied

Path Site
Local applyTerminalGitCredentialPromptGuard (via main/ipc/pty/host-env/assembly.ts)
Detached-host wire same function, deferGitConfigGuardToHost arm
Persistent daemon composeGuardedDaemonGitConfigEnv in daemon/pty-subprocess/spawn-environment.ts
SSH relay, fresh spawn relay/pty-handler.ts (via the shared function)
SSH relay, revive relay/pty-handler.ts revive block

relay/agent-exec-handler.ts always passes isUnattended: true, so it is always
guarded and needs no change.

The fix is restore-then-decide, which also makes the guard idempotent — see the
bonus fix below.

Failing-first proof

New suite src/shared/terminal-git-credential-guard-inheritance.test.ts.

On main (65dd06a8701d) — 6 of 7 fail:

Tests  6 failed | 1 passed (7)

× does not leave GIT_TERMINAL_PROMPT=0 in an ordinary user terminal
    expected "0" to be undefined
× removes the whole indexed Git config protocol coherently
× keeps a caller indexed config entry the guard appended after
× restores the user values the guard overwrote
    expected "0" to be "1"
× unwinds only the WSLENV tokens the guard added
    expected 'CALLER_VALUE/p:GIT_TERMINAL_PROMPT:GC…' to be 'CALLER_VALUE/p'
× leaves a guarded child fully guarded
    expected "4" to be "2"
✓ leaves a user terminal with no inherited guard untouched

The one that passes on main is the preservation case — a user's own
GIT_TERMINAL_PROMPT=0 with no Orca marker must not be touched. It passes before
and after, which is the point.

After the fix — 11 pass, and the pre-existing guard suite is unchanged
(src/main/ipc/terminal-git-credential-guard.test.ts, 10/10, including
"leaves ordinary user terminals unchanged on every platform").

Real Git behaviour, under a real PTY

Same binary (git 2.50.1), same repo, same clean environment, only the inherited
guard differs:

=== A) unguarded pane (no guard env) -> git PROMPTS on the tty ===
Username for 'https://github.com':

=== B) unguarded pane that INHERITED the guard -> NO prompt, hard failure ===
fatal: could not read Username for 'https://github.com': terminal prompts disabled

Bonus fix: the guard was not idempotent

leaves a guarded child fully guarded fails on main with GIT_CONFIG_COUNT=4.
A guarded pane nested under a guarded pane appended Orca's credential pair again,
so GIT_CONFIG_COUNT grew by 2 per nesting level without bound. Restore-then-decide
fixes that too; pinned by does not grow the config protocol as guarded panes nest
(3 levels deep, still 2).

Ablation table

Each production hunk deleted individually, then the covering suites re-run. Source
files were checksummed before and after the sweep and verified byte-identical.

Hunk Ablated Result
H1 terminal-git-credential-guard.ts — restore-first FAILS (12)
H2 terminal-git-credential-guard.ts — record, local arm FAILS (8)
H3 terminal-git-credential-guard.ts — record, defer arm FAILS (1)
H4 spawn-environment.ts — daemon restore-first FAILS (1)
H5 spawn-environment.ts — daemon record FAILS (1)
H6 pty-handler.ts — relay revive restore-first FAILS (1)
H7 pty-handler.ts — relay revive record FAILS (1)
H8 git-credential-guard-provenance.ts — restoreScalars FAILS (9)
H9 git-credential-guard-provenance.ts — restoreIndexedConfig FAILS (8)
H10 git-credential-guard-provenance.ts — restoreWslEnv FAILS (1)
H11 git-credential-guard-provenance.ts — WSLENV marker forwarding FAILS (1)
H12 git-credential-guard-provenance.ts — ambiguous-protocol bail FAILS (1)

Every hunk is pinned; no hunk is unpinned or excused.

Relationship to #16909

Found while reviewing #16909, and this is the second of two causes of the same
user-visible symptom. #16909 stops ordinary terminals from looking like agent
launches; this PR stops terminals correctly identified as ordinary from keeping
the guard they inherited. Neither subsumes the other.

git merge-tree against #16909 head 02cacf64e0 is conflict-free, and I checked the
merged blobs rather than trusting the exit code: spawn-environment.ts and
pty-handler.ts both contain #16909's removeUnspecifiedPtyChildScopedEnv calls
and this PR's restore/record calls. Nothing #16909 adds is weakened or removed.

Testing

  • src/shared/terminal-git-credential-guard-inheritance.test.ts — 11 new
  • src/main/daemon/pty-subprocess-git-credential-guard.test.ts — +2 (daemon inherit-strip, daemon child round-trip)
  • src/relay/pty-handler-spawn-environment.test.ts — +1 (relay fresh spawn)
  • src/relay/pty-handler-revive.test.ts — +2 (revive inherit-strip, revive child round-trip)
  • Parent suites src/relay src/main/daemon src/shared src/main/ipc — 12,679 passed, 82 skipped, 0 failed
  • pnpm tc and pnpm tc:web — both exit 0
  • oxlint clean on changed files; changed-code quality gate: 0 findings (code quality, type-aware, React Doctor)
  • git diff --check clean; no node:child_process imports added

Test doubles for inherited environments are built by calling the real
applyTerminalGitCredentialPromptGuard, not by hand-writing an env dict, so they
cannot omit a variable the guard actually sets.

src/shared/git-credential-guard-env-test-harness.ts gives those suites ownership of
the credential-guard slice of process.env. This is needed because Orca's own agent
panes export the guard — a suite that reads ambient process.env is really reading
the pane the tests happen to run in.

What I did NOT verify

  • No packaged-build or live-app run. Everything is unit-level plus a direct
    node-pty reproduction of Git's behaviour. No $electron validation (this change
    has no UI surface).
  • macOS only. Windows, WSL and Linux behaviour is covered by tests that pass an
    explicit platform, not by running on those hosts. The WSLENV handling in
    particular has never been exercised against a real wsl.exe.
  • No real SSH relay. The relay spawn and revive paths are covered through the
    relay's own mocked-PTY suites, not against a live remote host.
  • Mixed-version hosts are safe but unfixed. A pane guarded by an older host
    carries no provenance marker, so its children still inherit the guard — the
    behaviour on main today. It is deliberately conservative rather than guessing,
    because stripping a user's own setting is the worse failure.
  • Ambiguous indexed config is left intact, meaning credential.interactive=false
    can survive into an unguarded terminal if the protocol was already corrupt. Chosen
    over a partial strip, which would break Git outright.
  • One pre-existing failure on main is untouched by this PR:
    pty-handler-spawn-environment.test.ts > leaves an ordinary Windows SSH user terminal unchanged fails on pristine 65dd06a8701d when the suite is run from a
    setup-gated pane (ORCA_SEQUENCED_STARTUP_COMMAND in the environment). That is
    exactly the bug Fix inherited PTY setup launch state #16909 fixes. I verified it fails with my changes stashed, and I
    did not modify that test.

@coderabbitai

coderabbitai Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds provenance metadata for Git credential guard environment mutations. Guard application restores inherited guard state before recalculating the current guard decision. Daemon composition and relay revival record provenance for guarded panes. Restoration handles scalar variables, indexed Git configuration, and WSLENV. PtyHandler now tracks retired pane surfaces, reaps exited PTYs, and restores retirement state when panes reattach or revive. New tests cover these behaviors.

Merge Risk: 🟡 Moderate · up to 9d2e9

The change correctly restores inherited Git credential settings for ordinary terminals, but a successfully reattached relay terminal can still be terminated by stale cleanup, and WSLENV restoration may remove user-modified tokens. Merge should wait for these bounded correctness and terminal-availability issues to be fixed or explicitly accepted.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides a detailed ELI5 explanation, scope, rationale, implementation paths, testing results, limitations, and issue context. However, it omits several required template elements, inc… Add the missing template sections. Provide a linked issue using Fixes #<number>, add Visual Proof or state N/A with a reason, complete AI Disclosure as applicable, complete Review, Agent skill upstream boundary, Notes, and Checklist sec…
Docstring Coverage ⚠️ Warning Docstring coverage is 47.62% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary fix: preventing Git credential guard variables from leaking into terminals that Orca chose not to guard.
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.
Full details: Description check

Explanation

The description provides a detailed ELI5 explanation, scope, rationale, implementation paths, testing results, limitations, and issue context. However, it omits several required template elements, including a formal Linked Issue entry with Fixes #, the required Visual Proof section or exact N/A statement, the AI Disclosure section, the Review and Agent skill upstream boundary sections, the Notes section, and the checklist confirmations.

Resolution

Add the missing template sections. Provide a linked issue using Fixes #&lt;number&gt;, add Visual Proof or state N/A with a reason, complete AI Disclosure as applicable, complete Review, Agent skill upstream boundary, Notes, and Checklist sections, and confirm the required validation commands or explain that CI will cover them.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@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: Pro Plus

Run ID: e9873cda-8f63-418f-b58a-4ca21b53e4f2

📥 Commits

Reviewing files that changed from the base of the PR and between 65dd06a and 9569b1b.

📒 Files selected for processing (9)
  • src/main/daemon/pty-subprocess-git-credential-guard.test.ts
  • src/main/daemon/pty-subprocess/spawn-environment.ts
  • src/relay/pty-handler-revive.test.ts
  • src/relay/pty-handler-spawn-environment.test.ts
  • src/relay/pty-handler.ts
  • src/shared/git-credential-guard-env-test-harness.ts
  • src/shared/git-credential-guard-provenance.ts
  • src/shared/terminal-git-credential-guard-inheritance.test.ts
  • src/shared/terminal-git-credential-guard.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.

…erminals

applyTerminalGitCredentialPromptGuard decided a terminal must NOT be guarded
and then returned without removing the guard variables it had inherited from
its parent. A pane launched under a guarded agent pane kept GIT_TERMINAL_PROMPT=0
(plus GCM_INTERACTIVE, the blanked askpass pair and the indexed credential
config), so git push/fetch/clone failed with "terminal prompts disabled"
instead of asking for credentials, with nothing in the UI explaining why.

Orca-applied guard env was previously indistinguishable from a user's own
export, so the guard now stamps a provenance marker recording the pre-guard
values. Unguarded terminals undo exactly those and nothing else; an
environment with no marker is left untouched.

Applied at the local, daemon and relay (spawn + revive) boundaries.
The guard appends its two credential entries at the recorded configBase, but
the restore stripped every later entry with the same key and value too, so a
user's own credential.interactive=false added inside a guarded pane was lost
when a child terminal the guard declines to guard undid the guard.

Bound removal to [base, base + entries.length) and source the keys and values
from the guard's own entry list, so the two stay in sync.
…t was stamped into

The daemon merges its inherited process env with the request main computed, and
both can carry a provenance marker. The request's marker won the merge, so the
guard the daemon inherited from the pane Orca was launched from was never undone:
its config pair survived and the fresh guard appended a second identical pair
(GIT_CONFIG_COUNT 5, not 3), and the marker the pane then carried recorded the
wire's priors instead of the user's, so a plain shell launched inside it kept
credential.interactive=false.

Undo each marker on its own side of the merge. Adds provenance unit tests for the
unreadable-marker and unknown-version fall-through, the scalar/config/WSLENV
ownership gates, and the deferred-marker config-base guard.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/credential-guard-leak-r1 branch from 28a835f to c62d76d Compare August 28, 2026 13:09
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review loop — round 1 (adversarial pass)

Reviewed at 28a835faa4, rebased onto current origin/main, re-reviewed, and pushed as c62d76d5ee. Verdict: patch, not supersede. The design is right and the four boundaries are real. One reachable correctness defect found and fixed, five unpinned semantic gates plus the entire unreadable-marker fall-through closed.

The defect — the marker collided with itself on the Electron→daemon boundary

This is the important one, because the PR did not actually fix its own target bug on that boundary.

The daemon merges its inherited process.env with the request env main computed, and both can carry a provenance marker. The request's marker won the merge, so the guard the daemon inherited from the pane Orca was launched from was never undone. Two consequences, both of them the exact bugs this PR exists to remove:

  • its config pair survived and the fresh guard appended a second identical pair — GIT_CONFIG_COUNT 5, not 3, i.e. the non-idempotence is back;
  • the marker the pane then carried recorded the wire's priors instead of the user's, so a plain shell launched inside it kept credential.interactive=false — the leak itself.

Fixed by undoing each marker on its own side of the merge. Pinned by a new daemon test that reads expected '5' to be '3' against the PR head and passes with the fix.

The wire question — answered, and the framing (mine included) was wrong

The marker never crosses a client↔host wire. I assumed it did, because the relay's buildSpawnEnv merges rendererEnv with no allowlist. The client's sending side is what settles it:

buildPtyHostEnv — the only main-side caller of applyTerminalGitCredentialPromptGuard, and therefore the only client-side writer of the marker — is structurally unreachable when connectionId is set: spawn-preflight.ts:242 is gated on ctx.isDaemonHostSpawn, defined at :81-84 as !args.connectionId && …, and local-configure.ts:57 lives in LocalPtyProvider.configure while SshPtyProvider installs no such hook. What the client actually sends for an SSH pane is buildSshPtySpawnEnv — renderer env plus a fixed five-key ORCA_RELAY* set, a PATH prepend, and one more; no process.env spread. grep for the guard-family keys across src/renderer and src/preload returns zero hits. The relay applies the guard itself against its own process.env.

Rule 3 — does the host publish new content? No. A pane's spawn env is write-only: assembled, handed to pty.spawn, discarded. SerializedPtyEntry persists the guard as a boolean and re-derives the env on revive. PtyProcessSummary, RuntimeTerminalSummary/Show, and inspectTerminalProcess carry no env; every env: z.record(...) in the RPC layer is request-side; the orchestration evidence path is a hard seven-key allowlist; the one read-back-from-a-live-process has a *) return 0 default limiting it to nine ORCA_* names.

So this is neither Rule 1 nor Rule 3 — it is not a wire change, and capability negotiation is not required. Arguing the other side honestly: the marker does reach the user's shell. But no decoder parses it and no peer's behaviour keys off it, so Rule 2's failure mode has no analogue — the marker's absence degrades to exactly pre-PR behaviour.

The one real skew boundary is the local PTY daemon, which can outlive an app update. Old daemon + new Electron: the marker is injected verbatim, the daemon does not restore, and the leak stays unfixed for that pane's children — degraded but strictly no worse than pre-PR. Nothing chokes on it (NDJSON line cap is 16 MiB against a ~250-byte value, and addWslEnvKeys puts only the name into WSLENV, never the JSON).

Is a JSON blob in the child env the right design? Yes

The guard must be undone at a point where Orca cannot know the user's pre-guard values from anything but the environment in front of it: the daemon can outlive Electron, the relay is a detached daemon started over SSH, and Electron itself is routinely launched from a guarded agent pane. In all three the process that must undo the guard was born already guarded, so it has no pristine snapshot to diff against. The alternatives were checked, not assumed: deriving a clean base env requires a snapshot that cannot exist in those cases; stripping the guard keys unconditionally is exactly what destroys a user's own export GIT_TERMINAL_PROMPT=0; and Orca-side state keyed by an opaque id adds a lifecycle and GC problem, has a failure mode where the id outlives its record, and still puts an ORCA_INTERNAL_* var in the child env.

On privacy, measured rather than speculated: a real guarded pane already exports seven guard variables. The marker is an eighth, and every value inside it is either null or already present in the same environment — the guard never overwrites a non-empty GIT_ASKPASS/SSH_ASKPASS. The one thing it newly discloses is that the user's GIT_TERMINAL_PROMPT used to be 1.

"No marker means nothing is touched" — proven at all four boundaries

restoreUnguardedGitCredentialEnv returns at the raw === undefined guard before any mutation, and each of the four boundaries (local, defer-to-host, daemon, relay spawn + revive) has its own test proving the no-marker default. This is the property protecting a user's own export GIT_TERMINAL_PROMPT=0.

Gate ablation — 22 gates, each ablated individually

Four came back structurally equivalent and are labelled as such rather than claimed as pins: prior ?? '' in guardOwnedValue is a dead branch; Object.hasOwn in snapshot cannot see a non-string for a Record<string,string> keyed by literals; the empty-WSLENV path converges on the same delete; and — notably — moving the marker delete after the parse changes nothing. I had flagged that ordering as a suspected fall-through hazard; it was disproven rather than accepted. The real fall-through protection is the readRestoreState null return and the v !== 1 check, and both are now pinned.

A methodology note worth recording: the first ablation pass produced false reds because git checkout -- restores from the index and was silently reverting the daemon fix. The table above is from the corrected run.

Gates

pnpm tc · oxlint · git diff --check clean · npx oxfmt --write on changed paths only, never pnpm format · no max-lines disable, no suppressions, no node:child_process import. Pristine-main baseline established first with env -u ORCA_SEQUENCED_STARTUP_COMMAND -u ORCA_SEQUENCED_STARTUP_SCRIPT (52/52 pass); without that unset, one test fails on clean main — the pane-pollution trap, pre-existing and not attributable to this PR.

Not verified — stated plainly

  • No Windows host. Every win32 path — WSLENV forwarding, the WSL crossing, forwardToWsl, Windows env-block limits — was exercised only through the platform: 'win32' parameter in unit tests, never on real Windows and never through a real wsl.exe. GCM behaviour under a restored GCM_INTERACTIVE is likewise unproven.
  • No real SSH host or relay — the relay boundary was exercised with node-pty mocked.
  • No live version-skew test. Old-daemon-plus-new-Electron and the v:2 forward-skew case are argued from code and pinned by unit tests, not reproduced against two real builds.
  • Corrupt-marker reachability is an absence claim. No truncation or mangling path was found across the boundaries checked, but that cannot be proven for Windows or an exotic shell.

Non-blocking observations

  • restoreUnguardedGitCredentialEnv's boolean return is never read — all four call sites discard it. A greenfield version would be void.
  • The marker key is a single global slot shared by two producers; the fix separates them by when each is consumed rather than by key. A distinct key would make the invariant structural rather than ordering-dependent — worth considering if a third producer ever appears.

…path

guardOwnedValue and SCALAR_KEYS mirror by hand, in another file, what
gitCredentialPromptGuardEnv writes, and nothing enforced the coupling. A guard
key the provenance module does not know is simply left behind in an unguarded
child -- the leak this PR exists to close. Adding GCM_PROVIDER to the guard
leaves all 107 existing tests green.

Assert guard-then-restore is the identity, with a liveness check so a guard that
stops writing fails instead of passing trivially. Red on all three drift shapes:
a changed value, an added key, and a guard that writes nothing.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Follow-up — head now 9a7f69d81c

One more commit, closing a drift hazard that was real and completely unpinned.

guardOwnedValue and SCALAR_KEYS mirror by hand, in a different file, what gitCredentialPromptGuardEnv actually writes, and nothing enforced the coupling. The consequence is not cosmetic: a guard key the provenance module does not know about is simply left behind in an unguarded child — the exact leak this PR exists to close.

That it was unpinned is demonstrated rather than asserted: adding a GCM_PROVIDER key to the guard leaves all 107 existing tests green. A future contributor extending the guard would reintroduce the bug with a fully green suite.

The fix is a ratchet rather than a wider marker. I had suggested recording post-guard values in the marker so the "was this changed after we ran?" comparison becomes self-maintaining; that works, but it changes the marker's shape, and since an old client's v:1 marker would lack the new field it is a compatibility cost paid forever to fix a test-coverage problem. The ratchet gets the same protection for free:

  • assert guard-then-restore is the identity over the environment;
  • with a liveness check, so a guard that stops writing anything fails instead of passing trivially;
  • red on all three drift shapes — a changed value, an added key, and a guard that writes nothing.

Worth noting for the reviewer's own discipline: this is the right shape because a completeness check stated as a grep or a hand-maintained key list is exactly the kind of assertion that gets silently gamed by the next change. An identity property with a liveness guard cannot be.

Verdict unchanged: patch, not supersede. Still not merged, approved, or closed — that is Brennan's call.

@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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 37697b7d-288a-4876-a0a7-08151c92ad30

📥 Commits

Reviewing files that changed from the base of the PR and between 9569b1b and c62d76d.

📒 Files selected for processing (7)
  • src/main/daemon/pty-subprocess-git-credential-guard.test.ts
  • src/main/daemon/pty-subprocess/spawn-environment.ts
  • src/relay/pty-handler.ts
  • src/shared/git-credential-guard-provenance.test.ts
  • src/shared/git-credential-guard-provenance.ts
  • src/shared/git-credential-prompt-env.ts
  • src/shared/terminal-git-credential-guard-inheritance.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/credential-guard-leak-r1 branch from baa3511 to 9a7f69d Compare August 28, 2026 13:20
A marker whose `configBase` is negative passed `Number.isSafeInteger`, so
`restoreIndexedConfig` treated index 0 as a guard slot and deleted a
`credential.interactive` pair the user had configured themselves. The
adjacent "not a safe integer" case was already rejected; -1 slipped
through because it is one.
…wards

The guard forwards `GIT_TERMINAL_PROMPT`, `GCM_INTERACTIVE` and the indexed
config protocol into WSLENV -- never `GIT_ASKPASS`/`SSH_ASKPASS`. Restoration
removed all four scalars, so a WSLENV token the guard never added was
stripped from an unguarded child purely because it postdated the pre-guard
snapshot, destroying the user's own WSL forwarding. Both sides now read one
exported constant, so the ratchet keeps them coupled.

@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: Pro Plus

Run ID: 808329c3-f0d1-4afd-9ca3-aa071258bce6

📥 Commits

Reviewing files that changed from the base of the PR and between c62d76d and 9d2e9e7.

📒 Files selected for processing (3)
  • src/shared/git-credential-guard-provenance.test.ts
  • src/shared/git-credential-guard-provenance.ts
  • src/shared/git-credential-prompt-env.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review loop — round 2

Head 9d2e9e75c6ecf89241b8aca67825d5305e0886ee · 25 pass / 0 fail / 9 skipping · mergeStateStatus CLEAN.
Not merged, approved, or closed — Brennan's call.

JOB 1 — native-smoke (windows-latest): FLAKE, #17014 exonerated

Settled by two runs at the identical head SHA, not by a hunch:

run head_sha event created verdict
33174677495 9a7f69d81c39… pull_request, PR 17014 13:16:45Z pass
33174955482 9a7f69d81c39… pull_request, PR 17014 13:20:37Z fail

Same commit, same event, same PR, 4 minutes apart.

Attribution could not come from main. computer-e2e.yml gates native-smoke on
if: github.event_name == 'pull_request', so main's scheduled runs show it skipped —
main has never run this job. Same shape as the PR Checks trap on #16915.

Byte-identical test file lists (the #16915 bar): the job's vitest invocation is hardcoded
in the workflow YAML; extracted from both logs and sha256 matched —
ec7b1c3032da9ca03425d70f4aa8126946b7d874eb6d211ae05a0f7abf375549 for both. 37 files, identical.

The failing test: src/main/ssh/ssh-remote-cli-launcher.test.ts >
preserves a multiline argument through the compiled remote launcher. It runs a real csc.exe
compile via powershell.exe
on a hosted Windows runner, under a 15s itWindows budget whose own
comment says cold csc.exe startup already blows the default. Timings for that one assertion on
this branch today:

2178 · 2102 · 7144 · 6827 · 7889 · 35438 (FAIL, cap 15000) · 5402 · 11871 ms

A 17x spread, and the best recent pass clears the cap by only 3.1s. Wall-clock bound on
external process startup.

Structural exoneration too: the job's 37 test files are fixed in the YAML, and none of the
PR's 11 changed files appears in that list or is imported by it
— ssh-remote-cli-launcher.ts
pulls in only ssh-remote-platform and ssh-remote-powershell. The PR's code is never loaded by
this job. The job runs at all only because the path filter includes src/main/daemon/**.

Pass rate: 7/8 = 87.5% on this branch today; 2 pass / 1 fail at 9a7f69d81c specifically
(one of those passes is the rerun I triggered, which turned the check green).

Recommended follow-up, not taken here: raise that one test's timeout. It belongs in its own PR —
touching it from #17014 would be unrelated scope on a file this PR does not own.

JOB 2 — both threads REAL, both fixed, both replied-to before resolving

thread verdict commit reply resolved
git-credential-guard-provenance.ts:95 — negative configBase Real e6054e671d r3881036410 yes (by coderabbitai after the push)
git-credential-guard-provenance.ts:190 — WSLENV over-removal Real 9d2e9e75c6 r3881038433 yes (by me)

:95 — a negative base makes slot 0 look guard-owned

Number.isSafeInteger(-1) is true, so -1 reached restoreIndexedConfig. With
GUARD_CONFIG_SLOT_COUNT === 2 the window at :146 becomes index >= -1 && index < 1, marking
index 0 guard-owned and deleting a user's own credential.interactive=false pair, then
rewriting the positional protocol. RED pre-fix: expected '1' to be '2' on GIT_CONFIG_COUNT.

Why it slipped is the interesting part: the adjacent ignores a configBase that is not a safe integer case already covers "0", 0.5, 1e400, true. Its intent was to reject every base the
guard cannot have written; -1 evaded it precisely by being a safe integer. A gap in an
existing contract, not a new one. Reachability stated honestly: Orca never writes a negative base
(readValidGitConfigEnvCount returns 0..n or null), so this needs a forged or mangled marker.
Worth closing anyway — every other marker field is already validated defensively, and this was the
one unvalidated field whose bad value triggers a destructive act against the user's own config.

:190 — the WSLENV removal set was a strict superset of the add set

  • Guard adds to WSLENV (git-credential-prompt-env.ts:118): GIT_TERMINAL_PROMPT,
    GCM_INTERACTIVE, the GIT_CONFIG_(COUNT|KEY_n|VALUE_n) keys, plus the marker name.
  • Restoration removed (:186-190): those plus all of SCALAR_KEYS — i.e. also GIT_ASKPASS
    and SSH_ASKPASS.

Checked as an absence claim rather than from one call site: all 14 non-test addWslEnvKeys call
sites
in src/ — none adds an askpass name. So those two could only ever be removed by the
"absent before the guard ⇒ ours" inference, which is wrong for a name the guard never adds. A WSL
user who forwards their own askpass from inside a guarded pane
(export WSLENV=$WSLENV:GIT_ASKPASS/p) has it deleted by the next unguarded spawn — the leak's
mirror image, hitting the exact invariant this PR exists to protect. Contrast restoreScalars,
which gets this right by only touching a key still holding guardOwnedValue; restoreWslEnv had
no equivalent ownership test.

I did not take the proposed fix. Recording added names in RestoreState works but widens the
marker for what is a coupling problem, and an old v:1 marker would lack the field — a compat cost
carried forever. Both sides now read one exported constant,
GIT_CREDENTIAL_GUARD_WSLENV_SCALAR_KEYS.

Narrowing did not weaken drift protection — probed, not assumed. Making the guard forward an
extra WSLENV name the constant does not cover turns two tests red, including r1's
undoes every key the real guard writes on win32 ratchet.

Ablation discipline

Each fix reverted individually: reverting only >= 0 reds only the configBase test (16 others
green); reverting only the WSLENV narrowing reds only the WSLENV test. Neither is jointly pinned.
Worktree git status hashed identical before and after ablation. The two commits were split from a
single validated change and the recombined diff was verified byte-identical to the pre-split
state.

Must-not-regress — all still hold

  • Three-state distinction (present / genuinely absent / read failed) untouched.
  • No marker ⇒ no change: restoreUnguardedGitCredentialEnv still returns at the
    raw === undefined guard; the four boundary tests still pass.
  • Positional GIT_CONFIG_COUNT/KEY_n/VALUE_n protocol: both fixes make removal narrower,
    never partial — :95 in fact prevents a partial strip.
  • Non-idempotence fix (restore-then-decide) intact.
  • Round-1 P1, the Electron→daemon marker collision, verified still held after my edits to the same
    module: spawn-environment.ts:145-157 still undoes each marker on its own side before the
    merge, and its pin (does not double the guard when the daemon inherited one and the request carries its own) passes.
  • Wire compat: no marker shape change, no new field, no new opcode. Panes guarded by an older host
    still leak by design — left alone.

Extra red found and attributed: e2e / ssh docker watcher isolation

This lane had never reported on this PR before (earlier runs were cancelled by newer pushes).
It went red on my head, then passed on rerun at the identical head 9d2e9e75c6.
Failing spec was ssh-pi-compatible-agent-title.spec.ts:147 with
No remote worktree found for /tmp/orca-docker-relay-perf-repo, amid SSH transport reconnects and
an EADDRINUSE on port forwarding — the known hydration race (#17017), not a title assertion.
I verified the spec ran in the earlier passing run too, so I did not lean on a "first run" excuse.

My two commits are structurally inert on Linux, which is what makes this attributable:
restoreWslEnv early-returns on env.WSLENV === undefined, the guard only writes WSLENV under
platform === 'win32', and configBase >= 0 only bites on a value Orca never writes.

Gates

pnpm tc exit 0 · oxlint clean · git diff --check clean · npx oxfmt --write on the three
changed paths only, never pnpm format · no max-lines disable or bump · no node:child_process
import added · pre-commit hook ran oxlint + react-doctor + oxfmt on both commits.
Suites: 129 passed / 8 skipped across provenance, inheritance, daemon guard, relay revive, relay
spawn-env, git-binary-compat and git runner. Run with
env -u ORCA_SEQUENCED_STARTUP_COMMAND -u ORCA_SEQUENCED_STARTUP_SCRIPT — the documented agent-pane
pollution trap.

NOT verified — stated plainly

  • No real Windows host and no real wsl.exe. The WSLENV fix is the Windows-specific one and is
    exercised only through the platform: 'win32' parameter in unit tests. Given the task's emphasis
    on Windows, this is the weakest point in my evidence: I reasoned about WSLENV semantics and the
    indexed GIT_CONFIG_* protocol from code, not from a live WSL crossing.
  • Docker is dead on this machine, so no Docker-SSH spec ran locally — that lane's verdict rests
    entirely on CI, including the rerun.
  • No real SSH host or relay exercised locally.
  • The native-smoke flake conclusion rests on 8 CI samples on one branch on one day; I did not
    survey other branches for the same test.
  • I did not re-audit round 1's findings, per instructions.

brennanb2025 added a commit that referenced this pull request Aug 29, 2026
`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.
brennanb2025 added a commit that referenced this pull request Aug 30, 2026
`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.
nwparker pushed a commit that referenced this pull request Aug 31, 2026
`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.
nwparker added a commit that referenced this pull request Aug 31, 2026
* 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 <79079362+brennanb2025@users.noreply.github.com>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* 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 <79079362+brennanb2025@users.noreply.github.com>

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