@mmnto/totem 1.78.0 → 1.79.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/artifacts/panel.d.ts +48 -48
  2. package/dist/artifacts/schema.d.ts +40 -40
  3. package/dist/compiler-schema.d.ts +1048 -7
  4. package/dist/compiler-schema.d.ts.map +1 -1
  5. package/dist/compiler-schema.js +129 -1
  6. package/dist/compiler-schema.js.map +1 -1
  7. package/dist/compiler-schema.test.js +92 -2
  8. package/dist/compiler-schema.test.js.map +1 -1
  9. package/dist/compiler.d.ts +2 -2
  10. package/dist/compiler.d.ts.map +1 -1
  11. package/dist/compiler.js +1 -1
  12. package/dist/compiler.js.map +1 -1
  13. package/dist/index.d.ts +8 -4
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +3 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/spine/authored-rule.d.ts +360 -0
  18. package/dist/spine/authored-rule.d.ts.map +1 -0
  19. package/dist/spine/authored-rule.js +199 -0
  20. package/dist/spine/authored-rule.js.map +1 -0
  21. package/dist/spine/authored-rule.test.d.ts +2 -0
  22. package/dist/spine/authored-rule.test.d.ts.map +1 -0
  23. package/dist/spine/authored-rule.test.js +220 -0
  24. package/dist/spine/authored-rule.test.js.map +1 -0
  25. package/dist/spine/candidate-rule.d.ts +32 -0
  26. package/dist/spine/candidate-rule.d.ts.map +1 -1
  27. package/dist/spine/candidate-rule.js +2 -2
  28. package/dist/spine/candidate-rule.js.map +1 -1
  29. package/dist/spine/classify.d.ts +5 -5
  30. package/dist/spine/compile.d.ts +16 -4
  31. package/dist/spine/compile.d.ts.map +1 -1
  32. package/dist/spine/compile.js +23 -0
  33. package/dist/spine/compile.js.map +1 -1
  34. package/dist/spine/compile.test.js +69 -0
  35. package/dist/spine/compile.test.js.map +1 -1
  36. package/dist/spine/corpus-dispositions.d.ts +18 -18
  37. package/dist/spine/extract.d.ts +2 -2
  38. package/dist/spine/extract.d.ts.map +1 -1
  39. package/dist/spine/extract.js +5 -4
  40. package/dist/spine/extract.js.map +1 -1
  41. package/dist/spine/ledgers.d.ts +46 -21
  42. package/dist/spine/ledgers.d.ts.map +1 -1
  43. package/dist/spine/ledgers.js +16 -8
  44. package/dist/spine/ledgers.js.map +1 -1
  45. package/dist/spine/rule-policy.d.ts +27 -0
  46. package/dist/spine/rule-policy.d.ts.map +1 -0
  47. package/dist/spine/rule-policy.js +43 -0
  48. package/dist/spine/rule-policy.js.map +1 -0
  49. package/dist/spine/rule-policy.test.d.ts +2 -0
  50. package/dist/spine/rule-policy.test.d.ts.map +1 -0
  51. package/dist/spine/rule-policy.test.js +31 -0
  52. package/dist/spine/rule-policy.test.js.map +1 -0
  53. package/dist/spine/windtunnel-lock.d.ts +8 -8
  54. package/package.json +1 -1
@@ -0,0 +1,199 @@
1
+ // ─── ADR-112 Gate-1 authored producer: the AuthoredRuleRecord envelope ───────
2
+ //
3
+ // The human-authored counterpart to ADR-111's mined `CandidateRuleRecord`. An
4
+ // authored rule is anchored to a real historical DEFECT (its `provenance` is the
5
+ // AUTHORED variant of the ADR-112 union — train-side preimage fixtures, §3/§4),
6
+ // carries an INDEPENDENTLY-judged structural-eligibility result (NOT author-
7
+ // asserted — §3), an accelerant-lineage marker (§7), and is minted
8
+ // `unverified`/Yellow (ADR-089) with zero enforcement blast radius.
9
+ //
10
+ // SLICE A scope: the schema spine + the deterministic eligibility check + the
11
+ // stable rule-id mint. The `totem rule author` CLI + the `.totem/spine/
12
+ // authored-rules.yaml` reader are slice B; the compile-feed integration into
13
+ // `runCompileStage` is gated on the `compileCandidate` param-widening flagged in
14
+ // the slice-A report (a controller decision). The whitelist REGISTRY of
15
+ // decidable classes lives in the CLI (slice B, mirroring `valueEqualityFieldsFor`);
16
+ // this core check takes it injected (DI), staying network-free + LLM-free.
17
+ import { createHash } from 'node:crypto';
18
+ import { z } from 'zod';
19
+ import { AuthoredProvenanceRecordSchema } from '../compiler-schema.js';
20
+ /** The matcher engines an authored rule may declare (mirrors `CompiledRule.engine`). */
21
+ export const DeclaredEngineSchema = z.enum(['regex', 'ast', 'ast-grep']);
22
+ // The §3 eligibility-basis forms: `whitelist:<class>` (the cert-#1 deterministic basis,
23
+ // a non-empty class after the colon), or the deferred `capability-check` /
24
+ // `draft-classifier+stage4`. Pins `basis` to the contract so a free-form/typo'd value
25
+ // can't validate (strategy item 2, #2259).
26
+ const ELIGIBILITY_BASIS_RE = /^(?:whitelist:.+|capability-check|draft-classifier\+stage4)$/;
27
+ /**
28
+ * ADR-112 §3 — the result of the INDEPENDENT structural-eligibility check.
29
+ * Produced by `evaluateStructuralEligibility` (NOT by the author): only
30
+ * `decidable: true` reaches the compiler, mapping to the compiler's
31
+ * `classifierDisposition: 'structural'`. `judgedBy` records who/what judged it
32
+ * (ledger-recorded, never the author), so a human cannot smuggle a behavioral
33
+ * policy past ADR-091's gate by hand-asserting "structural" (FM(d)).
34
+ */
35
+ export const StructEligResultSchema = z.object({
36
+ decidable: z.boolean(),
37
+ /**
38
+ * `whitelist:<class>` for the cert-#1 static-whitelist basis; the
39
+ * `capability-check` / `draft-classifier+stage4` bases are contract-legal but
40
+ * deferred (slice-A uses the deterministic whitelist only). On a `decidable:
41
+ * false` verdict the basis still names the attempted whitelist class — the
42
+ * diagnostic is "no/ambiguous whitelist match", carried in `judgedBy`'s log.
43
+ * Constrained to the §3 forms (strategy item 2, #2259) so a typo'd/free-form
44
+ * basis can't validate — non-mutating (no `.trim()`), matching the hash-stability
45
+ * discipline on the other reference fields.
46
+ */
47
+ basis: z.string().refine((s) => ELIGIBILITY_BASIS_RE.test(s), {
48
+ message: 'basis must be a §3 eligibility basis: whitelist:<class> | capability-check | draft-classifier+stage4',
49
+ }),
50
+ judgedBy: z.string().refine((s) => s.trim().length > 0, {
51
+ message: 'judgedBy must name the check/agent that judged eligibility (never the author)',
52
+ }),
53
+ });
54
+ /** ADR-112 §3/§7 — accelerant-lineage marker. A mined hint that informed a human is recorded, never erased. */
55
+ export const AuthoredOriginSchema = z.union([
56
+ z.object({ kind: z.literal('from-scratch') }),
57
+ z.object({
58
+ kind: z.literal('mined-accelerant'),
59
+ sourceRunId: z.string().refine((s) => s.trim().length > 0, { message: 'sourceRunId required' }),
60
+ suggestionHash: z.string().refine((s) => s.trim().length > 0, {
61
+ message: 'suggestionHash required',
62
+ }),
63
+ }),
64
+ ]);
65
+ // The persisted minted-rule-id shape (ADR-112 §8): a 16-char lowercase-hex base from
66
+ // `mintAuthoredRuleId`, with an optional collision suffix. The suffix is EXACTLY what the
67
+ // mint emits — `-<n>` for n≥1, never `-0` and never zero-padded — so schema-valid ≡
68
+ // mint-producible (#2259 CR: a looser `-\d+` admitted ids like `…-0`/`…-01` the mint can't
69
+ // make). Pinned as a shared constant binding the SCHEMA boundary to the mint's codomain.
70
+ const AUTHORED_RULE_ID_HEX_LEN = 16;
71
+ const AUTHORED_RULE_ID_RE = new RegExp(`^[0-9a-f]{${AUTHORED_RULE_ID_HEX_LEN}}(?:-[1-9]\\d*)?$`);
72
+ /**
73
+ * ADR-112 §3 — the authored producer's sole output envelope. Parallel to
74
+ * ADR-111's `CandidateRuleRecord` but carrying the AUTHORED provenance variant,
75
+ * the INDEPENDENTLY-judged eligibility result, and the accelerant lineage.
76
+ * Minted `unverified: true` (ADR-089) — zero enforcement blast radius.
77
+ */
78
+ export const AuthoredRuleRecordSchema = z.object({
79
+ /**
80
+ * ADR-112 §3/§8 — the stable, minted rule identity (`mintAuthoredRuleId`),
81
+ * assigned ONCE at authoring time and PERSISTED on the record; NEVER re-derived
82
+ * from content at read time. `firingLabelId` + the §5.3
83
+ * `controls.positive[].targetRuleId` ground-truth labels embed it, so a
84
+ * content-re-derived id would orphan them (§8). Slice A reserves the field (this
85
+ * IS the schema spine); the authoring flow (slice B) mints it, and threading it
86
+ * into the compiled artifact's identity (`firingLabelId ← ruleId`, replacing the
87
+ * `dslSource`-derived `lessonHash`) is slice C/D. The RESOLVED id (with any `-N`
88
+ * collision suffix) is what is stored.
89
+ */
90
+ ruleId: z.string().regex(AUTHORED_RULE_ID_RE, {
91
+ message: 'ruleId must be a minted authored rule id — 16 hex chars + optional -<n> suffix (ADR-112 §3/§8)',
92
+ }),
93
+ provenance: AuthoredProvenanceRecordSchema,
94
+ /** INDEPENDENTLY established (§3) — the author never sets this; the check does. */
95
+ structuralEligibility: StructEligResultSchema,
96
+ origin: AuthoredOriginSchema,
97
+ declaredEngine: DeclaredEngineSchema,
98
+ /** Reference to the §8 authoring-ledger entry (author/date/engine/splitRef/attestations). */
99
+ authoringLedgerRef: z.string().refine((s) => s.trim().length > 0, {
100
+ message: 'authoringLedgerRef must be a non-empty ledger reference',
101
+ }),
102
+ /** The human-written matcher (same DSL the compiler accepts from the miner). */
103
+ dslSource: z.string().refine((s) => s.trim().length > 0, {
104
+ message: 'dslSource must be non-empty',
105
+ }),
106
+ /** Zero-trust mint (ADR-089 / ADR-112 §1) — always literally `true`. */
107
+ unverified: z.literal(true),
108
+ });
109
+ /**
110
+ * ADR-112 §3 — the INDEPENDENT structural-eligibility check. A CLOSED registry
111
+ * predicate, NOT prose: `decidable` is true iff EXACTLY ONE whitelist entry
112
+ * matches `(declaredEngine, structuralClass)`. Unknown class, unsupported
113
+ * engine, or multiple matches → `decidable: false` (NO default-to-structural).
114
+ * The author supplies `declaredEngine` + `structuralClass`; this check OWNS the
115
+ * verdict — any author-supplied disposition is irrelevant here (FM(d)).
116
+ * Deterministic + pure (no IO, no LLM) — the same input always yields the same
117
+ * verdict (Tenet-15).
118
+ */
119
+ export function evaluateStructuralEligibility(input, whitelist, judgedBy) {
120
+ const matches = whitelist.filter((e) => e.engine === input.declaredEngine && e.structuralClass === input.structuralClass);
121
+ return {
122
+ decidable: matches.length === 1,
123
+ basis: `whitelist:${input.structuralClass}`,
124
+ judgedBy,
125
+ };
126
+ }
127
+ // ── Stable rule-id mint (ADR-112 §8) ──────────────────────────────────────────
128
+ /**
129
+ * ADR-112 §8 — mint a stable, deterministic authored rule-id. The seed is
130
+ * `sha256(JSON.stringify([author, targetDefect]))[:16]` (an INJECTIVE encoding —
131
+ * see the inline note) — `dslSource` is DELIBERATELY EXCLUDED so an author can
132
+ * tighten/refactor the matcher without orphaning the rule's ledger history. On collision with an already-resolved id (two rules sharing the same
133
+ * `(author, targetDefect)`), a stable `-N` counter is appended. The RESOLVED id
134
+ * is what callers persist — never recompute the raw seed at read time, or a
135
+ * later sibling could shift the suffix (the gemini/agy break). The
136
+ * `never-remine` marker is keyed to `targetDefect`, handled by the accelerant
137
+ * miner, not here.
138
+ */
139
+ export function mintAuthoredRuleId(author, targetDefect, existingIds) {
140
+ // Unambiguous seed encoding (GCA-high + CR-major, #2259): a bare `author·targetDefect`
141
+ // ALIASES distinct tuples — ('a·b','c') and ('a','b·c') collapse onto one seed. A JSON
142
+ // array of the two inputs is injective: distinct (author, targetDefect) pairs can never
143
+ // serialize to the same string, so a persisted id can't collide by encoding.
144
+ const seed = createHash('sha256')
145
+ .update(JSON.stringify([author, targetDefect]))
146
+ .digest('hex')
147
+ .slice(0, AUTHORED_RULE_ID_HEX_LEN);
148
+ if (!existingIds.has(seed))
149
+ return seed;
150
+ for (let n = 1;; n += 1) {
151
+ const candidate = `${seed}-${n}`;
152
+ if (!existingIds.has(candidate))
153
+ return candidate;
154
+ }
155
+ }
156
+ /**
157
+ * ADR-112 §2/§8 — turn structurally-DECIDABLE authored rules into the input
158
+ * `runCompileStage` consumes, reusing the ONE G-series compiler (never a second).
159
+ * The disposition is set HERE to `'structural'` from the INDEPENDENT eligibility
160
+ * verdict (§3) — the author never sets it. A NON-decidable record is a contract
161
+ * violation → FAIL LOUD (the FM(d) backstop in code), never a silent skip.
162
+ * `classifierLedgerRef = authored:<authoringLedgerRef>` is unique per rule (the
163
+ * authoring ledger is 1:1 with the rule); a duplicate fails loud so the downstream
164
+ * 1:1 classifier-ledger join can't silently collapse.
165
+ */
166
+ export function toCompileFeed(records) {
167
+ const candidates = [];
168
+ const entries = [];
169
+ const seen = new Set();
170
+ for (const record of records) {
171
+ if (!record.structuralEligibility.decidable) {
172
+ throw new Error(`[Totem Error] toCompileFeed: authored rule '${record.authoringLedgerRef}' is not structurally decidable — a non-decidable rule must never reach the compiler (ADR-112 §3 / FM(d))`);
173
+ }
174
+ const classifierLedgerRef = `authored:${record.authoringLedgerRef}`;
175
+ if (seen.has(classifierLedgerRef)) {
176
+ throw new Error(`[Totem Error] toCompileFeed: duplicate authoringLedgerRef '${record.authoringLedgerRef}' — each authored rule needs a unique ledger ref for the 1:1 compile join`);
177
+ }
178
+ seen.add(classifierLedgerRef);
179
+ candidates.push({
180
+ provenance: record.provenance,
181
+ classifierDisposition: 'structural',
182
+ classifierLedgerRef,
183
+ dslSource: record.dslSource,
184
+ // §3 (#7): carry the whitelist-judged engine so the compiler can assert it
185
+ // compiled under THAT engine — a regex-whitelisted rule whose dslSource parses
186
+ // as ast-grep must fail loud, not silently re-route to a different engine.
187
+ declaredEngine: record.declaredEngine,
188
+ unverified: true,
189
+ });
190
+ entries.push({
191
+ candidateRef: classifierLedgerRef,
192
+ disposition: 'structural',
193
+ stage4Confirmed: false,
194
+ dispositionSource: 'authored-whitelist',
195
+ });
196
+ }
197
+ return { candidates, classifierLedger: { entries } };
198
+ }
199
+ //# sourceMappingURL=authored-rule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authored-rule.js","sourceRoot":"","sources":["../../src/spine/authored-rule.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,EAAE;AACF,8EAA8E;AAC9E,iFAAiF;AACjF,gFAAgF;AAChF,6EAA6E;AAC7E,mEAAmE;AACnE,oEAAoE;AACpE,EAAE;AACF,8EAA8E;AAC9E,wEAAwE;AACxE,6EAA6E;AAC7E,iFAAiF;AACjF,wEAAwE;AACxE,oFAAoF;AACpF,2EAA2E;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,O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AAE,CAAC;IAChD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,SAAS,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CACb,+CAA+C,MAAM,CAAC,kBAAkB,2GAA2G,CACpL,CAAC;QACJ,CAAC;QACD,MAAM,mBAAmB,GAAG,YAAY,MAAM,CAAC,kBAAkB,EAAE,CAAC;QACpE,IAAI,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CACb,8DAA8D,MAAM,CAAC,kBAAkB,2EAA2E,CACnK,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAC9B,UAAU,CAAC,IAAI,CAAC;YACd,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,qBAAqB,EAAE,YAAY;YACnC,mBAAmB;YACnB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,2EAA2E;YAC3E,+EAA+E;YAC/E,2EAA2E;YAC3E,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC;YACX,YAAY,EAAE,mBAAmB;YACjC,WAAW,EAAE,YAAY;YACzB,eAAe,EAAE,KAAK;YACtB,iBAAiB,EAAE,oBAAoB;SACxC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC;AACvD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=authored-rule.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authored-rule.test.d.ts","sourceRoot":"","sources":["../../src/spine/authored-rule.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,220 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { AuthoredRuleRecordSchema, evaluateStructuralEligibility, mintAuthoredRuleId, toCompileFeed, } from './authored-rule.js';
3
+ const WHITELIST = [
4
+ { engine: 'regex', structuralClass: 'float-finite-assert' },
5
+ { engine: 'ast-grep', structuralClass: 'divisor-le-zero' },
6
+ ];
7
+ describe('evaluateStructuralEligibility (ADR-112 §3 — closed predicate)', () => {
8
+ it('decidable:true on EXACTLY ONE (engine,class) match', () => {
9
+ const r = evaluateStructuralEligibility({ declaredEngine: 'regex', structuralClass: 'float-finite-assert' }, WHITELIST, 'static-whitelist@cert-1');
10
+ expect(r.decidable).toBe(true);
11
+ expect(r.basis).toBe('whitelist:float-finite-assert');
12
+ expect(r.judgedBy).toBe('static-whitelist@cert-1');
13
+ });
14
+ it('decidable:false on an UNKNOWN class (no default-to-structural)', () => {
15
+ const r = evaluateStructuralEligibility({ declaredEngine: 'regex', structuralClass: 'unbounded-recursion-behavioral' }, WHITELIST, 'static-whitelist@cert-1');
16
+ expect(r.decidable).toBe(false);
17
+ });
18
+ it('decidable:false when the engine cannot represent the class (no matching pair)', () => {
19
+ // class is whitelisted for ast-grep, not regex → no (regex, divisor-le-zero) entry.
20
+ const r = evaluateStructuralEligibility({ declaredEngine: 'regex', structuralClass: 'divisor-le-zero' }, WHITELIST, 'static-whitelist@cert-1');
21
+ expect(r.decidable).toBe(false);
22
+ });
23
+ it('decidable:false on MULTIPLE matches (ambiguous)', () => {
24
+ const dupes = [
25
+ { engine: 'regex', structuralClass: 'float-finite-assert' },
26
+ { engine: 'regex', structuralClass: 'float-finite-assert' },
27
+ ];
28
+ const r = evaluateStructuralEligibility({ declaredEngine: 'regex', structuralClass: 'float-finite-assert' }, dupes, 'static-whitelist@cert-1');
29
+ expect(r.decidable).toBe(false);
30
+ });
31
+ it('is deterministic — 100 sequential iterations yield an identical verdict (LLM-free)', () => {
32
+ const first = JSON.stringify(evaluateStructuralEligibility({ declaredEngine: 'ast-grep', structuralClass: 'divisor-le-zero' }, WHITELIST, 'static-whitelist@cert-1'));
33
+ for (let i = 0; i < 100; i += 1) {
34
+ const again = JSON.stringify(evaluateStructuralEligibility({ declaredEngine: 'ast-grep', structuralClass: 'divisor-le-zero' }, WHITELIST, 'static-whitelist@cert-1'));
35
+ expect(again).toBe(first);
36
+ }
37
+ });
38
+ });
39
+ describe('AuthoredRuleRecord schema (ADR-112 §3)', () => {
40
+ const base = {
41
+ ruleId: '0f1e2d3c4b5a6978',
42
+ provenance: {
43
+ kind: 'authored',
44
+ author: 'totem-claude',
45
+ authoredAt: '2026-06-27',
46
+ targetDefect: 'float equality compared with == instead of a finite-tolerance check',
47
+ positiveFixtures: [
48
+ {
49
+ pr: 100,
50
+ mergeCommitSha: 'b'.repeat(40),
51
+ preimageCommitSha: 'c'.repeat(40),
52
+ filePath: 'src/physics/step.ts',
53
+ matchedSpan: 'L10-L12',
54
+ contentHash: 'deadbeefcafe',
55
+ },
56
+ ],
57
+ },
58
+ structuralEligibility: {
59
+ decidable: true,
60
+ basis: 'whitelist:float-finite-assert',
61
+ judgedBy: 's',
62
+ },
63
+ origin: { kind: 'from-scratch' },
64
+ declaredEngine: 'regex',
65
+ authoringLedgerRef: 'alr-0001',
66
+ dslSource: '**Pattern:** `== *\\d+\\.\\d+f?`',
67
+ unverified: true,
68
+ };
69
+ it('accepts a complete authored record', () => {
70
+ expect(() => AuthoredRuleRecordSchema.parse(base)).not.toThrow();
71
+ });
72
+ it('has NO author-settable disposition/routing field (the check owns eligibility — FM(d))', () => {
73
+ const parsed = AuthoredRuleRecordSchema.parse(base);
74
+ expect('classifierDisposition' in parsed).toBe(false);
75
+ expect('routing' in parsed).toBe(false);
76
+ });
77
+ it('requires the independent structuralEligibility result', () => {
78
+ const { structuralEligibility: _omit, ...without } = base;
79
+ expect(() => AuthoredRuleRecordSchema.parse(without)).toThrow();
80
+ });
81
+ it('reserves the minted ruleId on the record (ADR-112 §3/§8 — persisted, never re-derived)', () => {
82
+ const { ruleId: _omit, ...without } = base;
83
+ expect(() => AuthoredRuleRecordSchema.parse(without)).toThrow();
84
+ expect(() => AuthoredRuleRecordSchema.parse({ ...base, ruleId: ' ' })).toThrow();
85
+ expect(AuthoredRuleRecordSchema.parse(base).ruleId).toBe('0f1e2d3c4b5a6978');
86
+ });
87
+ it('enforces the minted ruleId SHAPE at the boundary — 16 hex + optional -<n> (#2259 CR-major)', () => {
88
+ for (const bad of [
89
+ 'NOTHEXNOTHEXNOTH',
90
+ '0f1e2d3c',
91
+ '0f1e2d3c4b5a6978abcd',
92
+ '0F1E2D3C4B5A6978',
93
+ 'rid-alr-1',
94
+ // non-canonical suffixes the mint never emits (n≥1, no zero-pad) — #2259 CR
95
+ '0f1e2d3c4b5a6978-0',
96
+ '0f1e2d3c4b5a6978-01',
97
+ ]) {
98
+ expect(() => AuthoredRuleRecordSchema.parse({ ...base, ruleId: bad })).toThrow();
99
+ }
100
+ for (const ok of ['0f1e2d3c4b5a6978', '0f1e2d3c4b5a6978-1', 'abcdef0123456789-42']) {
101
+ expect(() => AuthoredRuleRecordSchema.parse({ ...base, ruleId: ok })).not.toThrow();
102
+ }
103
+ // the mint always produces a schema-valid id (the shared shape constant binds both).
104
+ expect(() => AuthoredRuleRecordSchema.parse({
105
+ ...base,
106
+ ruleId: mintAuthoredRuleId('totem-claude', 'float-finite-assert', new Set()),
107
+ })).not.toThrow();
108
+ });
109
+ it('forces unverified:true (zero blast radius — ADR-089/§1)', () => {
110
+ expect(() => AuthoredRuleRecordSchema.parse({ ...base, unverified: false })).toThrow();
111
+ });
112
+ it('constrains structuralEligibility.basis to the §3 forms — not free-form (strategy item 2, #2259)', () => {
113
+ const withBasis = (basis) => ({
114
+ ...base,
115
+ structuralEligibility: { ...base.structuralEligibility, basis },
116
+ });
117
+ for (const bad of [
118
+ '',
119
+ 'freeform',
120
+ 'whitelist:',
121
+ 'whitelisted',
122
+ 'stage4',
123
+ ' capability-check',
124
+ ]) {
125
+ expect(() => AuthoredRuleRecordSchema.parse(withBasis(bad))).toThrow();
126
+ }
127
+ for (const ok of [
128
+ 'whitelist:float-finite-assert',
129
+ 'capability-check',
130
+ 'draft-classifier+stage4',
131
+ ]) {
132
+ expect(() => AuthoredRuleRecordSchema.parse(withBasis(ok))).not.toThrow();
133
+ }
134
+ });
135
+ });
136
+ describe('mintAuthoredRuleId (ADR-112 §8)', () => {
137
+ it('is deterministic for the same (author,targetDefect) and excludes dslSource', () => {
138
+ const a = mintAuthoredRuleId('totem-claude', 'float-finite-assert', new Set());
139
+ const b = mintAuthoredRuleId('totem-claude', 'float-finite-assert', new Set());
140
+ expect(a).toBe(b);
141
+ expect(a).toMatch(/^[0-9a-f]{16}$/);
142
+ });
143
+ it('encodes (author,targetDefect) injectively — delimiter-aliased tuples do NOT collide (#2259)', () => {
144
+ // A bare `author·targetDefect` seed would alias these two distinct tuples onto one id.
145
+ const a = mintAuthoredRuleId('a·b', 'c', new Set());
146
+ const b = mintAuthoredRuleId('a', 'b·c', new Set());
147
+ expect(a).not.toBe(b);
148
+ });
149
+ it('appends a stable counter on collision and yields distinct persisted ids', () => {
150
+ const first = mintAuthoredRuleId('totem-claude', 'divisor-le-zero', new Set());
151
+ const second = mintAuthoredRuleId('totem-claude', 'divisor-le-zero', new Set([first]));
152
+ const third = mintAuthoredRuleId('totem-claude', 'divisor-le-zero', new Set([first, second]));
153
+ expect(second).toBe(`${first}-1`);
154
+ expect(third).toBe(`${first}-2`);
155
+ expect(new Set([first, second, third]).size).toBe(3);
156
+ });
157
+ it('is stable across re-runs given the already-resolved id set', () => {
158
+ const resolved = mintAuthoredRuleId('a', 'd', new Set());
159
+ expect(mintAuthoredRuleId('a', 'd', new Set([resolved]))).toBe(`${resolved}-1`);
160
+ expect(mintAuthoredRuleId('a', 'd', new Set([resolved]))).toBe(`${resolved}-1`);
161
+ });
162
+ });
163
+ describe('toCompileFeed (ADR-112 §2/§8 — authored → compile-stage input)', () => {
164
+ const decidable = (ref) => ({
165
+ ruleId: mintAuthoredRuleId('totem-claude', ref, new Set()),
166
+ provenance: {
167
+ kind: 'authored',
168
+ author: 'totem-claude',
169
+ authoredAt: '2026-06-27',
170
+ targetDefect: 'float equality compared with == instead of a finite check',
171
+ positiveFixtures: [
172
+ {
173
+ pr: 1,
174
+ mergeCommitSha: 'a'.repeat(40),
175
+ preimageCommitSha: 'b'.repeat(40),
176
+ filePath: 'src/a.ts',
177
+ matchedSpan: 'L1',
178
+ contentHash: 'h1',
179
+ },
180
+ ],
181
+ },
182
+ structuralEligibility: {
183
+ decidable: true,
184
+ basis: 'whitelist:float-finite-assert',
185
+ judgedBy: 's',
186
+ },
187
+ origin: { kind: 'from-scratch' },
188
+ declaredEngine: 'regex',
189
+ authoringLedgerRef: ref,
190
+ dslSource: '**Pattern:** `== *\\d`',
191
+ unverified: true,
192
+ });
193
+ it('emits one structural candidate + a 1:1 authored-whitelist ledger entry per decidable rule', () => {
194
+ const feed = toCompileFeed([decidable('alr-1'), decidable('alr-2')]);
195
+ expect(feed.candidates).toHaveLength(2);
196
+ // the adapter — not the author — sets the disposition to structural.
197
+ expect(feed.candidates.every((c) => c.classifierDisposition === 'structural')).toBe(true);
198
+ // authored provenance is carried through, not flattened to a mined shape.
199
+ expect(feed.candidates[0].provenance.kind).toBe('authored');
200
+ expect(feed.candidates.map((c) => c.classifierLedgerRef)).toEqual([
201
+ 'authored:alr-1',
202
+ 'authored:alr-2',
203
+ ]);
204
+ // the classifier ledger NEVER claims an LLM judged a human rule (Tenet-20).
205
+ expect(feed.classifierLedger.entries.every((e) => e.dispositionSource === 'authored-whitelist')).toBe(true);
206
+ // the join key is 1:1 between candidate and ledger entry (runCompileStage requires it).
207
+ expect(feed.classifierLedger.entries.map((e) => e.candidateRef)).toEqual(feed.candidates.map((c) => c.classifierLedgerRef));
208
+ });
209
+ it('FAILS LOUD on a non-decidable record (FM(d) — never reaches the compiler)', () => {
210
+ const nd = {
211
+ ...decidable('alr-x'),
212
+ structuralEligibility: { decidable: false, basis: 'whitelist:foo', judgedBy: 's' },
213
+ };
214
+ expect(() => toCompileFeed([nd])).toThrow(/not structurally decidable/);
215
+ });
216
+ it('FAILS LOUD on a duplicate authoringLedgerRef (protects the 1:1 compile join)', () => {
217
+ expect(() => toCompileFeed([decidable('dup'), decidable('dup')])).toThrow(/duplicate authoringLedgerRef/);
218
+ });
219
+ });
220
+ //# sourceMappingURL=authored-rule.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authored-rule.test.js","sourceRoot":"","sources":["../../src/spine/authored-rule.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAEL,wBAAwB,EACxB,6BAA6B,EAC7B,kBAAkB,EAClB,aAAa,GAEd,MAAM,oBAAoB,CAAC;AAE5B,MAAM,SAAS,GAA8B;IAC3C,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE;IAC3D,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,iBAAiB,EAAE;CAC3D,CAAC;AAEF,QAAQ,CAAC,+DAA+D,EAAE,GAAG,EAAE;IAC7E,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM,CAAC,GAAG,6BAA6B,CACrC,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,EACnE,SAAS,EACT,yBAAyB,CAC1B,CAAC;QACF,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;QACtD,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACxE,MAAM,CAA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AM,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CACvE,8BAA8B,CAC/B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { type ProvenanceRecord } from '../compiler-schema.js';
2
3
  /**
3
4
  * Stage-2 classifier disposition (ADR-091 funnel, the gate). A `structural`
4
5
  * (syntactic-invariant) candidate is compile-eligible; a `behavioral` candidate
@@ -8,6 +9,32 @@ import { z } from 'zod';
8
9
  */
9
10
  export declare const ClassifierDispositionSchema: z.ZodEnum<["structural", "behavioral"]>;
10
11
  export type ClassifierDisposition = z.infer<typeof ClassifierDispositionSchema>;
12
+ /**
13
+ * ADR-112 — the minimal candidate shape the compile actuator (`compileCandidate`
14
+ * / `runCompileStage`) actually reads. BOTH the mined `CandidateRuleRecord` and an
15
+ * authored-derived candidate (via `toCompileFeed`) satisfy it: `provenance` is the
16
+ * `mined | authored` union, so ONE compiler accepts either producer without an
17
+ * authored rule masquerading as a classify result (ADR-112 §2 — a parallel
18
+ * front-end to one compiler, never a second compiler). The mined
19
+ * `CandidateRuleRecord` (whose `provenance` is the narrower `MinedProvenanceRecord`)
20
+ * is assignable to this shape; so is the authored compile-feed candidate.
21
+ */
22
+ export interface CompileInputCandidate {
23
+ provenance: ProvenanceRecord;
24
+ classifierDisposition: ClassifierDisposition;
25
+ classifierLedgerRef: string;
26
+ dslSource: string;
27
+ /**
28
+ * ADR-112 §3 (#2259/#7) — the engine the structural-eligibility whitelist judged
29
+ * this rule for (AUTHORED producer only). When present, `compileCandidate` asserts
30
+ * the compiled engine MATCHES it: a regex-whitelisted rule whose `dslSource` parses
31
+ * as ast-grep is a contract violation (the eligibility verdict was engine-specific),
32
+ * not a silent re-route. The MINED producer omits it — its engine + identity are
33
+ * `dslSource`-derived, so it carries no independent declaration to bind against.
34
+ */
35
+ declaredEngine?: 'regex' | 'ast' | 'ast-grep';
36
+ unverified: true;
37
+ }
11
38
  /**
12
39
  * ADR-111 §3 — the miner's sole output envelope, minted `unverified`/Yellow
13
40
  * with no hand-curation. A candidate that cannot produce a complete provenance
@@ -23,6 +50,7 @@ export declare const CandidateRuleRecordSchema: z.ZodObject<{
23
50
  * schema-unconstructible (FM(a)).
24
51
  */
25
52
  provenance: z.ZodObject<{
53
+ kind: z.ZodOptional<z.ZodLiteral<"mined">>;
26
54
  mergedPr: z.ZodNumber;
27
55
  reviewThread: z.ZodEffects<z.ZodString, string, string>;
28
56
  commitSha: z.ZodString;
@@ -30,10 +58,12 @@ export declare const CandidateRuleRecordSchema: z.ZodObject<{
30
58
  mergedPr: number;
31
59
  reviewThread: string;
32
60
  commitSha: string;
61
+ kind?: "mined" | undefined;
33
62
  }, {
34
63
  mergedPr: number;
35
64
  reviewThread: string;
36
65
  commitSha: string;
66
+ kind?: "mined" | undefined;
37
67
  }>;
38
68
  /** Stage-2 disposition. `behavioral` ⇒ RAG-only, never compiled (FM(c)). */
39
69
  classifierDisposition: z.ZodEnum<["structural", "behavioral"]>;
@@ -64,6 +94,7 @@ export declare const CandidateRuleRecordSchema: z.ZodObject<{
64
94
  mergedPr: number;
65
95
  reviewThread: string;
66
96
  commitSha: string;
97
+ kind?: "mined" | undefined;
67
98
  };
68
99
  unverified: true;
69
100
  classifierDisposition: "structural" | "behavioral";
@@ -74,6 +105,7 @@ export declare const CandidateRuleRecordSchema: z.ZodObject<{
74
105
  mergedPr: number;
75
106
  reviewThread: string;
76
107
  commitSha: string;
108
+ kind?: "mined" | undefined;
77
109
  };
78
110
  unverified: true;
79
111
  classifierDisposition: "structural" | "behavioral";
@@ -1 +1 @@
1
- {"version":3,"file":"candidate-rule.d.ts","sourceRoot":"","sources":["../../src/spine/candidate-rule.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;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EH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
@@ -12,7 +12,7 @@
12
12
  // (ADR-089): `unverified: true` forces `deriveRuleClass` to 'advisory' on any
13
13
  // later projection, so a candidate can never mint as `hard`.
14
14
  import { z } from 'zod';
15
- import { ProvenanceRecordSchema } from '../compiler-schema.js';
15
+ import { MinedProvenanceWireSchema } from '../compiler-schema.js';
16
16
  /**
17
17
  * Stage-2 classifier disposition (ADR-091 funnel, the gate). A `structural`
18
18
  * (syntactic-invariant) candidate is compile-eligible; a `behavioral` candidate
@@ -35,7 +35,7 @@ export const CandidateRuleRecordSchema = z.object({
35
35
  * downstream projection — no rename seam. An incomplete tuple is
36
36
  * schema-unconstructible (FM(a)).
37
37
  */
38
- provenance: ProvenanceRecordSchema,
38
+ provenance: MinedProvenanceWireSchema,
39
39
  /** Stage-2 disposition. `behavioral` ⇒ RAG-only, never compiled (FM(c)). */
40
40
  classifierDisposition: ClassifierDispositionSchema,
41
41
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"candidate-rule.js","sourceRoot":"","sources":["../../src/spine/candidate-rule.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,EAAE;AACF,8EAA8E;AAC9E,+EAA+E;AAC/E,yEAAyE;AACzE,2EAA2E;AAC3E,4EAA4E;AAC5E,wEAAwE;AACxE,gFAAgF;AAChF,yEAAyE;AACzE,yEAAyE;AACzE,8EAA8E;AAC9E,6DAA6D;AAE7D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC;AAGhF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAA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AE,2BAA2B;IAClD;;;;;;OAMG;IACH,mBAAmB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;QACjE,OAAO,EAAE,0DAA0D;KACpE,CAAC;IACF;;;;;OAKG;IACH,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE;QACvD,OAAO,EAAE,6BAA6B;KACvC,CAAC;IACF;;;;;OAKG;IACH,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;CAC5B,CAAC,CAAC"}
@@ -10,19 +10,19 @@ import { type ClassifierLedger, type EmissionLedger, type MinerLedgers, type Rou
10
10
  */
11
11
  export declare const ClassifierResultSchema: z.ZodEffects<z.ZodObject<{
12
12
  disposition: z.ZodEnum<["structural", "behavioral"]>;
13
- dispositionSource: z.ZodEnum<["classified", "error-default"]>;
13
+ dispositionSource: z.ZodEnum<["classified", "error-default", "authored-whitelist"]>;
14
14
  }, "strip", z.ZodTypeAny, {
15
15
  disposition: "structural" | "behavioral";
16
- dispositionSource: "classified" | "error-default";
16
+ dispositionSource: "classified" | "error-default" | "authored-whitelist";
17
17
  }, {
18
18
  disposition: "structural" | "behavioral";
19
- dispositionSource: "classified" | "error-default";
19
+ dispositionSource: "classified" | "error-default" | "authored-whitelist";
20
20
  }>, {
21
21
  disposition: "structural" | "behavioral";
22
- dispositionSource: "classified" | "error-default";
22
+ dispositionSource: "classified" | "error-default" | "authored-whitelist";
23
23
  }, {
24
24
  disposition: "structural" | "behavioral";
25
- dispositionSource: "classified" | "error-default";
25
+ dispositionSource: "classified" | "error-default" | "authored-whitelist";
26
26
  }>;
27
27
  export type ClassifierResult = z.infer<typeof ClassifierResultSchema>;
28
28
  /**
@@ -1,7 +1,6 @@
1
1
  import { type CompiledRule, type ProvenanceRecord } from '../compiler-schema.js';
2
2
  import { type Stage4Baseline, type Stage4VerificationResult, type Stage4VerifierDeps } from '../stage4-verifier.js';
3
- import type { CandidateRuleRecord } from './candidate-rule.js';
4
- import type { ClassifyStageResult } from './classify.js';
3
+ import type { CompileInputCandidate } from './candidate-rule.js';
5
4
  import type { ClassifierLedger } from './ledgers.js';
6
5
  /**
7
6
  * The slice-4 output: a compiled, Stage-4-verified candidate. Carries `provenance`
@@ -16,6 +15,19 @@ export interface CompiledCandidate {
16
15
  rule: CompiledRule;
17
16
  stage4: Stage4VerificationResult;
18
17
  }
18
+ /**
19
+ * ADR-112 §2 — the minimal input `runCompileStage` consumes: the candidates + the
20
+ * classifier ledger. A miner `ClassifyStageResult` satisfies it structurally (its
21
+ * extra `emissionLedger` is never read here); the authored producer's
22
+ * `toCompileFeed` builds it WITHOUT a mining emission ledger (an authored rule has
23
+ * no review-thread emission to attest, and the classifier ledger carries
24
+ * `dispositionSource: 'authored-whitelist'`, not a fabricated `'classified'`). One
25
+ * compiler, two producers — neither masquerading as the other.
26
+ */
27
+ export interface CompileStageInput {
28
+ candidates: readonly CompileInputCandidate[];
29
+ classifierLedger: ClassifierLedger;
30
+ }
19
31
  /** Pure compile outcome (no IO): a compiled rule, or a loud per-engine validation rejection. */
20
32
  export type CompileOutcome = {
21
33
  kind: 'compiled';
@@ -45,7 +57,7 @@ export interface CompileStageResult {
45
57
  * `rejected` outcome (NOT a throw) when the pattern parses but fails per-engine
46
58
  * safety validation (e.g. ReDoS) — a counted, reported `compile-rejected` state.
47
59
  */
48
- export declare function compileCandidate(candidate: CandidateRuleRecord, opts: {
60
+ export declare function compileCandidate(candidate: CompileInputCandidate, opts: {
49
61
  now: string;
50
62
  }): CompileOutcome;
51
63
  /**
@@ -58,5 +70,5 @@ export declare function compileCandidate(candidate: CandidateRuleRecord, opts: {
58
70
  * new entries array — updated entries are spread copies, unmodified entries share
59
71
  * the original reference (a structural copy, not a deep copy).
60
72
  */
61
- export declare function runCompileStage(classify: ClassifyStageResult, deps: CompileStageDeps): Promise<CompileStageResult>;
73
+ export declare function runCompileStage(classify: CompileStageInput, deps: CompileStageDeps): Promise<CompileStageResult>;
62
74
  //# sourceMappingURL=compile.d.ts.map