watcher: save state when it stops and wait for that save (closes #114) #186

Merged
clawbot merged 1 commits from issue-114-shutdown-save into next 2026-10-01 23:14:18 +02:00
1 Commits
Author SHA1 Message Date
sneak 032e07d823 watcher: save state when it stops and wait for that save (closes #114)
check / check (push) Successful in 1m16s
The final save at shutdown came from the state's own stop hook, while
the watcher's stop hook only cancelled its run loop, so a check under
way could change state after that save or be cut off at exit. Run now
saves state as it returns, and the watcher's stop hook waits for Run,
bounded by the shutdown deadline. The state's own save stays; Save
holds the state lock for the whole write, so the two cannot overlap.
The start hook derives the watcher's context with WithoutCancel, so
the linter needs no exception. A new test stops a watcher built by New
and reads the change back from the state file, with no DNS.

Model: opus-5-5
2026-10-01 21:12:29 +00:00