Skip to content

fix(bin): make watcher checkpoint timeout robust on non-GNU and INT-ignored runners - #271

Merged
sKeLe100 merged 2 commits into
mainfrom
fm/ci-main-shards-7-10-11
Nov 16, 2026
Merged

sKeLe100 merged 2 commits into
mainfrom
fm/ci-main-shards-7-10-11

Conversation

@sKeLe100

Copy link
Copy Markdown
Owner

Intent

Make firstmate's CI green again. GitHub Actions run 43809404058 on main (commit d1a7d40) passed on its first attempt this morning and FAILED on a rerun of the same commit today, in three jobs: 'Behavior portable serial 7' (not ok - watcher checkpoint did not run), 'Behavior portable serial 10' (not ok - an already durable contribution signal re-rang the watcher; 1 contribution regressions), 'Behavior portable serial 11' (not ok - quiet checkpoint exit: expected exit 124, got 137). The same three jobs fail on two unrelated PRs (#269, lint-memory-fallback-files) while those shards pass serially on PC01. So the failure is timing/environment on GitHub runners, not a code change; every firstmate PR is blocked until fixed.

What Changed

  • bin/fm-watch-checkpoint.sh: run_bounded now picks a timeout through a new find_gnu_timeout, which only trusts timeout or gtimeout if --version reports GNU coreutils. Any other timeout (for example uutils) falls through to the perl fallback.
  • bin/fm-watch-checkpoint.sh: the perl fallback's forked child now resets INT, TERM and the configured signal to DEFAULT before exec. This keeps a caller that left INT ignored (for example a backgrounded run) from stopping the watcher from trapping INT. GNU timeout already does this reset.
  • tests/fm-watch-checkpoint.test.sh: the perl fallback test is replaced by isolated-PATH tests using stub timeouts. They cover GNU timeout, non-GNU timeout yielding to GNU gtimeout, and non-GNU timeout falling back to perl with INT delivery and the cleanup bound before KILL. A further test checks that a quiet checkpoint exits 124 and leaves no watch lock when the caller ignores INT.

Risk Assessment

✅ Low: The change makes the checkpoint use only a GNU coreutils timeout or gtimeout and otherwise fall back to the existing Perl bound. That removes the likely cause of exit 137 on runners whose timeout is not GNU, and the new tests cover the GNU, gtimeout and Perl paths with executable stubs. I read the diff but did not run the tests or confirm the runner's timeout implementation.

Testing

I drove the real checkpoint through the perl timeout fallback with SIGINT ignored in the caller, which is how the hosted runner lane starts its tests. With the fix, the checkpoint exits 124 and the watcher lock is cleaned up. Without it, the regression test fails the same way as the original CI failure. I did not run shards 7, 10 or 11 or any other suite, and I did not try the GNU-timeout path with SIGINT ignored. The configured baseline command had already passed.

  • Live validation: ✅ go - 2 of 2 scenarios driven live against the product
Scenario Result Live Evidence
Perl-fallback quiet checkpoint with caller ignoring SIGINT exits 124 and removes the watch lock pid ✅ pass live bash -c 'trap "" INT; exec bash tests/fm-watch-checkpoint.test.sh' printed ok - Perl fallback checkpoint ends the watcher cleanly even when the caller ignores INT and exited 0
Adversarial: the regression test catches the bug when the signal reset is removed ✅ pass live With line 90 of bin/fm-watch-checkpoint.sh commented out, the test printed not ok - watch lock pid survived the Perl fallback checkpoint with INT ignored
  • Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (17m32s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

🔧 **Test** - 1 issue found → auto-fixed ✅
  • 🚨 configured test command failed with exit code 1
  • Live validation: ✅ go - 2 of 2 scenarios driven live against the product
Scenario Result Live Evidence
Watcher checkpoint with GNU timeout: quiet checkpoint exits 124 and a stub non-GNU timeout falls back to gtimeout or perl ✅ pass live bash tests/fm-watch-checkpoint.test.sh output: all ok, including 'quiet checkpoint exits 124' and the non-GNU fallback cases
Contribution signal is not re-rung (fm-contributions test) ✅ pass live bash tests/fm-contributions.test.sh exited 0 with no 'not ok' lines
  • bin/fm-test-run.sh --changed --exclude-family real-herdr-gated --exclude-quarantined --pc02-if-idle
  • bash tests/fm-watch-checkpoint.test.sh (passes, including the new non-GNU timeout fallback tests)
  • bash tests/fm-contributions.test.sh (passes)
  • Ran both tests with a fake non-GNU timeout first on PATH; the fake also broke the harness's own timeout use, so that run was discarded

🔧 Fix applied.
✅ Re-checked - no issues remain.

  • Live validation: ✅ go - 2 of 2 scenarios driven live against the product
Scenario Result Live Evidence
Perl-fallback quiet checkpoint with caller ignoring SIGINT exits 124 and removes the watch lock pid ✅ pass live bash -c 'trap "" INT; exec bash tests/fm-watch-checkpoint.test.sh' printed ok - Perl fallback checkpoint ends the watcher cleanly even when the caller ignores INT and exited 0
Adversarial: the regression test catches the bug when the signal reset is removed ✅ pass live With line 90 of bin/fm-watch-checkpoint.sh commented out, the test printed not ok - watch lock pid survived the Perl fallback checkpoint with INT ignored
  • bin/fm-test-run.sh --changed --exclude-family real-herdr-gated --exclude-quarantined --pc02-if-idle
  • bash -c 'trap "" INT; exec bash tests/fm-watch-checkpoint.test.sh' with the fix: all tests pass
  • The same command with the signal-reset line in run_with_perl_timeout commented out: not ok - watch lock pid survived the Perl fallback checkpoint with INT ignored; the file was restored afterward
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

mehulbhagwani and others added 2 commits November 16, 2026 16:05
* Fix non-GNU timeout fallback

* no-mistakes(review): Assert INT reaches watcher in non-GNU timeout fallback test

* no-mistakes(document): Document GNU-only timeout selection in watch checkpoint

* no-mistakes(ci): Greptile flagged that only the non-GNU-timeout-to-Perl path had an isolated test. I added two isolated tests in tests/fm-watch-checkpoint.test.sh, as you asked. The production code is unchanged. The rule being tested: run_bounded must run GNU `timeout` first, then GNU `gtimeout`, then Perl. Whichever GNU command it runs must receive `--signal=INT --kill-after=<bound>s <seconds> <watcher>`. What changed: - **Shared setup:** a new helper, `make_isolated_checkpoint`, copies the checkpoint into a temporary root. It also builds a PATH that holds only the named host tools, so the stubs decide which timeout is found. The existing Perl-fallback test now uses this helper too. Its assertions are the same. - **Stubs:** a non-GNU stub reports `uutils` for `--version` and exits 137 if it is ever used. A GNU stub reports `GNU coreutils` and writes its own name and arguments to `$FM_HOME/timeout-calls`, then exits 124. - **`test_gnu_timeout_runs_the_watcher_bound`:** GNU `timeout` and GNU `gtimeout` are both on PATH. The test asserts exit 124, the quiet checkpoint line, and exactly one call: `timeout --signal=INT --kill-after=5s 1 <root>/bin/fm-watch.sh`. - **`test_non_gnu_timeout_uses_gnu_gtimeout`:** a non-GNU `timeout` is next to a GNU `gtimeout`. The test asserts the same exact call, made by `gtimeout`. - In both new tests, Perl is not on PATH. So if the code picked Perl by mistake, the run would fail with 127. How I checked it: - The full test file passes: all 14 tests. - I broke the code on purpose twice. When I swapped the order to try `gtimeout` first, the GNU timeout test failed. When the code always picked Perl, the run exited 127 instead of 124. I then put the production file back; `git status` shows only the test file changed. - `shellcheck -x` passes on the test file. This is a change to tests only, so there is nothing a user would see to check by hand
@sKeLe100

Copy link
Copy Markdown
Owner Author

Root cause: ubuntu-latest moved from 24.04 to 26.04 between attempt 1 and the rerun of run 43809404058. The 26.04 runner's /usr/bin/timeout is uutils coreutils 0.10.0 (GNU 9.4 before), which does not deliver --signal=INT --kill-after the way fm-watch-checkpoint.sh relies on, so the checkpoint exited 137 instead of 124 (serials 7, 10 and 11).

Fix: the first commit is the cherry-picked upstream commit a95a227 (kunchenguid/firstmate #7911, fall back to perl when timeout is not GNU coreutils). The pipeline then found the perl fallback also needed to reset an inherited ignored INT before exec, which GNU timeout does implicitly; that is the second commit, with a regression test.

Result: serial 7, 10 and 11 pass on the hosted 26.04 runner with this branch.

@sKeLe100
sKeLe100 merged commit 8666a44 into main Nov 16, 2026
23 checks passed
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