feat: per-source sync status (persisted sweep state + knox sync-status + knox_sync_status MCP tool) #54

Closed
opened 2026-11-17 07:34:08 +00:00 by david · 1 comment
Owner

Problem

Ingest sweeps (browser, gitea, git, opencode sessions, karakeep, bookorbit, brevier) report outcome only to the log. A sweep that fails, or that silently does nothing because its env config is missing, is invisible from the MCP/CLI surface.

Concrete case found today: the knox watch container has no KARAKEEP_URL/KARAKEEP_API_KEY, so KarakeepIngester.IngestAll() is a silent no-op — the karakeep scope in the index has zero entries and nothing indicates why.

The existing sources registry table is dead weight: seeded once, never read or updated.

Proposal

  1. Persist sweep state in the sources table (extend it):
    status (ok|error|unconfigured), last_attempt_at, last_success_at, last_error_at, last_error, last_counts (JSON: new/updated/unchanged/scanned), interval_seconds.
    The watcher records after every sweep — including errors and "not configured".
  2. Status read API in internal/db: per-source status joined with derived per-source stats from observations (distinct fingerprints, MAX(collected_at)), plus a staleness verdict (last success older than ~2.5x interval → stale; error newer than success → failing; no row → never ran).
  3. Surfaces: knox sync-status [--json] CLI command and a knox_sync_status MCP tool.

Out of scope: Prometheus per-source gauges (metrics port already exists — follow-up if wanted).

## Problem Ingest sweeps (browser, gitea, git, opencode sessions, karakeep, bookorbit, brevier) report outcome **only to the log**. A sweep that fails, or that silently does nothing because its env config is missing, is invisible from the MCP/CLI surface. Concrete case found today: the `knox watch` container has **no** `KARAKEEP_URL`/`KARAKEEP_API_KEY`, so `KarakeepIngester.IngestAll()` is a silent no-op — the `karakeep` scope in the index has zero entries and nothing indicates why. The existing `sources` registry table is dead weight: seeded once, never read or updated. ## Proposal 1. **Persist sweep state** in the `sources` table (extend it): `status` (ok|error|unconfigured), `last_attempt_at`, `last_success_at`, `last_error_at`, `last_error`, `last_counts` (JSON: new/updated/unchanged/scanned), `interval_seconds`. The watcher records after every sweep — including errors and "not configured". 2. **Status read API** in `internal/db`: per-source status joined with derived per-source stats from `observations` (distinct fingerprints, MAX(collected_at)), plus a staleness verdict (last success older than ~2.5x interval → stale; error newer than success → failing; no row → never ran). 3. **Surfaces**: `knox sync-status [--json]` CLI command and a `knox_sync_status` MCP tool. Out of scope: Prometheus per-source gauges (metrics port already exists — follow-up if wanted).
Author
Owner

Implemented in 65fdcbc and deployed: CI green, casaos replica containers rolled via the workflow restart step (both healthy), laptop origin binary rebuilt and the knox user service restarted.

Verified live: knox sync-status shows opencode-session and browser-history recording ok sweeps with their intervals; remaining tickers (gitea/git 10m, karakeep/bookorbit 30m) fill in on their next fire.

Implemented in 65fdcbc and deployed: CI green, casaos replica containers rolled via the workflow restart step (both healthy), laptop origin binary rebuilt and the knox user service restarted. Verified live: `knox sync-status` shows opencode-session and browser-history recording ok sweeps with their intervals; remaining tickers (gitea/git 10m, karakeep/bookorbit 30m) fill in on their next fire.
david closed this issue 2026-11-17 07:59:25 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: david/knox#54