/** * JSONL append-only store for observability events. * * Slice A of v2.11.1 (slice topology observability). Pure file I/O — * no schema knowledge lives here. Schema/validation lives in * `observability-service.ts`. * * Layout: `.peaks/_runtime//metrics/slices.jsonl` — one file * per session, append-only. Mtime-based cross-session prune keeps at * most `MAX_METRICS_FILES` files in the repo (mirrors the * `peaks session checkpoint` contract). * * Write path is fire-and-forget: errors (disk full, permission * denied, ENOENT mid-write) are swallowed silently per PRD Q4 * (full-auto must never fail-loud on observability). */ export declare const METRICS_DIR = "metrics"; export declare const METRICS_FILENAME = "slices.jsonl"; export declare const MAX_METRICS_FILES = 10; /** Absolute path to a session's metrics JSONL file. */ export declare function metricsFilePath(projectRoot: string, sessionId: string): string; /** Absolute path to a session's metrics directory. */ export declare function metricsDirPath(projectRoot: string, sessionId: string): string; /** * Absolute path to a session's metrics JSONL file, or `null` when the * session id names no session directory. * * Total sibling of `metricsFilePath`, built on the axis's own total * entry (`tryGetSessionDir`) so the two agree on the predicate. It * exists because this module has frames whose contract is never-throws * (`readMetricLines`, and through it `readObservabilityEvents`) and * `metricsFilePath` was the one call in them that could still throw. * `null` here means exactly one thing — the id could not be resolved — * and every caller below handles it in the same statement that reads it. */ export declare function tryMetricsFilePath(projectRoot: string, sessionId: string): string | null; /** * Append one line to the session's metrics JSONL file. Creates the * directory tree on demand. Returns true on success, false on any * error (the caller MUST treat false as "drop silently" per Q4). */ export declare function appendMetricLine(projectRoot: string, sessionId: string, line: string): boolean; /** * Read all non-empty lines from a session's metrics JSONL file. * Returns [] when the file does not exist. Does NOT parse — callers * decide what counts as valid (see `observability-service.ts` * `readObservabilityEvents` for the schema-aware reader). * * Returns [] for an unresolvable session id too: this is the read half * of a fire-and-forget store, and `readObservabilityEvents` documents * that a session with no readable metrics file has no events. Throwing * here used to escape as a raw guard error out of a documented * never-throws reader (repair R6). */ export declare function readMetricLines(projectRoot: string, sessionId: string): string[]; export type SessionMetricsEntry = { sessionId: string; mtimeMs: number; path: string; }; /** * List every session that currently has a metrics JSONL on disk, * paired with its mtime. Ordered by sessionId for determinism; the * caller decides mtime ordering (see `pruneMetricsFiles`). */ export declare function listSessionDirsWithMetrics(projectRoot: string): SessionMetricsEntry[]; /** * Prune the metrics files across all sessions, retaining at most * `MAX_METRICS_FILES` by mtime (newest kept). Returns the list of * removed absolute paths. Best-effort: a failed removal is silently * skipped (matches Q4 fire-and-forget contract). */ export declare function pruneMetricsFiles(projectRoot: string): string[]; export declare const JSONL_STORE_CONSTANTS: { readonly METRICS_DIR: "metrics"; readonly METRICS_FILENAME: "slices.jsonl"; readonly MAX_METRICS_FILES: 10; };