/** * Execution history for scheduled jobs. * * Two backends, selected at runtime: * - JSONL (default): per-photon append-only log at * `{PHOTON_DIR}/.data/{photon}/schedules/executions.jsonl` * with size rotation (10MB → .1.jsonl … .3.jsonl) and boot-time TTL sweep. * - SQLite (opt-in via initExecutionHistorySqlite): single shared DB with * indexed queries. Recommended when `photon ps history` is queried often * or the daemon keeps many photons (linear full-file scans add up). * * Writes are best-effort: failures never propagate to callers of * recordExecution — an audit log that crashes scheduled jobs is worse than * a missing audit log. */ import type { ExecutionHistoryBackend } from './execution-history-sqlite.js'; export type ExecutionStatus = 'success' | 'error' | 'timeout'; export interface ExecutionEntry { /** Unix epoch ms when the job completed (or failed). */ ts: number; jobId: string; method: string; durationMs: number; status: ExecutionStatus; errorMessage?: string; /** Short JSON serialization of the return value (capped). */ outputPreview?: string; } export interface HistoryQuery { method?: string; limit?: number; sinceTs?: number; } /** Absolute path to a photon's executions.jsonl under the Option B layout. */ export declare function executionsFile(photonName: string, workingDir?: string): string; /** * Upgrade the execution-history writer to a SQLite backend. Call once at * daemon startup; safe to call more than once. The default path lives next * to the per-photon .data directories so existing deployments can keep * both representations alongside during migration. */ export declare function initExecutionHistorySqlite(opts: { path: string; ttlMs?: number; maxPerMethod?: number; }): Promise; /** Swap the SQLite backend for tests or custom providers. */ export declare function setExecutionHistoryBackend(backend: ExecutionHistoryBackend | null): void; /** Expose the active backend for sweep + query helpers. */ export declare function getExecutionHistoryBackend(): ExecutionHistoryBackend | null; /** * Append a single entry; rotate if the current file has crossed MAX_FILE_SIZE. * Never throws. */ export declare function recordExecution(photonName: string, entry: ExecutionEntry, workingDir?: string): void; /** Return entries matching the query, newest first. */ export declare function readExecutionHistory(photonName: string, query?: HistoryQuery, workingDir?: string): ExecutionEntry[]; /** * Apply TTL + per-method cap to one file. Writes only if anything was * dropped. Safe to call at boot per base. */ export declare function sweepExecutions(file: string, now?: number): void; /** * Sweep every photon's executions.jsonl under each listed base. Intended to * run once at daemon startup, after the bases registry is loaded. */ export declare function sweepAllBases(bases: string[], now?: number): void; /** Compact serialization of a tool return value, capped at OUTPUT_PREVIEW_MAX. */ export declare function previewResult(value: unknown): string | undefined; /** Internal constants exported for tests. */ export declare const __test__: { MAX_FILE_SIZE: number; MAX_ROTATED_FILES: number; TTL_MS: number; MAX_ENTRIES_PER_METHOD: number; OUTPUT_PREVIEW_MAX: number; }; //# sourceMappingURL=execution-history.d.ts.map