Repository navigation
feat(bin): domain-first routing with Claude→OpenAI fallback and read-only tmux dashboard - #737
Closed
Pawel-Podemski wants to merge 7 commits into
Closed
Pawel-Podemski wants to merge 7 commits into
Pawel-Podemski wants to merge 7 commits into
Conversation
added 7 commits
July 19, 2026 16:34
… quote dashboard script dir
…lable selector, and dashboard scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Implement domain-first FirstMate and SecondMate model routing with direct Claude-to-OpenAI hard-unavailability fallback, ban Ultra, preserve work-order state across fallback, and add a read-only three-pane tmux operator dashboard with tests and documentation.
What Changed
primary-availabledispatch strategy tofm-dispatch-select.shthat walks declared profiles in order and picks the first whose adapter command exists and whose provider is not proven exhausted; missing/stale/auth-failed telemetry is treated as UNKNOWN so it keeps the primary instead of speculatively downgrading, with a fresh-quota gate on the exact-zero exhaustion signal. Wired every "using first profile" fallback path (missing/unreadable quota, absent quota-axi, unparseable JSON) to honor this strategy.fm-spawn.sh: an optionalconfig/secondmate-dispatch.jsonresolves a per-ID (ordefault) profile through the sameuse/selectcontract, threading harness/model/effort while letting explicit per-spawn axes win and falling through to the legacysecondmate-harnesschain on a miss (set-e-safe so an uncovered ID no longer aborts the spawn); the local dispatch config is gitignored.fm-dashboard.sh,fm-dashboard-loop.sh,fm-dashboard-view.sh) that renders coordinator capture, roster, and worker details from fleet snapshots and current-state without keying or waking the observed session, backed by new dispatch/dashboard/bootstrap/secondmate-harness tests and updated architecture, configuration, scripts, and tmux-backend docs.Risk Assessment
✅ Low: The only changes since the prior review are the two correct, well-bounded fixes for the previously reported findings (set-e-safe dispatch resolution and a deduplicated age_label guard), leaving the branch clean.
Testing
The configured tmux e2e suite already passed as baseline; I re-ran the changed/related tests (dispatch-select, dashboard, secondmate-harness, bootstrap, spawn-batch, session-start, backend-orca) and all passed with no regressions. Beyond tests, I demonstrated the intent end-to-end: a CLI transcript proves the domain-first Claude→OpenAI fallback fires only on hard unavailability (missing adapter, exact quota exhaustion) and preserves the primary on unknown telemetry; a real tmux launch produced captures of the read-only three-pane observer dashboard (coordinator/roster/details) confirming it creates a separate observer session and never sends keys to the target; and a populated-snapshot render plus composited layout show the panes with live worker telemetry. No "Ultra" model/tier appears anywhere in the tree. Worktree left clean; all evidence written under the evidence directory.
Evidence: Domain-first Claude→OpenAI fallback routing transcript (4 scenarios)
Scenario A: Claude adapter HARD-MISSING → {"harness":"codex","model":"gpt-5.6-sol","effort":"high"} Scenario B: Claude quota EXACTLY exhausted (0%) → codex Scenario C: Claude telemetry UNKNOWN → claude PRESERVED (no speculative downgrade) Scenario D (control): healthy quota → claude PRESERVEDEvidence: Live three-pane read-only tmux dashboard — composited layout
Evidence: Live dashboard launch status (mutation: false, observer session)
status: ready observer: fm-dashboard-demo target: fm-demo attach: "tmux attach -t fm-dashboard-demo" detach: "Ctrl-b d" mutation: falseEvidence: Live captured coordinator pane (read-only target capture)
Evidence: Populated roster + details panes render
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-spawn.sh:321- fm-spawn.sh runs underset -eu(line 82), but the secondmate-dispatch resolution assignsSM_DISPATCH_SPEC=$(jq -ec '.profiles[$id] // .default // empty' ...)as a bare assignment and only readssm_dispatch_status=$?on the next line. When the spawned ID is not in the dispatch file and nodefaultexists,jq -eproduces no output and exits 4; underset -ethe assignment itself aborts the script with status 4 before line 322/the exit-4 fall-through branch (323-329) can run. I confirmed this empirically:set -eu; X=$(jq -ec '.profiles["nope"] // .default // empty' ...)exits the shell with code 4. Result: wheneverconfig/secondmate-dispatch.jsonis present but does not cover a given secondmate ID (and has nodefault), the secondmate spawn dies instead of falling through to the documented legacyconfig/secondmate-harnesschain (docs/configuration.md: 'A missing ID falls through to the optional default profile set, then to the backward-compatible config/secondmate-harness chain'). Fix by making the assignment set-e-safe, e.g.if SM_DISPATCH_SPEC=$(jq ...); then sm_dispatch_status=0; else sm_dispatch_status=$?; fi. The passing test only exercises a matching ID, so the exit-4 path is uncovered.bin/fm-dashboard-view.sh:33- age_label() runs two identicalcase "$seconds" in ''|null|*[!0-9]*)blocks back to back (one to print 'n/a', one to return). This can collapse to a single guard, e.g.case ... ) printf 'n/a'; return ;; esac. Purely a readability simplification; behavior is already correct.🔧 Fix: fix set -e abort in secondmate dispatch, dedup age_label guard
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"bash tests/fm-dispatch-select.test.sh(11 cases incl. primary-available fallback, exact-exhaustion, unknown-telemetry-preserves-primary, hard-missing-adapter)bash tests/fm-dashboard.test.sh(read-only observer-only tmux ops, no-active-worker render)bash tests/fm-secondmate-harness.test.sh(per-ID secondmate dispatch B3a, harness/model/effort threading)bash tests/fm-bootstrap.test.sh(validates crew-dispatch + per-ID secondmate-dispatch profiles)bash tests/fm-spawn-batch.test.sh,bash tests/fm-session-start.test.sh,bash tests/fm-backend-orca.test.sh(no regressions)Manual E2E:fm-dispatch-select.sh --select primary-availableacross 4 quota/adapter scenarios → routing-fallback-transcript.txtManual E2E: launched livefm-dashboard.sh fm-demoon isolated tmux socket, captured all three panes; verified observer session created and target never keyed✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.