/** * Does this document conform, and what will it not be able to answer? * * Ten releases of arithmetic that refuses to flatter are worth more if other * tools can emit and read the same documents. That needs two things, and this * module is the second of them: the contracts are written down in `docs/`, and * an emitter needs a way to find out whether what it produces actually * satisfies one — without reading a specification and hoping. * * **Two questions, kept apart.** *Is this a valid X* is a yes or no. *What can * a valid X of this shape not tell you* is the useful one, and it has nothing * to do with validity: a usage log with no `session` field is perfectly valid * and simply cannot support conversation growth. An emitter that only learns * the first answer ships something Trazum reads and half the findings quietly * never appear. So a conforming document still comes back with a list of what * it has bought itself out of. * * **It never repairs and never guesses.** A line that will not parse is * reported at its position; a field of the wrong type is named with the type * found. Nothing is coerced — the whole point of a conformance check that a * third party runs is that it agrees with what the reader will actually do. * * **Unknown fields are not problems.** Documents here gain fields without a * version bump, and a checker that rejects tomorrow's field is a checker * nobody upgrades. Only *absent* required fields and *wrong* types fail. */ /** * The documents this project emits, and their names. * * A runtime array rather than a bare union, because the union alone cannot be * read by anything but the type checker. The CLI kept its own hand-written copy * of these names for `--contract`, and that copy stopped at `cost-answer`: the * two contracts added at 1.50.4 and 1.51.0 existed, had rules, and could not be * named. One home per fact, and this is the home. */ export declare const CONTRACT_NAMES: readonly ['usage-log', 'profile', 'fleet', 'plan', 'verification', 'history', 'connected', 'cost-answer', 'spend-guard', 'outcome-report', 'annual-record', 'roll-up', 'first-run', 'pulse', 'rule-yield', 'gateway-refusal', 'bench', 'prompt-draft', 'position', 'routing-measurement', 'example-pruning', 'store-inventory', 'conformance', 'watch-cycle']; export type ContractName = (typeof CONTRACT_NAMES)[number]; export interface ConformanceProblem { /** Where: `line 12` for a log, or a dotted path inside a document. */ at: string; kind: /** A required field is absent. */ 'missing' /** Present, and not the type the contract states. */ | 'wrong-type' /** Present as `0` where the contract requires `null` for absence. */ | 'absence-as-zero' /** The line or the document could not be parsed at all. */ | 'unreadable'; detail: string; } /** A finding a valid document of this shape simply cannot support. */ export interface UnavailableFinding { finding: string; because: string; unlockedBy: string; } export interface ConformanceReport { schemaVersion: 1; /** Which contract this looks like, or null when nothing did. */ contract: ContractName | null; /** * Why nothing matched. Present only when `contract` is null, and never a * bare "invalid": a refusal with nothing after it is indistinguishable from * a bug, which is the rule this project applies to every other refusal. */ because: string | null; problems: ConformanceProblem[]; unavailable: UnavailableFinding[]; /** Records examined, for a log. Null for a single document. */ records: number | null; conforms: boolean; } /** * The required top-level fields of a named contract, as `conform` enforces * them — the single source the JSON Schemas are held to. * * `schemaVersion` used to be left out of this list, on the reasoning that * `conform` checks it separately from `DOCUMENT_RULES`. That is true about the * implementation and false about the question the function is asked: an * emitter calling this wants to know what its document must carry, and it was * not being told about a field `conform` would then refuse it for. Both * callers in this repository had already worked around it by prepending the * name themselves — a fact held in two places, which is the defect this module * exists to prevent one directory over. It is in the list now, for every * document contract; the usage log has no version field and its one * requirement is the model, same as the line parser's. */ export declare function requiredFieldsOf(name: ContractName): string[]; export interface ConformOptions { /** Force a contract instead of detecting one, for an emitter under test. */ contract?: ContractName; } /** * Checks a document or a usage log against the contract it claims. * * The check is on **required fields and their types**, and stops there. * Documents here gain fields without a version bump, so a checker that * rejected an unrecognised field would fail every consumer one release after * it shipped. */ export declare function conform(text: string, options?: ConformOptions): ConformanceReport; //# sourceMappingURL=conform.d.ts.map