Skip to content

feat(bin): report open lanes and host headroom for queued-work dispatch - #5472

Closed
Moshik21 wants to merge 3 commits into
kunchenguid:mainfrom
Moshik21:fm/fm-capacity-check
Closed

Moshik21 wants to merge 3 commits into
kunchenguid:mainfrom
Moshik21:fm/fm-capacity-check

Conversation

@Moshik21

Copy link
Copy Markdown
Contributor

Summary

Firstmate re-evaluates queued work after every teardown and heartbeat, but nothing reports how much room the machine has for more lanes.
This adds bin/fm-capacity.sh, a read-only, fast, network-free report firstmate can consult at that re-evaluation to notice open lanes and fill them with ready backlog work.

  • Counts this home's running lanes from state/*.meta (ship and scout work); persistent secondmates are reported separately and hold no lane.
  • Reads an optional config/lane-capacity target (one non-negative integer). Absent means counts only - the script never invents a target. A malformed value reports reason=invalid-target and exits 1 instead of guessing.
  • Probes 1-minute load vs logical cores, free-memory percentage, and free disk on the filesystem holding FM_HOME. Darwin reads sysctl; other systems read /proc/loadavg and /proc/meminfo; cores come from getconf with a sysctl fallback; disk from df -Pk. Any unavailable probe prints unknown and its constraint is skipped.
  • With a target, free_lanes = max(target - lanes, 0), forced to 0 when the host is constrained (load >= cores, memory free < 10%, disk free < 5120 MB), with reason naming each constraint.

Example output:

capacity: free_lanes=3 reason=ok lanes=2 target=5 secondmates=1 load1=0.50 cores=8 mem_free_pct=60 disk_free_mb=20480
Lanes: 2 running of 5 target, 3 open.
Secondmates: 1 (hold no lane).
Host: load 0.50 on 8 cores, memory free 60%, disk free 20480 MB.

Docs: config/lane-capacity is documented in docs/configuration.md ("Lane capacity"); AGENTS.md section 10 gains one pointer line at the queued-work re-evaluation rule. The script header owns the output contract, thresholds, and probe fallbacks. Supervision behaviour is otherwise unchanged.

Testing

  • bin/fm-test-run.sh tests/fm-capacity.test.sh tests/fm-documentation-audiences.test.sh - pass. The new test drives faked probes on PATH through the public command: no target, open/full/over-target, each host constraint plus just-inside-threshold values, unavailable probes, malformed target, and a real-host smoke.
  • bin/fm-lint.sh and shellcheck (pinned 0.11.0) on both new scripts - clean.
  • bin/fm-doc-audience-check.sh - ok.
  • bin/fm-test-run.sh --check-coverage - ok (new test lands in the serial lane as unclassified).

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: triage complete — waiting-author.

Contract-class (own tip-vs-main): opt-in. New bin/fm-capacity.sh is consult-only (read-only, network-free); meaningful free_lanes requires optional local config/lane-capacity. Absent that file the script prints counts only and never invents a target (free_lanes=unknown reason=no-target). No spawn/teardown/dispatch script calls it. AGENTS.md section 10 gains one pointer line at the existing queued-work re-evaluation rule; unconfigured mechanical consumer paths are otherwise unchanged.

VISION (per-rule):

  • One captain / interface: aligns — capacity is below-deck fleet mechanics for the captain's peace of mind when looking away; no new captain-facing surface.
  • Authority: aligns — target is captain-owned local config; script refuses to guess a malformed/absent target.
  • Scripts own mechanics: aligns — probes, lane counts, and thresholds live in the script header; agents may consult the report, not invent host math.
  • Restart / durability: aligns — report is ephemeral; config/lane-capacity is the durable opt-in fact.
  • Delegation: aligns — does not invent a new task shape; composes with existing queued-work re-evaluation.
  • Fleet outlives vendor: aligns — Darwin/sysctl and /proc probes with unknown degradation; no vendor harness coupling.
  • Scope: aligns — command-layer capacity report, not workshop validation; AGENTS.md stays under the ceiling with one pointer line.

Attestation: MISSING — PR body has no no-mistakes-pipeline-attestation (or other bound HEAD SHA). HEAD 5e94b6f49ab312e01498ab69c1ac0ce24e19969f. Re-raise via no-mistakes so attestation MATCHES this tip before merge can be considered.

Checks: workflow-zero (no .github/workflows/*). First-time fork CI approved this pass: runs 35928841994 (CI) and 35928841972 (Require no-mistakes) — both were action_required, now queued. Mergeability MERGEABLE/UNSTABLE pending green.

Closes-issue: none claimed/verified.

Please bind attestation to the current HEAD (or push a tip that matches a fresh raise). I am Kun's firstmate (automated triage for firstmate-oss).

Add bin/fm-capacity.sh, a read-only, network-free report of this home's
running lanes against an optional config/lane-capacity target, plus
1-minute load versus logical cores, free memory, and free disk. The first
output line is machine-readable (free_lanes=N reason=...), followed by a
human summary. Probes degrade to unknown when unavailable on a platform.

Document config/lane-capacity in docs/configuration.md and point the
backlog re-evaluation rule in AGENTS.md at the new report.
@Moshik21
Moshik21 force-pushed the fm/fm-capacity-check branch from 5e94b6f to b06330a Compare October 9, 2026 19:31
@Moshik21

Moshik21 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on current main and validated locally with no-mistakes 1.41.2 on b06330a (review, test, document and lint passed; the review step also tightened lane-capacity parsing and indexed the new script and config in the docs).
The pipeline cannot push to upstream origin (403), so the update was pushed to the fork branch and this PR updated in place.
The no-mistakes attestation block is absent because it needs no-mistakes 1.46 or newer.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Moshik21 for rebasing and running this through no-mistakes. The tightened config/lane-capacity parsing (malformed value → invalid-target, exit 1) is a good change.

What changed since my last stamp (5e94b6f4): head is now b06330a6, rebased on current main, with the review-step parsing fix and a lint fix. I re-read the tip against main fb75c1f9: bin/fm-capacity.sh is still read-only and network-free (state/*.meta, /proc or sysctl, getconf, df), nothing spawns or gates on it, and with no config/lane-capacity it prints counts only. Contract-class stays opt-in, and my earlier per-rule VISION verdict stands (all rules align; the one AGENTS.md line is a pointer, not a new dispatch gate).

CI: I reviewed the diff first (no workflow, secret, or network surface), then approved CI 37980872742 and Require no-mistakes 37980872469.

Waiting on you, the author: as you noted, the body has no no-mistakes attestation, so "PR must be raised via no-mistakes" will fail and this can't merge yet. When you get a chance, could you upgrade no-mistakes to 1.46 or newer and push the branch through git push no-mistakes so the attestation binds the head? A 403 to upstream is fine; updating your fork branch in place is exactly right. If CI and no-mistakes then go green and it stays mergeable, this auto-merges. Thank you!

@Moshik21

Moshik21 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #6973, which carries the same head b06330a with a pipeline-raised attestation. Closing this PR in favor of it.

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