@warpgogol/forge 9.4.1 → 9.5.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/CHANGELOG.md +15 -0
- package/bin/cli.ts +152 -11
- package/dist/bin/cli.js +125 -5
- package/dist/bin/cli.js.map +1 -1
- package/dist/os/flow/dirty-classify.d.ts +7 -0
- package/dist/os/flow/dirty-classify.d.ts.map +1 -1
- package/dist/os/flow/dirty-classify.js +11 -0
- package/dist/os/flow/dirty-classify.js.map +1 -1
- package/dist/os/flow/flow.module.d.ts.map +1 -1
- package/dist/os/flow/flow.module.js +3 -2
- package/dist/os/flow/flow.module.js.map +1 -1
- package/dist/os/flow/handlers/flow-check.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-check.js +9 -9
- package/dist/os/flow/handlers/flow-check.js.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-integrate.js +59 -26
- package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
- package/dist/os/flow/handlers/flow-open.d.ts.map +1 -1
- package/dist/os/flow/handlers/flow-open.js +14 -19
- package/dist/os/flow/handlers/flow-open.js.map +1 -1
- package/dist/os/flow/index.d.ts +1 -0
- package/dist/os/flow/index.d.ts.map +1 -1
- package/dist/os/flow/index.js +5 -3
- package/dist/os/flow/index.js.map +1 -1
- package/dist/os/flow/preflight.d.ts +24 -0
- package/dist/os/flow/preflight.d.ts.map +1 -1
- package/dist/os/flow/preflight.js +354 -10
- package/dist/os/flow/preflight.js.map +1 -1
- package/dist/os/flow/registry.d.ts +2 -2
- package/dist/os/gate-run/detach.d.ts +27 -0
- package/dist/os/gate-run/detach.d.ts.map +1 -0
- package/dist/os/gate-run/detach.js +85 -0
- package/dist/os/gate-run/detach.js.map +1 -0
- package/dist/os/gate-run/gate-run.module.d.ts +3 -0
- package/dist/os/gate-run/gate-run.module.d.ts.map +1 -0
- package/dist/os/gate-run/gate-run.module.js +23 -0
- package/dist/os/gate-run/gate-run.module.js.map +1 -0
- package/dist/os/gate-run/index.d.ts +7 -0
- package/dist/os/gate-run/index.d.ts.map +1 -0
- package/dist/os/gate-run/index.js +5 -0
- package/dist/os/gate-run/index.js.map +1 -0
- package/dist/os/gate-run/record.d.ts +47 -0
- package/dist/os/gate-run/record.d.ts.map +1 -0
- package/dist/os/gate-run/record.js +157 -0
- package/dist/os/gate-run/record.js.map +1 -0
- package/dist/os/gate-run/status.d.ts +41 -0
- package/dist/os/gate-run/status.d.ts.map +1 -0
- package/dist/os/gate-run/status.js +142 -0
- package/dist/os/gate-run/status.js.map +1 -0
- package/dist/os/gate-run/types.d.ts +47 -0
- package/dist/os/gate-run/types.d.ts.map +1 -0
- package/dist/os/gate-run/types.js +24 -0
- package/dist/os/gate-run/types.js.map +1 -0
- package/dist/os/rfc/evidence-annotation.d.ts +26 -0
- package/dist/os/rfc/evidence-annotation.d.ts.map +1 -0
- package/dist/os/rfc/evidence-annotation.js +52 -0
- package/dist/os/rfc/evidence-annotation.js.map +1 -0
- package/dist/os/rfc/handlers/fixed-inputs.d.ts.map +1 -1
- package/dist/os/rfc/handlers/fixed-inputs.js +7 -1
- package/dist/os/rfc/handlers/fixed-inputs.js.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
- package/dist/os/rfc/handlers/implement-stamp.js +21 -28
- package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
- package/dist/os/rfc/handlers/validate-rules.js +127 -7
- package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
- package/dist/os/rfc/rfc.module.d.ts.map +1 -1
- package/dist/os/rfc/rfc.module.js +3 -2
- package/dist/os/rfc/rfc.module.js.map +1 -1
- package/dist/src/cli-flags.d.ts.map +1 -1
- package/dist/src/cli-flags.js +6 -0
- package/dist/src/cli-flags.js.map +1 -1
- package/dist/src/types.d.ts +7 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +2 -8
- package/dist/src/types.js.map +1 -1
- package/os/flow/dirty-classify.ts +13 -0
- package/os/flow/flow.module.ts +3 -2
- package/os/flow/handlers/flow-check.ts +17 -18
- package/os/flow/handlers/flow-integrate.ts +75 -35
- package/os/flow/handlers/flow-open.ts +24 -31
- package/os/flow/index.ts +5 -7
- package/os/flow/preflight.ts +351 -9
- package/os/flow/tests/flow-integrate.preflight.test.ts +26 -5
- package/os/flow/tests/flow-integrate.test.ts +68 -2
- package/os/flow/tests/lockfile-induced.test.ts +328 -0
- package/os/gate-run/detach.ts +106 -0
- package/os/gate-run/gate-run.module.ts +25 -0
- package/os/gate-run/index.ts +16 -0
- package/os/gate-run/record.ts +194 -0
- package/os/gate-run/status.ts +168 -0
- package/os/gate-run/tests/gate-run-detach.test.ts +144 -0
- package/os/gate-run/tests/gate-run-record.test.ts +200 -0
- package/os/gate-run/types.ts +73 -0
- package/os/rfc/evidence-annotation.ts +61 -0
- package/os/rfc/handlers/fixed-inputs.test.ts +70 -0
- package/os/rfc/handlers/fixed-inputs.ts +11 -1
- package/os/rfc/handlers/implement-stamp.ts +25 -28
- package/os/rfc/handlers/list-create.test.ts +14 -5
- package/os/rfc/handlers/validate-evidence-shape.test.ts +218 -0
- package/os/rfc/handlers/validate-probe-meta.test.ts +71 -0
- package/os/rfc/handlers/validate-rules.ts +169 -17
- package/os/rfc/handlers/validate-transient-probes.test.ts +222 -0
- package/os/rfc/rfc-0000-template.md +10 -10
- package/os/rfc/rfc.module.ts +3 -2
- package/package.json +17 -1
- package/skills/fo/fo-session-retro/SKILL.md +4 -2
- package/src/cli-flags.ts +7 -0
- package/src/types.ts +9 -8
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1569 — V-50 containment compares each fixed-input literal
|
|
4
|
+
against the regex-UNESCAPED probe pattern (escaped metachar literals keep
|
|
5
|
+
coverage).</purpose>
|
|
6
|
+
<non-goals>
|
|
7
|
+
<item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
|
|
8
|
+
</non-goals>
|
|
9
|
+
</MODULE_CONTRACT>
|
|
10
|
+
<CHANGE_SUMMARY>
|
|
11
|
+
<item>RFC-1569: V-50 unescape-before-containment tests (AC-9)</item>
|
|
12
|
+
<item>RFC-1569: lint rfc evidence annotations and transient probe targets</item>
|
|
13
|
+
</CHANGE_SUMMARY>
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { test, expect, describe } from "vitest";
|
|
17
|
+
import { evaluateFixedInputs } from "./fixed-inputs.ts";
|
|
18
|
+
|
|
19
|
+
const body = (value: string): string =>
|
|
20
|
+
`## Fixed inputs\n\n| ID | Value | Source | Checked by |\n| --- | --- | --- | --- |\n| FI-1 | ${value} | decision | AC-1 |\n`;
|
|
21
|
+
|
|
22
|
+
describe("V-50: regex-unescaped containment (RFC-1569)", () => {
|
|
23
|
+
test("AC-9: escaped \\$\\{WORKSPACE_ROOT\\} pattern covers the literal", () => {
|
|
24
|
+
const diags = evaluateFixedInputs(
|
|
25
|
+
body("`${WORKSPACE_ROOT}`"),
|
|
26
|
+
["AC-1"],
|
|
27
|
+
[
|
|
28
|
+
{
|
|
29
|
+
probe: "file-contains",
|
|
30
|
+
criterion: "AC-1",
|
|
31
|
+
path: "x",
|
|
32
|
+
pattern: "\\$\\{WORKSPACE_ROOT\\}",
|
|
33
|
+
} as never,
|
|
34
|
+
],
|
|
35
|
+
);
|
|
36
|
+
expect(diags.filter((d) => d.message.includes("not contained"))).toEqual([]);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("unescaped metachars in a literal still report uncovered", () => {
|
|
40
|
+
const diags = evaluateFixedInputs(
|
|
41
|
+
body("`${WORKSPACE_ROOT}`"),
|
|
42
|
+
["AC-1"],
|
|
43
|
+
[
|
|
44
|
+
{
|
|
45
|
+
probe: "file-contains",
|
|
46
|
+
criterion: "AC-1",
|
|
47
|
+
path: "x",
|
|
48
|
+
pattern: "literal plain text",
|
|
49
|
+
} as never,
|
|
50
|
+
],
|
|
51
|
+
);
|
|
52
|
+
expect(diags.some((d) => d.message.includes("not contained"))).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("dotted literal covered by escaped a\\.b pattern", () => {
|
|
56
|
+
const diags = evaluateFixedInputs(
|
|
57
|
+
body("`a.b`"),
|
|
58
|
+
["AC-1"],
|
|
59
|
+
[
|
|
60
|
+
{
|
|
61
|
+
probe: "file-contains",
|
|
62
|
+
criterion: "AC-1",
|
|
63
|
+
path: "x",
|
|
64
|
+
pattern: "a\\.b",
|
|
65
|
+
} as never,
|
|
66
|
+
],
|
|
67
|
+
);
|
|
68
|
+
expect(diags.filter((d) => d.message.includes("not contained"))).toEqual([]);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -17,6 +17,7 @@ warning nudge. All functions are pure — no I/O.
|
|
|
17
17
|
<CHANGE_SUMMARY>
|
|
18
18
|
<item>RFC-1455: fixed-inputs section parser + V-50/V-51 evaluator for rfc.validate.</item>
|
|
19
19
|
<item>RFC-1455: fixed inputs bound to outcome probes — V-50/V-51 + skills</item>
|
|
20
|
+
<item>RFC-1569: lint rfc evidence annotations and transient probe targets</item>
|
|
20
21
|
</CHANGE_SUMMARY>
|
|
21
22
|
*/
|
|
22
23
|
|
|
@@ -235,8 +236,17 @@ export function evaluateFixedInputs(
|
|
|
235
236
|
}
|
|
236
237
|
|
|
237
238
|
const literals = fixedInputLiterals(row.value);
|
|
239
|
+
// RFC-1569: compare against the regex-UNESCAPED pattern too — a literal
|
|
240
|
+
// carrying metacharacters (${WORKSPACE_ROOT}) cannot be both escaped in
|
|
241
|
+
// the pattern and contained verbatim; `\d`/`\w` shorthand keeps its
|
|
242
|
+
// backslash (unescaping it would fake coverage for single-char literals).
|
|
243
|
+
const unescapePattern = (field: string): string =>
|
|
244
|
+
field.replace(/\\([.*+?^${}()|[\]\\])/g, "$1");
|
|
238
245
|
const uncovered = literals.filter(
|
|
239
|
-
(literal) =>
|
|
246
|
+
(literal) =>
|
|
247
|
+
!outcomeFields.some(
|
|
248
|
+
(field) => field.includes(literal) || unescapePattern(field).includes(literal),
|
|
249
|
+
),
|
|
240
250
|
);
|
|
241
251
|
if (uncovered.length > 0) {
|
|
242
252
|
diagnostics.push({
|
|
@@ -12,12 +12,12 @@ verification evidence, and atomically mutates RFC frontmatter.
|
|
|
12
12
|
</non-goals>
|
|
13
13
|
</MODULE_CONTRACT>
|
|
14
14
|
<CHANGE_SUMMARY>
|
|
15
|
-
<item>RFC-1454: review deviations recorded in the RFC — IMP-15 gate, V-49 provenance, skill contract</item>
|
|
16
15
|
<item>RFC-1483: self-sufficient implement stamp — default repair pass, ordered remediation checklist, --no-repair</item>
|
|
17
16
|
<item>RFC-1504: step 4 — shared stamp lock for rfc and adr stamp handlers</item>
|
|
18
17
|
<item>RFC-1504: review fixes — legacy acquiredAt fallback, atomic break claim, verified stamp release, onStale warnings</item>
|
|
19
18
|
<item>RFC-1516: add an evidence-freshness window to the stamp-sync chain for rfc-1516</item>
|
|
20
|
-
<
|
|
19
|
+
<item>RFC-1569: lint rfc evidence annotations and transient probe targets</item>
|
|
20
|
+
<history>RFC-0268, RFC-0476, RFC-0756, RFC-0795, RFC-0997, RFC-1053, RFC-1097, RFC-1249, RFC-1271, RFC-1306, RFC-1310, RFC-1321, RFC-1322, RFC-1330, RFC-1333, RFC-1383, RFC-1391, RFC-1453, RFC-1454, RFC-IMP-07</history>
|
|
21
21
|
</CHANGE_SUMMARY>
|
|
22
22
|
*/
|
|
23
23
|
|
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
loadRfcStatusMap,
|
|
41
41
|
} from "../frontmatter-io.ts";
|
|
42
42
|
import { evaluateAcceptanceCriteria, stripFencedCodeBlocks } from "./validate-rules.ts";
|
|
43
|
+
import { parseEvidenceAnnotation } from "../evidence-annotation.ts";
|
|
43
44
|
import { evaluateDeviationGate } from "./implement-stamp-deviations.ts";
|
|
44
45
|
import { toIsoDate } from "./shared.ts";
|
|
45
46
|
import { byteHashHex, normalizeProbes, runRfcVerificationEmit } from "../verification-evidence.ts";
|
|
@@ -388,23 +389,21 @@ export async function resolveCriterionEvidence(
|
|
|
388
389
|
return false;
|
|
389
390
|
}
|
|
390
391
|
};
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
return statFile(filePath);
|
|
392
|
+
// RFC-1569: the annotation grammar lives in os/rfc/evidence-annotation.ts —
|
|
393
|
+
// this resolver consumes it, no second regex here.
|
|
394
|
+
const parsed = parseEvidenceAnnotation(annotation);
|
|
395
|
+
switch (parsed.kind) {
|
|
396
|
+
case "probe":
|
|
397
|
+
return (envelope?.probes ?? []).some(
|
|
398
|
+
(r) => r.probe?.criterion === parsed.criterion && r.ok === true,
|
|
399
|
+
);
|
|
400
|
+
case "test":
|
|
401
|
+
case "file":
|
|
402
|
+
case "path-line":
|
|
403
|
+
return statFile(parsed.path);
|
|
404
|
+
case "invalid":
|
|
405
|
+
return false;
|
|
406
406
|
}
|
|
407
|
-
return false;
|
|
408
407
|
}
|
|
409
408
|
|
|
410
409
|
/**
|
|
@@ -556,7 +555,11 @@ async function evaluateStampEvidenceGates(opts: {
|
|
|
556
555
|
// ── RFC-IMP-10 / RFC-IMP-11: git-derived origin gates (RFC-1330) ─────────
|
|
557
556
|
// Derived fresh at stamp time (head = HEAD) — the committed envelope's
|
|
558
557
|
// origin records are volatile context and may predate later commits.
|
|
559
|
-
if (
|
|
558
|
+
if (
|
|
559
|
+
runIndependent &&
|
|
560
|
+
hasProbes &&
|
|
561
|
+
String(opts.frontmatter["createdAt"] ?? "") >= RFC_ORIGIN_CUTOFF
|
|
562
|
+
) {
|
|
560
563
|
const probes = acceptance as AcceptanceProbe[];
|
|
561
564
|
const origins = await deriveProbeOrigins({
|
|
562
565
|
git: createOriginGit(opts.workspaceRoot),
|
|
@@ -899,9 +902,7 @@ export async function runRfcImplementStamp(
|
|
|
899
902
|
// sync chain — probes re-execute even inside the freshness window.
|
|
900
903
|
syncReport = await context.invoke("rfc.evidence.sync", {
|
|
901
904
|
id: targetId,
|
|
902
|
-
...(input.flags["no-evidence-reuse"] === true
|
|
903
|
-
? { "no-evidence-reuse": "true" }
|
|
904
|
-
: {}),
|
|
905
|
+
...(input.flags["no-evidence-reuse"] === true ? { "no-evidence-reuse": "true" } : {}),
|
|
905
906
|
});
|
|
906
907
|
} catch (err) {
|
|
907
908
|
violations.push({
|
|
@@ -1238,9 +1239,7 @@ export async function runRfcImplementStamp(
|
|
|
1238
1239
|
flags: {
|
|
1239
1240
|
id: targetId,
|
|
1240
1241
|
...(waiveOutcome ? { "waive-outcome": waiveOutcome } : {}),
|
|
1241
|
-
...(input.flags["no-evidence-reuse"] === true
|
|
1242
|
-
? { "no-evidence-reuse": true }
|
|
1243
|
-
: {}),
|
|
1242
|
+
...(input.flags["no-evidence-reuse"] === true ? { "no-evidence-reuse": true } : {}),
|
|
1244
1243
|
},
|
|
1245
1244
|
},
|
|
1246
1245
|
context,
|
|
@@ -1459,9 +1458,7 @@ export async function runRfcImplementStamp(
|
|
|
1459
1458
|
flags: {
|
|
1460
1459
|
id: targetId,
|
|
1461
1460
|
...(waiveOutcome ? { "waive-outcome": waiveOutcome } : {}),
|
|
1462
|
-
...(input.flags["no-evidence-reuse"] === true
|
|
1463
|
-
? { "no-evidence-reuse": true }
|
|
1464
|
-
: {}),
|
|
1461
|
+
...(input.flags["no-evidence-reuse"] === true ? { "no-evidence-reuse": true } : {}),
|
|
1465
1462
|
},
|
|
1466
1463
|
},
|
|
1467
1464
|
context,
|
|
@@ -12,11 +12,12 @@ with candidates listed.
|
|
|
12
12
|
</non-goals>
|
|
13
13
|
</MODULE_CONTRACT>
|
|
14
14
|
<CHANGE_SUMMARY>
|
|
15
|
-
<item>RFC-1485: sweep compass headers — forge-os-rfc</item>
|
|
16
15
|
<item>RFC-1482: extract-safe RFC-1482 template path + changelog for 9.1.0</item>
|
|
17
16
|
<item>RFC-1514: attach corrected invocations to blocking diagnostics so retry is one-shot</item>
|
|
18
17
|
<item>RFC-1534: lint probe patterns, sync amends counterparts, name next free ledger id</item>
|
|
19
18
|
<item>RFC-1546: derive-and-repair recoverable state across flow surfaces (AC-1..AC-5)</item>
|
|
19
|
+
<item>RFC-1569: lint rfc evidence annotations and transient probe targets</item>
|
|
20
|
+
<history>RFC-1485</history>
|
|
20
21
|
</CHANGE_SUMMARY>
|
|
21
22
|
*/
|
|
22
23
|
|
|
@@ -187,7 +188,7 @@ describe("RFC-1482 validation-compliant skeleton", () => {
|
|
|
187
188
|
await rm(root, { recursive: true, force: true });
|
|
188
189
|
});
|
|
189
190
|
|
|
190
|
-
test("AC-1: emitted draft passes rfc.validate with zero V-45/V-48/V-50 violations", async () => {
|
|
191
|
+
test("AC-1: emitted draft passes rfc.validate with zero V-45/V-48/V-50/V-53/V-54 violations", async () => {
|
|
191
192
|
const result = await runRfcCreate(
|
|
192
193
|
{ flags: flags({ title: "Rotate the cache eviction cadence" }) } as never,
|
|
193
194
|
context(),
|
|
@@ -196,14 +197,22 @@ describe("RFC-1482 validation-compliant skeleton", () => {
|
|
|
196
197
|
const id = result.data!.id!;
|
|
197
198
|
const v = await runRfcValidate({ argv: [], flags: { id } } as never, context());
|
|
198
199
|
const violations = v.data?.violations ?? [];
|
|
199
|
-
const named = violations.filter((x) =>
|
|
200
|
+
const named = violations.filter((x) =>
|
|
201
|
+
["V-45", "V-48", "V-50", "V-53", "V-54"].includes(x.rule),
|
|
202
|
+
);
|
|
200
203
|
expect(named, JSON.stringify(violations, null, 1)).toEqual([]);
|
|
201
204
|
expect(v.data?.status, JSON.stringify(violations, null, 1)).toBe("pass");
|
|
202
205
|
});
|
|
203
206
|
|
|
204
207
|
test("AC-2: --proposed/--added seed commands.* and emit one reachable stub each", async () => {
|
|
205
208
|
const result = await runRfcCreate(
|
|
206
|
-
{
|
|
209
|
+
{
|
|
210
|
+
flags: flags({
|
|
211
|
+
title: "Tame the registry loader",
|
|
212
|
+
proposed: "foo.bar,baz.qux",
|
|
213
|
+
added: "foo.new",
|
|
214
|
+
}),
|
|
215
|
+
} as never,
|
|
207
216
|
context(),
|
|
208
217
|
);
|
|
209
218
|
expect(result.data?.status).toBe("ok");
|
|
@@ -224,7 +233,7 @@ describe("RFC-1482 validation-compliant skeleton", () => {
|
|
|
224
233
|
);
|
|
225
234
|
const body = await readFile(join(root, result.data!.file!), "utf8");
|
|
226
235
|
expect(body).toContain("## Fixed inputs");
|
|
227
|
-
expect(body).
|
|
236
|
+
expect(body).toMatch(/\|\s*ID\s*\| Value \| Source \| Checked by \|/);
|
|
228
237
|
expect(body).not.toMatch(/^\|\s*FI-/m);
|
|
229
238
|
});
|
|
230
239
|
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1569 V-53 — evidence-annotation shape lint on every criterion
|
|
4
|
+
line, plus parseEvidenceAnnotation exhaustiveness over the stamp's grammar.</purpose>
|
|
5
|
+
<non-goals>
|
|
6
|
+
<item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
|
|
7
|
+
</non-goals>
|
|
8
|
+
</MODULE_CONTRACT>
|
|
9
|
+
<CHANGE_SUMMARY>
|
|
10
|
+
<item>RFC-1569: V-53 rule tests + shared-parser exhaustiveness (AC-1, AC-2, AC-3)</item>
|
|
11
|
+
<item>RFC-1569: lint rfc evidence annotations and transient probe targets</item>
|
|
12
|
+
</CHANGE_SUMMARY>
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { test, expect, describe } from "vitest";
|
|
16
|
+
import { validateSingleRfc, type AddViolationFn } from "./validate-rules.ts";
|
|
17
|
+
import { parseEvidenceAnnotation } from "../evidence-annotation.ts";
|
|
18
|
+
import type { ParsedRfc } from "../frontmatter-io.ts";
|
|
19
|
+
import { join } from "node:path";
|
|
20
|
+
import { tmpdir } from "node:os";
|
|
21
|
+
|
|
22
|
+
const testWorkspace = join(tmpdir(), "test-workspace-rfc1569-v53");
|
|
23
|
+
|
|
24
|
+
function makeParsed(
|
|
25
|
+
status: string,
|
|
26
|
+
body: string,
|
|
27
|
+
extraFm: Record<string, unknown> = {},
|
|
28
|
+
): ParsedRfc {
|
|
29
|
+
return {
|
|
30
|
+
frontmatter: {
|
|
31
|
+
id: "RFC-9999",
|
|
32
|
+
title: "Test RFC",
|
|
33
|
+
status,
|
|
34
|
+
kind: "command",
|
|
35
|
+
scope: "workspace",
|
|
36
|
+
owners: ["architecture"],
|
|
37
|
+
createdAt: "2026-09-01",
|
|
38
|
+
updatedAt: "2026-09-01",
|
|
39
|
+
...extraFm,
|
|
40
|
+
},
|
|
41
|
+
body,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const BASE_BODY = `
|
|
46
|
+
# RFC-9999: Test RFC
|
|
47
|
+
|
|
48
|
+
## Context
|
|
49
|
+
|
|
50
|
+
Test context.
|
|
51
|
+
|
|
52
|
+
## Problem
|
|
53
|
+
|
|
54
|
+
Test problem.
|
|
55
|
+
|
|
56
|
+
## Decision
|
|
57
|
+
|
|
58
|
+
Test decision.
|
|
59
|
+
|
|
60
|
+
## Architectural fit
|
|
61
|
+
|
|
62
|
+
Test fit.
|
|
63
|
+
|
|
64
|
+
## Design
|
|
65
|
+
|
|
66
|
+
### CLI surface
|
|
67
|
+
|
|
68
|
+
Test CLI.
|
|
69
|
+
|
|
70
|
+
### TypeScript contracts
|
|
71
|
+
|
|
72
|
+
Test types.
|
|
73
|
+
|
|
74
|
+
### File system responsibilities
|
|
75
|
+
|
|
76
|
+
| Path | Role |
|
|
77
|
+
|---|---|
|
|
78
|
+
| \`test.ts\` | test |
|
|
79
|
+
|
|
80
|
+
### Output format
|
|
81
|
+
|
|
82
|
+
Test output.
|
|
83
|
+
|
|
84
|
+
### Failure modes
|
|
85
|
+
|
|
86
|
+
Test failures.
|
|
87
|
+
|
|
88
|
+
## Rollout
|
|
89
|
+
|
|
90
|
+
Test rollout.
|
|
91
|
+
|
|
92
|
+
## Alternatives considered
|
|
93
|
+
|
|
94
|
+
Test alternatives.
|
|
95
|
+
|
|
96
|
+
## Risks
|
|
97
|
+
|
|
98
|
+
Test risks.
|
|
99
|
+
|
|
100
|
+
## Acceptance criteria
|
|
101
|
+
|
|
102
|
+
ACCEPTANCE_HERE
|
|
103
|
+
|
|
104
|
+
## Implementation notes for agents
|
|
105
|
+
|
|
106
|
+
Test notes.
|
|
107
|
+
`;
|
|
108
|
+
|
|
109
|
+
async function runValidate(
|
|
110
|
+
parsed: ParsedRfc,
|
|
111
|
+
): Promise<{ rfcId: string; rule: string; message: string; severity: string }[]> {
|
|
112
|
+
const violations: { rfcId: string; rule: string; message: string; severity: string }[] = [];
|
|
113
|
+
const add: AddViolationFn = (rfcId, _file, rule, message, severity = "error") => {
|
|
114
|
+
violations.push({ rfcId, rule, message, severity });
|
|
115
|
+
};
|
|
116
|
+
await validateSingleRfc(
|
|
117
|
+
"rfc-9999-test.md",
|
|
118
|
+
parsed,
|
|
119
|
+
new Map(),
|
|
120
|
+
new Map(),
|
|
121
|
+
new Set(),
|
|
122
|
+
new Set(),
|
|
123
|
+
new Set(Object.keys(parsed.frontmatter)),
|
|
124
|
+
testWorkspace,
|
|
125
|
+
add,
|
|
126
|
+
);
|
|
127
|
+
return violations;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const PROSE_ANNOTATION =
|
|
131
|
+
"- [ ] AC-1: renders the hero (evidence: probe:AC-2 renders the hero)\n- [ ] AC-2: exits zero\n";
|
|
132
|
+
|
|
133
|
+
describe("V-53: evidence annotation shape (RFC-1569)", () => {
|
|
134
|
+
test("AC-1: unchecked criterion with prose annotation reports warning on a draft", async () => {
|
|
135
|
+
const violations = await runValidate(
|
|
136
|
+
makeParsed("draft", BASE_BODY.replace("ACCEPTANCE_HERE", PROSE_ANNOTATION)),
|
|
137
|
+
);
|
|
138
|
+
const v53 = violations.filter((v) => v.rule === "V-53");
|
|
139
|
+
expect(v53.length).toBeGreaterThan(0);
|
|
140
|
+
expect(v53.every((v) => v.severity === "warning")).toBe(true);
|
|
141
|
+
expect(v53[0]!.message).toContain("STAMP-CHECK-01");
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
test("AC-2: the same annotation on an accepted RFC reports error", async () => {
|
|
145
|
+
const violations = await runValidate(
|
|
146
|
+
makeParsed("accepted", BASE_BODY.replace("ACCEPTANCE_HERE", PROSE_ANNOTATION)),
|
|
147
|
+
);
|
|
148
|
+
const v53 = violations.filter((v) => v.rule === "V-53");
|
|
149
|
+
expect(v53.length).toBeGreaterThan(0);
|
|
150
|
+
expect(v53.every((v) => v.severity === "error")).toBe(true);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test("resolvable forms produce no V-53", async () => {
|
|
154
|
+
const acceptance = [
|
|
155
|
+
"- [ ] AC-1: c (evidence: test:packages/forge/x.test.ts)",
|
|
156
|
+
"- [ ] AC-2: c (evidence: file:packages/forge/x.ts)",
|
|
157
|
+
"- [ ] AC-3: c (evidence: file:packages/forge/x.ts:12-15)",
|
|
158
|
+
"- [ ] AC-4: c (evidence: packages/forge/x.ts:42)",
|
|
159
|
+
"- [ ] AC-5: c (evidence: probe:design:shared-grammar)",
|
|
160
|
+
].join("\n");
|
|
161
|
+
const violations = await runValidate(
|
|
162
|
+
makeParsed("draft", BASE_BODY.replace("ACCEPTANCE_HERE", acceptance), {
|
|
163
|
+
acceptance: [
|
|
164
|
+
{
|
|
165
|
+
probe: "file-contains",
|
|
166
|
+
criterion: "design:shared-grammar",
|
|
167
|
+
path: "x",
|
|
168
|
+
pattern: "y",
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
}),
|
|
172
|
+
);
|
|
173
|
+
expect(violations.filter((v) => v.rule === "V-53")).toEqual([]);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
test("probe annotation naming a missing criterion reports V-53", async () => {
|
|
177
|
+
const acceptance = "- [ ] AC-1: c (evidence: probe:AC-9)\n- [ ] AC-2: c (evidence: file:x.ts)";
|
|
178
|
+
const violations = await runValidate(
|
|
179
|
+
makeParsed("draft", BASE_BODY.replace("ACCEPTANCE_HERE", acceptance)),
|
|
180
|
+
);
|
|
181
|
+
const v53 = violations.filter((v) => v.rule === "V-53");
|
|
182
|
+
expect(v53.some((v) => v.message.includes("probe:AC-9"))).toBe(true);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
describe("AC-3: parseEvidenceAnnotation exhaustiveness (RFC-1569)", () => {
|
|
187
|
+
const resolvable: [string, string][] = [
|
|
188
|
+
["probe:AC-1", "probe"],
|
|
189
|
+
["probe:AC-12", "probe"],
|
|
190
|
+
["probe: design:shared-grammar", "probe"],
|
|
191
|
+
["test:packages/forge/x.test.ts", "test"],
|
|
192
|
+
["test: packages/forge/x.test.ts", "test"],
|
|
193
|
+
["file:packages/forge/x.ts", "file"],
|
|
194
|
+
["file:packages/forge/x.ts:12", "file"],
|
|
195
|
+
["file:packages/forge/x.ts:12-15", "file"],
|
|
196
|
+
["packages/forge/x.ts:42", "path-line"],
|
|
197
|
+
["packages/forge/x.ts:42-50", "path-line"],
|
|
198
|
+
];
|
|
199
|
+
for (const [raw, kind] of resolvable) {
|
|
200
|
+
test(`accepts "${raw}" as ${kind}`, () => {
|
|
201
|
+
const parsed = parseEvidenceAnnotation(raw);
|
|
202
|
+
expect(parsed.kind).toBe(kind);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
const unresolvable = [
|
|
206
|
+
"probe:AC-2 renders the hero",
|
|
207
|
+
"probe:AC-1 or test: <path>",
|
|
208
|
+
"test:",
|
|
209
|
+
"file: <module-path> with prose",
|
|
210
|
+
"",
|
|
211
|
+
"anything else",
|
|
212
|
+
];
|
|
213
|
+
for (const raw of unresolvable) {
|
|
214
|
+
test(`rejects "${raw}"`, () => {
|
|
215
|
+
expect(parseEvidenceAnnotation(raw).kind).toBe("invalid");
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>RFC-1569 — V-PROBE-META-01 extension: mid-pattern anchors and
|
|
4
|
+
unescaped brace/bracket arms over collectProbeMetacharHits.</purpose>
|
|
5
|
+
<non-goals>
|
|
6
|
+
<item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
|
|
7
|
+
</non-goals>
|
|
8
|
+
</MODULE_CONTRACT>
|
|
9
|
+
<CHANGE_SUMMARY>
|
|
10
|
+
<item>RFC-1569: metachar extension tests (AC-8) + suppression regression</item>
|
|
11
|
+
<item>RFC-1569: lint rfc evidence annotations and transient probe targets</item>
|
|
12
|
+
</CHANGE_SUMMARY>
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { test, expect, describe } from "vitest";
|
|
16
|
+
import { collectProbeMetacharHits } from "./validate-rules.ts";
|
|
17
|
+
|
|
18
|
+
const fm = (pattern: string): string =>
|
|
19
|
+
`acceptance:\n - probe: file-contains\n criterion: AC-1\n path: x\n pattern: "${pattern}"\n`;
|
|
20
|
+
|
|
21
|
+
const probe = (pattern: string) => [
|
|
22
|
+
{ probe: "file-contains", criterion: "AC-1", path: "x", pattern },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
describe("V-PROBE-META-01 extensions (RFC-1569)", () => {
|
|
26
|
+
test("AC-8: mid-pattern unescaped $ is flagged", () => {
|
|
27
|
+
const hits = collectProbeMetacharHits(probe("${WORKSPACE_ROOT}"), fm(""));
|
|
28
|
+
expect(hits.some((h) => h.chars.some((c) => c.includes("`$`")))).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("leading ^ and trailing $ anchors stay clean", () => {
|
|
32
|
+
const hits = collectProbeMetacharHits(probe("^hero end$"), fm(""));
|
|
33
|
+
expect(hits).toEqual([]);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("mid-pattern unescaped ^ is flagged", () => {
|
|
37
|
+
const hits = collectProbeMetacharHits(probe("a^b"), fm(""));
|
|
38
|
+
expect(hits.some((h) => h.chars.some((c) => c.includes("`^`")))).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("escaped \\$ and \\^ stay clean", () => {
|
|
42
|
+
const hits = collectProbeMetacharHits(probe("a\\$b\\^c"), fm(""));
|
|
43
|
+
expect(hits).toEqual([]);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("unescaped {} and [] are flagged", () => {
|
|
47
|
+
const brace = collectProbeMetacharHits(probe("a{1,2}"), fm(""));
|
|
48
|
+
expect(brace.some((h) => h.chars.some((c) => c.includes("`{`/`}`")))).toBe(true);
|
|
49
|
+
const bracket = collectProbeMetacharHits(probe("a[bc]"), fm(""));
|
|
50
|
+
expect(bracket.some((h) => h.chars.some((c) => c.includes("`[`/`]`")))).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("escaped \\{\\} and \\[\\] stay clean", () => {
|
|
54
|
+
const hits = collectProbeMetacharHits(probe("a\\{1\\}b\\[x\\]"), fm(""));
|
|
55
|
+
expect(hits).toEqual([]);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("suggestion escapes the newly flagged characters", () => {
|
|
59
|
+
const hits = collectProbeMetacharHits(probe("a{b}c[d]e$f"), fm(""));
|
|
60
|
+
const s = hits[0]?.suggestion ?? "";
|
|
61
|
+
expect(s).not.toMatch(/(?<!\\)[{[\]]/);
|
|
62
|
+
expect(s).toContain("\\$");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("probe-meta: intentional marker still suppresses", () => {
|
|
66
|
+
const pattern = "${WORKSPACE_ROOT}";
|
|
67
|
+
const fmWithMarker = `acceptance:\n - probe: file-contains\n criterion: AC-1\n path: x\n pattern: "${pattern}" # <!-- probe-meta: intentional -->\n`;
|
|
68
|
+
const hits = collectProbeMetacharHits(probe(pattern), fmWithMarker);
|
|
69
|
+
expect(hits).toEqual([]);
|
|
70
|
+
});
|
|
71
|
+
});
|