feat(#2569): DB-backed per-agent todo store + mcp.sock upsert/clear/list/mark-done ops

This commit is contained in:
damocles 2026-07-19 01:15:17 +02:00 committed by mara
commit 6685b33c9d
8 changed files with 505 additions and 0 deletions

View file

@ -97,9 +97,36 @@ pub fn for_agent(coord: &Coordinator, agent: &str) -> Result<Vec<LooseEnd>> {
age_seconds: saturating_age(now, r.created_at.timestamp()),
});
}
// Dynamic, subsystem-pushed todos (loose-ends v2, #2569). Scoped to
// this agent; the producing subsystem or the agent itself clears them.
out.extend(todos_for(coord, agent, None)?);
Ok(out)
}
/// This agent's dynamic todos as `LooseEnd::Todo` rows, optionally
/// filtered to one `subsystem`. Shared by [`for_agent`] and the
/// `ListTodos` handler so the row-mapping lives in one place.
pub fn todos_for(
coord: &Coordinator,
agent: &str,
subsystem: Option<&str>,
) -> Result<Vec<LooseEnd>> {
let now = now_unix();
Ok(coord
.todos
.list(agent, subsystem)?
.into_iter()
.map(|t| LooseEnd::Todo {
id: t.id,
subsystem: t.subsystem,
subsystem_key: t.subsystem_key,
summary: t.summary,
source: t.source,
age_seconds: saturating_age(now, t.updated_at.timestamp()),
})
.collect())
}
/// Hive-wide loose-ends view: EVERY pending approval + EVERY
/// unanswered question + EVERY pending reminder. Manager surface
/// only; sub-agents can't see each other's threads via the agent