import { z } from 'zod'; import { type ProvenanceRecord } from '../compiler-schema.js'; import type { ParsedRuleRecord } from './rule-record.js'; /** * Stage-2 classifier disposition (ADR-091 funnel, the gate). A `structural` * (syntactic-invariant) candidate is compile-eligible; a `behavioral` candidate * is RAG-only and MUST NEVER reach the compiler (ADR-111 FM(c) — the * misclassification the 0-31% prior failure is made of). The split is enforced, * not advisory. */ export declare const ClassifierDispositionSchema: z.ZodEnum<["structural", "behavioral"]>; export type ClassifierDisposition = z.infer; /** * ADR-112 — the minimal candidate shape the compile actuator (`compileCandidate` * / `runCompileStage`) actually reads. BOTH the mined `CandidateRuleRecord` and an * authored-derived candidate (via `toCompileFeed`) satisfy it: `provenance` is the * `mined | authored` union, so ONE compiler accepts either producer without an * authored rule masquerading as a classify result (ADR-112 §2 — a parallel * front-end to one compiler, never a second compiler). The mined * `CandidateRuleRecord` (whose `provenance` is the narrower `MinedProvenanceRecord`) * is assignable to this shape; so is the authored compile-feed candidate. */ export interface CompileInputCandidate { provenance: ProvenanceRecord; classifierDisposition: ClassifierDisposition; classifierLedgerRef: string; /** * The lesson-markdown DSL carrier. EXACTLY ONE of `dslSource` / `record` is * present on any candidate — the XOR is a producer contract asserted up front * in `compileCandidate` (both or neither throws). The MINED producer always * carries this one; the AUTHORED producer carries `record` since Prop 310 * slice 3 made the record the only authoring surface. */ dslSource?: string; /** * Prop 310 § Design 1 — the parsed `.totem/rules/.rule.yaml` record, the * other half of the carrier XOR above. Carried ALREADY PARSED (slice 1's * `ParsedRuleRecord`): re-serialising a record into lesson markdown just to * re-parse it would reintroduce the incumbent grammar this proposal supersedes, * so `compileCandidate` dispatches straight to `compileRuleRecord` and never * touches `extractManualPattern` on this path. */ record?: ParsedRuleRecord; /** * ADR-112 §3 (#2259/#7) — the engine the structural-eligibility whitelist judged * this rule for (AUTHORED producer only). When present, `compileCandidate` asserts * the compiled engine MATCHES it: a regex-whitelisted rule whose `dslSource` parses * as ast-grep is a contract violation (the eligibility verdict was engine-specific), * not a silent re-route. The MINED producer omits it — its engine + identity are * `dslSource`-derived, so it carries no independent declaration to bind against. */ declaredEngine?: 'regex' | 'ast' | 'ast-grep'; /** * ADR-112 §8 — the persisted, minted rule identity (AUTHORED producer only; * `mintAuthoredRuleId`, threaded from the record via `toCompileFeed`). When present, * `compileCandidate` makes it the compiled rule's `lessonHash` so the wind-tunnel * `firingLabelId` (and the §6 `controls.positive[].targetRuleId` it must match) * embed it — the §8/§9 id-unification (`firingLabelId ← ruleId`, replacing the * `dslSource`-derived hash). Stable across a matcher edit by construction, so * tightening `dslSource` never orphans the rule's ground-truth labels. The MINED * producer omits it — its identity is the `dslSource`-derived content hash. */ ruleId?: string; unverified: true; } /** * ADR-111 §3 — the miner's sole output envelope, minted `unverified`/Yellow * with no hand-curation. A candidate that cannot produce a complete provenance * tuple is dropped loudly to the drop ledger (Tenet 4 / FM(a)), never emitted * as a partial — the schema makes a partial unconstructible. */ export declare const CandidateRuleRecordSchema: z.ZodObject<{ /** * Provenance tuple (PR# + review-thread ref + commit SHA), reusing the * shipped `ProvenanceRecordSchema` (#2183) verbatim so a candidate's * provenance embeds byte-identically into `legitimacy.provenance` on the * downstream projection — no rename seam. An incomplete tuple is * schema-unconstructible (FM(a)). */ provenance: z.ZodObject<{ kind: z.ZodOptional>; mergedPr: z.ZodNumber; reviewThread: z.ZodEffects; commitSha: z.ZodString; }, "strip", z.ZodTypeAny, { mergedPr: number; reviewThread: string; commitSha: string; kind?: "mined" | undefined; }, { mergedPr: number; reviewThread: string; commitSha: string; kind?: "mined" | undefined; }>; /** Stage-2 disposition. `behavioral` ⇒ RAG-only, never compiled (FM(c)). */ classifierDisposition: z.ZodEnum<["structural", "behavioral"]>; /** * Reference into the classifier-ledger entry recording this candidate's * structural/behavioral disposition + Stage-4 confirmation. Non-empty * (non-mutating refine, matching `reviewThread`'s hash-stability discipline): * every emitted candidate is traceable to its classifier-ledger attestation — * "no compile output without a classifier-ledger entry" (FM(c)). */ classifierLedgerRef: z.ZodEffects; /** * The generated DSL source (ADR-103 compiler input). LLM-draft-only until the * deterministic funnel verifies it (ADR-111 §6 / Tenet-15 corollary). Non-empty * (same discipline as the reference fields): an empty DSL source is a degenerate * candidate that must take the loud-drop path, not emit as valid. */ dslSource: z.ZodEffects; /** * Zero-trust mint flag (ADR-089 / ADR-111 FM(b)). Literally `true` — a * candidate is ALWAYS minted unverified/Yellow; anything else is a * producer-side promotion across sense→enforce. Forces `deriveRuleClass` to * 'advisory' on any later projection into a CompiledRule. */ unverified: z.ZodLiteral; }, "strip", z.ZodTypeAny, { provenance: { mergedPr: number; reviewThread: string; commitSha: string; kind?: "mined" | undefined; }; unverified: true; classifierDisposition: "structural" | "behavioral"; classifierLedgerRef: string; dslSource: string; }, { provenance: { mergedPr: number; reviewThread: string; commitSha: string; kind?: "mined" | undefined; }; unverified: true; classifierDisposition: "structural" | "behavioral"; classifierLedgerRef: string; dslSource: string; }>; export type CandidateRuleRecord = z.infer; //# sourceMappingURL=candidate-rule.d.ts.map