@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.
Files changed (109) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/bin/cli.ts +152 -11
  3. package/dist/bin/cli.js +125 -5
  4. package/dist/bin/cli.js.map +1 -1
  5. package/dist/os/flow/dirty-classify.d.ts +7 -0
  6. package/dist/os/flow/dirty-classify.d.ts.map +1 -1
  7. package/dist/os/flow/dirty-classify.js +11 -0
  8. package/dist/os/flow/dirty-classify.js.map +1 -1
  9. package/dist/os/flow/flow.module.d.ts.map +1 -1
  10. package/dist/os/flow/flow.module.js +3 -2
  11. package/dist/os/flow/flow.module.js.map +1 -1
  12. package/dist/os/flow/handlers/flow-check.d.ts.map +1 -1
  13. package/dist/os/flow/handlers/flow-check.js +9 -9
  14. package/dist/os/flow/handlers/flow-check.js.map +1 -1
  15. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
  16. package/dist/os/flow/handlers/flow-integrate.js +59 -26
  17. package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
  18. package/dist/os/flow/handlers/flow-open.d.ts.map +1 -1
  19. package/dist/os/flow/handlers/flow-open.js +14 -19
  20. package/dist/os/flow/handlers/flow-open.js.map +1 -1
  21. package/dist/os/flow/index.d.ts +1 -0
  22. package/dist/os/flow/index.d.ts.map +1 -1
  23. package/dist/os/flow/index.js +5 -3
  24. package/dist/os/flow/index.js.map +1 -1
  25. package/dist/os/flow/preflight.d.ts +24 -0
  26. package/dist/os/flow/preflight.d.ts.map +1 -1
  27. package/dist/os/flow/preflight.js +354 -10
  28. package/dist/os/flow/preflight.js.map +1 -1
  29. package/dist/os/flow/registry.d.ts +2 -2
  30. package/dist/os/gate-run/detach.d.ts +27 -0
  31. package/dist/os/gate-run/detach.d.ts.map +1 -0
  32. package/dist/os/gate-run/detach.js +85 -0
  33. package/dist/os/gate-run/detach.js.map +1 -0
  34. package/dist/os/gate-run/gate-run.module.d.ts +3 -0
  35. package/dist/os/gate-run/gate-run.module.d.ts.map +1 -0
  36. package/dist/os/gate-run/gate-run.module.js +23 -0
  37. package/dist/os/gate-run/gate-run.module.js.map +1 -0
  38. package/dist/os/gate-run/index.d.ts +7 -0
  39. package/dist/os/gate-run/index.d.ts.map +1 -0
  40. package/dist/os/gate-run/index.js +5 -0
  41. package/dist/os/gate-run/index.js.map +1 -0
  42. package/dist/os/gate-run/record.d.ts +47 -0
  43. package/dist/os/gate-run/record.d.ts.map +1 -0
  44. package/dist/os/gate-run/record.js +157 -0
  45. package/dist/os/gate-run/record.js.map +1 -0
  46. package/dist/os/gate-run/status.d.ts +41 -0
  47. package/dist/os/gate-run/status.d.ts.map +1 -0
  48. package/dist/os/gate-run/status.js +142 -0
  49. package/dist/os/gate-run/status.js.map +1 -0
  50. package/dist/os/gate-run/types.d.ts +47 -0
  51. package/dist/os/gate-run/types.d.ts.map +1 -0
  52. package/dist/os/gate-run/types.js +24 -0
  53. package/dist/os/gate-run/types.js.map +1 -0
  54. package/dist/os/rfc/evidence-annotation.d.ts +26 -0
  55. package/dist/os/rfc/evidence-annotation.d.ts.map +1 -0
  56. package/dist/os/rfc/evidence-annotation.js +52 -0
  57. package/dist/os/rfc/evidence-annotation.js.map +1 -0
  58. package/dist/os/rfc/handlers/fixed-inputs.d.ts.map +1 -1
  59. package/dist/os/rfc/handlers/fixed-inputs.js +7 -1
  60. package/dist/os/rfc/handlers/fixed-inputs.js.map +1 -1
  61. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  62. package/dist/os/rfc/handlers/implement-stamp.js +21 -28
  63. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  64. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  65. package/dist/os/rfc/handlers/validate-rules.js +127 -7
  66. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  67. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  68. package/dist/os/rfc/rfc.module.js +3 -2
  69. package/dist/os/rfc/rfc.module.js.map +1 -1
  70. package/dist/src/cli-flags.d.ts.map +1 -1
  71. package/dist/src/cli-flags.js +6 -0
  72. package/dist/src/cli-flags.js.map +1 -1
  73. package/dist/src/types.d.ts +7 -0
  74. package/dist/src/types.d.ts.map +1 -1
  75. package/dist/src/types.js +2 -8
  76. package/dist/src/types.js.map +1 -1
  77. package/os/flow/dirty-classify.ts +13 -0
  78. package/os/flow/flow.module.ts +3 -2
  79. package/os/flow/handlers/flow-check.ts +17 -18
  80. package/os/flow/handlers/flow-integrate.ts +75 -35
  81. package/os/flow/handlers/flow-open.ts +24 -31
  82. package/os/flow/index.ts +5 -7
  83. package/os/flow/preflight.ts +351 -9
  84. package/os/flow/tests/flow-integrate.preflight.test.ts +26 -5
  85. package/os/flow/tests/flow-integrate.test.ts +68 -2
  86. package/os/flow/tests/lockfile-induced.test.ts +328 -0
  87. package/os/gate-run/detach.ts +106 -0
  88. package/os/gate-run/gate-run.module.ts +25 -0
  89. package/os/gate-run/index.ts +16 -0
  90. package/os/gate-run/record.ts +194 -0
  91. package/os/gate-run/status.ts +168 -0
  92. package/os/gate-run/tests/gate-run-detach.test.ts +144 -0
  93. package/os/gate-run/tests/gate-run-record.test.ts +200 -0
  94. package/os/gate-run/types.ts +73 -0
  95. package/os/rfc/evidence-annotation.ts +61 -0
  96. package/os/rfc/handlers/fixed-inputs.test.ts +70 -0
  97. package/os/rfc/handlers/fixed-inputs.ts +11 -1
  98. package/os/rfc/handlers/implement-stamp.ts +25 -28
  99. package/os/rfc/handlers/list-create.test.ts +14 -5
  100. package/os/rfc/handlers/validate-evidence-shape.test.ts +218 -0
  101. package/os/rfc/handlers/validate-probe-meta.test.ts +71 -0
  102. package/os/rfc/handlers/validate-rules.ts +169 -17
  103. package/os/rfc/handlers/validate-transient-probes.test.ts +222 -0
  104. package/os/rfc/rfc-0000-template.md +10 -10
  105. package/os/rfc/rfc.module.ts +3 -2
  106. package/package.json +17 -1
  107. package/skills/fo/fo-session-retro/SKILL.md +4 -2
  108. package/src/cli-flags.ts +7 -0
  109. 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) => !outcomeFields.some((field) => field.includes(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
- <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-IMP-07</history>
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
- if (annotation.startsWith("probe:")) {
392
- const refId = annotation.slice("probe:".length).trim();
393
- return (envelope?.probes ?? []).some((r) => r.probe?.criterion === refId && r.ok === true);
394
- }
395
- if (annotation.startsWith("test:") || annotation.startsWith("file:")) {
396
- // A trailing :line / :line-range rides the annotation, not the path.
397
- const filePath = annotation
398
- .slice(annotation.indexOf(":") + 1)
399
- .trim()
400
- .replace(/:\d+(?:-\d+)?$/, "");
401
- return statFile(filePath);
402
- }
403
- if (/^[^:]+:\d+(?:-\d+)?$/.test(annotation)) {
404
- const filePath = annotation.slice(0, annotation.lastIndexOf(":")).trim();
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 (runIndependent && hasProbes && String(opts.frontmatter["createdAt"] ?? "") >= RFC_ORIGIN_CUTOFF) {
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) => ["V-45", "V-48", "V-50"].includes(x.rule));
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
- { flags: flags({ title: "Tame the registry loader", proposed: "foo.bar,baz.qux", added: "foo.new" }) } as never,
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).toContain("| ID | Value | Source | Checked by |");
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
+ });