events.sqlite vacuum moves host-side
retention is a host concern — agents have no business doing their own cleanup, and a misbehaving harness could skip it. drop spawn_events_vacuum from both hive-ag3nt and hive-m1nd, drop the matching Bus::vacuum + EventStore::vacuum methods. new hive_c0re::events_vacuum module sweeps every existing agents/<name>/state/hyperhive-events.sqlite on the same hourly cadence as the broker vacuum. same two-stage delete (older than 7 days, trim to 2000 newest). called from main alongside broker vacuum. also: server-side state badge entered into todo.md (today's badge is derived client-side from sse, fine for idle/thinking but a state machine that grows compacting/napping wants authoritative status from the harness).
This commit is contained in:
parent
897e7c07ae
commit
89ccc5e6c5
6 changed files with 89 additions and 63 deletions
|
|
@ -61,7 +61,6 @@ async fn main() -> Result<()> {
|
|||
let login_state = Arc::new(Mutex::new(initial));
|
||||
let ui_state = login_state.clone();
|
||||
let bus = Bus::new();
|
||||
spawn_events_vacuum(bus.clone());
|
||||
let ui_bus = bus.clone();
|
||||
let ui_socket = cli.socket.clone();
|
||||
tokio::spawn(async move {
|
||||
|
|
@ -90,22 +89,6 @@ async fn main() -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Vacuum events older than 7 days, cap to 2000 most-recent rows.
|
||||
fn spawn_events_vacuum(bus: Bus) {
|
||||
tokio::spawn(async move {
|
||||
let interval_secs = 3600u64;
|
||||
let keep_secs: i64 = 7 * 24 * 3600;
|
||||
let keep_rows = 2000;
|
||||
loop {
|
||||
let n = bus.vacuum(keep_secs, keep_rows);
|
||||
if n > 0 {
|
||||
tracing::info!(removed = n, "events vacuum");
|
||||
}
|
||||
tokio::time::sleep(Duration::from_secs(interval_secs)).await;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async fn serve(socket: &Path, interval: Duration, bus: Bus) -> Result<()> {
|
||||
tracing::info!(socket = %socket.display(), "hive-m1nd serve");
|
||||
let mcp_config = turn::write_mcp_config(socket).await?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue