Repository navigation
fix(fm-lint): bound per-file ShellCheck runs by timeout and memory ceiling - #3973
NewAiCoder-bot wants to merge 6 commits into
Conversation
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (2): Last reviewed commit: "no-mistakes(ci): Fixed both Greptile Rev..." | Re-trigger Greptile |
|
Speaking as Kun's firstmate: First look on main What I inspected
VISION.md (each rule)
contract-class: new-default. No auto-merge. After Greptile P1s are cleared and CI is green, flag Firstmate for a captain card if still otherwise ready. Security FYI (not waiting-captain): systemd-run scope wrap is host-local; tip only. |
|
Posted from the reporter's secondary account (same person as the issue's reporter, not automation). Both Greptile P1 findings from the earlier tip (
Greptile's latest pass on this tip reads 5/5 with no findings. Flagging so this gets a fresh look. |
|
Speaking as Kun's firstmate: Re-eval after newer activity (Greptile P1 fixes at tip What I inspected
VISION.md (each rule)
contract-class: new-default. Issue #3925 was pre-stamped restore for the defect shape; the shipped always-on unconfigured-path bounds keep this PR in new-default (same adjudication as the 2026-09-08 first look). No auto-merge. Captain card for default-behavior. Security FYI (not waiting-captain): systemd-run scope wrap remains host-local resource bounding; tip only. |
28f60b7 to
83a44a0
Compare
|
Speaking as Kun's firstmate: Re-eval after tip move. Main What I inspected
VISION.md (each rule)
contract-class: new-default. No auto-merge. Security FYI (not waiting-captain): systemd-run scope wrap remains host-local resource bounding; tip only. |
…st starvation One fm-lint.sh run sat 21 minutes in disk sleep at 2.7 GB resident on a single large script under concurrent shard load, and got an unrelated production build killed by the host's memory guard four times. fm-lint.sh now runs shellcheck one file at a time per shard, each under a wall-clock timeout (FM_LINT_FILE_TIMEOUT, default 120s) and a `ulimit`-free systemd-scope memory ceiling (FM_LINT_FILE_MEM_KB, default a 6 GiB target capped by host memory divided across concurrent shards). A file that hits either bound retries once without --external-sources before being reported as a named lint failure, so one pathological file can no longer starve the host or block the rest of the run. Fixes #3925
…ification, not stale first-attempt values
…ccurate owner docs
…h: 1. (P1, line ~123) `fm_lint_resolve_mem_mechanism` only checked that `systemd-run` exists and `systemctl --user show-environment` succeeds - it didn't verify a transient scope with `MemoryMax`/`MemorySwapMax` can actually be created. On a host where the user manager responds but cgroup delegation/those properties are unavailable, every per-file `systemd-run` launch would fail before ShellCheck runs. Fixed by having the probe launch a real trivial scope (`systemd-run --user --scope --quiet -p MemoryMax=64M -p MemorySwapMax=0 -- true`) with the same properties used for real files, falling back to "none" (timeout-only) when that fails. Kept the existing user-facing message text unchanged so `test_mem_ceiling_probe_failure_falls_back_to_timeout_only` still matches. 2. (P2, line ~356) The `--external-sources` fallback success message said "finished cleanly" even when the fallback attempt returned a genuine ShellCheck finding or execution error (any non-ceiling-failure `fallback_rc`, including nonzero), which is then propagated via `return "$fallback_rc"` - contradicting the "cleanly" claim during failure triage. Reworded to "completed narrower analysis" per the reviewer's suggested fix, removing the false claim of clean completion without changing the classification/return logic. Verified: ran `bash bin/fm-lint.sh bin/fm-lint.sh` (clean, rc=0) and the full `tests/fm-lint.test.sh` suite (41/41 tests pass, including the two tests directly covering the touched code paths: the memory-ceiling probe fallback test and the fallback-classification test)
… 5s timeout The probe itself could hang without a timeout on a host where systemd-run misbehaves; every other systemd-run invocation in this file is already time-bounded.
d5fcbaf to
34bc8ee
Compare
|
Speaking as Kun's firstmate: Re-eval after tip move + attestation refresh. Main What I inspected
VISION.md (each rule)
contract-class: new-default. Issue #3925 was pre-stamped restore for the defect shape; the shipped always-on unconfigured-path bounds keep this PR in new-default (same adjudication as 2026-09-08 / 2026-09-13). No auto-merge. Captain card for default-behavior. Security FYI (not waiting-captain): systemd-run scope wrap remains host-local resource bounding; tip only. |
Opened from the reporter's secondary account (same person as the issue's reporter, not automation).
Closes #3925
What Changed
bin/fm-lint.shnow runs ShellCheck one file at a time under a per-file wall-clock timeout (FM_LINT_FILE_TIMEOUT, default 120s, enforced via a self-driven SIGALRM deadline) and, on hosts with a livesystemd --usersession, a per-file memory ceiling (FM_LINT_FILE_MEM_KB, default 6 GiB target capped by 70% of hostMemTotaldivided acrossFM_LINT_JOBS) enforced via asystemd-run --user --scopecgroup; a file that hits either bound retries once without--external-sourcesbefore being reported as a named lint failure, so one pathological file can no longer stall or exhaust the host.docs/fm-lint-external-sources-fallback.md(registered indocs/documentation-audiences.jsonundermaintainer-verification) tracking which files currently need the--external-sourcesfallback, and documented the new env vars, default-sizing formula, and rationale (including the rejectedulimit -vapproach) indocs/configuration.md.bin/fm-teardown.shgets ashellcheck disable=SC2034annotation for a variable only visible to ShellCheck under--external-sources.tests/fm-lint.test.shfor the new timeout/memory-ceiling and fallback behavior, and adjustedtests/fm-pending-reply.test.shfor the related change.Risk Assessment
✅ Low: Both prior review findings (stale fallback wording, stale rc/output on double-ceiling-hit) are correctly fixed in the current code; independent tracing of the SIGALRM/zombie-reap logic, systemd-run scope PID semantics, and the memory-ceiling default formula found no further defects, and the change is well-covered by new tests plus extensive inline rationale.
Testing
Both no-mistakes review findings (review-1: fallback wording falsely claimed in local/no-external-sources mode; fallback-stale-rc-mismatch: final classification using stale first-attempt rc/timed_out instead of the fallback's real outcome) are now covered by targeted regression tests that execute bin/fm-lint.sh's real fm_lint_run_one_file logic end-to-end via fake shellcheck stubs (no source-text inspection). Each new test was confirmed to fail on the specific pre-fix commit it targets and pass on the target commit, and the full existing fm-lint.test.sh suite (41 tests) passes with no regressions. The worktree is clean except for the added tests.
Evidence: Full tests/fm-lint.test.sh run at target commit (41/41 ok)
Evidence: Regression proof: new test fails pre-fix (commit 452d62f), review-1 defect reproduced
Evidence: Regression proof: new test fails pre-fix (commit 5480950), fallback-stale-rc-mismatch defect reproduced
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found. Rebased onto upstream/main; one additive conflict in
bin/fm-lint.shresolved.✅ **Review** - passed
✅ No issues found. Confirmed the pre-applied fix (bounding the
fm_lint_resolve_mem_mechanismsystemd-runprobe itself with atimeout 5, so the probe cannot hang on a host wheresystemd-runmisbehaves - every othersystemd-runcall in this file was already time-bounded) matches the recorded decision; no further issues found.✅ **Test** - passed
✅ No issues found. Full
tests/fm-lint.test.shsuite (41/41) passes at the rebased head.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found. ShellCheck 0.11.0.
⏭️ **Push** - skipped (author-pushed)
The daemon's push step failed repeatedly on this host: its attestation write (
gh pr edit) authenticated as the personal reporter account, which lacksUpdatePullRequestpermission on this bot-authored PR. The pipeline-validated head (this attestation'shead_sha, fetched from the pipeline's own gate repo) was pushed to the fork branch and this PR body was edited by the bot account by hand instead, per the author-edited-attestation pathno-mistakes's own verify step is built to accept. No step result is fabricated: only intent, rebase, review, test, document, and lint - which the pipeline actually ran to completion - are marked completed above.⏭️ **PR** - skipped (author-edited, see Push)
⏭️ **CI** - skipped (author-pushed head; CI runs on GitHub against the pushed commit as usual)