hive-agent: no-pressure hint when state dir top level hits 30+ entries

New state_entry_watch.rs, mirroring disk_watch.rs's shape exactly:
periodic in-process probe, Todos::upsert with a stable count-bucketed
summary (anti-nag - drifting inside one bucket stays silent, crossing
a bucket speaks up again), clears once back under threshold.

Top-level entry count only, deliberately - a large subdirectory (git
clone, build tree) counts as one entry regardless of what's inside it,
which is disk_watch's problem to catch on its own axis (bytes), not
this one's.

Wired into main.rs's spawn_todo_socket alongside disk_watch::run.

closes #3464
This commit is contained in:
damocles 2026-08-18 21:44:20 +02:00 committed by mara
commit 301a576feb
2 changed files with 192 additions and 0 deletions

View file

@ -24,6 +24,7 @@ mod questions;
mod reminder_timer;
mod reminders;
mod serve_common;
mod state_entry_watch;
mod stats;
mod stream_enrich;
mod todo_server;
@ -522,6 +523,9 @@ fn spawn_todo_socket(
// shares this store + wake directly instead of dialling the
// socket the out-of-process producers use.
tokio::spawn(disk_watch::run(store.clone(), todo_wake.clone()));
// Same shape, different signal: nudge on a crowded state-dir
// top level instead of disk pressure.
tokio::spawn(state_entry_watch::run(store.clone(), todo_wake.clone()));
Some(store)
}
Err(e) => {