@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
@@ -6,9 +6,6 @@
6
6
  </non-goals>
7
7
  </MODULE_CONTRACT>
8
8
  <CHANGE_SUMMARY>
9
- <item>RFC-1455: fixed inputs bound to outcome probes — V-50/V-51 + skills</item>
10
- <item>RFC-1534: V-PROBE-META-01 metachar lint — warning on unescaped parens and `**` + slash glob shapes in file-contains/test probe patterns at authoring statuses; `probe-meta: intentional` comment suppresses per-pattern via raw frontmatterSource scan.</item>
11
- <item>RFC-1454: review deviations recorded in the RFC — IMP-15 gate, V-49 provenance, skill contract</item>
12
9
  <item>RFC-1467: block rfc.create on terminal-kind near-duplicates until --revisit acknowledges + V-52 validate mirror</item>
13
10
  <item>RFC-1489: batch test probes through one instrumented Vitest run + frontmatter corpus reads
14
11
 
@@ -20,7 +17,9 @@ process (per-spec null on missing objects, wholesale null on spawn or
20
17
  framing failure). collectCommittedReviews prefers it and keeps the
21
18
  sequential show loop for stubs. rfc.validate memoizes the index once
22
19
  per run and V-49 consumes it — identical diagnostics, one batched read.</item>
23
- <history>RFC-0303, RFC-0722, RFC-0755, RFC-0795, RFC-0997, RFC-1006, RFC-1097, RFC-1271, RFC-1322, RFC-1330, RFC-1334, RFC-1336, RFC-1391, RFC-1453</history>
20
+ <item>RFC-1569: lint rfc evidence annotations and transient probe targets</item>
21
+ <item>RFC-1563: share the kernel command-result cache across session worktrees — one SQLite DB in the primary checkout, @@WORKSPACE_ROOT@@ payload anchoring, scoped --force clear, kernel.cache.prune</item>
22
+ <history>RFC-0303, RFC-0722, RFC-0755, RFC-0795, RFC-0997, RFC-1006, RFC-1097, RFC-1271, RFC-1322, RFC-1330, RFC-1334, RFC-1336, RFC-1391, RFC-1453, RFC-1454, RFC-1455, RFC-1534</history>
24
23
  </CHANGE_SUMMARY>
25
24
  */
26
25
 
@@ -37,11 +36,8 @@ import { execFile } from "../../../src/utils/sync-fs.ts";
37
36
  import { parse as yamlParse } from "yaml";
38
37
  import { proofSpecSchema } from "../../../src/formal/proof-spec.ts";
39
38
  import { validateAcceptanceShape } from "../acceptance.ts";
40
- import {
41
- scoreDecisions,
42
- REPROPOSED_SCORE,
43
- TERMINAL_KINDS,
44
- } from "../decision-log.ts";
39
+ import { EVIDENCE_FORMS, parseEvidenceAnnotation } from "../evidence-annotation.ts";
40
+ import { scoreDecisions, REPROPOSED_SCORE, TERMINAL_KINDS } from "../decision-log.ts";
45
41
  import type { DecisionLogEntry } from "../types.ts";
46
42
  import type { ParsedRfc, RfcCorpusEntry } from "../frontmatter-io.ts";
47
43
  import type { ReadAndParseRfcResult } from "../frontmatter-io.ts";
@@ -564,9 +560,7 @@ export function collectProbeMetacharHits(
564
560
  for (let i = 0; i < fmLines.length; i++) {
565
561
  const line = fmLines[i]!;
566
562
  if (!line.includes(`${field}:`) || !line.includes(value)) continue;
567
- return (
568
- line.includes(PROBE_META_MARKER) || (fmLines[i - 1] ?? "").includes(PROBE_META_MARKER)
569
- );
563
+ return line.includes(PROBE_META_MARKER) || (fmLines[i - 1] ?? "").includes(PROBE_META_MARKER);
570
564
  }
571
565
  return false;
572
566
  };
@@ -584,13 +578,25 @@ export function collectProbeMetacharHits(
584
578
  if (/(^|[^\\])\(/.test(pattern)) chars.push("unescaped `(`");
585
579
  if (/(^|[^\\])\)/.test(pattern)) chars.push("unescaped `)`");
586
580
  if (pattern.includes("**/")) chars.push("`**/` glob shape");
581
+ // RFC-1569 (F-0202): a mid-pattern `$`/`^` anchors silently — the probe can
582
+ // never match; unescaped `{}`/`[]` quantify/group instead of matching.
583
+ const rest = pattern.slice(1).replace(/\\\^/g, "");
584
+ if (rest.includes("^")) chars.push("mid-pattern `^` anchor");
585
+ const head = pattern.slice(0, -1).replace(/\\\$/g, "");
586
+ if (head.includes("$")) chars.push("mid-pattern `$` anchor");
587
+ if (/(^|[^\\])[{}]/.test(pattern)) chars.push("unescaped `{`/`}`");
588
+ if (/(^|[^\\])[[\]]/.test(pattern)) chars.push("unescaped `[`/`]`");
587
589
  if (chars.length === 0 || suppressed(field, pattern)) continue;
588
590
  hits.push({
589
591
  criterion: typeof probe.criterion === "string" ? probe.criterion : "?",
590
592
  probe: kind,
591
593
  pattern,
592
594
  chars,
593
- suggestion: pattern.replace(/\*\*\//g, "(?:.*/)?").replace(/([()])/g, "\\$1"),
595
+ suggestion: pattern
596
+ .replace(/\*\*\//g, "(?:.*/)?")
597
+ .replace(/([()[\]{}^$])/g, "\\$1")
598
+ .replace(/^\\\^/, "^")
599
+ .replace(/\\\$$/, "$"),
594
600
  });
595
601
  }
596
602
  return hits;
@@ -993,14 +999,160 @@ export async function validateSingleRfc(
993
999
  }
994
1000
  }
995
1001
 
1002
+ // V-53 (RFC-1569): evidence annotation SHAPE on every criterion line —
1003
+ // the stamp's grammar, applied at authoring time. Warning at
1004
+ // draft/reviewing, error from accepted on; V-37 keeps its checked-line
1005
+ // resolution semantics (the double-fire on checked lines is deliberate).
1006
+ // Implemented and archived RFCs are sealed — historical annotations
1007
+ // degrade to warning (re-authoring them would falsify the record).
1008
+ const v53Probes = Array.isArray(fm["acceptance"]) ? (fm["acceptance"] as AcceptanceProbe[]) : [];
1009
+ if (acceptanceSection) {
1010
+ const v53Severity =
1011
+ status === "draft" || status === "reviewing" || status === "implemented" || isArchived
1012
+ ? "warning"
1013
+ : "error";
1014
+ for (const line of acceptanceSection.split("\n")) {
1015
+ if (!/^- \[[ xX]\]/.test(line)) continue;
1016
+ const v53Matches = [...line.matchAll(/\(evidence:\s*(.+?)\)/g)];
1017
+ const v53Match = v53Matches.at(-1);
1018
+ if (!v53Match) continue;
1019
+ const v53Parsed = parseEvidenceAnnotation(v53Match[1]!);
1020
+ if (v53Parsed.kind === "invalid") {
1021
+ addViolation(
1022
+ rfcId,
1023
+ relFile,
1024
+ "V-53",
1025
+ `evidence "${v53Parsed.raw.trim()}" is not a resolvable form (expected ${EVIDENCE_FORMS}) — rfc.implement.stamp would refuse it with STAMP-CHECK-01`,
1026
+ v53Severity,
1027
+ );
1028
+ } else if (v53Parsed.kind === "probe") {
1029
+ const refId = v53Parsed.criterion;
1030
+ // AC-N existence comes from the checklist; a design:<heading>
1031
+ // criterion "exists" when a frontmatter probe declares it.
1032
+ const exists =
1033
+ criteriaEval.criterionIds.includes(refId) || v53Probes.some((p) => p.criterion === refId);
1034
+ if (!exists) {
1035
+ addViolation(
1036
+ rfcId,
1037
+ relFile,
1038
+ "V-53",
1039
+ `evidence "probe:${refId}" references a criterion that does not exist in acceptance criteria`,
1040
+ v53Severity,
1041
+ );
1042
+ } else if (v53Probes.length > 0 && !v53Probes.some((p) => p.criterion === refId)) {
1043
+ addViolation(
1044
+ rfcId,
1045
+ relFile,
1046
+ "V-53",
1047
+ `evidence "probe:${refId}" references a criterion with no bound probe`,
1048
+ v53Severity,
1049
+ );
1050
+ }
1051
+ }
1052
+ }
1053
+ }
1054
+
1055
+ // V-54 (RFC-1569, F-0175): transient probe targets — a target that only
1056
+ // resolves while a mission is open cannot carry stamp evidence. Warning
1057
+ // only: app-scope fallbacks to the cache clone are legitimate (RFC-1025).
1058
+ {
1059
+ let outcomeBuildRe: RegExp | null = null;
1060
+ try {
1061
+ const ob = loadForgeConfig(workspaceRoot).bindings?.commands.outcomeBuild;
1062
+ if (typeof ob === "string" && ob.trim()) {
1063
+ outcomeBuildRe = new RegExp(
1064
+ `^${ob
1065
+ .trim()
1066
+ .replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
1067
+ .replace(/\\\{target\\\}/g, "\\S+")}$`,
1068
+ );
1069
+ }
1070
+ } catch {
1071
+ // forge.yaml unreadable → no binding → nothing to exempt.
1072
+ }
1073
+ let appScopedCommands: Set<string> | null = null;
1074
+ const runProbes = v53Probes.filter((p) => p.probe === "run");
1075
+ if (runProbes.length > 0) {
1076
+ let manifestRaw: string | null = null;
1077
+ try {
1078
+ manifestRaw = await io.readFile(
1079
+ path.join(workspaceRoot, "docs", "command-manifest.generated.yaml"),
1080
+ );
1081
+ } catch {
1082
+ // Manifest absent (forge-only consumer repos) → skip the arm.
1083
+ }
1084
+ if (manifestRaw !== null) {
1085
+ try {
1086
+ const manifest = yamlParse(manifestRaw) as {
1087
+ commands?: { name?: string; scope?: string }[];
1088
+ };
1089
+ const entries = manifest?.commands;
1090
+ if (!Array.isArray(entries)) throw new Error("no commands[]");
1091
+ appScopedCommands = new Set(
1092
+ entries
1093
+ .filter((c) => c?.scope === "app" && typeof c?.name === "string")
1094
+ .map((c) => c.name as string),
1095
+ );
1096
+ } catch {
1097
+ addViolation(
1098
+ rfcId,
1099
+ relFile,
1100
+ "V-54",
1101
+ `command manifest malformed — app-scope arm of V-54 skipped for this run`,
1102
+ "warning",
1103
+ );
1104
+ }
1105
+ }
1106
+ }
1107
+ for (const probe of v53Probes) {
1108
+ const kind = probe.probe;
1109
+ const criterion = typeof probe.criterion === "string" ? probe.criterion : "?";
1110
+ if (kind === "file-exists" || kind === "file-contains" || kind === "json-schema") {
1111
+ const p = "path" in probe ? String(probe.path ?? "") : "";
1112
+ if (/^missions\/(?!archive\/)/.test(p)) {
1113
+ addViolation(
1114
+ rfcId,
1115
+ relFile,
1116
+ "V-54",
1117
+ `${criterion} ${kind} probe path "${p}" lives under missions/ outside missions/archive/ — it resolves only while a mission is open; bind a durable target instead`,
1118
+ "warning",
1119
+ );
1120
+ }
1121
+ }
1122
+ if (kind === "run") {
1123
+ const cmd = "command" in probe ? String(probe.command ?? "") : "";
1124
+ if (!cmd || (outcomeBuildRe && outcomeBuildRe.test(cmd.trim()))) continue;
1125
+ if (/(^|\s)--mission(\s|=|$)/.test(cmd)) {
1126
+ addViolation(
1127
+ rfcId,
1128
+ relFile,
1129
+ "V-54",
1130
+ `${criterion} run probe "${cmd}" carries a --mission flag — the command resolves only while that mission is open; use a test probe or a durable target`,
1131
+ "warning",
1132
+ );
1133
+ continue;
1134
+ }
1135
+ if (appScopedCommands !== null) {
1136
+ const hit = cmd.split(/\s+/).find((tok) => appScopedCommands!.has(tok));
1137
+ if (hit) {
1138
+ addViolation(
1139
+ rfcId,
1140
+ relFile,
1141
+ "V-54",
1142
+ `${criterion} run probe invokes app-scoped command "${hit}" — it needs an open site workpiece to run; prefer a test probe, a durable target, or the outcomeBuild binding`,
1143
+ "warning",
1144
+ );
1145
+ }
1146
+ }
1147
+ }
1148
+ }
1149
+ }
1150
+
996
1151
  // V-PROBE-META-01 (RFC-1534): regexp-trap metachar lint — warning at
997
1152
  // authoring statuses (draft/reviewing/accepted), never a blocking error;
998
1153
  // terminal statuses are archival and stay silent.
999
1154
  if (status === "draft" || status === "reviewing" || status === "accepted") {
1000
- for (const hit of collectProbeMetacharHits(
1001
- fm["acceptance"],
1002
- parsed.frontmatterSource ?? "",
1003
- )) {
1155
+ for (const hit of collectProbeMetacharHits(fm["acceptance"], parsed.frontmatterSource ?? "")) {
1004
1156
  addViolation(
1005
1157
  rfcId,
1006
1158
  relFile,
@@ -0,0 +1,222 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>RFC-1569 V-54 — transient probe target lint: missions/ paths,
4
+ --mission flags, app-scoped run commands, outcomeBuild exemption.</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-54 rule tests (AC-4, AC-5, --mission/app-scope arms)</item>
11
+ <item>RFC-1569: lint rfc evidence annotations and transient probe targets</item>
12
+ </CHANGE_SUMMARY>
13
+ */
14
+
15
+ import { test, expect, describe, beforeAll } from "vitest";
16
+ import { mkdirSync, writeFileSync } from "node:fs";
17
+ import { validateSingleRfc, type AddViolationFn } from "./validate-rules.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-v54");
23
+
24
+ beforeAll(() => {
25
+ mkdirSync(join(testWorkspace, "docs"), { recursive: true });
26
+ writeFileSync(
27
+ join(testWorkspace, "forge.yaml"),
28
+ 'bindings:\n commands:\n outcomeBuild: "werkstatt run leitstand.build --id {target}"\n',
29
+ );
30
+ writeFileSync(
31
+ join(testWorkspace, "docs", "command-manifest.generated.yaml"),
32
+ "commands:\n - name: agent.api-catalog.validate\n scope: app\n - name: rfc.validate\n scope: workspace\n",
33
+ );
34
+ });
35
+
36
+ function makeParsed(body: string, acceptance: unknown[]): ParsedRfc {
37
+ return {
38
+ frontmatter: {
39
+ id: "RFC-9999",
40
+ title: "Test RFC",
41
+ status: "draft",
42
+ kind: "command",
43
+ scope: "workspace",
44
+ owners: ["architecture"],
45
+ createdAt: "2026-09-01",
46
+ updatedAt: "2026-09-01",
47
+ acceptance,
48
+ },
49
+ body,
50
+ };
51
+ }
52
+
53
+ const BASE_BODY = `
54
+ # RFC-9999: Test RFC
55
+
56
+ ## Context
57
+
58
+ Test context.
59
+
60
+ ## Problem
61
+
62
+ Test problem.
63
+
64
+ ## Decision
65
+
66
+ Test decision.
67
+
68
+ ## Architectural fit
69
+
70
+ Test fit.
71
+
72
+ ## Design
73
+
74
+ ### CLI surface
75
+
76
+ Test CLI.
77
+
78
+ ### TypeScript contracts
79
+
80
+ Test types.
81
+
82
+ ### File system responsibilities
83
+
84
+ | Path | Role |
85
+ |---|---|
86
+ | \`test.ts\` | test |
87
+
88
+ ### Output format
89
+
90
+ Test output.
91
+
92
+ ### Failure modes
93
+
94
+ Test failures.
95
+
96
+ ## Rollout
97
+
98
+ Test rollout.
99
+
100
+ ## Alternatives considered
101
+
102
+ Test alternatives.
103
+
104
+ ## Risks
105
+
106
+ Test risks.
107
+
108
+ ## Acceptance criteria
109
+
110
+ - [ ] AC-1: first criterion
111
+ - [ ] AC-2: second criterion
112
+
113
+ ## Implementation notes for agents
114
+
115
+ Test notes.
116
+ `;
117
+
118
+ async function runValidate(
119
+ parsed: ParsedRfc,
120
+ ): Promise<{ rfcId: string; rule: string; message: string; severity: string }[]> {
121
+ const violations: { rfcId: string; rule: string; message: string; severity: string }[] = [];
122
+ const add: AddViolationFn = (rfcId, _file, rule, message, severity = "error") => {
123
+ violations.push({ rfcId, rule, message, severity });
124
+ };
125
+ await validateSingleRfc(
126
+ "rfc-9999-test.md",
127
+ parsed,
128
+ new Map(),
129
+ new Map(),
130
+ new Set(),
131
+ new Set(),
132
+ new Set(Object.keys(parsed.frontmatter)),
133
+ testWorkspace,
134
+ add,
135
+ );
136
+ return violations.filter((v) => v.rule === "V-54");
137
+ }
138
+
139
+ describe("V-54: transient probe targets (RFC-1569)", () => {
140
+ test("AC-4: file-contains probe under missions/ reports warning", async () => {
141
+ const violations = await runValidate(
142
+ makeParsed(BASE_BODY, [
143
+ {
144
+ probe: "file-contains",
145
+ criterion: "AC-1",
146
+ path: "missions/warpgogol-m000219/workpiece/src/index.astro",
147
+ pattern: "hero",
148
+ },
149
+ ]),
150
+ );
151
+ expect(violations.length).toBe(1);
152
+ expect(violations[0]!.severity).toBe("warning");
153
+ expect(violations[0]!.message).toContain("missions/");
154
+ });
155
+
156
+ test("missions/archive/ path is durable — no V-54", async () => {
157
+ const violations = await runValidate(
158
+ makeParsed(BASE_BODY, [
159
+ {
160
+ probe: "file-exists",
161
+ criterion: "AC-1",
162
+ path: "missions/archive/warpgogol-m000219/report.json",
163
+ },
164
+ ]),
165
+ );
166
+ expect(violations).toEqual([]);
167
+ });
168
+
169
+ test("run probe carrying --mission reports warning", async () => {
170
+ const violations = await runValidate(
171
+ makeParsed(BASE_BODY, [
172
+ {
173
+ probe: "run",
174
+ criterion: "AC-1",
175
+ command: "werkstatt run mission.validate --mission m000219 --json",
176
+ },
177
+ ]),
178
+ );
179
+ expect(violations.length).toBe(1);
180
+ expect(violations[0]!.message).toContain("--mission");
181
+ });
182
+
183
+ test("app-scoped run command reports warning", async () => {
184
+ const violations = await runValidate(
185
+ makeParsed(BASE_BODY, [
186
+ {
187
+ probe: "run",
188
+ criterion: "AC-1",
189
+ command: "pnpm exec werkstatt run agent.api-catalog.validate --app warpgogol",
190
+ },
191
+ ]),
192
+ );
193
+ expect(violations.length).toBe(1);
194
+ expect(violations[0]!.message).toContain("agent.api-catalog.validate");
195
+ });
196
+
197
+ test("AC-5: outcomeBuild binding command is exempt", async () => {
198
+ const violations = await runValidate(
199
+ makeParsed(BASE_BODY, [
200
+ {
201
+ probe: "run",
202
+ criterion: "AC-1",
203
+ command: "werkstatt run leitstand.build --id warpgogol",
204
+ },
205
+ ]),
206
+ );
207
+ expect(violations).toEqual([]);
208
+ });
209
+
210
+ test("workspace-scoped run command is clean", async () => {
211
+ const violations = await runValidate(
212
+ makeParsed(BASE_BODY, [
213
+ {
214
+ probe: "run",
215
+ criterion: "AC-1",
216
+ command: "pnpm exec werkstatt run rfc.validate --id RFC-9999",
217
+ },
218
+ ]),
219
+ );
220
+ expect(violations).toEqual([]);
221
+ });
222
+ });
@@ -225,8 +225,8 @@ interface ExampleResult {
225
225
  system behavior — they are checks that the document is complete.
226
226
  Use DR-N: identifiers. V-38 enforces completeness for accepted+ post-cutoff RFCs.
227
227
 
228
- - [ ] DR-1: Every considered alternative has a stated reason for rejection (evidence: file: <path:line>)
229
- - [ ] DR-2: The RFC enumerates every existing artifact it touches (evidence: file: <path:line>)
228
+ - [ ] DR-1: Every considered alternative has a stated reason for rejection (evidence: file:<path>:<line>)
229
+ - [ ] DR-2: The RFC enumerates every existing artifact it touches (evidence: file:<path>:<line>)
230
230
  - [ ] DR-3: The RFC states whether the decision is reversible and at what cost
231
231
  -->
232
232
 
@@ -235,12 +235,12 @@ interface ExampleResult {
235
235
  <!-- V-50 contract (RFC-1455): every value this RFC pins for the shipped
236
236
  result (verbatim copy, labels, names, decided option values) is a row
237
237
  bound to exactly one AC-N criterion whose probes observe the value.
238
- Emit the header schema only — a live placeholder row would itself trip
238
+ V-50 containment compares each literal against the regex-UNESCAPED probe pattern — escaping a metachar literal keeps coverage. Emit the header schema only — a live placeholder row would itself trip
239
239
  V-50. Add rows only when the draft fixes real inputs; delete this
240
240
  section's table when none exist. -->
241
241
 
242
- | ID | Value | Source | Checked by |
243
- | --- | --- | --- | --- |
242
+ | ID | Value | Source | Checked by |
243
+ | --- | ----- | ------ | ---------- |
244
244
 
245
245
  ## Acceptance criteria
246
246
 
@@ -248,11 +248,11 @@ interface ExampleResult {
248
248
  Each criterion is a falsifiable claim about an observable artifact, written in EARS form with a stable AC-N: identifier.
249
249
  Required mix: behavior, contract, negative, sync. 3–10 items. One claim = one checking mechanism. -->
250
250
 
251
- - [ ] AC-1: WHEN `<command> --json` is invoked, THE command SHALL return a JSON object matching the documented output schema (evidence: probe:AC-1 or test: <path>)
252
- - [ ] AC-2: THE `<command>` SHALL be registered in the kernel module with the correct name and scope (evidence: file: <module-path>)
253
- - [ ] AC-3: IF `<command>` receives invalid input, THEN THE command SHALL report a blocking error (evidence: test: <path/to/test>)
254
- - [ ] AC-4: IF `<command>` receives invalid input, THEN THE command SHALL exit non-zero (evidence: test: <path/to/test>)
255
- - [ ] AC-5: THE relevant `AGENTS.md` SHALL reference this RFC where agent behavior rules changed (evidence: file: <path:line>)
251
+ - [ ] AC-1: WHEN `<command> --json` is invoked, THE command SHALL return a JSON object matching the documented output schema (evidence: probe:AC-1)
252
+ - [ ] AC-2: THE `<command>` SHALL be registered in the kernel module with the correct name and scope (evidence: file:<module-path>)
253
+ - [ ] AC-3: IF `<command>` receives invalid input, THEN THE command SHALL report a blocking error (evidence: test:<path/to/test>)
254
+ - [ ] AC-4: IF `<command>` receives invalid input, THEN THE command SHALL exit non-zero (evidence: test:<path/to/test>)
255
+ - [ ] AC-5: THE relevant `AGENTS.md` SHALL reference this RFC where agent behavior rules changed (evidence: file:<path>:<line>)
256
256
 
257
257
  ## Implementation notes for agents
258
258
 
@@ -7,14 +7,14 @@
7
7
  </non-goals>
8
8
  </MODULE_CONTRACT>
9
9
  <CHANGE_SUMMARY>
10
- <item>RFC-1483: self-sufficient implement stamp — default repair pass, ordered remediation checklist, --no-repair</item>
11
10
  <item>RFC-1489: batch test probes through one instrumented Vitest run + frontmatter corpus reads
12
11
 
13
12
  runProbeSet is the single shared execution point: barrier-free segments of test probes sharing one effective bound run in one vitest --reporter=json --outputFile process with per-(file,testName) attribution; missing files/reports yield unverified. run/page/proof and all non-test kinds are barriers. --no-batch escapes to the legacy path on acceptance.run, verification.emit and verification.refresh. rfc.validate reads non-target corpus files frontmatter-only via readRfcFrontmatter (64 KiB bound, full-parse fallback); emit/refresh/acceptance corpus scans use the same accessor. Corpus map slimmed to RfcCorpusEntry {fileName, frontmatter}.</item>
14
13
  <item>RFC-1516: add an evidence-freshness window to the stamp-sync chain for rfc-1516</item>
15
14
  <item>RFC-1528: close review findings — manifest-union command inventory for regen/preflight</item>
16
15
  <item>RFC-1534: lint probe patterns, sync amends counterparts, name next free ledger id</item>
17
- <history>RFC-0260, RFC-0795, RFC-1097, RFC-1173, RFC-1231, RFC-1237, RFC-1249, RFC-1271, RFC-1306, RFC-1322, RFC-1333, RFC-1351, RFC-1354, RFC-1364, RFC-1453, RFC-1458, RFC-1461, RFC-1463, RFC-1467, RFC-1474, RFC-1482</history>
16
+ <item>RFC-1568: durable gate-run records, --detach mechanics, and forge CLI wiring</item>
17
+ <history>RFC-0260, RFC-0795, RFC-1097, RFC-1173, RFC-1231, RFC-1237, RFC-1249, RFC-1271, RFC-1306, RFC-1322, RFC-1333, RFC-1351, RFC-1354, RFC-1364, RFC-1453, RFC-1458, RFC-1461, RFC-1463, RFC-1467, RFC-1474, RFC-1482, RFC-1483</history>
18
18
  </CHANGE_SUMMARY>
19
19
  */
20
20
 
@@ -556,6 +556,7 @@ export async function createForgeRfcModule(): Promise<ForgeModule> {
556
556
  },
557
557
  {
558
558
  name: "rfc.implement.stamp",
559
+ detachable: true,
559
560
  // gate-completeness: handlers/implement-stamp.ts accumulates
560
561
  // violations[] across every independent precondition gate and emits
561
562
  // one stampFailResult — the complete set in a single run (RFC-1463).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warpgogol/forge",
3
- "version": "9.4.1",
3
+ "version": "9.5.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -176,10 +176,18 @@
176
176
  "types": "./os/queue/index.ts",
177
177
  "default": "./os/queue/index.ts"
178
178
  },
179
+ "./os/gate-run": {
180
+ "types": "./os/gate-run/index.ts",
181
+ "default": "./os/gate-run/index.ts"
182
+ },
179
183
  "./os/queue-module": {
180
184
  "types": "./os/queue/queue.module.ts",
181
185
  "default": "./os/queue/queue.module.ts"
182
186
  },
187
+ "./os/gate-run-module": {
188
+ "types": "./os/gate-run/gate-run.module.ts",
189
+ "default": "./os/gate-run/gate-run.module.ts"
190
+ },
183
191
  "./authority": {
184
192
  "types": "./src/authority/index.ts",
185
193
  "default": "./src/authority/index.ts"
@@ -498,10 +506,18 @@
498
506
  "types": "./dist/os/queue/index.d.ts",
499
507
  "default": "./dist/os/queue/index.js"
500
508
  },
509
+ "./os/gate-run": {
510
+ "types": "./dist/os/gate-run/index.d.ts",
511
+ "default": "./dist/os/gate-run/index.js"
512
+ },
501
513
  "./os/queue-module": {
502
514
  "types": "./dist/os/queue/queue.module.d.ts",
503
515
  "default": "./dist/os/queue/queue.module.js"
504
516
  },
517
+ "./os/gate-run-module": {
518
+ "types": "./dist/os/gate-run/gate-run.module.d.ts",
519
+ "default": "./dist/os/gate-run/gate-run.module.js"
520
+ },
505
521
  "./conformance": {
506
522
  "types": "./dist/src/conformance/index.d.ts",
507
523
  "default": "./dist/src/conformance/index.js"
@@ -20,7 +20,6 @@ triggerPhrases: ["завершаем", "протокол завершения",
20
20
  </non-goals>
21
21
  </MODULE_CONTRACT>
22
22
  <CHANGE_SUMMARY>
23
- <item>RFC-1528: worktree-first preamble — session-end writes go through a dedicated session worktree; docs.archive prefers the kernel host</item>
24
23
  <item>RFC-1531: add flow.integrate remediation flags on the shared dirty classifier</item>
25
24
  <item>RFC-1534: lint probe patterns, sync amends counterparts, name next free ledger id</item>
26
25
  <item>ADR-0126: docs-rule batch — 16 friction measures landed</item>
@@ -30,7 +29,8 @@ RFC-1460 harvest wave 2026-11-09: five draft RFCs (derive-and-repair flow
30
29
  surfaces, quiet kernel output, staged-commit/invocation guards, fixed-branch
31
30
  onboarding-status routing, forge task prettier coverage), seven docs-rule
32
31
  landings, registry flips — 25 entries served, F-0025 stays external.</item>
33
- <history>ADR-0119, ADR-0121, RFC-1097, RFC-1247, RFC-1433, RFC-1460, RFC-1487, RFC-1491</history>
32
+ <item>RFC-1460: session-end teardown — stop worktree-held dev servers before flow.integrate</item>
33
+ <history>ADR-0119, ADR-0121, RFC-1097, RFC-1247, RFC-1433, RFC-1460, RFC-1487, RFC-1491, RFC-1528</history>
34
34
  </CHANGE_SUMMARY>
35
35
  -->
36
36
 
@@ -205,8 +205,10 @@ for d in missions/*/workpiece; do [ -d "$d/.git" ] && echo "=== $d ===" && rtk g
205
205
  **3e. Integrate or discard the session flow branch:**
206
206
 
207
207
  - This step applies only when the session's cwd is a flow worktree — its branch is a registered `auto/session-*` entry (check `flow.status`; repositories not on the fixed branch model have no registered branches → skip silently). When the worktree-first preamble opened a retro worktree, run the integration from that worktree — the whole session's writes ride it.
208
+ - Before integrating, stop processes that hold files inside the session worktree — dev servers (`astro dev`, `vite dev`, `node --watch`, …) started during the session keep `node_modules`/build-output handles open and make `git worktree remove` fail with FLOW-INT-04 ("Directory not empty"): the branch still integrates, but an orphaned directory shell plus a stale server stay behind. Detect holders via `/proc` cwd links — `for d in /proc/[0-9]*/cwd; do readlink "$d"; done | grep -F "<worktree path>"` (or `lsof +D <worktree>`) — terminate them, then integrate.
208
209
  - After the clean-tree commit, run `flow.integrate` from the session worktree — it rebases the branch onto `develop`, runs the primary checkout's `hooks/integration-gate.sh`, and fast-forwards `develop`.
209
210
  - On a FLOW-INT-02 (rebase conflict) or FLOW-INT-05 (gate refusal) diagnostic, report the refusal and leave the branch for the next session — do not force-resolve inside session end.
211
+ - A FLOW-INT-04 (worktree removal failed) means the branch already integrated — only teardown failed: stop the file-holding process, confirm the worktree is unregistered (`git worktree list`), then remove the leftover directory.
210
212
  - A FLOW-INT-01 dirty refusal is different: `data.entries` carries each path's class (`disposable`/`work`/…) — remediate via the flow.integrate remediation flags (`--auto-clean` when every entry is disposable, `--autocommit` to sweep the rest into the fixed-subject commit) or leave the branch for the next session with the classification reported.
211
213
  - When the operator said to drop the work, run `flow.discard --reason "<operator words>"` instead of `flow.integrate`.
212
214
 
package/src/cli-flags.ts CHANGED
@@ -14,6 +14,7 @@ with `TypeError: targetId.toLowerCase is not a function`.</purpose>
14
14
  <item>RFC-1389 (port of RFC-1381): bare `-m` rewrites to `--message` when the merged schema declares `message` — other `-x` tokens stay KERNEL-ARG-01, now with honest hints (a known declared short alias, the command's single unsatisfied required non-boolean flag, or a truthful see-`--help` fallback) instead of the fabricated `--id <token>` template; alias-shaped tokens are never consumed as flag values.</item>
15
15
  <item>RFC-1395: port --output → --json alias into forge CLI parser</item>
16
16
  <item>RFC-1485: sweep compass headers — forge-src + forge root eslint</item>
17
+ <item>RFC-1568: durable gate-run records, --detach mechanics, and forge CLI wiring</item>
17
18
  </CHANGE_SUMMARY>
18
19
  */
19
20
 
@@ -34,6 +35,11 @@ export const CLI_UNIVERSAL_FLAGS: Record<string, ForgeFlagSpec> = {
34
35
  "dry-run": { kind: "boolean", description: "Report intended mutations without writing them." },
35
36
  force: { kind: "boolean", description: "Bypass a normally-blocking safety check." },
36
37
  help: { kind: "boolean", description: "Print command help instead of executing." },
38
+ detach: {
39
+ kind: "boolean",
40
+ description:
41
+ "RFC-1568: run a `detachable` command as a detached child — returns immediately with a run id; poll via gate.run.status.",
42
+ },
37
43
  };
38
44
 
39
45
  /**
@@ -43,6 +49,7 @@ export const CLI_UNIVERSAL_FLAGS: Record<string, ForgeFlagSpec> = {
43
49
  */
44
50
  const CLI_BOOLEAN_FLAGS = new Set<string>([
45
51
  "all",
52
+ "detach",
46
53
  "all-apps",
47
54
  "approve-all",
48
55
  "dry-run",
package/src/types.ts CHANGED
@@ -9,18 +9,12 @@ can be registered in a Warpgogol kernel without direct dependency.</purpose>
9
9
  </non-goals>
10
10
  </MODULE_CONTRACT>
11
11
  <CHANGE_SUMMARY>
12
- <item>RFC-1360: step 2 — env-input declaration sweep (59 commands)
13
-
14
- Declare every reachable env read on its owning command across engine/site/
15
- forge (fresh full-registry replay worklist: 151 ENV-INPUT-01, 60 commands).
16
- ForgeCommandMetadata gains the mirrored envInputs contract field. The
17
- npm_execpath ambient read in open-source-page.ts is removed for a
18
- deterministic PATH spawn (DNA-105) — undeclarable name class, ledger Q-9.</item>
19
12
  <item>RFC-1366: kernel resolves mission workpieceEnv + KERNEL-ENV-01 gate on required envInputs</item>
20
13
  <item>RFC-1461: declare rules[] severity via CommandRuleDecl workspace-wide (RFC-1461)</item>
21
14
  <item>RFC-1463: composite gates report complete violation sets and self-ensure prerequisites — ensure/compositeGate metadata, executor ensure runner, blockedBy skip tracking, ENSURE-01..04 + GATE-CMP-01, runCompositeGate</item>
22
15
  <item>RFC-1486: review r1 — committed-state adoption gate, uncommitted-hook committedness, step-failure trail, idempotency declaration, lazy asset resolution</item>
23
- <history>RFC-0518, RFC-1097, RFC-1147, RFC-1231, RFC-1306, RFC-1354</history>
16
+ <item>RFC-1568: durable gate-run records, --detach mechanics, and forge CLI wiring</item>
17
+ <history>RFC-0518, RFC-1097, RFC-1147, RFC-1231, RFC-1306, RFC-1354, RFC-1360</history>
24
18
  </CHANGE_SUMMARY>
25
19
  */
26
20
 
@@ -189,6 +183,13 @@ export interface ForgeCommandMetadata {
189
183
  * KernelCommandMetadata.
190
184
  */
191
185
  mutatingFlags?: string[];
186
+ /**
187
+ * RFC-1568: the command may run under `--detach` and every execution
188
+ * writes a durable gate-run record. Structurally mirrors
189
+ * KernelCommandMetadata — the standalone CLI checks this field on forge
190
+ * commands.
191
+ */
192
+ detachable?: true;
192
193
  /**
193
194
  * RFC-1327: rerun-safety class for mutating commands — structurally
194
195
  * mirrors KernelCommandMetadata. `rerun-safe` requires a sibling