/** * Audit decision writer — Slice K1. * * Persists a `RedLineAudit` snapshot to `.peaks/memory/audit-decisions/.md` * so the audit is searchable / indexable by the existing project-memory * machinery (`peaks memory search`, `peaks project memories`). * * Locked decisions (K1 design, user-approved): * * 1. **No `context` field** in the persisted record. `RedLineSource.context` * is the ±2 lines of raw markdown used only by `backing-detector.ts` * (`detectPartial(entry.source.context)`) to classify the entry as * partial / cli-backed / prose-only. It is an *intermediate artifact* — * once the audit runs, the classification result is captured by * `RedLineEntry.backing` and the raw context has no consumer. We * intentionally do not write `context` to the decision record (no * caller reads it; persisting it would just bloat the file). * * 2. **Path is `.peaks/memory/audit-decisions/`, NOT `_runtime/`** — the * decision is git-tracked source-of-truth (project memory), not session * ephemeral state. The subdir is named for human discoverability; the * memory service's recursive scan picks it up automatically. * * 3. **No new CLI subcommand.** Per `peaks-loop-when-adding-a-new-subcommand-…` * we extend the existing `peaks audit static` with a `--record` flag * instead of adding `peaks audit record` (which would be a new * top-level shape and conflict with the dev-preference red line * "Default-no on new CLI commands"). * * 4. **Memory index auto-regen.** Writing the file does not directly * manipulate `.peaks/memory/index.json`. The `peaks project memories` * reader uses mtime-based regeneration; the new file's mtime being * newer than `index.json` triggers regeneration on next read. * `readMemoryIndex()` is called eagerly here so the caller sees a * `hot.decision[]` update synchronously with the write. */ import type { RedLineAudit } from './types.js'; export interface AuditDecisionOptions { readonly projectRoot: string; /** ISO date (YYYY-MM-DD). Defaults to today (UTC). */ readonly date?: string; /** Optional request id, used to disambiguate multiple audits on the same day. */ readonly rid?: string; } export interface AuditDecisionRecord { readonly name: string; readonly title: string; readonly date: string; readonly filePath: string; readonly memoryDir: string; readonly indexPath: string; readonly totalRedLines: number; readonly cliBacked: number; readonly partial: number; readonly proseOnly: number; readonly enforcerFailures: number; readonly enforcerWarnings: number; readonly enforcerPasses: number; readonly indexSynced: boolean; } /** * Pure: render the decision markdown body. No I/O. Used by both the * writer and the test suite for byte-exact assertions. */ export declare function renderDecisionMarkdown(audit: RedLineAudit, options: { date: string; rid?: string; }): string; /** * Persist the audit as a project-memory decision. Idempotent only at the * file level — repeated calls with the same `(date, rid)` pair will overwrite * the previous decision markdown (the slug collides, the older file is * replaced). This matches the "one audit run = one decision record" model. */ export declare function writeAuditDecision(audit: RedLineAudit, options: AuditDecisionOptions): AuditDecisionRecord; export { writeDecision } from './artifact-writer.js';