Skip to content

ci: rebalance portable serial shards and guard runtime headroom - #4006

Closed
mremond wants to merge 11 commits into
kunchenguid:mainfrom
mremond:fm/fm-ci-shard-hints-go-stale-silently
Closed

mremond wants to merge 11 commits into
kunchenguid:mainfrom
mremond:fm/fm-ci-shard-hints-go-stale-silently

Conversation

@mremond

@mremond mremond commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

The portable serial lane was being cancelled at its 20-minute cap on roughly one pull-request run in five. The split algorithm was sound; it was fed stale numbers. Three changes, together:

  1. Refreshed the duration hints from the slowest measured duration per script across four green CI runs on 2026-09-07 and 2026-09-08 (34180535832, 34167501605, 34167485767, 34156531229). They now cover all 152 lane scripts, so serial_unhinted goes 10 to 0.
  2. Five shards to six, in the runner and the ci.yml matrix.
  3. A guard that checks estimate accuracy, not just presence - --check-shard-balance, run by tests-timing-aggregate over the timing artifacts every serial lane already uploads. It fails when a shard's measured wall time exceeds 90% of the job cap, and names the scripts furthest over their hints so the failure says what to re-measure.

Without point 3 the table goes stale silently again. That is not hypothetical: the same remedy was applied on 2026-09-01 and the lane was cancelling again 19 hours later.

Evidence

Before, the coverage guard was green while a shard ran 40% over its predicted weight:

$ bin/fm-test-run.sh --check-coverage
FM_TEST_COVERAGE ok total=189 parallel=24 serial=152 serial_shards=5 serial_unhinted=10 herdr=13   # before
FM_TEST_COVERAGE ok total=189 parallel=24 serial=152 serial_shards=6 serial_unhinted=0  herdr=13   # after

The new check fires on the stale table and passes on the refreshed one:

# stale 2026-09-01 hints, real lanes from green run 34180535832
shard balance guard failed: portable-serial-4of5 ran 19.19 min, 96.0% of the 20 min job cap (max 90%); repack the lane
  re-measure the scripts furthest over their hints:
    tests/fm-pi-branch-extension.test.sh measured 162.5s hint 22.2s (+140.3s)
    tests/fm-bearings-board.test.sh      measured  36.8s hint  4.2s  (+32.6s)
    ...

# refreshed hints, six shards
FM_TEST_SHARD_BALANCE ok shards=6 [email protected]% bound=20min

Balance from the real packer at six shards: 13.82 min of assignment weight each, 38 ms imbalance. Regrouping the four source runs' real per-script durations under that partition puts the worst shard at 13.14-13.37 min, 66-67% of the bound.

Threshold, chosen on measurement. 90% of 20 min fires at 18.00 min. At the measured lane growth of +2.1 min/day over six shards (+0.35 min/shard/day) that gives about 5.7 days of warning before a shard would actually be cancelled. The share is the suite's wall clock against the job's, so it understates by the surrounding steps' cost: measured across 30 tests-portable-serial jobs from 6 green runs, that is 15-24 s, worst case 2.0% of the bound against the 10% the threshold reserves.

The check on this PR is red, and it is not from this change

14 checks: 13 passed, 1 failed, none cancelled. The failure is Behavior portable serial 1, on tests/fm-backend.test.sh:

not ok - fm-spawn.sh should succeed for a project reached through a symlinked prefix when the backend reports physical cwd
error: could not resolve the shared Treehouse project lock ... expected exit 0, got 1

It is a genuine assertion failure, not a ceiling cut: the lane ended at 13.25 min against the 20-minute cap, where a cut lands on the bound at ~20.27 min and reports cancelled.

Two measurements establish it is not caused by this change:

  • The script passes when run alone on this branch (28 assertions, 0 failures).
  • The identical assertion fails in a real CI lane on fm/fm-captain-hold-recursive-stale-lock (0753b42b), a branch that contains none of this work and runs the old five-way packing - and it failed there in shard 5, not shard 1.

A coupling created by this repacking could not fail on a branch without the repacking. This branch also touches neither the failing test nor bin/fm-spawn.sh, where that error originates. A test that passes alone and fails in a real lane says something about running conditions rather than about the assertion; it is routed for its own investigation.

Two moves that would have produced a green badge, both declined

Adjusting the shard packing would have moved that test to different neighbours and very likely turned the check green. It was deliberately not done. If the failure is a latent condition, hiding it behind a packing choice is how it returns on a day nobody is looking, and a test that only passes next to the right neighbours is not a test we actually have.

The pipeline auto-committed a repair for it (d65ceb7e, a three-line FM_HOME/state fixture in tests/fm-backend.test.sh) and pushed it. It is deliberately reverted in d0866aa5.

Had that repair stood, it would have buried a defect already routed for its own investigation. The cost of accepting it was not untidiness in this pull request: it was the finding itself. The investigation depends on the failure still being reproducible, and a fixture that makes the symptom disappear without diagnosing it destroys exactly the evidence that investigation was opened to examine. The repair also touches a file this delivery otherwise does not, and it reversed an explicit decision not to fix that failure here. The fixture may well be diagnostically right - that belongs to the investigation, with evidence, not to a three-line drive-by inside a shard-balance change.

Status of the checks: a red mark accepted by decision, not a clean pass

Behavior portable serial 1 is red, and was accepted by explicit decision rather than fixed or hidden. The reason: the failure is pre-existing, established by the two measurements above, reproduced on an unrelated branch running the old five-way packing, and routed as its own separate investigation. Accepting it was a decision taken deliberately; this pull request should not be read as having passed its checks.

Every other check passes.

A second observation, recorded because it is a negative result

After the revert, the pipeline was run once more to produce a valid attestation for the current head. That run reached the same step, on the same branch, with the same red check that had earlier produced the unrequested auto-commit - and this time it asked instead of acting: it parked at an approval gate rather than committing a repair. Head unchanged, no commits, and a written 25-check expectation recorded before the run all still passing afterwards.

So the behaviour is situational, not deterministic. That is harder to characterise than a defect that always acts, and that difficulty is itself the finding.

What the six lanes prove

All six serial lanes ran to completion. None was cancelled - 12.31, 13.25, 13.46, 14.03, 14.33 and 15.40 min against the 20-minute cap. On a lane that had been cut at 20 minutes on about one run in five, that is the first direct evidence the split works, and it is the thing this change set out to fix.

Publication steps can remove required content, unpredictably

This description had to be restored after publication. The pipeline's PR step rewrote the body and deleted the whole description - both measurements, both declined green-badge moves, and the revert rationale - replacing it with a generated summary. It was restored by appending the step's own attestation section to the description rather than overwriting either, so both artefacts survive; the attestation's head_sha matches the validated head.

This is the third instance today across two deliveries, which makes it a property of the tooling rather than an accident of one branch. It also corrects an earlier reading: on another delivery the step removed some content and left other content intact, which looked selective. Here it removed everything. So it is not reliably selective, it varies - nobody can predict what survives a publication step.

The only safe assumption is therefore that required content must be verified present after publication, not trusted to persist through it.

Note for a later reader

The guard's final shape is deliberately minimal. A richer two-shape diagnosis was built during validation and then removed on purpose: a second pass/fail bound on hint drift, a non-failing warning share below the failure line, and a branch separating "the estimates are wrong" from "the lane has outgrown its shard count". Several defensive branches were likewise added and then removed. Both properties actually required survive in the single check - it fires before the badge goes red, and it names what to re-measure - and docs/fm-test-portable-shards.md records the decision so it is not re-derived and added back.


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.

  • Live validation: ✅ go - 5 of 6 scenarios driven live against the product
Scenario Result Live Evidence
List the refreshed partition: six nonempty, disjoint shards cover all 152 scripts and match the documented partition derived from four green runs. ✅ pass live Six-shard selection and refusals; Measured-source comparison and historical replay
Request an obsolete five-shard lane or an invalid shard index: the runner refuses instead of silently omitting work. ✅ pass live Six-shard selection and refusals
Check a freshly completed, filtered numbered shard: the guard passes, reports the 20-minute bound, and explicitly leaves five missing shards unchecked. ✅ pass live Healthy live guard
Delay an isolated shard and let it finish before cancellation: at 18.06 minutes the guard exits 1, reports 90.3% of the cap, and names the slowed script for remeasurement. ✅ pass live Delayed live guard; Fresh delayed-shard timing JSON; Live runner and controlled pause
Invoke the guard without artifacts or with a missing file: it refuses with exit code 2. ✅ pass live Missing-input refusals
Run the complete six-shard GitHub workflow and observe fresh job headroom and aggregate-guard execution. ⏸️ untested no This phase is forbidden from running the complete suite or executing CI. The outer executor must run the target through the GitHub workflow.
  • TMPDIR="$PWD/.test-phase-tmp" bash tests/fm-test-run.test.sh — passed, including fixture-based wall-time measurement checks.
  • bin/fm-test-run.sh --list-lanes, --check-coverage, and --list --lane for all six numbered shards.
  • bin/fm-test-run.sh --list --lane with portable-serial-1of5, portable-serial-7of6, and portable-serial-0of6.
  • Parsed .github/workflows/ci.yml with Ruby YAML; confirmed the six-member matrix and unchanged 20-minute cap.
  • gh-axi run view and gh-axi run download for runs 34180535832, 34167501605, 34167485767, and 34156531229.
  • python3 ~/.no-mistakes/evidence/01M20TE28ZPPZJ712ASRP3J3S9/measurements-check.py
  • python3 ~/.no-mistakes/evidence/01M20TE28ZPPZJ712ASRP3J3S9/live-guard-driver.py — healthy execution and a real 1082-second process pause, without mocked clocks or timing data.
  • Exercised missing-input CLI refusals; removed temporary worktree files and confirmed no remaining test processes, a clean worktree, and unchanged target HEAD.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

The serial shards are packed by bin-packing over a hand-maintained table of
per-script duration hints. The coverage guard bounds how much of the lane runs
on the default weight, but it never checks whether a hint that exists is still
true, so the table can go stale silently until a shard reaches its 20-minute
job cap and is cancelled. That has now happened twice, and the 2026-09-01
remedy of refreshing the hints and adding a shard held for under a day.

Three changes, together:

- Refresh the hint table from the slowest measured duration per script across
  four green CI runs on 2026-09-07 and 2026-09-08. The measurements cover the
  whole 152-script lane, so nothing runs on the default weight any more.
- Split the lane across six shards instead of five, in both the runner and the
  ci.yml matrix. Measured, the worst shard drops from 19.15 min to about
  13.4 min, 67% of the cap.
- Add bin/fm-test-run.sh --check-shard-balance, run by the tests-timing-aggregate
  job over the timing artifacts every serial lane already uploads. It fails when
  a shard's measured duration exceeds its hinted weight, naming the scripts to
  re-measure, and separately when a shard's measured duration exceeds a share of
  the job cap, which no hint refresh can fix. The two signals carry different
  remedies, and only the second survives a lane that has genuinely outgrown its
  shard count.

Against the stale table the new check fires on both signals for the shards that
were being cancelled, and it would have fired about sixteen hours before the
first cancellation after the previous rebalance while passing on that rebalance's
own run.
The guard carried four tolerances for inputs that neither the CI step nor the
documented refresh command can produce: a missing-file skip, an empty-artifact
skip, a zero-shards success return, and filtering of script entries with no
path. The shell dispatch already refuses a path that is not a file, the CI step
already warns and exits when its glob matches nothing, and numbered-lane
selection already rejects an empty shard.

Each was a promise with no reachable code path behind it, which is the defect
this change exists to eliminate. Remove them outright rather than hardening
them: a malformed artifact now fails loudly instead of being tolerated.

Partition parsing and the partial-coverage report stay, because a cancelled
shard genuinely uploads no artifact and the guard must still say how much of
the lane it could read.
@greptile-apps

greptile-apps Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (3): Last reviewed commit: "Revert "fix(ci): Fixed tests/fm-backend...." | Re-trigger Greptile

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Triage against tip main b84e0e362fac. HEAD c24c695423ff — attestation MATCH.

Contract-class: restore. Rebalances portable serial shard hints from measured durations and guards timeout headroom so the existing CI completeness contract stops cancelling overloaded serial lanes. Product defaults unchanged.

VISION.md (each rule)

  • One captain, one interface — aligns. Reliable CI evidence, not more captain noise.
  • Authority is explicit — aligns. No new autonomy grant.
  • Scripts own the mechanics — aligns. fm-test-run.sh + workflow shard packing + tests/docs.
  • A restart is a non-event — n/a/aligns. CI packaging only.
  • Delegation with a spine — aligns. No new task shape.
  • The fleet outlives any vendor — aligns. Forge CI packaging.
  • Scope — aligns. Repo discipline / forge, not widening command layer into workshop product behavior.

Blocker: Behavior portable serial 1 FAIL (run 34241076859 / job 102111087602): fm-spawn.sh should succeed for a project reached through a symlinked prefix when the backend reports physical cwd. Other serials/lint/Herdr/NM raise pass. Greptile 5/5.

Outcome: waiting-author (CI red). No auto-merge. Captain-flag: no. Security FYI: touches .github/workflows/ci.yml for shard/timeout headroom only — review clean for this pass; not a privilege-widening dump.

…_HOME/state fixture. Missing fixture state caused shared Treehouse lock resolution to fail. Reproduced before the fix; the backend suite now passes in 37 seconds. Targeted ShellCheck and git diff --check also pass
…lated FM_HOME/state fixture"

This reverts commit d65ceb7.

The pipeline's CI step committed and pushed that repair on its own. It is
reverted deliberately, for three reasons.

It buries a finding. tests/fm-backend.test.sh passes when run alone and fails
in a real CI lane, which says something about running conditions rather than
about the assertion. That was established by measurement, and the defect is
routed for its own investigation, which needs the failure to still exist.

It is outside this delivery. This branch rebalances the portable serial shards
and touches no other test; an unexplained repair to an unrelated test inside it
would leave a reviewer wondering what else drifted in.

And nobody decided it. An automatic step reversed an explicit instruction not
to fix that failure here.

The reverted fixture may well be diagnostically right. If it is, that belongs to
the investigation it was routed to, with the evidence, rather than to a
three-line drive-by inside a change about shard balance.
@mremond mremond changed the title ci: rebalance portable serial shards and guard timeout headroom ci: rebalance portable serial shards and guard runtime headroom Sep 8, 2026
@mremond

mremond commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Closing this, and explaining why rather than letting it lapse.

main now carries a competing remedy for the same problem

This request and main are two different answers to "the portable serial lane is being cancelled at its job cap". They are not two halves of one change, and they cannot both land.

The competing remedy arrived in 55d40691, merged as #4061 — a pull request whose stated purpose is fix: launch remote Herdr through the user login shell. Its shard-lane changes came from a pipeline auto-fix bullet, not from the request's own scope:

no-mistakes(ci): Raised portable serial CI timeout from 20 to 30 minutes, refreshed the specified timing hints, added missing hints, and recomputed shard documentation.

Measured against main at b1ad702f:

main this branch (d0866aa5)
shard count 5 6
job cap 30 min 20 min
hint table 146 hints, 11 unhinted 152 hints, 0 unhinted
balance guard absent --check-shard-balance

Why there is no mechanical resolution:

  1. The hint tables do not merge. They are two independent measurement sets over overlapping scripts, disagreeing on almost every shared entry. There is no textual resolution, only a choice of which measurement to keep — or a fresh one.
  2. The cap is load-bearing here. This branch pins PORTABLE_SERIAL_JOB_TIMEOUT_MINUTES=20 and deliberately fails when ci.yml disagrees, so that the cap cannot move in one place only. Against main's 30 it refuses; forcing 20 back would revert a landed decision.
  3. This branch's numbers are now stale. Its table was measured against a 152-script lane; main's lane is 156 scripts. Its headline claim that serial_unhinted reaches 0 is no longer true.

Rebasing would therefore mean re-deciding what the request delivers and re-deriving all of its evidence. That is a rewrite wearing a rebase's clothes, and nobody reviewing the result could tell which part was which. Closing is the honest outcome.

The part main does not have, and still needs

main raised the cap and refreshed the hints. Neither of those watches whether the hints stay true, and the record since shows why that matters.

The failure has already recurred under the new cap. In run 34439141091, Behavior portable serial 1 was cancelled at 30 min 15 s on 2026-09-10. The log shows no hang: the shard was still passing tests three seconds before ##[error]The operation was canceled. It ran out of a 30-minute budget doing real work. That is the third occurrence of one failure — 2026-09-01, 2026-09-08, 2026-09-10 — and the second cap raise did not end it.

The hint table on main is already wrong. docs/fm-test-portable-shards.md predicts every shard at 15.19 min with 17 ms of imbalance. Measured suite wall time from three green runs:

Run shards, fastest → slowest (min) spread
34413640474 11.14, 14.45, 15.33, 22.07, 23.09 2.07x
34439204619 12.18, 14.05, 14.55, 20.32, 21.02 1.73x
34447627189 13.24, 13.27, 13.57, 16.46, 21.93 1.66x

Across those runs, 37 hints are low by more than 2x and 11 by more than 5x (tests/fm-calm-pi-extension.test.sh is hinted at 0.3 s and measures 58.4 s). The hinted scripts total 71.9 min of assignment weight against 89.4 min measured — the table understates the lane by 24%.

--check-coverage was green through every one of those runs. It reports serial_unhinted=11, 7% against its 15% bound, and passes. It checks whether a hint is missing; it cannot check whether a hint is wrong. docs/fm-test-portable-shards.md on main states the coverage guard exists so no shard carries "more than twice another shard's real work" — the lane is at 2.07x, green.

What happens next

The genuinely additive part of this request is the balance guard, which main has no counterpart to. It reopens as its own request, scoped to that alone: no shard-count change, no cap change, and no hint table carried over from here — main's decisions on all three stand.

Its threshold is being re-derived rather than transcribed. The 90%-of-cap bound in this branch was computed against a 20-minute cap; against main's 30-minute cap the worst green shard measured above sits at 77%, so the bound as written here could never fire before a cancellation. That number is being measured again from main's own variance.

The branch is being left in place rather than deleted, so this history stays reachable.

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.

2 participants