Repository navigation
fix(windows): let a build with no job exports still retire a dead agent - #16563
Conversation
#16419 (a1ec047) routed the foreground poll's liveness question to the job object. On a build whose node-pty lacks the job exports the read returns null, which judgeCachedAgentJobEvidence reports as 'unavailable' -- correctly refusing to treat loss of contact as death. But that is the wrong reading here, and it matters more than it looks: **every shipped Windows release is such a build.** The patch adding listJobProcessIds is in no v1.4.* tag, 1.4.188 included (#16059). So for every Windows user today the read is null on every poll, the verdict is always 'unavailable', and the retire path never fires at all. Their panes keep a dead agent's name indefinitely, and because a non-null cache makes idleNoEvidenceShell false, the refresh also stays pinned at the 1s TTL instead of backing off to 15s. That is worse than what #16419 replaced: the forked probe was expensive but it did retire. The distinction the verdict was missing is between "we could have asked and could not" and "there is nothing to ask". Only the first is unverifiable. A build with no job exports is the second, so it now returns 'unsupported' and the authoritative scan decides alone -- exactly as it already does off Windows. Deliberately NOT falling back to the forked console probe: that is the #10857 storm this whole path exists to avoid, and re-forking per poll for the entire current fleet would be the worse trade. The scan that reaches this branch has already reported available and found no agent; trusting it needs no fork. Also deliberately not age-based: an earlier draft retired on age alone, which would expire a LIVE agent that a scan could have confirmed, since 'unproven' short-circuits the scan. isWindowsPtyJobReadable() sits beside the read rather than being imported from windows-pty-job, so one module mock controls both facts. Without that, every Windows-simulating test on a macOS runner silently took the unsupported path, because isPtyJobOwnershipAvailable() is false off Windows -- the suite would have been testing a configuration no Windows user has.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe change adds Merge Risk: ⚪ Minimal · up to This change restores retirement of dead Windows agents on builds without job exports, with the described tests and checks passing; no actionable merge-blocking risk remains beyond normal review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Description checkExplanation The description provides a clear ELI5 explanation, change summary, rationale, linked issue references, implementation boundaries, and detailed testing evidence. Several template headings and checklist items are not present, but the core required information is covered. ✨ Finishing Touches📝 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 |
Nine of the nineteen files mocking windows-pty-job-membership supplied only readWindowsPtyJobProcessIds, so isWindowsPtyJobReadable resolved to undefined in those suites. They pass today only because none of them reaches the call; the first one that does gets 'isWindowsPtyJobReadable is not a function'. Left alone this is the same trap the export exists to prevent -- a suite that is green about a configuration no user runs -- just arriving as a crash instead of a wrong answer. All nineteen now declare which build they simulate.
…nt (stablyai#16563) * fix(windows): let a build with no job exports still retire a dead agent stablyai#16419 (a1ec047) routed the foreground poll's liveness question to the job object. On a build whose node-pty lacks the job exports the read returns null, which judgeCachedAgentJobEvidence reports as 'unavailable' -- correctly refusing to treat loss of contact as death. But that is the wrong reading here, and it matters more than it looks: **every shipped Windows release is such a build.** The patch adding listJobProcessIds is in no v1.4.* tag, 1.4.188 included (stablyai#16059). So for every Windows user today the read is null on every poll, the verdict is always 'unavailable', and the retire path never fires at all. Their panes keep a dead agent's name indefinitely, and because a non-null cache makes idleNoEvidenceShell false, the refresh also stays pinned at the 1s TTL instead of backing off to 15s. That is worse than what stablyai#16419 replaced: the forked probe was expensive but it did retire. The distinction the verdict was missing is between "we could have asked and could not" and "there is nothing to ask". Only the first is unverifiable. A build with no job exports is the second, so it now returns 'unsupported' and the authoritative scan decides alone -- exactly as it already does off Windows. Deliberately NOT falling back to the forked console probe: that is the stablyai#10857 storm this whole path exists to avoid, and re-forking per poll for the entire current fleet would be the worse trade. The scan that reaches this branch has already reported available and found no agent; trusting it needs no fork. Also deliberately not age-based: an earlier draft retired on age alone, which would expire a LIVE agent that a scan could have confirmed, since 'unproven' short-circuits the scan. isWindowsPtyJobReadable() sits beside the read rather than being imported from windows-pty-job, so one module mock controls both facts. Without that, every Windows-simulating test on a macOS runner silently took the unsupported path, because isPtyJobOwnershipAvailable() is false off Windows -- the suite would have been testing a configuration no Windows user has. * test: give every job-membership mock the readability export Nine of the nineteen files mocking windows-pty-job-membership supplied only readWindowsPtyJobProcessIds, so isWindowsPtyJobReadable resolved to undefined in those suites. They pass today only because none of them reaches the call; the first one that does gets 'isWindowsPtyJobReadable is not a function'. Left alone this is the same trap the export exists to prevent -- a suite that is green about a configuration no user runs -- just arriving as a crash instead of a wrong answer. All nineteen now declare which build they simulate.
…nt (stablyai#16563) * fix(windows): let a build with no job exports still retire a dead agent object. On a build whose node-pty lacks the job exports the read returns null, which judgeCachedAgentJobEvidence reports as 'unavailable' -- correctly refusing to treat loss of contact as death. But that is the wrong reading here, and it matters more than it looks: **every shipped Windows release is such a build.** The patch adding listJobProcessIds is in no v1.4.* tag, 1.4.188 included (stablyai#16059). So for every Windows user today the read is null on every poll, the verdict is always 'unavailable', and the retire path never fires at all. Their panes keep a dead agent's name indefinitely, and because a non-null cache makes idleNoEvidenceShell false, the refresh also stays pinned at the 1s TTL instead of backing off to 15s. That is worse than what stablyai#16419 replaced: the forked probe was expensive but it did retire. The distinction the verdict was missing is between "we could have asked and could not" and "there is nothing to ask". Only the first is unverifiable. A build with no job exports is the second, so it now returns 'unsupported' and the authoritative scan decides alone -- exactly as it already does off Windows. Deliberately NOT falling back to the forked console probe: that is the stablyai#10857 storm this whole path exists to avoid, and re-forking per poll for the entire current fleet would be the worse trade. The scan that reaches this branch has already reported available and found no agent; trusting it needs no fork. Also deliberately not age-based: an earlier draft retired on age alone, which would expire a LIVE agent that a scan could have confirmed, since 'unproven' short-circuits the scan. isWindowsPtyJobReadable() sits beside the read rather than being imported from windows-pty-job, so one module mock controls both facts. Without that, every Windows-simulating test on a macOS runner silently took the unsupported path, because isPtyJobOwnershipAvailable() is false off Windows -- the suite would have been testing a configuration no Windows user has. * test: give every job-membership mock the readability export Nine of the nineteen files mocking windows-pty-job-membership supplied only readWindowsPtyJobProcessIds, so isWindowsPtyJobReadable resolved to undefined in those suites. They pass today only because none of them reaches the call; the first one that does gets 'isWindowsPtyJobReadable is not a function'. Left alone this is the same trap the export exists to prevent -- a suite that is green about a configuration no user runs -- just arriving as a crash instead of a wrong answer. All nineteen now declare which build they simulate. (cherry picked from commit 5e900b1)
…nt (stablyai#16563) * fix(windows): let a build with no job exports still retire a dead agent stablyai#16419 (882741f) routed the foreground poll's liveness question to the job object. On a build whose node-pty lacks the job exports the read returns null, which judgeCachedAgentJobEvidence reports as 'unavailable' -- correctly refusing to treat loss of contact as death. But that is the wrong reading here, and it matters more than it looks: **every shipped Windows release is such a build.** The patch adding listJobProcessIds is in no v1.4.* tag, 1.4.188 included (stablyai#16059). So for every Windows user today the read is null on every poll, the verdict is always 'unavailable', and the retire path never fires at all. Their panes keep a dead agent's name indefinitely, and because a non-null cache makes idleNoEvidenceShell false, the refresh also stays pinned at the 1s TTL instead of backing off to 15s. That is worse than what stablyai#16419 replaced: the forked probe was expensive but it did retire. The distinction the verdict was missing is between "we could have asked and could not" and "there is nothing to ask". Only the first is unverifiable. A build with no job exports is the second, so it now returns 'unsupported' and the authoritative scan decides alone -- exactly as it already does off Windows. Deliberately NOT falling back to the forked console probe: that is the stablyai#10857 storm this whole path exists to avoid, and re-forking per poll for the entire current fleet would be the worse trade. The scan that reaches this branch has already reported available and found no agent; trusting it needs no fork. Also deliberately not age-based: an earlier draft retired on age alone, which would expire a LIVE agent that a scan could have confirmed, since 'unproven' short-circuits the scan. isWindowsPtyJobReadable() sits beside the read rather than being imported from windows-pty-job, so one module mock controls both facts. Without that, every Windows-simulating test on a macOS runner silently took the unsupported path, because isPtyJobOwnershipAvailable() is false off Windows -- the suite would have been testing a configuration no Windows user has. * test: give every job-membership mock the readability export Nine of the nineteen files mocking windows-pty-job-membership supplied only readWindowsPtyJobProcessIds, so isWindowsPtyJobReadable resolved to undefined in those suites. They pass today only because none of them reaches the call; the first one that does gets 'isWindowsPtyJobReadable is not a function'. Left alone this is the same trap the export exists to prevent -- a suite that is green about a configuration no user runs -- just arriving as a crash instead of a wrong answer. All nineteen now declare which build they simulate.
Follow-up to #16419 (
a1ec0479e21). Found while triaging Windows issues, not reported by a user — but it affects every Windows user today.ELI5
#16419 moved the foreground poll's "is this agent still alive?" question from a forked helper to the pane's Win32 job object — the #10857 fix. When the job read returns
null, the verdict is'unavailable', and perdocs/reference/ssh-execution-boundary.mdthat must never be read as death. So the code holds the cached identity.Correct rule, wrong case. Every shipped Windows release returns
nullhere, because the node-pty patch that addslistJobProcessIdsis in nov1.4.*tag, 1.4.188 included (#16059 — I confirmed withgit tag --contains).So for the entire current Windows fleet:
Two user-visible symptoms today: a pane keeps showing an agent's name indefinitely after it exits, and because a non-null cache makes
idleNoEvidenceShellfalse, the refresh stays pinned at the 1 s TTL instead of backing off to 15 s — so every pane that ever ran an agent rescans the process table once a second, forever.The fix
The verdict was missing a distinction:
'unavailable', still holds. Unchanged.'unsupported', and the authoritative scan decides alone, exactly as it already does on macOS and Linux.The scan that reaches this branch has already reported
availableand found no agent, so trusting it costs nothing extra.Two things I deliberately did NOT do
No fallback to the forked console probe. That is the #10857 storm this path exists to eliminate, and re-forking per poll for the whole current fleet would be a worse trade than the bug being fixed.
No age-based retirement. My first draft returned
'unproven'/'expired'on age alone. That is wrong:'unproven'short-circuits the scan, so a live agent that a scan would have confirmed gets retired at 30 s. Deferring to the scan has neither problem.A testing trap worth flagging
isWindowsPtyJobReadable()is exported fromwindows-pty-job-membership.ts, beside the read, rather than imported fromwindows-pty-job.ts. That is not cosmetic:isPtyJobOwnershipAvailable()returnsfalseoff Windows, so on a macOS runner every Windows-simulating test would have silently taken the unsupported path — the suite would have been green about a configuration no Windows user has. Co-locating it means the module mock those 19 test files already use controls both facts, and each now declares which build it is simulating.Verification
'unsupported'back into'unavailable'turns them red.pty-subprocess-foreground-degraded-scan.test.tsdrives a shipped-fleet build (no job exports) and asserts the identity actually retires. Also mutation-verified.src/main+src/shareddiffed against anorigin/mainbaseline run in a scratch worktree: no regressions. Six files differed; all six pass in isolation, andsetup-agent-sequencingis flakier onmain(2/3 runs fail there, 0/3 here).Note on release ordering
This makes the code correct on both build kinds, so it does not depend on when the node-pty patch ships. But #16059's first item still stands independently: until a release is cut from a commit containing the patch, Windows users get no job-object teardown at all, and this PR only restores retirement for them — not the job mechanism itself.