Skip to content

fix(test): split fm-supervision-host so serial shards fit the job cap - #7706

Open
kunchenguid wants to merge 8 commits into
mainfrom
fm/serial1-01-split-supervision-host
Open

kunchenguid wants to merge 8 commits into
mainfrom
fm/serial1-01-split-supervision-host

Conversation

@kunchenguid

@kunchenguid kunchenguid commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this keeps Behavior portable serial 1 inside its 30-minute job cap.

Why serial 1 times out. Since #7625 (314ed460) raised the hint for tests/fm-supervision-host.test.sh to 1,192,918 ms, the portable serial packer has put that 82-test script alone in serial 1. Its real runtime on GitHub runners is 955–1,792 s, while the job leaves about 1,775 s for the test step. On main since 314ed460, serial 1 has passed 8 of 31 runs. Shard contents were the same in passing and failing runs, so this is runner speed against a single oversized script, not a regression from one commit. The latest main run after #7699 (98f3bd84, run 40046360276) was green except for this job, which was cancelled at the cap.

Changes

  • tests/fm-supervision-host.test.sh is split into tests/fm-supervision-host-a.test.sh and tests/fm-supervision-host-b.test.sh, 41 tests each.
    • All 82 test bodies are byte-identical to main, and each suite calls its tests in the original order.
    • The halves are balanced by per-test CI cost taken from serial 1 job logs (1,084 s vs 1,083 s, using the per-test max across runs).
  • tests/fm-supervision-host-helpers.sh holds the shared setup, moved unchanged apart from lint-suppression comments. Its stop_home_processes now uses wait_pid_bounded instead of a bare wait "$pid".
    • For a real child of the suite shell (ppid is $$ and it's in jobs -p), it waits up to about 5 s, then sends TERM, then KILL, then reaps.
    • A non-child or reused pid keeps the old immediate-return wait and is never signalled.
    • This fixes the one observed hang: main job 120583337224 at 86437e28 stalled about 1,594 s in test_claude_stop_hook_runs_the_host_without_the_file_and_off_opts_out.
  • bin/fm-test-run.sh: the family map, Pi __script__ list and hint table now name the two scripts. The hints are 596734 and 596184, scaled from the CI split so they sum to the old 1,192,918.
  • tests/lib.sh, docs/supervision-host.md, docs/verification/supervision.md and docs/fm-test-portable-shards.md are updated for the new names and the hint method.
  • No .github/workflows/ change. No timeout or budget change.

Contract class: restore. CI goes back to its documented promise that each portable serial shard fits the normal-tier job cap. No product code changes; the only runner change is the hint, map and list entries.

Packing after the change: --check-coverage is ok with serial_max_ms=1182738 against a budget of 1200000. Nothing runs alone at about 1.19M any more. Suite a lands in shard 2 and suite b in shard 3, each alongside other scripts.

Verification (cloud agent VM):

  • tests/fm-test-run.test.sh: 41/41.
  • Lint and repo invariants on the touched files: pass.
  • Suite b: 41/41.
  • Suite a: passes everything except test_claude_stop_hook_notifies_when_at_turn_downtime_write_fails, which also fails the same way on that VM against main's original file. On GitHub runners it passes in about 6–7 s.
  • Bounded wait:
    • A real child is reaped in about 1 s.
    • A non-child pid returns immediately and is left alive.
    • A hanging child is stopped in about 5.2 s.

Three adversarial review passes ran before this PR. The last came back low risk with no errors.

Follow-ups, not in this PR:

  • Headroom. On slow runners each half has taken about 870–910 s. With other scripts packed alongside, shards 2 and 3 could reach roughly 26–28 min. Recalibrating hints from slow-run data would be a separate change.
  • Slow real-time tests. Speed up the slowest park, latch and dialog tests, which take about 100–267 s each on slow runners.
  • Intermittent latch failure. "latch: the later failed probe did not hand the wake back" (seen on e7a99d59, f0fb8aac).

Speaking as Kun's firstmate: this keeps Behavior portable serial 1 inside its 30-minute job cap.

Why serial 1 times out. Since #7625 (314ed460) raised the hint for tests/fm-supervision-host.test.sh to 1,192,918 ms, the portable serial packer has put that 82-test script alone in serial 1. Its real runtime on GitHub runners is 955–1,792 s, while the job leaves about 1,775 s for the test step. On main since 314ed460, serial 1 has passed 8 of 31 runs. Shard contents were the same in passing and failing runs, so this is runner speed against a single oversized script, not a regression from one commit.

Changes

  • tests/fm-supervision-host.test.sh is split into tests/fm-supervision-host-a.test.sh (43 tests) and tests/fm-supervision-host-b.test.sh (44 tests).
    • All 87 test bodies are byte-identical to main's combined file.
    • The four fix(bin): acknowledge opt-in supervision-host hand-backs to main #7731 registrations keep main's relative order: test_lost_boundary_handoff and test_handoff_retry_respects_the_receiving_pane follow test_returned_driver_is_caught_away in -a; test_lost_pass_through_handoff and test_acknowledged_handoff_at_the_turn_keeps_the_pass_through_row follow test_returned_driver_is_caught_attended in -b.
  • tests/fm-supervision-host-helpers.sh holds the shared setup. Its stop_home_processes uses wait_pid_bounded instead of a bare wait "$pid".
    • For a real child of the suite shell (ppid is $$ and it's in jobs -p), it waits up to about 5 s, then sends TERM, then KILL, then reaps.
    • A non-child or reused pid keeps the old immediate-return wait and is never signalled.
  • bin/fm-test-run.sh packing hints are measured Ubuntu duration_ms, not shares of the old combined sample:
    • tests/fm-supervision-host-a.test.sh 674686 ms from run 40163854622 portable serial 2 (head 92f958d).
    • tests/fm-supervision-host-b.test.sh 481145 ms from run 40204257639 portable serial 3 (head 7f9195e).
    • tests/fm-watch-triage.test.sh is capped at 1200000 ms (measured 1610210 ms on run 40163854622 serial 1) so longest-processing-time assignment isolates it on serial 1.
  • No .github/workflows/ change. No timeout or budget change.

Main merge (#7731, then #7265). Head is 80895c297f291fc6e6653fb275afe99428f8d205. The combined host test file stays deleted.

Packing. --check-coverage is ok with serial_max_ms=1200000 against a budget of 1200000, serial_unhinted=0. Suite -a lands in serial 2; suite -b lands in serial 4. Serial 1 is watch-triage alone. Watch-triage's measured 1610 s plus about 30 s of job overhead is the projected wall for that shard (~1640 s under the 1800 s cap). The other serial shards project to about 1027–1426 s including setup.

Contract class: restore. CI goes back to its documented promise that each portable serial shard fits the normal-tier job cap. No product code changes from this PR beyond the split, bounded wait, and packing-hint updates.

Verification (cloud agent VM, after the measured-hint re-pack):

  • Coverage: FM_TEST_COVERAGE ok total=286 parallel=26 parallel_max_ms=814249 serial=244 serial_shards=9 serial_unhinted=0 serial_max_ms=1200000 serial_budget_ms=1200000 herdr=16.
  • Lint (bin/fm-lint.sh, changed-file mode, ShellCheck 0.11.0, actionlint 1.7.12): pass.
  • Repo invariants (CLAUDE.md pointer, .claude/skills symlink, untracked fleet paths) and bin/fm-doc-audience-check.sh: pass.
  • 87/87 test bodies byte-identical to main.
  • Suite b: 44/44.
  • Suite a: 42 pass. One environmental failure on this VM: test_tagged_lock_holder_reaches_the_engine_whole (this session does not own supervision). The previously flaky write-fail case passed this run.

Follow-ups, not in this PR:

  • Watch-triage floor. The suite itself measures 1610 s, so a projected worst-shard wall of 1500 s is not possible without splitting that script or changing the workflow.
  • Slow real-time tests. Speed up the slowest park, latch and dialog tests, which take about 100–267 s each on slow runners.
  • Intermittent latch failure. "latch: the later failed probe did not hand the wake back" (seen on e7a99d59, f0fb8aac).
Open in Web Open in Cursor 

cursoragent and others added 5 commits October 24, 2026 01:11
Move the 82-case suite into hook-driven and host-engine scripts that share
fixtures, so the portable serial packer no longer places a ~20-minute case
alone in one shard.

Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>
When session.stop exists, reap fake-claude pids with a deadline, then TERM,
then KILL, so a stuck Stop-hook child cannot hang the suite forever.

Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>
Move drain/report and attended close routing into the hook suite so each
half's CI-scaled hint stays near ten minutes, then record the measured
605208 ms and 587710 ms packing weights.

Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>
Split the 82 host cases by per-test CI seconds rather than local walls,
bound wait_pid_bounded to this shell's children, and stop exporting helper
names that shellcheck flagged.

Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>
Require a jobs -p match to also have ppid equal to this shell, and restore
the shared fm-supervision-host temp-root prefix.

Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>
@kunchenguid

Copy link
Copy Markdown
Owner Author

Speaking as Kun's firstmate: I've filed this PR's follow-ups as separate issues. They're not part of this change.

Port #7731's acknowledged hand-back tests into the split host suites,
keep the combined host test file deleted, and add estimated CI cost
of the four new tests to the serial duration hints.

Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>
cursoragent and others added 2 commits October 25, 2026 14:52
Port #7265's engine time-zone grant test into the split host suites
and keep the combined host test file deleted.

Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>
Replace the host-a/b share-of-sample hints with timing-artifact
duration_ms, cap watch-triage at the packing budget so it occupies its
own shard, refresh previously unhinted and understated companions from
the same CI artifacts, and restore the four #7731 registrations to
main's relative order.

Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>
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.

2 participants