diff --git a/hive-c0re/src/agent_config/capabilities.rs b/hive-c0re/src/agent_config/capabilities.rs index 80157c50..998c408c 100644 --- a/hive-c0re/src/agent_config/capabilities.rs +++ b/hive-c0re/src/agent_config/capabilities.rs @@ -65,9 +65,10 @@ fn prune_unknown(map: &mut BTreeMap>) -> bool { /// Read the per-agent capability map. Returns an empty map when the /// file is absent or unparsable — callers treat a missing entry as /// "no extra capabilities". Any entry that isn't a recognised -/// [`Capability`] is dropped (with a `warn!`) and the pruned form is -/// written back so the file heals rather than carrying the junk -/// forever. +/// [`Capability`] is dropped (with a `warn!`) from what's returned — +/// a stale or typo'd name is never honoured — but `read` itself never +/// writes; the on-disk file only gets repaired the next time something +/// calls `write`/`set_caps` anyway. #[must_use] pub fn read() -> BTreeMap> { let path = capabilities_path(); @@ -75,11 +76,7 @@ pub fn read() -> BTreeMap> { return BTreeMap::new(); }; let mut map: BTreeMap> = serde_json::from_str(&raw).unwrap_or_default(); - if prune_unknown(&mut map) { - // Best-effort: on write failure the caller still gets the - // pruned in-memory map, and the next read retries the repair. - let _ = write(&map); - } + prune_unknown(&mut map); map }