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,20 @@ func NewMCPServer(kdb *db.KnoxDB) *mcp.Server {
|
||||
return textResult(string(b)), nil, nil
|
||||
})
|
||||
|
||||
// ─── knox_sync_status ──────────────────────────────────────
|
||||
type syncStatusInput struct{}
|
||||
|
||||
mcp.AddTool(s, &mcp.Tool{Name: "knox_sync_status", Description: "Per-source ingest sync health: last sweep per source, staleness vs its interval, errors, and unconfigured (env missing) sources."},
|
||||
|
||||
func(ctx context.Context, req *mcp.CallToolRequest, in syncStatusInput) (*mcp.CallToolResult, any, error) {
|
||||
rows, err := kdb.SourceSync()
|
||||
if err != nil {
|
||||
return toolError(err.Error()), nil, nil
|
||||
}
|
||||
b, _ := json.MarshalIndent(rows, "", " ")
|
||||
return textResult(string(b)), nil, nil
|
||||
})
|
||||
|
||||
// ─── knox_count ────────────────────────────────────────────
|
||||
type countInput struct {
|
||||
Query string `json:"query,omitempty" jsonschema:"Search query"`
|
||||
|
||||
Reference in New Issue
Block a user