Repository navigation
fix(daemon): close #16924 review P2s — degrade warn, reap comment, Windows claim-reap CI - #16979
brennanb2025 wants to merge 6 commits into
Conversation
Independent exact-head review —
|
Review loop — round 1Reviewed at Stacking is intact. The question this review had to answer: are the three P2 fixes each independently pinned? Two were. One was not. P2a — the degrade warning: pinned, but its ordering was notThe warn sits in the Ablating each gate individually, which is the discipline #16926 asked for:
The second row is the hole. Emitting the warn on every link failure, including a routine lost publish race, kept the whole suite green — the EEXIST test only asserts After the fix the two arms fail independently, which is the point:
Each ablation reds exactly one distinct test. The existing P2b — the reap comment: correct, and structurally unpinnableThe ENOENT is non-EEXIST, so it degrades, and the P2c — dual-list wiring: correct, but the two lists are unenforced
The gap: Gates
Not verifiedCI on this branch last ran against a base 45 commits behind current |
Round 1 addendum — the degrade warning could not reach an operatorFollow-up to the review above. Pushed as Chasing whether The chain, all from this repo:
The convention for this exact situation is already in the file three lines from the call site. this.options.log.log('endpoint-publish-declined', { reason: outcome.status })
console.warn(`[daemon] Endpoint unavailable at startup: reason=${outcome.status}`)…and
Ablation — both new gates load-bearing and independent
The second gate exists for the same reason as the Gates
Still outstanding from the review above
|
Round 1 final — stack base moved, plus a false-alarm fixHead now
|
| ablation | result |
|---|---|
| warn back above the degraded write | 1 red — stays silent when the degraded write itself loses the ownership race |
strip describeErrnoCode's guard |
1 red — names the errno even when the link error carries none |
Each reds exactly one distinct test — combined with the two tables above, all six assertions added across this review fail independently.
Gates
tsc 0 errors. src/main/daemon/: 149 files / 1695 tests pass. oxfmt on changed files only, oxlint clean, git diff --check clean.
Carried forward, not fixed
deadPid()indaemon-pid-publish-claim-reap.test.ts:13-18is a PID-reuse race. It returns the pid of a just-exitedspawnSyncand relies onprocess.kill(pid, 0)throwing ESRCH. Windows recycles PIDs more aggressively, and this PR is what puts that test on Windows CI — so while the race is inherited from fix(daemon): make pid-record publish atomic via claim-then-link #16924, this PR is where it becomes a flake risk. One greenwindows-2022run is not evidence of stability.WINDOWS_PACKAGE_TESTSinconfig/scripts/pr-code-change-scope.mjsand the duplicate list in.github/workflows/pr.ymlremain unenforced against each other.- Not verified: no execution on a real hard-link-incapable volume (the degrade is fault-injected), and no
windows-2022run of my own.
|
CI note: Still recommend rebasing onto #16924's current head |
Gate-level ablation audit — 4 unpinned arms now pinned (tests only)Standing audit for "is any conservative arm only jointly pinned?". Every guard, early return, errno check, and individual conjunct on the publish/reap path was reverted alone, with all others left intact, against Before this commit, 8 of 18 arms could each be deleted with the whole Newly pinned (each test fails with its own arm reverted, passes with it restored, and is not triggered by any other arm's ablation)
Left in place as defence-in-depth — genuinely unpinnableThese four are strictly dominated: on every input the regex can produce, the outcome is identical with or without them, so any test would pass for the wrong reason.
All four are cheap and correct, and each becomes load-bearing the moment the ESRCH check or the claim-name shape changes. Recommendation: keep them. Flagging rather than testing them is deliberate — a test here would assert an unreachable branch. Notes
|
4a48655 to
f4c07f1
Compare
…ment, run claim-reap contract on Windows CI
…e warning The EEXIST rethrow sits above the non-atomic degrade warning precisely so a lost publish race stays quiet, but nothing pinned that order: moving the warn above the rethrow left all seven atomicity tests green. Assert the conflict path warns zero times so the two arms fail independently.
…mon keeps The degrade warning exists so an operator on a volume without hard links can tell torn-write protection is off, but publishDaemonPidFile runs inside the detached daemon: daemon-init spawns it with stdio 'ignore' and destroys the startup stderr pipe once it reports ready, so console alone reaches nobody on exactly the path the warning was written for -- the constraint daemon-file-log states in its header comment. Take an optional log and emit both, matching daemon-endpoint-lifecycle's handling of the sibling endpoint degrade three lines from this call site.
…ublished The warning sat above the degraded exclusive write, but that write can itself throw EEXIST: a daemon losing an ownership race on a hard-link-incapable volume announced 'torn-write protection is off for this record' for a record it never wrote. Announce after the write lands, so the claim is true when it is made. Also pin describeErrnoCode's no-code branch, which existed for exactly the exotic-volume error the degrade handles and was never exercised.
Gate-level ablation of the publish/reap path found four conservative arms that could each be reverted alone with the whole src/main/daemon suite (1695 tests) still green: - claimOwnerIsProvenDead's ESRCH-only check: accepting any errno as death reaps a LIVE foreign-owned publisher's claim, knocking that publish off the atomic path onto the degraded write - the rmSync swallow in the reap loop: an unremovable claim escaped into ensureRunning and blocked the launch the reap is only hygiene for - the EEXIST rethrow in publishDaemonPidFile: modelled with the canonical path free, so the fallback write succeeds and silently takes ownership the EEXIST exists to deny - the finally-unlink swallow: a failed claim write leaves no claim, so the cleanup's ENOENT replaced the real ENOSPC in the caller's error Each new test fails with its own arm reverted and passes with it restored; the other arms' ablations do not trigger it. No production change.
f4c07f1 to
91281c4
Compare
The Windows lane now runs daemon-pid-publish-claim-reap.test.ts, but its only foreign-owner gate injected EPERM — the POSIX errno. Windows reports a live but unsignalable process as EACCES (isPermissionError in win32-utils treats EACCES and EPERM as one), so the errno that lane can actually see had no gate. The fence is already correct there: it reaps only on ESRCH, so every other errno reads as alive. No production change — this pins that for EACCES too, so a later broadening to "any kill() error means dead" cannot land unnoticed and delete a live publisher's claim on Windows.
`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>
|
Obsolete: this follows up an unmerged parent PR whose code never reached main. |
ELI5
Its parent PR made Orca's terminal helper write its "I'm running, here's my id" note in one
all-or-nothing move, so a crash mid-write can't leave half a note behind. That trick needs a
filesystem feature that a few setups don't have — network drives and some container filesystems —
and on those Orca quietly went back to the old, interruptible way of writing. Quietly is the problem:
nobody could tell which mode they were in.
This PR makes Orca say so in its log when it has to fall back, corrects a comment that described the
wrong failure, and makes the existing safety check for leftover scratch files actually run on Windows
in CI. Nothing you click behaves differently.
User-facing before / after
When it bites
Only people whose Orca data directory is on a filesystem that refuses hard links — network home
directories and some container/VM setups. Everyone else sees no change at all; this PR adds a
diagnostic, not a behaviour.
Follow-up to #16924 closing the three P2s from its review (comment 5447786752). Stacked on
brennanb2025/daemon-pid-atomic-publish-r1because the code under change exists only there; after #16924 merges this needs a manual retarget onto main.daemon-pid-publish-claim-reap.tsclaimed deleting a live publisher's claim "would fail that publish". It actually knocks the publish off the atomic path: the link fails non-EEXIST and degrades to the exclusive direct write, which succeeds but reopens the torn-write window. Comment now says exactly that.publishDaemonPidFilewas silent. It nowconsole.warns with the errno, so an operator on a filesystem without hard links (network mounts, container overlays) can tell the atomic path is not in use. Pinned by the atomicity test: warn fires exactly once on the degrade path (ablation-proven failing-first — reverting the production hunk fails the test), and the normal atomic path asserts no warn.process.kill(pid, 0)/ ESRCH) was untested on Windows CI, and Windows process-existence probing is a different mechanism (OpenProcess, not POSIX signals).daemon-pid-publish-claim-reap.test.tsalready asserts with real fs and real processes that the reaper does NOT reap a claim whose owner is alive and DOES reap one whose owner is gone; it is now wired into the package (windows) job the same way fix(daemon): make pid-record publish atomic via claim-then-link #16924 wired the disk-contract test — added to BOTH thepr.yml"Test Windows-specific boundaries" vitest list ANDWINDOWS_PACKAGE_TESTSinconfig/scripts/pr-code-change-scope.mjs. Editing those two files is GLOBAL_FORCE, so this PR's own CI run executes the file on windows-2022 as the proof.No change to the link-vs-rename design (the three EEXIST-dependent call sites are untouched). Local: 37/37 daemon pid tests green,
pnpm tc:nodeclean, oxlint clean, both CI-wiring pin suites green (25/25).