Skip to content

fix(bin): bound each test script and the remote job stdin capture - #254

Merged
HelloWorldSungin merged 21 commits into
mainfrom
fm/fm-test-suite-robustness
Sep 4, 2026
Merged

HelloWorldSungin merged 21 commits into
mainfrom
fm/fm-test-suite-robustness

Conversation

@HelloWorldSungin

@HelloWorldSungin HelloWorldSungin commented Sep 3, 2026 •

Copy link
Copy Markdown
Owner

Intent

Reconcile the fm-test-suite-robustness branch with origin/main to deliver the
fixes for two open test-suite defects so a sweep no longer costs verdicts.

Issue 178 - tests/fm-on.test.sh can deadlock and stall the ENTIRE test sweep
with no verdict. The deadlock is a caller-open stdin crossing the SSH
transport into bin/fm-remote-entrypoint.sh, where fm_remote_job_stage captures
stdin via head -c and reads until EOF. The fix adopts upstream PR 3210 /
commit 1fd7ea2 (byte-identical shape): bin/fm-on.sh now exec ssh with stdin
from /dev/null by default and only forwards the caller's stream when --stdin
is passed. Upstream ships this through main as of a90370c
(fm/fm-upstream-sync-2026-09-02-round-2). The fork adds a defense-in-depth
bounded stdin capture (FM_REMOTE_JOB_STDIN_TIMEOUT + fm_remote_job_capture_stdin)
on top: a --stdin caller with a hung stream is refused within
FM_REMOTE_JOB_STDIN_TIMEOUT (default 360s) with FM_REMOTE_JOB_ERROR naming
the unclosed stream as the cause.

Issue 220 - tests/fm-test-run.test.sh hard-fails when ruby is absent instead
of skipping. The fix is a per-case skip_without
helper that emits a TAP # skip line naming the missing precondition instead
of failing the run, so the suite reaches a verdict with a visible skip on any
host that lacks an optional interpreter. Applied to the same shape in three
places (Herdr YAML parse, empty selection summary, timing markers) so any
absent optional interpreter reports as skipped, not failed.

This PR also adds bin/fm-test-run.sh DEFAULT_PER_SCRIPT_TIMEOUT_SECS=480
applied to every standard-mode sweep unless MODE=changed or --max-wall-ms is
set, so a hung script becomes an ordinary red (exit 124) rather than stalling
the suite. --changed uses upstream's CHANGED_DEFAULT_TIMEOUT_SECS=900
unchanged, and --max-wall-ms does not require the timeout helper. Per-script
exit 124 and exit 125 are distinguished by run_bound_outcome_note against
the started marker and elapsed time.

Standing constraints firstmate already decided: the authorship rewrite of
the 8 commits authored as Test test@example.com stays DECLINED (firstmate
composes the squash body at merge); a review finding whose remedy is a
TIMING CONSTANT is decided in favor of applying it; same reconciliation
choices are settled by taking upstream where the change arrived twice.

This is a merge commit (6f4e822) with two parents: fc448ab (PR 254 head)
and a90370c (origin/main). The merge base was the previous headless branch
where the previous worker's reconcile lived.

What Changed

  • bin/fm-test-run.sh now arms DEFAULT_PER_SCRIPT_TIMEOUT_SECS=480 on every standard-mode sweep (skipped when --per-script-timeout-secs is given, in --changed mode, or when --max-wall-ms is set), so a hung script becomes an ordinary exit=124 red instead of a sweep with no verdict; 0 is a real opt-out, a new run_bound_outcome_note separates a bound kill from a script's own exit 124/125 using elapsed time and a started marker, and INT/TERM traps relay the signal into each bounded script's process group (exiting 130/143) using the group id bin/fm-timeout-lib.sh now publishes through FM_TIMEOUT_PGID_FILE.
  • bin/fm-remote-job-lib.sh adds fm_remote_job_capture_stdin, which reads staged stdin under FM_REMOTE_JOB_STDIN_TIMEOUT (default 360s, range-checked in fm_remote_job_validate_settings) and refuses a caller stream that never reaches EOF with an explanatory FM_REMOTE_JOB_ERROR rather than blocking; the queue deadline is stamped after that capture so a slow-but-complete stream no longer spends the worker's admission budget, bin/fm-timeout-lib.sh becomes a required source rather than an optional one, and bin/fm-remote-entrypoint.sh takes the job id from FM_REMOTE_JOB_ID.
  • Tests announce missing optional interpreters as skips instead of failures - a per-case skip_without <interpreter> <title> TAP skip in tests/fm-test-run.test.sh and whole-script gate skips in the kimi-harness, no-mistakes-required, and bootstrap-network-parallel tests - alongside new cases covering the per-script bound, its opt-out, the 124/125 distinction, the signal relay, and every arm of the bounded stdin capture; docs and CI comments are refreshed for the current lane (154 scripts, ~7.2 min balanced shards), and docs/fork-divergence.md records both fork-only bounds.
  • This change also fixes the Behavior portable serial 6 red that hit both this branch and main. Two wall-clock races in tests/fm-secondmate-reconcile.test.sh produced two different assertions from one underlying cause under slow CI runners: test_busy_lifecycle_locks_never_hold_up_the_digest asserted the backgrounded run_notify had already exited after a fixed sleep 0.2 (replaced with a 60s deadline wait for the child exit while the lock holder still owns the lock - the actual property under test, not a wall-clock proxy), and test_the_window_is_four_hours seeded the cooldown stamp at now-14399 against the 14400s window (widened to a +/-60s bracket since bin/fm-secondmate-reconcile.sh:251 reads its own clock later and >=1s of elapsed wall time pushes the age to 14400). Mutation-checked: cooldown windows of 14300 or 14500 still fail the bracket, and swapping fm_lock_try_acquire for fm_lock_acquire_wait on the meta lock still fails the lock case. Only tests/fm-secondmate-reconcile.test.sh changed (17 insertions, 5 deletions in commit 6d2304c0); no production code touched. This change fixes the red on MAIN as well as on this branch since main's failure was the other race in the same file.
  • The remaining CI red (PR must be raised via no-mistakes) is NOT introduced by this change. The check emits "python interpreter not found; cannot parse pipeline attestation" - the checker never evaluated anything because python is not installed on the runner. Filed separately as fork issue 258 with the failing-run evidence; no code change was made for the check itself.

Risk Assessment

⚠️ Medium: The new bound logic, the bounded stdin capture, and the entrypoint diagnostic plumbing all trace correctly and are covered by new behavioral tests, but the change arms a per-script bound by default on every required CI lane at a documented-thin 1.41x margin over the slowest measured Herdr script and rewires the production remote staging call, so it is safe to merge with the remaining comment-accuracy and duplication items as follow-ups.

Testing

Ran the four directly-affected contract suites plus the fixture-copy siblings through the real runner (tests/fm-test-run.test.sh, tests/fm-remote-job.test.sh, tests/fm-on.test.sh, tests/fm-remote-entrypoint.test.sh, tests/fm-remote-job-orphan-reap.test.sh, tests/fm-remote-job-worker-leak.test.sh, tests/fm-kimi-harness.test.sh, tests/fm-bootstrap-network-parallel.test.sh, tests/fm-remote-backlog-handoff.test.sh) - all green - and then reproduced each defect and its fix as an operator-level CLI transcript against the base commit: fm-on.sh with a never-closing stdin (blocks at base, bounded refusal naming the unclosed stream at the target), the ruby-less and python3-less skip paths (red at base, visible TAP skip with a verdict at the target), and a hung script inside a sweep (no verdict at base, exit=124 red at the target) including the 124-self-inflicted and unarmable-125 annotations. Also recomputed the refreshed portable-serial figures from the runner's own lane listing and hint table and confirmed they match the doc, the CI workflow comment and the bound rationale exactly. No screenshots: this change is entirely shell CLI and test-runner behavior with no rendered surface, so the CLI transcripts are the actual end-user surface.

Evidence: Issue 178 end-to-end: caller-open stdin over the SSH transport, base vs intermediate vs target

############ BEFORE - base a90370c9 (upstream fm-on fix only, no bounded capture) $ fm-on.sh --stdin ios fm-probe-one.sh < <caller stream that never closes> [NO VERDICT: still blocked when the harness gave up after 60s] ############ INTERMEDIATE a78f2def (bound present, diagnostic still lost in a command substitution) $ fm-on.sh --stdin ios fm-probe-one.sh < <caller stream that never closes> error: cannot stage remote job [exit 70 after 5s] ############ AFTER - target e76dd59b (this change) $ fm-on.sh ios fm-probe-one.sh < <caller stream that never closes> remote command ran on the secondmate [exit 0 after 1s] $ fm-on.sh --stdin ios fm-probe-one.sh < <caller stream that never closes> error: remote job stdin never reached EOF within 5s; the caller must close the stream it hands over [exit 70 after 5s] $ printf 'payload one\npayload two\n' | fm-on.sh --stdin ios fm-probe-one.sh remote command ran on the secondmate stdin: payload one stdin: payload two [exit 0]

Issue 178 - a caller-open stdin crossing the SSH transport into bin/fm-remote-entrypoint.sh

Harness: the real bin/fm-on.sh driven over a fake ssh that execs the real bin/fm-remote-entrypoint.sh
(the same transport wiring tests/fm-on.test.sh uses), with the caller's stdin on a fifo whose write end
is held open, so the reader never sees EOF. FM_REMOTE_JOB_STDIN_TIMEOUT is shortened to 5s (default 360s).

############ BEFORE - base a90370c9 (upstream fm-on fix only, no bounded capture)
\### scenario A: default invocation (no --stdin) while the caller's stream stays open
$ fm-on.sh ios fm-probe-one.sh   < <caller stream that never closes>
remote command ran on the secondmate
[exit 0 after 1s]

\### scenario B: --stdin invocation, same never-closing stream, FM_REMOTE_JOB_STDIN_TIMEOUT=5
$ fm-on.sh --stdin ios fm-probe-one.sh   < <caller stream that never closes>
[NO VERDICT: still blocked when the harness gave up after 60s]

\### scenario C: --stdin invocation with a stream the caller DOES close - the payload path still works
$ printf 'payload one\npayload two\n' | fm-on.sh --stdin ios fm-probe-one.sh
remote command ran on the secondmate
stdin: payload one
stdin: payload two
[exit 0 ]

############ INTERMEDIATE a78f2def (bound present, diagnostic still lost in a command substitution)
\### scenario A: default invocation (no --stdin) while the caller's stream stays open
$ fm-on.sh ios fm-probe-one.sh   < <caller stream that never closes>
remote command ran on the secondmate
[exit 0 after 1s]

\### scenario B: --stdin invocation, same never-closing stream, FM_REMOTE_JOB_STDIN_TIMEOUT=5
$ fm-on.sh --stdin ios fm-probe-one.sh   < <caller stream that never closes>
error: cannot stage remote job
[exit 70 after 5s]

\### scenario C: --stdin invocation with a stream the caller DOES close - the payload path still works
$ printf 'payload one\npayload two\n' | fm-on.sh --stdin ios fm-probe-one.sh
remote command ran on the secondmate
stdin: payload one
stdin: payload two
[exit 0 ]

############ AFTER - target e76dd59b (this change)
\### scenario A: default invocation (no --stdin) while the caller's stream stays open
$ fm-on.sh ios fm-probe-one.sh   < <caller stream that never closes>
remote command ran on the secondmate
[exit 0 after 1s]

\### scenario B: --stdin invocation, same never-closing stream, FM_REMOTE_JOB_STDIN_TIMEOUT=5
$ fm-on.sh --stdin ios fm-probe-one.sh   < <caller stream that never closes>
error: remote job stdin never reached EOF within 5s; the caller must close the stream it hands over
[exit 70 after 5s]

\### scenario C: --stdin invocation with a stream the caller DOES close - the payload path still works
$ printf 'payload one\npayload two\n' | fm-on.sh --stdin ios fm-probe-one.sh
remote command ran on the secondmate
stdin: payload one
stdin: payload two
[exit 0 ]
Evidence: Issue 220 end-to-end: tests/fm-test-run.test.sh on a host that genuinely lacks ruby

host: Linux 6.14.11-4-pve; ruby: not installed; python3: /usr/bin/python3 ############ BEFORE - base a90370c9 (same host, same command) not ok - ruby is required to parse .github/workflows/ci.yml as YAML FM_TEST_END tests/fm-test-run.test.sh exit=1 duration_ms=98163 gate_skip=false FM_TEST_SUMMARY total=1 failed=1 skipped_gate=0 ############ AFTER - target e76dd59b (this change), same host, same command ok - Herdr CI family-run step times out at 20 min under a 75 min job backstop # skip ruby not found (optional interpreter, not installed by bin/fm-bootstrap.sh) FM_TEST_END tests/fm-test-run.test.sh exit=0 duration_ms=106655 gate_skip=false FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0

Issue 220 - tests/fm-test-run.test.sh on a host that genuinely lacks ruby
host: Linux 6.14.11-4-pve; ruby: not installed; python3: /usr/bin/python3

############ BEFORE - base a90370c9 tree (same host, same command)
$ bin/fm-test-run.sh tests/fm-test-run.test.sh
ok - jobs scheduler runs proven scripts; failure propagates; non-proven refused
not ok - ruby is required to parse .github/workflows/ci.yml as YAML
FM_TEST_END 2026-09-03T21:02:00Z tests/fm-test-run.test.sh exit=1 duration_ms=98163 gate_skip=false
FM_TEST_SUMMARY total=1 failed=1 skipped_gate=0 duration_ms=98183
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=1 duration_ms=98163 failed=1
FM_TEST_SLOWEST rank=1 script=tests/fm-test-run.test.sh duration_ms=98163
rc=1
   ... the sweep loses its verdict on this script: exit=1, failed=1

############ AFTER - target e76dd59b (this change), same host, same command
$ bin/fm-test-run.sh tests/fm-test-run.test.sh
ok - jobs scheduler runs proven scripts; failure propagates; non-proven refused
ok - Herdr CI family-run step times out at 20 min under a 75 min job backstop # skip ruby not found (optional interpreter, not installed by bin/fm-bootstrap.sh)
ok - the per-script bound also terminates and reports a hung script under --jobs
ok - --per-script-timeout-secs 0 is a real opt-out, not the default in disguise
ok - the per-script bound default arms for every standard mode without a flag
ok - a sweep stopped by a signal reports and relays the signal that stopped it
ok - a bound that could not be armed is reported as a script that never ran
ok - a script that exits 124 on its own is not reported as killed by the bound
   ... the missing interpreter is announced as a TAP skip and the sweep still reports: exit=0, failed=0
Evidence: Per-script bound end-to-end: a hung script inside an ordinary sweep, plus the 124/125 discrimination

############ BASE a90370c9 (no default per-script bound) $ bin/fm-test-run.sh tests/fm-brief.test.sh tests/fm-doctor.test.sh tests/fm-status.test.sh FM_TEST_BEGIN tests/fm-doctor.test.sh ... ok - the hung script started [NO VERDICT: still inside tests/fm-doctor.test.sh when the operator's 45s budget ran out; no FM_TEST_END, no FM_TEST_SUMMARY] ############ TARGET e76dd59b (bound shortened to 5s for the demo) ok - the hung script started not ok - tests/fm-doctor.test.sh exceeded the per-script bound of 5s and was terminated FM_TEST_END tests/fm-doctor.test.sh exit=124 duration_ms=5020 gate_skip=false ok - the sweep still reaches the scripts after the hung one FM_TEST_SUMMARY total=3 failed=1 skipped_gate=0 duration_ms=5103 [sweep exit 1 after 5s - an ordinary red verdict, not a stalled sweep] ### self-inflicted shapes not ok - tests/fm-brief.test.sh exited 124 on its own after 0s; the 30s per-script bound did not fire not ok - tests/fm-brief.test.sh was not run: the 30s per-script bound could not be armed ### default arms with no flag $ bin/fm-test-run.sh tests/fm-brief.test.sh # bin/fm-timeout-lib.sh removed fm-test-run: per-script timeout helper not found: bin/fm-timeout-lib.sh

Per-script bound - one hung script inside an ordinary sweep (the shape that stalled full sweeps in issue 178)

############ BASE a90370c9 (before this change: no default per-script bound)
\### the same three-script sweep with NO flag, the middle script hung
$ bin/fm-test-run.sh tests/fm-brief.test.sh tests/fm-doctor.test.sh tests/fm-status.test.sh
FM_TEST_BEGIN 2026-09-03T21:02:29Z tests/fm-brief.test.sh family=pure-contract-unit expected_gate_skip=none
ok - a healthy script runs to completion
FM_TEST_END 2026-09-03T21:02:29Z tests/fm-brief.test.sh exit=0 duration_ms=8 gate_skip=false
FM_TEST_BEGIN 2026-09-03T21:02:29Z tests/fm-doctor.test.sh family=unclassified expected_gate_skip=none
ok - the hung script started
Terminated
[NO VERDICT: still inside tests/fm-doctor.test.sh when the operator's 45s budget ran out; no FM_TEST_END, no FM_TEST_SUMMARY]

############ TARGET e76dd59b - a hung script inside an ordinary sweep
\### an ordinary sweep of three scripts, the middle one hung (bound shortened to 5s for the demo)
$ bin/fm-test-run.sh --per-script-timeout-secs 5 tests/fm-brief.test.sh tests/fm-doctor.test.sh tests/fm-status.test.sh
FM_TEST_BEGIN 2026-09-03T21:02:06Z tests/fm-brief.test.sh family=pure-contract-unit expected_gate_skip=none
ok - a healthy script runs to completion
FM_TEST_END 2026-09-03T21:02:06Z tests/fm-brief.test.sh exit=0 duration_ms=21 gate_skip=false
FM_TEST_BEGIN 2026-09-03T21:02:06Z tests/fm-doctor.test.sh family=unclassified expected_gate_skip=none
ok - the hung script started
not ok - tests/fm-doctor.test.sh exceeded the per-script bound of 5s and was terminated
FM_TEST_END 2026-09-03T21:02:11Z tests/fm-doctor.test.sh exit=124 duration_ms=5020 gate_skip=false
FM_TEST_BEGIN 2026-09-03T21:02:11Z tests/fm-status.test.sh family=unclassified expected_gate_skip=none
ok - the sweep still reaches the scripts after the hung one
FM_TEST_END 2026-09-03T21:02:11Z tests/fm-status.test.sh exit=0 duration_ms=21 gate_skip=false
FM_TEST_SUMMARY total=3 failed=1 skipped_gate=0 duration_ms=5103
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=1 duration_ms=21 failed=0
FM_TEST_SUMMARY_FAMILY family=unclassified count=2 duration_ms=5041 failed=1
FM_TEST_SLOWEST rank=1 script=tests/fm-doctor.test.sh duration_ms=5020
FM_TEST_SLOWEST rank=2 script=tests/fm-brief.test.sh duration_ms=21
FM_TEST_SLOWEST rank=3 script=tests/fm-status.test.sh duration_ms=21
[sweep exit 1 after 5s - an ordinary red verdict, not a stalled sweep]

\### the same bound arms with NO flag on a standard-mode sweep
(proved the way an operator would see it: with bin/fm-timeout-lib.sh removed, a no-flag sweep refuses to run unbounded)
$ bin/fm-test-run.sh tests/fm-brief.test.sh
fm-test-run: per-script timeout helper not found: bin/fm-timeout-lib.sh
[exit 2]
$ bin/fm-test-run.sh --per-script-timeout-secs 0 tests/fm-brief.test.sh   # documented opt-out
FM_TEST_BEGIN 2026-09-03T21:02:11Z tests/fm-brief.test.sh family=pure-contract-unit expected_gate_skip=none
ok - a healthy script runs to completion
FM_TEST_END 2026-09-03T21:02:11Z tests/fm-brief.test.sh exit=0 duration_ms=19 gate_skip=false
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=38
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=1 duration_ms=19 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-brief.test.sh duration_ms=19
[exit 0]

############ the two self-inflicted shapes the bound must not misattribute
\### a script that exits 124 on its own, under a 30s bound it never came near
$ bin/fm-test-run.sh --per-script-timeout-secs 30 tests/fm-brief.test.sh
FM_TEST_BEGIN 2026-09-03T21:08:32Z tests/fm-brief.test.sh family=pure-contract-unit expected_gate_skip=none
ok - this script chooses to exit 124 itself
not ok - tests/fm-brief.test.sh exited 124 on its own after 0s; the 30s per-script bound did not fire
FM_TEST_END 2026-09-03T21:08:32Z tests/fm-brief.test.sh exit=124 duration_ms=21 gate_skip=false
FM_TEST_SUMMARY total=1 failed=1 skipped_gate=0 duration_ms=41
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=1 duration_ms=21 failed=1
FM_TEST_SLOWEST rank=1 script=tests/fm-brief.test.sh duration_ms=21
[exit 1]

\### a bound that could not be armed at all (host stand-in: the bound owner reports its documented
    "no bounded runner could start" outcome, 125)
$ bin/fm-test-run.sh --per-script-timeout-secs 30 tests/fm-brief.test.sh
FM_TEST_BEGIN 2026-09-03T21:08:32Z tests/fm-brief.test.sh family=pure-contract-unit expected_gate_skip=none
not ok - tests/fm-brief.test.sh was not run: the 30s per-script bound could not be armed
FM_TEST_END 2026-09-03T21:08:32Z tests/fm-brief.test.sh exit=125 duration_ms=22 gate_skip=false
FM_TEST_SUMMARY total=1 failed=1 skipped_gate=0 duration_ms=41
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=1 duration_ms=22 failed=1
FM_TEST_SLOWEST rank=1 script=tests/fm-brief.test.sh duration_ms=22
[exit 1]
Evidence: Issue 220 whole-file gates: the same three scripts on a host without python3

BEFORE (base a90370c9): not ok - test needs python3 / not ok - python3 is required to exercise the pinned shared action / not ok - python3 is required to decode the fm-on.sh argv payload -> FM_TEST_SUMMARY total=3 failed=3 skipped_gate=0, exit 1 AFTER (target e76dd59b): skip: python3 not found (optional interpreter, not installed by bin/fm-bootstrap.sh) x2 and skip: python3 not found (optional decoder for the fm-on.sh argv payload) -> three FM_TEST_END lines with exit=0 gate_skip=true, FM_TEST_SUMMARY total=3 failed=0 skipped_gate=3, exit 0

Issue 220 - whole-file preconditions: the same three scripts on a host without python3
(python3 hidden from PATH; everything else identical)

############ BEFORE - base a90370c9
$ bin/fm-test-run.sh tests/fm-kimi-harness.test.sh tests/fm-no-mistakes-required.test.sh tests/fm-bootstrap-network-parallel.test.sh
FM_TEST_BEGIN 2026-09-03T21:07:43Z tests/fm-kimi-harness.test.sh family=pure-contract-unit expected_gate_skip=none
not ok - test needs python3
FM_TEST_END 2026-09-03T21:07:43Z tests/fm-kimi-harness.test.sh exit=1 duration_ms=0 gate_skip=false
FM_TEST_BEGIN 2026-09-03T21:07:43Z tests/fm-no-mistakes-required.test.sh family=unclassified expected_gate_skip=none
not ok - python3 is required to exercise the pinned shared action
FM_TEST_END 2026-09-03T21:07:43Z tests/fm-no-mistakes-required.test.sh exit=1 duration_ms=0 gate_skip=false
FM_TEST_BEGIN 2026-09-03T21:07:43Z tests/fm-bootstrap-network-parallel.test.sh family=session-bootstrap expected_gate_skip=none
not ok - python3 is required to decode the fm-on.sh argv payload
FM_TEST_END 2026-09-03T21:07:43Z tests/fm-bootstrap-network-parallel.test.sh exit=1 duration_ms=0 gate_skip=false
FM_TEST_SUMMARY total=3 failed=3 skipped_gate=0 duration_ms=0
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=1 duration_ms=0 failed=1
FM_TEST_SUMMARY_FAMILY family=session-bootstrap count=1 duration_ms=0 failed=1
FM_TEST_SUMMARY_FAMILY family=unclassified count=1 duration_ms=0 failed=1
FM_TEST_SLOWEST rank=1 script=tests/fm-bootstrap-network-parallel.test.sh duration_ms=0
FM_TEST_SLOWEST rank=2 script=tests/fm-kimi-harness.test.sh duration_ms=0
FM_TEST_SLOWEST rank=3 script=tests/fm-no-mistakes-required.test.sh duration_ms=0
[exit 1]

############ AFTER - target e76dd59b (this change)
$ PATH=<no python3> bin/fm-test-run.sh tests/fm-kimi-harness.test.sh tests/fm-no-mistakes-required.test.sh tests/fm-bootstrap-network-parallel.test.sh
FM_TEST_BEGIN 2026-09-03T21:07:33Z tests/fm-kimi-harness.test.sh family=pure-contract-unit expected_gate_skip=none
skip: python3 not found (optional interpreter, not installed by bin/fm-bootstrap.sh)
FM_TEST_END 2026-09-03T21:07:34Z tests/fm-kimi-harness.test.sh exit=0 duration_ms=1000 gate_skip=true
FM_TEST_BEGIN 2026-09-03T21:07:34Z tests/fm-no-mistakes-required.test.sh family=unclassified expected_gate_skip=none
skip: python3 not found (optional interpreter, not installed by bin/fm-bootstrap.sh)
FM_TEST_END 2026-09-03T21:07:34Z tests/fm-no-mistakes-required.test.sh exit=0 duration_ms=0 gate_skip=true
FM_TEST_BEGIN 2026-09-03T21:07:34Z tests/fm-bootstrap-network-parallel.test.sh family=session-bootstrap expected_gate_skip=none
skip: python3 not found (optional decoder for the fm-on.sh argv payload)
FM_TEST_END 2026-09-03T21:07:34Z tests/fm-bootstrap-network-parallel.test.sh exit=0 duration_ms=0 gate_skip=true
FM_TEST_SUMMARY total=3 failed=0 skipped_gate=3 duration_ms=1000
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=1 duration_ms=1000 failed=0
FM_TEST_SUMMARY_FAMILY family=session-bootstrap count=1 duration_ms=0 failed=0
FM_TEST_SUMMARY_FAMILY family=unclassified count=1 duration_ms=0 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-kimi-harness.test.sh duration_ms=1000
FM_TEST_SLOWEST rank=2 script=tests/fm-bootstrap-network-parallel.test.sh duration_ms=0
FM_TEST_SLOWEST rank=3 script=tests/fm-no-mistakes-required.test.sh duration_ms=0
[exit 0]
Evidence: Refreshed shard figures recomputed from the runner itself (matches docs, ci.yml and the bound rationale)

$ bin/fm-test-run.sh --list --lane portable-serial | wc -l 154 portable-serial-1of8 17 scripts 433890 ms (~433.9 s) portable-serial-2of8 19 scripts 433922 ms (~433.9 s) portable-serial-3of8 19 scripts 433897 ms (~433.9 s) portable-serial-4of8 19 scripts 433900 ms (~433.9 s) portable-serial-5of8 20 scripts 433900 ms (~433.9 s) portable-serial-6of8 20 scripts 433895 ms (~433.9 s) portable-serial-7of8 20 scripts 433908 ms (~433.9 s) portable-serial-8of8 20 scripts 433909 ms (~433.9 s) lane total 3471221 ms (~57.9 min); balanced shard ~433.9 s (~7.2 min) hints applying to the lane: 124 of 154 scripts, 2871221 ms unmeasured: 30 scripts at 20000 ms each

$ bin/fm-test-run.sh --list --lane portable-serial | wc -l
154

$ for k in 1..8: bin/fm-test-run.sh --list --lane portable-serial-${k}of8 | wc -l
portable-serial-1of8 17
portable-serial-2of8 19
portable-serial-3of8 19
portable-serial-4of8 19
portable-serial-5of8 20
portable-serial-6of8 20
portable-serial-7of8 20
portable-serial-8of8 20

estimated shard durations recomputed from the runner's own hint table + PORTABLE_SERIAL_DEFAULT_WEIGHT_MS=20000:
portable-serial-1of8   17 scripts  433890 ms (~433.9 s)
portable-serial-2of8   19 scripts  433922 ms (~433.9 s)
portable-serial-3of8   19 scripts  433897 ms (~433.9 s)
portable-serial-4of8   19 scripts  433900 ms (~433.9 s)
portable-serial-5of8   20 scripts  433900 ms (~433.9 s)
portable-serial-6of8   20 scripts  433895 ms (~433.9 s)
portable-serial-7of8   20 scripts  433908 ms (~433.9 s)
portable-serial-8of8   20 scripts  433909 ms (~433.9 s)
lane total 3471221 ms (~57.9 min); balanced shard ~433.9 s (~7.2 min)
hints applying to the lane: 124 of 154 scripts, 2871221 ms
unmeasured: 30 scripts at 20000 ms each
Evidence: TAP output: remote transport and job suites (fm-remote-job, fm-on, fm-remote-entrypoint, orphan-reap, worker-leak)
FM_TEST_BEGIN 2026-09-03T21:03:21Z tests/fm-remote-job.test.sh family=secondmate expected_gate_skip=none
ok - default queue and execution bounds independently cover long polls
ok - operator PATH excludes a symlinked local bin
ok - operator PATH honors nvm defaults with a deterministic fallback
ok - operator PATH resolves the authorized Nix profile bin link
ok - operator PATH orders discovered tool installs deterministically
ok - the worker preserves bounded argv and stdin in an empty environment
ok - active jobs keep the worker ready for concurrent requests
ok - ensure replaces a live worker after its code changes
ok - worker identity binds the canonical configured code root
tests/fm-remote-job.test.sh: line 366: 3629474 Killed                  nohup env HOME="$account_home" FM_ROOT_OVERRIDE="$root" FM_REMOTE_JOB_STATE_ROOT="$FM_REMOTE_JOB_STATE" FM_REMOTE_JOB_PLATFORM_OVERRIDE="${FM_REMOTE_JOB_PLATFORM_OVERRIDE:-}" "$worker" >> "$FM_REMOTE_JOB_STATE/logs/$FM_REMOTE_JOB_LABEL.log" 2>&1 < /dev/null
ok - stale ownership is reclaimed without signaling a reused pid
ok - the worker enforces the job timeout and publishes its result
ok - the worker expires queued jobs before they can mutate
ok - queued jobs receive a fresh bounded execution window
ok - a queued short command preempts a running long poll instead of waiting its window
ok - a poll re-armed after preemption reads the same cursor with nothing lost
ok - sibling polls never preempt each other into a re-arm churn loop
ok - worker shutdown terminates the active command tree before replacement
ok - Linux supervision recovers crashes and stops orphaned commands
ok - pre-execution validation obeys the job timeout
ok - the worker drains bounded output without changing command results
ok - the worker refuses symlinked job fields before command execution
ok - failed shutdown quarantines ownership against replacement workers
ok - quarantine recovery refuses unverifiable supervisors and ignores reused pids
ok - a repeatedly signalled shutdown still releases ownership for the next worker
ok - barely healthy worker failures remain bounded by the restart guard
ok - staging refuses a caller stream that never reaches EOF instead of blocking on it
ok - a finite payload survives the stdin bound byte for byte on every mechanism arm and call shape
ok - a slow but complete stdin capture leaves the queue budget intact
ok - an out-of-range stdin bound is refused by the shared settings validator
ok - a capture no bounded runner could start is refused rather than silently skipped
ok - the library refuses to load without the bound owner the capture depends on
ALL TESTS PASSED
FM_TEST_END 2026-09-03T21:04:51Z tests/fm-remote-job.test.sh exit=0 duration_ms=90070 gate_skip=false
FM_TEST_BEGIN 2026-09-03T21:04:51Z tests/fm-on.test.sh family=secondmate expected_gate_skip=none
ok - fm-on --stdin preserves argv, stdin, stdout, stderr, and exit status without shell interpretation
ok - fm-on defaults the remote command's stdin to /dev/null
ok - fm-on arms a bounded SSH dead-peer detection window by default (15s x 3 = 45s)
ok - fm-on's dead-peer detection window is env-overridable
ok - fm-on rejects invalid dead-peer settings before launching ssh
ok - the fixed entrypoint runs every command in the worker's explicit environment
ok - the entrypoint composes a deduplicated discovered child PATH (kept 2 existing, omitted 9 absent)
ok - read-only doctor inspects worker gaps over plain SSH without repair
ok - the remote doctor reports the same PATH the entrypoint hands its children
ok - the remote doctor derives tool readiness from the installed worker
ok - the remote doctor reports its required runtime tool set and optional tools
ok - multiple fm-*.sh executables work without a command table
ok - tracked-command authorization excludes checkout-local git
ok - doctor bootstrap remains authenticated when git is unavailable
ok - transport rejects shell escape, traversal, symlink, and option-injection surfaces
ok - the fixed entrypoint refuses incompatible protocols and unsafe roots
ok - ambiguous aliases refuse while exact secondmate ids remain routable
ok - unreachable and ambiguous transport failures are surfaced without retry
ALL TESTS PASSED
FM_TEST_END 2026-09-03T21:04:57Z tests/fm-on.test.sh exit=0 duration_ms=5938 gate_skip=false
FM_TEST_BEGIN 2026-09-03T21:04:57Z tests/fm-remote-entrypoint.test.sh family=unclassified expected_gate_skip=none
ok - fm-remote-entrypoint.sh invoked via a PATH symlink resolves SCRIPT_DIR to the real bin/ directory
ok - fm-remote-entrypoint.sh invoked directly still resolves SCRIPT_DIR correctly

all fm-remote-entrypoint tests passed
FM_TEST_END 2026-09-03T21:04:57Z tests/fm-remote-entrypoint.test.sh exit=0 duration_ms=90 gate_skip=false
FM_TEST_BEGIN 2026-09-03T21:04:57Z tests/fm-remote-job-orphan-reap.test.sh family=secondmate expected_gate_skip=none
ok - the Linux start path puts the whole worker tree in its own process group
ok - removing the state root and killing the recorded worker pid leaves the detached tree running
ok - a worker whose code root still exists is never reaped
ok - a worker stops its whole tree once its code root is pruned
ok - a dry run reports the abandoned worker and signals nothing
ok - the reaper stops an abandoned worker's whole tree
ok - the reaper is idempotent
FM_TEST_END 2026-09-03T21:05:00Z tests/fm-remote-job-orphan-reap.test.sh exit=0 duration_ms=2717 gate_skip=false
FM_TEST_BEGIN 2026-09-03T21:05:00Z tests/fm-remote-job-worker-leak.test.sh family=secondmate expected_gate_skip=none
ok - an idle worker leaves no orphans after a failed-quarantine TERM
ok - an idle worker leaves no orphans after a failed-quarantine INT
ok - an idle worker leaves no orphans after a failed-quarantine HUP
ok - a process-group TERM after a failed quarantine leaves no orphans
ok - removing the state root and TERMing the serving worker leaves no orphans
ok - a failed run with an active job leaves no orphaned processes
ok - serving worker shutdown reaps an unregistered descendant
ok - failed-quarantine shutdown leaves a replacement worker's quarantine marker
ok - supervisor shutdown reaps a child TERMing during spawn
ok - the Linux supervisor does not restart serving exit 0
ok - the Linux supervisor does not restart serving exit 75
ok - the Linux supervisor does not restart serving exit 125

all fm-remote-job-worker-leak tests passed
FM_TEST_END 2026-09-03T21:05:03Z tests/fm-remote-job-worker-leak.test.sh exit=0 duration_ms=3004 gate_skip=false
FM_TEST_SUMMARY total=5 failed=0 skipped_gate=0 duration_ms=101883
FM_TEST_SUMMARY_FAMILY family=secondmate count=4 duration_ms=101729 failed=0
FM_TEST_SUMMARY_FAMILY family=unclassified count=1 duration_ms=90 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-remote-job.test.sh duration_ms=90070
FM_TEST_SLOWEST rank=2 script=tests/fm-on.test.sh duration_ms=5938
FM_TEST_SLOWEST rank=3 script=tests/fm-remote-job-worker-leak.test.sh duration_ms=3004
FM_TEST_SLOWEST rank=4 script=tests/fm-remote-job-orphan-reap.test.sh duration_ms=2717
FM_TEST_SLOWEST rank=5 script=tests/fm-remote-entrypoint.test.sh duration_ms=90
rc=0
Evidence: TAP output: bin/fm-test-run.sh contract suite on the target
FM_TEST_BEGIN 2026-09-03T20:56:29Z tests/fm-test-run.test.sh family=pure-contract-unit expected_gate_skip=none
ok - exact suite coverage: --all lists every tests/*.test.sh once
ok - family selection returns a proper subset of the suite
ok - single-script selection lists exactly that path
ok - changed-file selection stays conservative (never silent full suite)
ok - runner and its documentation surfaces select their curated family, not just their contract owners
ok - changed selection covers dependents and fails closed for unmapped source
ok - a bin reference selects the referencing scripts, and consumers still select their curated families
ok - changed defaults to bounded automatic scheduling with serial override
ok - empty changed selection emits deterministic text and JSON summaries
ok - timing markers and JSON artifact are valid
ok - aggregate exit reflects any script failure
ok - gate-skip accounting is honest and non-failing
ok - fail-on-gate-skip converts herdr-not-found into a hard failure
ok - exclude-family drops the named primary family after selection
ok - portable shard union, disjointness, and coverage guard hold
ok - portable serial shards are a deterministic disjoint cover of the serial lane
ok - portable serial shard lanes refuse mismatched, out-of-range, and countless names
ok - coverage guard is clean under 3 locale(s), including collation divergence
ok - --jobs refuses non-proven / stateful selections
ok - --jobs admits and schedules a family with a recorded concurrent proof
ok - a concurrent run starts the longest-hint script first
ok - --per-script-timeout-secs turns a hung script into a bounded failure
ok - --max-wall-ms fails an over-budget run and refuses a malformed budget
ok - jobs scheduler runs proven scripts; failure propagates; non-proven refused
ok - Herdr CI family-run step times out at 20 min under a 75 min job backstop # skip ruby not found (optional interpreter, not installed by bin/fm-bootstrap.sh)
ok - the per-script bound also terminates and reports a hung script under --jobs
ok - --per-script-timeout-secs 0 is a real opt-out, not the default in disguise
ok - the per-script bound default arms for every standard mode without a flag
ok - a sweep stopped by a signal reports and relays the signal that stopped it
ok - a bound that could not be armed is reported as a script that never ran
ok - a script that exits 124 on its own is not reported as killed by the bound
ok - aggregate-json merges lane timing artifacts

all fm-test-run tests passed
FM_TEST_END 2026-09-03T20:58:16Z tests/fm-test-run.test.sh exit=0 duration_ms=106655 gate_skip=false
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=106684
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=1 duration_ms=106655 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-test-run.test.sh duration_ms=106655
rc=0
Evidence: TAP output: interpreter-skip sibling suites (kimi-harness, bootstrap-network-parallel, remote-backlog-handoff)
FM_TEST_BEGIN 2026-09-03T21:05:14Z tests/fm-kimi-harness.test.sh family=pure-contract-unit expected_gate_skip=none
ok - Kimi hook install is idempotent and removal restores every foreign config byte
ok - Kimi hook removal preserves owned newline boundaries and pristine bytes
ok - Kimi hook install refuses missing, malformed, and surprising config without writing
ok - Kimi hook install refuses without jq before any config write
ok - fm-spawn: kimi launches, delivers its brief, and registers a guarded turn-end token
ok - Kimi hook stays silent and inert without a Firstmate registry token
ok - fm-spawn: unsafe Kimi global config refuses before pane creation
ok - fm-teardown: Kimi task pointer and registry token are removed
ok - fm-spawn: Kimi fallback expands the active HOME
ok - fm-spawn: missing Kimi executable refuses before pane creation
ok - fm-spawn: kimi treats a silent pointer drop as a failed spawn
ok - fm-spawn: kimi never sends the brief pointer before an observable ready signal
ok - fm-harness: markerless kimi is detected by ancestry after env-marker precedence
lock acquired: harness pid 4081467
ok - fm-lock recognizes Kimi ancestry and live lock holders
ok - busy detection: real Kimi moon-plus-middot captures require its harness while idle labels stay idle
ok - fm-watch classifies Kimi as unknown rather than from its spinner, and Grok's fallback stays isolated
ok - composer classifier: kimi's existing bordered > shape is already safe without an override

all fm-kimi-harness tests passed
FM_TEST_END 2026-09-03T21:05:27Z tests/fm-kimi-harness.test.sh exit=0 duration_ms=13227 gate_skip=false
FM_TEST_BEGIN 2026-09-03T21:05:27Z tests/fm-bootstrap-network-parallel.test.sh family=session-bootstrap expected_gate_skip=none
ok - bootstrap network (parallel): per-mate output stays intact, fail-closed, and correctly sequenced
ok - bootstrap network (fallback): per-mate output stays intact, fail-closed, and correctly sequenced
# all fm-bootstrap-network-parallel tests passed
FM_TEST_END 2026-09-03T21:05:33Z tests/fm-bootstrap-network-parallel.test.sh exit=0 duration_ms=6097 gate_skip=false
FM_TEST_BEGIN 2026-09-03T21:05:33Z tests/fm-remote-backlog-handoff.test.sh family=secondmate expected_gate_skip=none
ok - confined put rejects incomplete and superseded payload generations
ok - confined put rejects directory replacement without external writes
ok - ambiguous receipt leaves one durable outbox and no duplicate dispatchable source
ok - re-delivery after unknown completion converges without duplication
ok - dropped transfer recovery overwrites scratch and delivers exactly once
ok - concurrent handoffs serialize staging through confirmed cleanup
ok - receiver removes one proven dead stale lock and retries once
ok - bootstrap detects pending outbox handoffs without a journal
ok - remote handoff wakes its supported endpoint or remains loudly recoverable
ok - fresh remote work gets a new wake after confirmed cleanup recovery
ok - route classification serializes with retirement before staging
ok - unconfigured bootstrap has no remote handoff behavior
ALL TESTS PASSED
FM_TEST_END 2026-09-03T21:05:54Z tests/fm-remote-backlog-handoff.test.sh exit=0 duration_ms=20502 gate_skip=false
FM_TEST_SUMMARY total=3 failed=0 skipped_gate=0 duration_ms=39870
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=1 duration_ms=13227 failed=0
FM_TEST_SUMMARY_FAMILY family=secondmate count=1 duration_ms=20502 failed=0
FM_TEST_SUMMARY_FAMILY family=session-bootstrap count=1 duration_ms=6097 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-remote-backlog-handoff.test.sh duration_ms=20502
FM_TEST_SLOWEST rank=2 script=tests/fm-kimi-harness.test.sh duration_ms=13227
FM_TEST_SLOWEST rank=3 script=tests/fm-bootstrap-network-parallel.test.sh duration_ms=6097
rc=0
Evidence: Manual E2E harnesses used to produce the transcripts above (reproducible, kept out of the worktree)
#!/usr/bin/env bash
# End-to-end demonstration of issue 178: a caller-open stdin crossing the SSH
# transport into bin/fm-remote-entrypoint.sh. Drives the real bin/fm-on.sh over
# a fake ssh that execs the real remote entrypoint, exactly as tests/fm-on.test.sh
# wires the transport, but with a stream that NEVER closes.
set -u
SRC=$1        # tree that provides bin/* (a checkout of some commit)
LABEL=$2
BOUND=${3:-5}

TMP=$(mktemp -d "${TMPDIR:-/tmp}/fm178.XXXXXX")
LOCAL_HOME="$TMP/local-home"; REMOTE_ROOT="$TMP/remote-root"; REMOTE_HOME="$TMP/remote-home"
FAKEBIN="$TMP/fakebin"; STATE="$TMP/remote-jobs"
mkdir -p "$LOCAL_HOME/data" "$REMOTE_ROOT/bin" "$REMOTE_HOME" "$FAKEBIN"
printf 'fixture\n' > "$REMOTE_ROOT/AGENTS.md"
cp "$SRC/bin/fm-remote-entrypoint.sh" "$SRC/bin/fm-remote-job-lib.sh" \
   "$SRC/bin/fm-remote-job-worker.sh" "$REMOTE_ROOT/bin/"
[ -f "$SRC/bin/fm-timeout-lib.sh" ] && cp "$SRC/bin/fm-timeout-lib.sh" "$REMOTE_ROOT/bin/"
cat > "$REMOTE_ROOT/bin/fm-probe-one.sh" <<'SH'
#!/usr/bin/env bash
set -u
printf 'remote command ran on the secondmate\n'
while IFS= read -r line || [ -n "$line" ]; do printf 'stdin: %s\n' "$line"; done
SH
chmod +x "$REMOTE_ROOT/bin"/*.sh
git -C "$REMOTE_ROOT" init -q -b main
git -C "$REMOTE_ROOT" config user.email t@example.com
git -C "$REMOTE_ROOT" config user.name T
git -C "$REMOTE_ROOT" add AGENTS.md bin
git -C "$REMOTE_ROOT" commit -qm fixture
cat > "$FAKEBIN/fake-ssh" <<'SH'
#!/usr/bin/env bash
while [ "$#" -gt 0 ]; do case "$1" in -o) shift 2 ;; --) shift; break ;; *) exit 90 ;; esac; done
shift 2
exec "$FM_FAKE_REMOTE_ENTRYPOINT" "$@"
SH
chmod +x "$FAKEBIN/fake-ssh"
cat > "$LOCAL_HOME/data/secondmates.md" <<EOF
- ios - iOS delivery (host: remote-mac; root: $REMOTE_ROOT; home: $REMOTE_HOME; scope: iOS work; projects: alpha; added 2026-08-02)
EOF

fm_on() {
  timeout 60 env FM_HOME="$LOCAL_HOME" FM_ROOT_OVERRIDE="$REMOTE_ROOT" \
    FM_SSH_BIN="$FAKEBIN/fake-ssh" \
    FM_FAKE_REMOTE_ENTRYPOINT="$REMOTE_ROOT/bin/fm-remote-entrypoint.sh" \
    FM_REMOTE_JOB_PLATFORM_OVERRIDE=Linux FM_REMOTE_JOB_STATE_ROOT="$STATE" \
    FM_REMOTE_JOB_STDIN_TIMEOUT="$BOUND" \
    "$SRC/bin/fm-on.sh" "$@"
}

# The caller's stream: bytes are available but the write end is never closed,
# so the reader never sees EOF. This is the shape issue 178 deadlocked on.
FIFO="$TMP/caller-stream.fifo"; mkfifo "$FIFO"
exec 9<>"$FIFO"; printf 'payload the caller never terminates\n' >&9

echo "############ $LABEL"
echo "### scenario A: default invocation (no --stdin) while the caller's stream stays open"
echo "\$ fm-on.sh ios fm-probe-one.sh   < <caller stream that never closes>"
A_BEGAN=$SECONDS
fm_on ios fm-probe-one.sh < "$FIFO" 2>&1
A_RC=$?
echo "[exit $A_RC after $((SECONDS - A_BEGAN))s]"

echo
echo "### scenario B: --stdin invocation, same never-closing stream, FM_REMOTE_JOB_STDIN_TIMEOUT=$BOUND"
echo "\$ fm-on.sh --stdin ios fm-probe-one.sh   < <caller stream that never closes>"
B_BEGAN=$SECONDS
fm_on --stdin ios fm-probe-one.sh < "$FIFO" 2>&1
B_RC=$?
B_ELAPSED=$((SECONDS - B_BEGAN))
if [ "$B_RC" -eq 124 ]; then
  echo "[NO VERDICT: still blocked when the harness gave up after ${B_ELAPSED}s]"
else
  echo "[exit $B_RC after ${B_ELAPSED}s]"
fi
echo
echo "### scenario C: --stdin invocation with a stream the caller DOES close - the payload path still works"
echo "\$ printf 'payload one\\npayload two\\n' | fm-on.sh --stdin ios fm-probe-one.sh"
printf 'payload one\npayload two\n' > "$TMP/finite"
fm_on --stdin ios fm-probe-one.sh < "$TMP/finite" 2>&1
echo "[exit $? ]"
exec 9>&-
pid=$(cat "$STATE/worker.pid" 2>/dev/null || true)
case "$pid" in ''|*[!0-9]*) ;; *) parent=$(ps -p "$pid" -o ppid= 2>/dev/null | tr -d ' '); kill "$parent" "$pid" 2>/dev/null; sleep 1 ;; esac
pkill -f "$STATE" 2>/dev/null
rm -rf "$TMP"

Pipeline

Updates from git push no-mistakes

... (12 earlier update rounds omitted to keep the PR body within GitHub's 65536-char limit; full history is in the run log.)

⚠️ **Review** - 3 infos

Concrete path: .github/workflows/ci.yml:296 runs bin/fm-test-run.sh --family real-herdr-gated, which is standard mode, so line 1901 now arms the 480s default (MODE != changed, no --max-wall-ms). A 341s Herdr E2E running 1.41x slower than its measured time under CI load is terminated at 480s and reported not ok - ... exceeded the per-script bound of 480s with exit=124 on a required lane - a slow-but-healthy run turned into a red that reads as a hang. The margin there is 480/341 = 1.41x, not the impossibility the comment claims, and it is materially thinner than the 2x+ margin the same comment cites for the portable lanes.

The 480s value itself is settled and I am not asking for it to change. What needs a decision is whether the honest 1.41x margin on a required lane is acceptable: if yes, the remedy is comment-only (state the measured margin the way the serial-lane margin is already stated at lines 158-171, and drop the "hard constraint" claim); if no, any wider margin or family exemption is a behavior change that needs authorization.

  • ℹ️ docs/fm-test-portable-shards.md:124 - This change recomputed the portable-serial arithmetic to "about 7.2 minutes, leaving roughly 2.1x hang-tripwire margin" (and ~58 min across 154 scripts at line 77), and mirrored it into bin/fm-test-run.sh:159. I verified those numbers against the runner and they are exact. The sibling comment describing the same lane in .github/workflows/ci.yml:132-135 still reads "Measured whole remainder is ~47 min of serial work; the balanced shards are ~6.2 min each. Cap is a hang tripwire with roughly 2.4x margin" and was not refreshed.

So the repo now states two different margins for the same 15-minute cap, and the stale one is the more comfortable of the two: a maintainer sizing the shard matrix from the ci.yml comment believes there is 2.4x of headroom where there is 2.1x, on the one lane the new per-script bound's own arithmetic (bin/fm-test-run.sh:161-164) already describes as "thin but still inside". The drift predates this branch, but this branch is what made the correct figures authoritative and quoted them in two other files.

Remedy is mechanical: update the three numbers in that ci.yml comment (~47 min -> ~58 min, ~6.2 min -> ~7.2 min, 2.4x -> 2.1x) so the workflow, the doc, and the runner comment quote one measurement. No workflow behavior changes.

  • ℹ️ CONTRIBUTING.md:93 - The command cheat-sheet marks bin/fm-test-run.sh --changed as the invocation that comes "with automatic bounded concurrency and a per-script bound", while the four neighbouring standard-mode lines (91 one script, 92 --family, 97 --lane, 100 --all) carry no such note. That was accurate before this change; it is not now. As of bin/fm-test-run.sh:1901 every one of those standard-mode invocations arms the 480s default, and --changed is in fact the mode the default block skips.

A contributor reading line 93 concludes that bin/fm-test-run.sh --all runs unbounded, then sees a legitimately slow script reported exit=124 with no flag passed and no documented bound to look for. The same file is the one the change already edited (line 125) to document the new interpreter-skip shape, and docs/fm-test-portable-shards.md:130 already points operators at --help for the bound - CONTRIBUTING is the remaining surface that contradicts it.

Remedy is a docs-only correction: state that a per-script bound applies to every standard-mode sweep and that --changed's distinguishing feature in that line is the automatic bounded concurrency, pointing at --help for the value and the 0 opt-out.

  • ℹ️ tests/fm-test-run.test.sh:1128 - test_per_script_timeout_bounds_a_hung_script (lines 1128-1170) re-proves what the pre-existing test_per_script_timeout_bounds_a_hang (line 839) already proves, against the same code path. Both build a fixture that sleep 600, run the runner with a small --per-script-timeout-secs, and assert the identical three facts: a non-zero run status, FM_TEST_END ... exit=124, and FM_TEST_SUMMARY total=1 failed=1. The older test additionally proves the harder property - that the terminated script's SIGTERM-ignoring grandchild is reaped - and that a non-numeric bound is refused.

The only assertion unique to the new case is that the recorded duration_ms is under 60000, i.e. that the script was terminated rather than waited out. That is worth keeping; the other ~35 lines are a second copy, including a second bounded 600-second fixture in a file that already runs ~21s in a 10-minute parallel lane.

Suggested remedy: move the duration_ms &lt; 60000 assertion into test_per_script_timeout_bounds_a_hang and drop test_per_script_timeout_bounds_a_hung_script and its registration at line 1701. Flagging as ask-user rather than auto-fix because deleting a case is a coverage judgement, not a mechanical edit - the sibling cases added in the same rounds (..._under_jobs, the 124/125 discrimination cases, ..._default_arms_for_standard_modes) each cover something the older test does not and should stay.

🔧 Fix: refresh stale CI shard figures and CONTRIBUTING bound note
2 issues (1 warning, 1 info) still open:

  • ⚠️ bin/fm-remote-entrypoint.sh:178 - The headline diagnostic this change adds is unreachable on the only production path. fm_remote_job_stage now reports the new bounded-capture outcomes through FM_REMOTE_JOB_ERROR (bin/fm-remote-job-lib.sh:686 "remote job stdin never reached EOF within ${FM_REMOTE_JOB_STDIN_TIMEOUT}s; the caller must close the stream it hands over", and :691 for the unarmable-bound case), but the entrypoint calls staging inside a command substitution, so the assignment happens in a subshell and is discarded before die reads it.

Concrete trace: fm-on.sh --stdin &lt;route&gt; fm-foo.sh from a producer that never closes its stream. sshd runs bin/fm-remote-entrypoint.sh, which reaches line 178 if ! JOB_ID=$(fm_remote_job_stage ...). Staging blocks in fm_remote_job_capture_stdin for 360s, fm_run_timed returns 124, the library sets the specific message and returns 1. Back in the parent, FM_REMOTE_JOB_ERROR is still the empty string fm_remote_job_ensure_worker reset at its own entry (bin/fm-remote-job-lib.sh, first statement of that function), so line 180 expands the :- fallback and the operator sees cannot stage remote job with exit 70 after six minutes, with nothing naming stdin. Verified the shell semantics directly against this library: the substitution shape prints the fallback, the direct shape prints the specific cause. The sibling calls at lines 176 (fm_remote_job_ensure_worker) and 184 (fm_remote_job_wait) are direct calls and do surface their messages, so line 178 is the one asymmetric site.

The library already anticipates this shape: it sets FM_REMOTE_JOB_ID=$id with the comment "Sourceable API consumed by callers that do not use command substitution." Earliest supported boundary is that API - call fm_remote_job_stage ... &gt;/dev/null directly, die on failure so FM_REMOTE_JOB_ERROR is still in scope, then take JOB_ID=$FM_REMOTE_JOB_ID. Non-substitution staging is already exercised by tests/fm-remote-job.test.sh, and the new arm-coverage loop pins both shapes, so the behavior is covered.

User intent states the refusal comes "with FM_REMOTE_JOB_ERROR naming the unclosed stream as the cause"; the variable is set, but no caller can read it. Flagging as a source defect rather than an intent contradiction because the remedy corrects plumbing rather than changing the promised behavior.

  • ℹ️ bin/fm-test-run.sh:167 - The new bound-rationale comment states "portable-parallel is tighter still: a ~1 min measured shard wall plus 480s plus that lane's setup steps sits at or just over its 600s cap". The measurement it reasons from is owned by docs/fm-test-portable-shards.md, which records portable-parallel-1 at 134295 ms (~134.3 s) and portable-parallel-2 at 126020 ms (~126.0 s) - about 2.2 minutes, not one.

The "~1 min" figure would only hold if the lane ran concurrently, and it does not: JOBS=1 is the default (bin/fm-test-run.sh:142), --lane portable-parallel-N only calls add_script (bin/fm-test-run.sh:760-772) and never raises JOBS, and .github/workflows/ci.yml:76 and :113 invoke the lane with --json only. So the shard wall in CI is the serial sum, ~134 s.

The conclusion is unaffected - redoing the comment's own replacement arithmetic with the real number gives 134 s less the ~12 s mean slot plus 480 s = ~602 s against the 600 s cap, which is still "at or just over" and if anything more certain than the comment claims. Only the premise is wrong. Remedy is the three-number correction the rest of this branch already applied to the serial lane: state ~134 s (~2.2 min) as the measured shard wall and ~602 s against the 600 s cap, so the runner comment and docs/fm-test-portable-shards.md quote one measurement. No behavior change.

🔧 Fix: surface stdin bound diagnostic; correct lane margin figures
3 infos still open:

  • ℹ️ bin/fm-test-run.sh:1900 - The arming-site rationale still carries the claim the branch's later round deliberately removed, so the file now asserts both sides of the same fact. Lines 1899-1902 say "480s sits above the real-Herdr family wall that caps any one script in it at ~420s and better than 2x over the 210s portable worst case, so this only ever fires on a script that is genuinely stuck." Lines 152-160, rewritten in commit e76dd59, say the opposite: "That wall is a measurement, not a ceiling: the only bound that lane enforces is the family-run step's 1200s, and the family's slowest measured script is the 341s presentation E2E. So 480s is 1.41x over that script ... and a Herdr E2E running 1.41x slower than measured turns red as exit=124 on a required lane." Verified against the tree: .github/workflows/ci.yml enforces only timeout-minutes: 20 on the family-run step, and the ~420s figure is 7 min / 12 scripts, a mean, not a cap.

The same overstatement survives in user-visible --help at bin/fm-test-run.sh:67-68 ("No real script approaches either automatic bound, so it only converts a HUNG script into a bounded failure"), where 341s against 480s is 71% of the bound. Round 4's fix instruction asked for exactly this correction ("drop the 'hard constraint rather than a statistical one' claim ... State the measured margin the way the serial-lane margin is already stated"); it landed at lines 151-171 and was not carried to the other two copies.

Remedy is the correction already approved, not a new decision: replace the duplicated arithmetic at 1899-1902 with a pointer to the DEFAULT_PER_SCRIPT_TIMEOUT_SECS rationale that owns it, and restate the --help sentence as the measured margin (1.41x on real-Herdr, 2.3x on the portable lanes) instead of "no real script approaches". No behavior change.

  • ℹ️ bin/fm-remote-entrypoint.sh:178 - The direct-call staging shape is restored but nothing in the tree now protects it, and this exact reversion has already happened once on this branch.

PR 254 head (fc448ab:140-146) carried the shape with a load-bearing comment: "Staged through the sourceable FM_REMOTE_JOB_ID API rather than a command substitution: a subshell would discard FM_REMOTE_JOB_ERROR and reduce every staging failure to the bare fallback below." Merge 6f4e822 reverted the code to JOB_ID=$(fm_remote_job_stage ...), which silently re-broke the headline diagnostic; round 4 rediscovered it and round 5 (e76dd59) restored the direct call but not the comment. The current lines 178-182 are the corrected shape with no explanation of why it must not be a command substitution.

No test pins it either: tests/fm-remote-entrypoint.test.sh only asserts symlink SCRIPT_DIR resolution, and tests/fm-on.test.sh drives the real entrypoint through a fake ssh but never exercises a staging failure, so no case observes the operator-visible diagnostic. The new coverage in tests/fm-remote-job.test.sh:869-887 pins both call shapes at the library level, which is precisely why the entrypoint-level regression passed CI unnoticed the first time.

Smallest honest remedy is mechanical: restore the three-line comment above line 178. Flagging the absent entrypoint-level regression case as the reason it matters rather than as the remedy, since adding one would extend this change.

  • ℹ️ bin/fm-test-run.sh:2148 - run_script_bounded stamps its own began (line 2148) and elapsed (line 2164) around the bounded call, but run_one_serial already brackets that same call with begin_ms/end_ms and computes duration from them (lines 2178-2192). The two intervals differ only by the printf FM_TEST_BEGIN and the set +e, so the second measurement adds nothing the caller does not already have.

now_ms shells out to python3 -c &#39;import time; ...&#39; (bin/fm-test-run.sh:114-120), so this is two extra interpreter spawns per script. That path is no longer rare: the new DEFAULT_PER_SCRIPT_TIMEOUT_SECS arms it for every standard-mode sweep, so a portable-serial shard now pays roughly 2 x 20 extra spawns, and --all pays 2 x 154, on a lane the same comment block describes as sitting ~891s inside a 900s cap.

The parallel path already derives the note's seconds from the single measurement it keeps: run_bound_outcome_note &#34;$script&#34; &#34;$rc&#34; &#34;$((duration / 1000))&#34; ... (line 2308). Doing the same in run_one_serial - move the run_bound_outcome_note | tee -a &#34;$out&#34; call out of run_script_bounded and feed it $((duration / 1000)) - removes the duplicate stamps and makes both paths quote one number. The discrimination stays correct: run_one_serial's interval strictly contains run_script_bounded's, so elapsed &gt;= bound can still never under-report a real bound kill. Only ordering shifts, and it shifts toward what the parallel path already does.

✅ **Test** - passed

✅ No issues found.

  • bin/fm-test-run.sh tests/fm-test-run.test.sh - green on this ruby-less host, with ok - Herdr CI family-run step... # skip ruby not found visible in the TAP
  • bin/fm-test-run.sh tests/fm-remote-job.test.sh tests/fm-on.test.sh tests/fm-remote-entrypoint.test.sh tests/fm-remote-job-orphan-reap.test.sh tests/fm-remote-job-worker-leak.test.sh - 5/5 green (bounded stdin capture, transport stdin default, staging diagnostic, timeout-lib fixture copies)
  • bin/fm-test-run.sh tests/fm-kimi-harness.test.sh tests/fm-bootstrap-network-parallel.test.sh tests/fm-remote-backlog-handoff.test.sh - 3/3 green (the whole-file skip refactor still runs normally when python3 is present)
  • Manual E2E for issue 178: real bin/fm-on.sh over the fake-ssh transport into the real bin/fm-remote-entrypoint.sh, caller stdin on a fifo held open, FM_REMOTE_JOB_STDIN_TIMEOUT=5, run against base a90370c9, intermediate a78f2def and the target - see fm178-e2e.sh in the evidence dir
  • Manual E2E for issue 220 (before): reconstructed the base a90370c9 tree as a git repo in temp and ran bin/fm-test-run.sh tests/fm-test-run.test.sh on the same ruby-less host - not ok - ruby is required to parse .github/workflows/ci.yml as YAML, exit=1
  • Manual E2E for issue 220 (whole-file gates): PATH=&lt;no python3&gt; bin/fm-test-run.sh tests/fm-kimi-harness.test.sh tests/fm-no-mistakes-required.test.sh tests/fm-bootstrap-network-parallel.test.sh on both trees - failed=3 at base, skipped_gate=3 exit 0 at the target
  • Manual E2E for the per-script bound: three-script fixture sweep with a hung middle script, no flag against base (NO VERDICT after the operator's budget) and --per-script-timeout-secs 5 against the target (exit=124, not ok - ... exceeded the per-script bound of 5s and was terminated, sweep continues) - see fm-bound-before.sh / fm-bound-demo.sh
  • Manual E2E for the 124/125 discrimination: a script that exits 124 itself and a stand-in fm_run_timed returning 125 - see fm-bound-124-125.sh
  • Default-arming and opt-out check: bin/fm-test-run.sh tests/fm-brief.test.sh with bin/fm-timeout-lib.sh removed refuses (per-script timeout helper not found), and --per-script-timeout-secs 0 runs unbounded and green
  • Doc-figure verification: bin/fm-test-run.sh --list --lane portable-serial | wc -l and each --lane portable-serial-&lt;k&gt;of8, plus a recomputation of shard weights from portable_serial_weight_hints + PORTABLE_SERIAL_DEFAULT_WEIGHT_MS
⚠️ **Document** - 2 infos
  • ℹ️ bin/fm-test-run.sh:552 - Follow-up, not resolvable in a documentation phase: the portable-serial weight hints are drifting data rather than stale prose. 30 of the lane's 154 scripts carry no measurement and ride PORTABLE_SERIAL_DEFAULT_WEIGHT_MS (600000 ms of the 3471221 ms estimate is guessed), and one hint names tests/fm-cursor-agy-adapter.test.sh, a script the lane no longer contains. The doc now states both facts honestly, so nothing is inaccurate, and the coverage guard keeps the partition complete regardless; but the balance the 15-minute cap's 2.1x margin is computed from rests partly on guesses. Refreshing needs per-shard timing artifacts from a green CI run via the procedure docs/fm-test-portable-shards.md:94 already owns, then re-deriving the shard table and the runner's ~434s figure from the new totals.
  • ℹ️ docs/fork-divergence.md:115 - Scope judgment worth visibility: I added two entries to the fork divergence ledger (bounded remote job stdin capture, default per-script test bound) because both are fork-local behavior added inside upstream-owned files by this reconcile PR, and the ledger's own maintenance rule requires a sync PR that creates a divergence to update it in the same round. The alternative reading is that the ledger records only divergences with a demonstrated collision surface, in which case these would wait until an upstream round actually collides with them. I judged recording them now to be right on this page's stated contract and on its own precedent of flagging entries that went unrecorded from introduction, but the placement call is the reviewer's to confirm.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Test and others added 14 commits September 3, 2026 09:03
…l interpreters

Two open defects made the suite unreliable in ways that cost verdicts.

Issue 178 (tests/fm-on.test.sh can deadlock and stall the entire test
sweep): the entrypoint captured caller stdin via head -c and would
block indefinitely whenever the caller's stdin was an open pipe with
no data, deadlocking the test (parent do_wait over grandchild
pipe_read) for the rest of the sweep. Adopt upstream's fix (PR 3210):
fm-on.sh now redirects ssh's stdin from /dev/null by default and only
forwards caller stdin when --stdin is passed. Update fm-on.test.sh to
use --stdin for the explicit stdin test and add a default-closed
assertion. Upstream left --per-script-timeout-secs off by default
outside --changed, which still allows an indefinite hang in the
non-changed path; apply 900s as the default for every standard-mode
sweep so a hung script becomes an ordinary red instead of stalling
the shard. Update tests/fm-test-run.test.sh to copy fm-timeout-lib.sh
alongside the runner under test.

Issue 220 (tests/fm-test-run.test.sh hard-fails when ruby is absent):
bin/fm-bootstrap.sh does not install ruby, so a host without system
ruby reported a hard failure on a YAML parse that nothing in the
suite depends on. Replace the fail with a visible TAP skip naming the
missing precondition and the reason. Audit the standard suite for
the same shape (optional external interpreter treated as mandatory)
and convert the matching python3 check in
tests/fm-bootstrap-network-parallel.test.sh to the same skip pattern.

Reproduction of the deadlock (before the fix, with stdin from an open
pipe that never writes): bash tests/fm-on.test.sh in do_wait over
bash bin/fm-on.sh ios fm-probe-two.sh in do_wait over bash
fm-remote-entrypoint.sh in pipe_read, deadlocking past six minutes.
After the fix the same scenario completes in ~5s. Stress: 5/5
runs of the test under a hanging-stdin pipe all complete and pass
without a per-script timeout, and a simulated deadlock test exits
124 within the configured bound under --per-script-timeout-secs 5.
The serial shard sizing evidence quoted a 129-script lane totalling
2819209 ms and a 6.8-minute balanced shard. The lane is now 152 scripts:
124 carry a measured hint (2871221 ms) and 28 carry the default weight,
so the estimated total is 3431221 ms and a balanced shard is about 7.1
minutes. Refresh the provenance sentence, the per-shard estimate table,
the four-shard comparison, and the timeout margin, and correct the
per-script bound rationale comment in bin/fm-test-run.sh, which quoted
the same stale 363s shard wall.
Sungin Kim added 6 commits September 3, 2026 18:33
Resolve the merge against origin/main (a90370c) onto PR 254 head fc448ab
to close both the fm-on.test.sh stdin deadlock (#178) and the
fm-test-run.test.sh ruby-dependency hard-fail (#220).

Conflict resolutions:

* CONTRIBUTING.md: take upstream's runner overview.
* bin/fm-on.sh: take upstream's usage() line range (sed '2,25p') per the
  handoff rule for hunks where upstream's version already carries the
  same change.
* bin/fm-remote-entrypoint.sh: take upstream's JOB_ID pattern
  (JOB_ID=$(fm_remote_job_stage ...)) so the disconnect probe
  (FM_REMOTE_JOB_DISCONNECT_PROBE=entrypoint_caller_connected) and
  abandonment cancellation wire into the same upstream lane machinery
  that drove upstream PR 3210.
* bin/fm-remote-job-lib.sh: take upstream's advance_seq_hint/next_seq/
  cancelled/cancel functions and add the sourceable FM_REMOTE_JOB_ID
  plus the time-bounded FM_REMOTE_JOB_STDIN_TIMEOUT capture (fork's
  fm_remote_job_capture_stdin) on top, since the worker already calls
  fm_remote_job_cancelled and the bounded stdin capture is the durable
  half of issue #178's fix for a --stdin caller that never closes its
  stream.
* bin/fm-test-run.sh: take upstream's --jobs admission and
  --max-wall-ms budget, keep the fork's 480s DEFAULT_PER_SCRIPT_TIMEOUT_SECS
  default for non-changed modes (the guard for issue #178) along with
  run_bound_outcome_note, run_forward_signal signal relay, and the
  run_script_bounded PGID/started marker chain that lets exit 124 and
  exit 125 be told apart. Skip the 480s default when MODE=changed or
  --max-wall-ms is set so upstream's CHANGED_DEFAULT_TIMEOUT_SECS=900
  applies unchanged on --changed and --max-wall-ms does not require the
  timeout helper. Set PER_SCRIPT_TIMEOUT_SET on every explicit
  --per-script-timeout-secs so an opt-out 0 is treated as such.
* tests/fm-test-run.test.sh: keep fork's skip_without helper so a host
  without ruby or python3 still reaches a verdict, with the affected
  cases skipped rather than the whole file failing (the same shape as
  issue #220's ruby precondition).

Closes #178
Closes #220
@HelloWorldSungin HelloWorldSungin changed the title fix(bin): close fm-on stdin by default and bound each test script fix(bin): bound each test script and the remote job stdin capture Sep 3, 2026
…ck needs no code change. "Behavior portable serial 6" was failing on tests/fm-secondmate-reconcile.test.sh, which carries two wall-clock races (the same job also failed one run earlier on main, on the other of the two): 1. test_busy_lifecycle_locks_never_hold_up_the_digest ("not ok - a busy meta lock blocked the reconcile path", this PR's head). It asserted the backgrounded run_notify had already exited after a fixed `sleep 0.2`. Under CPU contention a correct non-blocking run legitimately needs longer, so the test reported "blocked" when nothing was blocked. Replaced the fixed budget with the actual property under test: wait for the child to exit while the lock holder still owns the lock, bounded at 60s so a genuinely blocking path still reports instead of hanging. 2. test_the_window_is_four_hours ("the window was shorter than four hours", main's run of the same shard). It seeded the cooldown stamp at now-14399 against the 14400s window - a one-second margin. bin/fm-secondmate-reconcile.sh:251 reads its own clock later, so >=1s of elapsed wall time pushes the age to 14400 and the ask is sent. Widened to a +/-60s bracket (14340 / 14460). Only tests/fm-secondmate-reconcile.test.sh changed (17 insertions, 5 deletions). No production code touched. Verification (24-core host, so both races only surface under contention; pinned to 2 loaded CPUs to mimic the runner): - Reproduced both CI failures verbatim on unmodified code under that load. - After the fix both cases and the full file pass under identical load; the file also passes through the real lane runner bin/fm-test-run.sh (exit 0, 39.3s). - Mutation-checked that the loosened assertions still discriminate: cooldown windows of 14300 or 14500 (only 100s off four hours) still fail the bracket, and swapping fm_lock_try_acquire for fm_lock_acquire_wait on the meta lock still fails the lock case. The temporarily mutated bin/fm-secondmate-reconcile.sh was restored (git diff clean). - bin/fm-lint.sh passes; bin/fm-test-run.sh --check-coverage passes. "PR must be raised via no-mistakes": not caused by this change. The action ran on a synchronize event with empty PR_BODY/PR_HEAD_SHA; the PR body currently does contain the required "Updates from [git push no-mistakes]" attestation, and the same check passed on the opened event for this branch. This is the attestation-check-after-a-pipeline-push case, external to the code, so no edit was made for it
@HelloWorldSungin
HelloWorldSungin merged commit bb26893 into main Sep 4, 2026
16 of 19 checks passed
@HelloWorldSungin
HelloWorldSungin deleted the fm/fm-test-suite-robustness branch September 4, 2026 00:10
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.

1 participant