Shared persistent state across all subconscious agents

Moved persistent_state from per-agent to a single shared BTreeMap on
Subconscious. All agents read/write the same state — surface's walked
keys are visible to observe and reflect, etc.

- Subconscious.state: shared BTreeMap<String, String>
- walked() derives from state["walked"] instead of separate Vec
- subconscious-state.json is now a flat key-value map
- All agent outputs merge into the shared state on completion
- Loaded on startup, saved after any agent completes

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-07 19:16:01 -04:00
parent 578be807e7
commit 27ca3c058d
8 changed files with 60 additions and 80 deletions

View file

@ -241,14 +241,18 @@ impl SubconsciousScreen {
}
}
if !snap.walked.is_empty() {
lines.push(Line::raw(""));
lines.push(Line::styled(
format!(" walked ({}):", snap.walked.len()),
Style::default().fg(Color::Cyan),
));
for key in &snap.walked {
lines.push(Line::styled(format!(" {}", key), dim));
if let Some(walked_str) = snap.state.get("walked") {
let walked: Vec<&str> = walked_str.lines()
.map(|l| l.trim()).filter(|l| !l.is_empty()).collect();
if !walked.is_empty() {
lines.push(Line::raw(""));
lines.push(Line::styled(
format!(" walked ({}):", walked.len()),
Style::default().fg(Color::Cyan),
));
for key in &walked {
lines.push(Line::styled(format!(" {}", key), dim));
}
}
}
}