forked from kent/consciousness
Compute graph health in consciousness, rename F4 to hippocampus
Graph health stats (alpha, gini, cc, episodic ratio, consolidation plan) now computed directly by the unconscious module on startup and every 10 minutes, instead of fetching from the poc-memory daemon. F4 screen renamed to hippocampus, stripped down to just the health gauges — daemon task list removed (agents now shown on F3). Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
1df49482fd
commit
7aba17e5f0
5 changed files with 46 additions and 91 deletions
|
|
@ -67,6 +67,8 @@ pub struct UnconsciousSnapshot {
|
|||
pub struct Unconscious {
|
||||
agents: Vec<UnconsciousAgent>,
|
||||
max_concurrent: usize,
|
||||
pub graph_health: Option<crate::subconscious::daemon::GraphHealth>,
|
||||
last_health_check: Option<Instant>,
|
||||
}
|
||||
|
||||
impl Unconscious {
|
||||
|
|
@ -75,7 +77,13 @@ impl Unconscious {
|
|||
.filter(|name| defs::get_def(name).is_some())
|
||||
.map(|name| UnconsciousAgent::new(name))
|
||||
.collect();
|
||||
Self { agents, max_concurrent: 2 }
|
||||
let mut s = Self {
|
||||
agents, max_concurrent: 2,
|
||||
graph_health: None,
|
||||
last_health_check: None,
|
||||
};
|
||||
s.refresh_health();
|
||||
s
|
||||
}
|
||||
|
||||
/// Toggle an agent on/off by name. Returns new enabled state.
|
||||
|
|
@ -95,8 +103,25 @@ impl Unconscious {
|
|||
}).collect()
|
||||
}
|
||||
|
||||
fn refresh_health(&mut self) {
|
||||
let store = match crate::store::Store::load() {
|
||||
Ok(s) => s,
|
||||
Err(_) => return,
|
||||
};
|
||||
self.graph_health = Some(crate::subconscious::daemon::compute_graph_health(&store));
|
||||
self.last_health_check = Some(Instant::now());
|
||||
}
|
||||
|
||||
/// Reap finished agents and spawn new ones.
|
||||
pub fn trigger(&mut self) {
|
||||
// Periodic graph health refresh
|
||||
if self.last_health_check
|
||||
.map(|t| t.elapsed() > Duration::from_secs(600))
|
||||
.unwrap_or(false)
|
||||
{
|
||||
self.refresh_health();
|
||||
}
|
||||
|
||||
for agent in &mut self.agents {
|
||||
if agent.handle.as_ref().is_some_and(|h| h.is_finished()) {
|
||||
agent.last_run = Some(Instant::now());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue