fix: persist categorizations to capnp log

categorize() only updated the in-memory HashMap and state.json cache.
When init appended new nodes to nodes.capnp (making it newer than
state.json), the next load() would rebuild from capnp logs and lose
all category assignments.

Fix: append an updated node version to the capnp log when category
changes, so it survives cache rebuilds.

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
ProofOfConcept 2026-02-28 22:19:17 -05:00
parent 23fac4e5fe
commit 6322b3fd61

View file

@ -711,8 +711,16 @@ impl Store {
pub fn categorize(&mut self, key: &str, cat_str: &str) -> Result<(), String> {
let cat = Category::from_str(cat_str)
.ok_or_else(|| format!("Unknown category '{}'. Use: core/tech/gen/obs/task", cat_str))?;
if let Some(node) = self.nodes.get_mut(key) {
let updated = if let Some(node) = self.nodes.get_mut(key) {
node.category = cat;
node.version += 1;
Some(node.clone())
} else {
None
};
if let Some(node) = updated {
// Persist to capnp log so category survives cache rebuilds
self.append_nodes(&[node])?;
Ok(())
} else {
Err(format!("No node '{}'", key))