Skip to content

feat(bin): report underused spend-lane capacity at heartbeat review - #316

Merged
sKeLe100 merged 3 commits into
mainfrom
fm/heartbeat-underused-account-alert
Nov 23, 2026
Merged

sKeLe100 merged 3 commits into
mainfrom
fm/heartbeat-underused-account-alert

Conversation

@sKeLe100

Copy link
Copy Markdown
Owner

Intent

Session gap 2026-11-21: file every gap from this session as priority 0, PC01, within resources. At bearings and each heartbeat, compare /fleet's per-account windows with standing orders (e.g. the order to keep an account's workers filled) and act or report when capacity idles; the captain had to ask. On 2026-11-22 the same gap recurred: the fleet sat nearly idle with Claude #2 at 98% and OpenCode Go at 100% while queued work waited.

What Changed

  • Added bin/fm-underused-capacity.sh, a read-only script that combines per-lane quota windows, the pool's free slots and the queue's dispatchable count. It prints idle capacity: <lane> <pct>%, <n> free slots, <m> dispatchable, live=<k> for each lane whose five-hour window has headroom, whose weekly window is not ahead of pace, while a free slot and dispatchable work both exist. It exits 1 if a required source can't be read, so a broken read is never reported as "nothing idle". The threshold defaults to 50% and can be set through config/underused-capacity-threshold, FM_UNDERUSED_FIVE_HOUR_MIN or --threshold.
  • bin/fm-queue-snapshot.sh now emits a dispatchable: <n> line. It counts dispatchable items across the full queued set before --limit trims the rows.
  • Documented the new threshold file and script in docs/configuration.md, docs/architecture.md, AGENTS.md and the operational-home-layout skill. Added tests/fm-underused-capacity.test.sh and extended tests/fm-queue-snapshot.test.sh for the new line.

Risk Assessment

✅ Low: The fix round correctly inverted the weekly-pace filter to skip only ahead lanes, the fixtures and the threshold-precedence test now exercise the right cases, and the new script is read-only with loud failure exits.

Testing

The baseline suite passed. I ran the focused test and drove the real script on synthetic snapshots. Weekly-behind lanes were reported, the weekly-ahead lane was silenced, and an empty queue gave no output. The test's threshold-precedence case now sets FM_HOME, and the script and its test cover the corrected pace rule.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Heartbeat check reports behind-pace lanes (claude#2 83%, opencode-go 99%) with work queued and skips the ahead-of-pace lane ✅ pass live CLI output: 'idle capacity: claude#2 83%, 2 free slots, 3 dispatchable, live=0' and 'idle capacity: opencode-go 99%, ...'; claude#1 (weekly ahead) absent
No output when the queue has zero dispatchable items ✅ pass live Run with 'dispatchable: 0' printed nothing, exit 0
Threshold flag beats config file (test 6 with FM_HOME set) ✅ pass live tests/fm-underused-capacity.test.sh prints 'ok'

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed ✅
  • 🚨 bin/fm-underused-capacity.sh:238 - The weekly-window filter is inverted. quota-axi's pace.status is ahead when the lane is burning faster than the clock (a live reading shows ahead with burnMultiple 1.13 and a negative reserve), and behind when it is under-spending with positive reserve. fm-resource-snapshot.sh:734 passes that status through as pace. The script drops a lane whose weekly window reads behind, so it silences the lanes with the most unused capacity, and it reports lanes that are ahead and overspending. This defeats the intent, because the 2026-11-22 incident was OpenCode Go at 100% and Claude fix(pending-reply): force bounded remote-reply poll before escalating #2 at 98% sitting idle, and those lanes would most likely read weekly behind. The same inverted rule is restated in the header (bin/fm-underused-capacity.sh:21-26), in AGENTS.md:293 (weekly window is not behind pace) and in the test fixtures. tests/fm-underused-capacity.test.sh:51-62 and the test 1 expectation at lines 83-86 encode it: claude#1 weekly ahead is reported, while opencode-go (rolling 99%, weekly behind) and claude#2 are silenced. The tests only mirror the implementation's rule and have no independent oracle. Fix: skip the lane when the weekly pace is ahead, or drop the weekly gate. Then flip the fixtures so a lane with a weekly behind reading is reported, which is the case that would have caught the incident.
  • ℹ️ tests/fm-underused-capacity.test.sh:125 - The final --threshold 70 run in test 6 omits FM_HOME=&#34;$d&#34;, so the config file is never consulted in that run. The case passes regardless of whether the flag actually beats the config file, which is the precedence the comment says it checks. Set FM_HOME for that run, with a config value that would otherwise silence the lane, so the test can fail if the flag stopped winning.

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

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Heartbeat check reports behind-pace lanes (claude#2 83%, opencode-go 99%) with work queued and skips the ahead-of-pace lane ✅ pass live CLI output: 'idle capacity: claude#2 83%, 2 free slots, 3 dispatchable, live=0' and 'idle capacity: opencode-go 99%, ...'; claude#1 (weekly ahead) absent
No output when the queue has zero dispatchable items ✅ pass live Run with 'dispatchable: 0' printed nothing, exit 0
Threshold flag beats config file (test 6 with FM_HOME set) ✅ pass live tests/fm-underused-capacity.test.sh prints 'ok'
  • bin/fm-test-run.sh --changed --exclude-family real-herdr-gated --exclude-quarantined --pc02-if-idle
  • bash tests/fm-underused-capacity.test.sh
  • bin/fm-underused-capacity.sh run against a synthetic snapshot with free slots and dispatchable work
  • same run with zero dispatchable items
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

sKeLe100 and others added 3 commits November 22, 2026 20:58
Add bin/fm-underused-capacity.sh, a read-only deterministic comparison of
each spend lane's quota windows and live workers against the pool's free
slots and the dispatchable queue count. It prints one idle capacity line per
lane whose fresh five-hour window is at or above a configurable threshold and
whose weekly window is not behind pace, and never dispatches.

Expose the queue's full-set dispatchable count from fm-queue-snapshot.sh and
wire the report into the heartbeat review with a docs line and fixture tests
for idle, saturated, quota-tight, and empty-queue cases.
@sKeLe100
sKeLe100 merged commit 013c8f9 into main Nov 23, 2026
25 checks passed
sKeLe100 pushed a commit that referenced this pull request Nov 23, 2026
…he upstream catch-up

Fork main moved from 397c859 to 968740b while the catch-up branch was
in validation, leaving the PR in conflict with its base. This is a true
merge of origin/main into the branch, never a rebase, so the 221-commit
upstream merge and its resolution commits stay intact.

Three conflicts, each an additive same-spot insertion kept on both sides:
- .agents/skills/operational-home-layout/SKILL.md: the branch's
  ready-after-green, record-export-root and status-archive rows plus
  main's underused-capacity-threshold row (#316), in sorted order.
- bin/fm-test-run.sh: the branch's fm-capacity.sh and
  fm-lane-vitals-lib.sh mapping arms plus main's
  fm-dispatch-calibration.sh and fm-llm-usage-lib.sh arms (#318).
- tests/fm-tool-update-check.test.sh: upstream's
  test_a_failing_probe_still_reports_its_version plus main's
  test_windows_interop_copy_is_never_a_candidate (#319), both run.
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