Convert store and CLI to anyhow::Result for cleaner error handling
Replace Result<_, String> with anyhow::Result throughout: - hippocampus/store module (persist, ops, types, view, mod) - CLI modules (admin, agent, graph, journal, node) - Run trait in main.rs Use .context() and .with_context() instead of .map_err(|e| format!(...)) patterns. Add bail!() for early error returns. Add access_local() helper in hippocampus/mod.rs that returns Result<Arc<Mutex<Store>>> for direct local store access. Fix store access patterns to properly lock Arc<Mutex<Store>> before accessing fields in mind/unconscious.rs, mind/mod.rs, subconscious/learn.rs, and hippocampus/memory.rs. Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
5db00e083f
commit
b8db8754be
17 changed files with 282 additions and 295 deletions
|
|
@ -12,6 +12,7 @@ use futures::FutureExt;
|
|||
use crate::agent::oneshot::{AutoAgent, AutoStep, RunStats};
|
||||
use crate::agent::tools;
|
||||
use crate::subconscious::defs;
|
||||
use crate::hippocampus::access_local;
|
||||
|
||||
fn config_path() -> std::path::PathBuf {
|
||||
dirs::home_dir().unwrap_or_default()
|
||||
|
|
@ -254,12 +255,9 @@ pub async fn prepare_spawn(name: &str, mut auto: AutoAgent) -> Result<SpawnResul
|
|||
};
|
||||
|
||||
// Run query and resolve placeholders
|
||||
let mut store = match crate::store::Store::load() {
|
||||
let store_arc = match access_local() {
|
||||
Ok(s) => s,
|
||||
Err(e) => {
|
||||
dbglog!("[unconscious] store load failed: {}", e);
|
||||
return Err(auto);
|
||||
}
|
||||
Err(_) => return Err(auto),
|
||||
};
|
||||
|
||||
let exclude: std::collections::HashSet<String> = std::collections::HashSet::new();
|
||||
|
|
@ -274,6 +272,7 @@ pub async fn prepare_spawn(name: &str, mut auto: AutoAgent) -> Result<SpawnResul
|
|||
};
|
||||
|
||||
if !batch.node_keys.is_empty() {
|
||||
let mut store = store_arc.lock().await;
|
||||
store.record_agent_visits(&batch.node_keys, name).ok();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue