import { z } from 'zod'; import type { CompileInputCandidate } from './candidate-rule.js'; import type { ClassifierLedger } from './ledgers.js'; /** The matcher engines an authored rule may declare (mirrors `CompiledRule.engine`). */ export declare const DeclaredEngineSchema: z.ZodEnum<["regex", "ast", "ast-grep"]>; export type DeclaredEngine = z.infer; /** * ADR-112 §3 — the result of the INDEPENDENT structural-eligibility check. * Produced by `evaluateStructuralEligibility` (NOT by the author): only * `decidable: true` reaches the compiler, mapping to the compiler's * `classifierDisposition: 'structural'`. `judgedBy` records who/what judged it * (ledger-recorded, never the author), so a human cannot smuggle a behavioral * policy past ADR-091's gate by hand-asserting "structural" (FM(d)). */ export declare const StructEligResultSchema: z.ZodObject<{ decidable: z.ZodBoolean; /** * `whitelist:` for the cert-#1 static-whitelist basis; the * `capability-check` / `draft-classifier+stage4` bases are contract-legal but * deferred (slice-A uses the deterministic whitelist only). On a `decidable: * false` verdict the basis still names the attempted whitelist class — the * diagnostic is "no/ambiguous whitelist match", carried in `judgedBy`'s log. * Constrained to the §3 forms (strategy item 2, #2259) so a typo'd/free-form * basis can't validate — non-mutating (no `.trim()`), matching the hash-stability * discipline on the other reference fields. */ basis: z.ZodEffects; judgedBy: z.ZodEffects; }, "strip", z.ZodTypeAny, { decidable: boolean; judgedBy: string; basis: string; }, { decidable: boolean; judgedBy: string; basis: string; }>; export type StructEligResult = z.infer; /** ADR-112 §3/§7 — accelerant-lineage marker. A mined hint that informed a human is recorded, never erased. */ export declare const AuthoredOriginSchema: z.ZodUnion<[z.ZodObject<{ kind: z.ZodLiteral<"from-scratch">; }, "strip", z.ZodTypeAny, { kind: "from-scratch"; }, { kind: "from-scratch"; }>, z.ZodObject<{ kind: z.ZodLiteral<"mined-accelerant">; sourceRunId: z.ZodEffects; suggestionHash: z.ZodEffects; }, "strip", z.ZodTypeAny, { kind: "mined-accelerant"; sourceRunId: string; suggestionHash: string; }, { kind: "mined-accelerant"; sourceRunId: string; suggestionHash: string; }>]>; export type AuthoredOrigin = z.infer; export { AUTHORED_RULE_ID_RE } from '../compiler-schema.js'; /** * ADR-112 §3 — the authored producer's sole output envelope. Parallel to * ADR-111's `CandidateRuleRecord` but carrying the AUTHORED provenance variant, * the INDEPENDENTLY-judged eligibility result, and the accelerant lineage. * Minted `unverified: true` (ADR-089) — zero enforcement blast radius. */ export declare const AuthoredRuleRecordSchema: z.ZodObject<{ /** * ADR-112 §3/§8 — the stable, minted rule identity (`mintAuthoredRuleId`), * assigned ONCE at authoring time and PERSISTED on the record; NEVER re-derived * from content at read time. `firingLabelId` + the §5.3 * `controls.positive[].targetRuleId` ground-truth labels embed it, so a * content-re-derived id would orphan them (§8). Slice A reserves the field (this * IS the schema spine); the authoring flow (slice B) mints it, and threading it * into the compiled artifact's identity (`firingLabelId ← ruleId`, replacing the * `dslSource`-derived `lessonHash`) is slice C/D. The RESOLVED id (with any `-N` * collision suffix) is what is stored. */ ruleId: z.ZodString; provenance: z.ZodObject<{ kind: z.ZodLiteral<"authored">; author: z.ZodEffects; authoredAt: z.ZodEffects; targetDefect: z.ZodEffects; positiveFixtures: z.ZodArray; lessonRef: z.ZodString; badExample: z.ZodEffects; goodExample: z.ZodEffects; }, "strict", z.ZodTypeAny, { kind: "lesson"; lessonRef: string; badExample: string; goodExample: string; }, { kind: "lesson"; lessonRef: string; badExample: string; goodExample: string; }>, z.ZodObject<{ kind: z.ZodLiteral<"commit">; preimageCommitSha: z.ZodString; mergeCommitSha: z.ZodString; }, "strict", z.ZodTypeAny, { kind: "commit"; preimageCommitSha: string; mergeCommitSha: string; }, { kind: "commit"; preimageCommitSha: string; mergeCommitSha: string; }>, z.ZodObject<{ kind: z.ZodLiteral<"record">; ruleId: z.ZodString; ordinal: z.ZodNumber; pairHash: z.ZodString; badExample: z.ZodEffects; goodExample: z.ZodEffects; }, "strict", z.ZodTypeAny, { kind: "record"; badExample: string; goodExample: string; ruleId: string; ordinal: number; pairHash: string; }, { kind: "record"; badExample: string; goodExample: string; ruleId: string; ordinal: number; pairHash: string; }>]>; filePath: z.ZodEffects; matchedSpan: z.ZodEffects; contentHash: z.ZodEffects; }, "strict", z.ZodTypeAny, { pr: number; preimageSource: { kind: "lesson"; lessonRef: string; badExample: string; goodExample: string; } | { kind: "commit"; preimageCommitSha: string; mergeCommitSha: string; } | { kind: "record"; badExample: string; goodExample: string; ruleId: string; ordinal: number; pairHash: string; }; filePath: string; matchedSpan: string; contentHash: string; }, { pr: number; preimageSource: { kind: "lesson"; lessonRef: string; badExample: string; goodExample: string; } | { kind: "commit"; preimageCommitSha: string; mergeCommitSha: string; } | { kind: "record"; badExample: string; goodExample: string; ruleId: string; ordinal: number; pairHash: string; }; filePath: string; matchedSpan: string; contentHash: string; }>, { pr: number; preimageSource: { kind: "lesson"; lessonRef: string; badExample: string; goodExample: string; } | { kind: "commit"; preimageCommitSha: string; mergeCommitSha: string; } | { kind: "record"; badExample: string; goodExample: string; ruleId: string; ordinal: number; pairHash: string; }; filePath: string; matchedSpan: string; contentHash: string; }, { pr: number; preimageSource: { kind: "lesson"; lessonRef: string; badExample: string; goodExample: string; } | { kind: "commit"; preimageCommitSha: string; mergeCommitSha: string; } | { kind: "record"; badExample: string; goodExample: string; ruleId: string; ordinal: number; pairHash: string; }; filePath: string; matchedSpan: string; contentHash: string; }>, "many">; negativeFixtures: z.ZodOptional; matchedSpan: z.ZodEffects; nearMissSource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"lesson">; example: z.ZodEffects; lessonRef: z.ZodOptional; }, "strict", z.ZodTypeAny, { kind: "lesson"; example: string; lessonRef?: string | undefined; }, { kind: "lesson"; example: string; lessonRef?: string | undefined; }>, z.ZodObject<{ kind: z.ZodLiteral<"commit">; commitSha: z.ZodString; }, "strict", z.ZodTypeAny, { kind: "commit"; commitSha: string; }, { kind: "commit"; commitSha: string; }>]>; }, "strict", z.ZodTypeAny, { filePath: string; matchedSpan: string; nearMissSource: { kind: "lesson"; example: string; lessonRef?: string | undefined; } | { kind: "commit"; commitSha: string; }; }, { filePath: string; matchedSpan: string; nearMissSource: { kind: "lesson"; example: string; lessonRef?: string | undefined; } | { kind: "commit"; commitSha: string; }; }>, "many">>; }, "strip", z.ZodTypeAny, { kind: "authored"; author: string; authoredAt: string; targetDefect: string; positiveFixtures: { pr: number; preimageSource: { kind: "lesson"; lessonRef: string; badExample: string; goodExample: string; } | { kind: "commit"; preimageCommitSha: string; mergeCommitSha: string; } | { kind: "record"; badExample: string; goodExample: string; ruleId: string; ordinal: number; pairHash: string; }; filePath: string; matchedSpan: string; contentHash: string; }[]; negativeFixtures?: { filePath: string; matchedSpan: string; nearMissSource: { kind: "lesson"; example: string; lessonRef?: string | undefined; } | { kind: "commit"; commitSha: string; }; }[] | undefined; }, { kind: "authored"; author: string; authoredAt: string; targetDefect: string; positiveFixtures: { pr: number; preimageSource: { kind: "lesson"; lessonRef: string; badExample: string; goodExample: string; } | { kind: "commit"; preimageCommitSha: string; mergeCommitSha: string; } | { kind: "record"; badExample: string; goodExample: string; ruleId: string; ordinal: number; pairHash: string; }; filePath: string; matchedSpan: string; contentHash: string; }[]; negativeFixtures?: { filePath: string; matchedSpan: string; nearMissSource: { kind: "lesson"; example: string; lessonRef?: string | undefined; } | { kind: "commit"; commitSha: string; }; }[] | undefined; }>; /** INDEPENDENTLY established (§3) — the author never sets this; the check does. */ structuralEligibility: z.ZodObject<{ decidable: z.ZodBoolean; /** * `whitelist:` for the cert-#1 static-whitelist basis; the * `capability-check` / `draft-classifier+stage4` bases are contract-legal but * deferred (slice-A uses the deterministic whitelist only). On a `decidable: * false` verdict the basis still names the attempted whitelist class — the * diagnostic is "no/ambiguous whitelist match", carried in `judgedBy`'s log. * Constrained to the §3 forms (strategy item 2, #2259) so a typo'd/free-form * basis can't validate — non-mutating (no `.trim()`), matching the hash-stability * discipline on the other reference fields. */ basis: z.ZodEffects; judgedBy: z.ZodEffects; }, "strip", z.ZodTypeAny, { decidable: boolean; judgedBy: string; basis: string; }, { decidable: boolean; judgedBy: string; basis: string; }>; origin: z.ZodUnion<[z.ZodObject<{ kind: z.ZodLiteral<"from-scratch">; }, "strip", z.ZodTypeAny, { kind: "from-scratch"; }, { kind: "from-scratch"; }>, z.ZodObject<{ kind: z.ZodLiteral<"mined-accelerant">; sourceRunId: z.ZodEffects; suggestionHash: z.ZodEffects; }, "strip", z.ZodTypeAny, { kind: "mined-accelerant"; sourceRunId: string; suggestionHash: string; }, { kind: "mined-accelerant"; sourceRunId: string; suggestionHash: string; }>]>; /** * The engine the structural-eligibility whitelist was judged for. Since Prop 310 * slice 3 it is DERIVED at intake from the record's `target.type` * (`parsed.derivedEngine`, § Design 3/R17) and is never author-mirrored — a * mirrored engine field is Tenet 20's prohibited copy at record scale. */ declaredEngine: z.ZodEnum<["regex", "ast", "ast-grep"]>; /** Reference to the §8 authoring-ledger entry (author/date/engine/splitRef/attestations). */ authoringLedgerRef: z.ZodEffects; /** * Prop 310 § Design 1 — the INGESTED rule record. Replaces the inline * `dslSource`: since slice 3 the record file is the only authoring surface, so * the matcher reaches the compiler already parsed, never re-serialised into * lesson markdown. * * `contentHash` is the sha256 of the LF-admitted bytes actually ingested, and it * is what the §8 attestations bind to (§ Design 1's relocation constraint): the * `path` is INFORMATIONAL only, because renaming a record changes no identity * (§ Design 1) and must not force re-attestation. `parsed` is the in-memory * value the lowering consumes and is never hash material — `contentHash` stands * in for it, so the bytes and the attestation can never disagree. */ record: z.ZodObject<{ /** Repo-relative POSIX path the record was read from — informational, never identity. */ path: z.ZodEffects; /** sha256 of the LF-admitted record bytes — what every attestation binds to. */ contentHash: z.ZodString; /** Slice 1's parsed value (§ Design 3's derived engine + Amendment 1's pair hashes). */ parsed: z.ZodObject<{ record: z.ZodObject<{ schemaVersion: z.ZodLiteral<1>; severity: z.ZodEnum<["error", "warning"]>; message: z.ZodEffects; recoveryHint: z.ZodOptional>; target: z.ZodEffects; language: z.ZodOptional>; pattern: z.ZodOptional>; rule: z.ZodOptional, Record, Record>>; scope: z.ZodObject<{ fileGlobs: z.ZodArray, "many">; excludeGlobs: z.ZodOptional, "many">>; }, "strict", z.ZodTypeAny, { fileGlobs: string[]; excludeGlobs?: string[] | undefined; }, { fileGlobs: string[]; excludeGlobs?: string[] | undefined; }>; }, "strict", z.ZodTypeAny, { type: "regex" | "ast-grep"; scope: { fileGlobs: string[]; excludeGlobs?: string[] | undefined; }; rule?: Record | undefined; pattern?: string | undefined; language?: string | undefined; }, { type: "regex" | "ast-grep"; scope: { fileGlobs: string[]; excludeGlobs?: string[] | undefined; }; rule?: Record | undefined; pattern?: string | undefined; language?: string | undefined; }>, { type: "regex" | "ast-grep"; scope: { fileGlobs: string[]; excludeGlobs?: string[] | undefined; }; rule?: Record | undefined; pattern?: string | undefined; language?: string | undefined; }, { type: "regex" | "ast-grep"; scope: { fileGlobs: string[]; excludeGlobs?: string[] | undefined; }; rule?: Record | undefined; pattern?: string | undefined; language?: string | undefined; }>; examples: z.ZodArray; good: z.ZodEffects; }, "strict", z.ZodTypeAny, { bad: string; good: string; }, { bad: string; good: string; }>, "many">; requires: z.ZodOptional; scope: z.ZodEnum<["line", "file"]>; }, "strict", z.ZodTypeAny, { pattern: string; scope: "line" | "file"; }, { pattern: string; scope: "line" | "file"; }>>; curation: z.ZodOptional; curatedBy: z.ZodOptional>; curatedAt: z.ZodOptional>; baseline5Phase: z.ZodOptional; }, "strict", z.ZodTypeAny, { sourceLesson: string; curatedBy?: string | undefined; curatedAt?: string | undefined; baseline5Phase?: number | undefined; }, { sourceLesson: string; curatedBy?: string | undefined; curatedAt?: string | undefined; baseline5Phase?: number | undefined; }>, { sourceLesson: string; curatedBy?: string | undefined; curatedAt?: string | undefined; baseline5Phase?: number | undefined; }, { sourceLesson: string; curatedBy?: string | undefined; curatedAt?: string | undefined; baseline5Phase?: number | undefined; }>>; verification_shadow: z.ZodOptional; source: z.ZodEffects; }, "strict", z.ZodTypeAny, { type: string; source: string; }, { type: string; source: string; }>>; }, "strict", z.ZodTypeAny, { message: string; severity: "error" | "warning"; examples: { bad: string; good: string; }[]; schemaVersion: 1; target: { type: "regex" | "ast-grep"; scope: { fileGlobs: string[]; excludeGlobs?: string[] | undefined; }; rule?: Record | undefined; pattern?: string | undefined; language?: string | undefined; }; requires?: { pattern: string; scope: "line" | "file"; } | undefined; recoveryHint?: string | undefined; curation?: { sourceLesson: string; curatedBy?: string | undefined; curatedAt?: string | undefined; baseline5Phase?: number | undefined; } | undefined; verification_shadow?: { type: string; source: string; } | undefined; }, { message: string; severity: "error" | "warning"; examples: { bad: string; good: string; }[]; schemaVersion: 1; target: { type: "regex" | "ast-grep"; scope: { fileGlobs: string[]; excludeGlobs?: string[] | undefined; }; rule?: Record | undefined; pattern?: string | undefined; language?: string | undefined; }; requires?: { pattern: string; scope: "line" | "file"; } | undefined; recoveryHint?: string | undefined; curation?: { sourceLesson: string; curatedBy?: string | undefined; curatedAt?: string | undefined; baseline5Phase?: number | undefined; } | undefined; verification_shadow?: { type: string; source: string; } | undefined; }>; derivedEngine: z.ZodEnum<["ast-grep", "regex"]>; examplePairHashes: z.ZodArray, "many">; }, "strict", z.ZodTypeAny, { record: { message: string; severity: "error" | "warning"; examples: { bad: string; good: string; }[]; schemaVersion: 1; target: { type: "regex" | "ast-grep"; scope: { fileGlobs: string[]; excludeGlobs?: string[] | undefined; }; rule?: Record | undefined; pattern?: string | undefined; language?: string | undefined; }; requires?: { pattern: string; scope: "line" | "file"; } | undefined; recoveryHint?: string | undefined; curation?: { sourceLesson: string; curatedBy?: string | undefined; curatedAt?: string | undefined; baseline5Phase?: number | undefined; } | undefined; verification_shadow?: { type: string; source: string; } | undefined; }; derivedEngine: "regex" | "ast-grep"; examplePairHashes: { ordinal: number; hash: string; }[]; }, { record: { message: string; severity: "error" | "warning"; examples: { bad: string; good: string; }[]; schemaVersion: 1; target: { type: "regex" | "ast-grep"; scope: { fileGlobs: string[]; excludeGlobs?: string[] | undefined; }; rule?: Record | undefined; pattern?: string | undefined; language?: string | undefined; }; requires?: { pattern: string; scope: "line" | "file"; } | undefined; recoveryHint?: string | undefined; curation?: { sourceLesson: string; curatedBy?: string | undefined; curatedAt?: string | undefined; baseline5Phase?: number | undefined; } | undefined; verification_shadow?: { type: string; source: string; } | undefined; }; derivedEngine: "regex" | "ast-grep"; examplePairHashes: { ordinal: number; hash: string; }[]; }>; }, "strict", z.ZodTypeAny, { path: string; contentHash: string; parsed: { record: { message: string; severity: "error" | "warning"; examples: { bad: string; good: string; }[]; schemaVersion: 1; target: { type: "regex" | "ast-grep"; scope: { fileGlobs: string[]; excludeGlobs?: string[] | undefined; }; rule?: Record | undefined; pattern?: string | undefined; language?: string | undefined; }; requires?: { pattern: string; scope: "line" | "file"; } | undefined; recoveryHint?: string | undefined; curation?: { sourceLesson: string; curatedBy?: string | undefined; curatedAt?: string | undefined; baseline5Phase?: number | undefined; } | undefined; verification_shadow?: { type: string; source: string; } | undefined; }; derivedEngine: "regex" | "ast-grep"; examplePairHashes: { ordinal: number; hash: string; }[]; }; }, { path: string; contentHash: string; parsed: { record: { message: string; severity: "error" | "warning"; examples: { bad: string; good: string; }[]; schemaVersion: 1; target: { type: "regex" | "ast-grep"; scope: { fileGlobs: string[]; excludeGlobs?: string[] | undefined; }; rule?: Record | undefined; pattern?: string | undefined; language?: string | undefined; }; requires?: { pattern: string; scope: "line" | "file"; } | undefined; recoveryHint?: string | undefined; curation?: { sourceLesson: string; curatedBy?: string | undefined; curatedAt?: string | undefined; baseline5Phase?: number | undefined; } | undefined; verification_shadow?: { type: string; source: string; } | undefined; }; derivedEngine: "regex" | "ast-grep"; examplePairHashes: { ordinal: number; hash: string; }[]; }; }>; /** Zero-trust mint (ADR-089 / ADR-112 §1) — always literally `true`. */ unverified: z.ZodLiteral; }, "strip", z.ZodTypeAny, { record: { path: string; contentHash: string; parsed: { record: { message: string; severity: "error" | "warning"; examples: { bad: string; good: string; }[]; schemaVersion: 1; target: { type: "regex" | "ast-grep"; scope: { fileGlobs: string[]; excludeGlobs?: string[] | undefined; }; rule?: Record | undefined; pattern?: string | undefined; language?: string | undefined; }; requires?: { pattern: string; scope: "line" | "file"; } | undefined; recoveryHint?: string | undefined; curation?: { sourceLesson: string; curatedBy?: string | undefined; curatedAt?: string | undefined; baseline5Phase?: number | undefined; } | undefined; verification_shadow?: { type: string; source: string; } | undefined; }; derivedEngine: "regex" | "ast-grep"; examplePairHashes: { ordinal: number; hash: string; }[]; }; }; ruleId: string; provenance: { kind: "authored"; author: string; authoredAt: string; targetDefect: string; positiveFixtures: { pr: number; preimageSource: { kind: "lesson"; lessonRef: string; badExample: string; goodExample: string; } | { kind: "commit"; preimageCommitSha: string; mergeCommitSha: string; } | { kind: "record"; badExample: string; goodExample: string; ruleId: string; ordinal: number; pairHash: string; }; filePath: string; matchedSpan: string; contentHash: string; }[]; negativeFixtures?: { filePath: string; matchedSpan: string; nearMissSource: { kind: "lesson"; example: string; lessonRef?: string | undefined; } | { kind: "commit"; commitSha: string; }; }[] | undefined; }; unverified: true; structuralEligibility: { decidable: boolean; judgedBy: string; basis: string; }; authoringLedgerRef: string; declaredEngine: "regex" | "ast" | "ast-grep"; origin: { kind: "from-scratch"; } | { kind: "mined-accelerant"; sourceRunId: string; suggestionHash: string; }; }, { record: { path: string; contentHash: string; parsed: { record: { message: string; severity: "error" | "warning"; examples: { bad: string; good: string; }[]; schemaVersion: 1; target: { type: "regex" | "ast-grep"; scope: { fileGlobs: string[]; excludeGlobs?: string[] | undefined; }; rule?: Record | undefined; pattern?: string | undefined; language?: string | undefined; }; requires?: { pattern: string; scope: "line" | "file"; } | undefined; recoveryHint?: string | undefined; curation?: { sourceLesson: string; curatedBy?: string | undefined; curatedAt?: string | undefined; baseline5Phase?: number | undefined; } | undefined; verification_shadow?: { type: string; source: string; } | undefined; }; derivedEngine: "regex" | "ast-grep"; examplePairHashes: { ordinal: number; hash: string; }[]; }; }; ruleId: string; provenance: { kind: "authored"; author: string; authoredAt: string; targetDefect: string; positiveFixtures: { pr: number; preimageSource: { kind: "lesson"; lessonRef: string; badExample: string; goodExample: string; } | { kind: "commit"; preimageCommitSha: string; mergeCommitSha: string; } | { kind: "record"; badExample: string; goodExample: string; ruleId: string; ordinal: number; pairHash: string; }; filePath: string; matchedSpan: string; contentHash: string; }[]; negativeFixtures?: { filePath: string; matchedSpan: string; nearMissSource: { kind: "lesson"; example: string; lessonRef?: string | undefined; } | { kind: "commit"; commitSha: string; }; }[] | undefined; }; unverified: true; structuralEligibility: { decidable: boolean; judgedBy: string; basis: string; }; authoringLedgerRef: string; declaredEngine: "regex" | "ast" | "ast-grep"; origin: { kind: "from-scratch"; } | { kind: "mined-accelerant"; sourceRunId: string; suggestionHash: string; }; }>; export type AuthoredRuleRecord = z.infer; /** * Prop 310 § Design 10 — the AUTHOR-SIDE positive fixture: the ADR-112 §6 corpus * anchor (`pr` + `filePath` + `matchedSpan` + `contentHash`, the line-drift-stable * locus) plus an ORDINAL REFERENCE into the record's `examples`. * * The author writes the reference; INTAKE derives the fixture's `preimageSource` * from `examples[example]` and the minted `ruleId` (Amendment 1: the record's * `examples` block is the editable home, the envelope derives). So an inline * `preimageSource` here is unknown-key under `.strict()` AND named explicitly by * the intake's migration scan — the author never hand-writes the derived side, and * the derived `AuthoredFixture` never carries the reference back (two homes for * one ordinal is the Tenet-20 mirror). * * Refines are NON-mutating, matching `AuthoredFixtureSchema`'s own hash-stability * discipline: these values land inside the ledger's material hash. */ export declare const RecordFixtureInputSchema: z.ZodObject<{ /** The PR where the defect was caught/introduced (the in-corpus anchor). */ pr: z.ZodNumber; /** File the defect locus lives in. */ filePath: z.ZodEffects; /** Line-range or AST-node path — the defect locus, not just the file. */ matchedSpan: z.ZodEffects; /** Span content hash, line-drift-stable (cf. `firingLabelId`). */ contentHash: z.ZodEffects; /** * The `examples[i]` ordinal this fixture's preimage differential draws from * (§ Design 10's `(ruleId, ordinal)` join key). A dangling ordinal, or two * fixtures of one entry naming the same one, fails LOUD at intake — never a * silent re-pair. */ example: z.ZodNumber; }, "strict", z.ZodTypeAny, { pr: number; filePath: string; matchedSpan: string; contentHash: string; example: number; }, { pr: number; filePath: string; matchedSpan: string; contentHash: string; example: number; }>; export type RecordFixtureInput = z.infer; export declare const AuthoredRuleInputSchema: z.ZodObject<{ /** Agent-id or operator handle — attributable (mirrors the provenance field). Trimmed. */ author: z.ZodEffects, string, string>; /** * ISO-8601 authoring date — trimmed + calendar-validated at the INTAKE boundary * (CR diff-review): the same `isIso8601CalendarDate` the record provenance uses, * so a malformed `not-a-date` fails here with a clean `CONFIG_INVALID` instead of * escaping to a raw ZodError at record construction (pass 1). */ authoredAt: z.ZodEffects, string, string>; /** The declared DEFECT the rule targets — the pre-image, not its fix (ADR-110 §4 TP-def). Trimmed. */ targetDefect: z.ZodEffects, string, string>; /** * The structural rule-CLASS the author CLAIMS. Fed to the INDEPENDENT * `evaluateStructuralEligibility` against the DI whitelist; it is NOT stored * verbatim on the record — the *verdict* (`structuralEligibility`, basis * `whitelist:`) is. Naming a class is a claim the check adjudicates, * never a self-certification of `decidable`. Trimmed so a stray space can't * cause an exact-match miss against the registry. */ structuralClass: z.ZodEffects, string, string>; /** * Prop 310 § Design 1 — a repo-relative POSIX reference to the rule record, * `.totem/rules/.rule.yaml`. THE ONLY rule carrier the envelope accepts * (OQ-1 ruling, records-only): an inline `dslSource` / `declaredEngine` / * `preimageSource` is a migration error the intake rejects BY NAME. * * The path's shape (inside `/rules/`, `*.rule.yaml`, no `..`) is * checked at the intake seam, which has the filesystem; this schema only pins * it to a non-empty string. Trimmed: the path is NOT hash material (§ Design 1 * — a rename must not force re-attestation), so normalising it costs nothing * and stops a stray space from becoming an unresolvable reference. */ record: z.ZodEffects, string, string>; /** ≥1 real lc instance the rule claims to catch — ALL train-side (§5). */ positiveFixtures: z.ZodArray; /** Line-range or AST-node path — the defect locus, not just the file. */ matchedSpan: z.ZodEffects; /** Span content hash, line-drift-stable (cf. `firingLabelId`). */ contentHash: z.ZodEffects; /** * The `examples[i]` ordinal this fixture's preimage differential draws from * (§ Design 10's `(ruleId, ordinal)` join key). A dangling ordinal, or two * fixtures of one entry naming the same one, fails LOUD at intake — never a * silent re-pair. */ example: z.ZodNumber; }, "strict", z.ZodTypeAny, { pr: number; filePath: string; matchedSpan: string; contentHash: string; example: number; }, { pr: number; filePath: string; matchedSpan: string; contentHash: string; example: number; }>, "many">; /** * Declared SILENCE-ONLY near-misses the rule must stay silent on (feeds §6 * `controls.negative[]`). The `nearMissSource` shape (strategy#770) — one side, * no bad/good pair, no `pr` — NOT the positiveFixtures fixture shape. */ negativeFixtures: z.ZodOptional; matchedSpan: z.ZodEffects; nearMissSource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"lesson">; example: z.ZodEffects; lessonRef: z.ZodOptional; }, "strict", z.ZodTypeAny, { kind: "lesson"; example: string; lessonRef?: string | undefined; }, { kind: "lesson"; example: string; lessonRef?: string | undefined; }>, z.ZodObject<{ kind: z.ZodLiteral<"commit">; commitSha: z.ZodString; }, "strict", z.ZodTypeAny, { kind: "commit"; commitSha: string; }, { kind: "commit"; commitSha: string; }>]>; }, "strict", z.ZodTypeAny, { filePath: string; matchedSpan: string; nearMissSource: { kind: "lesson"; example: string; lessonRef?: string | undefined; } | { kind: "commit"; commitSha: string; }; }, { filePath: string; matchedSpan: string; nearMissSource: { kind: "lesson"; example: string; lessonRef?: string | undefined; } | { kind: "commit"; commitSha: string; }; }>, "many">>; /** * Accelerant lineage (§7). Optional in the YAML; the reader defaults an * absent value to `{ kind: 'from-scratch' }` when constructing the record, so * the persisted `origin` is always explicit (§7 lineage is never erased). */ origin: z.ZodOptional; }, "strip", z.ZodTypeAny, { kind: "from-scratch"; }, { kind: "from-scratch"; }>, z.ZodObject<{ kind: z.ZodLiteral<"mined-accelerant">; sourceRunId: z.ZodEffects; suggestionHash: z.ZodEffects; }, "strip", z.ZodTypeAny, { kind: "mined-accelerant"; sourceRunId: string; suggestionHash: string; }, { kind: "mined-accelerant"; sourceRunId: string; suggestionHash: string; }>]>>; }, "strict", z.ZodTypeAny, { record: string; author: string; authoredAt: string; targetDefect: string; positiveFixtures: { pr: number; filePath: string; matchedSpan: string; contentHash: string; example: number; }[]; structuralClass: string; negativeFixtures?: { filePath: string; matchedSpan: string; nearMissSource: { kind: "lesson"; example: string; lessonRef?: string | undefined; } | { kind: "commit"; commitSha: string; }; }[] | undefined; origin?: { kind: "from-scratch"; } | { kind: "mined-accelerant"; sourceRunId: string; suggestionHash: string; } | undefined; }, { record: string; author: string; authoredAt: string; targetDefect: string; positiveFixtures: { pr: number; filePath: string; matchedSpan: string; contentHash: string; example: number; }[]; structuralClass: string; negativeFixtures?: { filePath: string; matchedSpan: string; nearMissSource: { kind: "lesson"; example: string; lessonRef?: string | undefined; } | { kind: "commit"; commitSha: string; }; }[] | undefined; origin?: { kind: "from-scratch"; } | { kind: "mined-accelerant"; sourceRunId: string; suggestionHash: string; } | undefined; }>; export type AuthoredRuleInput = z.infer; /** * SLICE B — the on-disk shape of `.totem/spine/authored-rules.yaml`. A file-level * authoring header carries the §5/§8 leakage-guard ATTESTATIONS once for the * session (not per-rule, since all rules in one file are authored under one * frozen split), followed by the rules. Slice B RECORDS these faithfully into the * authoring-ledger (strategy's boundary confirm: B records `splitRef` / * `authoredAfterSplit` / `fixturePrs`); the MECHANICAL verification — the split * was frozen BEFORE authoring (§5.1/FM(g)), fixtures resolve train-side (§5.2), * the harness is sandboxed (§5.4) — is the cert-run harness in SLICE C. The * attestations are `literal(true)`: an author who cannot attest them is not * authoring legitimately, so a `false` fails the read rather than recording a * self-defeating attestation. `.strict()` rejects unknown header keys. */ export declare const AuthoredRulesFileSchema: z.ZodObject<{ /** The frozen split (ADR-110 §6) the rules were authored under (recorded; verified in C). Trimmed (GCA) so stray whitespace can't bypass the non-empty check or perturb the revision fingerprint. */ splitRef: z.ZodEffects, string, string>; /** §1(g) embargo attestation — authored AFTER the split was frozen. Always `true`; verified in C. */ authoredAfterSplit: z.ZodLiteral; /** §5 attestation — the author did not inspect the held-out slice. Always `true`; sandboxed in C. */ heldOutNonInspectionAttestation: z.ZodLiteral; /** * ADR-112 §5.1/§8 R1 — the frozen split's `freezeCommitment`, REQUIRED when * `splitRef` is a content-addressed frozen-artifact reference (`split:`): * the intake binding verifies it against the resolved artifact and chains it * into every ledger entry's material (the (b) tamper-evidence leg). A legacy * free-text `splitRef` omits it (pre-R1 adherence-class shape, byte-unchanged). */ freezeCommitment: z.ZodOptional; /** The authored rules (≥1). */ rules: z.ZodArray, string, string>; /** * ISO-8601 authoring date — trimmed + calendar-validated at the INTAKE boundary * (CR diff-review): the same `isIso8601CalendarDate` the record provenance uses, * so a malformed `not-a-date` fails here with a clean `CONFIG_INVALID` instead of * escaping to a raw ZodError at record construction (pass 1). */ authoredAt: z.ZodEffects, string, string>; /** The declared DEFECT the rule targets — the pre-image, not its fix (ADR-110 §4 TP-def). Trimmed. */ targetDefect: z.ZodEffects, string, string>; /** * The structural rule-CLASS the author CLAIMS. Fed to the INDEPENDENT * `evaluateStructuralEligibility` against the DI whitelist; it is NOT stored * verbatim on the record — the *verdict* (`structuralEligibility`, basis * `whitelist:`) is. Naming a class is a claim the check adjudicates, * never a self-certification of `decidable`. Trimmed so a stray space can't * cause an exact-match miss against the registry. */ structuralClass: z.ZodEffects, string, string>; /** * Prop 310 § Design 1 — a repo-relative POSIX reference to the rule record, * `.totem/rules/.rule.yaml`. THE ONLY rule carrier the envelope accepts * (OQ-1 ruling, records-only): an inline `dslSource` / `declaredEngine` / * `preimageSource` is a migration error the intake rejects BY NAME. * * The path's shape (inside `/rules/`, `*.rule.yaml`, no `..`) is * checked at the intake seam, which has the filesystem; this schema only pins * it to a non-empty string. Trimmed: the path is NOT hash material (§ Design 1 * — a rename must not force re-attestation), so normalising it costs nothing * and stops a stray space from becoming an unresolvable reference. */ record: z.ZodEffects, string, string>; /** ≥1 real lc instance the rule claims to catch — ALL train-side (§5). */ positiveFixtures: z.ZodArray; /** Line-range or AST-node path — the defect locus, not just the file. */ matchedSpan: z.ZodEffects; /** Span content hash, line-drift-stable (cf. `firingLabelId`). */ contentHash: z.ZodEffects; /** * The `examples[i]` ordinal this fixture's preimage differential draws from * (§ Design 10's `(ruleId, ordinal)` join key). A dangling ordinal, or two * fixtures of one entry naming the same one, fails LOUD at intake — never a * silent re-pair. */ example: z.ZodNumber; }, "strict", z.ZodTypeAny, { pr: number; filePath: string; matchedSpan: string; contentHash: string; example: number; }, { pr: number; filePath: string; matchedSpan: string; contentHash: string; example: number; }>, "many">; /** * Declared SILENCE-ONLY near-misses the rule must stay silent on (feeds §6 * `controls.negative[]`). The `nearMissSource` shape (strategy#770) — one side, * no bad/good pair, no `pr` — NOT the positiveFixtures fixture shape. */ negativeFixtures: z.ZodOptional; matchedSpan: z.ZodEffects; nearMissSource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{ kind: z.ZodLiteral<"lesson">; example: z.ZodEffects; lessonRef: z.ZodOptional; }, "strict", z.ZodTypeAny, { kind: "lesson"; example: string; lessonRef?: string | undefined; }, { kind: "lesson"; example: string; lessonRef?: string | undefined; }>, z.ZodObject<{ kind: z.ZodLiteral<"commit">; commitSha: z.ZodString; }, "strict", z.ZodTypeAny, { kind: "commit"; commitSha: string; }, { kind: "commit"; commitSha: string; }>]>; }, "strict", z.ZodTypeAny, { filePath: string; matchedSpan: string; nearMissSource: { kind: "lesson"; example: string; lessonRef?: string | undefined; } | { kind: "commit"; commitSha: string; }; }, { filePath: string; matchedSpan: string; nearMissSource: { kind: "lesson"; example: string; lessonRef?: string | undefined; } | { kind: "commit"; commitSha: string; }; }>, "many">>; /** * Accelerant lineage (§7). Optional in the YAML; the reader defaults an * absent value to `{ kind: 'from-scratch' }` when constructing the record, so * the persisted `origin` is always explicit (§7 lineage is never erased). */ origin: z.ZodOptional; }, "strip", z.ZodTypeAny, { kind: "from-scratch"; }, { kind: "from-scratch"; }>, z.ZodObject<{ kind: z.ZodLiteral<"mined-accelerant">; sourceRunId: z.ZodEffects; suggestionHash: z.ZodEffects; }, "strip", z.ZodTypeAny, { kind: "mined-accelerant"; sourceRunId: string; suggestionHash: string; }, { kind: "mined-accelerant"; sourceRunId: string; suggestionHash: string; }>]>>; }, "strict", z.ZodTypeAny, { record: string; author: string; authoredAt: string; targetDefect: string; positiveFixtures: { pr: number; filePath: string; matchedSpan: string; contentHash: string; example: number; }[]; structuralClass: string; negativeFixtures?: { filePath: string; matchedSpan: string; nearMissSource: { kind: "lesson"; example: string; lessonRef?: string | undefined; } | { kind: "commit"; commitSha: string; }; }[] | undefined; origin?: { kind: "from-scratch"; } | { kind: "mined-accelerant"; sourceRunId: string; suggestionHash: string; } | undefined; }, { record: string; author: string; authoredAt: string; targetDefect: string; positiveFixtures: { pr: number; filePath: string; matchedSpan: string; contentHash: string; example: number; }[]; structuralClass: string; negativeFixtures?: { filePath: string; matchedSpan: string; nearMissSource: { kind: "lesson"; example: string; lessonRef?: string | undefined; } | { kind: "commit"; commitSha: string; }; }[] | undefined; origin?: { kind: "from-scratch"; } | { kind: "mined-accelerant"; sourceRunId: string; suggestionHash: string; } | undefined; }>, "many">; }, "strict", z.ZodTypeAny, { rules: { record: string; author: string; authoredAt: string; targetDefect: string; positiveFixtures: { pr: number; filePath: string; matchedSpan: string; contentHash: string; example: number; }[]; structuralClass: string; negativeFixtures?: { filePath: string; matchedSpan: string; nearMissSource: { kind: "lesson"; example: string; lessonRef?: string | undefined; } | { kind: "commit"; commitSha: string; }; }[] | undefined; origin?: { kind: "from-scratch"; } | { kind: "mined-accelerant"; sourceRunId: string; suggestionHash: string; } | undefined; }[]; splitRef: string; authoredAfterSplit: true; heldOutNonInspectionAttestation: true; freezeCommitment?: string | undefined; }, { rules: { record: string; author: string; authoredAt: string; targetDefect: string; positiveFixtures: { pr: number; filePath: string; matchedSpan: string; contentHash: string; example: number; }[]; structuralClass: string; negativeFixtures?: { filePath: string; matchedSpan: string; nearMissSource: { kind: "lesson"; example: string; lessonRef?: string | undefined; } | { kind: "commit"; commitSha: string; }; }[] | undefined; origin?: { kind: "from-scratch"; } | { kind: "mined-accelerant"; sourceRunId: string; suggestionHash: string; } | undefined; }[]; splitRef: string; authoredAfterSplit: true; heldOutNonInspectionAttestation: true; freezeCommitment?: string | undefined; }>; export type AuthoredRulesFile = z.infer; /** * One decidable `(engine, structuralClass)` pair. The whitelist of these lives * in the CLI registry (slice B); the registry lists ONLY pairs the engine can * actually represent, so "exactly one match" subsumes ADR-112 §3's "AND the * engine can represent that class" condition. */ export interface WhitelistEntry { engine: DeclaredEngine; structuralClass: string; } /** * ADR-112 §3 — the INDEPENDENT structural-eligibility check. A CLOSED registry * predicate, NOT prose: `decidable` is true iff EXACTLY ONE whitelist entry * matches `(declaredEngine, structuralClass)`. Unknown class, unsupported * engine, or multiple matches → `decidable: false` (NO default-to-structural). * The author supplies `declaredEngine` + `structuralClass`; this check OWNS the * verdict — any author-supplied disposition is irrelevant here (FM(d)). * Deterministic + pure (no IO, no LLM) — the same input always yields the same * verdict (Tenet-15). */ export declare function evaluateStructuralEligibility(input: { declaredEngine: DeclaredEngine; structuralClass: string; }, whitelist: readonly WhitelistEntry[], judgedBy: string): StructEligResult; /** * ADR-112 §8 — mint a stable, deterministic authored rule-id. The seed is * `sha256(JSON.stringify([author, targetDefect]))[:16]` (an INJECTIVE encoding — * see the inline note) — `dslSource` is DELIBERATELY EXCLUDED so an author can * tighten/refactor the matcher without orphaning the rule's ledger history. On collision with an already-resolved id (two rules sharing the same * `(author, targetDefect)`), a stable `-N` counter is appended. The RESOLVED id * is what callers persist — never recompute the raw seed at read time, or a * later sibling could shift the suffix (the gemini/agy break). The * `never-remine` marker is keyed to `targetDefect`, handled by the accelerant * miner, not here. */ export declare function mintAuthoredRuleId(author: string, targetDefect: string, existingIds: ReadonlySet): string; /** * The authored producer's compile-stage input — what `toCompileFeed` builds for * `runCompileStage`. Deliberately NOT a `ClassifyStageResult`: an authored rule * has no mining emission ledger, so faking one would be a provenance lie. The * classifier ledger it carries records `dispositionSource: 'authored-whitelist'`. */ export interface AuthoredCompileFeed { candidates: CompileInputCandidate[]; classifierLedger: ClassifierLedger; } /** * ADR-112 §2/§8 — turn structurally-DECIDABLE authored rules into the input * `runCompileStage` consumes, reusing the ONE G-series compiler (never a second). * The disposition is set HERE to `'structural'` from the INDEPENDENT eligibility * verdict (§3) — the author never sets it. A NON-decidable record is a contract * violation → FAIL LOUD (the FM(d) backstop in code), never a silent skip. * `classifierLedgerRef = authored:` is unique per rule (the * authoring ledger is 1:1 with the rule); a duplicate fails loud so the downstream * 1:1 classifier-ledger join can't silently collapse. */ export declare function toCompileFeed(records: readonly AuthoredRuleRecord[]): AuthoredCompileFeed; //# sourceMappingURL=authored-rule.d.ts.map