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:
@@ -193,6 +193,16 @@ func Open(path string) (*KnoxDB, error) {
|
||||
"ALTER TABLE threads ADD COLUMN superseded_by TEXT",
|
||||
"ALTER TABLE snippets ADD COLUMN junk INTEGER DEFAULT 0",
|
||||
"ALTER TABLE snippets ADD COLUMN kind TEXT DEFAULT 'code'",
|
||||
// Per-source sync health (issue #54). The columns are declared in
|
||||
// schema.sql too, so these only matter for databases opened before
|
||||
// the change.
|
||||
"ALTER TABLE sources ADD COLUMN status TEXT DEFAULT ''",
|
||||
"ALTER TABLE sources ADD COLUMN last_attempt_at TEXT DEFAULT ''",
|
||||
"ALTER TABLE sources ADD COLUMN last_success_at TEXT DEFAULT ''",
|
||||
"ALTER TABLE sources ADD COLUMN last_error_at TEXT DEFAULT ''",
|
||||
"ALTER TABLE sources ADD COLUMN last_error TEXT DEFAULT ''",
|
||||
"ALTER TABLE sources ADD COLUMN last_counts TEXT DEFAULT ''",
|
||||
"ALTER TABLE sources ADD COLUMN interval_seconds INTEGER DEFAULT 0",
|
||||
}
|
||||
for _, m := range migrations {
|
||||
if _, err := db.Exec(m); err != nil && !strings.Contains(err.Error(), "duplicate column") {
|
||||
|
||||
Reference in New Issue
Block a user