From 968db59208454b68c6dec096ea08852f0940664f Mon Sep 17 00:00:00 2001 From: atlas Date: Thu, 17 Sep 2026 20:59:43 +0200 Subject: [PATCH] capabilities: read() filters but no longer persists the prune MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Operator ruling: repair belongs on the write path, not the read path. read() still drops unrecognised names from what it returns (with a warn!) so a stale name is never honoured, but it no longer writes the pruned form back — the file heals the next time set_caps()/write() run, which prune anyway since they're fed a map read() already filtered. Refs #4474 --- hive-c0re/src/agent_config/capabilities.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) 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 }