Repository navigation
fix(bin): make watcher checkpoint timeout robust on non-GNU and INT-ignored runners - #271
Conversation
* 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
|
Root cause: Fix: the first commit is the cherry-picked upstream commit a95a227 (kunchenguid/firstmate #7911, fall back to perl when Result: serial 7, 10 and 11 pass on the hosted 26.04 runner with this branch. |
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_boundednow picks a timeout through a newfind_gnu_timeout, which only truststimeoutorgtimeoutif--versionreports GNU coreutils. Any othertimeout(for example uutils) falls through to the perl fallback.bin/fm-watch-checkpoint.sh: the perl fallback's forked child now resetsINT,TERMand the configured signal toDEFAULTbeforeexec. This keeps a caller that leftINTignored (for example a backgrounded run) from stopping the watcher from trappingINT. GNUtimeoutalready does this reset.tests/fm-watch-checkpoint.test.sh: the perl fallback test is replaced by isolated-PATH tests using stub timeouts. They cover GNUtimeout, non-GNUtimeoutyielding to GNUgtimeout, and non-GNUtimeoutfalling back to perl withINTdelivery and the cleanup bound beforeKILL. A further test checks that a quiet checkpoint exits 124 and leaves no watch lock when the caller ignoresINT.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.
bash -c 'trap "" INT; exec bash tests/fm-watch-checkpoint.test.sh'printedok - Perl fallback checkpoint ends the watcher cleanly even when the caller ignores INTand exited 0bin/fm-watch-checkpoint.shcommented out, the test printednot ok - watch lock pid survived the Perl fallback checkpoint with INT ignoredPipeline
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 ✅
bash tests/fm-watch-checkpoint.test.shoutput: all ok, including 'quiet checkpoint exits 124' and the non-GNU fallback casesbash tests/fm-contributions.test.shexited 0 with no 'not ok' linesbin/fm-test-run.sh --changed --exclude-family real-herdr-gated --exclude-quarantined --pc02-if-idlebash 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-GNUtimeoutfirst on PATH; the fake also broke the harness's own timeout use, so that run was discarded🔧 Fix applied.
✅ Re-checked - no issues remain.
bash -c 'trap "" INT; exec bash tests/fm-watch-checkpoint.test.sh'printedok - Perl fallback checkpoint ends the watcher cleanly even when the caller ignores INTand exited 0bin/fm-watch-checkpoint.shcommented out, the test printednot ok - watch lock pid survived the Perl fallback checkpoint with INT ignoredbin/fm-test-run.sh --changed --exclude-family real-herdr-gated --exclude-quarantined --pc02-if-idlebash -c 'trap "" INT; exec bash tests/fm-watch-checkpoint.test.sh'with the fix: all tests passThe same command with the signal-reset line inrun_with_perl_timeoutcommented 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.