/** * IR-semantics doc generator — Phase 1 PR-5a. * * Walks `CONTRACT_REGISTRY` and serialises each entry to either machine- * readable JSON (for Sight / external tooling) or human-readable Markdown * (for `pnpm docs:contracts` and CI job summaries). * * Council guidance applied: * - Compact JSON: never inline all fixtures. Per-contract entry carries * fixture count + 2 representative samples. Full fixture inlining * would make the committed registry.json a multi-KB churn magnet. * - Deterministic ordering: contracts sorted by `nodeType`, samples * picked by stable selection (first + middle) not random. * - Pure functions: takes a `Map` argument (the registry snapshot) so * tests can hand-craft a registry without mutating the global. * * Adding fields: * 1. Update `ContractDoc`/`FixtureSample` types * 2. Update `serializeContract()` to populate the new field * 3. Update `renderMarkdownContract()` to surface it * 4. Regenerate `generated/contracts/registry.json` (the drift test will * fail loudly on stale output) */ import type { NodeContract } from './index.js'; export interface FixtureSample { description: string; expectedCompletionKind: 'normal' | 'return' | 'throw' | 'break' | 'continue'; expectedEventCount: number; } export interface ContractDoc { nodeType: string; forbiddenRewrites: ReadonlyArray; fixtureCount: number; fixtureSamples: ReadonlyArray; } /** Top-level shape so consumers can verify they got the right artifact. */ export interface RegistryDoc { schemaVersion: 1; generatedBy: 'kern-ir-semantics-doc-generator'; contracts: ReadonlyArray; } /** * Snapshot the registry into a stable, deterministic shape. Sorts contracts * by `nodeType` so iteration order of `Map` (insertion order) cannot affect * the serialised output. */ export declare function snapshotRegistry(registry: ReadonlyMap): RegistryDoc; /** JSON output — pretty-printed (2-space indent) with a trailing newline so * the file is well-formed and `git diff` stays readable. */ export declare function serializeJson(registry: ReadonlyMap): string; /** Human-readable Markdown — emitted to stdout / `$GITHUB_STEP_SUMMARY`, * never written to disk in the repo. */ export declare function serializeMarkdown(registry: ReadonlyMap): string;