@mmnto/totem 1.64.0 → 1.64.2

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 (39) hide show
  1. package/dist/artifacts/panel.d.ts +1919 -0
  2. package/dist/artifacts/panel.d.ts.map +1 -0
  3. package/dist/artifacts/panel.js +503 -0
  4. package/dist/artifacts/panel.js.map +1 -0
  5. package/dist/artifacts/panel.test.d.ts +15 -0
  6. package/dist/artifacts/panel.test.d.ts.map +1 -0
  7. package/dist/artifacts/panel.test.js +335 -0
  8. package/dist/artifacts/panel.test.js.map +1 -0
  9. package/dist/artifacts/post-checks-rules.d.ts +93 -0
  10. package/dist/artifacts/post-checks-rules.d.ts.map +1 -0
  11. package/dist/artifacts/post-checks-rules.js +307 -0
  12. package/dist/artifacts/post-checks-rules.js.map +1 -0
  13. package/dist/artifacts/post-checks-rules.test.d.ts +9 -0
  14. package/dist/artifacts/post-checks-rules.test.d.ts.map +1 -0
  15. package/dist/artifacts/post-checks-rules.test.js +258 -0
  16. package/dist/artifacts/post-checks-rules.test.js.map +1 -0
  17. package/dist/artifacts/post-checks.d.ts +102 -0
  18. package/dist/artifacts/post-checks.d.ts.map +1 -0
  19. package/dist/artifacts/post-checks.js +80 -0
  20. package/dist/artifacts/post-checks.js.map +1 -0
  21. package/dist/artifacts/post-checks.test.d.ts +12 -0
  22. package/dist/artifacts/post-checks.test.d.ts.map +1 -0
  23. package/dist/artifacts/post-checks.test.js +103 -0
  24. package/dist/artifacts/post-checks.test.js.map +1 -0
  25. package/dist/compiler-schema.d.ts +329 -0
  26. package/dist/compiler-schema.d.ts.map +1 -1
  27. package/dist/compiler-schema.js +136 -1
  28. package/dist/compiler-schema.js.map +1 -1
  29. package/dist/compiler-schema.test.js +136 -1
  30. package/dist/compiler-schema.test.js.map +1 -1
  31. package/dist/compiler.d.ts +2 -2
  32. package/dist/compiler.d.ts.map +1 -1
  33. package/dist/compiler.js +1 -1
  34. package/dist/compiler.js.map +1 -1
  35. package/dist/index.d.ts +8 -2
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +4 -1
  38. package/dist/index.js.map +1 -1
  39. package/package.json +1 -1
@@ -0,0 +1,307 @@
1
+ /**
2
+ * The default deterministic post-check rule set (mmnto-ai/totem#2103, strategy#474
3
+ * slice 4). Each rule is zero-LLM and returns a verdict at its STATIC tier; the
4
+ * aggregator ({@link evaluatePostChecks}) owns rejection. Rule decomposition
5
+ * follows the cohort pre-build round (codex): the OutputContract's three knobs
6
+ * (`schema` / `citationsRequired` / `verifyFallback`) are distinct
7
+ * responsibilities, not one rule.
8
+ *
9
+ * Helpers (containment, citation extraction, line-range) are exported for
10
+ * direct unit testing — they are the load-bearing edge-case surface (agy).
11
+ */
12
+ // `node:fs` is a STATIC import by design (CR #2177 review #3, declined): @mmnto/totem
13
+ // (core) is a Node package — native LanceDB + tree-sitter bindings — never an
14
+ // edge/Deno/browser target, so the module-load portability concern does not apply.
15
+ // The `readFile` seam exists for test injection, not runtime portability.
16
+ import { readFileSync } from 'node:fs';
17
+ import * as path from 'node:path';
18
+ import { resolveCaller, } from './post-checks.js';
19
+ import { PROVENANCE_CLASSES } from './schema.js';
20
+ const KNOWN_EXTENSION = /\.(ts|tsx|js|jsx|mjs|cjs|md|json|ya?ml|go|py|rs|java|c|cpp|h)$/i;
21
+ const CANONICAL_PROVENANCE = new Set(PROVENANCE_CLASSES);
22
+ /** Default file read: returns the text, or `undefined` if the path does not resolve (honest-absent). */
23
+ function defaultReadFile(absPath) {
24
+ try {
25
+ return readFileSync(absPath, 'utf8');
26
+ // totem-context: honest-absent — undefined means "not found", consumed as a citation fail.
27
+ }
28
+ catch {
29
+ return undefined;
30
+ }
31
+ }
32
+ function readFileVia(ctx, absPath) {
33
+ return (ctx.readFile ?? defaultReadFile)(absPath);
34
+ }
35
+ /**
36
+ * Is `citedPath` a relative path nested inside `configRoot`? Rejects absolute
37
+ * paths and Windows drive-letters up front, normalizes separators BEFORE
38
+ * resolving (win32: `src\..\..\etc/passwd` must not slip), then requires the
39
+ * resolved path to stay under the root (agy review on mmnto-ai/totem#2103).
40
+ */
41
+ export function isContained(configRoot, citedPath) {
42
+ if (path.isAbsolute(citedPath) || /^[a-zA-Z]:/.test(citedPath))
43
+ return false;
44
+ // Normalize separators BEFORE resolving: on POSIX `\` is a literal filename
45
+ // char, so `src\..\..\etc/passwd` would NOT get its `..` collapsed by
46
+ // path.resolve and would escape the root undetected. Forward-slashing first
47
+ // makes traversal detection identical on win32 and POSIX.
48
+ const normalizedCited = citedPath.replace(/\\/g, '/');
49
+ const root = path.resolve(configRoot);
50
+ // path.join (NOT path.resolve) so a normalized-absolute segment can't reset the
51
+ // base out of root (GCA review — absolute-path injection); then path.relative +
52
+ // a FIRST-SEGMENT check (not startsWith, which would false-reject a `..foo` file)
53
+ // and a cross-drive guard. No hardcoded separator → a filesystem-root config
54
+ // never double-slashes into a false fail.
55
+ const rel = path.relative(root, path.join(root, normalizedCited));
56
+ return rel.split(path.sep)[0] !== '..' && !path.isAbsolute(rel);
57
+ }
58
+ /**
59
+ * Conservatively extract `path` / `path:line` / `path:start-end` citations from
60
+ * backticked spans in `content`. Strips fenced code blocks first (their sample
61
+ * paths / command logs would false-fail), and ignores backticked tokens that
62
+ * carry neither a path separator nor a known extension — so `` `main` `` /
63
+ * `` `pnpm test` `` are not treated as citations (agy review on mmnto-ai/totem#2103).
64
+ */
65
+ export function extractCitations(content) {
66
+ const withoutFences = content.replace(/```[\s\S]*?```/g, '');
67
+ const citations = [];
68
+ for (const match of withoutFences.matchAll(/`([^`]+)`/g)) {
69
+ const token = match[1].trim();
70
+ const parsed = /^(.+?)(?::(\d+)(?:-(\d+))?)?$/.exec(token);
71
+ if (parsed === null)
72
+ continue;
73
+ const filePath = parsed[1].replace(/\\/g, '/');
74
+ // Skip URLs (CR review): a `https://…/x.ts` token has a separator + extension,
75
+ // would fail containment, and would false-fail a spec that links external docs.
76
+ if (/^https?:\/\//.test(filePath))
77
+ continue;
78
+ if (!filePath.includes('/') && !KNOWN_EXTENSION.test(filePath)) {
79
+ continue;
80
+ }
81
+ const citation = { raw: token, filePath };
82
+ if (parsed[2] !== undefined)
83
+ citation.line = Number(parsed[2]);
84
+ if (parsed[3] !== undefined)
85
+ citation.endLine = Number(parsed[3]);
86
+ citations.push(citation);
87
+ }
88
+ return citations;
89
+ }
90
+ /**
91
+ * Is a citation's line reference valid against a file of `totalLines` lines?
92
+ * Path-only citations (no line) always pass the line check. 1-indexed; a range
93
+ * requires `0 < start <= end <= totalLines` (agy boundary matrix).
94
+ */
95
+ export function lineRefValid(totalLines, line, endLine) {
96
+ if (line === undefined)
97
+ return true;
98
+ if (!Number.isInteger(line) || line <= 0 || line > totalLines)
99
+ return false;
100
+ if (endLine !== undefined) {
101
+ if (!Number.isInteger(endLine) || endLine < line || endLine > totalLines)
102
+ return false;
103
+ }
104
+ return true;
105
+ }
106
+ function countLines(text) {
107
+ return text.split('\n').length;
108
+ }
109
+ // ── Rules ──────────────────────────────────────────────────────────────────
110
+ /**
111
+ * Structured-output contract (decidable, all callers). Absent `schema` ⇒
112
+ * abstain (prose output is never treated as malformed JSON). Present ⇒
113
+ * `output.content` must parse as JSON; non-JSON is a decidable fail. NOTE: deep
114
+ * JSON-Schema shape validation is a follow-on — core carries no validator
115
+ * dependency this slice, so the gate is parse-only (codex review: "non-JSON is
116
+ * a decidable fail").
117
+ */
118
+ export const structuredOutputRule = {
119
+ name: 'structured-output',
120
+ tier: 'decidable',
121
+ appliesTo: () => true,
122
+ evaluate: (a) => {
123
+ if (a.admission?.outputContract?.schema === undefined) {
124
+ return { verdict: 'abstain', message: 'no outputContract.schema declared' };
125
+ }
126
+ try {
127
+ JSON.parse(a.output.content);
128
+ return { verdict: 'pass', message: 'output parses as JSON (shape-validation deferred)' };
129
+ // totem-context: fail-loud — a parse failure becomes a decidable 'fail' verdict, not a silent pass.
130
+ }
131
+ catch {
132
+ return {
133
+ verdict: 'fail',
134
+ message: 'outputContract.schema declared but output.content is not valid JSON',
135
+ };
136
+ }
137
+ },
138
+ };
139
+ /**
140
+ * Citation resolution (decidable). Gates only when the caller declared
141
+ * `citationsRequired`. For each cited path: must be in-root, the file must
142
+ * exist, and any line reference must be in range. For a `review` run, a citation
143
+ * outside the delivered grounding bundle is also a fail (review cites what it was
144
+ * given). Claim *support* (does the cited text back the claim) stays sensor-only
145
+ * — out of scope here (ADR-109).
146
+ *
147
+ * Intentional overlap (CR #2177 review): on a `spec` run with `citationsRequired`,
148
+ * an unresolved path is ALSO flagged by spec-verify — both correctly fail it, so the
149
+ * report can carry two decidable findings for one path. The rules are independent by
150
+ * design (different escapes: spec-verify owns the `VERIFY:` fallback, this owns
151
+ * line-range + bundle membership); de-duplicating overlapping decidable fails belongs
152
+ * at the live-wiring / aggregation layer (#2104), not by coupling rules in this slice.
153
+ */
154
+ export const citationResolvesRule = {
155
+ name: 'citation-resolves',
156
+ tier: 'decidable',
157
+ appliesTo: () => true,
158
+ evaluate: (a, ctx) => {
159
+ if (a.admission?.outputContract?.citationsRequired !== true) {
160
+ return { verdict: 'abstain', message: 'citations not required by outputContract' };
161
+ }
162
+ const citations = extractCitations(a.output.content);
163
+ if (citations.length === 0) {
164
+ return { verdict: 'abstain', message: 'no resolvable path citations in output' };
165
+ }
166
+ const bundlePaths = resolveCaller(a) === 'review' && a.grounding.bundle !== undefined
167
+ ? // normalize separators (GCA review): bundle filePaths may be win32 backslash,
168
+ // cited filePaths are forward-slashed, so compare on a common separator.
169
+ new Set(a.grounding.bundle.items.map((i) => i.filePath.replace(/\\/g, '/')))
170
+ : undefined;
171
+ const failures = [];
172
+ for (const c of citations) {
173
+ if (!isContained(ctx.configRoot, c.filePath)) {
174
+ failures.push(`${c.raw} (escapes repo root)`);
175
+ continue;
176
+ }
177
+ const text = readFileVia(ctx, path.resolve(ctx.configRoot, c.filePath));
178
+ if (text === undefined) {
179
+ failures.push(`${c.raw} (file not found)`);
180
+ continue;
181
+ }
182
+ if (!lineRefValid(countLines(text), c.line, c.endLine)) {
183
+ failures.push(`${c.raw} (line out of range)`);
184
+ continue;
185
+ }
186
+ if (bundlePaths !== undefined && !bundlePaths.has(c.filePath)) {
187
+ failures.push(`${c.raw} (not in delivered grounding bundle)`);
188
+ }
189
+ }
190
+ if (failures.length === 0) {
191
+ return { verdict: 'pass', message: `all ${citations.length} citations resolve` };
192
+ }
193
+ return {
194
+ verdict: 'fail',
195
+ message: `unresolvable citation(s): ${failures.join('; ')}`,
196
+ context: { failures },
197
+ };
198
+ },
199
+ };
200
+ /**
201
+ * Spec VERIFY requirement (decidable, caller `spec`). A spec that references a
202
+ * path which does not resolve on disk must mark it with `VERIFY:` — otherwise it
203
+ * is a fabricated path (the mmnto-ai/totem#2090/#2091 class). `VERIFY:` is accepted
204
+ * as the escape UNLESS the caller set `outputContract.verifyFallback === false`
205
+ * (the verify-fallback knob, folded here where `VERIFY:` is actually consumed —
206
+ * codex review).
207
+ */
208
+ export const specVerifyRule = {
209
+ name: 'spec-verify',
210
+ tier: 'decidable',
211
+ appliesTo: (a) => resolveCaller(a) === 'spec',
212
+ evaluate: (a, ctx) => {
213
+ const content = a.output.content;
214
+ const citations = extractCitations(content);
215
+ if (citations.length === 0) {
216
+ return { verdict: 'abstain', message: 'no path citations in spec output' };
217
+ }
218
+ const unresolved = citations.filter((c) => {
219
+ if (!isContained(ctx.configRoot, c.filePath))
220
+ return true;
221
+ return readFileVia(ctx, path.resolve(ctx.configRoot, c.filePath)) === undefined;
222
+ });
223
+ if (unresolved.length === 0) {
224
+ return { verdict: 'pass', message: `all ${citations.length} cited paths resolve` };
225
+ }
226
+ const verifyAllowed = a.admission?.outputContract?.verifyFallback !== false;
227
+ // Strip fences before the marker search too (Greptile review) — a VERIFY: that
228
+ // exists only inside a code block (which extractCitations already strips) must
229
+ // not excuse unresolved paths the citation pass never saw.
230
+ const hasVerifyMarker = /\bVERIFY:/.test(content.replace(/```[\s\S]*?```/g, ''));
231
+ if (verifyAllowed && hasVerifyMarker) {
232
+ return {
233
+ verdict: 'pass',
234
+ message: `${unresolved.length} unresolved path(s) but VERIFY: present`,
235
+ };
236
+ }
237
+ const paths = unresolved.map((c) => c.filePath);
238
+ return {
239
+ verdict: 'fail',
240
+ message: hasVerifyMarker
241
+ ? `unresolved path(s) and verifyFallback is disabled: ${paths.join(', ')}`
242
+ : `unresolved cited path(s) without VERIFY:: ${paths.join(', ')}`,
243
+ context: { unresolved: paths },
244
+ };
245
+ },
246
+ };
247
+ /**
248
+ * Override-memory reappearance (decidable, caller `review`). A finding the
249
+ * operator dispositioned (rejected) must not reappear in a later review. The
250
+ * anchored-span key format lives in the store (mmnto-ai/totem#2105); this rule only
251
+ * asks the injected {@link OverrideSet} whether any reappears. Absent store ⇒
252
+ * abstain (the rule no-ops until #2105 wires a store).
253
+ */
254
+ export const overrideReappearanceRule = {
255
+ name: 'override-reappearance',
256
+ tier: 'decidable',
257
+ appliesTo: (a) => resolveCaller(a) === 'review',
258
+ evaluate: (a, ctx) => {
259
+ if (ctx.overrideMemory === undefined) {
260
+ return { verdict: 'abstain', message: 'no override memory supplied (store lands in #2105)' };
261
+ }
262
+ const reappeared = ctx.overrideMemory.reappearsIn(a.output.content);
263
+ if (reappeared.length === 0) {
264
+ return { verdict: 'pass', message: 'no dispositioned overrides reappeared' };
265
+ }
266
+ return {
267
+ verdict: 'fail',
268
+ message: `dispositioned override(s) reappeared: ${reappeared.join(', ')}`,
269
+ context: { reappeared: [...reappeared] },
270
+ };
271
+ },
272
+ };
273
+ /**
274
+ * Provenance fail-safe-down sensor (SENSOR, all grounded runs; mmnto-ai/totem#2101
275
+ * F2 rider, enforcement test rides #2103). A grounding item whose `provenance`
276
+ * is not a canonical class is surfaced as NOT-upgraded (lowest trust). SENSOR
277
+ * tier: it is telemetry and can NEVER gate — an invented class must not confer,
278
+ * nor deny, trust by gating.
279
+ */
280
+ export const provenanceSensorRule = {
281
+ name: 'provenance-fail-safe-down',
282
+ tier: 'sensor',
283
+ appliesTo: (a) => a.grounding.bundle !== undefined,
284
+ evaluate: (a) => {
285
+ const items = a.grounding.bundle?.items ?? [];
286
+ const unknown = [
287
+ ...new Set(items.map((i) => i.provenance).filter((p) => !CANONICAL_PROVENANCE.has(p))),
288
+ ];
289
+ if (unknown.length === 0) {
290
+ return { verdict: 'pass', message: 'all provenance classes canonical' };
291
+ }
292
+ return {
293
+ verdict: 'fail',
294
+ message: `non-canonical provenance treated as not-upgraded: ${unknown.join(', ')}`,
295
+ context: { unknown },
296
+ };
297
+ },
298
+ };
299
+ /** The default rule set, in execution order. */
300
+ export const DEFAULT_RULES = [
301
+ structuredOutputRule,
302
+ citationResolvesRule,
303
+ specVerifyRule,
304
+ overrideReappearanceRule,
305
+ provenanceSensorRule,
306
+ ];
307
+ //# sourceMappingURL=post-checks-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-checks-rules.js","sourceRoot":"","sources":["../../src/artifacts/post-checks-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,sFAAsF;AACtF,8EAA8E;AAC9E,mFAAmF;AACnF,0EAA0E;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAIL,aAAa,GACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,eAAe,GAAG,iEAAiE,CAAC;AAC1F,MAAM,oBAAoB,GAAwB,IAAI,GAAG,CAAC,kBAAkB,CAAC,CAAC;AAE9E,wGAAwG;AACxG,SAAS,eAAe,CAAC,OAAe;IACtC,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACrC,2FAA2F;IAC7F,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,GAAqB,EAAE,OAAe;IACzD,OAAO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,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SACvF,CAAC;QACF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,kCAAkC,EAAE,CAAC;QAC1E,CAAC;QACD,OAAO;YACL,OAAO,EAAE,MAAM;YACf,OAAO,EAAE,qDAAqD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YAClF,OAAO,EAAE,EAAE,OAAO,EAAE;SACrB,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,gDAAgD;AAChD,MAAM,CAAC,MAAM,aAAa,GAA6B;IACrD,oBAAoB;IACpB,oBAAoB;IACpB,cAAc;IACd,wBAAwB;IACxB,oBAAoB;CACrB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Post-check rule + helper tests (mmnto-ai/totem#2103, strategy#474 slice 4).
3
+ * Covers the agy edge-case matrix (containment/win32, citation extraction,
4
+ * line-range boundaries), the codex contract folds (3 OutputContract rules,
5
+ * spec VERIFY + verifyFallback), the OQ2 override boundary, and the F2
6
+ * provenance sensor end-to-end through the engine.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=post-checks-rules.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-checks-rules.test.d.ts","sourceRoot":"","sources":["../../src/artifacts/post-checks-rules.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,258 @@
1
+ /**
2
+ * Post-check rule + helper tests (mmnto-ai/totem#2103, strategy#474 slice 4).
3
+ * Covers the agy edge-case matrix (containment/win32, citation extraction,
4
+ * line-range boundaries), the codex contract folds (3 OutputContract rules,
5
+ * spec VERIFY + verifyFallback), the OQ2 override boundary, and the F2
6
+ * provenance sensor end-to-end through the engine.
7
+ */
8
+ import { describe, expect, it } from 'vitest';
9
+ import { evaluatePostChecks } from './post-checks.js';
10
+ import { citationResolvesRule, DEFAULT_RULES, extractCitations, isContained, lineRefValid, overrideReappearanceRule, specVerifyRule, structuredOutputRule, } from './post-checks-rules.js';
11
+ function artifact(o = {}) {
12
+ const { caller, taskProfile = 'Spec', content = '', codeBlind, outputContract, bundleItems } = o;
13
+ const a = {
14
+ backend: { taskProfile },
15
+ output: { content },
16
+ grounding: {},
17
+ };
18
+ if (caller !== undefined || codeBlind !== undefined || outputContract !== undefined) {
19
+ const admission = {};
20
+ if (caller !== undefined || codeBlind !== undefined) {
21
+ const runMetadata = {};
22
+ if (caller !== undefined)
23
+ runMetadata.caller = caller;
24
+ if (codeBlind !== undefined)
25
+ runMetadata.codeBlind = codeBlind;
26
+ admission.runMetadata = runMetadata;
27
+ }
28
+ if (outputContract !== undefined)
29
+ admission.outputContract = outputContract;
30
+ a.admission = admission;
31
+ }
32
+ if (bundleItems !== undefined) {
33
+ a.grounding.bundle = {
34
+ items: bundleItems.map((b) => ({
35
+ provenance: b.provenance ?? 'similarity-only',
36
+ filePath: b.filePath,
37
+ })),
38
+ };
39
+ }
40
+ return a;
41
+ }
42
+ /** A readFile stub: returns a 5-line file for any path whose normalized form ends with a known suffix. */
43
+ function readStub(existing) {
44
+ const norm = (p) => p.replace(/\\/g, '/');
45
+ return (abs) => (existing.some((e) => norm(abs).endsWith(e)) ? 'a\nb\nc\nd\ne' : undefined);
46
+ }
47
+ const ctx = (existing = []) => ({
48
+ configRoot: '/repo',
49
+ readFile: readStub(existing),
50
+ });
51
+ describe('isContained — win32-safe containment', () => {
52
+ it('accepts a relative path nested in root', () => {
53
+ expect(isContained('/repo', 'src/x.ts')).toBe(true);
54
+ });
55
+ it('rejects parent-traversal escape', () => {
56
+ expect(isContained('/repo', '../../etc/passwd')).toBe(false);
57
+ });
58
+ it('rejects backslash-separator traversal on any platform', () => {
59
+ // POSIX treats `\` as a literal char; normalization must still catch this escape.
60
+ expect(isContained('/repo', 'src\\..\\..\\etc/passwd')).toBe(false);
61
+ });
62
+ it('does not false-reject a filename that merely starts with .. (segment check, not startsWith)', () => {
63
+ expect(isContained('/repo', '..foo.ts')).toBe(true);
64
+ });
65
+ it('rejects an absolute path', () => {
66
+ expect(isContained('/repo', '/etc/passwd')).toBe(false);
67
+ });
68
+ it('rejects a drive-letter path', () => {
69
+ expect(isContained('/repo', 'C:\\Windows\\System32')).toBe(false);
70
+ });
71
+ });
72
+ describe('extractCitations', () => {
73
+ it('parses path, path:line, and path:start-end', () => {
74
+ const cites = extractCitations('see `src/a.ts`, `src/b.ts:12`, and `src/c.ts:3-9`');
75
+ expect(cites).toEqual([
76
+ { raw: 'src/a.ts', filePath: 'src/a.ts' },
77
+ { raw: 'src/b.ts:12', filePath: 'src/b.ts', line: 12 },
78
+ { raw: 'src/c.ts:3-9', filePath: 'src/c.ts', line: 3, endLine: 9 },
79
+ ]);
80
+ });
81
+ it('strips fenced code blocks before extracting', () => {
82
+ const content = 'real `src/real.ts`\n```ts\nimport `src/fake.ts`\n```\n';
83
+ expect(extractCitations(content).map((c) => c.filePath)).toEqual(['src/real.ts']);
84
+ });
85
+ it('ignores backticked tokens with no separator or known extension', () => {
86
+ expect(extractCitations('run `main` then `pnpm test`')).toEqual([]);
87
+ });
88
+ it('ignores URL tokens even when they carry a separator and a known extension', () => {
89
+ expect(extractCitations('see `https://pkg.go.dev/path/filepath.ts`')).toEqual([]);
90
+ });
91
+ it('keeps a bare filename with a known extension', () => {
92
+ expect(extractCitations('the `tsconfig.json` file').map((c) => c.filePath)).toEqual([
93
+ 'tsconfig.json',
94
+ ]);
95
+ });
96
+ });
97
+ describe('lineRefValid — boundary matrix', () => {
98
+ it('path-only (no line) always passes', () => expect(lineRefValid(5)).toBe(true));
99
+ it('line in range passes', () => expect(lineRefValid(5, 5)).toBe(true));
100
+ it('line 0 fails', () => expect(lineRefValid(5, 0)).toBe(false));
101
+ it('line beyond EOF fails', () => expect(lineRefValid(5, 6)).toBe(false));
102
+ it('valid range passes', () => expect(lineRefValid(5, 2, 4)).toBe(true));
103
+ it('inverted range fails', () => expect(lineRefValid(5, 4, 2)).toBe(false));
104
+ it('range past EOF fails', () => expect(lineRefValid(5, 2, 99)).toBe(false));
105
+ });
106
+ describe('structuredOutputRule', () => {
107
+ it('abstains when no schema is declared', async () => {
108
+ expect((await structuredOutputRule.evaluate(artifact({ content: 'prose' }), ctx())).verdict).toBe('abstain');
109
+ });
110
+ it('applies to all runs (abstains without a schema rather than being gated out)', () => {
111
+ expect(structuredOutputRule.appliesTo(artifact({ content: 'prose' }))).toBe(true);
112
+ });
113
+ it('fails when schema is declared but content is not JSON', async () => {
114
+ const a = artifact({ content: 'not json', outputContract: { schema: { type: 'object' } } });
115
+ expect((await structuredOutputRule.evaluate(a, ctx())).verdict).toBe('fail');
116
+ });
117
+ it('passes when schema is declared and content is JSON', async () => {
118
+ const a = artifact({ content: '{"ok":true}', outputContract: { schema: { type: 'object' } } });
119
+ expect((await structuredOutputRule.evaluate(a, ctx())).verdict).toBe('pass');
120
+ });
121
+ });
122
+ describe('citationResolvesRule', () => {
123
+ it('abstains when citations are not required by the contract', async () => {
124
+ const a = artifact({ content: 'see `src/a.ts`' });
125
+ expect((await citationResolvesRule.evaluate(a, ctx(['src/a.ts']))).verdict).toBe('abstain');
126
+ });
127
+ it('passes when every citation resolves and lines are in range', async () => {
128
+ const a = artifact({
129
+ content: 'see `src/a.ts:2` and `src/b.ts`',
130
+ outputContract: { citationsRequired: true },
131
+ });
132
+ expect((await citationResolvesRule.evaluate(a, ctx(['src/a.ts', 'src/b.ts']))).verdict).toBe('pass');
133
+ });
134
+ it('fails on a missing file', async () => {
135
+ const a = artifact({
136
+ content: 'see `src/gone.ts`',
137
+ outputContract: { citationsRequired: true },
138
+ });
139
+ expect((await citationResolvesRule.evaluate(a, ctx([]))).verdict).toBe('fail');
140
+ });
141
+ it('fails on an out-of-range line', async () => {
142
+ const a = artifact({
143
+ content: 'see `src/a.ts:99`',
144
+ outputContract: { citationsRequired: true },
145
+ });
146
+ expect((await citationResolvesRule.evaluate(a, ctx(['src/a.ts']))).verdict).toBe('fail');
147
+ });
148
+ it('fails a review citation outside the delivered bundle', async () => {
149
+ const a = artifact({
150
+ caller: 'review',
151
+ content: 'see `src/a.ts`',
152
+ outputContract: { citationsRequired: true },
153
+ bundleItems: [{ filePath: 'src/other.ts' }],
154
+ });
155
+ expect((await citationResolvesRule.evaluate(a, ctx(['src/a.ts']))).verdict).toBe('fail');
156
+ });
157
+ it('abstains when there are no citations to resolve', async () => {
158
+ const a = artifact({
159
+ content: 'no citations here',
160
+ outputContract: { citationsRequired: true },
161
+ });
162
+ expect((await citationResolvesRule.evaluate(a, ctx())).verdict).toBe('abstain');
163
+ });
164
+ });
165
+ describe('specVerifyRule — the #2090/#2091 fabrication class', () => {
166
+ const invented = 'The fix lives in `packages/cli/src/utils/diff-selector.ts`.';
167
+ it('fails a spec citing a nonexistent path without VERIFY:', async () => {
168
+ const a = artifact({ caller: 'spec', content: invented });
169
+ expect((await specVerifyRule.evaluate(a, ctx([]))).verdict).toBe('fail');
170
+ });
171
+ it('passes when VERIFY: marks the unresolved path', async () => {
172
+ const a = artifact({
173
+ caller: 'spec',
174
+ content: `${invented}\nVERIFY: this path may not exist yet.`,
175
+ });
176
+ expect((await specVerifyRule.evaluate(a, ctx([]))).verdict).toBe('pass');
177
+ });
178
+ it('still fails with VERIFY: when verifyFallback is disabled', async () => {
179
+ const a = artifact({
180
+ caller: 'spec',
181
+ content: `${invented}\nVERIFY: x`,
182
+ outputContract: { verifyFallback: false },
183
+ });
184
+ expect((await specVerifyRule.evaluate(a, ctx([]))).verdict).toBe('fail');
185
+ });
186
+ it('passes when all cited paths resolve', async () => {
187
+ const a = artifact({
188
+ caller: 'spec',
189
+ content: 'see `packages/cli/src/utils/diff-selector.ts`',
190
+ });
191
+ expect((await specVerifyRule.evaluate(a, ctx(['packages/cli/src/utils/diff-selector.ts']))).verdict).toBe('pass');
192
+ });
193
+ it('does not apply to review runs', () => {
194
+ expect(specVerifyRule.appliesTo(artifact({ caller: 'review' }))).toBe(false);
195
+ });
196
+ });
197
+ describe('overrideReappearanceRule — OQ2 boundary', () => {
198
+ it('abstains when no override memory is supplied', async () => {
199
+ const a = artifact({ caller: 'review', content: 'anything' });
200
+ expect((await overrideReappearanceRule.evaluate(a, ctx())).verdict).toBe('abstain');
201
+ });
202
+ it('passes when no override reappears', async () => {
203
+ const a = artifact({ caller: 'review', content: 'clean output' });
204
+ const c = { ...ctx(), overrideMemory: { reappearsIn: () => [] } };
205
+ expect((await overrideReappearanceRule.evaluate(a, c)).verdict).toBe('pass');
206
+ });
207
+ it('fails when the store reports a reappearance', async () => {
208
+ const a = artifact({ caller: 'review', content: 'the rejected claim is back' });
209
+ const c = { ...ctx(), overrideMemory: { reappearsIn: () => ['override-7'] } };
210
+ expect((await overrideReappearanceRule.evaluate(a, c)).verdict).toBe('fail');
211
+ });
212
+ });
213
+ describe('engine + DEFAULT_RULES integration', () => {
214
+ it('rejects the #2090 fabrication end-to-end', async () => {
215
+ const a = artifact({
216
+ caller: 'spec',
217
+ content: 'see `packages/cli/src/utils/diff-selector.ts`',
218
+ });
219
+ const r = await evaluatePostChecks(a, DEFAULT_RULES, ctx([]));
220
+ expect(r.isRejected).toBe(true);
221
+ expect(r.findings.find((f) => f.ruleName === 'spec-verify')?.verdict).toBe('fail');
222
+ });
223
+ it('F2: a non-canonical provenance class is a SENSOR signal and never rejects', async () => {
224
+ const a = artifact({
225
+ caller: 'spec',
226
+ content: 'no citations',
227
+ bundleItems: [{ filePath: 'src/a.ts', provenance: 'execution-verified' }],
228
+ });
229
+ const r = await evaluatePostChecks(a, DEFAULT_RULES, ctx());
230
+ const prov = r.findings.find((f) => f.ruleName === 'provenance-fail-safe-down');
231
+ expect(prov).toMatchObject({ tier: 'sensor', verdict: 'fail' });
232
+ expect(r.isRejected).toBe(false);
233
+ });
234
+ it('slice-1 historic artifact (unknown profile, no contract, no bundle) is all-abstain and does not reject', async () => {
235
+ // Unknown taskProfile + no caller → resolveCaller undefined → caller-scoped rules
236
+ // don't apply; the contract/bundle rules abstain. Protects retrofitted history.
237
+ const historic = artifact({
238
+ taskProfile: 'LegacyUnknown',
239
+ content: 'plain text, no citations',
240
+ });
241
+ const r = await evaluatePostChecks(historic, DEFAULT_RULES, ctx());
242
+ expect(r.isRejected).toBe(false);
243
+ expect(r.findings.every((f) => f.verdict === 'abstain')).toBe(true);
244
+ });
245
+ it('code-blind profile: spec checks still run and a resolvable citation does not false-fail', async () => {
246
+ // agy must-cover profile (b): a code-blind spec run (zero code retrieved) still runs
247
+ // spec-verify; the codeBlind flag is inert to the gates and must not cause a fail.
248
+ const a = artifact({
249
+ caller: 'spec',
250
+ codeBlind: true,
251
+ content: 'see `packages/cli/src/utils/diff-selector.ts`',
252
+ });
253
+ const r = await evaluatePostChecks(a, DEFAULT_RULES, ctx(['packages/cli/src/utils/diff-selector.ts']));
254
+ expect(r.isRejected).toBe(false);
255
+ expect(r.findings.find((f) => f.ruleName === 'spec-verify')?.verdict).toBe('pass');
256
+ });
257
+ });
258
+ //# sourceMappingURL=post-checks-rules.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-checks-rules.test.js","sourceRoot":"","sources":["../../src/artifacts/post-checks-rules.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAyB,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,wBAAwB,EACxB,cAAc,EACd,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAgBhC,SAAS,QAAQ,CAAC,IAAkB,EAAE;IACpC,MAAM,EAAE,MAAM,EAAE,WA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