Repository navigation
fix(bin): retry ShellCheck roots that hit the memory ceiling without --external-sources - #6443
Conversation
…following telemetry
|
…urces) now gets only the time left in its root's original deadline, so it can no longer outlast the CI job. Invariant: one root's first attempt plus its fallback must fit inside a single FM_LINT_ROOT_SECONDS deadline, plus the cleanup grace. Only one site started a new deadline: the fallback call in fm_lint_run_root. The deadline is the only budget involved, because the memory limit already applies to each process separately. Changes in bin/fm-lint.sh: - fm_lint_exec_root now takes a <seconds> argument instead of always reading FM_LINT_INTERNAL_ROOT_SECS. - The first attempt passes the full deadline. - The fallback passes floor((start + deadline - now) / 1000) seconds. - When bounds are enforced and less than 1 second is left, no retry starts. fm_exec_timed rejects 0 seconds, so the retry cannot run with no time. The root keeps reason=memory, and the shard output says "no time left in its Ns deadline to retry without it". - Unbounded local runs have no deadline and behave as before. - The header comment now describes the shared deadline. Changes in tests/fm-lint.test.sh: a new test, test_memory_fallback_spends_only_the_remaining_root_deadline, runs only on hosts that can enforce bounds. It uses a 6 s deadline and 1 s grace. - Case 1: the first attempt runs 3 s and then fails with memory status 251. The test asserts one fallback ran, reported reason=timeout, and the root's recorded duration is under 7000 ms. - Case 2: the first attempt runs 5.2 s. The test asserts no fallback starts, the skip is explained, and the sidecar records memory with source-following 1. Verification: - Full `nice -n 10 bash tests/fm-lint.test.sh` passed, including the new test, in about 5 minutes. - Case 1 run against the HEAD script: the root took 9168 ms, so the under-7000 ms check fails before the fix. - `bin/fm-lint.sh bin/fm-lint.sh tests/fm-lint.test.sh` reported no findings. - The CI workflow is unchanged, so the Test step still runs only tests/fm-lint.test.sh with nice -n 10 and the 12 GiB ShellCheck limit
| out=$(PATH="$fakebin:$PATH" FM_LINT_JOBS=1 FM_LINT_REQUIRE_BOUNDS=1 \ | ||
| FM_LINT_ROOT_SECONDS=6 FM_LINT_ROOT_GRACE=1 \ | ||
| FM_TEST_ATTEMPT_LOG="$log" FM_TEST_FIRST_SECS=5.2 \ | ||
| "$LINT" --telemetry "$tmp/spent.tsv" "$fixture" 2>&1) || rc=$? |
There was a problem hiding this comment.
Deadline test can fail under load
The fake first attempt sleeps for 5.2 seconds under a 6-second watchdog, leaving less than 0.8 seconds for startup and scheduling delays. If those delays exceed the remaining time, the watchdog reports a timeout before the fake ShellCheck emits its memory failure. The test then fails its memory-reason and no-retry assertions even though the fallback behaves correctly, making this CI check timing-sensitive.
commented
Oct 2, 2026
|
Speaking as Kun's firstmate (oss triage, not the captain's dispatcher). Verdict: waiting-ci. Contract-class restore (my judgment): CI already promised per-root ShellCheck with Attestation: MATCH VISION: One captain one interface — aligns (CI forge mechanics). Authority explicit — aligns. Scripts vs agents — aligns (deterministic lint envelope). Restart non-event — aligns. Delegation with spine — aligns. Fleet outlives vendor — aligns. Scope — aligns (validation belongs to lint/CI, not workshop). Greptile: SUCCESS; prior P1 "Retry can outlast CI" is resolved/outdated (fallback now uses remaining deadline; under 1s left skips retry). Outstanding P2 only (deadline-test timing under load) — not a merge gate. This pass: no new workflow approvals (fork CI already running). No auto-merge until full green + CLEAN. No Firstmate flag. |
commented
Oct 2, 2026
|
Speaking as Kun's firstmate: this is merged. Thank you @tiago-peixoto — really appreciate you taking the time on this. |
Intent
Fixes #5620.
Prepare the fix for #5620: CI lint runs ShellCheck with --external-sources per root, and on current main bin/fm-teardown.sh already peaks at about 8,382,364 KB against the CI runner's 8 GiB (8,388,608 KB) per-root memory ceiling, so any change touching the libraries teardown reaches fails Lint with reason=memory rc=251 (open PRs #4893 and #5598 both cross it by about 1 MB with no ShellCheck findings). The maintainer earlier pointed to #3973's fix shape (one file at a time under a per-file timeout and memory ceiling, with a named fallback without --external-sources); #3973 was closed unmerged. A question asking which direction the maintainer prefers is open on the issue.
The issue is not yet labeled ready-for-pr, and firstmate only accepts a PR after that invitation.
What Changed
bin/fm-lint.shnow retries a root once without--external-sourcesif it fails with a memory reason while following sources. The retry runs under the same per-root timeout and address-space bounds, and it excludes only the cross-file codes that local no-source lint already skips (SC1091,SC2034,SC2153,SC2329). If the retry is clean, the root passes with a newmemory-fallbackreason and a warning line in the shard output. Retry findings or a failed retry still fail lint, and the retry's diagnostics replace those of the failed attempt.source_followed_directivescount includes only roots whose final attempt followed sources.tests/fm-lint.test.shcovers the fallback path in bounded and unbounded runs, including RSS reporting, using disposable test roots. The script header anddocs/fm-test-portable-shards.mdnow describe the fallback and its reporting.Fixes #5620.
Risk Assessment
✅ Low: The change adds one bounded retry, and only for roots already classified as memory failures (rc=251 or GHC heap exhaustion), so the existing failure modes stay intact: the retry drops only --external-sources and excludes only the four cross-file codes that local lint already excludes. Fallback findings and failed retries still fail lint, and the roots log and telemetry index mapping (1-based ROOTS order, field 12) are consistent with how both are produced and read; the tests run the real lint entry point in bounded and unbounded modes.
Testing
I ran the real bin/fm-lint.sh and the real ShellCheck 0.11.0 against bin/fm-teardown.sh under enforced per-root bounds. The baseline run reproduced the issue's footprint: about 8,381,404 KB resident with sources followed. With an 8 GiB ceiling, the source-following attempt ran out of memory (rc=251). The retry without --external-sources then passed at about 5.6 GB. Lint exited 0, printed the disclosure line, recorded reason memory-fallback in the roots log, and reported telemetry source_followed_directives=0. Three adversarial runs behaved correctly. An injected SC2086 finding still failed lint (rc=1, reason findings). A 1 GiB or 512 MiB ceiling made the retry run out of memory too, and lint failed with reason=memory rc=251. A 5-second deadline failed with reason=timeout and no retry. I did not run CI partition mode (--partition), but it uses the same per-root function. The temporary probe script and scratch files were removed. The transcripts are in the evidence directory.
Evidence: Baseline: teardown peaks ~8.38 GB RSS with sources followed
Source: Baseline: teardown peaks ~8.38 GB RSS with sources followed
Evidence: 8 GiB ceiling: memory failure, then the no-source retry passes (memory-fallback, source_followed_directives 0)
Source: 8 GiB ceiling: memory failure, then the no-source retry passes (memory-fallback, source_followed_directives 0)
fm-lint: bin/fm-teardown.sh hit the memory ceiling with --external-sources (reason=memory rc=251); retried without it; fallback passed with cross-file codes excluded (SC1091,SC2034,SC2153,SC2329) end 1 bin/fm-teardown.sh 0 full ... 0 memory-fallback 5594212 0Evidence: Retry with an injected SC2086 finding fails lint
Source: Retry with an injected SC2086 finding fails lint
Evidence: 2 GiB ceiling: the retry still passes
Source: 2 GiB ceiling: the retry still passes
Evidence: 1 GiB ceiling: the retry also runs out of memory and lint fails with memory rc=251
Source: 1 GiB ceiling: the retry also runs out of memory and lint fails with memory rc=251
Evidence: Timeout is not retried
Source: Timeout is not retried
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
FM_LINT_JOBS=1 FM_LINT_REQUIRE_BOUNDS=1 bin/fm-lint.sh --telemetry ... bin/fm-teardown.sh(baseline, default 12 GiB address-space limit)FM_LINT_ROOT_MEMORY_KIB=8388608 FM_LINT_REQUIRE_BOUNDS=1 bin/fm-lint.sh --telemetry ... bin/fm-teardown.sh(CI-sized 8 GiB ceiling)FM_LINT_ROOT_MEMORY_KIB=8388608 ... bin/fm-lint.sh bin/fm-zz-probe-finding.sh(temporary copy of teardown with an injected SC2086 finding, deleted afterwards)FM_LINT_ROOT_MEMORY_KIB=2097152 / 1048576 / 524288 ... bin/fm-lint.sh bin/fm-teardown.sh(ceilings low enough that the retry also runs out of memory)FM_LINT_ROOT_SECONDS=5 FM_LINT_REQUIRE_BOUNDS=1 bin/fm-lint.sh bin/fm-teardown.sh(timeout is not retried)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.