Skip to content

test(sandbox): the process-reaper "share one read" test fails in CI with 169–182 reads in flight #4209

Closed

Description

@yannickmonney

The daemon Unit test signalExecProcesses > scans that run at once share one read of a stuck process (services/sandbox-runtime/daemon/src/process-reaper.test.ts:376) sometimes fails in CI. It expects pendingProcReads() to be 1 and gets well over a hundred. The PRs it failed on don't touch the daemon. Agents can't re-run jobs (the token gets HTTP 403 on POST …/jobs/{id}/rerun), so each failure costs the PR a new push and another full CI cycle while CI is saturated.

Occurrences

Each row is read from the job log.

Run / job PR at head Result
37163264839 / 111321565146 #4191 at 0f498dc92 Expected: 1, Received: 182 at 00:13:30Z (347 ms)
37164487001 / 111325069441 #4195 at 2ae1bf7c1 Expected: 1, Received: 169 at 00:29:44Z (125 ms)

The same test passed in the same window on #4190 (111321948276, 00:20Z) and #4193 (111325809401, 00:50Z). Both failures ran on ubuntu-24.04 hosted runners.

What the test and code do

  • The test builds a fake process table with two pids: 42, tagged, and 41, whose environ is a FIFO that never answers. It starts two taggedPids scans and one groupMembers scan, waits 100 ms and expects one read in flight, since the scans share the stuck read.
  • pendingProcReads() returns the module-global readsInFlight (process-reaper.ts:139). It counts every tracked read in the process: the listing, each stat and each environ, for any procRoot.
  • With two fake pids, this test alone can't put 169 or 182 reads in flight. Those counts are close to the number of processes on a hosted runner.

Likely cause (unverified)

Another scan of the real /proc was in flight when the assertion ran. bun test runs the daemon's files in one process, and in run 37163264839 exec-manager.test.ts ran before process-reaper.test.ts. A reaping round that an earlier file started or scheduled with the default procRoot would add one read per real process. Those reads can queue behind the stuck FIFO read in libuv's small pool, so on a slow runner they're still out at the 100 ms mark. Locally they finish first and the test passes.

Acceptance

  • Confirm or refute the cause above, with a deterministic local reproduction if feasible. For example, start a real-/proc scan, or an earlier file's delayed round, just before the assertion.
  • The test proves the sharing property using only its own reads: a per-root count, a delta, or isolated state. It must not weaken the "one read per stuck process" assertion or add a blanket retry.
  • If earlier tests leave scans or timers running into later files, they end them in their own teardown.
  • No change to production reaping behaviour unless the investigation finds a production defect. If it does, describe it separately.
  • An independent review by a distinct agent.

Coordination

PR #4167 (TALE-500, the #4125 follow-ups) also edits process-reaper.ts and this test file, and is open. Agree on ordering with that PR so the two don't conflict.

Related: #4097 (introduced the test), #4125 (MEDIUM 3: a stuck read can exhaust the pool).

Activity

  1. yannickmonney commented on Oct 4, 2026

    @yannickmonney
    ContributorAuthor

    Third occurrence: #4165 at e8a371dc4444e9f2b4f7731588825d3e3d25b7d7, run 37164130485 / job 111325050575, completed 00:34:12Z. Same test and line, Expected: 1, received 33. That run had 321 passes, 2 skips and 1 failure. #4165 doesn't touch the daemon either.

    The count varies from run to run (33, 169, 182), which fits reads from another scan that happen to be in flight at the assertion rather than a fixed leak.

  2. yannickmonney commented on Oct 4, 2026

    @yannickmonney
    ContributorAuthor

    TALE-527 — #4209 / #4170 reconciliation receipt

    Run: 0d1ec9c2-5fa2-4309-a7c4-2bd59dca81d5; readback and local execution 2026-10-04 02:33–02:39 UTC. Read-only evidence slice; no code PR.

    Verdict

    #4170 addresses the observed cross-suite global-counter contamination, with real uncached execution evidence. A concrete readiness/coverage gap remains; do not treat #4209 as fully pressure-proven or close it from this receipt.

    The original 33/169/182 outstanding-read failures cannot arise from the fixture's two synthetic PIDs alone. pendingProcReads() counts listing/stat/environment reads across all roots in one process; the environment-sharing map uses ${root}/${pid}@${startTime}. #4170's isolatedReadTest moves each FIFO/global-counter fixture into its own Bun child, selects one exact escaped full test name, checks exit status, and requires a completion file written only after the selected body finishes. Thus unrelated scans in the parent suite cannot contribute to the child's counter. The production shutdown counter and exact one-read assertions are unchanged. The helper and fixture are in services/sandbox-runtime/daemon/src/process-reaper.test.ts (helper line 40, fixture line 416, assertions lines 430 and 436); tracking/sharing is in process-reaper.ts (lines 133–151 and 241 onward).

    The delayed SIGKILL round in exec-manager.ts:1101 is untracked by that method's returned promise, consistent with the audit hypothesis. This slice did not causally reproduce which earlier test/timer supplied each historical count; do not promote that hypothesis to a proven attribution.

    Actual CI execution

    Relevant job lines (full log lines 6178–6181, 6473, 6617–6621):

    2026-10-04T00:44:18.0553179Z ##[group]@tale/sandbox-runtime-daemon:test
    2026-10-04T00:44:18.0554144Z cache miss, executing 29c66422bb920e5b
    2026-10-04T00:44:18.0554943Z $ bun test
    2026-10-04T00:44:18.0555318Z bun test v1.4.2 (744846f84)
    2026-10-04T00:44:18.0803333Z (pass) signalExecProcesses > scans that run at once share one read of a stuck process [353.88ms]
    2026-10-04T00:44:18.0902493Z  327 pass
    2026-10-04T00:44:18.0902682Z  2 skip
    2026-10-04T00:44:18.0902860Z  0 fail
    2026-10-04T00:44:18.0903284Z Ran 329 tests across 25 files. [67.65s]
    

    This is an executed daemon task, despite other tasks in the same Unit job being cache hits. The sharing fixture's wrapper passes only after its child completes and writes the expected marker; a no-match child cannot silently pass this wrapper. Nested child's successful stdout/stderr is captured, so the visible CI result is the outer fixture line, not a separate inner result line.

    Current-main Checks run https://github.com/tale-project/tale/actions/runs/37170810886 still had its source job queued at the snapshot. No fresh main CI execution is claimed. One fresh final-PR candidate run is evidence of execution, not a statistical proof that all scheduling/load failures are eliminated.

    Bounded local execution at unchanged main

    Command: bun test services/sandbox-runtime/daemon/src/process-reaper.test.ts, sequentially 20 invocations, Bun 1.4.2 (744846f84), Linux, 4 online CPUs, UV_THREADPOOL_SIZE unset. No install: the file imports only Bun/node builtins and its local production module, so existing Bun sufficed despite no repository node_modules.

    Logs local-run-01.log through local-run-20.log preserve every invocation and nested failure. No failed run was retried until green or omitted from the count.

    Remaining gap and smallest proposed repair

    The sharing test still uses a fixed 100 ms sleep at line 429. Child isolation does not guarantee that listing/stat/ordinary environment reads have settled, or that both tag scans have reached the outstanding synthetic FIFO read, by that wall-clock point. Counts may be transiently zero or greater than one on a slow/saturated child. No such target failure occurred in these 20 runs, so this is a concrete source-level gap, not an observed pressure reproduction.

    Proposed narrow repair for the existing same-file owner:

    1. Keep fix(sandbox): bound replay consumers and preserve agent output #4170's isolated child and completion-marker guard. Add test-local read-start/read-settle readiness signals scoped to synthetic root, PID 41 and start time 1041; use a narrowly scoped injectable test reader/observer only if a test-local filesystem observer cannot expose the necessary state. Do not change reaping behavior or the production global counter.
    2. Hold that environment read open until assertions finish. Explicitly establish the first read is outstanding, both tag scans have reached/joined that read, and fixture listing/stat/ordinary-environment work has completed. Replace the 100 ms assumption with readiness, not polling/retrying a failed correctness assertion.
    3. Retain the exact pendingProcReads() === 1 assertion in the child and the existing scan-result assertions; do not use a delta or relaxed threshold that can hide duplicate reads.
    4. Add a controlled unrelated scan in the parent process, started before the child and held outstanding until the child reports completion. Assert its parent counter remains nonzero while the child proves exactly one synthetic read. This deterministically checks the isolation boundary without mixing parent counts into the child. Release all gates/readers in finally; bounded readiness failure must fail the test rather than retry the test.

    Proposed integration owner: Codex #2 / TALE-500 (#4167); fleet manager owns admission/order. Coordination was posted on TALE-500 as comment bc38bedd-3447-49e1-a829-bac77694bc63. This is a proposal and handoff, not an acknowledged agreement or authorization to restart a protected review. No file overlap was edited. Pending human review/independent acceptance on #4167 remains untouched.

    Scope, resources and unrun work

    Disk checked first: 250 GiB free, then 244 GiB, both above 20 GiB floor. Existing clone fetched; review branch chore/reconcile-process-reaper-evidence starts from origin/main and remains local/clean. No source edits, commits, push, PR, merge, issue closure or card move. Authentication uses environment-only token through gh; no credential written into a file or remote.

    Unrun: deterministic historical cross-suite reproduction, the proposed explicit-readiness/active-unrelated-scan regression, injected filesystem/threadpool/CPU/memory pressure, all-daemon local suite, full-platform suite, full-workspace typecheck/check, lint/format gates (no source changed), stack, browser, E2E and containers. These behaviors are not proven by the receipt.

    Deliverables: this report, CI execution log and daemon excerpt, CI metadata/main snapshot, all 20 local logs, and posting receipts. Findings are posted to #4209 and TALE-527, with a short verdict note to TALE-357. #4209 stays open.

  3. yannickmonney commented on Oct 4, 2026

    @yannickmonney
    ContributorAuthor

    Closing as resolved by #4170 (merged 02:21Z as 9b7463b707c5e44349f0a8c51e764a39e3e5c4fb). The fleet manager confirmed the following from source and the job log:

    • Production code unchanged: services/sandbox-runtime/daemon/src/process-reaper.ts has the same blob (c7f0973f) before and after the merge (6524150fe → 9b7463b70). Only process-reaper.test.ts changed (ce63ecd4 → 0fc88e22). It now runs the FIFO and global-counter cases in fresh child processes, with the original assertions and scan deadlines, and each child must exit 0 and write its completion marker.
    • Executed, not cached: hosted Unit job 111325282439 ran the daemon suite (00:44Z). It logs (pass) signalExecProcesses > scans that run at once share one read of a stuck process [353.88ms] and a daemon total of 327 pass / 2 skip / 0 fail.
    • Independent reconciliation: TALE-527 (Codex fix(docs): update deployment documentation and conversation ui #7) reached the same result, in this comment. Root verified it separately.

    Remaining limit, not an observed failure: the sharing case still waits a fixed 100 ms for readiness. Explicit, keyed read readiness would be stronger. That hardening was proposed to the owner of the same file, TALE-500 / #4167 (Codex #2), and is not filed separately. This closure doesn't claim that every pressure behaviour is tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions