refactor(dash): fold active_model into hyperhive-harness.json, not a separate file

hive-c0re was reading harness/hyperhive-model directly to surface the
model badge on the dashboard. hyperhive-model is a runtime-override
file (not the resolved priority) and adds to the marker-file count.

Instead: mirror the fully-resolved model into hyperhive-harness.json
(the consolidated state file that already replaced hyperhive-rate-limited
/ hyperhive-needs-login). Written by hive-ag3nt on:
- Bus::new() startup (captures nix config > override > default)
- set_model() runtime change (MCP set-model call)
- emit_status() (keeps model current across rate-limit / auth flips)

hive-c0re reads active_model from hyperhive-harness.json, same dir +
same read path as rate_limited / needs_login. No new files.
This commit is contained in:
iris 2026-06-27 21:06:54 +02:00
commit c580d721fb
2 changed files with 45 additions and 22 deletions

View file

@ -205,18 +205,20 @@ pub async fn read_agent_status_live(name: &str) -> (Option<String>, Option<i64>,
(text, set_at, true)
}
/// Read the active Claude model from the agent's harness state file
/// (`harness/hyperhive-model`). Returns `None` when the file is absent
/// or empty — callers should treat `None` as "model not yet known".
/// Read the active Claude model from `hyperhive-harness.json` (the
/// consolidated harness state file in the agent's state dir). Written by
/// the harness on startup and on every `set_model` / `emit_status` call,
/// so it always reflects the resolved priority (nix config > runtime
/// override > default). Returns `None` when the field is absent or the
/// harness has not yet started a turn.
fn read_active_model(name: &str) -> Option<String> {
let path = Coordinator::agent_harness_dir(name).join("hyperhive-model");
let s = std::fs::read_to_string(path).ok()?;
let trimmed = s.trim();
if trimmed.is_empty() {
None
} else {
Some(trimmed.to_owned())
}
let path = Coordinator::agent_notes_dir(name).join("hyperhive-harness.json");
let raw = std::fs::read_to_string(path).ok()?;
let v: serde_json::Value = serde_json::from_str(&raw).ok()?;
v.get("active_model")
.and_then(serde_json::Value::as_str)
.filter(|s| !s.is_empty())
.map(str::to_owned)
}
/// Host-side hive + swarm display names, read from the c0re service's