mirror of
https://github.com/hanzoai/engine.git
synced 2026-11-20 23:45:50 +00:00
The learned routing head is now a first-class hanzo-router primitive, and exactly one Policy type reaches the serve seam. The featurizer moves from the enso crate into hanzo-router (featurize.rs); heads.rs adds the serve-time scorer (bilinear W + arm profiles). Policy grows `learned`: mounted, route() scores arms x^T W p minus the SLO penalty; empty, the rule-based walk. The PREFER table (a-priori per-task arm preferences, ported from the live eval harness) ships as prefer() -- the preference-aware default. hanzo-server-core resolves one deployment_policy(): ROUTER_HEADS=<bundle> mounts the head (Policy::load_heads), unset keeps prefer(). Reversible by one env var. Seam test proves the wired path routes per the head and diverges from the rule-based default on the same prompt + pool. router-fit (renamed from enso-fit) emits the serve bundle next to --out. Fitted on 2981 real eval events (gpqa_diamond + livecodebench, prompt text included so fit-time features match serve-time): held-out decision quality (prompt-level splits, 8 seeds) head 0.9215+-0.011 vs rule-based 0.9162+-0.007 vs best-single-arm 0.9215 (gpt-5.5) vs oracle 0.9402. Bundle + regen docs in hanzo-router/heads/. The enso crate remains the offline learner only; its Policy never reaches the seam.
Router heads — the learned routing policy
router.heads.json is the serve bundle the engine mounts via
ROUTER_HEADS=<path> (loaded by hanzo_router::Policy::load_heads at startup;
unset = the rule-based prefer() policy). One Policy type either way.
Fit from eval events (per-prompt, per-arm outcomes with real prompt text):
cargo run --release -p hanzo-router-retrain --bin router-fit -- \
--events <events.jsonl> --out heads.safetensors --gamma 0.1
which writes the servable heads.heads.json next to --out. Current bundle:
2981 events (gpqa_diamond + livecodebench, 373 prompts x 8 arms), gamma 0.1
picked by held-out decision quality (mean realized correctness of the chosen
arm, prompt-level splits, 8 seeds): head 0.9215 +- 0.011 vs rule-based
0.9162 +- 0.007 vs best-single-arm 0.9215 (gpt-5.5) vs oracle 0.9402.