@mmnto/totem 1.79.0 → 1.80.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/compiler-schema.d.ts +1635 -256
  2. package/dist/compiler-schema.d.ts.map +1 -1
  3. package/dist/compiler-schema.js +110 -10
  4. package/dist/compiler-schema.js.map +1 -1
  5. package/dist/compiler-schema.test.js +164 -7
  6. package/dist/compiler-schema.test.js.map +1 -1
  7. package/dist/compiler.d.ts +1 -1
  8. package/dist/compiler.d.ts.map +1 -1
  9. package/dist/compiler.js +1 -1
  10. package/dist/compiler.js.map +1 -1
  11. package/dist/config-schema.d.ts +6 -6
  12. package/dist/index.d.ts +5 -3
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +3 -2
  15. package/dist/index.js.map +1 -1
  16. package/dist/spine/authored-rule.d.ts +1030 -32
  17. package/dist/spine/authored-rule.d.ts.map +1 -1
  18. package/dist/spine/authored-rule.js +115 -1
  19. package/dist/spine/authored-rule.js.map +1 -1
  20. package/dist/spine/authored-rule.test.js +10 -4
  21. package/dist/spine/authored-rule.test.js.map +1 -1
  22. package/dist/spine/authoring-ledger.d.ts +204 -0
  23. package/dist/spine/authoring-ledger.d.ts.map +1 -0
  24. package/dist/spine/authoring-ledger.js +220 -0
  25. package/dist/spine/authoring-ledger.js.map +1 -0
  26. package/dist/spine/authoring-ledger.test.d.ts +2 -0
  27. package/dist/spine/authoring-ledger.test.d.ts.map +1 -0
  28. package/dist/spine/authoring-ledger.test.js +144 -0
  29. package/dist/spine/authoring-ledger.test.js.map +1 -0
  30. package/dist/spine/compile.test.js +5 -2
  31. package/dist/spine/compile.test.js.map +1 -1
  32. package/dist/spine/corpus-dispositions.d.ts +4 -4
  33. package/dist/spine/windtunnel-lock.d.ts +6 -6
  34. package/dist/store/lance-schema.d.ts +2 -2
  35. package/package.json +1 -1
@@ -36,6 +36,15 @@ export declare const AstGrepYamlRuleSchema: z.ZodObject<{
36
36
  rule: z.ZodRecord<z.ZodString, z.ZodUnknown>;
37
37
  }, z.ZodTypeAny, "passthrough">>;
38
38
  export type AstGrepYamlRule = NapiConfig;
39
+ /**
40
+ * True iff `s` is a well-formed ISO-8601 date/timestamp AND a REAL calendar date.
41
+ * `Date.parse` alone is insufficient: it NORMALIZES day-overflow (`2026-02-31` → Mar 3,
42
+ * `2026-02-29` non-leap → Mar 1) instead of rejecting it (#2259 CR re-review). The
43
+ * `Date.UTC` round-trip validates the date HEAD's calendar independently of any timezone
44
+ * in the time component — a negative offset can legitimately shift the UTC day, so the
45
+ * head, not the parsed instant, is what must round-trip.
46
+ */
47
+ export declare function isIso8601CalendarDate(s: string): boolean;
39
48
  /**
40
49
  * mmnto-ai/totem#2183 — the §3.1 provenance leg of the ADR-110 Gate-1
41
50
  * legitimacy bar: the identity of the merged-PR history a regenerated rule was
@@ -89,37 +98,181 @@ export declare const MinedProvenanceWireSchema: z.ZodObject<{
89
98
  kind?: "mined" | undefined;
90
99
  }>;
91
100
  export type MinedProvenanceRecord = z.infer<typeof MinedProvenanceWireSchema>;
101
+ /**
102
+ * ADR-112 §4 — the preimage-differential SOURCE for one fixture, a discriminated
103
+ * union on `kind` (declared PER FIXTURE; not a fixed binding to landed commits).
104
+ * The materializer (slice C/D) fires the matcher on the preimage and asserts it
105
+ * is SILENT on the postimage — a matcher that fires only on the fixed form is
106
+ * fix-shaped and is NOT a legitimate positive control (FM(i)):
107
+ * - `lesson` (PRIMARY, review-caught repos): the lesson corpus' `badExample`
108
+ * (preimage — fire) / `goodExample` (postimage — silent). `lessonRef` is an
109
+ * IMMUTABLE lesson id/hash (the `hashLesson` codomain, `LESSON_REF_RE`),
110
+ * never a path/mutable alias (§8 identity discipline).
111
+ * - `commit` (FALLBACK, land-then-fix repos): the pre-fix parent
112
+ * (`preimageCommitSha` — fire) / post-fix merge (`mergeCommitSha` — silent).
113
+ *
114
+ * `z.discriminatedUnion` (not `z.union`): both branches carry a REQUIRED literal
115
+ * `kind`, so Zod routes a parse error to the matched branch instead of emitting
116
+ * "no union member matched" noise (cf. `cert-corpus-seed.ts`'s `window`). The
117
+ * OPTIONAL-discriminator round-trip reason `ProvenanceRecordSchema` documents for
118
+ * its `z.union` does NOT apply — `preimageSource` is a new field with no persisted
119
+ * authored set. Each branch is `.strict()` so a cross-branch key (e.g. a
120
+ * `badExample` under `kind:'commit'`) fails LOUD (FM(d) posture) rather than being
121
+ * silently stripped. All refines are NON-mutating (no `.trim()`) to preserve the
122
+ * manifest-hash stability discipline.
123
+ */
124
+ export declare const PreimageSourceSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
125
+ kind: z.ZodLiteral<"lesson">;
126
+ /** IMMUTABLE lesson id/hash (the 16-hex `hashLesson` codomain) — never a path/mutable alias (§4/§8). */
127
+ lessonRef: z.ZodString;
128
+ /**
129
+ * The defect PREIMAGE exemplar the matcher must FIRE on (§4). This is a lesson
130
+ * corpus `badExample` — distinct from `CompiledRuleBaseSchema.badExample` (an
131
+ * optional human-readable code snippet on a compiled rule); here it is the
132
+ * load-bearing positive-control preimage, so non-empty is required.
133
+ */
134
+ badExample: z.ZodEffects<z.ZodString, string, string>;
135
+ /** The fixed POSTIMAGE exemplar the matcher must stay SILENT on (§4) — a lesson `goodExample`. */
136
+ goodExample: z.ZodEffects<z.ZodString, string, string>;
137
+ }, "strict", z.ZodTypeAny, {
138
+ kind: "lesson";
139
+ lessonRef: string;
140
+ badExample: string;
141
+ goodExample: string;
142
+ }, {
143
+ kind: "lesson";
144
+ lessonRef: string;
145
+ badExample: string;
146
+ goodExample: string;
147
+ }>, z.ZodObject<{
148
+ kind: z.ZodLiteral<"commit">;
149
+ /** The PARENT (pre-fix) commit where the DEFECT is present — the matcher must FIRE on this (ADR-112 §4). */
150
+ preimageCommitSha: z.ZodString;
151
+ /** The PR's merge/squash commit — the post-fix (defect-absent) anchor; the matcher must stay SILENT on this. */
152
+ mergeCommitSha: z.ZodString;
153
+ }, "strict", z.ZodTypeAny, {
154
+ kind: "commit";
155
+ preimageCommitSha: string;
156
+ mergeCommitSha: string;
157
+ }, {
158
+ kind: "commit";
159
+ preimageCommitSha: string;
160
+ mergeCommitSha: string;
161
+ }>]>;
162
+ export type PreimageSource = z.infer<typeof PreimageSourceSchema>;
92
163
  /**
93
164
  * ADR-112 §3 — one real lc instance an authored rule claims to catch. ALL such
94
165
  * fixtures are TRAIN-side (the §5 leakage guard); the preimage-differential
95
- * (§4) is evaluated in slice C/D, but the record must CARRY both commits + the
96
- * defect locus here so derivation is possible. `matchedSpan` + `contentHash`
97
- * are the line-drift-stable locus (cf. `firingLabelId`), not just the file.
166
+ * (§4) is evaluated in slice C/D, but the record CARRIES the declared
167
+ * `preimageSource` (lesson | commit) + the defect locus here so derivation is
168
+ * possible. `matchedSpan` + `contentHash` are the line-drift-stable locus
169
+ * (cf. `firingLabelId`), not just the file.
98
170
  */
99
- export declare const AuthoredFixtureSchema: z.ZodObject<{
100
- /** The PR whose merge introduced the fix (the in-corpus anchor). */
171
+ export declare const AuthoredFixtureSchema: z.ZodEffects<z.ZodObject<{
172
+ /** The PR where the defect was caught/introduced (the in-corpus anchor). */
101
173
  pr: z.ZodNumber;
102
- /** The PR's merge/squash committhe post-fix (defect-absent) anchor. */
103
- mergeCommitSha: z.ZodString;
104
- /** The PARENT (pre-fix) commit where the DEFECT is present (ADR-112 §4). */
105
- preimageCommitSha: z.ZodString;
174
+ /** The §4 preimage-differential sourcelesson-anchored (PRIMARY) or commit-pair (FALLBACK). */
175
+ preimageSource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
176
+ kind: z.ZodLiteral<"lesson">;
177
+ /** IMMUTABLE lesson id/hash (the 16-hex `hashLesson` codomain) — never a path/mutable alias (§4/§8). */
178
+ lessonRef: z.ZodString;
179
+ /**
180
+ * The defect PREIMAGE exemplar the matcher must FIRE on (§4). This is a lesson
181
+ * corpus `badExample` — distinct from `CompiledRuleBaseSchema.badExample` (an
182
+ * optional human-readable code snippet on a compiled rule); here it is the
183
+ * load-bearing positive-control preimage, so non-empty is required.
184
+ */
185
+ badExample: z.ZodEffects<z.ZodString, string, string>;
186
+ /** The fixed POSTIMAGE exemplar the matcher must stay SILENT on (§4) — a lesson `goodExample`. */
187
+ goodExample: z.ZodEffects<z.ZodString, string, string>;
188
+ }, "strict", z.ZodTypeAny, {
189
+ kind: "lesson";
190
+ lessonRef: string;
191
+ badExample: string;
192
+ goodExample: string;
193
+ }, {
194
+ kind: "lesson";
195
+ lessonRef: string;
196
+ badExample: string;
197
+ goodExample: string;
198
+ }>, z.ZodObject<{
199
+ kind: z.ZodLiteral<"commit">;
200
+ /** The PARENT (pre-fix) commit where the DEFECT is present — the matcher must FIRE on this (ADR-112 §4). */
201
+ preimageCommitSha: z.ZodString;
202
+ /** The PR's merge/squash commit — the post-fix (defect-absent) anchor; the matcher must stay SILENT on this. */
203
+ mergeCommitSha: z.ZodString;
204
+ }, "strict", z.ZodTypeAny, {
205
+ kind: "commit";
206
+ preimageCommitSha: string;
207
+ mergeCommitSha: string;
208
+ }, {
209
+ kind: "commit";
210
+ preimageCommitSha: string;
211
+ mergeCommitSha: string;
212
+ }>]>;
106
213
  /** File the defect locus lives in. */
107
214
  filePath: z.ZodEffects<z.ZodString, string, string>;
108
215
  /** Line-range or AST-node path — the defect locus, not just the file. */
109
216
  matchedSpan: z.ZodEffects<z.ZodString, string, string>;
110
217
  /** Span content hash, line-drift-stable (cf. `firingLabelId`). */
111
218
  contentHash: z.ZodEffects<z.ZodString, string, string>;
112
- }, "strip", z.ZodTypeAny, {
219
+ }, "strict", z.ZodTypeAny, {
113
220
  pr: number;
114
- mergeCommitSha: string;
115
- preimageCommitSha: string;
221
+ preimageSource: {
222
+ kind: "lesson";
223
+ lessonRef: string;
224
+ badExample: string;
225
+ goodExample: string;
226
+ } | {
227
+ kind: "commit";
228
+ preimageCommitSha: string;
229
+ mergeCommitSha: string;
230
+ };
116
231
  filePath: string;
117
232
  matchedSpan: string;
118
233
  contentHash: string;
119
234
  }, {
120
235
  pr: number;
121
- mergeCommitSha: string;
122
- preimageCommitSha: string;
236
+ preimageSource: {
237
+ kind: "lesson";
238
+ lessonRef: string;
239
+ badExample: string;
240
+ goodExample: string;
241
+ } | {
242
+ kind: "commit";
243
+ preimageCommitSha: string;
244
+ mergeCommitSha: string;
245
+ };
246
+ filePath: string;
247
+ matchedSpan: string;
248
+ contentHash: string;
249
+ }>, {
250
+ pr: number;
251
+ preimageSource: {
252
+ kind: "lesson";
253
+ lessonRef: string;
254
+ badExample: string;
255
+ goodExample: string;
256
+ } | {
257
+ kind: "commit";
258
+ preimageCommitSha: string;
259
+ mergeCommitSha: string;
260
+ };
261
+ filePath: string;
262
+ matchedSpan: string;
263
+ contentHash: string;
264
+ }, {
265
+ pr: number;
266
+ preimageSource: {
267
+ kind: "lesson";
268
+ lessonRef: string;
269
+ badExample: string;
270
+ goodExample: string;
271
+ } | {
272
+ kind: "commit";
273
+ preimageCommitSha: string;
274
+ mergeCommitSha: string;
275
+ };
123
276
  filePath: string;
124
277
  matchedSpan: string;
125
278
  contentHash: string;
@@ -143,59 +296,221 @@ export declare const AuthoredProvenanceRecordSchema: z.ZodObject<{
143
296
  /** The declared DEFECT the rule targets — the pre-image, not its fix. */
144
297
  targetDefect: z.ZodEffects<z.ZodString, string, string>;
145
298
  /** ≥1 real lc instance the rule claims to catch — ALL train-side (§5). */
146
- positiveFixtures: z.ZodArray<z.ZodObject<{
147
- /** The PR whose merge introduced the fix (the in-corpus anchor). */
299
+ positiveFixtures: z.ZodArray<z.ZodEffects<z.ZodObject<{
300
+ /** The PR where the defect was caught/introduced (the in-corpus anchor). */
148
301
  pr: z.ZodNumber;
149
- /** The PR's merge/squash committhe post-fix (defect-absent) anchor. */
150
- mergeCommitSha: z.ZodString;
151
- /** The PARENT (pre-fix) commit where the DEFECT is present (ADR-112 §4). */
152
- preimageCommitSha: z.ZodString;
302
+ /** The §4 preimage-differential sourcelesson-anchored (PRIMARY) or commit-pair (FALLBACK). */
303
+ preimageSource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
304
+ kind: z.ZodLiteral<"lesson">;
305
+ /** IMMUTABLE lesson id/hash (the 16-hex `hashLesson` codomain) — never a path/mutable alias (§4/§8). */
306
+ lessonRef: z.ZodString;
307
+ /**
308
+ * The defect PREIMAGE exemplar the matcher must FIRE on (§4). This is a lesson
309
+ * corpus `badExample` — distinct from `CompiledRuleBaseSchema.badExample` (an
310
+ * optional human-readable code snippet on a compiled rule); here it is the
311
+ * load-bearing positive-control preimage, so non-empty is required.
312
+ */
313
+ badExample: z.ZodEffects<z.ZodString, string, string>;
314
+ /** The fixed POSTIMAGE exemplar the matcher must stay SILENT on (§4) — a lesson `goodExample`. */
315
+ goodExample: z.ZodEffects<z.ZodString, string, string>;
316
+ }, "strict", z.ZodTypeAny, {
317
+ kind: "lesson";
318
+ lessonRef: string;
319
+ badExample: string;
320
+ goodExample: string;
321
+ }, {
322
+ kind: "lesson";
323
+ lessonRef: string;
324
+ badExample: string;
325
+ goodExample: string;
326
+ }>, z.ZodObject<{
327
+ kind: z.ZodLiteral<"commit">;
328
+ /** The PARENT (pre-fix) commit where the DEFECT is present — the matcher must FIRE on this (ADR-112 §4). */
329
+ preimageCommitSha: z.ZodString;
330
+ /** The PR's merge/squash commit — the post-fix (defect-absent) anchor; the matcher must stay SILENT on this. */
331
+ mergeCommitSha: z.ZodString;
332
+ }, "strict", z.ZodTypeAny, {
333
+ kind: "commit";
334
+ preimageCommitSha: string;
335
+ mergeCommitSha: string;
336
+ }, {
337
+ kind: "commit";
338
+ preimageCommitSha: string;
339
+ mergeCommitSha: string;
340
+ }>]>;
153
341
  /** File the defect locus lives in. */
154
342
  filePath: z.ZodEffects<z.ZodString, string, string>;
155
343
  /** Line-range or AST-node path — the defect locus, not just the file. */
156
344
  matchedSpan: z.ZodEffects<z.ZodString, string, string>;
157
345
  /** Span content hash, line-drift-stable (cf. `firingLabelId`). */
158
346
  contentHash: z.ZodEffects<z.ZodString, string, string>;
159
- }, "strip", z.ZodTypeAny, {
347
+ }, "strict", z.ZodTypeAny, {
160
348
  pr: number;
161
- mergeCommitSha: string;
162
- preimageCommitSha: string;
349
+ preimageSource: {
350
+ kind: "lesson";
351
+ lessonRef: string;
352
+ badExample: string;
353
+ goodExample: string;
354
+ } | {
355
+ kind: "commit";
356
+ preimageCommitSha: string;
357
+ mergeCommitSha: string;
358
+ };
163
359
  filePath: string;
164
360
  matchedSpan: string;
165
361
  contentHash: string;
166
362
  }, {
167
363
  pr: number;
168
- mergeCommitSha: string;
169
- preimageCommitSha: string;
364
+ preimageSource: {
365
+ kind: "lesson";
366
+ lessonRef: string;
367
+ badExample: string;
368
+ goodExample: string;
369
+ } | {
370
+ kind: "commit";
371
+ preimageCommitSha: string;
372
+ mergeCommitSha: string;
373
+ };
374
+ filePath: string;
375
+ matchedSpan: string;
376
+ contentHash: string;
377
+ }>, {
378
+ pr: number;
379
+ preimageSource: {
380
+ kind: "lesson";
381
+ lessonRef: string;
382
+ badExample: string;
383
+ goodExample: string;
384
+ } | {
385
+ kind: "commit";
386
+ preimageCommitSha: string;
387
+ mergeCommitSha: string;
388
+ };
389
+ filePath: string;
390
+ matchedSpan: string;
391
+ contentHash: string;
392
+ }, {
393
+ pr: number;
394
+ preimageSource: {
395
+ kind: "lesson";
396
+ lessonRef: string;
397
+ badExample: string;
398
+ goodExample: string;
399
+ } | {
400
+ kind: "commit";
401
+ preimageCommitSha: string;
402
+ mergeCommitSha: string;
403
+ };
170
404
  filePath: string;
171
405
  matchedSpan: string;
172
406
  contentHash: string;
173
407
  }>, "many">;
174
408
  /** Declared near-misses the rule must stay silent on (feeds §6 negative controls). */
175
- negativeFixtures: z.ZodOptional<z.ZodArray<z.ZodObject<{
176
- /** The PR whose merge introduced the fix (the in-corpus anchor). */
409
+ negativeFixtures: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
410
+ /** The PR where the defect was caught/introduced (the in-corpus anchor). */
177
411
  pr: z.ZodNumber;
178
- /** The PR's merge/squash committhe post-fix (defect-absent) anchor. */
179
- mergeCommitSha: z.ZodString;
180
- /** The PARENT (pre-fix) commit where the DEFECT is present (ADR-112 §4). */
181
- preimageCommitSha: z.ZodString;
412
+ /** The §4 preimage-differential sourcelesson-anchored (PRIMARY) or commit-pair (FALLBACK). */
413
+ preimageSource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
414
+ kind: z.ZodLiteral<"lesson">;
415
+ /** IMMUTABLE lesson id/hash (the 16-hex `hashLesson` codomain) — never a path/mutable alias (§4/§8). */
416
+ lessonRef: z.ZodString;
417
+ /**
418
+ * The defect PREIMAGE exemplar the matcher must FIRE on (§4). This is a lesson
419
+ * corpus `badExample` — distinct from `CompiledRuleBaseSchema.badExample` (an
420
+ * optional human-readable code snippet on a compiled rule); here it is the
421
+ * load-bearing positive-control preimage, so non-empty is required.
422
+ */
423
+ badExample: z.ZodEffects<z.ZodString, string, string>;
424
+ /** The fixed POSTIMAGE exemplar the matcher must stay SILENT on (§4) — a lesson `goodExample`. */
425
+ goodExample: z.ZodEffects<z.ZodString, string, string>;
426
+ }, "strict", z.ZodTypeAny, {
427
+ kind: "lesson";
428
+ lessonRef: string;
429
+ badExample: string;
430
+ goodExample: string;
431
+ }, {
432
+ kind: "lesson";
433
+ lessonRef: string;
434
+ badExample: string;
435
+ goodExample: string;
436
+ }>, z.ZodObject<{
437
+ kind: z.ZodLiteral<"commit">;
438
+ /** The PARENT (pre-fix) commit where the DEFECT is present — the matcher must FIRE on this (ADR-112 §4). */
439
+ preimageCommitSha: z.ZodString;
440
+ /** The PR's merge/squash commit — the post-fix (defect-absent) anchor; the matcher must stay SILENT on this. */
441
+ mergeCommitSha: z.ZodString;
442
+ }, "strict", z.ZodTypeAny, {
443
+ kind: "commit";
444
+ preimageCommitSha: string;
445
+ mergeCommitSha: string;
446
+ }, {
447
+ kind: "commit";
448
+ preimageCommitSha: string;
449
+ mergeCommitSha: string;
450
+ }>]>;
182
451
  /** File the defect locus lives in. */
183
452
  filePath: z.ZodEffects<z.ZodString, string, string>;
184
453
  /** Line-range or AST-node path — the defect locus, not just the file. */
185
454
  matchedSpan: z.ZodEffects<z.ZodString, string, string>;
186
455
  /** Span content hash, line-drift-stable (cf. `firingLabelId`). */
187
456
  contentHash: z.ZodEffects<z.ZodString, string, string>;
188
- }, "strip", z.ZodTypeAny, {
457
+ }, "strict", z.ZodTypeAny, {
189
458
  pr: number;
190
- mergeCommitSha: string;
191
- preimageCommitSha: string;
459
+ preimageSource: {
460
+ kind: "lesson";
461
+ lessonRef: string;
462
+ badExample: string;
463
+ goodExample: string;
464
+ } | {
465
+ kind: "commit";
466
+ preimageCommitSha: string;
467
+ mergeCommitSha: string;
468
+ };
192
469
  filePath: string;
193
470
  matchedSpan: string;
194
471
  contentHash: string;
195
472
  }, {
196
473
  pr: number;
197
- mergeCommitSha: string;
198
- preimageCommitSha: string;
474
+ preimageSource: {
475
+ kind: "lesson";
476
+ lessonRef: string;
477
+ badExample: string;
478
+ goodExample: string;
479
+ } | {
480
+ kind: "commit";
481
+ preimageCommitSha: string;
482
+ mergeCommitSha: string;
483
+ };
484
+ filePath: string;
485
+ matchedSpan: string;
486
+ contentHash: string;
487
+ }>, {
488
+ pr: number;
489
+ preimageSource: {
490
+ kind: "lesson";
491
+ lessonRef: string;
492
+ badExample: string;
493
+ goodExample: string;
494
+ } | {
495
+ kind: "commit";
496
+ preimageCommitSha: string;
497
+ mergeCommitSha: string;
498
+ };
499
+ filePath: string;
500
+ matchedSpan: string;
501
+ contentHash: string;
502
+ }, {
503
+ pr: number;
504
+ preimageSource: {
505
+ kind: "lesson";
506
+ lessonRef: string;
507
+ badExample: string;
508
+ goodExample: string;
509
+ } | {
510
+ kind: "commit";
511
+ preimageCommitSha: string;
512
+ mergeCommitSha: string;
513
+ };
199
514
  filePath: string;
200
515
  matchedSpan: string;
201
516
  contentHash: string;
@@ -207,16 +522,32 @@ export declare const AuthoredProvenanceRecordSchema: z.ZodObject<{
207
522
  targetDefect: string;
208
523
  positiveFixtures: {
209
524
  pr: number;
210
- mergeCommitSha: string;
211
- preimageCommitSha: string;
525
+ preimageSource: {
526
+ kind: "lesson";
527
+ lessonRef: string;
528
+ badExample: string;
529
+ goodExample: string;
530
+ } | {
531
+ kind: "commit";
532
+ preimageCommitSha: string;
533
+ mergeCommitSha: string;
534
+ };
212
535
  filePath: string;
213
536
  matchedSpan: string;
214
537
  contentHash: string;
215
538
  }[];
216
539
  negativeFixtures?: {
217
540
  pr: number;
218
- mergeCommitSha: string;
219
- preimageCommitSha: string;
541
+ preimageSource: {
542
+ kind: "lesson";
543
+ lessonRef: string;
544
+ badExample: string;
545
+ goodExample: string;
546
+ } | {
547
+ kind: "commit";
548
+ preimageCommitSha: string;
549
+ mergeCommitSha: string;
550
+ };
220
551
  filePath: string;
221
552
  matchedSpan: string;
222
553
  contentHash: string;
@@ -228,16 +559,32 @@ export declare const AuthoredProvenanceRecordSchema: z.ZodObject<{
228
559
  targetDefect: string;
229
560
  positiveFixtures: {
230
561
  pr: number;
231
- mergeCommitSha: string;
232
- preimageCommitSha: string;
562
+ preimageSource: {
563
+ kind: "lesson";
564
+ lessonRef: string;
565
+ badExample: string;
566
+ goodExample: string;
567
+ } | {
568
+ kind: "commit";
569
+ preimageCommitSha: string;
570
+ mergeCommitSha: string;
571
+ };
233
572
  filePath: string;
234
573
  matchedSpan: string;
235
574
  contentHash: string;
236
575
  }[];
237
576
  negativeFixtures?: {
238
577
  pr: number;
239
- mergeCommitSha: string;
240
- preimageCommitSha: string;
578
+ preimageSource: {
579
+ kind: "lesson";
580
+ lessonRef: string;
581
+ badExample: string;
582
+ goodExample: string;
583
+ } | {
584
+ kind: "commit";
585
+ preimageCommitSha: string;
586
+ mergeCommitSha: string;
587
+ };
241
588
  filePath: string;
242
589
  matchedSpan: string;
243
590
  contentHash: string;
@@ -265,59 +612,221 @@ export declare const ProvenanceRecordSchema: z.ZodUnion<[z.ZodObject<{
265
612
  /** The declared DEFECT the rule targets — the pre-image, not its fix. */
266
613
  targetDefect: z.ZodEffects<z.ZodString, string, string>;
267
614
  /** ≥1 real lc instance the rule claims to catch — ALL train-side (§5). */
268
- positiveFixtures: z.ZodArray<z.ZodObject<{
269
- /** The PR whose merge introduced the fix (the in-corpus anchor). */
615
+ positiveFixtures: z.ZodArray<z.ZodEffects<z.ZodObject<{
616
+ /** The PR where the defect was caught/introduced (the in-corpus anchor). */
270
617
  pr: z.ZodNumber;
271
- /** The PR's merge/squash committhe post-fix (defect-absent) anchor. */
272
- mergeCommitSha: z.ZodString;
273
- /** The PARENT (pre-fix) commit where the DEFECT is present (ADR-112 §4). */
274
- preimageCommitSha: z.ZodString;
618
+ /** The §4 preimage-differential sourcelesson-anchored (PRIMARY) or commit-pair (FALLBACK). */
619
+ preimageSource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
620
+ kind: z.ZodLiteral<"lesson">;
621
+ /** IMMUTABLE lesson id/hash (the 16-hex `hashLesson` codomain) — never a path/mutable alias (§4/§8). */
622
+ lessonRef: z.ZodString;
623
+ /**
624
+ * The defect PREIMAGE exemplar the matcher must FIRE on (§4). This is a lesson
625
+ * corpus `badExample` — distinct from `CompiledRuleBaseSchema.badExample` (an
626
+ * optional human-readable code snippet on a compiled rule); here it is the
627
+ * load-bearing positive-control preimage, so non-empty is required.
628
+ */
629
+ badExample: z.ZodEffects<z.ZodString, string, string>;
630
+ /** The fixed POSTIMAGE exemplar the matcher must stay SILENT on (§4) — a lesson `goodExample`. */
631
+ goodExample: z.ZodEffects<z.ZodString, string, string>;
632
+ }, "strict", z.ZodTypeAny, {
633
+ kind: "lesson";
634
+ lessonRef: string;
635
+ badExample: string;
636
+ goodExample: string;
637
+ }, {
638
+ kind: "lesson";
639
+ lessonRef: string;
640
+ badExample: string;
641
+ goodExample: string;
642
+ }>, z.ZodObject<{
643
+ kind: z.ZodLiteral<"commit">;
644
+ /** The PARENT (pre-fix) commit where the DEFECT is present — the matcher must FIRE on this (ADR-112 §4). */
645
+ preimageCommitSha: z.ZodString;
646
+ /** The PR's merge/squash commit — the post-fix (defect-absent) anchor; the matcher must stay SILENT on this. */
647
+ mergeCommitSha: z.ZodString;
648
+ }, "strict", z.ZodTypeAny, {
649
+ kind: "commit";
650
+ preimageCommitSha: string;
651
+ mergeCommitSha: string;
652
+ }, {
653
+ kind: "commit";
654
+ preimageCommitSha: string;
655
+ mergeCommitSha: string;
656
+ }>]>;
275
657
  /** File the defect locus lives in. */
276
658
  filePath: z.ZodEffects<z.ZodString, string, string>;
277
659
  /** Line-range or AST-node path — the defect locus, not just the file. */
278
660
  matchedSpan: z.ZodEffects<z.ZodString, string, string>;
279
661
  /** Span content hash, line-drift-stable (cf. `firingLabelId`). */
280
662
  contentHash: z.ZodEffects<z.ZodString, string, string>;
281
- }, "strip", z.ZodTypeAny, {
663
+ }, "strict", z.ZodTypeAny, {
282
664
  pr: number;
283
- mergeCommitSha: string;
284
- preimageCommitSha: string;
665
+ preimageSource: {
666
+ kind: "lesson";
667
+ lessonRef: string;
668
+ badExample: string;
669
+ goodExample: string;
670
+ } | {
671
+ kind: "commit";
672
+ preimageCommitSha: string;
673
+ mergeCommitSha: string;
674
+ };
285
675
  filePath: string;
286
676
  matchedSpan: string;
287
677
  contentHash: string;
288
678
  }, {
289
679
  pr: number;
290
- mergeCommitSha: string;
291
- preimageCommitSha: string;
680
+ preimageSource: {
681
+ kind: "lesson";
682
+ lessonRef: string;
683
+ badExample: string;
684
+ goodExample: string;
685
+ } | {
686
+ kind: "commit";
687
+ preimageCommitSha: string;
688
+ mergeCommitSha: string;
689
+ };
690
+ filePath: string;
691
+ matchedSpan: string;
692
+ contentHash: string;
693
+ }>, {
694
+ pr: number;
695
+ preimageSource: {
696
+ kind: "lesson";
697
+ lessonRef: string;
698
+ badExample: string;
699
+ goodExample: string;
700
+ } | {
701
+ kind: "commit";
702
+ preimageCommitSha: string;
703
+ mergeCommitSha: string;
704
+ };
705
+ filePath: string;
706
+ matchedSpan: string;
707
+ contentHash: string;
708
+ }, {
709
+ pr: number;
710
+ preimageSource: {
711
+ kind: "lesson";
712
+ lessonRef: string;
713
+ badExample: string;
714
+ goodExample: string;
715
+ } | {
716
+ kind: "commit";
717
+ preimageCommitSha: string;
718
+ mergeCommitSha: string;
719
+ };
292
720
  filePath: string;
293
721
  matchedSpan: string;
294
722
  contentHash: string;
295
723
  }>, "many">;
296
724
  /** Declared near-misses the rule must stay silent on (feeds §6 negative controls). */
297
- negativeFixtures: z.ZodOptional<z.ZodArray<z.ZodObject<{
298
- /** The PR whose merge introduced the fix (the in-corpus anchor). */
725
+ negativeFixtures: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
726
+ /** The PR where the defect was caught/introduced (the in-corpus anchor). */
299
727
  pr: z.ZodNumber;
300
- /** The PR's merge/squash committhe post-fix (defect-absent) anchor. */
301
- mergeCommitSha: z.ZodString;
302
- /** The PARENT (pre-fix) commit where the DEFECT is present (ADR-112 §4). */
303
- preimageCommitSha: z.ZodString;
728
+ /** The §4 preimage-differential sourcelesson-anchored (PRIMARY) or commit-pair (FALLBACK). */
729
+ preimageSource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
730
+ kind: z.ZodLiteral<"lesson">;
731
+ /** IMMUTABLE lesson id/hash (the 16-hex `hashLesson` codomain) — never a path/mutable alias (§4/§8). */
732
+ lessonRef: z.ZodString;
733
+ /**
734
+ * The defect PREIMAGE exemplar the matcher must FIRE on (§4). This is a lesson
735
+ * corpus `badExample` — distinct from `CompiledRuleBaseSchema.badExample` (an
736
+ * optional human-readable code snippet on a compiled rule); here it is the
737
+ * load-bearing positive-control preimage, so non-empty is required.
738
+ */
739
+ badExample: z.ZodEffects<z.ZodString, string, string>;
740
+ /** The fixed POSTIMAGE exemplar the matcher must stay SILENT on (§4) — a lesson `goodExample`. */
741
+ goodExample: z.ZodEffects<z.ZodString, string, string>;
742
+ }, "strict", z.ZodTypeAny, {
743
+ kind: "lesson";
744
+ lessonRef: string;
745
+ badExample: string;
746
+ goodExample: string;
747
+ }, {
748
+ kind: "lesson";
749
+ lessonRef: string;
750
+ badExample: string;
751
+ goodExample: string;
752
+ }>, z.ZodObject<{
753
+ kind: z.ZodLiteral<"commit">;
754
+ /** The PARENT (pre-fix) commit where the DEFECT is present — the matcher must FIRE on this (ADR-112 §4). */
755
+ preimageCommitSha: z.ZodString;
756
+ /** The PR's merge/squash commit — the post-fix (defect-absent) anchor; the matcher must stay SILENT on this. */
757
+ mergeCommitSha: z.ZodString;
758
+ }, "strict", z.ZodTypeAny, {
759
+ kind: "commit";
760
+ preimageCommitSha: string;
761
+ mergeCommitSha: string;
762
+ }, {
763
+ kind: "commit";
764
+ preimageCommitSha: string;
765
+ mergeCommitSha: string;
766
+ }>]>;
304
767
  /** File the defect locus lives in. */
305
768
  filePath: z.ZodEffects<z.ZodString, string, string>;
306
769
  /** Line-range or AST-node path — the defect locus, not just the file. */
307
770
  matchedSpan: z.ZodEffects<z.ZodString, string, string>;
308
771
  /** Span content hash, line-drift-stable (cf. `firingLabelId`). */
309
772
  contentHash: z.ZodEffects<z.ZodString, string, string>;
310
- }, "strip", z.ZodTypeAny, {
773
+ }, "strict", z.ZodTypeAny, {
311
774
  pr: number;
312
- mergeCommitSha: string;
313
- preimageCommitSha: string;
775
+ preimageSource: {
776
+ kind: "lesson";
777
+ lessonRef: string;
778
+ badExample: string;
779
+ goodExample: string;
780
+ } | {
781
+ kind: "commit";
782
+ preimageCommitSha: string;
783
+ mergeCommitSha: string;
784
+ };
314
785
  filePath: string;
315
786
  matchedSpan: string;
316
787
  contentHash: string;
317
788
  }, {
318
789
  pr: number;
319
- mergeCommitSha: string;
320
- preimageCommitSha: string;
790
+ preimageSource: {
791
+ kind: "lesson";
792
+ lessonRef: string;
793
+ badExample: string;
794
+ goodExample: string;
795
+ } | {
796
+ kind: "commit";
797
+ preimageCommitSha: string;
798
+ mergeCommitSha: string;
799
+ };
800
+ filePath: string;
801
+ matchedSpan: string;
802
+ contentHash: string;
803
+ }>, {
804
+ pr: number;
805
+ preimageSource: {
806
+ kind: "lesson";
807
+ lessonRef: string;
808
+ badExample: string;
809
+ goodExample: string;
810
+ } | {
811
+ kind: "commit";
812
+ preimageCommitSha: string;
813
+ mergeCommitSha: string;
814
+ };
815
+ filePath: string;
816
+ matchedSpan: string;
817
+ contentHash: string;
818
+ }, {
819
+ pr: number;
820
+ preimageSource: {
821
+ kind: "lesson";
822
+ lessonRef: string;
823
+ badExample: string;
824
+ goodExample: string;
825
+ } | {
826
+ kind: "commit";
827
+ preimageCommitSha: string;
828
+ mergeCommitSha: string;
829
+ };
321
830
  filePath: string;
322
831
  matchedSpan: string;
323
832
  contentHash: string;
@@ -329,16 +838,32 @@ export declare const ProvenanceRecordSchema: z.ZodUnion<[z.ZodObject<{
329
838
  targetDefect: string;
330
839
  positiveFixtures: {
331
840
  pr: number;
332
- mergeCommitSha: string;
333
- preimageCommitSha: string;
841
+ preimageSource: {
842
+ kind: "lesson";
843
+ lessonRef: string;
844
+ badExample: string;
845
+ goodExample: string;
846
+ } | {
847
+ kind: "commit";
848
+ preimageCommitSha: string;
849
+ mergeCommitSha: string;
850
+ };
334
851
  filePath: string;
335
852
  matchedSpan: string;
336
853
  contentHash: string;
337
854
  }[];
338
855
  negativeFixtures?: {
339
856
  pr: number;
340
- mergeCommitSha: string;
341
- preimageCommitSha: string;
857
+ preimageSource: {
858
+ kind: "lesson";
859
+ lessonRef: string;
860
+ badExample: string;
861
+ goodExample: string;
862
+ } | {
863
+ kind: "commit";
864
+ preimageCommitSha: string;
865
+ mergeCommitSha: string;
866
+ };
342
867
  filePath: string;
343
868
  matchedSpan: string;
344
869
  contentHash: string;
@@ -350,16 +875,32 @@ export declare const ProvenanceRecordSchema: z.ZodUnion<[z.ZodObject<{
350
875
  targetDefect: string;
351
876
  positiveFixtures: {
352
877
  pr: number;
353
- mergeCommitSha: string;
354
- preimageCommitSha: string;
878
+ preimageSource: {
879
+ kind: "lesson";
880
+ lessonRef: string;
881
+ badExample: string;
882
+ goodExample: string;
883
+ } | {
884
+ kind: "commit";
885
+ preimageCommitSha: string;
886
+ mergeCommitSha: string;
887
+ };
355
888
  filePath: string;
356
889
  matchedSpan: string;
357
890
  contentHash: string;
358
891
  }[];
359
892
  negativeFixtures?: {
360
893
  pr: number;
361
- mergeCommitSha: string;
362
- preimageCommitSha: string;
894
+ preimageSource: {
895
+ kind: "lesson";
896
+ lessonRef: string;
897
+ badExample: string;
898
+ goodExample: string;
899
+ } | {
900
+ kind: "commit";
901
+ preimageCommitSha: string;
902
+ mergeCommitSha: string;
903
+ };
363
904
  filePath: string;
364
905
  matchedSpan: string;
365
906
  contentHash: string;
@@ -427,59 +968,221 @@ export declare const LegitimacySchema: z.ZodObject<{
427
968
  /** The declared DEFECT the rule targets — the pre-image, not its fix. */
428
969
  targetDefect: z.ZodEffects<z.ZodString, string, string>;
429
970
  /** ≥1 real lc instance the rule claims to catch — ALL train-side (§5). */
430
- positiveFixtures: z.ZodArray<z.ZodObject<{
431
- /** The PR whose merge introduced the fix (the in-corpus anchor). */
971
+ positiveFixtures: z.ZodArray<z.ZodEffects<z.ZodObject<{
972
+ /** The PR where the defect was caught/introduced (the in-corpus anchor). */
432
973
  pr: z.ZodNumber;
433
- /** The PR's merge/squash committhe post-fix (defect-absent) anchor. */
434
- mergeCommitSha: z.ZodString;
435
- /** The PARENT (pre-fix) commit where the DEFECT is present (ADR-112 §4). */
436
- preimageCommitSha: z.ZodString;
974
+ /** The §4 preimage-differential sourcelesson-anchored (PRIMARY) or commit-pair (FALLBACK). */
975
+ preimageSource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
976
+ kind: z.ZodLiteral<"lesson">;
977
+ /** IMMUTABLE lesson id/hash (the 16-hex `hashLesson` codomain) — never a path/mutable alias (§4/§8). */
978
+ lessonRef: z.ZodString;
979
+ /**
980
+ * The defect PREIMAGE exemplar the matcher must FIRE on (§4). This is a lesson
981
+ * corpus `badExample` — distinct from `CompiledRuleBaseSchema.badExample` (an
982
+ * optional human-readable code snippet on a compiled rule); here it is the
983
+ * load-bearing positive-control preimage, so non-empty is required.
984
+ */
985
+ badExample: z.ZodEffects<z.ZodString, string, string>;
986
+ /** The fixed POSTIMAGE exemplar the matcher must stay SILENT on (§4) — a lesson `goodExample`. */
987
+ goodExample: z.ZodEffects<z.ZodString, string, string>;
988
+ }, "strict", z.ZodTypeAny, {
989
+ kind: "lesson";
990
+ lessonRef: string;
991
+ badExample: string;
992
+ goodExample: string;
993
+ }, {
994
+ kind: "lesson";
995
+ lessonRef: string;
996
+ badExample: string;
997
+ goodExample: string;
998
+ }>, z.ZodObject<{
999
+ kind: z.ZodLiteral<"commit">;
1000
+ /** The PARENT (pre-fix) commit where the DEFECT is present — the matcher must FIRE on this (ADR-112 §4). */
1001
+ preimageCommitSha: z.ZodString;
1002
+ /** The PR's merge/squash commit — the post-fix (defect-absent) anchor; the matcher must stay SILENT on this. */
1003
+ mergeCommitSha: z.ZodString;
1004
+ }, "strict", z.ZodTypeAny, {
1005
+ kind: "commit";
1006
+ preimageCommitSha: string;
1007
+ mergeCommitSha: string;
1008
+ }, {
1009
+ kind: "commit";
1010
+ preimageCommitSha: string;
1011
+ mergeCommitSha: string;
1012
+ }>]>;
437
1013
  /** File the defect locus lives in. */
438
1014
  filePath: z.ZodEffects<z.ZodString, string, string>;
439
1015
  /** Line-range or AST-node path — the defect locus, not just the file. */
440
1016
  matchedSpan: z.ZodEffects<z.ZodString, string, string>;
441
1017
  /** Span content hash, line-drift-stable (cf. `firingLabelId`). */
442
1018
  contentHash: z.ZodEffects<z.ZodString, string, string>;
443
- }, "strip", z.ZodTypeAny, {
1019
+ }, "strict", z.ZodTypeAny, {
444
1020
  pr: number;
445
- mergeCommitSha: string;
446
- preimageCommitSha: string;
1021
+ preimageSource: {
1022
+ kind: "lesson";
1023
+ lessonRef: string;
1024
+ badExample: string;
1025
+ goodExample: string;
1026
+ } | {
1027
+ kind: "commit";
1028
+ preimageCommitSha: string;
1029
+ mergeCommitSha: string;
1030
+ };
447
1031
  filePath: string;
448
1032
  matchedSpan: string;
449
1033
  contentHash: string;
450
1034
  }, {
451
1035
  pr: number;
452
- mergeCommitSha: string;
453
- preimageCommitSha: string;
1036
+ preimageSource: {
1037
+ kind: "lesson";
1038
+ lessonRef: string;
1039
+ badExample: string;
1040
+ goodExample: string;
1041
+ } | {
1042
+ kind: "commit";
1043
+ preimageCommitSha: string;
1044
+ mergeCommitSha: string;
1045
+ };
1046
+ filePath: string;
1047
+ matchedSpan: string;
1048
+ contentHash: string;
1049
+ }>, {
1050
+ pr: number;
1051
+ preimageSource: {
1052
+ kind: "lesson";
1053
+ lessonRef: string;
1054
+ badExample: string;
1055
+ goodExample: string;
1056
+ } | {
1057
+ kind: "commit";
1058
+ preimageCommitSha: string;
1059
+ mergeCommitSha: string;
1060
+ };
1061
+ filePath: string;
1062
+ matchedSpan: string;
1063
+ contentHash: string;
1064
+ }, {
1065
+ pr: number;
1066
+ preimageSource: {
1067
+ kind: "lesson";
1068
+ lessonRef: string;
1069
+ badExample: string;
1070
+ goodExample: string;
1071
+ } | {
1072
+ kind: "commit";
1073
+ preimageCommitSha: string;
1074
+ mergeCommitSha: string;
1075
+ };
454
1076
  filePath: string;
455
1077
  matchedSpan: string;
456
1078
  contentHash: string;
457
1079
  }>, "many">;
458
1080
  /** Declared near-misses the rule must stay silent on (feeds §6 negative controls). */
459
- negativeFixtures: z.ZodOptional<z.ZodArray<z.ZodObject<{
460
- /** The PR whose merge introduced the fix (the in-corpus anchor). */
1081
+ negativeFixtures: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
1082
+ /** The PR where the defect was caught/introduced (the in-corpus anchor). */
461
1083
  pr: z.ZodNumber;
462
- /** The PR's merge/squash committhe post-fix (defect-absent) anchor. */
463
- mergeCommitSha: z.ZodString;
464
- /** The PARENT (pre-fix) commit where the DEFECT is present (ADR-112 §4). */
465
- preimageCommitSha: z.ZodString;
1084
+ /** The §4 preimage-differential sourcelesson-anchored (PRIMARY) or commit-pair (FALLBACK). */
1085
+ preimageSource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
1086
+ kind: z.ZodLiteral<"lesson">;
1087
+ /** IMMUTABLE lesson id/hash (the 16-hex `hashLesson` codomain) — never a path/mutable alias (§4/§8). */
1088
+ lessonRef: z.ZodString;
1089
+ /**
1090
+ * The defect PREIMAGE exemplar the matcher must FIRE on (§4). This is a lesson
1091
+ * corpus `badExample` — distinct from `CompiledRuleBaseSchema.badExample` (an
1092
+ * optional human-readable code snippet on a compiled rule); here it is the
1093
+ * load-bearing positive-control preimage, so non-empty is required.
1094
+ */
1095
+ badExample: z.ZodEffects<z.ZodString, string, string>;
1096
+ /** The fixed POSTIMAGE exemplar the matcher must stay SILENT on (§4) — a lesson `goodExample`. */
1097
+ goodExample: z.ZodEffects<z.ZodString, string, string>;
1098
+ }, "strict", z.ZodTypeAny, {
1099
+ kind: "lesson";
1100
+ lessonRef: string;
1101
+ badExample: string;
1102
+ goodExample: string;
1103
+ }, {
1104
+ kind: "lesson";
1105
+ lessonRef: string;
1106
+ badExample: string;
1107
+ goodExample: string;
1108
+ }>, z.ZodObject<{
1109
+ kind: z.ZodLiteral<"commit">;
1110
+ /** The PARENT (pre-fix) commit where the DEFECT is present — the matcher must FIRE on this (ADR-112 §4). */
1111
+ preimageCommitSha: z.ZodString;
1112
+ /** The PR's merge/squash commit — the post-fix (defect-absent) anchor; the matcher must stay SILENT on this. */
1113
+ mergeCommitSha: z.ZodString;
1114
+ }, "strict", z.ZodTypeAny, {
1115
+ kind: "commit";
1116
+ preimageCommitSha: string;
1117
+ mergeCommitSha: string;
1118
+ }, {
1119
+ kind: "commit";
1120
+ preimageCommitSha: string;
1121
+ mergeCommitSha: string;
1122
+ }>]>;
466
1123
  /** File the defect locus lives in. */
467
1124
  filePath: z.ZodEffects<z.ZodString, string, string>;
468
1125
  /** Line-range or AST-node path — the defect locus, not just the file. */
469
1126
  matchedSpan: z.ZodEffects<z.ZodString, string, string>;
470
1127
  /** Span content hash, line-drift-stable (cf. `firingLabelId`). */
471
1128
  contentHash: z.ZodEffects<z.ZodString, string, string>;
472
- }, "strip", z.ZodTypeAny, {
1129
+ }, "strict", z.ZodTypeAny, {
473
1130
  pr: number;
474
- mergeCommitSha: string;
475
- preimageCommitSha: string;
1131
+ preimageSource: {
1132
+ kind: "lesson";
1133
+ lessonRef: string;
1134
+ badExample: string;
1135
+ goodExample: string;
1136
+ } | {
1137
+ kind: "commit";
1138
+ preimageCommitSha: string;
1139
+ mergeCommitSha: string;
1140
+ };
476
1141
  filePath: string;
477
1142
  matchedSpan: string;
478
1143
  contentHash: string;
479
1144
  }, {
480
1145
  pr: number;
481
- mergeCommitSha: string;
482
- preimageCommitSha: string;
1146
+ preimageSource: {
1147
+ kind: "lesson";
1148
+ lessonRef: string;
1149
+ badExample: string;
1150
+ goodExample: string;
1151
+ } | {
1152
+ kind: "commit";
1153
+ preimageCommitSha: string;
1154
+ mergeCommitSha: string;
1155
+ };
1156
+ filePath: string;
1157
+ matchedSpan: string;
1158
+ contentHash: string;
1159
+ }>, {
1160
+ pr: number;
1161
+ preimageSource: {
1162
+ kind: "lesson";
1163
+ lessonRef: string;
1164
+ badExample: string;
1165
+ goodExample: string;
1166
+ } | {
1167
+ kind: "commit";
1168
+ preimageCommitSha: string;
1169
+ mergeCommitSha: string;
1170
+ };
1171
+ filePath: string;
1172
+ matchedSpan: string;
1173
+ contentHash: string;
1174
+ }, {
1175
+ pr: number;
1176
+ preimageSource: {
1177
+ kind: "lesson";
1178
+ lessonRef: string;
1179
+ badExample: string;
1180
+ goodExample: string;
1181
+ } | {
1182
+ kind: "commit";
1183
+ preimageCommitSha: string;
1184
+ mergeCommitSha: string;
1185
+ };
483
1186
  filePath: string;
484
1187
  matchedSpan: string;
485
1188
  contentHash: string;
@@ -491,16 +1194,32 @@ export declare const LegitimacySchema: z.ZodObject<{
491
1194
  targetDefect: string;
492
1195
  positiveFixtures: {
493
1196
  pr: number;
494
- mergeCommitSha: string;
495
- preimageCommitSha: string;
1197
+ preimageSource: {
1198
+ kind: "lesson";
1199
+ lessonRef: string;
1200
+ badExample: string;
1201
+ goodExample: string;
1202
+ } | {
1203
+ kind: "commit";
1204
+ preimageCommitSha: string;
1205
+ mergeCommitSha: string;
1206
+ };
496
1207
  filePath: string;
497
1208
  matchedSpan: string;
498
1209
  contentHash: string;
499
1210
  }[];
500
1211
  negativeFixtures?: {
501
1212
  pr: number;
502
- mergeCommitSha: string;
503
- preimageCommitSha: string;
1213
+ preimageSource: {
1214
+ kind: "lesson";
1215
+ lessonRef: string;
1216
+ badExample: string;
1217
+ goodExample: string;
1218
+ } | {
1219
+ kind: "commit";
1220
+ preimageCommitSha: string;
1221
+ mergeCommitSha: string;
1222
+ };
504
1223
  filePath: string;
505
1224
  matchedSpan: string;
506
1225
  contentHash: string;
@@ -512,16 +1231,32 @@ export declare const LegitimacySchema: z.ZodObject<{
512
1231
  targetDefect: string;
513
1232
  positiveFixtures: {
514
1233
  pr: number;
515
- mergeCommitSha: string;
516
- preimageCommitSha: string;
1234
+ preimageSource: {
1235
+ kind: "lesson";
1236
+ lessonRef: string;
1237
+ badExample: string;
1238
+ goodExample: string;
1239
+ } | {
1240
+ kind: "commit";
1241
+ preimageCommitSha: string;
1242
+ mergeCommitSha: string;
1243
+ };
517
1244
  filePath: string;
518
1245
  matchedSpan: string;
519
1246
  contentHash: string;
520
1247
  }[];
521
1248
  negativeFixtures?: {
522
1249
  pr: number;
523
- mergeCommitSha: string;
524
- preimageCommitSha: string;
1250
+ preimageSource: {
1251
+ kind: "lesson";
1252
+ lessonRef: string;
1253
+ badExample: string;
1254
+ goodExample: string;
1255
+ } | {
1256
+ kind: "commit";
1257
+ preimageCommitSha: string;
1258
+ mergeCommitSha: string;
1259
+ };
525
1260
  filePath: string;
526
1261
  matchedSpan: string;
527
1262
  contentHash: string;
@@ -573,16 +1308,32 @@ export declare const LegitimacySchema: z.ZodObject<{
573
1308
  targetDefect: string;
574
1309
  positiveFixtures: {
575
1310
  pr: number;
576
- mergeCommitSha: string;
577
- preimageCommitSha: string;
1311
+ preimageSource: {
1312
+ kind: "lesson";
1313
+ lessonRef: string;
1314
+ badExample: string;
1315
+ goodExample: string;
1316
+ } | {
1317
+ kind: "commit";
1318
+ preimageCommitSha: string;
1319
+ mergeCommitSha: string;
1320
+ };
578
1321
  filePath: string;
579
1322
  matchedSpan: string;
580
1323
  contentHash: string;
581
1324
  }[];
582
1325
  negativeFixtures?: {
583
1326
  pr: number;
584
- mergeCommitSha: string;
585
- preimageCommitSha: string;
1327
+ preimageSource: {
1328
+ kind: "lesson";
1329
+ lessonRef: string;
1330
+ badExample: string;
1331
+ goodExample: string;
1332
+ } | {
1333
+ kind: "commit";
1334
+ preimageCommitSha: string;
1335
+ mergeCommitSha: string;
1336
+ };
586
1337
  filePath: string;
587
1338
  matchedSpan: string;
588
1339
  contentHash: string;
@@ -603,16 +1354,32 @@ export declare const LegitimacySchema: z.ZodObject<{
603
1354
  targetDefect: string;
604
1355
  positiveFixtures: {
605
1356
  pr: number;
606
- mergeCommitSha: string;
607
- preimageCommitSha: string;
1357
+ preimageSource: {
1358
+ kind: "lesson";
1359
+ lessonRef: string;
1360
+ badExample: string;
1361
+ goodExample: string;
1362
+ } | {
1363
+ kind: "commit";
1364
+ preimageCommitSha: string;
1365
+ mergeCommitSha: string;
1366
+ };
608
1367
  filePath: string;
609
1368
  matchedSpan: string;
610
1369
  contentHash: string;
611
1370
  }[];
612
1371
  negativeFixtures?: {
613
1372
  pr: number;
614
- mergeCommitSha: string;
615
- preimageCommitSha: string;
1373
+ preimageSource: {
1374
+ kind: "lesson";
1375
+ lessonRef: string;
1376
+ badExample: string;
1377
+ goodExample: string;
1378
+ } | {
1379
+ kind: "commit";
1380
+ preimageCommitSha: string;
1381
+ mergeCommitSha: string;
1382
+ };
616
1383
  filePath: string;
617
1384
  matchedSpan: string;
618
1385
  contentHash: string;
@@ -817,59 +1584,221 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
817
1584
  /** The declared DEFECT the rule targets — the pre-image, not its fix. */
818
1585
  targetDefect: z.ZodEffects<z.ZodString, string, string>;
819
1586
  /** ≥1 real lc instance the rule claims to catch — ALL train-side (§5). */
820
- positiveFixtures: z.ZodArray<z.ZodObject<{
821
- /** The PR whose merge introduced the fix (the in-corpus anchor). */
1587
+ positiveFixtures: z.ZodArray<z.ZodEffects<z.ZodObject<{
1588
+ /** The PR where the defect was caught/introduced (the in-corpus anchor). */
822
1589
  pr: z.ZodNumber;
823
- /** The PR's merge/squash committhe post-fix (defect-absent) anchor. */
824
- mergeCommitSha: z.ZodString;
825
- /** The PARENT (pre-fix) commit where the DEFECT is present (ADR-112 §4). */
826
- preimageCommitSha: z.ZodString;
1590
+ /** The §4 preimage-differential sourcelesson-anchored (PRIMARY) or commit-pair (FALLBACK). */
1591
+ preimageSource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
1592
+ kind: z.ZodLiteral<"lesson">;
1593
+ /** IMMUTABLE lesson id/hash (the 16-hex `hashLesson` codomain) — never a path/mutable alias (§4/§8). */
1594
+ lessonRef: z.ZodString;
1595
+ /**
1596
+ * The defect PREIMAGE exemplar the matcher must FIRE on (§4). This is a lesson
1597
+ * corpus `badExample` — distinct from `CompiledRuleBaseSchema.badExample` (an
1598
+ * optional human-readable code snippet on a compiled rule); here it is the
1599
+ * load-bearing positive-control preimage, so non-empty is required.
1600
+ */
1601
+ badExample: z.ZodEffects<z.ZodString, string, string>;
1602
+ /** The fixed POSTIMAGE exemplar the matcher must stay SILENT on (§4) — a lesson `goodExample`. */
1603
+ goodExample: z.ZodEffects<z.ZodString, string, string>;
1604
+ }, "strict", z.ZodTypeAny, {
1605
+ kind: "lesson";
1606
+ lessonRef: string;
1607
+ badExample: string;
1608
+ goodExample: string;
1609
+ }, {
1610
+ kind: "lesson";
1611
+ lessonRef: string;
1612
+ badExample: string;
1613
+ goodExample: string;
1614
+ }>, z.ZodObject<{
1615
+ kind: z.ZodLiteral<"commit">;
1616
+ /** The PARENT (pre-fix) commit where the DEFECT is present — the matcher must FIRE on this (ADR-112 §4). */
1617
+ preimageCommitSha: z.ZodString;
1618
+ /** The PR's merge/squash commit — the post-fix (defect-absent) anchor; the matcher must stay SILENT on this. */
1619
+ mergeCommitSha: z.ZodString;
1620
+ }, "strict", z.ZodTypeAny, {
1621
+ kind: "commit";
1622
+ preimageCommitSha: string;
1623
+ mergeCommitSha: string;
1624
+ }, {
1625
+ kind: "commit";
1626
+ preimageCommitSha: string;
1627
+ mergeCommitSha: string;
1628
+ }>]>;
827
1629
  /** File the defect locus lives in. */
828
1630
  filePath: z.ZodEffects<z.ZodString, string, string>;
829
1631
  /** Line-range or AST-node path — the defect locus, not just the file. */
830
1632
  matchedSpan: z.ZodEffects<z.ZodString, string, string>;
831
1633
  /** Span content hash, line-drift-stable (cf. `firingLabelId`). */
832
1634
  contentHash: z.ZodEffects<z.ZodString, string, string>;
833
- }, "strip", z.ZodTypeAny, {
1635
+ }, "strict", z.ZodTypeAny, {
834
1636
  pr: number;
835
- mergeCommitSha: string;
836
- preimageCommitSha: string;
1637
+ preimageSource: {
1638
+ kind: "lesson";
1639
+ lessonRef: string;
1640
+ badExample: string;
1641
+ goodExample: string;
1642
+ } | {
1643
+ kind: "commit";
1644
+ preimageCommitSha: string;
1645
+ mergeCommitSha: string;
1646
+ };
837
1647
  filePath: string;
838
1648
  matchedSpan: string;
839
1649
  contentHash: string;
840
1650
  }, {
841
1651
  pr: number;
842
- mergeCommitSha: string;
843
- preimageCommitSha: string;
1652
+ preimageSource: {
1653
+ kind: "lesson";
1654
+ lessonRef: string;
1655
+ badExample: string;
1656
+ goodExample: string;
1657
+ } | {
1658
+ kind: "commit";
1659
+ preimageCommitSha: string;
1660
+ mergeCommitSha: string;
1661
+ };
1662
+ filePath: string;
1663
+ matchedSpan: string;
1664
+ contentHash: string;
1665
+ }>, {
1666
+ pr: number;
1667
+ preimageSource: {
1668
+ kind: "lesson";
1669
+ lessonRef: string;
1670
+ badExample: string;
1671
+ goodExample: string;
1672
+ } | {
1673
+ kind: "commit";
1674
+ preimageCommitSha: string;
1675
+ mergeCommitSha: string;
1676
+ };
1677
+ filePath: string;
1678
+ matchedSpan: string;
1679
+ contentHash: string;
1680
+ }, {
1681
+ pr: number;
1682
+ preimageSource: {
1683
+ kind: "lesson";
1684
+ lessonRef: string;
1685
+ badExample: string;
1686
+ goodExample: string;
1687
+ } | {
1688
+ kind: "commit";
1689
+ preimageCommitSha: string;
1690
+ mergeCommitSha: string;
1691
+ };
844
1692
  filePath: string;
845
1693
  matchedSpan: string;
846
1694
  contentHash: string;
847
1695
  }>, "many">;
848
1696
  /** Declared near-misses the rule must stay silent on (feeds §6 negative controls). */
849
- negativeFixtures: z.ZodOptional<z.ZodArray<z.ZodObject<{
850
- /** The PR whose merge introduced the fix (the in-corpus anchor). */
1697
+ negativeFixtures: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
1698
+ /** The PR where the defect was caught/introduced (the in-corpus anchor). */
851
1699
  pr: z.ZodNumber;
852
- /** The PR's merge/squash committhe post-fix (defect-absent) anchor. */
853
- mergeCommitSha: z.ZodString;
854
- /** The PARENT (pre-fix) commit where the DEFECT is present (ADR-112 §4). */
855
- preimageCommitSha: z.ZodString;
1700
+ /** The §4 preimage-differential sourcelesson-anchored (PRIMARY) or commit-pair (FALLBACK). */
1701
+ preimageSource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
1702
+ kind: z.ZodLiteral<"lesson">;
1703
+ /** IMMUTABLE lesson id/hash (the 16-hex `hashLesson` codomain) — never a path/mutable alias (§4/§8). */
1704
+ lessonRef: z.ZodString;
1705
+ /**
1706
+ * The defect PREIMAGE exemplar the matcher must FIRE on (§4). This is a lesson
1707
+ * corpus `badExample` — distinct from `CompiledRuleBaseSchema.badExample` (an
1708
+ * optional human-readable code snippet on a compiled rule); here it is the
1709
+ * load-bearing positive-control preimage, so non-empty is required.
1710
+ */
1711
+ badExample: z.ZodEffects<z.ZodString, string, string>;
1712
+ /** The fixed POSTIMAGE exemplar the matcher must stay SILENT on (§4) — a lesson `goodExample`. */
1713
+ goodExample: z.ZodEffects<z.ZodString, string, string>;
1714
+ }, "strict", z.ZodTypeAny, {
1715
+ kind: "lesson";
1716
+ lessonRef: string;
1717
+ badExample: string;
1718
+ goodExample: string;
1719
+ }, {
1720
+ kind: "lesson";
1721
+ lessonRef: string;
1722
+ badExample: string;
1723
+ goodExample: string;
1724
+ }>, z.ZodObject<{
1725
+ kind: z.ZodLiteral<"commit">;
1726
+ /** The PARENT (pre-fix) commit where the DEFECT is present — the matcher must FIRE on this (ADR-112 §4). */
1727
+ preimageCommitSha: z.ZodString;
1728
+ /** The PR's merge/squash commit — the post-fix (defect-absent) anchor; the matcher must stay SILENT on this. */
1729
+ mergeCommitSha: z.ZodString;
1730
+ }, "strict", z.ZodTypeAny, {
1731
+ kind: "commit";
1732
+ preimageCommitSha: string;
1733
+ mergeCommitSha: string;
1734
+ }, {
1735
+ kind: "commit";
1736
+ preimageCommitSha: string;
1737
+ mergeCommitSha: string;
1738
+ }>]>;
856
1739
  /** File the defect locus lives in. */
857
1740
  filePath: z.ZodEffects<z.ZodString, string, string>;
858
1741
  /** Line-range or AST-node path — the defect locus, not just the file. */
859
1742
  matchedSpan: z.ZodEffects<z.ZodString, string, string>;
860
1743
  /** Span content hash, line-drift-stable (cf. `firingLabelId`). */
861
1744
  contentHash: z.ZodEffects<z.ZodString, string, string>;
862
- }, "strip", z.ZodTypeAny, {
1745
+ }, "strict", z.ZodTypeAny, {
863
1746
  pr: number;
864
- mergeCommitSha: string;
865
- preimageCommitSha: string;
1747
+ preimageSource: {
1748
+ kind: "lesson";
1749
+ lessonRef: string;
1750
+ badExample: string;
1751
+ goodExample: string;
1752
+ } | {
1753
+ kind: "commit";
1754
+ preimageCommitSha: string;
1755
+ mergeCommitSha: string;
1756
+ };
866
1757
  filePath: string;
867
1758
  matchedSpan: string;
868
1759
  contentHash: string;
869
1760
  }, {
870
1761
  pr: number;
871
- mergeCommitSha: string;
872
- preimageCommitSha: string;
1762
+ preimageSource: {
1763
+ kind: "lesson";
1764
+ lessonRef: string;
1765
+ badExample: string;
1766
+ goodExample: string;
1767
+ } | {
1768
+ kind: "commit";
1769
+ preimageCommitSha: string;
1770
+ mergeCommitSha: string;
1771
+ };
1772
+ filePath: string;
1773
+ matchedSpan: string;
1774
+ contentHash: string;
1775
+ }>, {
1776
+ pr: number;
1777
+ preimageSource: {
1778
+ kind: "lesson";
1779
+ lessonRef: string;
1780
+ badExample: string;
1781
+ goodExample: string;
1782
+ } | {
1783
+ kind: "commit";
1784
+ preimageCommitSha: string;
1785
+ mergeCommitSha: string;
1786
+ };
1787
+ filePath: string;
1788
+ matchedSpan: string;
1789
+ contentHash: string;
1790
+ }, {
1791
+ pr: number;
1792
+ preimageSource: {
1793
+ kind: "lesson";
1794
+ lessonRef: string;
1795
+ badExample: string;
1796
+ goodExample: string;
1797
+ } | {
1798
+ kind: "commit";
1799
+ preimageCommitSha: string;
1800
+ mergeCommitSha: string;
1801
+ };
873
1802
  filePath: string;
874
1803
  matchedSpan: string;
875
1804
  contentHash: string;
@@ -881,16 +1810,32 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
881
1810
  targetDefect: string;
882
1811
  positiveFixtures: {
883
1812
  pr: number;
884
- mergeCommitSha: string;
885
- preimageCommitSha: string;
1813
+ preimageSource: {
1814
+ kind: "lesson";
1815
+ lessonRef: string;
1816
+ badExample: string;
1817
+ goodExample: string;
1818
+ } | {
1819
+ kind: "commit";
1820
+ preimageCommitSha: string;
1821
+ mergeCommitSha: string;
1822
+ };
886
1823
  filePath: string;
887
1824
  matchedSpan: string;
888
1825
  contentHash: string;
889
1826
  }[];
890
1827
  negativeFixtures?: {
891
1828
  pr: number;
892
- mergeCommitSha: string;
893
- preimageCommitSha: string;
1829
+ preimageSource: {
1830
+ kind: "lesson";
1831
+ lessonRef: string;
1832
+ badExample: string;
1833
+ goodExample: string;
1834
+ } | {
1835
+ kind: "commit";
1836
+ preimageCommitSha: string;
1837
+ mergeCommitSha: string;
1838
+ };
894
1839
  filePath: string;
895
1840
  matchedSpan: string;
896
1841
  contentHash: string;
@@ -902,16 +1847,32 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
902
1847
  targetDefect: string;
903
1848
  positiveFixtures: {
904
1849
  pr: number;
905
- mergeCommitSha: string;
906
- preimageCommitSha: string;
1850
+ preimageSource: {
1851
+ kind: "lesson";
1852
+ lessonRef: string;
1853
+ badExample: string;
1854
+ goodExample: string;
1855
+ } | {
1856
+ kind: "commit";
1857
+ preimageCommitSha: string;
1858
+ mergeCommitSha: string;
1859
+ };
907
1860
  filePath: string;
908
1861
  matchedSpan: string;
909
1862
  contentHash: string;
910
1863
  }[];
911
1864
  negativeFixtures?: {
912
1865
  pr: number;
913
- mergeCommitSha: string;
914
- preimageCommitSha: string;
1866
+ preimageSource: {
1867
+ kind: "lesson";
1868
+ lessonRef: string;
1869
+ badExample: string;
1870
+ goodExample: string;
1871
+ } | {
1872
+ kind: "commit";
1873
+ preimageCommitSha: string;
1874
+ mergeCommitSha: string;
1875
+ };
915
1876
  filePath: string;
916
1877
  matchedSpan: string;
917
1878
  contentHash: string;
@@ -963,16 +1924,32 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
963
1924
  targetDefect: string;
964
1925
  positiveFixtures: {
965
1926
  pr: number;
966
- mergeCommitSha: string;
967
- preimageCommitSha: string;
1927
+ preimageSource: {
1928
+ kind: "lesson";
1929
+ lessonRef: string;
1930
+ badExample: string;
1931
+ goodExample: string;
1932
+ } | {
1933
+ kind: "commit";
1934
+ preimageCommitSha: string;
1935
+ mergeCommitSha: string;
1936
+ };
968
1937
  filePath: string;
969
1938
  matchedSpan: string;
970
1939
  contentHash: string;
971
1940
  }[];
972
1941
  negativeFixtures?: {
973
1942
  pr: number;
974
- mergeCommitSha: string;
975
- preimageCommitSha: string;
1943
+ preimageSource: {
1944
+ kind: "lesson";
1945
+ lessonRef: string;
1946
+ badExample: string;
1947
+ goodExample: string;
1948
+ } | {
1949
+ kind: "commit";
1950
+ preimageCommitSha: string;
1951
+ mergeCommitSha: string;
1952
+ };
976
1953
  filePath: string;
977
1954
  matchedSpan: string;
978
1955
  contentHash: string;
@@ -993,16 +1970,32 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
993
1970
  targetDefect: string;
994
1971
  positiveFixtures: {
995
1972
  pr: number;
996
- mergeCommitSha: string;
997
- preimageCommitSha: string;
1973
+ preimageSource: {
1974
+ kind: "lesson";
1975
+ lessonRef: string;
1976
+ badExample: string;
1977
+ goodExample: string;
1978
+ } | {
1979
+ kind: "commit";
1980
+ preimageCommitSha: string;
1981
+ mergeCommitSha: string;
1982
+ };
998
1983
  filePath: string;
999
1984
  matchedSpan: string;
1000
1985
  contentHash: string;
1001
1986
  }[];
1002
1987
  negativeFixtures?: {
1003
1988
  pr: number;
1004
- mergeCommitSha: string;
1005
- preimageCommitSha: string;
1989
+ preimageSource: {
1990
+ kind: "lesson";
1991
+ lessonRef: string;
1992
+ badExample: string;
1993
+ goodExample: string;
1994
+ } | {
1995
+ kind: "commit";
1996
+ preimageCommitSha: string;
1997
+ mergeCommitSha: string;
1998
+ };
1006
1999
  filePath: string;
1007
2000
  matchedSpan: string;
1008
2001
  contentHash: string;
@@ -1030,13 +2023,13 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
1030
2023
  engine: "regex" | "ast" | "ast-grep";
1031
2024
  compiledAt: string;
1032
2025
  status?: "active" | "archived" | "untested-against-codebase" | "pending-verification" | undefined;
2026
+ badExample?: string | undefined;
2027
+ goodExample?: string | undefined;
1033
2028
  astQuery?: string | undefined;
1034
2029
  astGrepPattern?: string | undefined;
1035
2030
  astGrepYamlRule?: z.objectOutputType<{
1036
2031
  rule: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1037
2032
  }, z.ZodTypeAny, "passthrough"> | undefined;
1038
- badExample?: string | undefined;
1039
- goodExample?: string | undefined;
1040
2033
  createdAt?: string | undefined;
1041
2034
  fileGlobs?: string[] | undefined;
1042
2035
  category?: "security" | "architecture" | "style" | "performance" | undefined;
@@ -1060,16 +2053,32 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
1060
2053
  targetDefect: string;
1061
2054
  positiveFixtures: {
1062
2055
  pr: number;
1063
- mergeCommitSha: string;
1064
- preimageCommitSha: string;
2056
+ preimageSource: {
2057
+ kind: "lesson";
2058
+ lessonRef: string;
2059
+ badExample: string;
2060
+ goodExample: string;
2061
+ } | {
2062
+ kind: "commit";
2063
+ preimageCommitSha: string;
2064
+ mergeCommitSha: string;
2065
+ };
1065
2066
  filePath: string;
1066
2067
  matchedSpan: string;
1067
2068
  contentHash: string;
1068
2069
  }[];
1069
2070
  negativeFixtures?: {
1070
2071
  pr: number;
1071
- mergeCommitSha: string;
1072
- preimageCommitSha: string;
2072
+ preimageSource: {
2073
+ kind: "lesson";
2074
+ lessonRef: string;
2075
+ badExample: string;
2076
+ goodExample: string;
2077
+ } | {
2078
+ kind: "commit";
2079
+ preimageCommitSha: string;
2080
+ mergeCommitSha: string;
2081
+ };
1073
2082
  filePath: string;
1074
2083
  matchedSpan: string;
1075
2084
  contentHash: string;
@@ -1087,13 +2096,13 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
1087
2096
  engine: "regex" | "ast" | "ast-grep";
1088
2097
  compiledAt: string;
1089
2098
  status?: "active" | "archived" | "untested-against-codebase" | "pending-verification" | undefined;
2099
+ badExample?: string | undefined;
2100
+ goodExample?: string | undefined;
1090
2101
  astQuery?: string | undefined;
1091
2102
  astGrepPattern?: string | undefined;
1092
2103
  astGrepYamlRule?: z.objectInputType<{
1093
2104
  rule: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1094
2105
  }, z.ZodTypeAny, "passthrough"> | undefined;
1095
- badExample?: string | undefined;
1096
- goodExample?: string | undefined;
1097
2106
  createdAt?: string | undefined;
1098
2107
  fileGlobs?: string[] | undefined;
1099
2108
  category?: "security" | "architecture" | "style" | "performance" | undefined;
@@ -1117,16 +2126,32 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
1117
2126
  targetDefect: string;
1118
2127
  positiveFixtures: {
1119
2128
  pr: number;
1120
- mergeCommitSha: string;
1121
- preimageCommitSha: string;
2129
+ preimageSource: {
2130
+ kind: "lesson";
2131
+ lessonRef: string;
2132
+ badExample: string;
2133
+ goodExample: string;
2134
+ } | {
2135
+ kind: "commit";
2136
+ preimageCommitSha: string;
2137
+ mergeCommitSha: string;
2138
+ };
1122
2139
  filePath: string;
1123
2140
  matchedSpan: string;
1124
2141
  contentHash: string;
1125
2142
  }[];
1126
2143
  negativeFixtures?: {
1127
2144
  pr: number;
1128
- mergeCommitSha: string;
1129
- preimageCommitSha: string;
2145
+ preimageSource: {
2146
+ kind: "lesson";
2147
+ lessonRef: string;
2148
+ badExample: string;
2149
+ goodExample: string;
2150
+ } | {
2151
+ kind: "commit";
2152
+ preimageCommitSha: string;
2153
+ mergeCommitSha: string;
2154
+ };
1130
2155
  filePath: string;
1131
2156
  matchedSpan: string;
1132
2157
  contentHash: string;
@@ -1144,13 +2169,13 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
1144
2169
  engine: "regex" | "ast" | "ast-grep";
1145
2170
  compiledAt: string;
1146
2171
  status?: "active" | "archived" | "untested-against-codebase" | "pending-verification" | undefined;
2172
+ badExample?: string | undefined;
2173
+ goodExample?: string | undefined;
1147
2174
  astQuery?: string | undefined;
1148
2175
  astGrepPattern?: string | undefined;
1149
2176
  astGrepYamlRule?: z.objectOutputType<{
1150
2177
  rule: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1151
2178
  }, z.ZodTypeAny, "passthrough"> | undefined;
1152
- badExample?: string | undefined;
1153
- goodExample?: string | undefined;
1154
2179
  createdAt?: string | undefined;
1155
2180
  fileGlobs?: string[] | undefined;
1156
2181
  category?: "security" | "architecture" | "style" | "performance" | undefined;
@@ -1174,16 +2199,32 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
1174
2199
  targetDefect: string;
1175
2200
  positiveFixtures: {
1176
2201
  pr: number;
1177
- mergeCommitSha: string;
1178
- preimageCommitSha: string;
2202
+ preimageSource: {
2203
+ kind: "lesson";
2204
+ lessonRef: string;
2205
+ badExample: string;
2206
+ goodExample: string;
2207
+ } | {
2208
+ kind: "commit";
2209
+ preimageCommitSha: string;
2210
+ mergeCommitSha: string;
2211
+ };
1179
2212
  filePath: string;
1180
2213
  matchedSpan: string;
1181
2214
  contentHash: string;
1182
2215
  }[];
1183
2216
  negativeFixtures?: {
1184
2217
  pr: number;
1185
- mergeCommitSha: string;
1186
- preimageCommitSha: string;
2218
+ preimageSource: {
2219
+ kind: "lesson";
2220
+ lessonRef: string;
2221
+ badExample: string;
2222
+ goodExample: string;
2223
+ } | {
2224
+ kind: "commit";
2225
+ preimageCommitSha: string;
2226
+ mergeCommitSha: string;
2227
+ };
1187
2228
  filePath: string;
1188
2229
  matchedSpan: string;
1189
2230
  contentHash: string;
@@ -1201,13 +2242,13 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
1201
2242
  engine: "regex" | "ast" | "ast-grep";
1202
2243
  compiledAt: string;
1203
2244
  status?: "active" | "archived" | "untested-against-codebase" | "pending-verification" | undefined;
2245
+ badExample?: string | undefined;
2246
+ goodExample?: string | undefined;
1204
2247
  astQuery?: string | undefined;
1205
2248
  astGrepPattern?: string | undefined;
1206
2249
  astGrepYamlRule?: z.objectInputType<{
1207
2250
  rule: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1208
2251
  }, z.ZodTypeAny, "passthrough"> | undefined;
1209
- badExample?: string | undefined;
1210
- goodExample?: string | undefined;
1211
2252
  createdAt?: string | undefined;
1212
2253
  fileGlobs?: string[] | undefined;
1213
2254
  category?: "security" | "architecture" | "style" | "performance" | undefined;
@@ -1231,16 +2272,32 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
1231
2272
  targetDefect: string;
1232
2273
  positiveFixtures: {
1233
2274
  pr: number;
1234
- mergeCommitSha: string;
1235
- preimageCommitSha: string;
2275
+ preimageSource: {
2276
+ kind: "lesson";
2277
+ lessonRef: string;
2278
+ badExample: string;
2279
+ goodExample: string;
2280
+ } | {
2281
+ kind: "commit";
2282
+ preimageCommitSha: string;
2283
+ mergeCommitSha: string;
2284
+ };
1236
2285
  filePath: string;
1237
2286
  matchedSpan: string;
1238
2287
  contentHash: string;
1239
2288
  }[];
1240
2289
  negativeFixtures?: {
1241
2290
  pr: number;
1242
- mergeCommitSha: string;
1243
- preimageCommitSha: string;
2291
+ preimageSource: {
2292
+ kind: "lesson";
2293
+ lessonRef: string;
2294
+ badExample: string;
2295
+ goodExample: string;
2296
+ } | {
2297
+ kind: "commit";
2298
+ preimageCommitSha: string;
2299
+ mergeCommitSha: string;
2300
+ };
1244
2301
  filePath: string;
1245
2302
  matchedSpan: string;
1246
2303
  contentHash: string;
@@ -1551,59 +2608,221 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
1551
2608
  /** The declared DEFECT the rule targets — the pre-image, not its fix. */
1552
2609
  targetDefect: z.ZodEffects<z.ZodString, string, string>;
1553
2610
  /** ≥1 real lc instance the rule claims to catch — ALL train-side (§5). */
1554
- positiveFixtures: z.ZodArray<z.ZodObject<{
1555
- /** The PR whose merge introduced the fix (the in-corpus anchor). */
2611
+ positiveFixtures: z.ZodArray<z.ZodEffects<z.ZodObject<{
2612
+ /** The PR where the defect was caught/introduced (the in-corpus anchor). */
1556
2613
  pr: z.ZodNumber;
1557
- /** The PR's merge/squash committhe post-fix (defect-absent) anchor. */
1558
- mergeCommitSha: z.ZodString;
1559
- /** The PARENT (pre-fix) commit where the DEFECT is present (ADR-112 §4). */
1560
- preimageCommitSha: z.ZodString;
2614
+ /** The §4 preimage-differential sourcelesson-anchored (PRIMARY) or commit-pair (FALLBACK). */
2615
+ preimageSource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
2616
+ kind: z.ZodLiteral<"lesson">;
2617
+ /** IMMUTABLE lesson id/hash (the 16-hex `hashLesson` codomain) — never a path/mutable alias (§4/§8). */
2618
+ lessonRef: z.ZodString;
2619
+ /**
2620
+ * The defect PREIMAGE exemplar the matcher must FIRE on (§4). This is a lesson
2621
+ * corpus `badExample` — distinct from `CompiledRuleBaseSchema.badExample` (an
2622
+ * optional human-readable code snippet on a compiled rule); here it is the
2623
+ * load-bearing positive-control preimage, so non-empty is required.
2624
+ */
2625
+ badExample: z.ZodEffects<z.ZodString, string, string>;
2626
+ /** The fixed POSTIMAGE exemplar the matcher must stay SILENT on (§4) — a lesson `goodExample`. */
2627
+ goodExample: z.ZodEffects<z.ZodString, string, string>;
2628
+ }, "strict", z.ZodTypeAny, {
2629
+ kind: "lesson";
2630
+ lessonRef: string;
2631
+ badExample: string;
2632
+ goodExample: string;
2633
+ }, {
2634
+ kind: "lesson";
2635
+ lessonRef: string;
2636
+ badExample: string;
2637
+ goodExample: string;
2638
+ }>, z.ZodObject<{
2639
+ kind: z.ZodLiteral<"commit">;
2640
+ /** The PARENT (pre-fix) commit where the DEFECT is present — the matcher must FIRE on this (ADR-112 §4). */
2641
+ preimageCommitSha: z.ZodString;
2642
+ /** The PR's merge/squash commit — the post-fix (defect-absent) anchor; the matcher must stay SILENT on this. */
2643
+ mergeCommitSha: z.ZodString;
2644
+ }, "strict", z.ZodTypeAny, {
2645
+ kind: "commit";
2646
+ preimageCommitSha: string;
2647
+ mergeCommitSha: string;
2648
+ }, {
2649
+ kind: "commit";
2650
+ preimageCommitSha: string;
2651
+ mergeCommitSha: string;
2652
+ }>]>;
1561
2653
  /** File the defect locus lives in. */
1562
2654
  filePath: z.ZodEffects<z.ZodString, string, string>;
1563
2655
  /** Line-range or AST-node path — the defect locus, not just the file. */
1564
2656
  matchedSpan: z.ZodEffects<z.ZodString, string, string>;
1565
2657
  /** Span content hash, line-drift-stable (cf. `firingLabelId`). */
1566
2658
  contentHash: z.ZodEffects<z.ZodString, string, string>;
1567
- }, "strip", z.ZodTypeAny, {
2659
+ }, "strict", z.ZodTypeAny, {
1568
2660
  pr: number;
1569
- mergeCommitSha: string;
1570
- preimageCommitSha: string;
2661
+ preimageSource: {
2662
+ kind: "lesson";
2663
+ lessonRef: string;
2664
+ badExample: string;
2665
+ goodExample: string;
2666
+ } | {
2667
+ kind: "commit";
2668
+ preimageCommitSha: string;
2669
+ mergeCommitSha: string;
2670
+ };
1571
2671
  filePath: string;
1572
2672
  matchedSpan: string;
1573
2673
  contentHash: string;
1574
2674
  }, {
1575
2675
  pr: number;
1576
- mergeCommitSha: string;
1577
- preimageCommitSha: string;
2676
+ preimageSource: {
2677
+ kind: "lesson";
2678
+ lessonRef: string;
2679
+ badExample: string;
2680
+ goodExample: string;
2681
+ } | {
2682
+ kind: "commit";
2683
+ preimageCommitSha: string;
2684
+ mergeCommitSha: string;
2685
+ };
2686
+ filePath: string;
2687
+ matchedSpan: string;
2688
+ contentHash: string;
2689
+ }>, {
2690
+ pr: number;
2691
+ preimageSource: {
2692
+ kind: "lesson";
2693
+ lessonRef: string;
2694
+ badExample: string;
2695
+ goodExample: string;
2696
+ } | {
2697
+ kind: "commit";
2698
+ preimageCommitSha: string;
2699
+ mergeCommitSha: string;
2700
+ };
2701
+ filePath: string;
2702
+ matchedSpan: string;
2703
+ contentHash: string;
2704
+ }, {
2705
+ pr: number;
2706
+ preimageSource: {
2707
+ kind: "lesson";
2708
+ lessonRef: string;
2709
+ badExample: string;
2710
+ goodExample: string;
2711
+ } | {
2712
+ kind: "commit";
2713
+ preimageCommitSha: string;
2714
+ mergeCommitSha: string;
2715
+ };
1578
2716
  filePath: string;
1579
2717
  matchedSpan: string;
1580
2718
  contentHash: string;
1581
2719
  }>, "many">;
1582
2720
  /** Declared near-misses the rule must stay silent on (feeds §6 negative controls). */
1583
- negativeFixtures: z.ZodOptional<z.ZodArray<z.ZodObject<{
1584
- /** The PR whose merge introduced the fix (the in-corpus anchor). */
2721
+ negativeFixtures: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodObject<{
2722
+ /** The PR where the defect was caught/introduced (the in-corpus anchor). */
1585
2723
  pr: z.ZodNumber;
1586
- /** The PR's merge/squash committhe post-fix (defect-absent) anchor. */
1587
- mergeCommitSha: z.ZodString;
1588
- /** The PARENT (pre-fix) commit where the DEFECT is present (ADR-112 §4). */
1589
- preimageCommitSha: z.ZodString;
2724
+ /** The §4 preimage-differential sourcelesson-anchored (PRIMARY) or commit-pair (FALLBACK). */
2725
+ preimageSource: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
2726
+ kind: z.ZodLiteral<"lesson">;
2727
+ /** IMMUTABLE lesson id/hash (the 16-hex `hashLesson` codomain) — never a path/mutable alias (§4/§8). */
2728
+ lessonRef: z.ZodString;
2729
+ /**
2730
+ * The defect PREIMAGE exemplar the matcher must FIRE on (§4). This is a lesson
2731
+ * corpus `badExample` — distinct from `CompiledRuleBaseSchema.badExample` (an
2732
+ * optional human-readable code snippet on a compiled rule); here it is the
2733
+ * load-bearing positive-control preimage, so non-empty is required.
2734
+ */
2735
+ badExample: z.ZodEffects<z.ZodString, string, string>;
2736
+ /** The fixed POSTIMAGE exemplar the matcher must stay SILENT on (§4) — a lesson `goodExample`. */
2737
+ goodExample: z.ZodEffects<z.ZodString, string, string>;
2738
+ }, "strict", z.ZodTypeAny, {
2739
+ kind: "lesson";
2740
+ lessonRef: string;
2741
+ badExample: string;
2742
+ goodExample: string;
2743
+ }, {
2744
+ kind: "lesson";
2745
+ lessonRef: string;
2746
+ badExample: string;
2747
+ goodExample: string;
2748
+ }>, z.ZodObject<{
2749
+ kind: z.ZodLiteral<"commit">;
2750
+ /** The PARENT (pre-fix) commit where the DEFECT is present — the matcher must FIRE on this (ADR-112 §4). */
2751
+ preimageCommitSha: z.ZodString;
2752
+ /** The PR's merge/squash commit — the post-fix (defect-absent) anchor; the matcher must stay SILENT on this. */
2753
+ mergeCommitSha: z.ZodString;
2754
+ }, "strict", z.ZodTypeAny, {
2755
+ kind: "commit";
2756
+ preimageCommitSha: string;
2757
+ mergeCommitSha: string;
2758
+ }, {
2759
+ kind: "commit";
2760
+ preimageCommitSha: string;
2761
+ mergeCommitSha: string;
2762
+ }>]>;
1590
2763
  /** File the defect locus lives in. */
1591
2764
  filePath: z.ZodEffects<z.ZodString, string, string>;
1592
2765
  /** Line-range or AST-node path — the defect locus, not just the file. */
1593
2766
  matchedSpan: z.ZodEffects<z.ZodString, string, string>;
1594
2767
  /** Span content hash, line-drift-stable (cf. `firingLabelId`). */
1595
2768
  contentHash: z.ZodEffects<z.ZodString, string, string>;
1596
- }, "strip", z.ZodTypeAny, {
2769
+ }, "strict", z.ZodTypeAny, {
1597
2770
  pr: number;
1598
- mergeCommitSha: string;
1599
- preimageCommitSha: string;
2771
+ preimageSource: {
2772
+ kind: "lesson";
2773
+ lessonRef: string;
2774
+ badExample: string;
2775
+ goodExample: string;
2776
+ } | {
2777
+ kind: "commit";
2778
+ preimageCommitSha: string;
2779
+ mergeCommitSha: string;
2780
+ };
1600
2781
  filePath: string;
1601
2782
  matchedSpan: string;
1602
2783
  contentHash: string;
1603
2784
  }, {
1604
2785
  pr: number;
1605
- mergeCommitSha: string;
1606
- preimageCommitSha: string;
2786
+ preimageSource: {
2787
+ kind: "lesson";
2788
+ lessonRef: string;
2789
+ badExample: string;
2790
+ goodExample: string;
2791
+ } | {
2792
+ kind: "commit";
2793
+ preimageCommitSha: string;
2794
+ mergeCommitSha: string;
2795
+ };
2796
+ filePath: string;
2797
+ matchedSpan: string;
2798
+ contentHash: string;
2799
+ }>, {
2800
+ pr: number;
2801
+ preimageSource: {
2802
+ kind: "lesson";
2803
+ lessonRef: string;
2804
+ badExample: string;
2805
+ goodExample: string;
2806
+ } | {
2807
+ kind: "commit";
2808
+ preimageCommitSha: string;
2809
+ mergeCommitSha: string;
2810
+ };
2811
+ filePath: string;
2812
+ matchedSpan: string;
2813
+ contentHash: string;
2814
+ }, {
2815
+ pr: number;
2816
+ preimageSource: {
2817
+ kind: "lesson";
2818
+ lessonRef: string;
2819
+ badExample: string;
2820
+ goodExample: string;
2821
+ } | {
2822
+ kind: "commit";
2823
+ preimageCommitSha: string;
2824
+ mergeCommitSha: string;
2825
+ };
1607
2826
  filePath: string;
1608
2827
  matchedSpan: string;
1609
2828
  contentHash: string;
@@ -1615,16 +2834,32 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
1615
2834
  targetDefect: string;
1616
2835
  positiveFixtures: {
1617
2836
  pr: number;
1618
- mergeCommitSha: string;
1619
- preimageCommitSha: string;
2837
+ preimageSource: {
2838
+ kind: "lesson";
2839
+ lessonRef: string;
2840
+ badExample: string;
2841
+ goodExample: string;
2842
+ } | {
2843
+ kind: "commit";
2844
+ preimageCommitSha: string;
2845
+ mergeCommitSha: string;
2846
+ };
1620
2847
  filePath: string;
1621
2848
  matchedSpan: string;
1622
2849
  contentHash: string;
1623
2850
  }[];
1624
2851
  negativeFixtures?: {
1625
2852
  pr: number;
1626
- mergeCommitSha: string;
1627
- preimageCommitSha: string;
2853
+ preimageSource: {
2854
+ kind: "lesson";
2855
+ lessonRef: string;
2856
+ badExample: string;
2857
+ goodExample: string;
2858
+ } | {
2859
+ kind: "commit";
2860
+ preimageCommitSha: string;
2861
+ mergeCommitSha: string;
2862
+ };
1628
2863
  filePath: string;
1629
2864
  matchedSpan: string;
1630
2865
  contentHash: string;
@@ -1636,16 +2871,32 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
1636
2871
  targetDefect: string;
1637
2872
  positiveFixtures: {
1638
2873
  pr: number;
1639
- mergeCommitSha: string;
1640
- preimageCommitSha: string;
2874
+ preimageSource: {
2875
+ kind: "lesson";
2876
+ lessonRef: string;
2877
+ badExample: string;
2878
+ goodExample: string;
2879
+ } | {
2880
+ kind: "commit";
2881
+ preimageCommitSha: string;
2882
+ mergeCommitSha: string;
2883
+ };
1641
2884
  filePath: string;
1642
2885
  matchedSpan: string;
1643
2886
  contentHash: string;
1644
2887
  }[];
1645
2888
  negativeFixtures?: {
1646
2889
  pr: number;
1647
- mergeCommitSha: string;
1648
- preimageCommitSha: string;
2890
+ preimageSource: {
2891
+ kind: "lesson";
2892
+ lessonRef: string;
2893
+ badExample: string;
2894
+ goodExample: string;
2895
+ } | {
2896
+ kind: "commit";
2897
+ preimageCommitSha: string;
2898
+ mergeCommitSha: string;
2899
+ };
1649
2900
  filePath: string;
1650
2901
  matchedSpan: string;
1651
2902
  contentHash: string;
@@ -1697,16 +2948,32 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
1697
2948
  targetDefect: string;
1698
2949
  positiveFixtures: {
1699
2950
  pr: number;
1700
- mergeCommitSha: string;
1701
- preimageCommitSha: string;
2951
+ preimageSource: {
2952
+ kind: "lesson";
2953
+ lessonRef: string;
2954
+ badExample: string;
2955
+ goodExample: string;
2956
+ } | {
2957
+ kind: "commit";
2958
+ preimageCommitSha: string;
2959
+ mergeCommitSha: string;
2960
+ };
1702
2961
  filePath: string;
1703
2962
  matchedSpan: string;
1704
2963
  contentHash: string;
1705
2964
  }[];
1706
2965
  negativeFixtures?: {
1707
2966
  pr: number;
1708
- mergeCommitSha: string;
1709
- preimageCommitSha: string;
2967
+ preimageSource: {
2968
+ kind: "lesson";
2969
+ lessonRef: string;
2970
+ badExample: string;
2971
+ goodExample: string;
2972
+ } | {
2973
+ kind: "commit";
2974
+ preimageCommitSha: string;
2975
+ mergeCommitSha: string;
2976
+ };
1710
2977
  filePath: string;
1711
2978
  matchedSpan: string;
1712
2979
  contentHash: string;
@@ -1727,16 +2994,32 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
1727
2994
  targetDefect: string;
1728
2995
  positiveFixtures: {
1729
2996
  pr: number;
1730
- mergeCommitSha: string;
1731
- preimageCommitSha: string;
2997
+ preimageSource: {
2998
+ kind: "lesson";
2999
+ lessonRef: string;
3000
+ badExample: string;
3001
+ goodExample: string;
3002
+ } | {
3003
+ kind: "commit";
3004
+ preimageCommitSha: string;
3005
+ mergeCommitSha: string;
3006
+ };
1732
3007
  filePath: string;
1733
3008
  matchedSpan: string;
1734
3009
  contentHash: string;
1735
3010
  }[];
1736
3011
  negativeFixtures?: {
1737
3012
  pr: number;
1738
- mergeCommitSha: string;
1739
- preimageCommitSha: string;
3013
+ preimageSource: {
3014
+ kind: "lesson";
3015
+ lessonRef: string;
3016
+ badExample: string;
3017
+ goodExample: string;
3018
+ } | {
3019
+ kind: "commit";
3020
+ preimageCommitSha: string;
3021
+ mergeCommitSha: string;
3022
+ };
1740
3023
  filePath: string;
1741
3024
  matchedSpan: string;
1742
3025
  contentHash: string;
@@ -1764,13 +3047,13 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
1764
3047
  engine: "regex" | "ast" | "ast-grep";
1765
3048
  compiledAt: string;
1766
3049
  status?: "active" | "archived" | "untested-against-codebase" | "pending-verification" | undefined;
3050
+ badExample?: string | undefined;
3051
+ goodExample?: string | undefined;
1767
3052
  astQuery?: string | undefined;
1768
3053
  astGrepPattern?: string | undefined;
1769
3054
  astGrepYamlRule?: z.objectOutputType<{
1770
3055
  rule: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1771
3056
  }, z.ZodTypeAny, "passthrough"> | undefined;
1772
- badExample?: string | undefined;
1773
- goodExample?: string | undefined;
1774
3057
  createdAt?: string | undefined;
1775
3058
  fileGlobs?: string[] | undefined;
1776
3059
  category?: "security" | "architecture" | "style" | "performance" | undefined;
@@ -1794,16 +3077,32 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
1794
3077
  targetDefect: string;
1795
3078
  positiveFixtures: {
1796
3079
  pr: number;
1797
- mergeCommitSha: string;
1798
- preimageCommitSha: string;
3080
+ preimageSource: {
3081
+ kind: "lesson";
3082
+ lessonRef: string;
3083
+ badExample: string;
3084
+ goodExample: string;
3085
+ } | {
3086
+ kind: "commit";
3087
+ preimageCommitSha: string;
3088
+ mergeCommitSha: string;
3089
+ };
1799
3090
  filePath: string;
1800
3091
  matchedSpan: string;
1801
3092
  contentHash: string;
1802
3093
  }[];
1803
3094
  negativeFixtures?: {
1804
3095
  pr: number;
1805
- mergeCommitSha: string;
1806
- preimageCommitSha: string;
3096
+ preimageSource: {
3097
+ kind: "lesson";
3098
+ lessonRef: string;
3099
+ badExample: string;
3100
+ goodExample: string;
3101
+ } | {
3102
+ kind: "commit";
3103
+ preimageCommitSha: string;
3104
+ mergeCommitSha: string;
3105
+ };
1807
3106
  filePath: string;
1808
3107
  matchedSpan: string;
1809
3108
  contentHash: string;
@@ -1821,13 +3120,13 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
1821
3120
  engine: "regex" | "ast" | "ast-grep";
1822
3121
  compiledAt: string;
1823
3122
  status?: "active" | "archived" | "untested-against-codebase" | "pending-verification" | undefined;
3123
+ badExample?: string | undefined;
3124
+ goodExample?: string | undefined;
1824
3125
  astQuery?: string | undefined;
1825
3126
  astGrepPattern?: string | undefined;
1826
3127
  astGrepYamlRule?: z.objectInputType<{
1827
3128
  rule: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1828
3129
  }, z.ZodTypeAny, "passthrough"> | undefined;
1829
- badExample?: string | undefined;
1830
- goodExample?: string | undefined;
1831
3130
  createdAt?: string | undefined;
1832
3131
  fileGlobs?: string[] | undefined;
1833
3132
  category?: "security" | "architecture" | "style" | "performance" | undefined;
@@ -1851,16 +3150,32 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
1851
3150
  targetDefect: string;
1852
3151
  positiveFixtures: {
1853
3152
  pr: number;
1854
- mergeCommitSha: string;
1855
- preimageCommitSha: string;
3153
+ preimageSource: {
3154
+ kind: "lesson";
3155
+ lessonRef: string;
3156
+ badExample: string;
3157
+ goodExample: string;
3158
+ } | {
3159
+ kind: "commit";
3160
+ preimageCommitSha: string;
3161
+ mergeCommitSha: string;
3162
+ };
1856
3163
  filePath: string;
1857
3164
  matchedSpan: string;
1858
3165
  contentHash: string;
1859
3166
  }[];
1860
3167
  negativeFixtures?: {
1861
3168
  pr: number;
1862
- mergeCommitSha: string;
1863
- preimageCommitSha: string;
3169
+ preimageSource: {
3170
+ kind: "lesson";
3171
+ lessonRef: string;
3172
+ badExample: string;
3173
+ goodExample: string;
3174
+ } | {
3175
+ kind: "commit";
3176
+ preimageCommitSha: string;
3177
+ mergeCommitSha: string;
3178
+ };
1864
3179
  filePath: string;
1865
3180
  matchedSpan: string;
1866
3181
  contentHash: string;
@@ -1878,13 +3193,13 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
1878
3193
  engine: "regex" | "ast" | "ast-grep";
1879
3194
  compiledAt: string;
1880
3195
  status?: "active" | "archived" | "untested-against-codebase" | "pending-verification" | undefined;
3196
+ badExample?: string | undefined;
3197
+ goodExample?: string | undefined;
1881
3198
  astQuery?: string | undefined;
1882
3199
  astGrepPattern?: string | undefined;
1883
3200
  astGrepYamlRule?: z.objectOutputType<{
1884
3201
  rule: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1885
3202
  }, z.ZodTypeAny, "passthrough"> | undefined;
1886
- badExample?: string | undefined;
1887
- goodExample?: string | undefined;
1888
3203
  createdAt?: string | undefined;
1889
3204
  fileGlobs?: string[] | undefined;
1890
3205
  category?: "security" | "architecture" | "style" | "performance" | undefined;
@@ -1908,16 +3223,32 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
1908
3223
  targetDefect: string;
1909
3224
  positiveFixtures: {
1910
3225
  pr: number;
1911
- mergeCommitSha: string;
1912
- preimageCommitSha: string;
3226
+ preimageSource: {
3227
+ kind: "lesson";
3228
+ lessonRef: string;
3229
+ badExample: string;
3230
+ goodExample: string;
3231
+ } | {
3232
+ kind: "commit";
3233
+ preimageCommitSha: string;
3234
+ mergeCommitSha: string;
3235
+ };
1913
3236
  filePath: string;
1914
3237
  matchedSpan: string;
1915
3238
  contentHash: string;
1916
3239
  }[];
1917
3240
  negativeFixtures?: {
1918
3241
  pr: number;
1919
- mergeCommitSha: string;
1920
- preimageCommitSha: string;
3242
+ preimageSource: {
3243
+ kind: "lesson";
3244
+ lessonRef: string;
3245
+ badExample: string;
3246
+ goodExample: string;
3247
+ } | {
3248
+ kind: "commit";
3249
+ preimageCommitSha: string;
3250
+ mergeCommitSha: string;
3251
+ };
1921
3252
  filePath: string;
1922
3253
  matchedSpan: string;
1923
3254
  contentHash: string;
@@ -1935,13 +3266,13 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
1935
3266
  engine: "regex" | "ast" | "ast-grep";
1936
3267
  compiledAt: string;
1937
3268
  status?: "active" | "archived" | "untested-against-codebase" | "pending-verification" | undefined;
3269
+ badExample?: string | undefined;
3270
+ goodExample?: string | undefined;
1938
3271
  astQuery?: string | undefined;
1939
3272
  astGrepPattern?: string | undefined;
1940
3273
  astGrepYamlRule?: z.objectInputType<{
1941
3274
  rule: z.ZodRecord<z.ZodString, z.ZodUnknown>;
1942
3275
  }, z.ZodTypeAny, "passthrough"> | undefined;
1943
- badExample?: string | undefined;
1944
- goodExample?: string | undefined;
1945
3276
  createdAt?: string | undefined;
1946
3277
  fileGlobs?: string[] | undefined;
1947
3278
  category?: "security" | "architecture" | "style" | "performance" | undefined;
@@ -1965,16 +3296,32 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
1965
3296
  targetDefect: string;
1966
3297
  positiveFixtures: {
1967
3298
  pr: number;
1968
- mergeCommitSha: string;
1969
- preimageCommitSha: string;
3299
+ preimageSource: {
3300
+ kind: "lesson";
3301
+ lessonRef: string;
3302
+ badExample: string;
3303
+ goodExample: string;
3304
+ } | {
3305
+ kind: "commit";
3306
+ preimageCommitSha: string;
3307
+ mergeCommitSha: string;
3308
+ };
1970
3309
  filePath: string;
1971
3310
  matchedSpan: string;
1972
3311
  contentHash: string;
1973
3312
  }[];
1974
3313
  negativeFixtures?: {
1975
3314
  pr: number;
1976
- mergeCommitSha: string;
1977
- preimageCommitSha: string;
3315
+ preimageSource: {
3316
+ kind: "lesson";
3317
+ lessonRef: string;
3318
+ badExample: string;
3319
+ goodExample: string;
3320
+ } | {
3321
+ kind: "commit";
3322
+ preimageCommitSha: string;
3323
+ mergeCommitSha: string;
3324
+ };
1978
3325
  filePath: string;
1979
3326
  matchedSpan: string;
1980
3327
  contentHash: string;
@@ -2042,13 +3389,13 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
2042
3389
  engine: "regex" | "ast" | "ast-grep";
2043
3390
  compiledAt: string;
2044
3391
  status?: "active" | "archived" | "untested-against-codebase" | "pending-verification" | undefined;
3392
+ badExample?: string | undefined;
3393
+ goodExample?: string | undefined;
2045
3394
  astQuery?: string | undefined;
2046
3395
  astGrepPattern?: string | undefined;
2047
3396
  astGrepYamlRule?: z.objectOutputType<{
2048
3397
  rule: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2049
3398
  }, z.ZodTypeAny, "passthrough"> | undefined;
2050
- badExample?: string | undefined;
2051
- goodExample?: string | undefined;
2052
3399
  createdAt?: string | undefined;
2053
3400
  fileGlobs?: string[] | undefined;
2054
3401
  category?: "security" | "architecture" | "style" | "performance" | undefined;
@@ -2072,16 +3419,32 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
2072
3419
  targetDefect: string;
2073
3420
  positiveFixtures: {
2074
3421
  pr: number;
2075
- mergeCommitSha: string;
2076
- preimageCommitSha: string;
3422
+ preimageSource: {
3423
+ kind: "lesson";
3424
+ lessonRef: string;
3425
+ badExample: string;
3426
+ goodExample: string;
3427
+ } | {
3428
+ kind: "commit";
3429
+ preimageCommitSha: string;
3430
+ mergeCommitSha: string;
3431
+ };
2077
3432
  filePath: string;
2078
3433
  matchedSpan: string;
2079
3434
  contentHash: string;
2080
3435
  }[];
2081
3436
  negativeFixtures?: {
2082
3437
  pr: number;
2083
- mergeCommitSha: string;
2084
- preimageCommitSha: string;
3438
+ preimageSource: {
3439
+ kind: "lesson";
3440
+ lessonRef: string;
3441
+ badExample: string;
3442
+ goodExample: string;
3443
+ } | {
3444
+ kind: "commit";
3445
+ preimageCommitSha: string;
3446
+ mergeCommitSha: string;
3447
+ };
2085
3448
  filePath: string;
2086
3449
  matchedSpan: string;
2087
3450
  contentHash: string;
@@ -2108,13 +3471,13 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
2108
3471
  engine: "regex" | "ast" | "ast-grep";
2109
3472
  compiledAt: string;
2110
3473
  status?: "active" | "archived" | "untested-against-codebase" | "pending-verification" | undefined;
3474
+ badExample?: string | undefined;
3475
+ goodExample?: string | undefined;
2111
3476
  astQuery?: string | undefined;
2112
3477
  astGrepPattern?: string | undefined;
2113
3478
  astGrepYamlRule?: z.objectInputType<{
2114
3479
  rule: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2115
3480
  }, z.ZodTypeAny, "passthrough"> | undefined;
2116
- badExample?: string | undefined;
2117
- goodExample?: string | undefined;
2118
3481
  createdAt?: string | undefined;
2119
3482
  fileGlobs?: string[] | undefined;
2120
3483
  category?: "security" | "architecture" | "style" | "performance" | undefined;
@@ -2138,16 +3501,32 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
2138
3501
  targetDefect: string;
2139
3502
  positiveFixtures: {
2140
3503
  pr: number;
2141
- mergeCommitSha: string;
2142
- preimageCommitSha: string;
3504
+ preimageSource: {
3505
+ kind: "lesson";
3506
+ lessonRef: string;
3507
+ badExample: string;
3508
+ goodExample: string;
3509
+ } | {
3510
+ kind: "commit";
3511
+ preimageCommitSha: string;
3512
+ mergeCommitSha: string;
3513
+ };
2143
3514
  filePath: string;
2144
3515
  matchedSpan: string;
2145
3516
  contentHash: string;
2146
3517
  }[];
2147
3518
  negativeFixtures?: {
2148
3519
  pr: number;
2149
- mergeCommitSha: string;
2150
- preimageCommitSha: string;
3520
+ preimageSource: {
3521
+ kind: "lesson";
3522
+ lessonRef: string;
3523
+ badExample: string;
3524
+ goodExample: string;
3525
+ } | {
3526
+ kind: "commit";
3527
+ preimageCommitSha: string;
3528
+ mergeCommitSha: string;
3529
+ };
2151
3530
  filePath: string;
2152
3531
  matchedSpan: string;
2153
3532
  contentHash: string;
@@ -2227,6 +3606,8 @@ export declare const CompilerOutputSchema: z.ZodEffects<z.ZodObject<{
2227
3606
  }, "strip", z.ZodTypeAny, {
2228
3607
  compilable: boolean;
2229
3608
  message?: string | undefined;
3609
+ badExample?: string | undefined;
3610
+ goodExample?: string | undefined;
2230
3611
  pattern?: string | undefined;
2231
3612
  engine?: "regex" | "ast" | "ast-grep" | undefined;
2232
3613
  astQuery?: string | undefined;
@@ -2234,8 +3615,6 @@ export declare const CompilerOutputSchema: z.ZodEffects<z.ZodObject<{
2234
3615
  astGrepYamlRule?: z.objectOutputType<{
2235
3616
  rule: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2236
3617
  }, z.ZodTypeAny, "passthrough"> | undefined;
2237
- badExample?: string | undefined;
2238
- goodExample?: string | undefined;
2239
3618
  fileGlobs?: string[] | undefined;
2240
3619
  severity?: "error" | "warning" | undefined;
2241
3620
  reasonCode?: "context-required" | "semantic-analysis-required" | undefined;
@@ -2243,6 +3622,8 @@ export declare const CompilerOutputSchema: z.ZodEffects<z.ZodObject<{
2243
3622
  }, {
2244
3623
  compilable: boolean;
2245
3624
  message?: string | undefined;
3625
+ badExample?: string | undefined;
3626
+ goodExample?: string | undefined;
2246
3627
  pattern?: string | undefined;
2247
3628
  engine?: "regex" | "ast" | "ast-grep" | undefined;
2248
3629
  astQuery?: string | undefined;
@@ -2250,8 +3631,6 @@ export declare const CompilerOutputSchema: z.ZodEffects<z.ZodObject<{
2250
3631
  astGrepYamlRule?: z.objectInputType<{
2251
3632
  rule: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2252
3633
  }, z.ZodTypeAny, "passthrough"> | undefined;
2253
- badExample?: string | undefined;
2254
- goodExample?: string | undefined;
2255
3634
  fileGlobs?: string[] | undefined;
2256
3635
  severity?: "error" | "warning" | undefined;
2257
3636
  reasonCode?: "context-required" | "semantic-analysis-required" | undefined;
@@ -2259,6 +3638,8 @@ export declare const CompilerOutputSchema: z.ZodEffects<z.ZodObject<{
2259
3638
  }>, {
2260
3639
  compilable: boolean;
2261
3640
  message?: string | undefined;
3641
+ badExample?: string | undefined;
3642
+ goodExample?: string | undefined;
2262
3643
  pattern?: string | undefined;
2263
3644
  engine?: "regex" | "ast" | "ast-grep" | undefined;
2264
3645
  astQuery?: string | undefined;
@@ -2266,8 +3647,6 @@ export declare const CompilerOutputSchema: z.ZodEffects<z.ZodObject<{
2266
3647
  astGrepYamlRule?: z.objectOutputType<{
2267
3648
  rule: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2268
3649
  }, z.ZodTypeAny, "passthrough"> | undefined;
2269
- badExample?: string | undefined;
2270
- goodExample?: string | undefined;
2271
3650
  fileGlobs?: string[] | undefined;
2272
3651
  severity?: "error" | "warning" | undefined;
2273
3652
  reasonCode?: "context-required" | "semantic-analysis-required" | undefined;
@@ -2275,6 +3654,8 @@ export declare const CompilerOutputSchema: z.ZodEffects<z.ZodObject<{
2275
3654
  }, {
2276
3655
  compilable: boolean;
2277
3656
  message?: string | undefined;
3657
+ badExample?: string | undefined;
3658
+ goodExample?: string | undefined;
2278
3659
  pattern?: string | undefined;
2279
3660
  engine?: "regex" | "ast" | "ast-grep" | undefined;
2280
3661
  astQuery?: string | undefined;
@@ -2282,8 +3663,6 @@ export declare const CompilerOutputSchema: z.ZodEffects<z.ZodObject<{
2282
3663
  astGrepYamlRule?: z.objectInputType<{
2283
3664
  rule: z.ZodRecord<z.ZodString, z.ZodUnknown>;
2284
3665
  }, z.ZodTypeAny, "passthrough"> | undefined;
2285
- badExample?: string | undefined;
2286
- goodExample?: string | undefined;
2287
3666
  fileGlobs?: string[] | undefined;
2288
3667
  severity?: "error" | "warning" | undefined;
2289
3668
  reasonCode?: "context-required" | "semantic-analysis-required" | undefined;