Tokio-driven tick scheduler + registry for vigies.
Topology
┌──────────────────────────┐
│ RuntimeHandle (Clone) │ ← public surface used by
└────────────┬─────────────┘ vigy-cli / vigy-rpc /
│ vigy-graphql / vigy-rest
▼
┌──────────────────────────┐
│ Inner (Arc'd) │
│ - store: Store │
│ - tasks: Mutex<HashMap> │
│ - bus: broadcast tx │
└────────────┬─────────────┘
│ spawn per-vigy
▼
┌─────────────────────────────────────────────┐
│ tick_loop(vigy_id) — one tokio task each │
│ loop { │
│ sleep(interval). │
│ evaluate(vigy.program, fresh host). │
│ persist VigyRun. │
│ broadcast to bus. │
│ backoff on error. │
│ } │
└─────────────────────────────────────────────┘
Invariants
- One task per vigy.
register_or_updatecancels the old task before spawning the new one, so there's no double-tick risk. - Backoff on errors. Three failing ticks in a row → cap at 30s sleep until a tick succeeds.
- Store is source of truth. On startup,
RuntimeHandle::openreads existing vigies from the store and spawns tasks for the enabled ones.