import type { CompileOutcome } from './compile.js'; import type { ParsedRuleRecord } from './rule-record.js'; /** A `target.language` token resolved against the registry, or the reason it did not. */ export type RecordLanguageResolution = { resolved: true; /** The declared token, confirmed registered. Resolution is MEMBERSHIP, so this equals `target.language`. */ language: string; /** * A registered extension mapping to `language`, used to pin the ast-grep * validator to exactly this grammar (see `languageProbeGlobs`). */ extension: string; } | { resolved: false; reason: string; }; /** * Resolve `target.language` against the registry, using `extensionToLanguage` as * the authority verbatim (§ Design 6). Deterministic: `registeredExtensions()` * returns a sorted snapshot, so the representative extension for a language with * several (`.ts`/`.mts`/`.cts` → `typescript`) is always the same one — and every * extension of one language maps to the same napi grammar anyway, so the pick * cannot change the validation verdict, only the diagnostic. * * An unresolvable language FAILS LOUD (§ Design 6 / § Failure modes: "Unresolvable * `language:` at compile — hard error"). It is surfaced as a `rejected` outcome * rather than a throw, matching the incumbent's treatment of every other * authored-content validation failure: `rejected` is a counted, reported, * NON-silent state, while throws are reserved for producer-contract violations * (a malformed id, a payload/type divergence) — see `compileRuleRecord`. */ export declare function resolveRecordLanguage(language: string): RecordLanguageResolution; /** * The glob list handed to `validateAstGrepPattern` so it resolves to EXACTLY the * declared language. * * The shipped validator's language input is a glob list (`resolveAstGrepLangs` * derives Langs from trailing extensions), so pinning it to one grammar means * handing it one glob carrying one registered extension. These globs are a * VALIDATOR PROBE and nothing else — they are never the record's globs, never * reach the compiled rule, and never touch `sanitizeFileGlobs`. * * The coupling to `resolveAstGrepLangs`' derivation is pinned by a conformance * test (`record-lower.test.ts`: the probe resolves to exactly one Lang, and that * Lang equals `extensionToLang(extension)`), so a change to the shipped * derivation fails loud here instead of silently un-pinning the record path. */ export declare function languageProbeGlobs(extension: string): string[]; /** * Check the § Design 6 one-declared-language rule against a record's positive * globs. Returns `null` when the scope is consistent, or the rejection reason. * ast-grep targets only — the caller does not invoke it for regex. */ export declare function checkLanguageGlobConsistency(language: string, fileGlobs: readonly string[]): string | null; /** * NapiConfig siblings of `rule` that V1 cannot express. Named explicitly so the * author is told the truth — a typed construct-gap awaiting a version bump with * its own sibling home under `target:` — instead of napi's generic * "unknown field" error, which would read as a typo in the rule tree. */ export declare const V1_INEXPRESSIBLE_NAPI_KEYS: readonly ["constraints", "utils"]; /** Inputs the lowering needs that the record deliberately does not carry (§ Design 1/§ Design 3). */ export interface CompileRuleRecordOptions { /** * The ADR-112 §8 producer-minted rule id, supplied at the intake seam. NEVER * minted here and never author-set — identity is producer-owned (R17). */ ruleId: string; /** Injected timestamp — no `new Date()` in core (Tenet 15 determinism). */ now: string; } /** * Lower a parsed Prop 310 record into a `CompiledRule`. * * PURE (no IO). Returns a `CompileOutcome`: * - `{kind: 'compiled'}` — the record lowered totally. * - `{kind: 'rejected', reason}` — an authored-content gate failed (bad regex * in the target or in `requires`, an unresolvable `language`, a malformed * ast-grep tree, a V1-inexpressible NapiConfig key). Loud and counted, never * silent; the reason names the governing § so the author is sent to the spec. * * THROWS on a producer-contract violation — a missing/malformed `ruleId`, a key * with no defined lowering, or an engine-binding divergence. These are bugs in * the code that CALLED this function, not defects in the author's record, and * they carry the incumbent's fail-loud idiom (`compile.ts: compileCandidate`) * verbatim: assert up front, before any validation work, so a violation can * never be masked by a coincidental `rejected` outcome. */ export declare function compileRuleRecord(parsed: ParsedRuleRecord, opts: CompileRuleRecordOptions): CompileOutcome; //# sourceMappingURL=record-lower.d.ts.map