Repository navigation
refactor(dispatch): delegate selector, fallback chain, and capacity to llm-router-axi - #66
Conversation
adibirzu
left a comment
There was a problem hiding this comment.
Grok second-level review (coordinator). Holding merge for the architect's Mac proof.
Net -3631 / +599. Selector is a 110-line forwarder, capacity-lib is a 73-line wrapper over llm-router-axi capacity, fallback reads route chain. Account helpers and fleet-quota-lib are kept because the plugins do not cover them; that is why the under-400-line target is not met (2122 remaining, of which 734 accounts+federation, 824 handoff+review, 564 shims). Local adi1 tests: 13+4 suites, 0 failed.
Do not merge until Mac proof: install both tools from main, route --flags for ship/easy/backend, review, architecture, and one fm-spawn dry run.
…o llm-router-axi Shim-first P3b deletion: the fork's dispatch selection, in-run model fallback chain, and machine-capacity probes now live in llm-router-axi (select, route chain, capacity, record, classify-evidence) and usage-axi, so the fork keeps only thin adapters. - bin/fm-dispatch-select.mjs is a thin forwarding shim over llm-router-axi select/record/classify-evidence, kept for existing callers. - bin/fm-model-fallback.sh reads its step-down chain from llm-router-axi route chain and records depletion with llm-router-axi record. - bin/fm-capacity-lib.sh is a thin spawn-admission wrapper over llm-router-axi capacity; bin/fm-capacity.sh reports that reading plus the usage-axi machine measurement. config/spawn-capacity is retired. - config/crew-dispatch.json keeps its judgment rules and profiles; the reserve, cooldown, fallback chain, and capacity thresholds move to the router policy. bootstrap stops validating the moved fields. - Moves the moved commands' tests to fake the router and drops the fork-only selector test. Federation (fm-fleet-quota-lib.sh, account helpers) and review (fm-review.sh/docs/code-review.md) are not moved into the plugins and are kept.
The two tools are not published on npm yet, so fm-router-lib.sh's install hint and the docs/skills that quote it now clone and build from the GitHub main clones instead of pretending an npm install exists.
13ade9e to
d208aa2
Compare
origin/main's Stock macOS Bash snapshot job was already red: d30f50e added one fm-fleet-snapshot-view test and two fm-bearings-snapshot tests without bumping the workflow's expected counts (18/53). Set them to the counts the tests now emit (19/55) so the rebased PR can pass.
adibirzu
left a comment
There was a problem hiding this comment.
Grok second-level follow-up. Holding merge for the architect's final Mac re-prove (architect merges this pass).
Git-clone install hint is in fm-router-lib.sh (clone adibirzu/llm-router-axi and usage-axi, npm ci && npm run build && npm install -g --prefix ~/.local .). Rebased onto origin/main 4f39813. max_fleet_agents from fork PR 55 is dropped in favour of llm-router-axi policy agentCeiling. Local adi1 tests 13+4, 0 failed. Do not merge from this home.
Summary
P3b deletion PR: the firstmate fork's dispatch selection, in-run model-fallback chain, and machine-capacity probes now live in
llm-router-axiandusage-axi, so the fork keeps only thin adapters.One PR, direct-PR, no merge.
Rebased onto current
origin/main(4f39813b); no upstream commits are pulled into this PR.bin/fm-dispatch-select.mjsis a thin forwarding shim overllm-router-axi select/record/classify-evidence, kept only so existing callers keep their command line (110 lines, was 777).bin/fm-model-fallback.shreads its step-down chain fromllm-router-axi route chain --json, classifies depletion withllm-router-axi classify-evidence, and records depletion withllm-router-axi record; it keeps its evidence cursor, paused-line filtering, and in-place handoff orchestration (318 lines, was 380).bin/fm-capacity-lib.shis a thin spawn-admission wrapper overllm-router-axi capacity(73 lines, was 847 + the rebasedmax_fleet_agentsaddition);bin/fm-capacity.shreports that reading plus theusage-axi machinemeasurement (63 lines, was 75).config/spawn-capacityis retired; the gauges and thresholds live in the router policy.config/crew-dispatch.jsonkeeps its judgmentrulesanddefaultprofiles; the reserve, cooldown, telemetry age, in-run fallback chain, and capacity thresholds move to~/.config/llm-router-axi/policy.json.bin/fm-bootstrap.shstops validating the moved fields;bin/fm-config-inherit-lib.shdrops the retiredspawn-capacityfrom the inheritable set.AGENTS.md,docs/configuration.md,docs/architecture.md,docs/scripts.md,docs/examples/crew-dispatch.json, and therouter-dispatch/quota-array-dispatchskills point at the tools and no longer restate the moved contracts.bin/fm-router-lib.sh's install hint builds both tools from their GitHub main clones (npm ci && npm run build && npm install -g --prefix ~/.local .); neither is published on npm yet, and the docs/skills that quote the hint were updated to match..github/workflows/ci.yml's Stock macOS Bash job expected the pre-rebase snapshot/Bearings test counts;d30f50edonorigin/mainadded onefm-fleet-snapshot-viewtest and twofm-bearings-snapshottests without bumping them, soorigin/main's macOS job was already red. This PR sets the expectations to what the tests emit (19 and 55), which unblocks the rebased checks.Rebase resolution (capacity max_fleet_agents)
origin/mainadvanced after this branch opened and now carriesfeat(fm-capacity): add opt-in max_fleet_agents machine-wide ceiling(fork PR #55), which added an in-repo agent-count ceiling to the oldbin/fm-capacity-lib.sh.This PR deletes that in-repo measurement in favour of
llm-router-axi capacity, whose policyagentCeilingis the same ceiling and is exactly what P3c made agree withusage-axi machine.The rebase therefore keeps the deletion and drops the in-repo
max_fleet_agentsknob and its tests; the equivalent limit lives in~/.config/llm-router-axi/policy.jsonasagentCeiling.If the captain wants the old per-home knob back, it would have to be re-expressed as a router-policy value, not re-added to firstmate.
What was not deleted, and why
The architect list asked for the account helpers to be removed and for
fm-fleet-quota-lib.shto keep only federation.After review I kept both, because neither feature moved into the plugins and deleting them would drop capability and break kept surfaces:
bin/fm-accounts-lib.sh,fm-spawn-acct.sh, andfm-account-exec.share the multi-account registry, isolation, and launch path.llm-router-axiroutes by provider but does not select or isolate accounts, and federation (fm-fleet-snapshot.sh,fm-crew-usage-lib.sh) plusfm-spawn.sh --accountdepend on the registry. Removing them now would remove working behavior the plugins do not cover, so this PR leaves them and flags the gap for the architect.bin/fm-fleet-quota-lib.shis entirely the federation quota/pace surface (its own header marksfm_fleet_pick_surfaceas operator-only and never a dispatch path), so there are no dispatch-only parts to delete; it is kept whole.bin/fm-runtime-handoff.shwas not on the deletion list andbin/fm-review.sh+docs/code-review.mdare explicitly out of scope (futurereview-axi), so all three are untouched.quota-array-dispatchstill exists and still owns the selection judgment boundary; its mechanics owner now points atllm-router-axi selectinstead of the shim. The full skill collapse is P4 scope per plan section 3.Fork dispatch-surface diff vs upstream
Measured against
upstream/mainatb182d0f9(same methodology as P0 section 5: strict counts files in the plan section 1 set that are absent upstream at their full line count; listed adds the rewrittenbin/fm-harness.shand the modifiedquota-array-dispatchskill).origin/mainthen)origin/main4f39813b)Net reduction against the rebased base: 1556 lines on both measures.
The remaining 2122 strict lines break down as:
fm-dispatch-select.mjs110,fm-capacity-lib.sh73,fm-capacity.sh63,fm-model-fallback.sh318fm-fleet-quota-lib.sh460,fm-accounts-lib.sh197,fm-spawn-acct.sh51,fm-account-exec.sh26fm-runtime-handoff.sh371,fm-review.sh363,docs/code-review.md90The under-400-line target is not reachable while the account surface is unreplaced by a plugin and
fm-runtime-handoff.shand the review surface stay in-repo as directed.fm-model-fallback.shalso cannot shrink far below its current size because it still owns the evidence cursor, paused-line filtering, and the guarded in-place relaunch that the router does not.Migration note
A home that carried
config/spawn-capacitylimits or crew-dispatchsubscriptionRouting/modelFallback/modelFallbackCycles/fallbackLanesmust move them into~/.config/llm-router-axi/policy.json.llm-router-axi policy initwrites the bundled default andllm-router-axi policy show --fullexpands every lane.An absent
llm-router-axinow makes spawn admission decline rather than run unguarded, so both tools must be installed before this lands.Both are unpublished on npm; build and install each from its GitHub main clone with the command in
bin/fm-router-lib.sh's install hint.GitHub checks
PR must be raised via no-mistakesfails by design: this is a direct-PR task, not a no-mistakes run, per the brief.The other failing check,
Stock macOS Bash snapshot compatibility, was failing onorigin/mainbefore this branch for the test-count reason above and is fixed here.Local CI
All commands run on the adi1 host from the task worktree, after the rebase.
The changed tests drive a fake
llm-router-axirather than the live tool;tests/capacity-pin.shnow binds that fake for every spawn suite so admission does not depend on the runner's memory pressure or on whether the tools happen to be installed on the runner.Code Review (Stage 1)
bin/fm-review.sh worktreewithout--stage1-onlyescalates to Stage 2 delegate mode only because the changeset exceeds the 1000-line threshold; this is a net-deletive change with no printed-rule findings, and the Stage 2 checklist was reviewed against the flagged shell files with no corrections required.Mac-side proof
Not in this PR, per the brief.
The architect re-proves on the Mac after this rebase (both tools built from git main,
llm-router-axi route --flags, one realfm-spawndry run) and merges PR 66 themselves.