Repository navigation
fix(terminal): stop leaking the Git credential guard into terminals Orca chose not to guard - #17014
brennanb2025 wants to merge 6 commits into
Conversation
📝 WalkthroughWalkthroughThe 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 Merge Risk: 🟡 Moderate · up to 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)
✅ Passed checks (3 passed)
Full details: Description checkExplanation 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 Resolution Add the missing template sections. Provide a linked issue using
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (9)
src/main/daemon/pty-subprocess-git-credential-guard.test.tssrc/main/daemon/pty-subprocess/spawn-environment.tssrc/relay/pty-handler-revive.test.tssrc/relay/pty-handler-spawn-environment.test.tssrc/relay/pty-handler.tssrc/shared/git-credential-guard-env-test-harness.tssrc/shared/git-credential-guard-provenance.tssrc/shared/terminal-git-credential-guard-inheritance.test.tssrc/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.
28a835f to
c62d76d
Compare
Review loop — round 1 (adversarial pass)Reviewed at The defect — the marker collided with itself on the Electron→daemon boundaryThis is the important one, because the PR did not actually fix its own target bug on that boundary. The daemon merges its inherited
Fixed by undoing each marker on its own side of the merge. Pinned by a new daemon test that reads The wire question — answered, and the framing (mine included) was wrongThe marker never crosses a client↔host wire. I assumed it did, because the relay's
Rule 3 — does the host publish new content? No. A pane's spawn env is write-only: assembled, handed to 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 Is a JSON blob in the child env the right design? YesThe 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 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 "No marker means nothing is touched" — proven at all four boundaries
Gate ablation — 22 gates, each ablated individuallyFour came back structurally equivalent and are labelled as such rather than claimed as pins: A methodology note worth recording: the first ablation pass produced false reds because Gates
Not verified — stated plainly
Non-blocking observations
|
…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.
Follow-up — head now
|
There was a problem hiding this comment.
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
📒 Files selected for processing (7)
src/main/daemon/pty-subprocess-git-credential-guard.test.tssrc/main/daemon/pty-subprocess/spawn-environment.tssrc/relay/pty-handler.tssrc/shared/git-credential-guard-provenance.test.tssrc/shared/git-credential-guard-provenance.tssrc/shared/git-credential-prompt-env.tssrc/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.
baa3511 to
9a7f69d
Compare
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.
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
src/shared/git-credential-guard-provenance.test.tssrc/shared/git-credential-guard-provenance.tssrc/shared/git-credential-prompt-env.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Review loop — round 2Head JOB 1 —
|
| 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, theGIT_CONFIG_(COUNT|KEY_n|VALUE_n)keys, plus the marker name. - Restoration removed (
:186-190): those plus all ofSCALAR_KEYS— i.e. alsoGIT_ASKPASS
andSSH_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:
restoreUnguardedGitCredentialEnvstill returns at the
raw === undefinedguard; the four boundary tests still pass. - Positional
GIT_CONFIG_COUNT/KEY_n/VALUE_nprotocol: both fixes make removal narrower,
never partial —:95in 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-157still 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 theplatform: 'win32'parameter in unit tests. Given the task's emphasis
on Windows, this is the weakest point in my evidence: I reasoned aboutWSLENVsemantics and the
indexedGIT_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-smokeflake 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.
`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.
`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.
`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 <79079362+brennanb2025@users.noreply.github.com>
* 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>
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
applyTerminalGitCredentialPromptGuardlooked at a new terminal and decided "thisone 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 clonethat needs credentials does notprompt. It fails immediately:
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:
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=0yourself, deleting it would be itsown bug. On
mainthis was not distinguishable: the existingORCA_INTERNAL_TERMINAL_GIT_CREDENTIAL_GUARD_POLICYmarker is deleted on every pathbefore 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 thevalues 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)GIT_TERMINAL_PROMPT0GCM_INTERACTIVEneverGIT_ASKPASS''SSH_ASKPASS''GIT_CONFIG_COUNT/GIT_CONFIG_KEY_n/GIT_CONFIG_VALUE_ncredential.interactive=false,credential.guiPrompt=falseCOUNTWSLENVThe 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 (
readValidGitConfigEnvCountreturnsnull) it is left completelyintact rather than half-stripped. Both are tested.
WSLENValso carries the new provenance marker, so a variable stripped on theWindows side is stripped in the guest too rather than arriving guarded.
Where it is applied
applyTerminalGitCredentialPromptGuard(viamain/ipc/pty/host-env/assembly.ts)deferGitConfigGuardToHostarmcomposeGuardedDaemonGitConfigEnvindaemon/pty-subprocess/spawn-environment.tsrelay/pty-handler.ts(via the shared function)relay/pty-handler.tsrevive blockrelay/agent-exec-handler.tsalways passesisUnattended: true, so it is alwaysguarded 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:The one that passes on
mainis the preservation case — a user's ownGIT_TERMINAL_PROMPT=0with no Orca marker must not be touched. It passes beforeand 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:
Bonus fix: the guard was not idempotent
leaves a guarded child fully guardedfails onmainwithGIT_CONFIG_COUNT=4.A guarded pane nested under a guarded pane appended Orca's credential pair again,
so
GIT_CONFIG_COUNTgrew by 2 per nesting level without bound. Restore-then-decidefixes 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.
terminal-git-credential-guard.ts— restore-firstterminal-git-credential-guard.ts— record, local armterminal-git-credential-guard.ts— record, defer armspawn-environment.ts— daemon restore-firstspawn-environment.ts— daemon recordpty-handler.ts— relay revive restore-firstpty-handler.ts— relay revive recordgit-credential-guard-provenance.ts—restoreScalarsgit-credential-guard-provenance.ts—restoreIndexedConfiggit-credential-guard-provenance.ts—restoreWslEnvgit-credential-guard-provenance.ts— WSLENV marker forwardinggit-credential-guard-provenance.ts— ambiguous-protocol bailEvery 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-treeagainst #16909 head02cacf64e0is conflict-free, and I checked themerged blobs rather than trusting the exit code:
spawn-environment.tsandpty-handler.tsboth contain #16909'sremoveUnspecifiedPtyChildScopedEnvcallsand this PR's restore/record calls. Nothing #16909 adds is weakened or removed.
Testing
src/shared/terminal-git-credential-guard-inheritance.test.ts— 11 newsrc/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)src/relay src/main/daemon src/shared src/main/ipc— 12,679 passed, 82 skipped, 0 failedpnpm tcandpnpm tc:web— both exit 0oxlintclean on changed files; changed-code quality gate: 0 findings (code quality, type-aware, React Doctor)git diff --checkclean; nonode:child_processimports addedTest doubles for inherited environments are built by calling the real
applyTerminalGitCredentialPromptGuard, not by hand-writing an env dict, so theycannot omit a variable the guard actually sets.
src/shared/git-credential-guard-env-test-harness.tsgives those suites ownership ofthe credential-guard slice of
process.env. This is needed because Orca's own agentpanes export the guard — a suite that reads ambient
process.envis really readingthe pane the tests happen to run in.
What I did NOT verify
node-ptyreproduction of Git's behaviour. No$electronvalidation (this changehas no UI surface).
explicit
platform, not by running on those hosts. TheWSLENVhandling inparticular has never been exercised against a real
wsl.exe.relay's own mocked-PTY suites, not against a live remote host.
carries no provenance marker, so its children still inherit the guard — the
behaviour on
maintoday. It is deliberately conservative rather than guessing,because stripping a user's own setting is the worse failure.
credential.interactive=falsecan survive into an unguarded terminal if the protocol was already corrupt. Chosen
over a partial strip, which would break Git outright.
mainis untouched by this PR:pty-handler-spawn-environment.test.ts > leaves an ordinary Windows SSH user terminal unchangedfails on pristine65dd06a8701dwhen the suite is run from asetup-gated pane (
ORCA_SEQUENCED_STARTUP_COMMANDin the environment). That isexactly 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.