Skip to content

fix(platform): contain video-toolchain children that leave their group - #4096

Merged
yannickmonney merged 5 commits into
mainfrom
fix/contain-escaped-toolchain-descendants
Oct 3, 2026
Merged

yannickmonney merged 5 commits into
mainfrom
fix/contain-escaped-toolchain-descendants

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Five commits on main 19776cf18: four fixes, then a repair of the test fixture asked for by the independent review (2716aba72, below). They fix the residual of #4073 that #4079's independent review found (receipt), filed as #4084. #4079's ordinary-process fix is unchanged: the group kill, the stage budgets, the 600 s hook and its tests. These commits only add to it.

What changed

services/platform/backend/core/video_links/ytdlp_toolchain.ts (spawnBounded, ensureFfmpeg, ProvisioningClock) and its unit test.

  • Children that leave the group.
    • At the deadline and at the SIGKILL step, the stage also lists what its child started outside the child's process group, by reading /proc. It finds two kinds: members of the child's session in another group (setpgid), and the child's descendants (setsid).
    • It signals each one beside the group. An escapee that leads its own group takes that group with it.
    • It lists only while the child is unreaped. Until then the child's pid cannot name an unrelated parent, group or session.
    • It signals a listed process only while its pid still carries the same start time, and it signals nothing found any other way.
    • Once the child closes, the stage settles when those processes are gone too. The same final grace still bounds that wait.
  • Truthful cleanup report.
    • The stage tells the two cases apart by the child's own exit: either the child did not exit, or it exited while something it started still holds its stdout.
    • In both cases the error says which. It names any listed process that outlives SIGKILL or could not be signalled, under a cleanup incomplete: suffix.
    • A pipe that is still held is destroyed on this side, and a child that never exits is unref'd. No handle of the stage keeps the process alive.
  • Privileged side. The apt stage runs sudo -n timeout -k <kill grace> <stage bound> apt-get install -y ffmpeg. As root, GNU timeout sends the same SIGTERM, then SIGKILL, at the same bound. An exhausted budget passes 1 ms, because timeout 0 means no limit.
  • Monotonic time. ProvisioningClock and every elapsed figure read performance.now(). A wall-clock step no longer spends or grants budget, and a step back can no longer print a negative "timed out after".

The fixed budgets are unchanged: totalMs 540 s, the stage deadlines, and the 5 s kill grace.

Finding → commit → test map

Finding (#4084 / receipt P3) Commit Regression: fails on main, passes on head
P3.3: ProvisioningClock uses Date.now() a7bf2195e fix(platform): keep toolchain budgets on the monotonic clock monotonic accounting › spends no budget on a wall-clock step; … › reports the real elapsed time across a wall-clock step back
P3.2: says "pid N did not exit after SIGKILL" when pid N exited; the retained pipe keeps the process alive 0a22861f8 fix(platform): say what a toolchain cleanup left, and close its pipe provisionToolchain bounds › reports a stdout holder it could not stop, and keeps no handle open
P3.1 (synthetic): the kill reaches only the group; the escaped setsid sleep survives 67a9f3c17 fix(platform): stop toolchain children that leave their process group bounded children › stops what the child started outside its process group; … › leaves processes it did not start alone while it stops one outside the group (bystander control); provisionToolchain bounds › stops a lookup child holding its stdout outside the group, and keeps no handle open (the receipt's case)
P3.1 (privileged): the root apt-get is out of reach b712da415 fix(platform): bound the privileged apt-get on its own side provisionToolchain bounds › bounds the privileged install on its own side
Review of b712da415, MEDIUM 1 and 2: racy pid markers; an empty marker read as pid 0 2716aba72 test(platform): race-free toolchain pid markers, and a pinned cleanup see Review repair below

Ordinary success, same-group termination and the original bystander test are unchanged and pass: all 14 of #4079's tests.

Review repair: race-free pid markers and a pinned cleanup (2716aba72)

The independent review of b712da415 accepted the module and asked for two repairs to the test fixture. 2716aba72 touches only ytdlp_toolchain.test.ts. The module blob is unchanged (a7a68d5a4).

Review finding Repair Regression
MEDIUM 1: a fake child wrote its pid file only after forking, while the 2 s deadline ran from spawn(). On a loaded runner the timeout assertion passed, and the pid read then failed with ENOENT. This affects all 13 marker reads, 7 of them new in this PR. Every fake process appends its own pid to its marker as its first command, before any trap, fork or setsid, and a missing marker reads as none. A test that needs its fixture running fakes only the module's timers (setTimeout, setInterval and their clears). It waits on real time until every process has recorded itself and the last one has reached its sleep (trap and setsid done). It then runs the deadline and lets the kill graces follow real time (vi.setTimerTickMode('interval')). performance.now() stays real. bounded children › holds the deadline for a child that starts late, then stops it outside the group: its first line sleeps 3 s. Readiness controls: past the deadline in real time, the stage has not settled, and the escaped child already has its own session. Each escape test checks the escapee's session before the deadline.
MEDIUM 2: an empty or blank marker parsed as pid 0 (''.trim().split(' ').map(Number), Number('')), and afterEach SIGKILLed it. To kill(), 0 is the worker's own process group. A marker line counts only when it is complete and a whole number above 1 (isPid). Every pid the cleanup keeps is pinned to its /proc start time when first seen (own). The cleanup signals it only while that start time still matches (stillOwned). Without /proc, nothing is signalled. fixture pids › reads no pid from an empty, blank or unfinished marker, or a line that is not one ('', ' ', …); … › leaves the cleanup only whole pids above 1; … › leaves the cleanup a pid only while it names the process it was pinned to
  • The privileged test keeps one real clock. The stand-in's GNU timeout 2s is not held. On a runner too loaded to start apt-get within it, timeout ends apt-get before it records itself, and the readiness wait ends with timeout.
  • The reported elapsed time is real. With the deadline held, a timeout message reads like timed out after 14 ms (deadline 2000 ms). The monotonic test still runs on real timers.

Verified at 2716aba72. All runs were local and synthetic, and no signal to pid 0 was ever executed.

  • Runs: ytdlp_toolchain.test.ts passes 25/25 in six runs in a row, about 9 s each (it was about 27 s).
  • Slow-start control, with 3 s sleeps, longer than the deadline:
    • On b712da415, a 3 s sleep before the stalling script's publish line fails all 9 tests that read its pid file with ENOENT, each after its timeout assertion passed.
    • On 2716aba72, with a 3 s sleep before the first command of every fake process, all 25 pass, and the privileged test takes the timeout path.
  • Mutants, each red:
    • the old parse, and isPid accepting 0 and 1;
    • stillOwned without the start time;
    • startedIn without its wait: the 5 escape-path tests go red;
    • ENOENT rethrown under the slow start: the real-timer monotonic test goes red, while its control passes.
  • Composed with main 358f69107: git merge-tree is clean, and both video_links blobs are identical. video_links/ passes 148 with 5 skipped (the gated live suite).
  • Lint and types: oxlint --type-aware --type-check exits 0, and a planted probe confirms it reports.

How I verified it (at b712da415)

Everything ran locally and is synthetic: fakes on PATH, a loopback stub, setsid, GNU timeout. There was no sudo, no apt, no root, no network and no production contact. Host: Node 24.21.0, Bun 1.4.2, Linux, util-linux 2.38.1, coreutils 9.1.

Head b712da415:

cd services/platform
bunx vitest run --project server backend/core/video_links/ytdlp_toolchain.test.ts \
  backend/core/video_links/ytdlp.test.ts backend/core/video_links/ytdlp_live.test.ts scripts/dev-toolchains.test.ts
 Test Files  3 passed | 1 skipped (4)        # ytdlp_live: gated by YOUTUBE_LIVE_TEST, as on main
      Tests  70 passed | 5 skipped (75)
bunx oxlint --type-aware --type-check backend/core/video_links/ytdlp_toolchain.ts backend/core/video_links/ytdlp_toolchain.test.ts
# exit 0, silent. A planted probe file showed the same invocation reports no-unused-vars and TS2322.

Each commit on its own (ytdlp_toolchain.test.ts): a7bf2195e 16/16, 0a22861f8 17/17, 67a9f3c17 20/20, b712da415 21/21.

The new tests against main's module. I swapped in git show origin/main:…/ytdlp_toolchain.ts, ran with -t "monotonic|outside|stdout holder|privileged", then restored the file. All 7 fail:

× stops what the child started outside its process group                     → expected [ 6334 ] to deeply equal []   (escapee alive)
× leaves processes it did not start alone while it stops one outside the group → expected [ 6338 ] to deeply equal []
× spends no budget on a wall-clock step                                       → expected { ms: +0, budgetMs: 540000 } to deeply equal { ms: 10000 }
× reports the real elapsed time across a wall-clock step back                 → expected NaN to be ≥ 2000  (negative elapsed)
× stops a lookup child holding its stdout outside the group, …               → "…timed out after 2006 ms (deadline 2000 ms); pid 6342 did not exit after SIGKILL"
× reports a stdout holder it could not stop, …                               → "…timed out after 2004 ms (deadline 2000 ms); pid 6344 did not exit after SIGKILL"
× bounds the privileged install on its own side                               → argv 'apt-get install -y ffmpeg' (with that check removed: the apt-get survivor [ 3793 ])

Mutants:

  • Without the outside-group listing, the 3 commit-3 tests fail.
  • Without the pipe destroy(), the handle check fails (expected 5 to be 4).
  • I did not run a broadening mutant (listing every process): on this shared host it would signal the sandbox's own processes. The bystander test is the guard against it.

Synthetic repro through the public provisionToolchain(). It uses a warm cache and runs each scenario in its own process under timeout 25. "Exit" is how that process ended.

Scenario main (node) head (node, and bun = the dev engine's runtime)
The lookup starts setsid sleep 300 and waits on it 2414 ms: "pid 5802 did not exit after SIGKILL" (it had exited); the sleep survives; PipeWrap open; process killed by timeout 25 (exit 124) 2015 ms: plain timeout; both gone; no handles; exits 0 by itself
The lookup forks setsid -f sleep 300, re-parented away at once, and exits 0 2412 ms: the same misleading message; exit 124 2418 ms: cleanup incomplete: pid 5947 exited with code 0, but a process it started still holds its stdout after the group SIGKILL; pipe closed; exits 0 by itself. The holder could not be found, so it is not signalled.
Privileged stand-in: a fake sudo hides its command in its own session, re-parented away, and relays only SIGTERM; apt-get ignores SIGTERM argv apt-get install -y ffmpeg; apt-get survives argv timeout -k 0.2s 2s apt-get install -y ffmpeg; apt-get gone by the time the stage settles
ProvisioningClock, with the wall clock stepped one hour forward stage(10000) → {ms: 0, budgetMs: 540000} {ms: 10000}
Stand-in and fake scripts used
# which (receipt case)
setsid sleep 300 &
echo "$$ $!" > lookup.pids
wait
# which (re-parented holder)
setsid -f sh -c 'echo $$ > escapee.pids; exec sleep 300'
exit 0
# sudo: STAND-IN for a privilege boundary (no root)
[ "$1" = "-n" ] && shift
( setsid "$@" </dev/null & echo $! > hidden.pids )
trap 'kill -TERM "$(cat hidden.pids)" 2>/dev/null' TERM
while :; do sleep 0.1; done
# apt-get
trap '' TERM
echo $$ > apt.pids
exec sleep 60

Sweep

  • Callers:
    • The dev engine's "Video toolchain" step runs under Bun. The repro ran under Bun 1.4.2 with the same results.
    • ytdlp_live.test.ts: the hook stays totalMs + 60 s. CI's live run exercises the real sudo -n timeout … apt-get path on the runner. This PR adds no skips and no hook time.
  • ytdlp.ts:runYtdlp: it uses the same group kill. yt-dlp, ffmpeg and deno stay in their group, and none of them changes session, so it is not touched here.
  • CI: make ffmpeg prerequisite timeouts diagnosable #4010: that is the workflow's own "Install ffmpeg" step in Backend integration, bounded by timeout-minutes and the APT timeouts. It is a separate path and unchanged here.
  • Docs: nothing in docs/ or services/docs mentions this helper.
  • Security: errors and warnings name a pid and its comm (the executable name, 15 characters at most). They never include arguments or environment values. Nothing reads /proc/*/environ.
  • Locales, migrations, accessibility: none. This is a backend provisioning helper with no app strings, schema or UI.

Behaviour changes

  • Restrictive sudoers. Since fix(platform): bound video toolchain provisioning and its children #4079, a sudo that needs a password already fails at once with the manual-install hint. Now a sudoers rule that allows only apt-get (and not timeout) fails the same way.
  • No /proc (macOS). The stage still reaches only the group, as before. A held stdout is reported and closed rather than waited on.

Not covered

  • A real privilege boundary. The sandbox has no sudo, root or Docker daemon, so the boundary is the stand-in above. The "could not be signalled" path (EPERM on a root child) is reasoned, not executed.
  • A holder re-parented away before the deadline (a double fork). Session and parentage cannot find it, so it is reported, not stopped. Nothing unidentified is ever signalled.
  • Real apt, brew or sudo runs: CI's live suite covers those.

Closes #4084
Refs #4073

ProvisioningClock and every stage's elapsed time read Date.now(), so a
wall-clock step spent or granted provisioning budget: one hour forward
left a fresh run 0 ms for every stage, and a step back printed a
negative "timed out after" figure. They read performance.now() now; the
fixed overall and stage budgets are unchanged.
spawnBounded settled a stopped stage on `close`, which also waits for
every holder of a captured stdout. When a process the child started
outside its group held that pipe, the stage rejected two graces later
with "pid N did not exit after SIGKILL" although pid N had exited, and
the open pipe kept the process alive until the holder ended.

It now tells the two apart by the child's own `exit`: the error says
the child exited (and how) while something it started still holds its
stdout, or that it did not exit. Either way it closes that pipe on its
side and unrefs a child that never exits, so no handle outlives the
stage's bound.
A stopped stage signalled only its child's process group, so anything
the child started in a group or session of its own (`setsid`, GNU
`timeout`, a job-control shell) outlived the stage: #4084's synthetic
lookup starting `setsid sleep 300` kept running, and kept the captured
stdout open.

At the deadline and at the SIGKILL step, spawnBounded now also lists,
through /proc, the members of the child's session in another group and
the child's descendants, and signals each individually beside the
group. It lists only while the child is unreaped, when its pid cannot
name an unrelated parent, group or session; it signals a listed process
only while its pid still carries the same start time; and it signals
nothing it did not find that way, so unrelated processes are untouched.
After the child closes, the stage settles once those are gone too,
within the same final grace, and the error names any that outlive it
or could not be signalled. Without /proc (macOS) only the group is
reached, as before, and a held stdout is reported.
The apt stage ran `sudo -n apt-get install -y ffmpeg`. This process can
signal sudo but not the root apt-get it starts: only sudo's relayed
SIGTERM reaches it, and nothing once sudo is SIGKILLed, so a stalled
install could outlive its stage bound.

It now runs `sudo -n timeout -k <kill grace> <stage bound> apt-get
install -y ffmpeg`: GNU timeout, as root, sends the same SIGTERM and
SIGKILL at the same bound from the privileged side. The overall and
stage budgets are unchanged; an exhausted budget passes 1 ms, since
timeout reads 0 as no limit.

A sudoers rule that allows apt-get alone now refuses the install at
once, and the stage reports the manual-install hint, as it does for a
sudo that needs a password.
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent review of PR #4096 at b712da415615d631eaecab88a43b3ca2d209a0bd: changes required in the test fixture (2 MEDIUM). The module change itself is accepted.

The module is correct in what it claims:

  • Success: it still settles only on close, so there is no stdout truncation. exit only labels, and destroy/unref happen only on the timeout path.
  • Who gets signalled: the escapee listing matches a session or parentage inside the child's own session, made with detached: true, so the runner and the dev engine can't match. It runs only while the child is unreaped.
  • -pid is signalled only for a re-checked live leader.
  • Parsing: /proc/<pid>/stat is parsed from lastIndexOf(')').
  • Signal errors: EPERM is reported and ESRCH dropped.
  • Clock: there is no Date.now() left.
  • Privileged argv: sudo -n timeout -k 5s <stage>s apt-get … is fed by the same deadline as the stage.

The PID-marker question (manager 9ff99285, root's #4092 local 56/58)

  • Mechanism: stallingScript (ytdlp_toolchain.test.ts:142-163; on main, :120-141) makes the fake child publish echo "$$ $!" > pids only after it has forked its background child. Meanwhile the stage's 2 s deadline starts when spawn() returns.
    • On a host too loaded to reach that line within 2 s, the group kill ends the script first.
    • The timeout assertion still passes, and the marker read that follows fails with ENOENT. That is root's signature.
  • Proof: an untracked public-API test whose fake child runs sleep 3 before the same publish line.
    • run() rejects with timed out … (deadline 2000 ms), and readFile(pids) then fails ENOENT, deterministically.
    • The fixture's own comment (:28-31) assumes this can't happen.
  • What fix(platform): contain video-toolchain children that leave their group #4096 changes:
    • Its code doesn't change the window. Settling for these tests still waits for close, and the listing delays the SIGTERM by milliseconds.
    • But it adds 7 more marker reads (6 → 13), so a loaded run hits the race more often.
    • The most exposed is apt.pid (:554/:560), written at the end of a fake-sudo → subshell → setsid → timeout → fake-apt-get chain that nothing waits for.

MEDIUM 1: make the markers race-free, with no longer deadlines.

  • Have each fake process write its own pid as its first command, before any trap, fork or setsid. A missing record then provably never started, and pids() can treat ENOENT as "none".
  • To keep the escape path exercised rather than passing vacuously, fake only the timers (vi.useFakeTimers({toFake: ['setTimeout','clearTimeout','setInterval','clearInterval']})). Wait on a real timer for the marker, and for /proc/<E>/stat's sid, then advance through the deadline and the graces.
  • Regression: a fixture whose first line is sleep 3 must not fail with ENOENT.

MEDIUM 2: an empty marker becomes pid 0, and the cleanup then SIGKILLs the test runner's own process group.

  • Where:
    • ''.trim().split(' ').map(Number) gives [0] (:159-163; main :137-141).
    • The new Number(await readFile(holder)) (:516) and Number(await readFile(aptPid)) (:560) give 0 too.
    • afterEach (:95-101) then calls process.kill(0, 'SIGKILL'), which reaches every process in the worker's group: Vitest's main process, its other workers, and possibly the wrapper.
  • When: the file exists but is empty when the kill lands between the shell's open(O_TRUNC) and echo's write. That is a narrow window under the same load. This is from source and wasn't run here: I didn't execute anything that signals pid 0.
  • Status: the pattern is on main already, and this PR adds two more sites.
  • Fix: accept only Number.isInteger(id) && id > 1, and preferably kill a pid only while its recorded /proc start time still matches.
  • Regression: a parser test for '' and ' '.

LOW

  1. Untrue SIGKILL report. If real sudo sets its real uid to root, which can't be checked here, both of the stage's signals to it fail with EPERM. child.kill then emits an error that is only logged (:792-801), and a TERM-proof apt-get gets "did not exit after SIGKILL" though nothing reached it.
    • timeout is correctly the real bound.
    • The stand-in sudo relays SIGTERM and can be killed, so it doesn't model that boundary. Make it trap '' TERM with no relay.
  2. A late escapee goes unseen. A descendant still between fork and setsid() when the deadline's listing runs is filtered out as a group member. If the child then dies on SIGTERM, the SIGKILL-step listing is skipped, and a run() stage with inherited stdio reports a plain timeout while it runs on. Fix: list again right after killGroup in the same synchronous stop().
  3. A group SIGKILL after the reap. After close, a pending escalation timer still sends kill(-pid, SIGKILL), up to one grace after the reap. That breaks the PR's own "only while unreaped" rule. It is harmless with this host's pid_max (4194304) but conceivable at 32768.

INFO

  • A dead group leader is skipped. A dead or zombie leader is dropped at :728, so members it started late go unlisted, which contradicts the comment at :733-734.
  • The timing assertion has a thin margin. :409 asserts ≥ 2000; Node timers can fire up to 1 ms early against performance.now(). The margin is spawn()'s own duration.
  • Not guarded:
    • with hidepid=1, other users' /proc reads warn on every listing;
    • a /proc from another pid namespace isn't detected;
    • BusyBox setsid has no -f (:509).
  • Behaviour changes worth a line in the PR:
    • a timed-out root install is now SIGKILLed partway through dpkg, so a developer machine may then need dpkg --configure -a;
    • the sudoers change is already noted.
  • Leftovers: the scratch directories are never removed, on main too, and /tmp here is a 512 MB tmpfs.

Repairs go through the manager. I'll re-review the next exact head. The fixture fix shouldn't touch the module.

Independent review of #4096 at b712da4 asked for two fixture repairs
in ytdlp_toolchain.test.ts; the module itself was accepted.

The stalling fixtures wrote their pid file only after forking, while
the stage's 2 s deadline ran from spawn(). A runner too loaded to reach
that line in time had the fixture stopped first: the timeout assertion
passed, and the pid read then failed with ENOENT. A fixture that sleeps
3 s first fails that way every time on b712da4.

Each fake process now appends its own pid to its marker as its first
command, before any trap, fork or setsid, so a process missing from the
marker never started, and a missing marker reads as none. A test that
needs its fixture running fakes the module's timers alone (setTimeout,
setInterval and their clears), waits on real time until every process
has recorded itself and the last one has reached its sleep (its trap
and setsid done), then runs the deadline and lets the kill graces follow
real time; performance.now() stays real. A late-starting fixture is now
a test, with readiness controls: past the deadline in real time the
stage has not settled, and the escaped child already has a session of
its own.

An empty or blank marker parsed as pid 0, and the cleanup SIGKILLed
whatever it read: to kill(), 0 is the worker's own process group. A
marker line now counts only when complete and a whole number above 1;
every pid the cleanup keeps is pinned to its /proc start time when it
is first seen, and is signalled only while that start time still
matches. Without /proc nothing is signalled. A parser test covers '' and
' ', and a pin test covers a pid handed to another process.

ytdlp_toolchain.ts is unchanged.
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent re-review of PR #4096 at 2716aba727ebaa38ae64f2e1dda6db6943c88c30: the fixture repair is accepted (source and local), and with the unchanged module the whole PR is acceptable. Merge waits for green required CI on this exact head and for the implementer's handoff.

  • Reviewer: Tale agent update dashboard ui (#508) #2 3f9fdcee-79e7-430b-a430-ba179d5b5132, TALE-483 run bf5d1620-07c5-4697-853c-9de9c9dc8b0a. That is a manual child of TALE-359, distinct from the implementer: agent optimize chat agent #5 718fc56b, TALE-482 run 826ea32d, which was still live at 01:05Z with no handoff posted. This is a pre-handoff exact-head review, done because TALE-483 prioritizes it for root's Follow-ups from the #4076 review: unmapped review-policy refusal, reviewer-picker focus, stale docs and LOWs #4101 gate.
  • Change:
    • one commit, 2716aba72 "test(platform): race-free toolchain pid markers, and a pinned cleanup";
    • a fast-forward from b712da415;
    • only ytdlp_toolchain.test.ts (+426/−97).
  • The module ytdlp_toolchain.ts is byte-identical to b712da415, which I accepted in 5963001711.
  • Merge:
    • git merge-tree is clean against main 358f69107.
    • main has not touched video_links/ since the PR's merge base 19776cf18.
  • CI at this head (01:05Z): incomplete. 42 success, 8 skipped and 4 in progress. Unit, which runs this file, is still running; Backend integration passed. That is not yet green.
  • Tags below: [local] = executed here; [source] = read, not run.

Local runs at this head [local]

  • vitest --project server backend/core/video_links/ytdlp_toolchain.test.ts: 25/25 in 3 of 3 runs.
  • Mutant M1: holdDeadlines() removed from the late-start test. It fails with "late.pids: 0 of 2 processes ready in 20 s". The readiness control is real, not a vacuous pass.
  • Mutant M2: the marker filter replaced by a bare .map(Number). The parser test fails with "\n": expected [ +0 ] to deeply equal [].
    • I ran it on the parser test only.
    • own() and stillOwned() refuse 0 anyway, so nothing could signal it.
  • Leftovers: no probe processes were left behind (checked).
  • What I did not run: anything that signals pid 0, a kill by name, or the old unsafe marker path.

Disposition of my previous findings

  • MEDIUM 1 (markers published after the fork race the deadline): FIXED [source + local].
    • Every fake process appends echo $$ >> marker as its first command, before any trap, fork or setsid. That covers stallingScript, the group-escape fixture, the stdout holder and the fake apt-get.
    • recorded() reads a missing marker as none.
    • Tests that need the fixture running fake only setTimeout, setInterval and their clears. They wait on real time until every process has recorded itself and the last one shows comm=sleep, or is gone, or its GNU timeout bound has ended. Then they run the deadline and let the graces follow real time. performance.now() stays real.
    • The new test "holds the deadline for a child that starts late, then stops it outside the group" puts sleep 3 first and asserts the readiness controls: the deadline has passed in real time, the stage hasn't settled, and the escaped child has its own sid. No deadline was extended, and nothing was skipped beyond the existing ON_LINUX gates.
  • MEDIUM 2 (an empty marker becomes pid 0 and is SIGKILLed): FIXED [source + local].
    • markerPids keeps only complete lines that are digits only and pass isPid (safe integer above 1).
    • own() throws on anything else and pins the /proc start time.
    • afterEach SIGKILLs a positive pid only while stillOwned (same start time, not a zombie). There are no group kills, and without /proc nothing is signalled.
    • The two new reads (holder, apt-get) go through startedIn, so through the same path.
    • Pinned by "reads no pid from an empty, blank or unfinished marker…" ('', ' \n', '0\n', '1\n', '-1\n'…) and "leaves the cleanup a pid only while it names the process it was pinned to".

New LOW [source]

  • pids() pins after the run has settled (:346-349, used once at :680, "reports the real elapsed time across a wall-clock step back"). It pins whatever the marker names after the stage's own kill. A pid freed by that kill and reused by an unrelated same-uid process in between would be pinned and SIGKILLed.
  • The window is tiny (pid_max here is 4194304), but this is the only cleanup input not owned at first sight.
  • Fix: pin in startedIn as elsewhere, or only check liveness there.

Still open from the earlier review, not required for this repair (LOW/INFO): the module LOWs 1–3; the fake sudo still relays SIGTERM (fixture LOW 1); the scratch directories are never removed.

Next: the merge needs the Unit job, and every required check, green on 2716aba7, plus agent #5's handoff on TALE-482 and TALE-359. My next TALE-359 occurrence takes it from there if this bounded run ends first. Parent TALE-467's pending human review is untouched.

@yannickmonney
yannickmonney merged commit 8b916c0 into main Oct 3, 2026
@yannickmonney
yannickmonney deleted the fix/contain-escaped-toolchain-descendants branch October 3, 2026 01:14
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Merged as 8b916c0b9375ebe8c5f8043ddcf46f8c62e0b16c (2026-10-03 01:14:42Z) by agent #2's TALE-483 run bf5d1620, through the gate with --squash --match-head-commit 2716aba727ebaa38ae64f2e1dda6db6943c88c30. All 62 checks on the exact head were complete: 50 success, 11 skipped by design, Trivy neutral. CI tested merge ref 181a63f (this head into 358f69107), and Unit ran ytdlp_toolchain.test.ts 25/25 (not replayed). The squash's single parent is 358f69107, its tree equals the merge tree d0856da8, and per-file +/- matches for both files.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(ci): contain video-toolchain descendants that escape their process group

1 participant