Skip to content

feat(daemon): add tiered health, backup, alerts, maintenance #830

Closed

Description

@Sinity

Summary

Add production-grade daemon operations features on top of the already-landed daemon/status substrate: tiered health, backup/portability, notifications, CI-facing checks, and scheduled maintenance.

Prior comments supersede the older broad body: WAL checkpointing, pidfile/single-instance locking, typed DaemonStatus, and FTS startup readiness already exist.

Remaining scope

Tiered health

Extend DaemonStatus with typed health checks and alert severity:

  • fast checks: daemon heartbeat, disk/WAL size, source availability;
  • medium checks: FTS readiness, insight freshness, stale live attempts, repeated stage failures;
  • expensive checks: blob integrity, embedding coverage, deeper DB integrity.

Represent alerts with a typed model such as HealthAlert(check_name, severity, message, checked_at, consecutive_failures).

Production failure visibility

Use concrete 2026-05-06 evidence as design cases:

  • DB locked writer contention;
  • embed-stage event-loop failures;
  • insight rebuild failures;
  • slow vs stuck convergence/backlog;
  • inactive-by-design vs unexpectedly stopped daemon state.

Backup and portability

Define practical local-first backup/export surfaces:

  • SQLite/WAL backup guidance or Litestream integration;
  • blob store backup guidance or restic integration;
  • portable archive export if it fits the storage model.

Notifications and maintenance

Notifications should be config-driven (#829) and initially cover health alerts, budget/cost thresholds, schema staleness, and session-complete/hook events where #802 supplies data.

Scheduled maintenance should distinguish daemon-owned fast tasks from systemd/cron-heavy tasks.

Non-goals

Dependencies

Acceptance criteria

  • Health checks are grouped by cost/frequency and expose severity/escalation.
  • Status/MCP/CLI can report slow, stuck, disabled, and failing convergence distinctly.
  • Recent stage/source/path/error-class failures are bounded and structured.
  • Backup/portable export plan is implemented or split into focused child issues with exact storage boundaries.
  • Notifications are config-driven and have at least one tested backend or explicit dry-run surface.
  • CI-facing health/check command has deterministic exit behavior.
  • Docs explain daemon-owned vs systemd/cron-owned maintenance tasks.

Refs #845 #829 #828 #802 #852.

Activity

  1. Sinity commented on May 4, 2026

    @Sinity
    OwnerAuthor

    Related: #717 (daemon owns health monitoring — status API is the contract), #829 (config system provides thresholds and notification rules), #828 (embedding task is a post-ingest daemon job).

  2. Sinity commented on May 4, 2026

    @Sinity
    OwnerAuthor

    Status update (2026-05-04)

    Several items in this issue are already implemented in the running daemon:

    Already done:

    • WAL checkpoint — _periodic_wal_checkpoint() runs every 5 minutes (cli.py:110-128)
    • Pidfile/instance lock — _verify_pidfile() + _acquire_pidfile() via fcntl.flock (cli.py:39-60, 157-171)
    • DaemonStatus model — feat(daemon): unified DaemonStatus model consumed by all surfaces #774 is closed, daemon_status_payload() exists in daemon/status.py
    • FTS startup readiness check — _ensure_fts_startup_readiness() runs on daemon start (cli.py:63-107)

    Still needed from this issue:

    • Tiered health monitoring (W12, U18) — structured health levels beyond ok/warn/err
    • Backup/portability — no polylogue backup or export-all command
    • Notifications — no hooks for stale ingestion, disk pressure, corruption
    • CI integration — no CI job that smoke-tests daemon health
    • Scheduled maintenance beyond WAL checkpoint (e.g., periodic integrity_check)

    The daemon is operational; these are the production-grade hardening items.

  3. Sinity commented on May 6, 2026

    @Sinity
    OwnerAuthor

    Production evidence to feed daemon health/status design

    The 2026-05-06 system update surfaced concrete conditions that the daemon operations surface should report, not merely log.

    Observed while polylogued.service was active:

    live.watcher: batch failed for codex: database is locked
    converger: execute failed for ... stage=embed: asyncio.run() cannot be called from a running event loop
    insights: rebuild failed
    

    Observed while the legacy Sinnix catch-up service was running:

    #845 owns replacing the legacy polylogue run service with daemon convergence. This issue should own the operations-facing part of that experience.

    Suggested health/status requirements:

    • Daemon status exposes recent stage failures by stage/source/path/error class, including repeated convergence failures such as asyncio.run() in a running loop.
    • Daemon health distinguishes inactive-by-design, stopped unexpectedly, and blocked/stale ingestion states.
    • Backlog/progress/stage timing from convergence is visible in structured status/MCP output, not only journal logs.
    • Health can report repeated recoverable provider-detection/parse failures separately from fatal ingestion failure.
    • Operators/agents can tell whether convergence is slow but making progress, stuck, or disabled by configuration/systemd ownership.
  4. added
    type:feat
    area:daemon
    theme:operations
    on May 6, 2026
  5. Sinity commented on May 6, 2026

    @Sinity
    OwnerAuthor

    Backlog hygiene note after #845/#847 production evidence

    This issue is still useful, but the body is now broader than the remaining actionable scope.

    Already implemented or no longer the center of this issue, per prior comments:

    • WAL checkpoint loop.
    • pidfile / single-instance lock.
    • typed DaemonStatus model and status payload.
    • FTS startup readiness check.

    Remaining operational scope should be interpreted as:

    Do not use this issue as a reason to keep polylogue-run.service or polylogue run; those are part of the migration away from the legacy batch model.

  6. changed the title [-]feat(daemon): operations surface — health monitoring, backup, notifications, CI integration[/-] [+]feat(daemon): add tiered health, backup, alerts, maintenance[/+] on May 6, 2026
  7. Sinity commented on May 6, 2026

    @Sinity
    OwnerAuthor

    Execution supplement

    Mass-execution wave: #852 Wave 2 after #829 and coordinated with #845/#844 status fields.

    Focused verification:

    • daemon health/status tests for each tier and degraded reason;
    • backup/maintenance/alert dry-run tests with no destructive action by default;
    • status/API/CLI contract tests proving the same health model reaches surfaces;
    • devtools verify --quick, then full devtools verify before PR.

    Keep this issue operational; embedding work stays in #828 and raw failure taxonomy stays in #844.

  8. Sinity commented on May 7, 2026

    @Sinity
    OwnerAuthor

    Gap-audit adjacent operations issues

    New issues now split adjacent responsibilities:

    Interpretation for #830: keep this issue on tiered health, backup, alerts, and maintenance visibility. It should expose the status/alert vocabulary that #871/#869 consume, but not become the whole planner/onboarding/security/performance issue.

    Refs #871 #869 #868 #872 #852.

  9. reopened this on May 7, 2026
  10. 10 remaining items

  11. Sinity commented on May 9, 2026

    @Sinity
    OwnerAuthor

    Tracker filed at #999 — health-check tests, non-log notification backends, and restore-roundtrip backup tests carried forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:daemontheme:operationstype:feat

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions