/** * CHOICE COST — the human layer. * ============================== * * Three layers, not two: * * ANALYSIS src/analysis/choice-cost.ts — what the sites are and what they cost. * POLICY bench/choice-cost-guard.ts — which of those numbers fail a build. * RENDERING this file — how a person reads either of them. * * The structured report is the source of truth. Nothing here computes a finding, and * nothing here decides pass or fail; a gate consumes the data and never this text. If * a number appears below that is not in the report, that is a bug in this file. * * WHAT A PARSER GENERATOR CAN SHOW THAT A COMPILER CANNOT * ------------------------------------------------------- * A type error has one source to point at. A wasted-work finding has TWO, and relating * them is the whole diagnostic: * * - the GRAMMAR site — the ordered choice whose arm ordering costs the time * - the COST — measured, over a real corpus, per alternative * * So the ordering is printed WITH its measured cost beside each arm, which makes the * fix self-evident without a paragraph explaining it: * * StylesheetAtRule › dispatch[0] 1.31 MB rescanned * 0 RoutedAtRuleStatement failed 4,182 / 4,271 1.31 MB * 1 RoutedLayerBlock matched 4,182 * * Reading that, nobody needs to be told what to do. * * QUIET BY DEFAULT * ---------------- * Nothing in this module prints. It returns strings. There is no console call and no * process-wide default-on channel, deliberately: importing `examples/css/parser.ts` * already emits roughly sixty lines of gating advice before any user code runs, and a * beautiful diagnostic that nobody reads because it is buried in build noise is not * beautiful. This one is available on request — from the CLI gate, or by calling it — * and silent otherwise. * * DETERMINISM BINDS THE RENDERING TOO * ----------------------------------- * The rendering is diffable: it preserves the report's ordering, contains no timings, * no dates, no absolute paths, and colour is opt-in rather than auto-detected, so the * same report always renders to the same bytes. A renderer that sniffed `isTTY` would * produce two different outputs from one report and break exactly that. */ import type { ChoiceInventoryReport, ChoiceInventoryEntry, WastedWorkReport } from './choice-cost.ts'; import { groupDigits } from './format-number.ts'; export type RenderOptions = { /** Rows to show. Default 20. The report always holds all of them. */ limit?: number; /** * ANSI colour. Default false — NOT auto-detected from `isTTY`, because a renderer * whose bytes depend on where it is piped cannot be diffed or snapshotted. */ color?: boolean; }; /** * Deterministic thousands grouping. `toLocaleString()` is locale-dependent and * would make the output differ between machines — the one thing a gateable * rendering cannot do. * * DEFINED IN `./format-number.ts` and re-exported here because this module's own * callers import it from here. It was a byte-identical second copy: `./terminal.ts` * declared one, this file declared another, and the two were one edit away from * disagreeing about how a report reads on two different screens. */ export { groupDigits }; /** Byte counts at a glance. Binary units, fixed to one decimal, so 1,376,256 renders * as `1.3 MB` on every machine. */ export declare function bytes(n: number): string; /** * The combinator source a left-factoring would produce, ready to paste. * * Offered ONLY for the shape where it is mechanical and total: every arm of the choice * in one group. A partial group needs the author to decide which arms move and in what * order — an ordering decision that changes what the grammar accepts, which no * generated rewrite may make silently. * * This is a PREVIEW. It is not applied, and — until the digest-verification loop * described in `docs/` is wired — it is not yet proven behaviour-preserving, so it is * labelled a candidate rather than offered as a fix. An unverified rewrite presented * as verified is worse than no suggestion at all. */ export declare function leftFactorPreview(e: ChoiceInventoryEntry): string | null; export declare function renderChoiceInventory(r: ChoiceInventoryReport, opts?: RenderOptions): string; /** * The ranked list, with each top site expanded into its arm ordering. * * The expansion is the point. A ranked list of site keys tells you WHERE; the arm * breakdown beside it tells you WHY, and "arm 0 failed 4,182 of 4,271 times" is an * argument for moving arm 0 that needs no prose attached. */ export declare function renderWastedWork(r: WastedWorkReport, opts?: RenderOptions): string; //# sourceMappingURL=choice-cost-render.d.ts.map