/** * The append-only RUN LEDGER — one row per `aih` invocation in * `.aih/runs/YYYY-MM.jsonl`. This is the "what happened" half of the * Supportability Pack, distinct from `.aih/history.jsonl` (PR2 of the report * trends), which is a deterministic, byte-stable metrics snapshot PER COMMIT. * * The ledger is the OPPOSITE: wall-clock, non-deterministic, append-only, and * written OUTSIDE the plan's `FsTransaction` (no idempotency, no `.aih.bak`). It * is local diagnostics — `.aih/` is gitignored — so it never touches the managed * project surface and never needs `--apply`. * * Trust model: log only once a repo is initialised (a committed `.aih-config.json` * marker exists), and never when the operator opts out (`--no-log` / `AIH_LOG=0`). * Writing must NEVER fail the command — {@link appendRunLog} swallows its own I/O * errors. Entry assembly ({@link buildRunEntry}) is separated from the append; raw * ledger files are local diagnostics, while tamper evidence/integrity comes from * packaging them with `aih evidence build`. */ import type { PlanResult } from "../internals/execute.js"; import type { Verdict } from "../internals/verify.js"; export declare const RUNS_DIR: string; /** How the run ended, mapped from the exit signals (see {@link statusFor}). */ export type RunStatus = "success" | "failed" | "partial" | "error"; /** Tally of plan write effects (mirrors {@link WriteSummary.effect}). */ export interface WriteTally { create: number; overwrite: number; merge: number; unchanged: number; kept: number; } export interface RunLogEntry { schemaVersion: 2; runId: string; startedAt: string; finishedAt: string; durationMs: number; capability: string; /** The invoking argv, redacted by the caller. */ argv: string[]; status: RunStatus; exitCode: number; mode: { apply: boolean; verify: boolean; json: boolean; sarif: boolean; }; platform: string; node: string; host: { platform: string; hostnameHash: string; }; repo: { remoteHash: string; }; writes: WriteTally; docs: number; execs: number; digests: number; backups: number; /** Verification counts, when probes ran. */ verification?: Record; /** Support-template counts, when a verification report produced findings. */ support?: { findings: number; templates: number; }; } /** * Map the run's exit signals to a status. `error` is a thrown exception (set by * the caller); otherwise: a failed probe → `failed`; a failed exec with probes * clean → `partial`; else `success`. Mirrors runCapability's exit-code logic. */ export declare function statusFor(verifyFailed: boolean, execFailed: boolean): RunStatus; export interface RunEntryInput { runId: string; startedAt: string; finishedAt: string; capability: string; argv: string[]; status: RunStatus; exitCode: number; mode: { apply: boolean; verify: boolean; json: boolean; sarif: boolean; }; platform: string; node: string; root?: string; /** The plan result, when one was produced (absent on a thrown error). */ result?: PlanResult; support?: { findings: number; templates: number; }; } /** Assemble a {@link RunLogEntry} from a run's inputs. No clock; repo identity is hashed. */ export declare function buildRunEntry(input: RunEntryInput): RunLogEntry; /** * Is run logging enabled for this root? Only after the repo is initialised (a * committed `.aih-config.json` marker), and never when opted out via `--no-log` * or `AIH_LOG=0`. No CI special-case — a CI job that wants silence sets `AIH_LOG=0`. */ export declare function isLoggingEnabled(root: string, env: NodeJS.ProcessEnv, opts: { noLog?: boolean; }): boolean; /** Month-sharded ledger filename for `date` (UTC), e.g. `2026-06.jsonl`. */ export declare function monthFile(date: Date): string; /** * Append one entry to `.aih/runs/YYYY-MM.jsonl` under `root`. Pure append (no * read, no dedup), outside any transaction. Swallows all I/O errors — a logging * failure must never change the command's outcome. */ export declare function appendRunLog(root: string, entry: RunLogEntry, date: Date): void;