/** * peaks-cli v2.13.3 — Envelope unification (AC-1: real markdown parse). * * The 5 input envelopes feeding `aggregateVerdict()` have always been * heterogeneous (peaks-security-audit / peaks-perf-audit / karpathy / * peaks-mut / peaks-qa). v2.13.1 shipped precedence wiring without * touching the on-disk shapes. v2.13.2 introduced a discriminated-union * type projection `AnyEnvelope` and 5 pure parser functions. * * v2.13.3 dogfood bug #1: parseSecurity/Perf previously only supported * a JSON.parse path. The real v2.12.0 audit files at * `.peaks/_runtime//audit/security.md` and `audit/perf.md` are * YAML frontmatter + markdown body — NOT JSON. The fix preserves * the JSON.parse path (back-compat for unit tests + any consumer that * passed JSON explicitly) and adds a markdown fallback that extracts * `verdict:` from the frontmatter and parses `## Findings` bullets. * * Karpathy §2 (Simplicity First): * - single file, ~210 lines, zero new IO. * - re-uses existing strict-shape guards (isSecurityAuditEnvelope / * isPerfAuditEnvelope) — no duplicate validation logic. * - parsers return `null` on malformed input (mirrors loadMutReport's * "missing → null" contract). Callers can detect "envelope missing" * without throwing. */ import { type SecurityAuditEnvelope } from '../audit-independent/security-audit-service.js'; import { type PerfAuditEnvelope } from '../audit-independent/perf-audit-service.js'; import { type KarpathyEnvelope, type MutEnvelope, type QaEnvelope, type AggregatorInput } from './verdict-aggregator.js'; /** * `kind` is the discriminator. The on-disk file format is unchanged; * this field exists only in the TS type projection. The aggregator * accepts both the legacy `{security, perf, ...}` shape and the new * union via a thin adapter (`aggregateFromEnvelopes`). */ export type AnyEnvelope = { kind: 'security'; envelope: SecurityAuditEnvelope; } | { kind: 'perf'; envelope: PerfAuditEnvelope; } | { kind: 'karpathy'; envelope: KarpathyEnvelope; } | { kind: 'mut'; envelope: MutEnvelope; } | { kind: 'qa'; envelope: QaEnvelope; }; /** * v2.13.3 AC-1 — parse real v2.12.0 audit markdown. * * Strategy (per PRD AC-1 mitigation): * 1. Try JSON.parse first (back-compat with prior unit tests + any * consumer that passes a JSON string explicitly). * 2. Fall back to markdown parse: extract `verdict:` from YAML * frontmatter, parse `## Findings` bullets in the body, return * a SecurityAuditEnvelope. * 3. Return null when neither path yields a valid envelope. */ export declare function parseSecurityEnvelope(md: string): SecurityAuditEnvelope | null; export declare function parsePerfEnvelope(md: string): PerfAuditEnvelope | null; /** * Karpathy review is stored as markdown (`.peaks/_runtime//rd/karpathy-review.md`). * We parse the 3 state lines that drive the aggregator: * - `gateAction: pass | warn | block` * - `verdict: pass | warn | block` (alias for gateAction) * - `passed: true | false` * Plus the violations list under a `## Violations` heading, where each * bullet begins with `[SEVERITY] file:line — hint` and declares a * guideline tag like `(simplicity-first)`. */ export declare function parseKarpathyEnvelope(md: string): KarpathyEnvelope | null; /** * Mut envelope is JSON. Mirrors `loadMutReport`'s contract: missing * fields → null. The strict shape matches `MutReportJson` in * `services/mut/types.ts`. */ export declare function parseMutEnvelope(json: unknown): MutEnvelope | null; /** * QA test report is markdown under `qa/test-reports/.md`. * The verdict line is `verdict: pass | return-to-rd | blocked` and * optionally carries a `reportPath:` line. Anything else → null. */ export declare function parseQaEnvelope(md: string): QaEnvelope | null; /** * Convert a partial list of `AnyEnvelope` values to the legacy * `AggregatorInput` shape. `null` envelopes are skipped (a missing * envelope is treated as "audit not run" — same semantics as * `AggregatorInput` without that key). */ export declare function envelopesToAggregatorInput(list: ReadonlyArray): AggregatorInput;