idle: persist timeout, suppress restart fire, add debug/save/idle-timeout commands

Several idle timer fixes and new inspection capabilities:

- Persist idle_timeout across daemon restarts (was reverting to 5min default)
- Set fired=true on load to suppress immediate fire from stale timestamps
- Add human-readable ISO timestamps to daemon-state.json for debugging
- Use to_string_pretty for readable state file
- Make save() public for RPC access
- Remove kb_idle_minutes() — go purely off message timestamps
- Add maybe_prompt_notification() with idle gate so notifications only
  inject via tmux when truly idle, not during active sessions
- Add debug_json() for full state inspection with computed values
  (would_fire, block_reason, all timers)

New RPC commands (schema @16-18):
  poc-daemon idle-timeout <secs>  — set idle timeout
  poc-daemon save                 — force state persistence
  poc-daemon debug                — dump full internal state as JSON

Also: save state on clean shutdown, route module notifications through
maybe_prompt_notification before submitting to queue.

Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
ProofOfConcept 2026-03-05 21:16:19 -05:00 committed by Kent Overstreet
parent 8662759d53
commit eab656aa64
4 changed files with 207 additions and 30 deletions

View file

@ -61,6 +61,10 @@ interface Daemon {
getTypes @13 () -> (types :List(TypeInfo));
setThreshold @14 (type :Text, level :UInt8) -> ();
idleTimeout @16 (seconds :Float64) -> ();
save @17 () -> ();
debug @18 () -> (json :Text);
# Modules
moduleCommand @15 (module :Text, command :Text, args :List(Text))
-> (result :Text);