Skip to content

ci: split lint and serial test shards finer to cut CI wall time - #7

Merged
ICBreakerLA merged 6 commits into
mainfrom
fm/fm-fork-ci-5min
Oct 6, 2026
Merged

ICBreakerLA merged 6 commits into
mainfrom
fm/fm-fork-ci-5min

Conversation

@ICBreakerLA

@ICBreakerLA ICBreakerLA commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Intent

Cut the wall time of a typical PR on the ICBreakerLA/firstmate fork (push to all checks green) toward 5 minutes, from 15-31 minutes today, without weakening, skipping, deleting or waiving any check or test: finer serial sharding (12 shards, long independent suites split by test call), 8 lint partitions, parallel lanes at their proven --jobs 4

What Changed

  • bin/fm-lint.sh: generalized --partition from a fixed 1of2/2of2 to KofN (N from 2 to 8) with N-way weighted bin packing, and .github/workflows/ci.yml now runs 8 lint partitions instead of 2.
  • bin/fm-test-run.sh: raised PORTABLE_SERIAL_SHARDS from 9 to 12, added portable_serial_split_hints/--list-split-hints to split 10 long, independent serial suites into slices that run via the new tests/fm-test-slice-gate.sh (loaded through BASH_ENV, dispatching every n-th top-level test_* call), and extended run_coverage_guard to require every slice of every split script to run exactly once (failing a slice that ran no calls).
  • .github/workflows/ci.yml now passes --jobs 4 to the two portable-parallel lanes; CONTRIBUTING.md and docs/fm-test-portable-shards.md are updated to list the new required check contexts (Lint 1-Lint 8, Behavior portable serial 1-12) and document the slice-splitting mechanism and job layout.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The change is a well-bounded CI/tooling change (finer serial sharding via a DEBUG-trap based call-slicer, 8 lint partitions, --jobs 4 on already-proven-isolated parallel lanes) with generalized, backward-compatible packing math, a coverage guard extended correctly to the new slice unit, and new tests that exercise real execution paths rather than source-text matching; the only findings are two pieces of dead/redundant code left over from the refactor.

Testing

Directly exercised bin/fm-lint.sh and bin/fm-test-run.sh as real CLI tools. The new 8-way lint partitioning is complete/disjoint over 471 canonical files with zero duplicates, and every malformed --partition value is correctly refused. bin/fm-test-run.sh now lists 12 portable-serial-of12 lanes, --list-split-hints reports the 10 scripts slated for slicing matching the diff, and --check-coverage (which validates exact-once slice/script coverage across all 12 shards under budget) passed cleanly. Most decisively, I ran all 8 slices of the real, longest suite in the repo (tests/fm-watch-triage.test.sh, deliberately split 8 ways because it is the long pole) end-to-end through the actual slice gate and confirmed its 141 top-level test_ calls each ran in exactly one slice — no duplicates, no omissions. The pre-existing tests/fm-test-run.test.sh contract suite ran 39 of its tests with no failures (including the new slice-gate and --jobs-scheduler tests) before hitting one unrelated pre-existing test that requires a ruby binary this sandbox doesn't have; that test is not part of this diff and is about Herdr CI job step timeouts, not sharding. tests/fm-lint.test.sh similarly could not run its real-ShellCheck-execution assertions because shellcheck/actionlint are absent here with no network access to install them via the repo's own pinned installer scripts. Both gaps are sandbox tool-availability limitations, not product defects, and neither touches the partitioning/sharding logic this change actually alters, which was proven correct by direct, live execution above.

  • Live validation: ✅ go - 7 of 9 scenarios driven live against the product
Scenario Result Live Evidence
8-way lint partitioning is complete and disjoint over the canonical inventory ✅ pass live CI=true bin/fm-lint.sh --partition {1..8}of8 --list-files, 471 files total, 0 duplicates, union exactly equals CI=true bin/fm-lint.sh --list-files
Lint --partition input validation rejects malformed/out-of-range K-of-N values (adversarial) ✅ pass live 0of2, 3of2, 1of1, 1of9, 9of8, '1of', '2', '1of2.5' all exit 2 with a clear message naming the problem
Serial remainder is packed into exactly 12 independently-selectable shard lanes with no lost/duplicated script or slice ✅ pass live bin/fm-test-run.sh --list-lanes shows portable-serial-1of12..12of12; bin/fm-test-run.sh --check-coverage exits 0 with serial_shards=12 and serial_max_ms=773627 <= serial_budget_ms=1200000
--list-split-hints exposes the long-suite split table added for finer sharding ✅ pass live bin/fm-test-run.sh --list-split-hints output matches the 10 scripts and slice counts introduced in the diff, including tests/fm-watch-triage.test.sh 8
All 8 slices of the real, longest suite in the repo (fm-watch-triage.test.sh) together run every test_* call exactly once with zero duplicates or omissions ✅ pass live Full live run of slices 1of8..8of8 through BASH_ENV=tests/fm-test-slice-gate.sh: 141 total 'ran' decisions, 141 unique test_* names, zero duplicates, all 8 slices exit 0
The repo's own slice-gate and split-coverage contract tests pass live against the changed runner ✅ pass live bash tests/fm-test-run.test.sh printed 'ok - slice gate runs every call exactly once and stays inert elsewhere' and 'ok - every split script has a test call for every slice'
--jobs 4 parallel scheduling (new ci.yml flag) is accepted and exercised by the runner's own scheduler contract tests ✅ pass live bash tests/fm-test-run.test.sh printed 'ok - --jobs refuses non-proven / stateful selections', 'ok - --jobs admits and schedules a family with a recorded concurrent proof', and 'ok - jobs scheduler ru…
Full ShellCheck + actionlint execution of a lint partition finds the same issues as before (lint behavior itself unchanged) ⏸️ untested no Missing tools (shellcheck 0.11.0, actionlint 1.7.12) and no network access in this sandbox to fetch them via the repo's own pinned installers; would need either the binaries pre-installed or network e…
tests/fm-test-run.test.sh::test_herdr_ci_family_run_has_a_step_timeout (pre-existing, unrelated to this diff) passes live ⏸️ untested no This sandbox has no ruby binary and no network access to install one; this is a pre-existing test unrelated to the lint-partition/serial-shard/--jobs changes under review, so it does not bear on this…
Evidence: 8-way lint partition union check (471 files, 0 dup, match)
RESULT: MATCH - 8-way partition is complete and disjoint
fail=0
dupcount=0
471 files each side
Evidence: Invalid --partition rejections
0of2, 3of2, 1of1, 1of9, 9of8, '1of', '2', '1of2.5' all exit 2 with a clear diagnostic
Evidence: 12 portable-serial lanes + coverage guard pass
portable-serial-1of12 .. portable-serial-12of12
FM_TEST_COVERAGE ok total=254 parallel=24 parallel_max_ms=665545 parallel_imbalance_ms=2 parallel_unhinted=0 serial=214 serial_shards=12 serial_unhinted=13 serial_max_ms=773627 serial_budget_ms=1200000 herdr=16
Evidence: --list-split-hints output
tests/fm-backlog-atomicity.test.sh 2
tests/fm-bearings-snapshot.test.sh 2
tests/fm-pr-check-security.test.sh 3
tests/fm-public-followup.test.sh 4
tests/fm-secondmate-harness.test.sh 2
tests/fm-session-start.test.sh 3
tests/fm-spawn-dispatch-profile.test.sh 2
tests/fm-supervision-host.test.sh 6
tests/fm-teardown.test.sh 2
tests/fm-watch-triage.test.sh 8
Evidence: All 8 live slices of the real fm-watch-triage.test.sh suite: exactly-once coverage of 141 test_* calls
slice 1 rc=0 ran=18 skipped=123
slice 2 rc=0 ran=18 skipped=123
slice 3 rc=0 ran=18 skipped=123
slice 4 rc=0 ran=18 skipped=123
slice 5 rc=0 ran=18 skipped=123
slice 6 rc=0 ran=17 skipped=124
slice 7 rc=0 ran=17 skipped=124
slice 8 rc=0 ran=17 skipped=124
total ran across slices: 141
unique calls covered: 141
duplicate calls: none
Evidence: fm-test-run.test.sh live run, 39 passing checks before an unrelated ruby-gated test
ok - slice gate runs every call exactly once and stays inert elsewhere
ok - every split script has a test call for every slice
ok - portable serial shard lanes refuse mismatched, out-of-range, and countless names
ok - --jobs refuses non-proven / stateful selections
ok - --jobs admits and schedules a family with a recorded concurrent proof
ok - jobs scheduler runs proven scripts; failure propagates; non-proven refused
not ok - ruby is required to parse .github/workflows/ci.yml as YAML
- Outcome: ⚠️ 1 info across 1 run (21m11s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos
  • ℹ️ bin/fm-test-run.sh:906 - portable_serial_lane_weight() is now dead code: its only call site (previously in run_coverage_guard) was replaced by portable_serial_assignments | awk ... in this same diff, and no other caller remains (verified by grep across bin/ and tests/). Safe to delete since nothing references it.
  • ℹ️ bin/fm-test-run.sh:1178 - The uniq -d/serial_shard_dups duplicate check that runs after the new cmp -s &#34;$tmp/serial_units_raw&#34; &#34;$tmp/serial_units_expected&#34; check is now unreachable in practice: the preceding cmp already fails on any multiset mismatch between actual and expected per-slice units (a duplicate unit paired with sorted-line comparison against the unique expected set cannot pass cmp while also containing a dup, since dup+missing would shift content at the first differing sorted position). The block can be removed as redundant.
⚠️ **Test** - 1 info
  • ℹ️ This sandbox has no shellcheck, actionlint, or ruby binary on PATH and no network access to fetch them via the repo's own pinned installer scripts, so real lint-execution evidence and one unrelated pre-existing contract test could not be produced. This is an environment limitation, not a defect introduced by this diff; the sharding/partitioning logic the diff actually changes was proven correct by direct live execution.
  • Live validation: ✅ go - 7 of 9 scenarios driven live against the product
Scenario Result Live Evidence
8-way lint partitioning is complete and disjoint over the canonical inventory ✅ pass live CI=true bin/fm-lint.sh --partition {1..8}of8 --list-files, 471 files total, 0 duplicates, union exactly equals CI=true bin/fm-lint.sh --list-files
Lint --partition input validation rejects malformed/out-of-range K-of-N values (adversarial) ✅ pass live 0of2, 3of2, 1of1, 1of9, 9of8, '1of', '2', '1of2.5' all exit 2 with a clear message naming the problem
Serial remainder is packed into exactly 12 independently-selectable shard lanes with no lost/duplicated script or slice ✅ pass live bin/fm-test-run.sh --list-lanes shows portable-serial-1of12..12of12; bin/fm-test-run.sh --check-coverage exits 0 with serial_shards=12 and serial_max_ms=773627 <= serial_budget_ms=1200000
--list-split-hints exposes the long-suite split table added for finer sharding ✅ pass live bin/fm-test-run.sh --list-split-hints output matches the 10 scripts and slice counts introduced in the diff, including tests/fm-watch-triage.test.sh 8
All 8 slices of the real, longest suite in the repo (fm-watch-triage.test.sh) together run every test_* call exactly once with zero duplicates or omissions ✅ pass live Full live run of slices 1of8..8of8 through BASH_ENV=tests/fm-test-slice-gate.sh: 141 total 'ran' decisions, 141 unique test_* names, zero duplicates, all 8 slices exit 0
The repo's own slice-gate and split-coverage contract tests pass live against the changed runner ✅ pass live bash tests/fm-test-run.test.sh printed 'ok - slice gate runs every call exactly once and stays inert elsewhere' and 'ok - every split script has a test call for every slice'
--jobs 4 parallel scheduling (new ci.yml flag) is accepted and exercised by the runner's own scheduler contract tests ✅ pass live bash tests/fm-test-run.test.sh printed 'ok - --jobs refuses non-proven / stateful selections', 'ok - --jobs admits and schedules a family with a recorded concurrent proof', and 'ok - jobs scheduler ru…
Full ShellCheck + actionlint execution of a lint partition finds the same issues as before (lint behavior itself unchanged) ⏸️ untested no Missing tools (shellcheck 0.11.0, actionlint 1.7.12) and no network access in this sandbox to fetch them via the repo's own pinned installers; would need either the binaries pre-installed or network e…
tests/fm-test-run.test.sh::test_herdr_ci_family_run_has_a_step_timeout (pre-existing, unrelated to this diff) passes live ⏸️ untested no This sandbox has no ruby binary and no network access to install one; this is a pre-existing test unrelated to the lint-partition/serial-shard/--jobs changes under review, so it does not bear on this…
  • CI=true bin/fm-lint.sh --partition {1..8}of8 --list-files union-checked against CI=true bin/fm-lint.sh --list-files
  • bin/fm-lint.sh --partition <invalid> --list-files for 0of2, 3of2, 1of1, 1of9, 9of8, 1of, 2, 1of2.5
  • bin/fm-test-run.sh --list-lanes | grep portable-serial
  • bin/fm-test-run.sh --check-coverage
  • bin/fm-test-run.sh --list-split-hints
  • full live slice-gate run of all 8 slices of tests/fm-watch-triage.test.sh via BASH_ENV=tests/fm-test-slice-gate.sh, checked for exactly-once coverage of every test_* call
  • bash tests/fm-test-run.test.sh (ran to its first failure, which was an unrelated pre-existing test blocked by a missing ruby binary)
  • bash tests/fm-lint.test.sh (blocked early by missing shellcheck/actionlint)
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → auto-fixed ✅
  • ⚠️ linter found issues (exit code 1)

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

✅ **Push** - passed

✅ No issues found.

…rallel lanes 4-wide

The serial lane's longest shard carried 30 minutes of one-runner work and was
cancelled at its cap. Slice the independent test_* calls of ten long suites
across twelve shards, partition lint eight ways, and run the proven-isolated
parallel lanes at their proven --jobs 4. No test, check, or threshold is
removed or loosened.
…un.sh:907 (`portable_serial_lane_weight()`) was dead code — its only call site had been replaced by `portable_serial_assignments | awk ...` earlier in the same diff, and ShellCheck's SC2329 ("function is never invoked") correctly flags it, which fails the lint step by default severity. Confirmed by reproducing locally: `FM_LINT_JOBS=1 bin/fm-lint.sh --partition 4of8` reported `bin/fm-test-run.sh ... reason=findings rc=1` with the SC2329 hit before the fix, and exits clean (rc=0, no SC2329) after deleting the unused function. Grepped the whole tree to confirm nothing else calls it, so removal (not suppression) is correct per the removal-first rule. This was the only genuine lint finding in the diff; a second PR-noted dead-code item (an unreachable `uniq -d` duplicate check inside `run_coverage_guard`, PR body line ~130) is real but belongs to the separate "Test coverage guard" job, which is not among the failing checks, is not flagged by any tool, and is out of scope for this round's two selected findings — left untouched. For "Behavior portable serial 7" I could not confirm a code-caused defect. I verified the new 12-shard/slice mechanism directly: `bin/fm-test-run.sh --check-coverage` passes cleanly (exact-once coverage, no dup/missing units across all 12 shards), the full `tests/fm-test-run.test.sh` self-test suite passes every case about the new slicing/packing logic ("slice gate runs every call exactly once...", "portable serial shards are a deterministic disjoint cover...", etc.), and a direct manual run of slice 1of8 of the longest split script (tests/fm-watch-triage.test.sh) dispatched exactly 18 of its 141 top-level test_* calls (the expected ~1/8), confirming the slice gate works correctly. Running the actual portable-serial-7of12 lane locally produced only 4 script failures, and each traces unambiguously to this sandbox's missing tooling rather than to the change: no tmux binary (blocks the afk/tmux-dependent fm-supervision-host assertions), no tasks-axi binary and a blocked npm registry (`fail "tasks-axi is required for ..."` in fm-bearings-snapshot and fm-teardown-sandbox), and blocked outbound network (curl 403 fetching a pinned GitHub Action verifier in fm-no-mistakes-required, a pre-existing test untouched by this PR). I could not fetch the actual GitHub Actions job log for shard 7 either — the Actions log-blob endpoint returned 403/"approval required" in this sandbox, matching the task's own "log retrieval incomplete" note. Per the task rules, since every concrete signal I could obtain points at sandbox-only tooling/network gaps rather than the PR's sharding/slicing code (which I verified behaves correctly), I did not invent a speculative fix for this check
…hot.test.sh that broke "Behavior portable serial 7". Rule that was broken: each test must start from a clean remote-ledger fixture, whatever tests ran before it. Cause: call #5 (test_remote_ledgers_share_one_concurrent_budget_and_fall_back_to_cache) leaves $TMP_ROOT/remote-ledger-home-1/state/slow-ledger-read behind, and only call #6 removes it. Slice 1of2 runs #5 but skips #6, so in call #25 (test_landed_preserves_kindless_v1_summary_reports) the fake ssh sleeps 30s against the 15s budget and collection times out. Fix: one line in make_remote_ledger_fleet (line 258), the single place every test builds these homes. After mkdir -p "$remote_home/state" it runs rm -f on slow-ledger-read, unbounded-ledger-read and home-summary.json; write_remote_home_summary then rewrites the summary. All other uses of these marker files are per-test create/remove pairs. The 15s budget and all assertions are unchanged. Verification: (1) a copy of the script calling only #5 then #25 (slice 1of2 order) fails without the line ("structured home ledger collection timed out and no valid cached copy is available") and passes with it; the copy and the leftover untracked tests/_verify-fix.test.sh were deleted. (2) bin/fm-lint.sh exits 0 (ShellCheck 0.11.0, actionlint 1.7.12). A direct shellcheck run shows one SC2034 at line 271 that predates this fix and is not flagged by the project lint. (3) bin/fm-test-run.sh --lane portable-serial-7of12 still exits 1 locally with 4 failures, each from sandbox gaps (no tmux, no tasks-axi, curl 403 fetching the pinned action verifier). The remote-ledger tests in it pass, but the bearings script stops at the tasks-axi requirement before call #25, so only check (1) exercises #25. Nothing was committed
@ICBreakerLA
ICBreakerLA merged commit bef03e7 into main Oct 6, 2026
28 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.

1 participant