/** * Generic validation framework for lexicon artifacts. * * Provides configurable validation checks that any lexicon can use * by passing lexicon-specific configuration. */ import { type CoverageThresholds } from "./coverage.js"; export interface ValidateCheck { name: string; ok: boolean; error?: string; } export interface ValidateResult { success: boolean; checks: ValidateCheck[]; } /** * Set by the publish workflow to arm the release-time surface gate * (chant #1473). Absent in ordinary CI, where upstream drift is expected. */ export declare const RELEASE_GATE_ENV = "CHANT_RELEASE_GATE"; /** * Set by `chant dev surface-diff --update-snapshot` for the validate run it * performs before rewriting the baseline (chant #1825). When set to "1", the * `surface-matches-snapshot` check is skipped. That check fails on exactly the * staleness the update run exists to fix, and with an `"always"` gate (#1475) * the two would deadlock: validate cannot pass until the snapshot is updated, * and the snapshot cannot be updated until validate passes. Every other check * still runs, so a broken generate cannot be baselined. */ export declare const SNAPSHOT_UPDATE_ENV = "CHANT_SNAPSHOT_UPDATE"; export interface LexiconValidationConfig { /** Filename of the lexicon JSON (e.g. "lexicon-mydom.json") */ lexiconJsonFilename: string; /** Required backward-compatible export names to check in lexicon JSON */ requiredNames: string[]; /** * When true, a required name is satisfied if it appears as a substring of any * lexicon JSON key (not only as an exact key). Lexicons that bound their * generated type expansion (e.g. azure, #438) emit shared types under * resource-prefixed/variant names, so the bare curated name is present only * as a substring. Defaults to false (exact-key match). */ requiredNamesMatchSubstring?: boolean; /** Base path of the lexicon package */ basePath: string; /** * chant #1473 — this lexicon's release is gated on the generated API * matching the committed `surface.snapshot.json`. * * Two conditions, both required. The lexicon opts in here, AND * {@link RELEASE_GATE_ENV} is set — which the publish workflow does and * ordinary CI does not. * * The env half is not caution, it is correctness. `validate` runs on every * PR, and the upstream a lexicon generates from can move at any time: the * CloudFormation archive republishes schemas several times a day, and some * of those edits do change the surface. A hard surface check on every PR * would turn any unrelated change red the moment upstream moved, which is * the same trap the spec pin fell into one level down. Drift between * releases is expected and is what the scheduled lexicon-upgrade job exists * to report (#1423). * * What must never happen is *publishing* a surface nobody reviewed. That is * a release-time property, so it is checked at release time. * * `"always"` drops the env half (#1475). It is for a lexicon whose upstream * is pinned to an immutable ref — k8s generates from a kubernetes release * tag plus vendored CRDs, azure from a commit sha of the * resource-manager-schemas repo — so a fresh `generate` on a PR is * deterministic and the only way the surface can move is a change in this * repo. For those, drift on a PR is exactly the thing to fail on: the CRD * batches #1319/#1320/#1321 left the k8s baseline 393 entries behind, and * the #1144 pin left azure 483 behind, because nothing compared the two * until a release was attempted. Never use `"always"` for a lexicon that * fetches a moving upstream. */ checkSurfaceSnapshot?: boolean | "always"; /** Environment to read {@link RELEASE_GATE_ENV} from. Defaults to `process.env`; overridden in tests. */ env?: NodeJS.ProcessEnv; /** Path to the generated directory (defaults to basePath/src/generated) */ generatedDir?: string; /** Coverage thresholds (optional) */ coverageThresholds?: CoverageThresholds; } /** * Validate generated lexicon artifacts using the provided configuration. */ export declare function validateLexiconArtifacts(config: LexiconValidationConfig): Promise; /** * Print validation results to stderr and throw on failure. */ export declare function printValidationResult(result: ValidateResult): void; //# sourceMappingURL=validate.d.ts.map