Repository navigation
Conversation
|
Correcting the trade-off section I added to this PR body — it was wrong, and understated the cost. I wrote that there was "one, small" trade-off in the safe direction. I had read one call site. There are three, and the third changes the conclusion.
if (hasRecognizedCandidate && options.readWindowsConptyProcessIds) {
const conptyProcessIds = await options.readWindowsConptyProcessIds()
if (!conptyProcessIds) {
return { available: false, processName: null }
}With a permanent-null stub, this returns And the retire path ( So the honest cost is not "agent-finished detected slightly later". It is:
That is a real regression, not a conservative degradation, and my summary hid it. Apologies — the ELI5 and the measurement stand, the trade-off list did not. There is a better design, and it is already in the tree
All three call sites keep their semantics: This PR rejected the job object as "not authoritative for foreground application identity". That is true but beside the point: the probe was never used for identity, only for membership and liveness, where the job is authoritative. Coverage matches too — patched node-pty covers local and daemon, and the SSH relay never called this module. Recommended: reimplement Floor, if pure deletion is preferred: delete at the callers rather than leaving a permanent-null stub — remove the Happy to implement the job-object version if you want it. |
|
Closing because the polling fix is already implemented in current main, and this PR's remaining permanent-null implementation would discard useful correctness behavior. At main The PR head instead always returns This disposition is based on the intended parent-to-head delta and current main's callers, not merge conflicts. Native Windows execution was not repeated in this audit. Branch preserved. |
ELI5
To work out which program is currently in the foreground of a Windows terminal pane — is Claude still running, or has it exited back to the shell? — Orca asked Windows for the list of processes attached to that pane's console.
node-pty answers that question by forking a little helper process each time you ask.
Orca asks on a poll, per pane. So with panes open and agents running, that is one short-lived
conpty_console_list_agentprocess per read, per pane, forever. On the reported machines it is hundreds of hidden processes; killing them does nothing because the next poll spawns more. RAM goes, and the machine gets unusable within minutes.The fix is to stop asking. That probe was always optional: it only ever confirmed a cached answer. So instead of forking a helper, we now return "unverifiable", and every caller already has a conservative path for that.
The measurement, from a fixture that issues 32 concurrent reads for distinct PTY roots:
maintodayUser-facing trade-offs
Summary
Relates to #10857 and STA-2715.
Invariant and owner
Falsifiable invariant: any number of foreground membership reads creates exactly zero console-list subprocesses and returns unverifiable.
The authoritative owner is src/main/providers/windows-conpty-process-membership.ts. It previously forked a one-shot helper without owning the foreground poll/cancellation topology. Local and daemon providers consume its answer and already treat null conservatively.
The other consumer is node-pty's system-ConPTY teardown path. node-pty owns that helper, its deadline, and the PTY teardown. Hidden PTYs and the Windows SSH relay reach that existing owner. This PR does not pool or admission-limit it: physical review proved that global load shedding skipped concurrent console-member cleanup, while detached descendants are outside GetConsoleProcessList entirely. The final diff therefore does not change node-pty or SSH behavior.
Reproduction and topology
Current origin/main is affected. The identical Windows fixture issues 32 concurrent reads for distinct PTY roots and stalls every helper:
This distinguishes the defect as unbounded active foreground fanout, not a persistent post-settlement leak. The two independent signals are injected fork count and OS PID liveness. The disabled arm uses the same assertion and confirms cleanup returns to zero.
Design decision
Compared before coding/rework:
Downside: production local/daemon Windows foreground confirmation no longer gets exact console membership from this path. Recognized agent routing may remain conservative or use existing process-table/hook evidence. This is intentional: unavailable is safer than stale identity or subprocess fanout.
Evidence
The earlier pushed design produced expected CI failures in its now-deleted admission test and stale child_process allowlist. Commit 8cc16c6 removes both causes. Fresh CI run 32643375247 is green, including Windows packaging, static analysis, compatibility checks, all 32 Node test shards, and the aggregate verify job.
External review state
Draft. OpenCode review remains blocked because opencode is not installed on Physical Windows 2; no installation was attempted. Linear remains unavailable as linear_not_connected, so the full Linear issue/comment/attachment read could not be completed. GitHub #10857 and linked PRs #15749/#15755 were read as evidence. No Linear/GitHub comments were posted.