feat: per-source sync status (#54)
Ingest sweeps reported outcome only to the log: a failing sweep, or one that silently no-ops because its env config is missing, was invisible from the CLI/MCP surface. Extend the (previously dead) sources registry table with per-source sweep state and expose it. - db: RecordSync upserts one outcome per sweep (status ok/error/unconfigured, timestamps kept monotonic, last success survives a later failure); the columns are declared in schema.sql and added by migration for existing DBs. - db: SourceSync reads sweep state joined with derived per-source counts from observations, and computes a verdict: ok, stale (>2.5x interval since last success), error, unconfigured, never. - watch: record every sweep of browser-history, gitea, git, opencode-session, karakeep, bookorbit and brevier — including failures and not-configured no-ops, which are exactly the invisible cases. - cmd: knox sync-status [--json] and the knox_sync_status MCP tool. Motivating case: this node's watch container has no KARAKEEP_URL/API_KEY, so its karakeep ingester was a permanent silent no-op.
This commit is contained in:
+20
-2
@@ -94,19 +94,37 @@ CREATE TABLE IF NOT EXISTS sessions (
|
||||
indexed INTEGER DEFAULT 0
|
||||
);
|
||||
|
||||
-- SOURCE REGISTRY
|
||||
-- SOURCE REGISTRY: also records per-source sync health. The watcher upserts
|
||||
-- one row per sweep via RecordSync — including failures and "not configured" —
|
||||
-- so ingest problems stay visible from the shared DB after restarts (and from
|
||||
-- the MCP process, which shares the file but not memory). Empty status means
|
||||
-- "no sweep recorded yet".
|
||||
CREATE TABLE IF NOT EXISTS sources (
|
||||
id TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
enabled INTEGER DEFAULT 1,
|
||||
last_event TEXT,
|
||||
created_at TEXT DEFAULT (datetime('now'))
|
||||
created_at TEXT DEFAULT (datetime('now')),
|
||||
status TEXT DEFAULT '',
|
||||
last_attempt_at TEXT DEFAULT '',
|
||||
last_success_at TEXT DEFAULT '',
|
||||
last_error_at TEXT DEFAULT '',
|
||||
last_error TEXT DEFAULT '',
|
||||
last_counts TEXT DEFAULT '',
|
||||
interval_seconds INTEGER DEFAULT 0
|
||||
);
|
||||
|
||||
INSERT OR IGNORE INTO sources (id, name) VALUES ('opencode-session', 'Opencode Session Diffs');
|
||||
INSERT OR IGNORE INTO sources (id, name) VALUES ('opencode-log', 'Opencode Log Files');
|
||||
INSERT OR IGNORE INTO sources (id, name) VALUES ('git', 'Git History');
|
||||
INSERT OR IGNORE INTO sources (id, name) VALUES ('filesystem', 'File System Watcher');
|
||||
INSERT OR IGNORE INTO sources (id, name) VALUES ('browser-history', 'Browser History');
|
||||
INSERT OR IGNORE INTO sources (id, name) VALUES ('gitea', 'Gitea Activity');
|
||||
INSERT OR IGNORE INTO sources (id, name) VALUES ('karakeep', 'Karakeep Bookmarks');
|
||||
INSERT OR IGNORE INTO sources (id, name) VALUES ('bookorbit', 'BookOrbit Highlights');
|
||||
INSERT OR IGNORE INTO sources (id, name) VALUES ('brevier', 'Brevier Reading Archive');
|
||||
INSERT OR IGNORE INTO sources (id, name) VALUES ('obsidian', 'Obsidian Vault');
|
||||
INSERT OR IGNORE INTO sources (id, name) VALUES ('skills-catalog', 'Skills Catalog');
|
||||
|
||||
-- KNOWLEDGE THREADS: why observations exist, what questions they answer
|
||||
CREATE TABLE IF NOT EXISTS threads (
|
||||
|
||||
Reference in New Issue
Block a user