Repository navigation
v1.91.297.0 fix(browse): read Windows process start times in-process so the terminal agent boots without PowerShell (GSTA-139 flaky pass) - #3545
Conversation
…hell from two flaky test paths (GSTA-139 S5) The terminal agent's identity probe launched powershell.exe Get-CimInstance with a 2 s timeout on every boot (twice when started standalone). On loaded Windows runners a launch takes ~0.94 s at p50 and up to 10.8 s, so the agent missed the watchdog test's 5 s window and a stalled launch returned an empty identity. Under Bun the start time now comes from GetProcessTimes in the same /Date(ms)/ form PowerShell's CreationDate serialises to, so records, the Node daemon (which keeps the PowerShell reader) and earlier releases agree. The kill-time command-line check still uses PowerShell. path-security-realpath builds its 8.3 alias with GetShortPathNameW instead of a PowerShell launch that stalled for 30 s and was reported as '8.3 disabled'. cookie-import-native-job prints the Restart Manager receipt when its owner assertion fails. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…fy a win32 agent by generation when readers disagree Review of d4f0ea3 (specialist + outside voice, confirmed by Windows Free Tests 40699973746 shard 3): test 5's fake child pid cannot be opened, so its start time falls back to the PowerShell query; only the owner must skip it. Adversarial note: the Bun reader and the Node daemon's PowerShell reader can disagree for a process created in a DST-ambiguous hour; on win32 a live process carrying the record's --agent-gen is still the agent, so it is stopped, never treated as gone beside a second agent. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…ine is unknown, not gone Fix-check (adversarial reviewer): when the Bun reader and a Node-written record disagree and the PowerShell command-line query also fails, the agent was read as gone and a second agent could start beside it. Base treated a failed query as unknown; this restores that. CHANGELOG [Unreleased] entry. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…turn (terminal-agent-watchdog source pin) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
E2E Evals: ✅ PASS3 executed, 0 reused rule/judge records | 0 manual accepted (unscored; no score-cache credit) | $.17 rule/judge cost | reconcile exit: 0 Profile: pr / mode Rule and judge shards
Fail-closed reconciliationSliced lane: planner → duration-packed executors → fail-closed report. Behavior cases run a pre-registered 3-trial panel (PASS at 2/3 with no contract violation); a PASS 2/3 is shown with its failed trial, never as a clean pass. Reused results retain their original provenance and expiry. Dispatched narrow screen (gstack-ship-queue ready --screen) of merge commit |
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
What changed
Windows terminal-agent boot: the owner identity read moved from two PowerShell spawns to in-process GetProcessTimes, so boot fits the 5 s watchdog window.
Before/after as text: Windows terminal-agent boot: the owner identity read moved from two PowerShell spawns to in-process GetProcessTimes, so boot fits the 5 s watchdog window
Why
The daily flaky pass (GSTA-139) found
terminal-agent-owner-watchdog.test.tsred on Windows because "terminal-agent-pid never appeared in 5 s", andpath-security-realpath.test.tsstalled for 30 s and then reported "8.3 short names are disabled". Both waited on apowershell.exelaunch that took 0.93 s at the median and up to 10.8 s onwindows-latest. The agent now reads its Windows start time in-process, so it boots in about 0.9 s, and the test builds its 8.3 alias withGetShortPathNameW.Approvals
Source: gstack-approvals record for flaky-2026-10-28-windows (display only; not an approval citation).
Summary
Under Bun,
browse/src/terminal-agent-control.tsreads a Windows process start time throughOpenProcessandGetProcessTimes. It writes the result in the/Date(<ms>)/format that PowerShell'sCreationDategives, and the two matched on 147 of 147 processes. The Node daemon (server-node.mjs) cannot loadbun:ffi, so it keeps the PowerShell reader through a lazyrequire. The kill-time check still reads the command line through PowerShell and stops a process only when it carries the record's--agent-gen.Two flaky entries are fixed at their cause (the Windows owner watchdog and the path-security alias). One gets diagnostics:
cookie-import-native-jobnow prints the Restart Manager receipt when its owner assertion fails. Eight stay Open with diagnoses in the ledger: cookie-auth (the 400 ms budget is the limiter), team-init PowerShell, land-and-deploy (about 2 s per bash+jq dispatch), qa-probe EBUSY (not reproduced in 50 tries), cookie-picker ENOBUFS (one event), cookie-import-native (no log), macOS terminal-agent-lifecycle (ps -o lstart=with a 2 s timeout) and gstack-doctor EBUSY (open PR #3273 owns that file).Test 5 in
process-liveness-windows.test.tschanged. It was an implementation-coupled expectation that moved along with the product. On Windows it expected the PowerShell mock'sfixture-owner-startas the owner start time. It now requires the in-process value, equality with a real read, and no PowerShell query naming the owner pid. Linux and macOS keep the old assertion, and a separate test still pins the PowerShell command-line check at kill time. The file went from 7 tests to 14.Blast radius
Agent records written by earlier releases and by the Node daemon still compare, because the start time keeps the same
/Date(<ms>)/format: 147 of 147 in-process reads equalled PowerShell'sCreationDateonwindows-latest(script ran, probe 40700055293). If the two readers ever disagree, for example across a time-zone change, a live process that carries the record's--agent-genis still the agent. One whose command line cannot be read isunknown. Every caller treatsunknownas hands-off. Nothing is signalled, the discovery files stay, and a second agent is refused (walked failure path, reviewer read ofkillAgentByRecord,stopAgentByRecord,spawnTerminalAgentand server.ts teardown; tests for each). Linux and macOS behaviour is unchanged.Test Coverage
All new code paths have test coverage.
process-liveness-windows.test.tscovers the in-process reader, the Node fallback, the kill-time command-line check, a reader disagreement identified by generation, and the unknown path (never signalled, never gone). Two Windows-only cases run against real processes: the in-process value equalsCreationDate, and a live agent whose identity cannot be read blocks a second one. The disagreement test was failing-first: it fails on the old reader withReceived "".Tests: 7 → 14 in
browse/test/process-liveness-windows.test.ts(+7 new).Tests ran: Windows Free Tests 6 of 6 shards green at 20d7707 (run 40704565417), all seven
win32 terminal-agent identity (GSTA-139)cases passed in shard 3. Free Tests green at 20d7707 (run 40704571615): 21 suite shards, typecheck, macOS named regressions and CSO launchers.Pre-Landing Review
REVIEW_LOOP: passes=1 blocking_found=1 deferred=0 noted=2 fixed=3 scope=frozen fix_checks=2 dispatches=2
Gate edits: test 5 in
browse/test/process-liveness-windows.test.tswas changed (Windows branch only), kept as an implementation-coupled expectation that moved with the product, per the option A approval above.One CRITICAL in pass 1, fixed: test 5's zero-PowerShell assertion also counted the fallback query for the fake child pid (Windows Free Tests 40699973746). Scoped to the owner in c397b4c.
Review notes
These are informational findings below the blocking floor, listed rather than looped:
terminal-agent-control.tsagentProcessInfostill launches PowerShell when the in-process start time already mismatches the record (specialist, confidence 6). This costs about 1 s on a stale record and does not affect correctness.unknown. That also covers a successful query whoseCommandLineis null, which happens for an elevated process that reused a dead agent's pid. The terminal pane then stays down until that process exits (adversarial fix-check, confidence 5). It fails safe: nothing is killed and no second agent starts.pii.phone.e164matches: numeric pid and/Date(...)/literals in the tests. Warn only.terminal-agent-watchdog.test.tstest 3 pins the zombie check beforereturn actual.commandLine.split. 20d7707 restores that shape without changing behaviour.Exploratory QA
Windows probes on a scratch branch measured each entry before the change (run 40697033633) and the agent boot after it (run 40700055293). 120 of 120 boots finished inside the 5 s window, compared with 78 of 80 before.
Design Review
No frontend files changed — design review skipped.
Eval Results
No prompt-related files changed — evals skipped.
TODOS
No TODO items completed in this PR.
Documentation
Status: current. No documentation changes were needed.
Scope: base 4b8c03b to head caa404d (3 commits). It covers
browse/src/terminal-agent-control.ts(the Windows start time is read in-process through GetProcessTimes under Bun and through PowerShell under Node, with the same/Date(ms)/value; on win32 a start-time mismatch counts as the agent when the command line carries the record's--agent-gen, and as unknown when the command line cannot be read), three browse test files and CHANGELOG. There were no staged, unstaged or untracked changes. All authored docs were checked by keyword search, and the relevant ones were read.Documentation health:
Coverage: all shipped features have adequate documentation. The change is an internal identity fix, and its only new export is a test seam. Diagram drift: none.
Test plan
bun testover every terminal-agent test plus process-liveness, path-security and cookie-import-native-job (24 files): no failures on Linuxbun run typecheck: cleanCreationDate147 of 147🤖 Generated with Claude Code