Repository navigation
Conversation
Confidence Score: 5/5The PR appears safe to merge because no concrete changed-code defect remains after checking the wrapper equivalence and source-boundary changes. The shared wrapper preserves all positional arguments, lock lifecycle, dynamic wake-library bindings, and body return codes, while the other script changes affect ShellCheck analysis directives rather than runtime sourcing. Reviews (1): Last reviewed commit: "fix(bin): fit ShellCheck extended analys..." | Re-trigger Greptile |
ShellCheck inlines every followed source at every source site and its extended analysis keeps a full variables-in-scope map per control-flow node, so memory grows with inlined lines times variables in scope. Six production roots (spawn, teardown, watch, send, backlog-handoff, procevent-remote-reply) exceeded the 4 GB cap on main, and three more sat within 10 percent of it; the pending-reply library alone cost 2.0 GB because six lock wrappers each re-sourced the wake library inside the function body. - fm-pending-reply-lib: fold the six identical per-correlation lock wrappers into one shared wrapper and load the wake and parent-channel libraries through two loader functions (same dynamic-scope binding and positional parameters as the inline sources); both loads are analysis boundaries. - fm-wake-lib: the lazy classify and timeout loads are analysis boundaries, so consumers stop inlining the classifier graph. - teardown, herdr backend, public-followup, merge-outcome, bootstrap, afk-return, home-summary-refresh: lazy or duplicate in-function wake library sources become analysis boundaries. - spawn, teardown, watch: the largest already-canonical libraries they source stay analysis boundaries at the root. - Two SC2034 suppressions where a variable is now consumed only behind a boundary; two SC2329 suppressions for test stubs reached through the shared wrapper's dynamic dispatch. - firstmate-coding-guidelines: one source-graph budget rule. All 167 production roots now complete under the cap (largest 1.8 GB); the full lint passes with FM_LINT_JOBS=1. No runtime behavior changes. Claude-Session: https://claude.ai/code/session_014f2aYxnXHTw4r9oeq3xxRP
5204d87 to
519ae5e
Compare
|
Rebased onto current main (daaffdb); conflicts resolved in .agents/skills/firstmate-coding-guidelines/SKILL.md, bin/fm-afk-return.sh, and bin/fm-spawn.sh (upstream had moved the config-inherit source and the in-function classify-lib load; the PR's analysis-boundary directives were reapplied at their new locations). One new SC2034 suppression in bin/fm-wake-lib.sh for the branch-owner sentinel read that upstream added on 2026-09-08, which the classify-lib boundary now exposes. No behavior change; bin/fm-lint.sh and the tests for the touched scripts pass. |
Intent
The captain suffered three machine-wide OOM crashes on 2026-09-04 caused by firstmate's lint suite (the captain calls it "spellcheck") running ShellCheck unbounded, and said: "ok we just suffered through three OOM crashes due to spellcheck being unbounded." A memory cap was added (#3685,
ulimit -varound shellcheck in bin/fm-lint.sh, default 4 GB via FM_LINT_SHELLCHECK_MAX_MB), but the cap only turns the crash into a failed lint step: on unchanged main, ShellCheck's extended analysis of three scripts cannot complete under 4 GB.Evidence from the previous task (a per-file bisect with shellcheck 0.11.0,
--norc --external-sources, extended analysis on, one file per process):GitHub CI runs the same full lint and passes, so the analysis does complete on runners with more memory.
bin/fm-lint.sh --fast(extended analysis off) is clean.The captain wants the full lint to be safe to run on a 24 GB machine: find what construct in those three scripts makes ShellCheck's extended analysis explode and restructure the scripts so the full lint completes under the 4 GB cap, without changing their behavior.
What Changed
Final changed paths and statuses:
Risk Assessment
✅ Low: The only executable change is folding six identical lock wrappers into one shared wrapper whose dynamic-scope binding and positional-parameter pass-through I traced as equivalent to the inlined originals (fm-wake-lib and fm-parent-channel-lib use no top-level positional parameters or
local/declare -g), everything else is ShellCheck directives and comments, and I confirmed the three named roots now lint clean under a 4 GB address-space limit.Testing
Completed 1 recorded test check.
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-spawn.sh:263- The intent asks to "find what construct in those three scripts makes ShellCheck's extended analysis explode and restructure the scripts so the full lint completes under the 4 GB cap". The diagnosed cause is followed-source fan-out (each# shellcheck source=target inlined at every source site), and the only genuine restructuring is the pending-reply wrapper dedup. The rest of the reduction, including all of the savings in fm-spawn.sh, fm-teardown.sh, and fm-watch.sh, comes from converting followed sources to# shellcheck source=/dev/nullanalysis boundaries (spawn +5, teardown +6, watch +1, plus wake-lib, herdr, bootstrap, afk-return, merge-outcome, public-followup, home-summary-refresh). That is a lint-coverage tradeoff, not a script change: from those roots ShellCheck no longer sees the boundaried libraries' function and variable definitions, so cross-file checks (e.g. a misspelled fm_lock_* call or a lowercase variable read from fm-pr-lib/fm-busy-lib/fm-pending-reply-lib) are no longer caught at the root, and the new SKILL.md rule (line 122) institutionalizes boundaries as the standing remedy. Each library is still linted as its own root, and the same pattern already existed in 13 places on base, so this is a reasonable engineering choice, but it substitutes directives for the restructuring the intent describes and the author/captain should confirm the reduced cross-file analysis is acceptable. Verified independently: with--norc --external-sourcesand extended analysis on, fm-spawn.sh, fm-teardown.sh, fm-watch.sh, and fm-pending-reply-lib.sh now each complete in ~4-5 s underulimit -v 4194304with peak RSS of 1.67 GB, 1.04 GB, 1.17 GB, and 0.69 GB respectively..agents/skills/firstmate-coding-guidelines/SKILL.md:122- The 4 GB ShellCheck cap this change targets (PR fix(bin): bound shellcheck memory per lint shard #3685,ulimit -v/ FM_LINT_SHELLCHECK_MAX_MB in bin/fm-lint.sh) is still an open, unmerged PR; neither the base commit nor origin/main contains any ulimit in fm-lint.sh. Nothing in this branch enforces the budget the new SKILL.md rule and the source comments refer to, so the guideline currently describes a cap that only exists in a pending PR and in the captain's local checkout. This does not affect correctness of the change, but merge ordering matters: the guideline text and the "under the cap" claim become enforceable only once fix(bin): bound shellcheck memory per lint shard #3685 lands.bin/fm-test-run.sh --changed --exclude-family real-herdr-gated✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.