Expand description
hq-core router: roles, presets, seats and a limit-aware fallback.
Config (<data_dir>/routing.json, owner-edited, hot-reloaded on each call):
{
"seats": [{ "id": "box-claude", "node": "hatchery-box", "provider": "claude" }],
"roles": {
"dev": { "preset": ["claude/opus:high", "codex/gpt-5:high"], "auto": true },
"advisor": { "preset": ["codex/gpt-5:medium"], "auto": false }
},
"limit_cooldown_secs": 3600,
"advisor": { "min_interval_secs": 300, "dedup_secs": 3600 }
}A preset entry is provider/model[:effort]. A seat is one place a provider can run
(a node + provider, optionally a named account). The router walks the role’s preset in
order and, for each entry, the seats of that provider; a seat with a recent limit
signal is skipped until a ready signal, a parsed reset time, or the cooldown passes.
Signals are hints (screen heuristics): they only reorder and never delete a seat, and
when every seat is limited the router still answers with the soonest-free one.
The router recommends; it picks on its own only in roles with "auto": true.
Structs§
- Advice
Gate - Advisor anti-noise gate: one advice per
min_intervalper advisor, and the same topic not again withindedup. Memory only (a restart forgets; that is acceptable noise). - Advisor
Policy - Candidate
- Inventory
Model - One model a node’s provider CLI exposes (as reported by the node).
- Model
Ref provider/model[:effort]- Node
Inventory - Stored inventory row: one provider on one node.
- Provider
Inventory - What a node reports for one provider.
- Recommendation
- Role
- Routing
Config - Seat
- Seat
State - Latest limit knowledge per (node, provider), built from session signals.
Functions§
- clean_
report - Validate a node’s report (bounded, plain identifiers). A bad provider, model or effort entry is dropped on its own; the rest of the report is kept.
- fold_
signals - Fold signals (oldest first) into per-(node, provider) state.
- offered
- A role preset entry is valid only if some node reports that provider/model (and effort).
- ok_
model_ id - Model ids may carry a vendor path or tag (
kimi-code/k3,name:tag,x@v). - parse_
model_ ref - parse_
reset - “try again in 2 hours”, “in 45 minutes”: relative reset, capped at 8 days.
- recommend
- recommend_
in - Like
recommend, but only seats whose node reports the model count (wheninventoryis given).