Skip to content

Implement persistent watch daemon #15

@subzeroid

Description

@subzeroid

Context

/watch is currently REPL-session-local: each watch runs as an in-process asyncio task and dies when the REPL exits. The sqlite watches table already persists watch registrations, but there is no restart recovery or daemon control surface.

This issue tracks turning watch registrations into a persistent local daemon flow while keeping the existing CLI/REPL UX simple.

Scope

Add a persistent daemon mode for registered watches:

  • Restart recovery from the sqlite watches table.
  • A one-shot daemon runner suitable for systemd, launchd, tmux, or a user-managed shell.
  • Control surface from REPL/one-shot CLI to list, add, remove, and inspect watch state.
  • Clear status fields for active/paused/error watches.
  • Safe shutdown that does not corrupt sqlite or leave in-flight ticks writing after close.

Constraints

  • Keep all state local in ~/.insto/store.db.
  • Do not introduce a network service, HTTP API, telemetry, or phone-home.
  • Keep the 5-minute interval floor unless tests explicitly lower it.
  • Keep HikerAPI/account cost and rate-limit risk visible.
  • Unit tests must not require live Instagram.

Initial implementation target

Start with the smallest shippable slice:

  • insto watch-daemon run or equivalent daemon entrypoint.
  • Load persisted watches rows and tick them with the existing facade/watch logic.
  • Update last_ok, last_error, and status in sqlite.
  • Document how to run it manually; platform service files can come later.

Acceptance criteria

  • Existing /watch, /unwatch, /watching, /diff, and /history behavior stays compatible.
  • Daemon mode resumes persisted watches after process restart.
  • Tests cover daemon loading, one tick, error state update, and shutdown.
  • Docs explain manual daemon usage and limitations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions