@mmnto/totem 1.14.10 → 1.14.12
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 +76 -1
- package/dist/compile-lesson.d.ts.map +1 -1
- package/dist/compile-lesson.js +481 -53
- package/dist/compile-lesson.js.map +1 -1
- package/dist/compile-lesson.test.js +756 -8
- package/dist/compile-lesson.test.js.map +1 -1
- package/dist/compiler-schema.d.ts +185 -9
- package/dist/compiler-schema.d.ts.map +1 -1
- package/dist/compiler-schema.js +95 -10
- package/dist/compiler-schema.js.map +1 -1
- package/dist/compiler.d.ts +11 -3
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js +24 -4
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.test.js +162 -22
- package/dist/compiler.test.js.map +1 -1
- package/dist/config-schema.d.ts +86 -0
- package/dist/config-schema.d.ts.map +1 -1
- package/dist/config-schema.js +54 -0
- package/dist/config-schema.js.map +1 -1
- package/dist/config-schema.test.js +137 -1
- package/dist/config-schema.test.js.map +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/ledger.d.ts +10 -0
- package/dist/ledger.d.ts.map +1 -1
- package/dist/ledger.js +8 -0
- package/dist/ledger.js.map +1 -1
- package/dist/lesson-pattern.d.ts.map +1 -1
- package/dist/lesson-pattern.js +6 -9
- package/dist/lesson-pattern.js.map +1 -1
- package/dist/pack-merge.d.ts +73 -0
- package/dist/pack-merge.d.ts.map +1 -0
- package/dist/pack-merge.js +117 -0
- package/dist/pack-merge.js.map +1 -0
- package/dist/pack-merge.test.d.ts +2 -0
- package/dist/pack-merge.test.d.ts.map +1 -0
- package/dist/pack-merge.test.js +238 -0
- package/dist/pack-merge.test.js.map +1 -0
- package/dist/regex-utils.d.ts +5 -0
- package/dist/regex-utils.d.ts.map +1 -1
- package/dist/regex-utils.js +6 -1
- package/dist/regex-utils.js.map +1 -1
- package/dist/regex-utils.test.js +15 -2
- package/dist/regex-utils.test.js.map +1 -1
- package/dist/rule-engine.d.ts.map +1 -1
- package/dist/rule-engine.js +3 -0
- package/dist/rule-engine.js.map +1 -1
- package/dist/rule-engine.test.js +29 -0
- package/dist/rule-engine.test.js.map +1 -1
- package/dist/rule-metrics.d.ts +40 -0
- package/dist/rule-metrics.d.ts.map +1 -1
- package/dist/rule-metrics.js +28 -0
- package/dist/rule-metrics.js.map +1 -1
- package/dist/rule-metrics.test.js +104 -3
- package/dist/rule-metrics.test.js.map +1 -1
- package/package.json +1 -1
package/dist/compile-lesson.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompiledRule, CompilerOutput, RegexValidation } from './compiler-schema.js';
|
|
1
|
+
import type { CompiledRule, CompilerOutput, NonCompilableReasonCode, RegexValidation } from './compiler-schema.js';
|
|
2
2
|
import type { RuleTestResult } from './rule-tester.js';
|
|
3
3
|
export interface LessonInput {
|
|
4
4
|
index: number;
|
|
@@ -6,17 +6,64 @@ export interface LessonInput {
|
|
|
6
6
|
body: string;
|
|
7
7
|
hash: string;
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Machine-readable skip reasons. Threaded through `CompileLessonResult` so
|
|
11
|
+
* downstream consumers (totem doctor, Layer 4 fallthrough reporting per ADR-088)
|
|
12
|
+
* can distinguish why a lesson produced no rule without string-matching
|
|
13
|
+
* human-readable messages.
|
|
14
|
+
*
|
|
15
|
+
* mmnto-ai/totem#1481 aligned this internal type 1:1 with the persisted
|
|
16
|
+
* `NonCompilableReasonCode` enum so ledger writers can pass the code through
|
|
17
|
+
* without a mapping table. `'non-compilable'` renamed to `'out-of-scope'`,
|
|
18
|
+
* `'security-verify-rejected'` renamed to `'security-rule-rejected'`, and
|
|
19
|
+
* four producer-facing codes joined: `'no-pattern-generated'`,
|
|
20
|
+
* `'pattern-syntax-invalid'`, `'pattern-zero-match'`, `'no-pattern-found'`.
|
|
21
|
+
* Fresh compile runs MUST NOT emit `'legacy-unknown'`; that sentinel exists
|
|
22
|
+
* solely for migrating pre-#1481 2-tuples.
|
|
23
|
+
*/
|
|
24
|
+
export type CompileLessonReasonCode = Exclude<NonCompilableReasonCode, 'legacy-unknown'>;
|
|
25
|
+
/**
|
|
26
|
+
* Single event inside a lesson's compile pipeline. Appended to a per-lesson
|
|
27
|
+
* `trace` array on every pipeline step (generate / verify / retry / result)
|
|
28
|
+
* and surfaced via `CompileLessonResult.trace` for the CLI `--verbose`
|
|
29
|
+
* renderer (mmnto-ai/totem#1482).
|
|
30
|
+
*
|
|
31
|
+
* `layer` numbers align with the ADR-088 staging (1 = manual, 2 = example-
|
|
32
|
+
* based, 3 = Layer 3 LLM with verify-retry). Consumers MUST tolerate unknown
|
|
33
|
+
* layer numbers so a future ADR-088 phase (dedicated Layer 1 / Layer 2
|
|
34
|
+
* telemetry) can emit without breaking the renderer.
|
|
35
|
+
*
|
|
36
|
+
* `patternHash` is a stable 16-character sha256 prefix of the emitted
|
|
37
|
+
* pattern, included only on `generate` events. Callers use it to correlate
|
|
38
|
+
* retries ("this retry produced the same pattern") without forwarding the
|
|
39
|
+
* pattern string itself.
|
|
40
|
+
*
|
|
41
|
+
* `reasonCode` is only set on the terminal `result` event when the lesson
|
|
42
|
+
* skipped. A compiled or failed lesson omits the field.
|
|
43
|
+
*/
|
|
44
|
+
export interface LayerTraceEvent {
|
|
45
|
+
layer: number;
|
|
46
|
+
action: 'generate' | 'verify' | 'retry' | 'result';
|
|
47
|
+
outcome: string;
|
|
48
|
+
patternHash?: string;
|
|
49
|
+
reasonCode?: Exclude<NonCompilableReasonCode, 'legacy-unknown'>;
|
|
50
|
+
}
|
|
9
51
|
export type CompileLessonResult = {
|
|
10
52
|
status: 'compiled';
|
|
11
53
|
rule: CompiledRule;
|
|
54
|
+
trace?: LayerTraceEvent[];
|
|
12
55
|
} | {
|
|
13
56
|
status: 'skipped';
|
|
14
57
|
hash: string;
|
|
15
58
|
reason?: string;
|
|
59
|
+
reasonCode: CompileLessonReasonCode;
|
|
60
|
+
trace?: LayerTraceEvent[];
|
|
16
61
|
} | {
|
|
17
62
|
status: 'failed';
|
|
63
|
+
trace?: LayerTraceEvent[];
|
|
18
64
|
} | {
|
|
19
65
|
status: 'noop';
|
|
66
|
+
trace?: LayerTraceEvent[];
|
|
20
67
|
};
|
|
21
68
|
export interface CompileLessonCallbacks {
|
|
22
69
|
onWarn?: (heading: string, message: string) => void;
|
|
@@ -53,6 +100,17 @@ export interface CompileLessonDeps {
|
|
|
53
100
|
* system prompt would invalidate the cache on every --upgrade call.
|
|
54
101
|
*/
|
|
55
102
|
telemetryPrefix?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Assert that this compile is producing a security rule. Per ADR-088
|
|
105
|
+
* Decision 3 (Layer 3 zero-tolerance), security rules that fail the smoke
|
|
106
|
+
* gate are rejected outright with no retry. Reserved for callers that know
|
|
107
|
+
* the source pack context (e.g., compiling lessons from a pack scoped
|
|
108
|
+
* `@totem/pack-agent-security` or any pack whose manifest carries an
|
|
109
|
+
* immutable severity contract). Today's `totem lesson compile` at repo
|
|
110
|
+
* level does not set this; a future pack-build command will. Defaults to
|
|
111
|
+
* false; security zero-tolerance is gated on an affirmative caller assertion.
|
|
112
|
+
*/
|
|
113
|
+
securityContext?: boolean;
|
|
56
114
|
}
|
|
57
115
|
/**
|
|
58
116
|
* Compile-time validation for ast-grep patterns (#1062, #1339).
|
|
@@ -141,6 +199,23 @@ export declare function formatExampleFailure(result: RuleTestResult): string;
|
|
|
141
199
|
* Returns { rule, rejectReason } so callers can report why a pattern was rejected.
|
|
142
200
|
*/
|
|
143
201
|
export declare function buildManualRule(lesson: LessonInput, existingByHash: Map<string, CompiledRule>): BuildRuleResult;
|
|
202
|
+
/**
|
|
203
|
+
* Security-context signal for the missing-Example-Hit check. Either the
|
|
204
|
+
* compile orchestrator asserts the pack is security-scoped
|
|
205
|
+
* (`deps.securityContext === true`) OR the rule under construction already
|
|
206
|
+
* carries `immutable: true` (set by the pack manifest, ADR-089). Both
|
|
207
|
+
* paths trigger the zero-tolerance reject per ADR-088 Decision 3.
|
|
208
|
+
*
|
|
209
|
+
* The LLM-emitted `CompilerOutput` does not currently carry an `immutable`
|
|
210
|
+
* field (packs set it at pack-merge time), so the second signal only
|
|
211
|
+
* engages on the Pipeline 1 manual-rule path where `buildManualRule`
|
|
212
|
+
* could synthesize an immutable rule directly. A future change that
|
|
213
|
+
* threads `immutable` through `CompilerOutput` can wire Pipeline 2/3
|
|
214
|
+
* into this helper without touching the call sites.
|
|
215
|
+
*/
|
|
216
|
+
export declare function isSecurityContext(deps: CompileLessonDeps, rule?: {
|
|
217
|
+
immutable?: boolean;
|
|
218
|
+
} | null): boolean;
|
|
144
219
|
/**
|
|
145
220
|
* Compile a single lesson into a rule.
|
|
146
221
|
* Handles both manual patterns (zero LLM) and LLM-compiled patterns.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-lesson.d.ts","sourceRoot":"","sources":["../src/compile-lesson.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compile-lesson.d.ts","sourceRoot":"","sources":["../src/compile-lesson.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,uBAAuB,EACvB,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAM9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAKvD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,EAAE,gBAAgB,CAAC,CAAC;AAEzF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,eAAe;IAC9B,K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