Repository navigation
fix(server): ACP teardown survives processes exiting during the /proc scan - #36719
Conversation
…id-scan Fails on main: the Linux process-tree snapshot reads /proc with withFileTypes, and the lstat Node does for an entry of unknown type throws ENOENT when that process exits during the scan (#36707). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… scan The Linux process-tree snapshot listed /proc with withFileTypes, and the lstat Node does for entries of unknown type threw ENOENT when a process exited mid-scan, poisoning the session. List /proc by name instead; readLinuxProcessIdentity already skips vanished processes. Fixes #36707 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Linux ACP teardown now lists /proc by name so processes exiting during enumeration do not abort the snapshot. Existing identity and ownership safeguards remain unchanged, keeping the change narrowly scoped. You can add or adjust custom eligibility rules. Learn more. |
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
… scan (pingdotgg#36719) (cherry picked from commit 77d3358)
… scan (pingdotgg#36719) (cherry picked from commit 77d3358)
This round needed no code change. The brief said nothing had to change yet; this step was only to watch PR #36719. The fix (unchanged): makeLinuxProcessTreeController().snapshot now lists /proc by name with readdirSync("/proc") and keeps numeric entries, so Node no longer lstats each dirent; that lstat threw ENOENT when a process exited mid-scan and poisoned the ACP session. readLinuxProcessIdentity already skips vanished processes. All 37 checks passed on 53935ea. Macroscope approved with no line comments. CodeRabbit reported no actionable comments and minimal merge risk. No high-or-above findings were open, so I stopped watching the PR.
Fixes #36707
Reproduction on main
Commit origin/main 96735d7, Node v26.13.1, Linux. (1) Real run: a script imported packages/provider-acp/src/server/AcpSessionRuntime.ts, built the real controller with makePosixProcessTreeController("linux") and called snapshot() in a tight loop for 12s while a separate bash loop started batches of 20 short-lived
/bin/trueprocesses. Result: 61 of 7697 snapshot() calls threwError: ENOENT: no such file or directory, lstat '/proc/83724', the reporter's exact error from readdirSync("/proc", { withFileTypes: true }). (2) Deterministic test: added a Linux-only case to apps/server/src/provider/acp/AcpSessionRuntime.processTree.test.ts. It patches fs.readdirSync (via createRequire + syncBuiltinESMExports) to throw ENOENT/lstat for the withFileTypes read of /proc and expects snapshot() to still return the current process.vp test run src/provider/acp/AcpSessionRuntime.processTree.test.tsfails on main (1 failed | 17 passed). With the reporter's proposed fix temporarily applied (readdirSync("/proc") by name, numeric entries only), all 18 tests pass; the fix was reverted and not committed.Evidence
Stop an ACP thread during real Linux process churn, then send another message to the same session. Fresh synthetic databases; Chromium, Linux x64, Node v26.12.1; identical viewport and theme. A free ACP surrogate supplies model responses; production teardown and /proc reads run unchanged. Cgroups are read-only in a private mount namespace to exercise the process-tree fallback.
Across 30 live server cycles, base poisoned 9 sessions; head poisoned none and resumed all 30. The recordings show the same additional Stop-and-continue interaction with eight churn workers.
Reproduction scripts, instructions and runtime transcripts · Server driver
Not shown:
Tests
No new runs this round. CI on 53935ea: all 37 checks passed (Build and Typecheck, Test, Test Server 1-8, Test Web 1-2, Macroscope checks, CodeRabbit). Earlier:
vp test run src/provider/acp/AcpSessionRuntime.processTree.test.ts18/18 passed andvp run check:changedpassed everything.Not in this change
Who did the work
Run by the t3code factory in T3 Code.