@mmnto/totem 1.18.2 → 1.19.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.
- package/dist/compile-lesson.d.ts +42 -0
- package/dist/compile-lesson.d.ts.map +1 -1
- package/dist/compile-lesson.js +189 -0
- package/dist/compile-lesson.js.map +1 -1
- package/dist/compile-lesson.test.js +539 -0
- package/dist/compile-lesson.test.js.map +1 -1
- package/dist/compiler-schema.d.ts +110 -30
- package/dist/compiler-schema.d.ts.map +1 -1
- package/dist/compiler-schema.js +48 -2
- package/dist/compiler-schema.js.map +1 -1
- package/dist/compiler-schema.test.js +80 -0
- package/dist/compiler-schema.test.js.map +1 -1
- package/dist/compiler.d.ts +13 -6
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js +14 -7
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.test.js +33 -0
- package/dist/compiler.test.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/recurrence-stats.d.ts +10 -10
- package/dist/retrospect.d.ts +42 -42
- package/dist/stage4-verifier.d.ts +133 -0
- package/dist/stage4-verifier.d.ts.map +1 -0
- package/dist/stage4-verifier.js +355 -0
- package/dist/stage4-verifier.js.map +1 -0
- package/dist/stage4-verifier.test.d.ts +2 -0
- package/dist/stage4-verifier.test.d.ts.map +1 -0
- package/dist/stage4-verifier.test.js +372 -0
- package/dist/stage4-verifier.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -96,8 +96,43 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
|
|
|
96
96
|
category: z.ZodOptional<z.ZodEnum<["security", "architecture", "style", "performance"]>>;
|
|
97
97
|
/** Severity level — error blocks CI, warning reports but doesn't fail */
|
|
98
98
|
severity: z.ZodOptional<z.ZodEnum<["error", "warning"]>>;
|
|
99
|
-
/**
|
|
100
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Lifecycle status. Three values:
|
|
101
|
+
* - `'active'` — rule is enforced by `totem lint`/`totem review`.
|
|
102
|
+
* - `'archived'` — rule is preserved on disk (telemetry continuity)
|
|
103
|
+
* but skipped at lint time. `loadCompiledRules`
|
|
104
|
+
* filters these out (`compiler.ts:132`).
|
|
105
|
+
* - `'untested-against-codebase'` — Stage 4 verifier (mmnto-ai/totem#1682)
|
|
106
|
+
* ran against the consumer's codebase but found
|
|
107
|
+
* zero matches. The rule's runtime behavior on
|
|
108
|
+
* real code is unknown; treated as inert at lint
|
|
109
|
+
* time the same way `'archived'` is, but with a
|
|
110
|
+
* distinct lifecycle semantic so a subsequent
|
|
111
|
+
* compile cycle in a populated repo can re-run
|
|
112
|
+
* Stage 4 and promote to `'active'`.
|
|
113
|
+
*
|
|
114
|
+
* Distinct from the boolean `unverified` flag below: `unverified` is set
|
|
115
|
+
* by ADR-089 zero-trust default on every LLM-generated rule (post-Layer-3
|
|
116
|
+
* pass); `'untested-against-codebase'` is set by Stage 4 when the
|
|
117
|
+
* verifier's deterministic codebase walk produced no hits. A rule can be
|
|
118
|
+
* `unverified: true` AND `status: 'untested-against-codebase'`
|
|
119
|
+
* simultaneously — they answer different questions (author-trust vs
|
|
120
|
+
* empirical-firing).
|
|
121
|
+
*/
|
|
122
|
+
status: z.ZodOptional<z.ZodEnum<["active", "archived", "untested-against-codebase"]>>;
|
|
123
|
+
/**
|
|
124
|
+
* Stage 4 confidence (mmnto-ai/totem#1682). Set to `'high'` when Stage 4's
|
|
125
|
+
* codebase walk found in-scope matches that are structurally equivalent
|
|
126
|
+
* to the rule's `badExample` — the rule fires on real code, and that real
|
|
127
|
+
* code has the exact authored shape, so the rule is doing what the lesson
|
|
128
|
+
* intended. Single-valued enum in T1; future Stage 4 phases may add a
|
|
129
|
+
* `'low'` value (currently no writer; deferred per ticket #1682 Open
|
|
130
|
+
* Question 2). Absent (undefined) means Stage 4 has not assigned a
|
|
131
|
+
* confidence — either the rule was archived, the verifier produced
|
|
132
|
+
* Candidate Debt outcome (forced `severity: 'warning'` carries that
|
|
133
|
+
* signal instead), or Stage 4 has not yet run on this rule.
|
|
134
|
+
*/
|
|
135
|
+
confidence: z.ZodOptional<z.ZodEnum<["high"]>>;
|
|
101
136
|
/** Reason for archiving (when status is 'archived') */
|
|
102
137
|
archivedReason: z.ZodOptional<z.ZodString>;
|
|
103
138
|
/**
|
|
@@ -153,7 +188,7 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
|
|
|
153
188
|
pattern: string;
|
|
154
189
|
engine: "regex" | "ast" | "ast-grep";
|
|
155
190
|
compiledAt: string;
|
|
156
|
-
status?: "active" | "archived" | undefined;
|
|
191
|
+
status?: "active" | "archived" | "untested-against-codebase" | undefined;
|
|
157
192
|
astQuery?: string | undefined;
|
|
158
193
|
astGrepPattern?: string | undefined;
|
|
159
194
|
astGrepYamlRule?: z.objectOutputType<{
|
|
@@ -165,6 +200,7 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
|
|
|
165
200
|
fileGlobs?: string[] | undefined;
|
|
166
201
|
category?: "security" | "architecture" | "style" | "performance" | undefined;
|
|
167
202
|
severity?: "error" | "warning" | undefined;
|
|
203
|
+
confidence?: "high" | undefined;
|
|
168
204
|
archivedReason?: string | undefined;
|
|
169
205
|
archivedAt?: string | undefined;
|
|
170
206
|
manual?: boolean | undefined;
|
|
@@ -177,7 +213,7 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
|
|
|
177
213
|
pattern: string;
|
|
178
214
|
engine: "regex" | "ast" | "ast-grep";
|
|
179
215
|
compiledAt: string;
|
|
180
|
-
status?: "active" | "archived" | undefined;
|
|
216
|
+
status?: "active" | "archived" | "untested-against-codebase" | undefined;
|
|
181
217
|
astQuery?: string | undefined;
|
|
182
218
|
astGrepPattern?: string | undefined;
|
|
183
219
|
astGrepYamlRule?: z.objectInputType<{
|
|
@@ -189,6 +225,7 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
|
|
|
189
225
|
fileGlobs?: string[] | undefined;
|
|
190
226
|
category?: "security" | "architecture" | "style" | "performance" | undefined;
|
|
191
227
|
severity?: "error" | "warning" | undefined;
|
|
228
|
+
confidence?: "high" | undefined;
|
|
192
229
|
archivedReason?: string | undefined;
|
|
193
230
|
archivedAt?: string | undefined;
|
|
194
231
|
manual?: boolean | undefined;
|
|
@@ -201,7 +238,7 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
|
|
|
201
238
|
pattern: string;
|
|
202
239
|
engine: "regex" | "ast" | "ast-grep";
|
|
203
240
|
compiledAt: string;
|
|
204
|
-
status?: "active" | "archived" | undefined;
|
|
241
|
+
status?: "active" | "archived" | "untested-against-codebase" | undefined;
|
|
205
242
|
astQuery?: string | undefined;
|
|
206
243
|
astGrepPattern?: string | undefined;
|
|
207
244
|
astGrepYamlRule?: z.objectOutputType<{
|
|
@@ -213,6 +250,7 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
|
|
|
213
250
|
fileGlobs?: string[] | undefined;
|
|
214
251
|
category?: "security" | "architecture" | "style" | "performance" | undefined;
|
|
215
252
|
severity?: "error" | "warning" | undefined;
|
|
253
|
+
confidence?: "high" | undefined;
|
|
216
254
|
archivedReason?: string | undefined;
|
|
217
255
|
archivedAt?: string | undefined;
|
|
218
256
|
manual?: boolean | undefined;
|
|
@@ -225,7 +263,7 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
|
|
|
225
263
|
pattern: string;
|
|
226
264
|
engine: "regex" | "ast" | "ast-grep";
|
|
227
265
|
compiledAt: string;
|
|
228
|
-
status?: "active" | "archived" | undefined;
|
|
266
|
+
status?: "active" | "archived" | "untested-against-codebase" | undefined;
|
|
229
267
|
astQuery?: string | undefined;
|
|
230
268
|
astGrepPattern?: string | undefined;
|
|
231
269
|
astGrepYamlRule?: z.objectInputType<{
|
|
@@ -237,6 +275,7 @@ export declare const CompiledRuleSchema: z.ZodEffects<z.ZodObject<{
|
|
|
237
275
|
fileGlobs?: string[] | undefined;
|
|
238
276
|
category?: "security" | "architecture" | "style" | "performance" | undefined;
|
|
239
277
|
severity?: "error" | "warning" | undefined;
|
|
278
|
+
confidence?: "high" | undefined;
|
|
240
279
|
archivedReason?: string | undefined;
|
|
241
280
|
archivedAt?: string | undefined;
|
|
242
281
|
manual?: boolean | undefined;
|
|
@@ -257,7 +296,7 @@ export type CompiledRule = z.infer<typeof CompiledRuleSchema>;
|
|
|
257
296
|
* losing the hash/title pair. Fresh compile runs MUST NOT emit
|
|
258
297
|
* `'legacy-unknown'`; enforcement sits at producers, not the schema.
|
|
259
298
|
*/
|
|
260
|
-
export declare const NonCompilableReasonCodeSchema: z.ZodEnum<["no-pattern-generated", "pattern-syntax-invalid", "pattern-zero-match", "verify-retry-exhausted", "security-rule-rejected", "no-pattern-found", "out-of-scope", "missing-badexample", "missing-goodexample", "matches-good-example", "context-required", "semantic-analysis-required", "self-suppressing-pattern", "legacy-unknown"]>;
|
|
299
|
+
export declare const NonCompilableReasonCodeSchema: z.ZodEnum<["no-pattern-generated", "pattern-syntax-invalid", "pattern-zero-match", "verify-retry-exhausted", "security-rule-rejected", "no-pattern-found", "out-of-scope", "missing-badexample", "missing-goodexample", "matches-good-example", "context-required", "semantic-analysis-required", "self-suppressing-pattern", "stage4-out-of-scope-match", "legacy-unknown"]>;
|
|
261
300
|
export type NonCompilableReasonCode = z.infer<typeof NonCompilableReasonCodeSchema>;
|
|
262
301
|
/**
|
|
263
302
|
* Reason codes that represent retry-eligible transient failures, not
|
|
@@ -300,17 +339,17 @@ export declare function shouldWriteToLedger(reasonCode: NonCompilableReasonCode)
|
|
|
300
339
|
export declare const NonCompilableEntryWriteSchema: z.ZodObject<{
|
|
301
340
|
hash: z.ZodString;
|
|
302
341
|
title: z.ZodString;
|
|
303
|
-
reasonCode: z.ZodEnum<["no-pattern-generated", "pattern-syntax-invalid", "pattern-zero-match", "verify-retry-exhausted", "security-rule-rejected", "no-pattern-found", "out-of-scope", "missing-badexample", "missing-goodexample", "matches-good-example", "context-required", "semantic-analysis-required", "self-suppressing-pattern", "legacy-unknown"]>;
|
|
342
|
+
reasonCode: z.ZodEnum<["no-pattern-generated", "pattern-syntax-invalid", "pattern-zero-match", "verify-retry-exhausted", "security-rule-rejected", "no-pattern-found", "out-of-scope", "missing-badexample", "missing-goodexample", "matches-good-example", "context-required", "semantic-analysis-required", "self-suppressing-pattern", "stage4-out-of-scope-match", "legacy-unknown"]>;
|
|
304
343
|
reason: z.ZodOptional<z.ZodString>;
|
|
305
344
|
}, "strip", z.ZodTypeAny, {
|
|
306
345
|
hash: string;
|
|
307
346
|
title: string;
|
|
308
|
-
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "legacy-unknown";
|
|
347
|
+
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "stage4-out-of-scope-match" | "legacy-unknown";
|
|
309
348
|
reason?: string | undefined;
|
|
310
349
|
}, {
|
|
311
350
|
hash: string;
|
|
312
351
|
title: string;
|
|
313
|
-
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "legacy-unknown";
|
|
352
|
+
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "stage4-out-of-scope-match" | "legacy-unknown";
|
|
314
353
|
reason?: string | undefined;
|
|
315
354
|
}>;
|
|
316
355
|
/**
|
|
@@ -324,17 +363,17 @@ export declare const NonCompilableEntryWriteSchema: z.ZodObject<{
|
|
|
324
363
|
export declare const NonCompilableEntryReadSchema: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
325
364
|
hash: z.ZodString;
|
|
326
365
|
title: z.ZodString;
|
|
327
|
-
reasonCode: z.ZodEnum<["no-pattern-generated", "pattern-syntax-invalid", "pattern-zero-match", "verify-retry-exhausted", "security-rule-rejected", "no-pattern-found", "out-of-scope", "missing-badexample", "missing-goodexample", "matches-good-example", "context-required", "semantic-analysis-required", "self-suppressing-pattern", "legacy-unknown"]>;
|
|
366
|
+
reasonCode: z.ZodEnum<["no-pattern-generated", "pattern-syntax-invalid", "pattern-zero-match", "verify-retry-exhausted", "security-rule-rejected", "no-pattern-found", "out-of-scope", "missing-badexample", "missing-goodexample", "matches-good-example", "context-required", "semantic-analysis-required", "self-suppressing-pattern", "stage4-out-of-scope-match", "legacy-unknown"]>;
|
|
328
367
|
reason: z.ZodOptional<z.ZodString>;
|
|
329
368
|
}, "strip", z.ZodTypeAny, {
|
|
330
369
|
hash: string;
|
|
331
370
|
title: string;
|
|
332
|
-
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "legacy-unknown";
|
|
371
|
+
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "stage4-out-of-scope-match" | "legacy-unknown";
|
|
333
372
|
reason?: string | undefined;
|
|
334
373
|
}, {
|
|
335
374
|
hash: string;
|
|
336
375
|
title: string;
|
|
337
|
-
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "legacy-unknown";
|
|
376
|
+
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "stage4-out-of-scope-match" | "legacy-unknown";
|
|
338
377
|
reason?: string | undefined;
|
|
339
378
|
}>, z.ZodObject<{
|
|
340
379
|
hash: z.ZodString;
|
|
@@ -348,12 +387,12 @@ export declare const NonCompilableEntryReadSchema: z.ZodEffects<z.ZodUnion<[z.Zo
|
|
|
348
387
|
}>]>, {
|
|
349
388
|
hash: string;
|
|
350
389
|
title: string;
|
|
351
|
-
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "legacy-unknown";
|
|
390
|
+
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "stage4-out-of-scope-match" | "legacy-unknown";
|
|
352
391
|
reason?: string | undefined;
|
|
353
392
|
}, string | {
|
|
354
393
|
hash: string;
|
|
355
394
|
title: string;
|
|
356
|
-
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "legacy-unknown";
|
|
395
|
+
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "stage4-out-of-scope-match" | "legacy-unknown";
|
|
357
396
|
reason?: string | undefined;
|
|
358
397
|
} | {
|
|
359
398
|
hash: string;
|
|
@@ -426,8 +465,43 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
426
465
|
category: z.ZodOptional<z.ZodEnum<["security", "architecture", "style", "performance"]>>;
|
|
427
466
|
/** Severity level — error blocks CI, warning reports but doesn't fail */
|
|
428
467
|
severity: z.ZodOptional<z.ZodEnum<["error", "warning"]>>;
|
|
429
|
-
/**
|
|
430
|
-
|
|
468
|
+
/**
|
|
469
|
+
* Lifecycle status. Three values:
|
|
470
|
+
* - `'active'` — rule is enforced by `totem lint`/`totem review`.
|
|
471
|
+
* - `'archived'` — rule is preserved on disk (telemetry continuity)
|
|
472
|
+
* but skipped at lint time. `loadCompiledRules`
|
|
473
|
+
* filters these out (`compiler.ts:132`).
|
|
474
|
+
* - `'untested-against-codebase'` — Stage 4 verifier (mmnto-ai/totem#1682)
|
|
475
|
+
* ran against the consumer's codebase but found
|
|
476
|
+
* zero matches. The rule's runtime behavior on
|
|
477
|
+
* real code is unknown; treated as inert at lint
|
|
478
|
+
* time the same way `'archived'` is, but with a
|
|
479
|
+
* distinct lifecycle semantic so a subsequent
|
|
480
|
+
* compile cycle in a populated repo can re-run
|
|
481
|
+
* Stage 4 and promote to `'active'`.
|
|
482
|
+
*
|
|
483
|
+
* Distinct from the boolean `unverified` flag below: `unverified` is set
|
|
484
|
+
* by ADR-089 zero-trust default on every LLM-generated rule (post-Layer-3
|
|
485
|
+
* pass); `'untested-against-codebase'` is set by Stage 4 when the
|
|
486
|
+
* verifier's deterministic codebase walk produced no hits. A rule can be
|
|
487
|
+
* `unverified: true` AND `status: 'untested-against-codebase'`
|
|
488
|
+
* simultaneously — they answer different questions (author-trust vs
|
|
489
|
+
* empirical-firing).
|
|
490
|
+
*/
|
|
491
|
+
status: z.ZodOptional<z.ZodEnum<["active", "archived", "untested-against-codebase"]>>;
|
|
492
|
+
/**
|
|
493
|
+
* Stage 4 confidence (mmnto-ai/totem#1682). Set to `'high'` when Stage 4's
|
|
494
|
+
* codebase walk found in-scope matches that are structurally equivalent
|
|
495
|
+
* to the rule's `badExample` — the rule fires on real code, and that real
|
|
496
|
+
* code has the exact authored shape, so the rule is doing what the lesson
|
|
497
|
+
* intended. Single-valued enum in T1; future Stage 4 phases may add a
|
|
498
|
+
* `'low'` value (currently no writer; deferred per ticket #1682 Open
|
|
499
|
+
* Question 2). Absent (undefined) means Stage 4 has not assigned a
|
|
500
|
+
* confidence — either the rule was archived, the verifier produced
|
|
501
|
+
* Candidate Debt outcome (forced `severity: 'warning'` carries that
|
|
502
|
+
* signal instead), or Stage 4 has not yet run on this rule.
|
|
503
|
+
*/
|
|
504
|
+
confidence: z.ZodOptional<z.ZodEnum<["high"]>>;
|
|
431
505
|
/** Reason for archiving (when status is 'archived') */
|
|
432
506
|
archivedReason: z.ZodOptional<z.ZodString>;
|
|
433
507
|
/**
|
|
@@ -483,7 +557,7 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
483
557
|
pattern: string;
|
|
484
558
|
engine: "regex" | "ast" | "ast-grep";
|
|
485
559
|
compiledAt: string;
|
|
486
|
-
status?: "active" | "archived" | undefined;
|
|
560
|
+
status?: "active" | "archived" | "untested-against-codebase" | undefined;
|
|
487
561
|
astQuery?: string | undefined;
|
|
488
562
|
astGrepPattern?: string | undefined;
|
|
489
563
|
astGrepYamlRule?: z.objectOutputType<{
|
|
@@ -495,6 +569,7 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
495
569
|
fileGlobs?: string[] | undefined;
|
|
496
570
|
category?: "security" | "architecture" | "style" | "performance" | undefined;
|
|
497
571
|
severity?: "error" | "warning" | undefined;
|
|
572
|
+
confidence?: "high" | undefined;
|
|
498
573
|
archivedReason?: string | undefined;
|
|
499
574
|
archivedAt?: string | undefined;
|
|
500
575
|
manual?: boolean | undefined;
|
|
@@ -507,7 +582,7 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
507
582
|
pattern: string;
|
|
508
583
|
engine: "regex" | "ast" | "ast-grep";
|
|
509
584
|
compiledAt: string;
|
|
510
|
-
status?: "active" | "archived" | undefined;
|
|
585
|
+
status?: "active" | "archived" | "untested-against-codebase" | undefined;
|
|
511
586
|
astQuery?: string | undefined;
|
|
512
587
|
astGrepPattern?: string | undefined;
|
|
513
588
|
astGrepYamlRule?: z.objectInputType<{
|
|
@@ -519,6 +594,7 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
519
594
|
fileGlobs?: string[] | undefined;
|
|
520
595
|
category?: "security" | "architecture" | "style" | "performance" | undefined;
|
|
521
596
|
severity?: "error" | "warning" | undefined;
|
|
597
|
+
confidence?: "high" | undefined;
|
|
522
598
|
archivedReason?: string | undefined;
|
|
523
599
|
archivedAt?: string | undefined;
|
|
524
600
|
manual?: boolean | undefined;
|
|
@@ -531,7 +607,7 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
531
607
|
pattern: string;
|
|
532
608
|
engine: "regex" | "ast" | "ast-grep";
|
|
533
609
|
compiledAt: string;
|
|
534
|
-
status?: "active" | "archived" | undefined;
|
|
610
|
+
status?: "active" | "archived" | "untested-against-codebase" | undefined;
|
|
535
611
|
astQuery?: string | undefined;
|
|
536
612
|
astGrepPattern?: string | undefined;
|
|
537
613
|
astGrepYamlRule?: z.objectOutputType<{
|
|
@@ -543,6 +619,7 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
543
619
|
fileGlobs?: string[] | undefined;
|
|
544
620
|
category?: "security" | "architecture" | "style" | "performance" | undefined;
|
|
545
621
|
severity?: "error" | "warning" | undefined;
|
|
622
|
+
confidence?: "high" | undefined;
|
|
546
623
|
archivedReason?: string | undefined;
|
|
547
624
|
archivedAt?: string | undefined;
|
|
548
625
|
manual?: boolean | undefined;
|
|
@@ -555,7 +632,7 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
555
632
|
pattern: string;
|
|
556
633
|
engine: "regex" | "ast" | "ast-grep";
|
|
557
634
|
compiledAt: string;
|
|
558
|
-
status?: "active" | "archived" | undefined;
|
|
635
|
+
status?: "active" | "archived" | "untested-against-codebase" | undefined;
|
|
559
636
|
astQuery?: string | undefined;
|
|
560
637
|
astGrepPattern?: string | undefined;
|
|
561
638
|
astGrepYamlRule?: z.objectInputType<{
|
|
@@ -567,6 +644,7 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
567
644
|
fileGlobs?: string[] | undefined;
|
|
568
645
|
category?: "security" | "architecture" | "style" | "performance" | undefined;
|
|
569
646
|
severity?: "error" | "warning" | undefined;
|
|
647
|
+
confidence?: "high" | undefined;
|
|
570
648
|
archivedReason?: string | undefined;
|
|
571
649
|
archivedAt?: string | undefined;
|
|
572
650
|
manual?: boolean | undefined;
|
|
@@ -585,17 +663,17 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
585
663
|
nonCompilable: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
586
664
|
hash: z.ZodString;
|
|
587
665
|
title: z.ZodString;
|
|
588
|
-
reasonCode: z.ZodEnum<["no-pattern-generated", "pattern-syntax-invalid", "pattern-zero-match", "verify-retry-exhausted", "security-rule-rejected", "no-pattern-found", "out-of-scope", "missing-badexample", "missing-goodexample", "matches-good-example", "context-required", "semantic-analysis-required", "self-suppressing-pattern", "legacy-unknown"]>;
|
|
666
|
+
reasonCode: z.ZodEnum<["no-pattern-generated", "pattern-syntax-invalid", "pattern-zero-match", "verify-retry-exhausted", "security-rule-rejected", "no-pattern-found", "out-of-scope", "missing-badexample", "missing-goodexample", "matches-good-example", "context-required", "semantic-analysis-required", "self-suppressing-pattern", "stage4-out-of-scope-match", "legacy-unknown"]>;
|
|
589
667
|
reason: z.ZodOptional<z.ZodString>;
|
|
590
668
|
}, "strip", z.ZodTypeAny, {
|
|
591
669
|
hash: string;
|
|
592
670
|
title: string;
|
|
593
|
-
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "legacy-unknown";
|
|
671
|
+
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "stage4-out-of-scope-match" | "legacy-unknown";
|
|
594
672
|
reason?: string | undefined;
|
|
595
673
|
}, {
|
|
596
674
|
hash: string;
|
|
597
675
|
title: string;
|
|
598
|
-
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "legacy-unknown";
|
|
676
|
+
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "stage4-out-of-scope-match" | "legacy-unknown";
|
|
599
677
|
reason?: string | undefined;
|
|
600
678
|
}>, z.ZodObject<{
|
|
601
679
|
hash: z.ZodString;
|
|
@@ -609,12 +687,12 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
609
687
|
}>]>, {
|
|
610
688
|
hash: string;
|
|
611
689
|
title: string;
|
|
612
|
-
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "legacy-unknown";
|
|
690
|
+
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "stage4-out-of-scope-match" | "legacy-unknown";
|
|
613
691
|
reason?: string | undefined;
|
|
614
692
|
}, string | {
|
|
615
693
|
hash: string;
|
|
616
694
|
title: string;
|
|
617
|
-
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "legacy-unknown";
|
|
695
|
+
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "stage4-out-of-scope-match" | "legacy-unknown";
|
|
618
696
|
reason?: string | undefined;
|
|
619
697
|
} | {
|
|
620
698
|
hash: string;
|
|
@@ -629,7 +707,7 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
629
707
|
pattern: string;
|
|
630
708
|
engine: "regex" | "ast" | "ast-grep";
|
|
631
709
|
compiledAt: string;
|
|
632
|
-
status?: "active" | "archived" | undefined;
|
|
710
|
+
status?: "active" | "archived" | "untested-against-codebase" | undefined;
|
|
633
711
|
astQuery?: string | undefined;
|
|
634
712
|
astGrepPattern?: string | undefined;
|
|
635
713
|
astGrepYamlRule?: z.objectOutputType<{
|
|
@@ -641,6 +719,7 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
641
719
|
fileGlobs?: string[] | undefined;
|
|
642
720
|
category?: "security" | "architecture" | "style" | "performance" | undefined;
|
|
643
721
|
severity?: "error" | "warning" | undefined;
|
|
722
|
+
confidence?: "high" | undefined;
|
|
644
723
|
archivedReason?: string | undefined;
|
|
645
724
|
archivedAt?: string | undefined;
|
|
646
725
|
manual?: boolean | undefined;
|
|
@@ -650,7 +729,7 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
650
729
|
nonCompilable?: {
|
|
651
730
|
hash: string;
|
|
652
731
|
title: string;
|
|
653
|
-
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "legacy-unknown";
|
|
732
|
+
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "stage4-out-of-scope-match" | "legacy-unknown";
|
|
654
733
|
reason?: string | undefined;
|
|
655
734
|
}[] | undefined;
|
|
656
735
|
}, {
|
|
@@ -662,7 +741,7 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
662
741
|
pattern: string;
|
|
663
742
|
engine: "regex" | "ast" | "ast-grep";
|
|
664
743
|
compiledAt: string;
|
|
665
|
-
status?: "active" | "archived" | undefined;
|
|
744
|
+
status?: "active" | "archived" | "untested-against-codebase" | undefined;
|
|
666
745
|
astQuery?: string | undefined;
|
|
667
746
|
astGrepPattern?: string | undefined;
|
|
668
747
|
astGrepYamlRule?: z.objectInputType<{
|
|
@@ -674,6 +753,7 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
674
753
|
fileGlobs?: string[] | undefined;
|
|
675
754
|
category?: "security" | "architecture" | "style" | "performance" | undefined;
|
|
676
755
|
severity?: "error" | "warning" | undefined;
|
|
756
|
+
confidence?: "high" | undefined;
|
|
677
757
|
archivedReason?: string | undefined;
|
|
678
758
|
archivedAt?: string | undefined;
|
|
679
759
|
manual?: boolean | undefined;
|
|
@@ -683,7 +763,7 @@ export declare const CompiledRulesFileSchema: z.ZodObject<{
|
|
|
683
763
|
nonCompilable?: (string | {
|
|
684
764
|
hash: string;
|
|
685
765
|
title: string;
|
|
686
|
-
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "legacy-unknown";
|
|
766
|
+
reasonCode: "no-pattern-generated" | "pattern-syntax-invalid" | "pattern-zero-match" | "verify-retry-exhausted" | "security-rule-rejected" | "no-pattern-found" | "out-of-scope" | "missing-badexample" | "missing-goodexample" | "matches-good-example" | "context-required" | "semantic-analysis-required" | "self-suppressing-pattern" | "stage4-out-of-scope-match" | "legacy-unknown";
|
|
687
767
|
reason?: string | undefined;
|
|
688
768
|
} | {
|
|
689
769
|
hash: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler-schema.d.ts","sourceRoot":"","sources":["../src/compiler-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB;;;;;;gCAIb,CAAC;AAEjB,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;;;gCAAmB,CAAC;AAEtD,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"compiler-schema.d.ts","sourceRoot":"","sources":["../src/compiler-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB;;;;;;gCAIb,CAAC;AAEjB,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;;;gCAAmB,CAAC;AAEtD,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC;AAoLzC,eAAO,MAAM,kBAAkB;IA/K7B,0EAA0E;;IAE1E,+DAA+D;;IAE/D,sDAAsD;;IAEtD,sEAAsE;;IAEtE,6IAA6I;;IAE7I,qEAAqE;;IAErE;;;;OAIG;;IAEH;;;;;;OAMG;;;;;;;;IAEH;;;;;OAKG;;IAEH;;;;;;;;OAQG;;IAEH,mDAAmD;;IAEnD,iFAAiF;;IAEjF,kGAAkG;;IAElG,mDAAmD;;IAEnD,yEAAyE;;IAEzE;;;;;;;;;;;;;;;;;;;;;;OAsBG;;IAEH;;;;;;;;;;;OAWG;;IAEH,uDAAuD;;IAEvD;;;;;;;;;OASG;;IAEH;;;;;;;;;;;OAWG;;IAEH;;;;;OAKG;;IAEH;;;;;;;;;;;;;OAaG;;;;;;;;;;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C;IAC7B,+FAA+F;IAC/F,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAID,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wEAAwE;AACxE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,uEAAuE;IACvE,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAC9B,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,EACzC,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,gBAAgB,KACvB,IAAI,CAAC"}
|
package/dist/compiler-schema.js
CHANGED
|
@@ -82,8 +82,43 @@ const CompiledRuleBaseSchema = z.object({
|
|
|
82
82
|
category: z.enum(['security', 'architecture', 'style', 'performance']).optional(),
|
|
83
83
|
/** Severity level — error blocks CI, warning reports but doesn't fail */
|
|
84
84
|
severity: z.enum(['error', 'warning']).optional(),
|
|
85
|
-
/**
|
|
86
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Lifecycle status. Three values:
|
|
87
|
+
* - `'active'` — rule is enforced by `totem lint`/`totem review`.
|
|
88
|
+
* - `'archived'` — rule is preserved on disk (telemetry continuity)
|
|
89
|
+
* but skipped at lint time. `loadCompiledRules`
|
|
90
|
+
* filters these out (`compiler.ts:132`).
|
|
91
|
+
* - `'untested-against-codebase'` — Stage 4 verifier (mmnto-ai/totem#1682)
|
|
92
|
+
* ran against the consumer's codebase but found
|
|
93
|
+
* zero matches. The rule's runtime behavior on
|
|
94
|
+
* real code is unknown; treated as inert at lint
|
|
95
|
+
* time the same way `'archived'` is, but with a
|
|
96
|
+
* distinct lifecycle semantic so a subsequent
|
|
97
|
+
* compile cycle in a populated repo can re-run
|
|
98
|
+
* Stage 4 and promote to `'active'`.
|
|
99
|
+
*
|
|
100
|
+
* Distinct from the boolean `unverified` flag below: `unverified` is set
|
|
101
|
+
* by ADR-089 zero-trust default on every LLM-generated rule (post-Layer-3
|
|
102
|
+
* pass); `'untested-against-codebase'` is set by Stage 4 when the
|
|
103
|
+
* verifier's deterministic codebase walk produced no hits. A rule can be
|
|
104
|
+
* `unverified: true` AND `status: 'untested-against-codebase'`
|
|
105
|
+
* simultaneously — they answer different questions (author-trust vs
|
|
106
|
+
* empirical-firing).
|
|
107
|
+
*/
|
|
108
|
+
status: z.enum(['active', 'archived', 'untested-against-codebase']).optional(),
|
|
109
|
+
/**
|
|
110
|
+
* Stage 4 confidence (mmnto-ai/totem#1682). Set to `'high'` when Stage 4's
|
|
111
|
+
* codebase walk found in-scope matches that are structurally equivalent
|
|
112
|
+
* to the rule's `badExample` — the rule fires on real code, and that real
|
|
113
|
+
* code has the exact authored shape, so the rule is doing what the lesson
|
|
114
|
+
* intended. Single-valued enum in T1; future Stage 4 phases may add a
|
|
115
|
+
* `'low'` value (currently no writer; deferred per ticket #1682 Open
|
|
116
|
+
* Question 2). Absent (undefined) means Stage 4 has not assigned a
|
|
117
|
+
* confidence — either the rule was archived, the verifier produced
|
|
118
|
+
* Candidate Debt outcome (forced `severity: 'warning'` carries that
|
|
119
|
+
* signal instead), or Stage 4 has not yet run on this rule.
|
|
120
|
+
*/
|
|
121
|
+
confidence: z.enum(['high']).optional(),
|
|
87
122
|
/** Reason for archiving (when status is 'archived') */
|
|
88
123
|
archivedReason: z.string().optional(),
|
|
89
124
|
/**
|
|
@@ -210,6 +245,17 @@ export const NonCompilableReasonCodeSchema = z.enum([
|
|
|
210
245
|
// `LEDGER_RETRY_PENDING_CODES`); ledger writes record the audit trail
|
|
211
246
|
// bot reviewers can cite per strategy upstream-feedback item 021.
|
|
212
247
|
'self-suppressing-pattern',
|
|
248
|
+
// `stage4-out-of-scope-match` (mmnto-ai/totem#1682) classifies rules that
|
|
249
|
+
// Stage 4 (Verify-Against-Codebase) auto-archived because the pattern
|
|
250
|
+
// fired on files in the verification baseline — files outside the
|
|
251
|
+
// lesson's `fileGlobs` scope, test files, or fixture directories. The
|
|
252
|
+
// rule is over-broad by definition: it matches legitimate code, not just
|
|
253
|
+
// the authored hazard shape. Stage 4 surfaces the offending paths in the
|
|
254
|
+
// archive's `archivedReason` text (T1 baseline behavior); structured
|
|
255
|
+
// path persistence lands in T3 (mmnto-ai/totem#1684) via
|
|
256
|
+
// `.totem/rule-metrics.json`. Terminal: re-running compile re-evaluates
|
|
257
|
+
// against the current codebase but does not enter the retry path.
|
|
258
|
+
'stage4-out-of-scope-match',
|
|
213
259
|
'legacy-unknown',
|
|
214
260
|
]);
|
|
215
261
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler-schema.js","sourceRoot":"","sources":["../src/compiler-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,uDAAuD;AAEvD;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC;KAC9B,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;CAC5B,CAAC;KACD,WAAW,EAAE,CAAC;AAIjB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAItD,uDAAuD;AAEvD,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,0EAA0E;IAC1E,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,+DAA+D;IAC/D,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,sDAAsD;IACtD,OAAO,EAAE,CAAC,CAAC,MA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;IACxE,sEAAsE;IACtE,4DAA4D;IAC5D,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO;IACvF,GAAG,CAAC,QAAQ,CAAC;QACX,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM;QAC3B,OAAO,EACL,iGAAiG;QACnG,IAAI,EAAE,CAAC,aAAa,CAAC;KACtB,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAS,qCAAqC,CAC5C,IAAkD,EAClD,GAAoB;IAEpB,IAAI,IAAI,CAAC,UAAU,KAAK,SAAS;QAAE,OAAO;IAC1C,IAAI,CAAC,IAAI,CAAC,UAAU;QAAE,OAAO;IAC7B,GAAG,CAAC,QAAQ,CAAC;QACX,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,MAAM;QAC3B,OAAO,EAAE,yEAAyE;QAClF,IAAI,EAAE,CAAC,YAAY,CAAC;KACrB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,wBAAwB,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;IACrF,4BAA4B,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACxC,wBAAwB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACpC,yBAAyB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACrC,qCAAqC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AACnD,CAAC,CAAC,CAAC"}
|
|
@@ -193,6 +193,86 @@ describe('CompiledRule archivedAt field', () => {
|
|
|
193
193
|
expect(parsed.archivedAt).toBe('2026-04-13T12:05:00Z');
|
|
194
194
|
});
|
|
195
195
|
});
|
|
196
|
+
// ─── Stage 4 Verify-Against-Codebase schema deltas (mmnto-ai/totem#1682) ──
|
|
197
|
+
describe('CompiledRule status field — Stage 4 untested-against-codebase value', () => {
|
|
198
|
+
const stage4UntestedRule = {
|
|
199
|
+
lessonHash: 'abc123def456',
|
|
200
|
+
lessonHeading: 'Stage 4 untested rule',
|
|
201
|
+
pattern: '\\bfoo\\b',
|
|
202
|
+
message: 'No foo',
|
|
203
|
+
engine: 'regex',
|
|
204
|
+
compiledAt: '2026-04-30T12:00:00Z',
|
|
205
|
+
status: 'untested-against-codebase',
|
|
206
|
+
};
|
|
207
|
+
it("accepts a CompiledRule with status 'untested-against-codebase'", () => {
|
|
208
|
+
const parsed = CompiledRuleSchema.parse(stage4UntestedRule);
|
|
209
|
+
expect(parsed.status).toBe('untested-against-codebase');
|
|
210
|
+
});
|
|
211
|
+
it("preserves status: 'untested-against-codebase' across round-trip", () => {
|
|
212
|
+
const firstParse = CompiledRuleSchema.parse(stage4UntestedRule);
|
|
213
|
+
const serialized = JSON.parse(JSON.stringify(firstParse));
|
|
214
|
+
const secondParse = CompiledRuleSchema.parse(serialized);
|
|
215
|
+
expect(secondParse.status).toBe('untested-against-codebase');
|
|
216
|
+
});
|
|
217
|
+
it('rejects an unknown status value', () => {
|
|
218
|
+
const bogus = { ...stage4UntestedRule, status: 'pending-verification' };
|
|
219
|
+
expect(() => CompiledRuleSchema.parse(bogus)).toThrow();
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
describe('CompiledRule confidence field (mmnto-ai/totem#1682)', () => {
|
|
223
|
+
const baseRule = {
|
|
224
|
+
lessonHash: 'abc123def456',
|
|
225
|
+
lessonHeading: 'High-confidence rule',
|
|
226
|
+
pattern: '\\bfoo\\b',
|
|
227
|
+
message: 'No foo',
|
|
228
|
+
engine: 'regex',
|
|
229
|
+
compiledAt: '2026-04-30T12:00:00Z',
|
|
230
|
+
};
|
|
231
|
+
it("accepts a CompiledRule with confidence: 'high'", () => {
|
|
232
|
+
const parsed = CompiledRuleSchema.parse({ ...baseRule, confidence: 'high' });
|
|
233
|
+
expect(parsed.confidence).toBe('high');
|
|
234
|
+
});
|
|
235
|
+
it('accepts a CompiledRule without a confidence field (absent = unset)', () => {
|
|
236
|
+
const parsed = CompiledRuleSchema.parse(baseRule);
|
|
237
|
+
expect(parsed.confidence).toBeUndefined();
|
|
238
|
+
});
|
|
239
|
+
it('rejects an unknown confidence value', () => {
|
|
240
|
+
const bogus = { ...baseRule, confidence: 'medium' };
|
|
241
|
+
expect(() => CompiledRuleSchema.parse(bogus)).toThrow();
|
|
242
|
+
});
|
|
243
|
+
it('preserves confidence across a round-trip', () => {
|
|
244
|
+
const firstParse = CompiledRuleSchema.parse({ ...baseRule, confidence: 'high' });
|
|
245
|
+
const serialized = JSON.parse(JSON.stringify(firstParse));
|
|
246
|
+
const secondParse = CompiledRuleSchema.parse(serialized);
|
|
247
|
+
expect(secondParse.confidence).toBe('high');
|
|
248
|
+
});
|
|
249
|
+
it("survives concurrently with status: 'untested-against-codebase' (orthogonal axes)", () => {
|
|
250
|
+
const parsed = CompiledRuleSchema.parse({
|
|
251
|
+
...baseRule,
|
|
252
|
+
status: 'untested-against-codebase',
|
|
253
|
+
confidence: 'high',
|
|
254
|
+
});
|
|
255
|
+
expect(parsed.status).toBe('untested-against-codebase');
|
|
256
|
+
expect(parsed.confidence).toBe('high');
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
describe("NonCompilableReasonCodeSchema 'stage4-out-of-scope-match' (mmnto-ai/totem#1682)", () => {
|
|
260
|
+
it("accepts 'stage4-out-of-scope-match' as a valid reason code", () => {
|
|
261
|
+
expect(() => NonCompilableReasonCodeSchema.parse('stage4-out-of-scope-match')).not.toThrow();
|
|
262
|
+
});
|
|
263
|
+
it("includes 'stage4-out-of-scope-match' in the enum options", () => {
|
|
264
|
+
const values = NonCompilableReasonCodeSchema.options;
|
|
265
|
+
expect(values).toContain('stage4-out-of-scope-match');
|
|
266
|
+
});
|
|
267
|
+
it("treats 'stage4-out-of-scope-match' as terminal (NOT in LEDGER_RETRY_PENDING_CODES)", () => {
|
|
268
|
+
// Stage 4 archive is structural — re-running compile re-evaluates against
|
|
269
|
+
// the current codebase, but the rule is not retry-eligible the way
|
|
270
|
+
// `pattern-zero-match` or `verify-retry-exhausted` are. shouldWriteToLedger
|
|
271
|
+
// returns true, meaning ledger writes record the audit trail.
|
|
272
|
+
expect(LEDGER_RETRY_PENDING_CODES.has('stage4-out-of-scope-match')).toBe(false);
|
|
273
|
+
expect(shouldWriteToLedger('stage4-out-of-scope-match')).toBe(true);
|
|
274
|
+
});
|
|
275
|
+
});
|
|
196
276
|
// ─── CompilerOutput badExample required per engine (mmnto-ai/totem#1409) ──
|
|
197
277
|
describe('CompilerOutput badExample required by engine', () => {
|
|
198
278
|
it('accepts a regex CompilerOutput with a non-empty badExample', () => {
|