import type { Clock, JournalKind, KernelPaths, MonitorRecord, RunRecord, TaskRecord } from "./types.js"; export declare function canonicalViewBytes(value: unknown): string; export declare function viewsEqual(a: unknown, b: unknown): boolean; /** Reconstruct complete run view from journal (last next_run wins). */ export declare function replayRunView(paths: KernelPaths, runId: string): RunRecord | null; /** Reconstruct complete task views from journal (last next_task per task_id). */ export declare function replayTaskViews(paths: KernelPaths, runId: string): TaskRecord[]; export declare function replayTaskView(paths: KernelPaths, runId: string, taskId: string): TaskRecord | null; export declare function replayMonitorView(paths: KernelPaths, runId: string): MonitorRecord | null; /** Per-run task projection path — old runs never share files with a new campaign. */ export declare function taskProjectionPath(paths: KernelPaths, runId: string, taskId: string): string; /** * Resolve active run id from **journal authority first**. * - Exactly one non-terminal journaled run wins. * - More than one non-terminal run fails closed. * - When all are terminal, pick deterministically by journaled started_at then run_id. * - Disk is never preferred over journal (avoids stale-old-disk masking a new start). */ export declare function resolveActiveRunId(paths: KernelPaths): string | null; /** Goal text from journal (first goal_text payload), never untrusted disk alone. */ export declare function replayGoalText(paths: KernelPaths, runId: string): string | null; /** * Load complete run view from journal under lock. Repairs stale/missing run.json. * Disk summaries are never treated as authority for mutation CAS. */ export declare function loadAuthoritativeRunUnlocked(paths: KernelPaths): RunRecord | null; /** * Load complete task view from journal. Repairs stale/missing task projection. * Returns null if the task was never journaled. */ export declare function loadAuthoritativeTaskUnlocked(paths: KernelPaths, runId: string, taskId: string): TaskRecord | null; /** * Load complete monitor view from the active run's journal only. * Stale disk projections are repaired from journal. No disk-only authority. * Returns null when the active run has never journaled a monitor view. */ export declare function loadAuthoritativeMonitorUnlocked(paths: KernelPaths): MonitorRecord | null; interface PrivateRunCommit { readonly paths: KernelPaths; readonly clock: Clock; readonly runId: string; readonly kind: JournalKind; readonly expectedVersion: number | null; readonly operationId?: string; readonly next: RunRecord; readonly extraPayload?: Readonly>; readonly goalText?: string; readonly projectGoal?: boolean; readonly archive?: { readonly previousRunId: string; readonly previousGoalText: string | null; readonly previousRun: RunRecord; }; } export interface RunMutationInput { readonly paths: KernelPaths; readonly clock: Clock; readonly kind: JournalKind; /** CAS against journal-replayed version; null only for genesis start. */ readonly expectedVersion: number | null; readonly operationId?: string; readonly extraPayload?: Readonly>; readonly goalText?: string; readonly projectGoal?: boolean; readonly archive?: PrivateRunCommit["archive"]; /** * Build the complete next view from the authoritative current view. * For genesis (no current), expectedVersion must be null. */ readonly buildNext: (current: RunRecord | null) => RunRecord; } /** * Mutate run under an existing kernel lock: journal-first load, CAS, append, project. * Call only while holding the kernel lock. */ export declare function mutateRunUnlocked(input: RunMutationInput): RunRecord; export interface TaskMutationInput { readonly paths: KernelPaths; readonly clock: Clock; readonly runId: string; readonly taskId: string; readonly kind: JournalKind; /** null only for first claim (genesis). */ readonly expectedVersion: number | null; readonly operationId?: string; readonly extraPayload?: Readonly>; readonly buildNext: (current: TaskRecord | null) => TaskRecord; } /** * Mutate task under an existing kernel lock: journal-first load, CAS, append, project. */ export declare function mutateTaskUnlocked(input: TaskMutationInput): TaskRecord; /** * Terminal-only under-lock task_activity with exact proof (7A.3C §B). * Not a general mutation option — sole path that binds next.updated_at to journal recorded_at * and builds extra payload from the real next task. */ export declare function appendTerminalTaskActivityUnlocked(input: { readonly paths: KernelPaths; readonly clock: Clock; readonly runId: string; readonly taskId: string; readonly expectedVersion: number; readonly operationId: string; readonly buildNext: (current: TaskRecord, recordedAt: string) => TaskRecord; /** Must not set next_task or task_id. Receives the real frozen next (with bound updated_at). */ readonly buildTerminalExtra: (nextTask: TaskRecord) => Readonly>; }): TaskRecord; export interface MonitorMutationInput { readonly paths: KernelPaths; readonly clock: Clock; readonly kind: JournalKind; readonly operationId?: string; readonly extraPayload?: Readonly>; readonly expectedGeneration?: number; readonly buildNext: (current: MonitorRecord | null) => MonitorRecord; } /** * Mutate monitor under an existing kernel lock: journal-first load when possible, * optional generation CAS, append when run exists, project. */ export declare function mutateMonitorUnlocked(input: MonitorMutationInput): MonitorRecord; export declare function nowIso(clock: Clock): string; export declare function nextOperationId(prefix: string, ...parts: string[]): string; /** Rebuild projections from journal after crash (idempotent). */ export declare function repairProjectionsFromJournal(paths: KernelPaths, runId: string): { readonly run: RunRecord | null; readonly tasks: readonly TaskRecord[]; }; export {};