@mmnto/totem 1.118.1 → 1.119.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/artifacts/admission.d.ts +12 -12
- package/dist/artifacts/verdict.d.ts +16 -16
- package/dist/compile-manifest.d.ts +89 -0
- package/dist/compile-manifest.d.ts.map +1 -1
- package/dist/compile-manifest.js +180 -31
- package/dist/compile-manifest.js.map +1 -1
- package/dist/compile-manifest.test.js +169 -1
- package/dist/compile-manifest.test.js.map +1 -1
- package/dist/compiler-schema.d.ts +1067 -0
- package/dist/compiler-schema.d.ts.map +1 -1
- package/dist/compiler-schema.js +204 -1
- package/dist/compiler-schema.js.map +1 -1
- package/dist/compiler-schema.test.js +92 -0
- package/dist/compiler-schema.test.js.map +1 -1
- package/dist/compiler.d.ts +2 -6
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js +6 -17
- package/dist/compiler.js.map +1 -1
- package/dist/freeze.d.ts +3 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/ledger.d.ts +12 -12
- package/dist/regex-safety/apply-rules-bounded.d.ts +11 -0
- package/dist/regex-safety/apply-rules-bounded.d.ts.map +1 -1
- package/dist/regex-safety/apply-rules-bounded.js +59 -5
- package/dist/regex-safety/apply-rules-bounded.js.map +1 -1
- package/dist/regex-validation.d.ts +7 -0
- package/dist/regex-validation.d.ts.map +1 -0
- package/dist/regex-validation.js +32 -0
- package/dist/regex-validation.js.map +1 -0
- package/dist/rule-engine.d.ts +11 -1
- package/dist/rule-engine.d.ts.map +1 -1
- package/dist/rule-engine.js +125 -18
- package/dist/rule-engine.js.map +1 -1
- package/dist/spine/authored-rule.d.ts +669 -245
- package/dist/spine/authored-rule.d.ts.map +1 -1
- package/dist/spine/authored-rule.js +113 -27
- package/dist/spine/authored-rule.js.map +1 -1
- package/dist/spine/authored-rule.test.js +170 -4
- package/dist/spine/authored-rule.test.js.map +1 -1
- package/dist/spine/authoring-ledger.d.ts +69 -10
- package/dist/spine/authoring-ledger.d.ts.map +1 -1
- package/dist/spine/authoring-ledger.js +46 -25
- package/dist/spine/authoring-ledger.js.map +1 -1
- package/dist/spine/authoring-ledger.test.js +20 -7
- package/dist/spine/authoring-ledger.test.js.map +1 -1
- package/dist/spine/candidate-rule.d.ts +18 -1
- package/dist/spine/candidate-rule.d.ts.map +1 -1
- package/dist/spine/candidate-rule.js.map +1 -1
- package/dist/spine/cert-corpus-seed.d.ts +8 -8
- package/dist/spine/compile.d.ts +4 -1
- package/dist/spine/compile.d.ts.map +1 -1
- package/dist/spine/compile.js +50 -3
- package/dist/spine/compile.js.map +1 -1
- package/dist/spine/compile.test.js +189 -23
- package/dist/spine/compile.test.js.map +1 -1
- package/dist/spine/frozen-split.d.ts +18 -18
- package/dist/spine/ledgers.d.ts +24 -24
- package/dist/spine/lf-normalize.d.ts +9 -0
- package/dist/spine/lf-normalize.d.ts.map +1 -0
- package/dist/spine/lf-normalize.js +38 -0
- package/dist/spine/lf-normalize.js.map +1 -0
- package/dist/spine/preimage-differential.d.ts +3 -1
- package/dist/spine/preimage-differential.d.ts.map +1 -1
- package/dist/spine/preimage-differential.js +9 -6
- package/dist/spine/preimage-differential.js.map +1 -1
- package/dist/spine/preimage-differential.test.js +59 -0
- package/dist/spine/preimage-differential.test.js.map +1 -1
- package/dist/spine/record-exemplars.fixture.d.ts +5 -0
- package/dist/spine/record-exemplars.fixture.d.ts.map +1 -0
- package/dist/spine/record-exemplars.fixture.js +61 -0
- package/dist/spine/record-exemplars.fixture.js.map +1 -0
- package/dist/spine/record-lower.d.ts +90 -0
- package/dist/spine/record-lower.d.ts.map +1 -0
- package/dist/spine/record-lower.js +418 -0
- package/dist/spine/record-lower.js.map +1 -0
- package/dist/spine/record-lower.test.d.ts +2 -0
- package/dist/spine/record-lower.test.d.ts.map +1 -0
- package/dist/spine/record-lower.test.js +562 -0
- package/dist/spine/record-lower.test.js.map +1 -0
- package/dist/spine/record-runtime.d.ts +215 -0
- package/dist/spine/record-runtime.d.ts.map +1 -0
- package/dist/spine/record-runtime.js +330 -0
- package/dist/spine/record-runtime.js.map +1 -0
- package/dist/spine/record-runtime.test.d.ts +2 -0
- package/dist/spine/record-runtime.test.d.ts.map +1 -0
- package/dist/spine/record-runtime.test.js +814 -0
- package/dist/spine/record-runtime.test.js.map +1 -0
- package/dist/spine/rule-record.d.ts +864 -0
- package/dist/spine/rule-record.d.ts.map +1 -0
- package/dist/spine/rule-record.js +781 -0
- package/dist/spine/rule-record.js.map +1 -0
- package/dist/spine/rule-record.test.d.ts +2 -0
- package/dist/spine/rule-record.test.d.ts.map +1 -0
- package/dist/spine/rule-record.test.js +1262 -0
- package/dist/spine/rule-record.test.js.map +1 -0
- package/dist/spine/windtunnel-firing.d.ts.map +1 -1
- package/dist/spine/windtunnel-firing.js +28 -1
- package/dist/spine/windtunnel-firing.js.map +1 -1
- package/dist/spine/windtunnel-lock.d.ts +10 -10
- package/dist/stage4-verifier.d.ts.map +1 -1
- package/dist/stage4-verifier.js +61 -17
- package/dist/stage4-verifier.js.map +1 -1
- package/dist/sys/glob.d.ts +30 -0
- package/dist/sys/glob.d.ts.map +1 -1
- package/dist/sys/glob.js +62 -1
- package/dist/sys/glob.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,864 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { TotemParseError } from '../errors.js';
|
|
3
|
+
/** Base: any Prop 310 record-grammar parse failure. Carries file + key path. */
|
|
4
|
+
export declare class RuleRecordParseError extends TotemParseError {
|
|
5
|
+
readonly filePath: string;
|
|
6
|
+
readonly keyPath: string;
|
|
7
|
+
constructor(filePath: string, keyPath: string, detail: string, recoveryHint: string, cause?: unknown);
|
|
8
|
+
}
|
|
9
|
+
/** The § Design 2 no-silent-skip constructs a V1 consumer may never drop silently. */
|
|
10
|
+
export type NoSilentSkipConstruct = 'schemaVersion' | 'target.type' | 'requires.scope';
|
|
11
|
+
/**
|
|
12
|
+
* § Design 2 (R5) — unknown `schemaVersion`, unknown `target.type`, or a
|
|
13
|
+
* reserved-unimplemented construct (`requires.scope: block`, § Design 8). A V1
|
|
14
|
+
* consumer that cannot declare a degraded mode enumerating every skipped rule
|
|
15
|
+
* MUST fail; Prop 270 §6.3's warn-and-ignore is superseded (a silent
|
|
16
|
+
* warn-and-ignore is a fail-open rule drop in a governance compiler).
|
|
17
|
+
*/
|
|
18
|
+
export declare class RuleRecordNoSilentSkipError extends RuleRecordParseError {
|
|
19
|
+
readonly construct: NoSilentSkipConstruct;
|
|
20
|
+
constructor(filePath: string, construct: NoSilentSkipConstruct, detail: string);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* § Design 4 — a producer-owned / intake-seam key is INEXPRESSIBLE in a record at
|
|
24
|
+
* any depth. Distinct from a generic unknown-key rejection: the author needs to
|
|
25
|
+
* be told the key belongs to the ADR-112 producer or the intake invocation
|
|
26
|
+
* (§ Design 1), not that they typo'd a grammar field.
|
|
27
|
+
*/
|
|
28
|
+
export declare class RuleRecordProducerKeyError extends RuleRecordParseError {
|
|
29
|
+
readonly producerKey: string;
|
|
30
|
+
constructor(filePath: string, keyPath: string, producerKey: string);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A mapping key that is JS prototype machinery. NOT a § Design 4 violation —
|
|
34
|
+
* these are rejected on security grounds, not because a producer owns them — so
|
|
35
|
+
* it carries its own diagnostic and never says "producer-owned".
|
|
36
|
+
*/
|
|
37
|
+
export declare class RuleRecordPrototypeKeyError extends RuleRecordParseError {
|
|
38
|
+
readonly prototypeKey: string;
|
|
39
|
+
constructor(filePath: string, keyPath: string, prototypeKey: string);
|
|
40
|
+
}
|
|
41
|
+
/** § Design 4 — keys a record may never carry, at any depth. */
|
|
42
|
+
export declare const RULE_RECORD_INEXPRESSIBLE_KEYS: ReadonlySet<string>;
|
|
43
|
+
/**
|
|
44
|
+
* SECURITY FLOOR — mapping keys that are JS prototype machinery, rejected at any
|
|
45
|
+
* depth including the opaque `target.rule` interior. DELIBERATELY a separate set
|
|
46
|
+
* from `RULE_RECORD_INEXPRESSIBLE_KEYS`: that one is spec-defined at exactly 21
|
|
47
|
+
* producer-owned keys (§ Design 4) and size-guarded, while these three are not a
|
|
48
|
+
* grammar rule at all.
|
|
49
|
+
*
|
|
50
|
+
* The floor is needed because IR-2 keeps the payload interior OPAQUE: `yaml`
|
|
51
|
+
* materializes `__proto__` as an OWN ENUMERABLE property, so it survives into
|
|
52
|
+
* whatever slice 2's lowering builds — a spread carries it forward as a real key,
|
|
53
|
+
* and an `Object.assign` reparents the destination's prototype while silently
|
|
54
|
+
* DROPPING the key. Both are structural corruption a parser must not hand
|
|
55
|
+
* downstream. No legitimate ast-grep construct is named any of these.
|
|
56
|
+
*/
|
|
57
|
+
export declare const RULE_RECORD_FORBIDDEN_PROTOTYPE_KEYS: ReadonlySet<string>;
|
|
58
|
+
/**
|
|
59
|
+
* The closed set of § Design 7 rules a glob can violate. A runtime value, not a
|
|
60
|
+
* bare type union, so the conformance suite can assert every rule has a negative
|
|
61
|
+
* fixture — an unexercised rule is an unpinned rule (§ Design 14).
|
|
62
|
+
*/
|
|
63
|
+
export declare const GLOB_DIALECT_RULES: readonly ["empty", "surrounding-whitespace", "separator", "absolute-path", "drive-letter", "brace-expansion", "negation", "regex-syntax", "empty-segment", "current-segment", "parent-segment", "embedded-globstar", "adjacent-globstar"];
|
|
64
|
+
/** The § Design 7 rule a glob violated. Each maps to one negative conformance fixture. */
|
|
65
|
+
export type GlobDialectRule = (typeof GLOB_DIALECT_RULES)[number];
|
|
66
|
+
/** A dialect violation: the rule broken + a message citing it. */
|
|
67
|
+
export interface GlobDialectViolation {
|
|
68
|
+
rule: GlobDialectRule;
|
|
69
|
+
message: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* § Design 7 — validate one glob against the normative dialect. Returns the first
|
|
73
|
+
* violation (checks run in a fixed order, so the diagnostic is deterministic) or
|
|
74
|
+
* `null` when the glob is dialect-clean. Pure: it never rewrites the glob.
|
|
75
|
+
*
|
|
76
|
+
* Allowed: literal segments; `*` as a single-segment wildcard (including
|
|
77
|
+
* extension forms like `*.ts`); `**` as a whole-segment globstar, non-adjacent
|
|
78
|
+
* and non-nested. Anything outside that closed set is a parse error — an empty
|
|
79
|
+
* segment is not a literal segment, so it is rejected too.
|
|
80
|
+
*/
|
|
81
|
+
export declare function checkGlobDialect(glob: string): GlobDialectViolation | null;
|
|
82
|
+
/** § Design 2 — the only `schemaVersion` this V1 grammar admits. */
|
|
83
|
+
export declare const RULE_RECORD_SCHEMA_VERSION = 1;
|
|
84
|
+
/** § Design 4 — closed severity vocabulary; NO default (the census's silent warning-default is killed). */
|
|
85
|
+
export declare const RuleSeveritySchema: z.ZodEnum<["error", "warning"]>;
|
|
86
|
+
export type RuleSeverity = z.infer<typeof RuleSeveritySchema>;
|
|
87
|
+
/**
|
|
88
|
+
* § Design 6 (R16) — the V1 authoring enum. `ast` is dropped from the AUTHORING
|
|
89
|
+
* surface (0 of 485 corpus rules) while reader/compiled enums keep it inert;
|
|
90
|
+
* `rego` and ADR-109's action-rule type join by grammar version bump.
|
|
91
|
+
*/
|
|
92
|
+
export declare const RuleTargetTypeSchema: z.ZodEnum<["ast-grep", "regex"]>;
|
|
93
|
+
export type RuleTargetType = z.infer<typeof RuleTargetTypeSchema>;
|
|
94
|
+
/**
|
|
95
|
+
* § Design 6 (R16) — the S-expression tier. Reader/compiled enums keep it as an
|
|
96
|
+
* inert legacy member with a deprecation diagnostic; the AUTHORING surface drops
|
|
97
|
+
* it, and unlike `rego` / ADR-109's action-rule type it does NOT return by version
|
|
98
|
+
* bump. Exported with its diagnostic so the conformance suite pins the wording:
|
|
99
|
+
* pointing an author at a bump that will never carry `ast` is a wrong answer, not
|
|
100
|
+
* a terse one.
|
|
101
|
+
*/
|
|
102
|
+
export declare const LEGACY_INERT_ENGINE = "ast";
|
|
103
|
+
export declare const LEGACY_ENGINE_DETAIL = "`ast` (the S-expression tier) is DROPPED from the V1 authoring surface and does NOT return by version bump \u2014 0 of the 485 corpus rules used it. Reader and compiled enums keep `ast` as an inert legacy member with a deprecation diagnostic, but no record may declare it (\u00A7 Design 6, R16)";
|
|
104
|
+
/**
|
|
105
|
+
* § Design 8 — the absence unit. The closed name space RESERVES `line | block |
|
|
106
|
+
* file`; `line` and `file` are implemented at V1 and `block` is
|
|
107
|
+
* reserved-unimplemented pending a language adapter's boundary definition, so it
|
|
108
|
+
* hits the § Design 2 gate rather than parsing. NO default — omitting `scope:`
|
|
109
|
+
* is a parse error (a file-as-default is a silent default reborn).
|
|
110
|
+
*/
|
|
111
|
+
export declare const RequiresScopeSchema: z.ZodEnum<["line", "file"]>;
|
|
112
|
+
export type RequiresScope = z.infer<typeof RequiresScopeSchema>;
|
|
113
|
+
/** § Design 8 — the reserved-unimplemented member of the `requires.scope` name space. */
|
|
114
|
+
export declare const REQUIRES_SCOPE_RESERVED = "block";
|
|
115
|
+
/** § Design 4 — `target.scope`: positive globs only, with first-class structural exclusions. */
|
|
116
|
+
export declare const RuleScopeSchema: z.ZodObject<{
|
|
117
|
+
fileGlobs: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
118
|
+
/**
|
|
119
|
+
* Applied as `positiveMatch && !excludeMatch` — positive-form entries, never
|
|
120
|
+
* `!`-negation. Min-1 WHEN PRESENT: an empty list is a silent no-op, and
|
|
121
|
+
* "no exclusions" is expressed by OMITTING the key (§ Design 4 — no key in
|
|
122
|
+
* this grammar carries a do-nothing value).
|
|
123
|
+
*/
|
|
124
|
+
excludeGlobs: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
125
|
+
}, "strict", z.ZodTypeAny, {
|
|
126
|
+
fileGlobs: string[];
|
|
127
|
+
excludeGlobs?: string[] | undefined;
|
|
128
|
+
}, {
|
|
129
|
+
fileGlobs: string[];
|
|
130
|
+
excludeGlobs?: string[] | undefined;
|
|
131
|
+
}>;
|
|
132
|
+
export type RuleScope = z.infer<typeof RuleScopeSchema>;
|
|
133
|
+
/**
|
|
134
|
+
* § Design 4 — `target`. `language` is REQUIRED for ast-grep and FORBIDDEN for
|
|
135
|
+
* regex (§ Design 6: one declared language, validated under exactly that grammar
|
|
136
|
+
* — replacing the try-each-glob-derived-Lang cross-grammar acceptance). The
|
|
137
|
+
* payload is exactly one of `pattern` (flat) or `rule` (compound) for ast-grep,
|
|
138
|
+
* and `pattern` only for regex.
|
|
139
|
+
*/
|
|
140
|
+
export declare const RuleTargetSchema: z.ZodEffects<z.ZodObject<{
|
|
141
|
+
type: z.ZodEnum<["ast-grep", "regex"]>;
|
|
142
|
+
/** § Design 6 — an identifier TOKEN at parse; it resolves against the Map-backed registry at compile (slice 2), never a spec-frozen enum. */
|
|
143
|
+
language: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
144
|
+
pattern: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
145
|
+
rule: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnknown>, Record<string, unknown>, Record<string, unknown>>>;
|
|
146
|
+
scope: z.ZodObject<{
|
|
147
|
+
fileGlobs: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
148
|
+
/**
|
|
149
|
+
* Applied as `positiveMatch && !excludeMatch` — positive-form entries, never
|
|
150
|
+
* `!`-negation. Min-1 WHEN PRESENT: an empty list is a silent no-op, and
|
|
151
|
+
* "no exclusions" is expressed by OMITTING the key (§ Design 4 — no key in
|
|
152
|
+
* this grammar carries a do-nothing value).
|
|
153
|
+
*/
|
|
154
|
+
excludeGlobs: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
155
|
+
}, "strict", z.ZodTypeAny, {
|
|
156
|
+
fileGlobs: string[];
|
|
157
|
+
excludeGlobs?: string[] | undefined;
|
|
158
|
+
}, {
|
|
159
|
+
fileGlobs: string[];
|
|
160
|
+
excludeGlobs?: string[] | undefined;
|
|
161
|
+
}>;
|
|
162
|
+
}, "strict", z.ZodTypeAny, {
|
|
163
|
+
type: "regex" | "ast-grep";
|
|
164
|
+
scope: {
|
|
165
|
+
fileGlobs: string[];
|
|
166
|
+
excludeGlobs?: string[] | undefined;
|
|
167
|
+
};
|
|
168
|
+
rule?: Record<string, unknown> | undefined;
|
|
169
|
+
pattern?: string | undefined;
|
|
170
|
+
language?: string | undefined;
|
|
171
|
+
}, {
|
|
172
|
+
type: "regex" | "ast-grep";
|
|
173
|
+
scope: {
|
|
174
|
+
fileGlobs: string[];
|
|
175
|
+
excludeGlobs?: string[] | undefined;
|
|
176
|
+
};
|
|
177
|
+
rule?: Record<string, unknown> | undefined;
|
|
178
|
+
pattern?: string | undefined;
|
|
179
|
+
language?: string | undefined;
|
|
180
|
+
}>, {
|
|
181
|
+
type: "regex" | "ast-grep";
|
|
182
|
+
scope: {
|
|
183
|
+
fileGlobs: string[];
|
|
184
|
+
excludeGlobs?: string[] | undefined;
|
|
185
|
+
};
|
|
186
|
+
rule?: Record<string, unknown> | undefined;
|
|
187
|
+
pattern?: string | undefined;
|
|
188
|
+
language?: string | undefined;
|
|
189
|
+
}, {
|
|
190
|
+
type: "regex" | "ast-grep";
|
|
191
|
+
scope: {
|
|
192
|
+
fileGlobs: string[];
|
|
193
|
+
excludeGlobs?: string[] | undefined;
|
|
194
|
+
};
|
|
195
|
+
rule?: Record<string, unknown> | undefined;
|
|
196
|
+
pattern?: string | undefined;
|
|
197
|
+
language?: string | undefined;
|
|
198
|
+
}>;
|
|
199
|
+
export type RuleTarget = z.infer<typeof RuleTargetSchema>;
|
|
200
|
+
/**
|
|
201
|
+
* § Design 5/§ Design 10 — one bad/good exemplar pair. IR-1: both sides are
|
|
202
|
+
* non-empty. `examples` is certification's PRIMARY PREIMAGE SOURCE (ADR-112 §4)
|
|
203
|
+
* and Amendment 1 makes the record the EDITABLE home, so a zero-byte exemplar
|
|
204
|
+
* cannot serve as the fire-on-bad ∧ silent-on-good differential it exists to be.
|
|
205
|
+
*
|
|
206
|
+
* Named `RuleRecordExample`, not `RuleExample`: the shipped LEGACY
|
|
207
|
+
* `RuleExamples` (`lesson-pattern.ts`, on the same barrel) is the hit/miss shape
|
|
208
|
+
* of the frozen lesson path this grammar supersedes, and two barrel exports one
|
|
209
|
+
* character apart is a mis-import waiting to happen.
|
|
210
|
+
*/
|
|
211
|
+
export declare const RuleRecordExampleSchema: z.ZodObject<{
|
|
212
|
+
bad: z.ZodEffects<z.ZodString, string, string>;
|
|
213
|
+
good: z.ZodEffects<z.ZodString, string, string>;
|
|
214
|
+
}, "strict", z.ZodTypeAny, {
|
|
215
|
+
bad: string;
|
|
216
|
+
good: string;
|
|
217
|
+
}, {
|
|
218
|
+
bad: string;
|
|
219
|
+
good: string;
|
|
220
|
+
}>;
|
|
221
|
+
export type RuleRecordExample = z.infer<typeof RuleRecordExampleSchema>;
|
|
222
|
+
/**
|
|
223
|
+
* § Design 8 — the absence / must-contain block. Fires on a `target` match at
|
|
224
|
+
* locus L iff `requires.pattern` does NOT match within the declared scope
|
|
225
|
+
* containing L. V1 carries EXACTLY ONE block (multi-requires is a version-bump
|
|
226
|
+
* extension), so this is a single mapping, never a list.
|
|
227
|
+
*/
|
|
228
|
+
export declare const RuleRequiresSchema: z.ZodObject<{
|
|
229
|
+
/** A safe-regex2-gated regex evaluated TEXTUALLY at the declared scope (gate is slice 2), independent of `target.type`. */
|
|
230
|
+
pattern: z.ZodEffects<z.ZodString, string, string>;
|
|
231
|
+
scope: z.ZodEnum<["line", "file"]>;
|
|
232
|
+
}, "strict", z.ZodTypeAny, {
|
|
233
|
+
pattern: string;
|
|
234
|
+
scope: "line" | "file";
|
|
235
|
+
}, {
|
|
236
|
+
pattern: string;
|
|
237
|
+
scope: "line" | "file";
|
|
238
|
+
}>;
|
|
239
|
+
export type RuleRequires = z.infer<typeof RuleRequiresSchema>;
|
|
240
|
+
/**
|
|
241
|
+
* § Design 4 (R8) — Prop 270 §8's curation-provenance block, carried under the
|
|
242
|
+
* name `curation:` (renamed there because `provenance` is the ADR-112 producer's
|
|
243
|
+
* own output field). Keys are camelCase, normalized from Prop 270 §8's snake_case
|
|
244
|
+
* — a casing normalization, not a semantic change. The block is optional for
|
|
245
|
+
* direct-authored rules and REQUIRED for Baseline-5-curated ones.
|
|
246
|
+
*
|
|
247
|
+
* SHAPE, per OPERATOR RULING 2026-08-21 (superseding IR-4's build-time
|
|
248
|
+
* complete-or-absent reading, which rejected a lone `sourceLesson`):
|
|
249
|
+
*
|
|
250
|
+
* - `sourceLesson` is REQUIRED whenever the block is present. It is § Design 1's
|
|
251
|
+
* record→lesson link — the one thing every curated rule has, since a curated
|
|
252
|
+
* rule always derives from a lesson — so a block without it is incoherent.
|
|
253
|
+
* - `curatedBy` / `curatedAt` / `baseline5Phase` are the Baseline-5 PROCESS
|
|
254
|
+
* trio (Prop 270 §8), optional as a GROUP but ALL-OR-NONE together: a
|
|
255
|
+
* direct-authored rule carries the link alone, a Baseline-5-curated rule
|
|
256
|
+
* carries the whole process record, and a PARTIAL trio is a parse error
|
|
257
|
+
* naming the missing members.
|
|
258
|
+
*
|
|
259
|
+
* No defaults are introduced by the relaxation, and the key space stays closed —
|
|
260
|
+
* "optional" here means absent, never silently filled in.
|
|
261
|
+
*/
|
|
262
|
+
/** Prop 270 §8's Baseline-5 process trio — optional as a group, all-or-none together. */
|
|
263
|
+
export declare const CURATION_PROCESS_FIELDS: readonly ["curatedBy", "curatedAt", "baseline5Phase"];
|
|
264
|
+
export declare const RuleCurationSchema: z.ZodEffects<z.ZodObject<{
|
|
265
|
+
/** § Design 1 — the record→lesson link. Required whenever the block is present. */
|
|
266
|
+
sourceLesson: z.ZodEffects<z.ZodString, string, string>;
|
|
267
|
+
curatedBy: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
268
|
+
curatedAt: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
269
|
+
baseline5Phase: z.ZodOptional<z.ZodNumber>;
|
|
270
|
+
}, "strict", z.ZodTypeAny, {
|
|
271
|
+
sourceLesson: string;
|
|
272
|
+
curatedBy?: string | undefined;
|
|
273
|
+
curatedAt?: string | undefined;
|
|
274
|
+
baseline5Phase?: number | undefined;
|
|
275
|
+
}, {
|
|
276
|
+
sourceLesson: string;
|
|
277
|
+
curatedBy?: string | undefined;
|
|
278
|
+
curatedAt?: string | undefined;
|
|
279
|
+
baseline5Phase?: number | undefined;
|
|
280
|
+
}>, {
|
|
281
|
+
sourceLesson: string;
|
|
282
|
+
curatedBy?: string | undefined;
|
|
283
|
+
curatedAt?: string | undefined;
|
|
284
|
+
baseline5Phase?: number | undefined;
|
|
285
|
+
}, {
|
|
286
|
+
sourceLesson: string;
|
|
287
|
+
curatedBy?: string | undefined;
|
|
288
|
+
curatedAt?: string | undefined;
|
|
289
|
+
baseline5Phase?: number | undefined;
|
|
290
|
+
}>;
|
|
291
|
+
export type RuleCuration = z.infer<typeof RuleCurationSchema>;
|
|
292
|
+
/**
|
|
293
|
+
* § Design 9 (Amendment R4) — the optional classification block. Parsed under its
|
|
294
|
+
* closed keys and retained VERBATIM; never evaluated at V1. The snake_case name
|
|
295
|
+
* is a deliberate, named exception to the grammar's camelCase (§ Design 4): the
|
|
296
|
+
* key is already reserved in shipped forward-compat readers, so renaming it would
|
|
297
|
+
* buy consistency at the price of a pointless migration. NEVER rename it.
|
|
298
|
+
*/
|
|
299
|
+
export declare const VerificationShadowSchema: z.ZodObject<{
|
|
300
|
+
type: z.ZodEffects<z.ZodString, string, string>;
|
|
301
|
+
source: z.ZodEffects<z.ZodString, string, string>;
|
|
302
|
+
}, "strict", z.ZodTypeAny, {
|
|
303
|
+
type: string;
|
|
304
|
+
source: string;
|
|
305
|
+
}, {
|
|
306
|
+
type: string;
|
|
307
|
+
source: string;
|
|
308
|
+
}>;
|
|
309
|
+
export type VerificationShadow = z.infer<typeof VerificationShadowSchema>;
|
|
310
|
+
/**
|
|
311
|
+
* Prop 310 § Design 4 — the V1 rule record. `.strict()` at every depth of the
|
|
312
|
+
* record's own key space; no field anywhere has a default. The § Design 5
|
|
313
|
+
* mandatory set is `schemaVersion`, `severity`, `message`, `target.type`,
|
|
314
|
+
* `target.<payload>`, `target.scope.fileGlobs`, and a non-empty `examples`.
|
|
315
|
+
*/
|
|
316
|
+
export declare const RuleRecordSchema: z.ZodObject<{
|
|
317
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
318
|
+
severity: z.ZodEnum<["error", "warning"]>;
|
|
319
|
+
/** REQUIRED, non-empty (R8) — the census found `message` on 4 of 140 hand-authored lessons. */
|
|
320
|
+
message: z.ZodEffects<z.ZodString, string, string>;
|
|
321
|
+
recoveryHint: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
322
|
+
target: z.ZodEffects<z.ZodObject<{
|
|
323
|
+
type: z.ZodEnum<["ast-grep", "regex"]>;
|
|
324
|
+
/** § Design 6 — an identifier TOKEN at parse; it resolves against the Map-backed registry at compile (slice 2), never a spec-frozen enum. */
|
|
325
|
+
language: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
326
|
+
pattern: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
327
|
+
rule: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnknown>, Record<string, unknown>, Record<string, unknown>>>;
|
|
328
|
+
scope: z.ZodObject<{
|
|
329
|
+
fileGlobs: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
330
|
+
/**
|
|
331
|
+
* Applied as `positiveMatch && !excludeMatch` — positive-form entries, never
|
|
332
|
+
* `!`-negation. Min-1 WHEN PRESENT: an empty list is a silent no-op, and
|
|
333
|
+
* "no exclusions" is expressed by OMITTING the key (§ Design 4 — no key in
|
|
334
|
+
* this grammar carries a do-nothing value).
|
|
335
|
+
*/
|
|
336
|
+
excludeGlobs: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
337
|
+
}, "strict", z.ZodTypeAny, {
|
|
338
|
+
fileGlobs: string[];
|
|
339
|
+
excludeGlobs?: string[] | undefined;
|
|
340
|
+
}, {
|
|
341
|
+
fileGlobs: string[];
|
|
342
|
+
excludeGlobs?: string[] | undefined;
|
|
343
|
+
}>;
|
|
344
|
+
}, "strict", z.ZodTypeAny, {
|
|
345
|
+
type: "regex" | "ast-grep";
|
|
346
|
+
scope: {
|
|
347
|
+
fileGlobs: string[];
|
|
348
|
+
excludeGlobs?: string[] | undefined;
|
|
349
|
+
};
|
|
350
|
+
rule?: Record<string, unknown> | undefined;
|
|
351
|
+
pattern?: string | undefined;
|
|
352
|
+
language?: string | undefined;
|
|
353
|
+
}, {
|
|
354
|
+
type: "regex" | "ast-grep";
|
|
355
|
+
scope: {
|
|
356
|
+
fileGlobs: string[];
|
|
357
|
+
excludeGlobs?: string[] | undefined;
|
|
358
|
+
};
|
|
359
|
+
rule?: Record<string, unknown> | undefined;
|
|
360
|
+
pattern?: string | undefined;
|
|
361
|
+
language?: string | undefined;
|
|
362
|
+
}>, {
|
|
363
|
+
type: "regex" | "ast-grep";
|
|
364
|
+
scope: {
|
|
365
|
+
fileGlobs: string[];
|
|
366
|
+
excludeGlobs?: string[] | undefined;
|
|
367
|
+
};
|
|
368
|
+
rule?: Record<string, unknown> | undefined;
|
|
369
|
+
pattern?: string | undefined;
|
|
370
|
+
language?: string | undefined;
|
|
371
|
+
}, {
|
|
372
|
+
type: "regex" | "ast-grep";
|
|
373
|
+
scope: {
|
|
374
|
+
fileGlobs: string[];
|
|
375
|
+
excludeGlobs?: string[] | undefined;
|
|
376
|
+
};
|
|
377
|
+
rule?: Record<string, unknown> | undefined;
|
|
378
|
+
pattern?: string | undefined;
|
|
379
|
+
language?: string | undefined;
|
|
380
|
+
}>;
|
|
381
|
+
examples: z.ZodArray<z.ZodObject<{
|
|
382
|
+
bad: z.ZodEffects<z.ZodString, string, string>;
|
|
383
|
+
good: z.ZodEffects<z.ZodString, string, string>;
|
|
384
|
+
}, "strict", z.ZodTypeAny, {
|
|
385
|
+
bad: string;
|
|
386
|
+
good: string;
|
|
387
|
+
}, {
|
|
388
|
+
bad: string;
|
|
389
|
+
good: string;
|
|
390
|
+
}>, "many">;
|
|
391
|
+
requires: z.ZodOptional<z.ZodObject<{
|
|
392
|
+
/** A safe-regex2-gated regex evaluated TEXTUALLY at the declared scope (gate is slice 2), independent of `target.type`. */
|
|
393
|
+
pattern: z.ZodEffects<z.ZodString, string, string>;
|
|
394
|
+
scope: z.ZodEnum<["line", "file"]>;
|
|
395
|
+
}, "strict", z.ZodTypeAny, {
|
|
396
|
+
pattern: string;
|
|
397
|
+
scope: "line" | "file";
|
|
398
|
+
}, {
|
|
399
|
+
pattern: string;
|
|
400
|
+
scope: "line" | "file";
|
|
401
|
+
}>>;
|
|
402
|
+
curation: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
403
|
+
/** § Design 1 — the record→lesson link. Required whenever the block is present. */
|
|
404
|
+
sourceLesson: z.ZodEffects<z.ZodString, string, string>;
|
|
405
|
+
curatedBy: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
406
|
+
curatedAt: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
407
|
+
baseline5Phase: z.ZodOptional<z.ZodNumber>;
|
|
408
|
+
}, "strict", z.ZodTypeAny, {
|
|
409
|
+
sourceLesson: string;
|
|
410
|
+
curatedBy?: string | undefined;
|
|
411
|
+
curatedAt?: string | undefined;
|
|
412
|
+
baseline5Phase?: number | undefined;
|
|
413
|
+
}, {
|
|
414
|
+
sourceLesson: string;
|
|
415
|
+
curatedBy?: string | undefined;
|
|
416
|
+
curatedAt?: string | undefined;
|
|
417
|
+
baseline5Phase?: number | undefined;
|
|
418
|
+
}>, {
|
|
419
|
+
sourceLesson: string;
|
|
420
|
+
curatedBy?: string | undefined;
|
|
421
|
+
curatedAt?: string | undefined;
|
|
422
|
+
baseline5Phase?: number | undefined;
|
|
423
|
+
}, {
|
|
424
|
+
sourceLesson: string;
|
|
425
|
+
curatedBy?: string | undefined;
|
|
426
|
+
curatedAt?: string | undefined;
|
|
427
|
+
baseline5Phase?: number | undefined;
|
|
428
|
+
}>>;
|
|
429
|
+
verification_shadow: z.ZodOptional<z.ZodObject<{
|
|
430
|
+
type: z.ZodEffects<z.ZodString, string, string>;
|
|
431
|
+
source: z.ZodEffects<z.ZodString, string, string>;
|
|
432
|
+
}, "strict", z.ZodTypeAny, {
|
|
433
|
+
type: string;
|
|
434
|
+
source: string;
|
|
435
|
+
}, {
|
|
436
|
+
type: string;
|
|
437
|
+
source: string;
|
|
438
|
+
}>>;
|
|
439
|
+
}, "strict", z.ZodTypeAny, {
|
|
440
|
+
message: string;
|
|
441
|
+
severity: "error" | "warning";
|
|
442
|
+
examples: {
|
|
443
|
+
bad: string;
|
|
444
|
+
good: string;
|
|
445
|
+
}[];
|
|
446
|
+
schemaVersion: 1;
|
|
447
|
+
target: {
|
|
448
|
+
type: "regex" | "ast-grep";
|
|
449
|
+
scope: {
|
|
450
|
+
fileGlobs: string[];
|
|
451
|
+
excludeGlobs?: string[] | undefined;
|
|
452
|
+
};
|
|
453
|
+
rule?: Record<string, unknown> | undefined;
|
|
454
|
+
pattern?: string | undefined;
|
|
455
|
+
language?: string | undefined;
|
|
456
|
+
};
|
|
457
|
+
requires?: {
|
|
458
|
+
pattern: string;
|
|
459
|
+
scope: "line" | "file";
|
|
460
|
+
} | undefined;
|
|
461
|
+
recoveryHint?: string | undefined;
|
|
462
|
+
curation?: {
|
|
463
|
+
sourceLesson: string;
|
|
464
|
+
curatedBy?: string | undefined;
|
|
465
|
+
curatedAt?: string | undefined;
|
|
466
|
+
baseline5Phase?: number | undefined;
|
|
467
|
+
} | undefined;
|
|
468
|
+
verification_shadow?: {
|
|
469
|
+
type: string;
|
|
470
|
+
source: string;
|
|
471
|
+
} | undefined;
|
|
472
|
+
}, {
|
|
473
|
+
message: string;
|
|
474
|
+
severity: "error" | "warning";
|
|
475
|
+
examples: {
|
|
476
|
+
bad: string;
|
|
477
|
+
good: string;
|
|
478
|
+
}[];
|
|
479
|
+
schemaVersion: 1;
|
|
480
|
+
target: {
|
|
481
|
+
type: "regex" | "ast-grep";
|
|
482
|
+
scope: {
|
|
483
|
+
fileGlobs: string[];
|
|
484
|
+
excludeGlobs?: string[] | undefined;
|
|
485
|
+
};
|
|
486
|
+
rule?: Record<string, unknown> | undefined;
|
|
487
|
+
pattern?: string | undefined;
|
|
488
|
+
language?: string | undefined;
|
|
489
|
+
};
|
|
490
|
+
requires?: {
|
|
491
|
+
pattern: string;
|
|
492
|
+
scope: "line" | "file";
|
|
493
|
+
} | undefined;
|
|
494
|
+
recoveryHint?: string | undefined;
|
|
495
|
+
curation?: {
|
|
496
|
+
sourceLesson: string;
|
|
497
|
+
curatedBy?: string | undefined;
|
|
498
|
+
curatedAt?: string | undefined;
|
|
499
|
+
baseline5Phase?: number | undefined;
|
|
500
|
+
} | undefined;
|
|
501
|
+
verification_shadow?: {
|
|
502
|
+
type: string;
|
|
503
|
+
source: string;
|
|
504
|
+
} | undefined;
|
|
505
|
+
}>;
|
|
506
|
+
export type RuleRecord = z.infer<typeof RuleRecordSchema>;
|
|
507
|
+
/** One exemplar pair's drift sensor, keyed by its ordinal within the record (§ Design 10). */
|
|
508
|
+
export interface RuleExamplePairHash {
|
|
509
|
+
/** The `examples[i]` ordinal — half of the `(ruleId, ordinal)` join key; the producer supplies `ruleId` at intake (slice 3). */
|
|
510
|
+
ordinal: number;
|
|
511
|
+
/** sha256 hex over the LF-image of the pair's material. */
|
|
512
|
+
hash: string;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Amendment 1 item 3 — the § Design 10 per-pair content hash is CR-BLIND,
|
|
516
|
+
* computed over the LF-image of its material, so a CRLF-authored and an
|
|
517
|
+
* LF-authored variant of the same exemplar hash IDENTICALLY. The trial's P3 row
|
|
518
|
+
* (`serialization-admit`) is exactly the class this defeats: a writer that
|
|
519
|
+
* escape-smuggles `\r` past the admit hop must not fire a false drift alarm.
|
|
520
|
+
*
|
|
521
|
+
* This is a DIFFERENT EDGE from the authoring-ledger's material hash (Amendment 1
|
|
522
|
+
* item 3's own note) — different inputs, different consumers, different drift
|
|
523
|
+
* meaning. Only the LF-image PRIMITIVE is shared, single-homed at
|
|
524
|
+
* `lfDeepNormalize` (Tenet 20): mirroring the normalizer would let the two edges
|
|
525
|
+
* drift apart on the one thing they must agree about.
|
|
526
|
+
*/
|
|
527
|
+
export declare function ruleExamplePairHash(example: RuleRecordExample): string;
|
|
528
|
+
/**
|
|
529
|
+
* The parser's output — a pure VALUE, per-invocation, never cached (§ Data model
|
|
530
|
+
* deltas): the validated record, the § Design 3 derived engine, and the
|
|
531
|
+
* Amendment 1 item 3 per-pair hashes.
|
|
532
|
+
*/
|
|
533
|
+
export interface ParsedRuleRecord {
|
|
534
|
+
record: RuleRecord;
|
|
535
|
+
/**
|
|
536
|
+
* § Design 3 / R17 — derived from `target.type`, NEVER author-mirrored (a
|
|
537
|
+
* mirrored engine field is Tenet 20's prohibited copy at record scale).
|
|
538
|
+
*/
|
|
539
|
+
derivedEngine: RuleTargetType;
|
|
540
|
+
/** One entry per `examples[i]`, in ordinal order (§ Design 10 drift sensors). */
|
|
541
|
+
examplePairHashes: RuleExamplePairHash[];
|
|
542
|
+
}
|
|
543
|
+
/** One `examples[i]` ordinal and its § Design 10 drift-sensor digest. */
|
|
544
|
+
export declare const RuleExamplePairHashSchema: z.ZodObject<{
|
|
545
|
+
ordinal: z.ZodNumber;
|
|
546
|
+
hash: z.ZodString;
|
|
547
|
+
}, "strict", z.ZodTypeAny, {
|
|
548
|
+
ordinal: number;
|
|
549
|
+
hash: string;
|
|
550
|
+
}, {
|
|
551
|
+
ordinal: number;
|
|
552
|
+
hash: string;
|
|
553
|
+
}>;
|
|
554
|
+
/**
|
|
555
|
+
* The `ParsedRuleRecord` value as a Zod schema — the parser's OUTPUT expressed at
|
|
556
|
+
* a schema boundary so `AuthoredRuleRecord` can carry it under closed keys like
|
|
557
|
+
* every other field on that envelope (slice 3, § Data model deltas).
|
|
558
|
+
*
|
|
559
|
+
* NOT a second grammar: it is composed from the SAME `RuleRecordSchema` and
|
|
560
|
+
* `RuleTargetTypeSchema` the parser validates with, plus the pair-hash shape, so
|
|
561
|
+
* there is nothing here that could accept a record the parser rejects.
|
|
562
|
+
*
|
|
563
|
+
* IN-MEMORY ONLY, and never hash material: the ledger binds the record by its
|
|
564
|
+
* file `contentHash`, so re-serialising this value into a hash basis would be a
|
|
565
|
+
* second statement of the same bytes (Tenet 20) that could drift from them.
|
|
566
|
+
*/
|
|
567
|
+
export declare const ParsedRuleRecordSchema: z.ZodObject<{
|
|
568
|
+
record: z.ZodObject<{
|
|
569
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
570
|
+
severity: z.ZodEnum<["error", "warning"]>;
|
|
571
|
+
/** REQUIRED, non-empty (R8) — the census found `message` on 4 of 140 hand-authored lessons. */
|
|
572
|
+
message: z.ZodEffects<z.ZodString, string, string>;
|
|
573
|
+
recoveryHint: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
574
|
+
target: z.ZodEffects<z.ZodObject<{
|
|
575
|
+
type: z.ZodEnum<["ast-grep", "regex"]>;
|
|
576
|
+
/** § Design 6 — an identifier TOKEN at parse; it resolves against the Map-backed registry at compile (slice 2), never a spec-frozen enum. */
|
|
577
|
+
language: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
578
|
+
pattern: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
579
|
+
rule: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnknown>, Record<string, unknown>, Record<string, unknown>>>;
|
|
580
|
+
scope: z.ZodObject<{
|
|
581
|
+
fileGlobs: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
582
|
+
/**
|
|
583
|
+
* Applied as `positiveMatch && !excludeMatch` — positive-form entries, never
|
|
584
|
+
* `!`-negation. Min-1 WHEN PRESENT: an empty list is a silent no-op, and
|
|
585
|
+
* "no exclusions" is expressed by OMITTING the key (§ Design 4 — no key in
|
|
586
|
+
* this grammar carries a do-nothing value).
|
|
587
|
+
*/
|
|
588
|
+
excludeGlobs: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
589
|
+
}, "strict", z.ZodTypeAny, {
|
|
590
|
+
fileGlobs: string[];
|
|
591
|
+
excludeGlobs?: string[] | undefined;
|
|
592
|
+
}, {
|
|
593
|
+
fileGlobs: string[];
|
|
594
|
+
excludeGlobs?: string[] | undefined;
|
|
595
|
+
}>;
|
|
596
|
+
}, "strict", z.ZodTypeAny, {
|
|
597
|
+
type: "regex" | "ast-grep";
|
|
598
|
+
scope: {
|
|
599
|
+
fileGlobs: string[];
|
|
600
|
+
excludeGlobs?: string[] | undefined;
|
|
601
|
+
};
|
|
602
|
+
rule?: Record<string, unknown> | undefined;
|
|
603
|
+
pattern?: string | undefined;
|
|
604
|
+
language?: string | undefined;
|
|
605
|
+
}, {
|
|
606
|
+
type: "regex" | "ast-grep";
|
|
607
|
+
scope: {
|
|
608
|
+
fileGlobs: string[];
|
|
609
|
+
excludeGlobs?: string[] | undefined;
|
|
610
|
+
};
|
|
611
|
+
rule?: Record<string, unknown> | undefined;
|
|
612
|
+
pattern?: string | undefined;
|
|
613
|
+
language?: string | undefined;
|
|
614
|
+
}>, {
|
|
615
|
+
type: "regex" | "ast-grep";
|
|
616
|
+
scope: {
|
|
617
|
+
fileGlobs: string[];
|
|
618
|
+
excludeGlobs?: string[] | undefined;
|
|
619
|
+
};
|
|
620
|
+
rule?: Record<string, unknown> | undefined;
|
|
621
|
+
pattern?: string | undefined;
|
|
622
|
+
language?: string | undefined;
|
|
623
|
+
}, {
|
|
624
|
+
type: "regex" | "ast-grep";
|
|
625
|
+
scope: {
|
|
626
|
+
fileGlobs: string[];
|
|
627
|
+
excludeGlobs?: string[] | undefined;
|
|
628
|
+
};
|
|
629
|
+
rule?: Record<string, unknown> | undefined;
|
|
630
|
+
pattern?: string | undefined;
|
|
631
|
+
language?: string | undefined;
|
|
632
|
+
}>;
|
|
633
|
+
examples: z.ZodArray<z.ZodObject<{
|
|
634
|
+
bad: z.ZodEffects<z.ZodString, string, string>;
|
|
635
|
+
good: z.ZodEffects<z.ZodString, string, string>;
|
|
636
|
+
}, "strict", z.ZodTypeAny, {
|
|
637
|
+
bad: string;
|
|
638
|
+
good: string;
|
|
639
|
+
}, {
|
|
640
|
+
bad: string;
|
|
641
|
+
good: string;
|
|
642
|
+
}>, "many">;
|
|
643
|
+
requires: z.ZodOptional<z.ZodObject<{
|
|
644
|
+
/** A safe-regex2-gated regex evaluated TEXTUALLY at the declared scope (gate is slice 2), independent of `target.type`. */
|
|
645
|
+
pattern: z.ZodEffects<z.ZodString, string, string>;
|
|
646
|
+
scope: z.ZodEnum<["line", "file"]>;
|
|
647
|
+
}, "strict", z.ZodTypeAny, {
|
|
648
|
+
pattern: string;
|
|
649
|
+
scope: "line" | "file";
|
|
650
|
+
}, {
|
|
651
|
+
pattern: string;
|
|
652
|
+
scope: "line" | "file";
|
|
653
|
+
}>>;
|
|
654
|
+
curation: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
655
|
+
/** § Design 1 — the record→lesson link. Required whenever the block is present. */
|
|
656
|
+
sourceLesson: z.ZodEffects<z.ZodString, string, string>;
|
|
657
|
+
curatedBy: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
658
|
+
curatedAt: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
659
|
+
baseline5Phase: z.ZodOptional<z.ZodNumber>;
|
|
660
|
+
}, "strict", z.ZodTypeAny, {
|
|
661
|
+
sourceLesson: string;
|
|
662
|
+
curatedBy?: string | undefined;
|
|
663
|
+
curatedAt?: string | undefined;
|
|
664
|
+
baseline5Phase?: number | undefined;
|
|
665
|
+
}, {
|
|
666
|
+
sourceLesson: string;
|
|
667
|
+
curatedBy?: string | undefined;
|
|
668
|
+
curatedAt?: string | undefined;
|
|
669
|
+
baseline5Phase?: number | undefined;
|
|
670
|
+
}>, {
|
|
671
|
+
sourceLesson: string;
|
|
672
|
+
curatedBy?: string | undefined;
|
|
673
|
+
curatedAt?: string | undefined;
|
|
674
|
+
baseline5Phase?: number | undefined;
|
|
675
|
+
}, {
|
|
676
|
+
sourceLesson: string;
|
|
677
|
+
curatedBy?: string | undefined;
|
|
678
|
+
curatedAt?: string | undefined;
|
|
679
|
+
baseline5Phase?: number | undefined;
|
|
680
|
+
}>>;
|
|
681
|
+
verification_shadow: z.ZodOptional<z.ZodObject<{
|
|
682
|
+
type: z.ZodEffects<z.ZodString, string, string>;
|
|
683
|
+
source: z.ZodEffects<z.ZodString, string, string>;
|
|
684
|
+
}, "strict", z.ZodTypeAny, {
|
|
685
|
+
type: string;
|
|
686
|
+
source: string;
|
|
687
|
+
}, {
|
|
688
|
+
type: string;
|
|
689
|
+
source: string;
|
|
690
|
+
}>>;
|
|
691
|
+
}, "strict", z.ZodTypeAny, {
|
|
692
|
+
message: string;
|
|
693
|
+
severity: "error" | "warning";
|
|
694
|
+
examples: {
|
|
695
|
+
bad: string;
|
|
696
|
+
good: string;
|
|
697
|
+
}[];
|
|
698
|
+
schemaVersion: 1;
|
|
699
|
+
target: {
|
|
700
|
+
type: "regex" | "ast-grep";
|
|
701
|
+
scope: {
|
|
702
|
+
fileGlobs: string[];
|
|
703
|
+
excludeGlobs?: string[] | undefined;
|
|
704
|
+
};
|
|
705
|
+
rule?: Record<string, unknown> | undefined;
|
|
706
|
+
pattern?: string | undefined;
|
|
707
|
+
language?: string | undefined;
|
|
708
|
+
};
|
|
709
|
+
requires?: {
|
|
710
|
+
pattern: string;
|
|
711
|
+
scope: "line" | "file";
|
|
712
|
+
} | undefined;
|
|
713
|
+
recoveryHint?: string | undefined;
|
|
714
|
+
curation?: {
|
|
715
|
+
sourceLesson: string;
|
|
716
|
+
curatedBy?: string | undefined;
|
|
717
|
+
curatedAt?: string | undefined;
|
|
718
|
+
baseline5Phase?: number | undefined;
|
|
719
|
+
} | undefined;
|
|
720
|
+
verification_shadow?: {
|
|
721
|
+
type: string;
|
|
722
|
+
source: string;
|
|
723
|
+
} | undefined;
|
|
724
|
+
}, {
|
|
725
|
+
message: string;
|
|
726
|
+
severity: "error" | "warning";
|
|
727
|
+
examples: {
|
|
728
|
+
bad: string;
|
|
729
|
+
good: string;
|
|
730
|
+
}[];
|
|
731
|
+
schemaVersion: 1;
|
|
732
|
+
target: {
|
|
733
|
+
type: "regex" | "ast-grep";
|
|
734
|
+
scope: {
|
|
735
|
+
fileGlobs: string[];
|
|
736
|
+
excludeGlobs?: string[] | undefined;
|
|
737
|
+
};
|
|
738
|
+
rule?: Record<string, unknown> | undefined;
|
|
739
|
+
pattern?: string | undefined;
|
|
740
|
+
language?: string | undefined;
|
|
741
|
+
};
|
|
742
|
+
requires?: {
|
|
743
|
+
pattern: string;
|
|
744
|
+
scope: "line" | "file";
|
|
745
|
+
} | undefined;
|
|
746
|
+
recoveryHint?: string | undefined;
|
|
747
|
+
curation?: {
|
|
748
|
+
sourceLesson: string;
|
|
749
|
+
curatedBy?: string | undefined;
|
|
750
|
+
curatedAt?: string | undefined;
|
|
751
|
+
baseline5Phase?: number | undefined;
|
|
752
|
+
} | undefined;
|
|
753
|
+
verification_shadow?: {
|
|
754
|
+
type: string;
|
|
755
|
+
source: string;
|
|
756
|
+
} | undefined;
|
|
757
|
+
}>;
|
|
758
|
+
derivedEngine: z.ZodEnum<["ast-grep", "regex"]>;
|
|
759
|
+
examplePairHashes: z.ZodArray<z.ZodObject<{
|
|
760
|
+
ordinal: z.ZodNumber;
|
|
761
|
+
hash: z.ZodString;
|
|
762
|
+
}, "strict", z.ZodTypeAny, {
|
|
763
|
+
ordinal: number;
|
|
764
|
+
hash: string;
|
|
765
|
+
}, {
|
|
766
|
+
ordinal: number;
|
|
767
|
+
hash: string;
|
|
768
|
+
}>, "many">;
|
|
769
|
+
}, "strict", z.ZodTypeAny, {
|
|
770
|
+
record: {
|
|
771
|
+
message: string;
|
|
772
|
+
severity: "error" | "warning";
|
|
773
|
+
examples: {
|
|
774
|
+
bad: string;
|
|
775
|
+
good: string;
|
|
776
|
+
}[];
|
|
777
|
+
schemaVersion: 1;
|
|
778
|
+
target: {
|
|
779
|
+
type: "regex" | "ast-grep";
|
|
780
|
+
scope: {
|
|
781
|
+
fileGlobs: string[];
|
|
782
|
+
excludeGlobs?: string[] | undefined;
|
|
783
|
+
};
|
|
784
|
+
rule?: Record<string, unknown> | undefined;
|
|
785
|
+
pattern?: string | undefined;
|
|
786
|
+
language?: string | undefined;
|
|
787
|
+
};
|
|
788
|
+
requires?: {
|
|
789
|
+
pattern: string;
|
|
790
|
+
scope: "line" | "file";
|
|
791
|
+
} | undefined;
|
|
792
|
+
recoveryHint?: string | undefined;
|
|
793
|
+
curation?: {
|
|
794
|
+
sourceLesson: string;
|
|
795
|
+
curatedBy?: string | undefined;
|
|
796
|
+
curatedAt?: string | undefined;
|
|
797
|
+
baseline5Phase?: number | undefined;
|
|
798
|
+
} | undefined;
|
|
799
|
+
verification_shadow?: {
|
|
800
|
+
type: string;
|
|
801
|
+
source: string;
|
|
802
|
+
} | undefined;
|
|
803
|
+
};
|
|
804
|
+
derivedEngine: "regex" | "ast-grep";
|
|
805
|
+
examplePairHashes: {
|
|
806
|
+
ordinal: number;
|
|
807
|
+
hash: string;
|
|
808
|
+
}[];
|
|
809
|
+
}, {
|
|
810
|
+
record: {
|
|
811
|
+
message: string;
|
|
812
|
+
severity: "error" | "warning";
|
|
813
|
+
examples: {
|
|
814
|
+
bad: string;
|
|
815
|
+
good: string;
|
|
816
|
+
}[];
|
|
817
|
+
schemaVersion: 1;
|
|
818
|
+
target: {
|
|
819
|
+
type: "regex" | "ast-grep";
|
|
820
|
+
scope: {
|
|
821
|
+
fileGlobs: string[];
|
|
822
|
+
excludeGlobs?: string[] | undefined;
|
|
823
|
+
};
|
|
824
|
+
rule?: Record<string, unknown> | undefined;
|
|
825
|
+
pattern?: string | undefined;
|
|
826
|
+
language?: string | undefined;
|
|
827
|
+
};
|
|
828
|
+
requires?: {
|
|
829
|
+
pattern: string;
|
|
830
|
+
scope: "line" | "file";
|
|
831
|
+
} | undefined;
|
|
832
|
+
recoveryHint?: string | undefined;
|
|
833
|
+
curation?: {
|
|
834
|
+
sourceLesson: string;
|
|
835
|
+
curatedBy?: string | undefined;
|
|
836
|
+
curatedAt?: string | undefined;
|
|
837
|
+
baseline5Phase?: number | undefined;
|
|
838
|
+
} | undefined;
|
|
839
|
+
verification_shadow?: {
|
|
840
|
+
type: string;
|
|
841
|
+
source: string;
|
|
842
|
+
} | undefined;
|
|
843
|
+
};
|
|
844
|
+
derivedEngine: "regex" | "ast-grep";
|
|
845
|
+
examplePairHashes: {
|
|
846
|
+
ordinal: number;
|
|
847
|
+
hash: string;
|
|
848
|
+
}[];
|
|
849
|
+
}>;
|
|
850
|
+
/**
|
|
851
|
+
* Parse one `.totem/rules/<slug>.rule.yaml` document into a validated
|
|
852
|
+
* `ParsedRuleRecord`. Pure and total in the § Design 12 sense: it either returns
|
|
853
|
+
* a fully-validated value or THROWS a `RuleRecordParseError` naming the file and
|
|
854
|
+
* the offending record key path. There is no partial, degraded, or
|
|
855
|
+
* best-effort result — V1 declares no degraded mode (§ Design 2).
|
|
856
|
+
*
|
|
857
|
+
* Gate order is load-bearing: the § Design 2 no-silent-skip probes and the
|
|
858
|
+
* § Design 4 inexpressible-key scan run BEFORE full schema validation, so an
|
|
859
|
+
* unknown version / type / reserved construct and a producer-owned key each
|
|
860
|
+
* surface their OWN diagnostic instead of a misleading shape failure against a
|
|
861
|
+
* V1-shaped schema.
|
|
862
|
+
*/
|
|
863
|
+
export declare function parseRuleRecord(content: string, filePath: string): ParsedRuleRecord;
|
|
864
|
+
//# sourceMappingURL=rule-record.d.ts.map
|