/** * Per-run observability for pipeline job handlers (FEAT-495 item 4a). * * One row per `handler.handle()` INVOCATION (not per job-repo state * transition — a job that gets retried across attempts records one row per * attempt, matching what actually executed). Written by src/pipeline/ * worker.ts at each terminal branch of its tick loop. Distinct from * job-repo.ts's `jobs` table, which tracks CURRENT state per job row (one * row per job, mutated in place) — this table is a history of executions, * so a handler that's been invoked 500 times shows 500 rows even though the * underlying job count may be far smaller (retries) or larger (jobs whose * handler was never registered never reach here at all — see worker.ts's * "No handler registered" branch, which does NOT call recordHandlerRun, * since the handler itself never ran). */ import type { DB } from './db.js'; export type HandlerRunStatus = 'success' | 'failed' | 'paused'; export interface HandlerRunRecord { handler: string; status: HandlerRunStatus; durationMs: number; errorType?: string | null; errorMessage?: string | null; } /** Append one row. Called once per handler.handle() invocation that actually ran (see file header). */ export declare function recordHandlerRun(db: DB, rec: HandlerRunRecord, createdAt?: number): void; export interface HandlerRunSummary { handler: string; lastStatus: HandlerRunStatus; lastRunAt: number; lastDurationMs: number; lastErrorType: string | null; lastErrorMessage: string | null; totalRuns: number; totalFailed: number; } /** * One summary row per DISTINCT handler that has ever run, most-recently-run * first. Empty when handler_runs has no rows yet (nothing has ever been * dispatched to a handler this way, or the daemon just started). */ export declare function summarizeHandlerRuns(db: DB): HandlerRunSummary[];