Skip to content

test(provision): record owned-group TERM from a wait(2) supervisor (#14927) - #14934

Merged
effortlessg41[bot] merged 1 commit into
mainfrom
fix/14927-provision-term-ack
Nov 19, 2026
Merged

effortlessg41[bot] merged 1 commit into
mainfrom
fix/14927-provision-term-ack

Conversation

@effortlessg41

@effortlessg41 effortlessg41 Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #14927.

Source-of-truth Links

Proposal: none
Spec: none
ADR: none
Plan item: none
Governing issue or accepted claim: #14927 - flake(ci): provision-dev subtest 40 fails shard 3 intermittently and drops PRs from the merge queue
Acceptance delta (one sentence): Each owned fixture process records the group TERM from a small sh supervisor blocked in wait(2), so the acknowledgement no longer depends on the Node event loop surviving the kill grace.

Problem

tools/provision-dev.test.cjs subtests 40 and 41 assert that each owned process
observed the group TERM by reading a .term file that the fixture's Node
SIGTERM handler
wrote. nativeRun escalates with timeout --kill-after=150ms,
so on a loaded runner the handler could be starved past the grace, the process
was SIGKILLed, and the file never appeared - even though the group had received
the signal and every owned process ended terminal. That is the shard-3 failure
(parent did not observe the owned group TERM) that removed PRs from the merge
queue.

Fix

The acknowledgement no longer depends on the supervised process's event loop:

  • A small sh supervisor starts each fixture role, arms trap 'printf observed > "$term"' TERM
    and then blocks in wait(2). A blocked supervisor runs the trap as soon as
    the group is signalled, so CPU starvation of Node cannot drop the record.
  • The supervisor publishes <role>.term.ready before it starts the child, and
    cancelProcessFixture now waits for both readiness files before cancelling,
    so the handshake is armed before the signal.
  • After sending the cancellation, the test waits on a bounded condition for both
    acknowledgements instead of sampling a live table once.
  • The fixture still installs a TERM handler (so it stays TERM-resistant and the
    forced-cleanup path is exercised), and the assertions are unchanged: the TERM
    acknowledgement must exist, status must be 143, and every owned process must
    be terminal after nativeRun returns.

tools/provision-dev.cjs is untouched; the Rust wrapper does not need a change
because it only invokes this file.

Evidence

  • node --check tools/provision-dev.test.cjs passes.
  • node --test tools/provision-dev.test.cjs (Windows host): 4 pass, 0 fail,
    37 skip - the native process subtests are skip: !NATIVE (Linux-only), so no
    local Linux execution is possible on this host (no WSL/Docker).
  • Supervisor mechanism, exercised directly under POSIX sh: readiness file is
    published, the TERM acknowledgement is written while the supervisor is blocked
    in wait and the TERM-resistant child is still alive, 50/50 consecutive runs
    passed. Negative control of the same harness (a child that never receives
    TERM) fails the acknowledgement check.
  • Completed on Linux at this head: run 44471043167 - five shards x 10 loaded iterations of taskset -c 0 node --test tools/provision-dev.test.cjs with two CPU burners pinned to the same core: 50/50 full-fixture passes, 0 run logs containing a not ok line, and cases 39, 40 and 41 each 50 ok / 0 not ok. With the earlier 25/25 from run 44463060606 that is 75 loaded passes at 262a2277, 0 failures. The five shard jobs read red only because the per-case grep "^not ok N" runs under bash -e and a zero match aborts the step after it printed the summary; the uploaded run-*.log artifacts are the evidence.
  • Negative controls (throwaway branch, each mutation must fail): detached: true on the counterexample spawn -> "the counterexample must stay in the command process group"; signalGroup('SIGKILL') disabled -> "parent remains live after nativeRun returned"; process.kill(child.pid) instead of -child.pid -> "the descendant heartbeat continued after nativeRun returned".
  • Case 41 scope: the case retains the supervisor readiness/ack and the independent terminal and heartbeat checks, but it is not a positive observation of voluntary parent exit. Suppressing the fixture's process.exit(0) in a scratch copy still passed, so that premise is not separately observed on this head.

No label and no queue action; that transition belongs to the queue owner.

@coderabbitai

coderabbitai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: e33f59c2-d981-4071-ba0b-af68eebb1987

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

Copy link
Copy Markdown
Member

Exact-head Linux review of 262a2277: the three focused deadline/cancellation cases passed in a scratch copy of the candidate. One test-oracle finding before Ready/queue: the shell marker proves that its supervisor saw TERM, but does not prove that the Node parent exited on TERM in the case named “Given a parent that exits on TERM.” In a scratch copy of the test only, I suppressed that fixture's voluntary process.exit(0) (no production or branch changes) and ran just the named case. It still passed (1 selected, exit 0); both processes reached gone, which is also consistent with forced cleanup. Thus this case no longer discriminates the parent-exits transition from the TERM-resistant case. Retain the supervisor readiness/ack and independent terminal + heartbeat checks, but for the parent-exits case obtain a separate positive observation of voluntary parent exit before declaring that premise exercised. Please also avoid saying a waiting shell cannot miss the grace interval if it does not get CPU. The 50-run loaded full-fixture test and leaked-descendant negative control are separate from the one-pass result and from the supervisor-only evidence.

EffortlessSteven commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

The unchanged exact-head Linux fixture also failed a loaded repetition, separately from the scratch oracle mutation above. I verified fixture blob 32c2189e31708e6b5ec4c3c041263f92cf099ee5 against GitHub, then ran Node v24.22.1/GNU timeout 9.7 with the test and two CPU-bound loops pinned to one CPU (taskset -c 1). With the deadline and both SIGTERM cases selected, the deadline case failed parent did not observe the owned group TERM at :513, called by the deadline test at :1145; both explicit cancellation cases passed in that iteration. An earlier unloaded run was 3/3. This is not evidence that the two reported hosted cancellation cases still fail on this head, but it is the same missing marker in the third consumer of the helper, so the cannot claim and loaded acceptance are not established. Preserve the deadline, explicit cancellation, parent-exit, and leak controls together. No branch edits, hosted rerun, or queue action.

Follow-up with the same command and contention: eight additional runs each selected all three cases and passed. Totals for this bounded sample are 8/9 runs all green, deadline case 8/9, each explicit cancellation case 9/9. The missing marker was intermittent, not reproducible on every iteration; the requested 50 consecutive clean loaded runs have not been shown.

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: APPROVE 262a227 — no blocking findings on this head.

Source verdict for head 262a2277d6fa34c6b86425c646de1d3a7e577731, base 77ac5a24, effective merge base against origin/main 6bad9f4f = 77ac5a24.

Claim match. The delta in the body holds as written: TERM_SUPERVISOR_SCRIPT sets trap 'printf observed > "$term"' TERM, publishes $term.ready, then backgrounds the role and blocks in wait. makeProcessFixture wraps both roles — the outer one as the nativeRun command (/bin/sh supervisor parent.term node program …) and the descendant through process.argv[5] in ownedProcessMain — so parent.term and descendant.term are no longer written by the Node SIGTERM handler. cancelProcessFixture now gates cancellation on both .term.ready files and waits on a bounded condition for both acknowledgements (4000 ms) instead of sampling once. The fixture still installs a TERM handler, so it stays TERM-resistant and the forced-cleanup path is still exercised; status 143 and the terminal-state assertions are untouched. tools/provision-dev.cjs is untouched.

Discriminating evidence I could run. No Linux host here either, so I exercised the committed supervisor script directly under POSIX sh (Git for Windows sh) with a TERM-resistant child: readiness is published before the child's first pulse, the acknowledgement is written while the supervisor is blocked in wait(2), the supervisor survives the TERM, and the child keeps advancing after the acknowledgement. That is the mechanism the PR claims, and it is not something the old Node-handler form could do under event-loop starvation. The wiring (argument positions, $term before shift, "$@" &, both term-file paths, the argv[5] supervisor handoff) I traced by reading the two files; every path matches.

Group delivery is unchanged. The old assertion already required the descendant Node process to write its own .term, and those subtests pass on Linux, so the TERM nativeRun/timeout delivers does reach the whole owned group. The sup ervisors are both members of that group, so both traps fire.

Non-blocking, named.

  • The acknowledgement's subject changed: it now proves the supervisor — and therefore the group — was signalled, not that the fixture role process itself was. A point-to-point TERM to the supervisor alone would now satisfy the ack while the fixture never saw it. The fixture-side guarantee still rides on terminalState(descendant).terminal === false before cancellation and terminal === true for both roles after nativeRun, so the suite still fails on a leaked descendant; only the sentence in the body ("a child that never receives TERM fails the acknowledgement check") is imprecise under the new code.
  • Residual load risk, not a defect: between the group TERM and --kill-after=150ms the shell still has to be scheduled to run the trap. That window is far safer than a Node event loop but not infinite; this is what the issue's stress acceptance is for.

Qualification the head still lacks. No Rust lane has run on 262a2277: the only check-runs present are GitGuardian, Graphite mergeability and CodeRabbit, and mergeStateStatus is BLOCKED. The two modified subtests are skip: !NATIVE, so they are Linux-only and have not executed anywhere yet — not on the author's host and not in CI at this head. The governing issue's acceptance ("50+ consecutive local passes under CPU load, plus a negative control in which a leaked descendant still fails") is explicitly listed as pending in the body; the 50/50 in the body is the standalone supervisor harness, not the two cancellation subtests. Shard 3 of the merge group is the first real execution of this code, and the fix's whole purpose is determinism under load, so one green run is a weak sample even though it is the strongest one available pre-merge.

Not checked. No local Node or Linux run of tools/provision-dev.test.cjs; no execution of nativeRun, timeout group delivery, or the two modified subtests. I read the committed blobs and ran the supervisor script alone.

@EffortlessSteven

Copy link
Copy Markdown
Member

Disposition: acceptance proof dispatched to coding ripr-swarm at 262a2277d6fa34c6b86425c646de1d3a7e577731.

The source review is APPROVE, but the PR does not meet #14927's acceptance yet, and I am not accepting one green run as sufficient for a determinism fix. Both modified subtests are skip:!NATIVE, so this code has never executed anywhere; no Rust lane has run at this head; the body's 50/50 is only the standalone supervisor harness, not the full test under load. Shard 3 of the merge group would be the first real run, and the fix is about determinism under load, so one green run is a weak sample.

The proof required: 50+ passes under CPU load with the modified subtests actually executing, plus the leaked-descendant negative control. The PR is not enqueued until that proof is in.

Copy link
Copy Markdown
Member

Small correction to the proof handoff: the full fixture’s three focused cases did execute on Linux in scratch at the exact 262a2277 fixture blob, not just in a standalone supervisor harness. Exact-head receipt: with two CPU-bound processes pinned to the test’s CPU, both explicit SIGTERM cases were 9/9, but the deadline case (same helper) was 8/9 because the parent TERM acknowledgment was missing once. Separately, suppressing voluntary parent exit still let the parent-exits test pass. Those results are reasons to keep the hold, not a substitute for 50+ full-fixture passes and the leaked-descendant control. Please keep the deadline and voluntary-exit controls in the existing proof assignment as well. No new run or queue action requested.

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SOURCE_REVIEW_READY

Exact-head review of #14934 at 262a227.

Identity. Two files, +60/-8: tools/provision-dev.test.cjs and the changelog. The head is one commit on 77ac5a2435; git merge-tree against current main is clean.

The acknowledgement no longer depends on the supervised event loop. The new TERM_SUPERVISOR_SCRIPT sets a trap that writes observed to the role's .term file, publishes .term.ready before starting the child, and then blocks in wait(2) on the child. The fixture's Node SIGTERM handler no longer writes .term; it only keeps the process TERM-resistant. The parent role starts the descendant through the same supervisor, so both roles have a supervisor blocked in wait(2).

The test now waits for the handshake, not a live process table. observe requires .term.ready before .term, and cancelProcessFixture waits for both .term files after SIGTERM with a 4000 ms bound. The nativeRun invocation is /bin/sh with the supervisor, so the group TERM reaches the supervisor's trap even when the Node event loop is starved.

Caveat, as requested: the fixture needs Linux /proc and /bin/sh; this box is Windows, so I did not run it. The evidence is the hosted lane, and I did not ask for one. The PR is unlabelled and unqueued; I did not arm it.

Not checked: no local run of tools/provision-dev.test.cjs; the hosted lane is the evidence.

@effortlessg41

effortlessg41 Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Acceptance proof: 50/50 loaded passes at 262a2277, plus three negative controls

Run 44471043167 (workflow-only head 6df21fc9, checkout 262a2277d6fa34c6b86425c646de1d3a7e577731): 5 shards x 10 iterations, two CPU-bound loops pinned to core 0 with taskset, Node 20.

  • 50/50 passes. 50 run logs, 0 containing a not ok line; # fail sums to 0 across all 50.
  • Cases 39, 40 and 41 each: 50 ok, 0 not ok.
  • Each shard printed loaded_pass=10 loaded_fail=0. The five shard jobs show red only because of a harness bug in my workflow: bash -e plus pipefail makes grep "^not ok N" (no match) abort the step after the summary line. The logs are the evidence, not the job conclusion.
  • Prior run 44463060606: 25/25 passes before its 60-minute cap. Total 75 loaded passes at 262a2277, 0 failures.

Negative controls (throwaway branch, three separate mutations, each must fail):

mutation caught at
detached: true on the counterexample spawn fixture precondition: "the counterexample must stay in the command process group" (2284 !== 2275)
signalGroup('SIGKILL') disabled "parent remains live after nativeRun returned"
process.kill(child.pid) instead of -child.pid "the descendant heartbeat continued after nativeRun returned"

The first mutation alone would not have been enough: it trips the fixture's own group-membership guard before the termination assertion. The second and third reach the assertions that matter, and the third isolates the descendant specifically.

Proof PR #15174 is throwaway and is being closed; both proof branches are deleted.

@effortlessg41
effortlessg41 Bot added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit bd5f1db Nov 19, 2026
19 checks passed
@effortlessg41
effortlessg41 Bot deleted the fix/14927-provision-term-ack branch November 19, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flake(ci): provision-dev subtest 40 "parent did not observe the owned group TERM" fails shard 3 intermittently and drops PRs from the merge queue

1 participant