@warpgogol/forge 9.7.0 → 9.7.1

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 (182) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/os/adr/handlers/archive.d.ts.map +1 -1
  3. package/dist/os/adr/handlers/archive.js +3 -7
  4. package/dist/os/adr/handlers/archive.js.map +1 -1
  5. package/dist/os/adr/handlers/list-create.d.ts.map +1 -1
  6. package/dist/os/adr/handlers/list-create.js +8 -6
  7. package/dist/os/adr/handlers/list-create.js.map +1 -1
  8. package/dist/os/audit/handlers/archive.d.ts.map +1 -1
  9. package/dist/os/audit/handlers/archive.js +3 -7
  10. package/dist/os/audit/handlers/archive.js.map +1 -1
  11. package/dist/os/core/archive-regen.d.ts +1 -0
  12. package/dist/os/core/archive-regen.d.ts.map +1 -1
  13. package/dist/os/core/archive-regen.js +31 -6
  14. package/dist/os/core/archive-regen.js.map +1 -1
  15. package/dist/os/core/core.module.d.ts.map +1 -1
  16. package/dist/os/core/core.module.js +5 -0
  17. package/dist/os/core/core.module.js.map +1 -1
  18. package/dist/os/core/handlers/pinned-check.d.ts +13 -0
  19. package/dist/os/core/handlers/pinned-check.d.ts.map +1 -1
  20. package/dist/os/core/handlers/pinned-check.js +25 -0
  21. package/dist/os/core/handlers/pinned-check.js.map +1 -1
  22. package/dist/os/core/handlers/pinned-types.d.ts +7 -0
  23. package/dist/os/core/handlers/pinned-types.d.ts.map +1 -1
  24. package/dist/os/core/handlers/pinned-validate.d.ts.map +1 -1
  25. package/dist/os/core/handlers/pinned-validate.js +24 -1
  26. package/dist/os/core/handlers/pinned-validate.js.map +1 -1
  27. package/dist/os/flow/digest.d.ts +73 -1
  28. package/dist/os/flow/digest.d.ts.map +1 -1
  29. package/dist/os/flow/digest.js +344 -92
  30. package/dist/os/flow/digest.js.map +1 -1
  31. package/dist/os/flow/evidence-lock.d.ts +36 -0
  32. package/dist/os/flow/evidence-lock.d.ts.map +1 -0
  33. package/dist/os/flow/evidence-lock.js +156 -0
  34. package/dist/os/flow/evidence-lock.js.map +1 -0
  35. package/dist/os/flow/flow.module.d.ts.map +1 -1
  36. package/dist/os/flow/flow.module.js +36 -14
  37. package/dist/os/flow/flow.module.js.map +1 -1
  38. package/dist/os/flow/git.d.ts +50 -3
  39. package/dist/os/flow/git.d.ts.map +1 -1
  40. package/dist/os/flow/git.js +144 -12
  41. package/dist/os/flow/git.js.map +1 -1
  42. package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -1
  43. package/dist/os/flow/handlers/flow-digest.js +3 -5
  44. package/dist/os/flow/handlers/flow-digest.js.map +1 -1
  45. package/dist/os/flow/handlers/flow-push.d.ts +81 -0
  46. package/dist/os/flow/handlers/flow-push.d.ts.map +1 -1
  47. package/dist/os/flow/handlers/flow-push.js +642 -138
  48. package/dist/os/flow/handlers/flow-push.js.map +1 -1
  49. package/dist/os/flow/locks.d.ts +8 -0
  50. package/dist/os/flow/locks.d.ts.map +1 -1
  51. package/dist/os/flow/locks.js +6 -3
  52. package/dist/os/flow/locks.js.map +1 -1
  53. package/dist/os/flow/preflight.d.ts.map +1 -1
  54. package/dist/os/flow/preflight.js +4 -2
  55. package/dist/os/flow/preflight.js.map +1 -1
  56. package/dist/os/flow/registry.d.ts +9 -5
  57. package/dist/os/flow/registry.d.ts.map +1 -1
  58. package/dist/os/flow/registry.js +2 -2
  59. package/dist/os/flow/registry.js.map +1 -1
  60. package/dist/os/friction/friction.module.d.ts.map +1 -1
  61. package/dist/os/friction/friction.module.js +30 -5
  62. package/dist/os/friction/friction.module.js.map +1 -1
  63. package/dist/os/friction/handlers/friction-add.d.ts.map +1 -1
  64. package/dist/os/friction/handlers/friction-add.js +10 -17
  65. package/dist/os/friction/handlers/friction-add.js.map +1 -1
  66. package/dist/os/friction/handlers/friction-migrate.d.ts.map +1 -1
  67. package/dist/os/friction/handlers/friction-migrate.js +188 -2
  68. package/dist/os/friction/handlers/friction-migrate.js.map +1 -1
  69. package/dist/os/friction/store.d.ts +4 -0
  70. package/dist/os/friction/store.d.ts.map +1 -1
  71. package/dist/os/friction/store.js +20 -0
  72. package/dist/os/friction/store.js.map +1 -1
  73. package/dist/os/friction/types.d.ts +12 -0
  74. package/dist/os/friction/types.d.ts.map +1 -1
  75. package/dist/os/friction/types.js +8 -0
  76. package/dist/os/friction/types.js.map +1 -1
  77. package/dist/os/gate/handlers/gate-probe-catalog.d.ts.map +1 -1
  78. package/dist/os/gate/handlers/gate-probe-catalog.js +38 -5
  79. package/dist/os/gate/handlers/gate-probe-catalog.js.map +1 -1
  80. package/dist/os/mission/handlers/archive.d.ts.map +1 -1
  81. package/dist/os/mission/handlers/archive.js +3 -7
  82. package/dist/os/mission/handlers/archive.js.map +1 -1
  83. package/dist/os/plan/handlers/archive.d.ts.map +1 -1
  84. package/dist/os/plan/handlers/archive.js +3 -7
  85. package/dist/os/plan/handlers/archive.js.map +1 -1
  86. package/dist/os/rfc/handlers/archive.d.ts.map +1 -1
  87. package/dist/os/rfc/handlers/archive.js +3 -7
  88. package/dist/os/rfc/handlers/archive.js.map +1 -1
  89. package/dist/os/rfc/handlers/list-create.d.ts.map +1 -1
  90. package/dist/os/rfc/handlers/list-create.js +15 -7
  91. package/dist/os/rfc/handlers/list-create.js.map +1 -1
  92. package/dist/os/session/handlers/archive.d.ts.map +1 -1
  93. package/dist/os/session/handlers/archive.js +3 -7
  94. package/dist/os/session/handlers/archive.js.map +1 -1
  95. package/dist/os/system/handlers/system-product-register.d.ts +24 -0
  96. package/dist/os/system/handlers/system-product-register.d.ts.map +1 -0
  97. package/dist/os/system/handlers/system-product-register.js +322 -0
  98. package/dist/os/system/handlers/system-product-register.js.map +1 -0
  99. package/dist/os/system/handlers/system-products-status.d.ts +23 -0
  100. package/dist/os/system/handlers/system-products-status.d.ts.map +1 -0
  101. package/dist/os/system/handlers/system-products-status.js +235 -0
  102. package/dist/os/system/handlers/system-products-status.js.map +1 -0
  103. package/dist/os/system/schemas.d.ts +13 -0
  104. package/dist/os/system/schemas.d.ts.map +1 -1
  105. package/dist/os/system/schemas.js +15 -0
  106. package/dist/os/system/schemas.js.map +1 -1
  107. package/dist/os/system/system.module.d.ts.map +1 -1
  108. package/dist/os/system/system.module.js +113 -3
  109. package/dist/os/system/system.module.js.map +1 -1
  110. package/dist/src/config/forge-config.d.ts +2 -0
  111. package/dist/src/config/forge-config.d.ts.map +1 -1
  112. package/dist/src/config/forge-config.js +11 -10
  113. package/dist/src/config/forge-config.js.map +1 -1
  114. package/dist/src/onboarding/create.d.ts.map +1 -1
  115. package/dist/src/onboarding/create.js +27 -2
  116. package/dist/src/onboarding/create.js.map +1 -1
  117. package/dist/src/profiles/stack-profile.js +2 -2
  118. package/dist/src/types.js +2 -2
  119. package/dist/src/utils/verifier-git.d.ts +27 -1
  120. package/dist/src/utils/verifier-git.d.ts.map +1 -1
  121. package/dist/src/utils/verifier-git.js +36 -6
  122. package/dist/src/utils/verifier-git.js.map +1 -1
  123. package/docs/reference/system-hub.md +104 -0
  124. package/os/adr/handlers/archive.ts +3 -11
  125. package/os/adr/handlers/list-create.test.ts +174 -0
  126. package/os/adr/handlers/list-create.ts +16 -8
  127. package/os/audit/handlers/archive.ts +3 -11
  128. package/os/core/archive-regen.ts +33 -7
  129. package/os/core/core.module.ts +7 -0
  130. package/os/core/docs-archive.test.ts +25 -0
  131. package/os/core/handlers/pinned-check.ts +30 -0
  132. package/os/core/handlers/pinned-types.ts +7 -0
  133. package/os/core/handlers/pinned-validate.ts +28 -3
  134. package/os/flow/digest.ts +436 -95
  135. package/os/flow/evidence-lock.ts +184 -0
  136. package/os/flow/flow.module.ts +37 -14
  137. package/os/flow/git.ts +206 -11
  138. package/os/flow/handlers/flow-digest.ts +12 -8
  139. package/os/flow/handlers/flow-push.ts +725 -137
  140. package/os/flow/locks.ts +24 -7
  141. package/os/flow/preflight.ts +4 -2
  142. package/os/flow/registry.ts +7 -3
  143. package/os/flow/tests/digest-id-inputs.test.ts +106 -0
  144. package/os/flow/tests/digest-persist.test.ts +243 -0
  145. package/os/flow/tests/evidence-preflight-surface-skip.test.ts +218 -0
  146. package/os/flow/tests/flow-push-attest.test.ts +137 -0
  147. package/os/flow/tests/flow-push-review-baseline.test.ts +339 -0
  148. package/os/flow/tests/flow-push-verifier-batch.test.ts +134 -0
  149. package/os/friction/friction-add.test.ts +42 -0
  150. package/os/friction/friction-migrate.test.ts +67 -2
  151. package/os/friction/friction.module.ts +33 -5
  152. package/os/friction/handlers/friction-add.ts +10 -15
  153. package/os/friction/handlers/friction-migrate.ts +220 -1
  154. package/os/friction/store.ts +19 -0
  155. package/os/friction/types.ts +8 -0
  156. package/os/gate/handlers/gate-probe-catalog.ts +39 -7
  157. package/os/gate/handlers/gate-probe-ratchet.test.ts +57 -22
  158. package/os/mission/handlers/archive.ts +3 -11
  159. package/os/plan/handlers/archive.ts +3 -11
  160. package/os/rfc/handlers/archive.ts +3 -11
  161. package/os/rfc/handlers/list-create.ts +22 -17
  162. package/os/session/handlers/archive.ts +3 -11
  163. package/os/system/handlers/system-product-register.ts +492 -0
  164. package/os/system/handlers/system-products-status.ts +395 -0
  165. package/os/system/schemas.ts +17 -0
  166. package/os/system/system.module.ts +117 -3
  167. package/os/system/tests/system-product-register.test.ts +304 -0
  168. package/os/system/tests/system-products-status.test.ts +154 -0
  169. package/package.json +1 -1
  170. package/profiles/root-agents-system.md +82 -0
  171. package/profiles/system.yaml +1 -0
  172. package/src/config/forge-config.ts +16 -11
  173. package/src/onboarding/create-superfolder-guard.test.ts +73 -0
  174. package/src/onboarding/create.ts +28 -2
  175. package/src/profiles/stack-profile.ts +2 -2
  176. package/src/tests/evidence-consult-serialization.test.ts +202 -0
  177. package/src/tests/pinned-validate.test.ts +194 -0
  178. package/src/tests/profile-flow-hooks.test.ts +1 -0
  179. package/src/tests/profile-schema.test.ts +1 -0
  180. package/src/tests/stack-profile.test.ts +1 -0
  181. package/src/types.ts +2 -2
  182. package/src/utils/verifier-git.ts +53 -5
@@ -0,0 +1,304 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>Unit tests for system.product.register (RFC-1641) — explicit
4
+ registration writes the roster + local map (AC-2, AC-8), --discover sibling
5
+ scan semantics (AC-3), refusal cases write nothing (AC-4).</purpose>
6
+ <non-goals>
7
+ <item>Not a contract source of truth — the implementation under test owns the behaviour.</item>
8
+ </non-goals>
9
+ </MODULE_CONTRACT>
10
+ <CHANGE_SUMMARY>
11
+ <item>RFC-1641: system.product.register — roster write surface with --discover sibling scan</item>
12
+ <item>RFC-1641: step 1 — system.product.register handler + tests</item>
13
+ </CHANGE_SUMMARY>
14
+ */
15
+
16
+ import { test, expect, describe, beforeEach, afterEach } from "vitest";
17
+ import fs from "node:fs/promises";
18
+ import path from "node:path";
19
+ import os from "node:os";
20
+ import YAML from "yaml";
21
+
22
+ import { runSystemProductRegister } from "../handlers/system-product-register.ts";
23
+ import type { ForgeFlagValue } from "../../../src/types.ts";
24
+ import { gitExec, initRepo } from "../../flow/tests/helpers.ts";
25
+ import { localMapFor, makeContext, VALID_EDGES_YAML, VALID_SYSTEM_YAML } from "./helpers.ts";
26
+
27
+ // Discover scans dirname(root), so the hub must sit inside a controlled
28
+ // parent — never directly under os.tmpdir() where concurrent fixtures
29
+ // would read as candidate siblings.
30
+ let parent: string;
31
+ let hub: string;
32
+
33
+ const PRODUCTS_YAML = `schema: forge/system-products@1
34
+ products:
35
+ - id: alpha
36
+ remote: https://example.invalid/alpha.git
37
+ offers:
38
+ - alpha-contract
39
+ ignored:
40
+ - id: ignored-one
41
+ note: deliberate non-product
42
+ `;
43
+
44
+ const MEMBER_FORGE_YAML = `schema: forge/workspace@1
45
+ profile: typescript
46
+ forge:
47
+ syncedVersion: "9.7.0"
48
+ `;
49
+
50
+ async function writeHub(files: Record<string, string> = {}): Promise<void> {
51
+ const all: Record<string, string> = {
52
+ "forge.yaml": `schema: forge/workspace@1\nprofile: system\nforge:\n syncedVersion: "9.7.0"\n`,
53
+ "system/system.yaml": VALID_SYSTEM_YAML,
54
+ "system/products.yaml": PRODUCTS_YAML,
55
+ "system/edges.yaml": VALID_EDGES_YAML,
56
+ ...files,
57
+ };
58
+ for (const [rel, content] of Object.entries(all)) {
59
+ const abs = path.join(hub, rel);
60
+ await fs.mkdir(path.dirname(abs), { recursive: true });
61
+ await fs.writeFile(abs, content);
62
+ }
63
+ }
64
+
65
+ async function readYaml(rel: string): Promise<Record<string, unknown>> {
66
+ return YAML.parse(await fs.readFile(path.join(hub, rel), "utf8")) as Record<string, unknown>;
67
+ }
68
+
69
+ function productsOf(
70
+ parsed: Record<string, unknown>,
71
+ ): { id: string; remote?: string; offers?: string[]; frozen?: boolean }[] {
72
+ return (parsed["products"] as { id: string }[] | undefined) ?? [];
73
+ }
74
+
75
+ function foldersOf(parsed: Record<string, unknown>): Record<string, string> {
76
+ return (parsed["folders"] as Record<string, string> | undefined) ?? {};
77
+ }
78
+
79
+ function ctx(flags: Record<string, ForgeFlagValue>) {
80
+ return { input: { argv: [], flags }, context: makeContext(hub) };
81
+ }
82
+
83
+ beforeEach(async () => {
84
+ parent = await fs.mkdtemp(path.join(os.tmpdir(), "sys-register-parent-"));
85
+ hub = path.join(parent, "warpgogol-verbund");
86
+ await fs.mkdir(hub, { recursive: true });
87
+ await writeHub();
88
+ });
89
+
90
+ afterEach(async () => {
91
+ await fs.rm(parent, { recursive: true, force: true });
92
+ });
93
+
94
+ describe("system.product.register — explicit (RFC-1641 AC-2, AC-8)", () => {
95
+ test("appends products.yaml and maps the folder in products.local.yaml", async () => {
96
+ const gammaDir = path.join(parent, "gamma");
97
+ await fs.mkdir(gammaDir, { recursive: true });
98
+ const { input, context } = ctx({
99
+ id: "gamma",
100
+ remote: "https://example.invalid/gamma.git",
101
+ folder: "../gamma",
102
+ offers: ["gamma-contract", "gamma-events"],
103
+ frozen: true,
104
+ });
105
+ const result = await runSystemProductRegister(input, context);
106
+ expect(result.exitCode).toBe(0);
107
+ const products = productsOf(await readYaml("system/products.yaml"));
108
+ const gamma = products.find((p) => p.id === "gamma");
109
+ expect(gamma?.remote).toBe("https://example.invalid/gamma.git");
110
+ expect(gamma?.offers).toEqual(["gamma-contract", "gamma-events"]);
111
+ expect(gamma?.frozen).toBe(true);
112
+ const local = await readYaml("system/products.local.yaml");
113
+ expect(local["schema"]).toBe("forge/system-products-local@1");
114
+ expect(foldersOf(local)["gamma"]).toBe("../gamma");
115
+ expect(result.data?.written).toContain("system/products.yaml");
116
+ expect(result.data?.written).toContain("system/products.local.yaml");
117
+ });
118
+
119
+ test("an identical re-run is a skip, not a write", async () => {
120
+ await fs.mkdir(path.join(parent, "gamma"), { recursive: true });
121
+ const flags = { id: "gamma", remote: "https://example.invalid/gamma.git", folder: "../gamma" };
122
+ await runSystemProductRegister(ctx(flags).input, ctx(flags).context);
123
+ const second = await runSystemProductRegister(ctx(flags).input, ctx(flags).context);
124
+ expect(second.exitCode).toBe(0);
125
+ expect(second.data?.registered).toEqual([]);
126
+ expect(second.data?.skipped).toEqual([{ name: "gamma", reason: "already-registered" }]);
127
+ expect(second.data?.written).toEqual([]);
128
+ });
129
+
130
+ test("--update mutates offers and remote on an existing id", async () => {
131
+ const { input, context } = ctx({
132
+ id: "alpha",
133
+ update: true,
134
+ remote: "https://example.invalid/alpha-v2.git",
135
+ offers: ["alpha-contract", "alpha-v2"],
136
+ });
137
+ const result = await runSystemProductRegister(input, context);
138
+ expect(result.exitCode).toBe(0);
139
+ const alpha = productsOf(await readYaml("system/products.yaml")).find((p) => p.id === "alpha");
140
+ expect(alpha?.remote).toBe("https://example.invalid/alpha-v2.git");
141
+ expect(alpha?.offers).toEqual(["alpha-contract", "alpha-v2"]);
142
+ });
143
+
144
+ test("products.local.yaml keeps an existing launcher on write", async () => {
145
+ await writeHub({
146
+ "system/products.local.yaml": `schema: forge/system-products-local@1\nfolders:\n alpha: /x/alpha\nlauncher:\n argv: ["run", "agent"]\n`,
147
+ });
148
+ const { input, context } = ctx({
149
+ id: "gamma",
150
+ remote: "https://example.invalid/gamma.git",
151
+ folder: "../gamma",
152
+ });
153
+ const result = await runSystemProductRegister(input, context);
154
+ expect(result.exitCode).toBe(0);
155
+ const local = await readYaml("system/products.local.yaml");
156
+ expect(local["launcher"]).toEqual({ argv: ["run", "agent"] });
157
+ expect(foldersOf(local)["gamma"]).toBe("../gamma");
158
+ expect(foldersOf(local)["alpha"]).toBe("/x/alpha");
159
+ });
160
+ });
161
+
162
+ describe("system.product.register — refusals (RFC-1641 AC-4)", () => {
163
+ test("non-kebab id refuses SYSTEM-PRODUCTS-03 and writes nothing", async () => {
164
+ const { input, context } = ctx({ id: "Not_Kebab", remote: "https://x.invalid/y.git" });
165
+ const result = await runSystemProductRegister(input, context);
166
+ expect(result.exitCode).toBe(1);
167
+ expect(result.data?.errors[0]?.ruleId).toBe("SYSTEM-PRODUCTS-03");
168
+ expect(productsOf(await readYaml("system/products.yaml")).map((p) => p.id)).toEqual(["alpha"]);
169
+ });
170
+
171
+ test("duplicate id without --update refuses", async () => {
172
+ const { input, context } = ctx({ id: "alpha", remote: "https://other.invalid/a.git" });
173
+ const result = await runSystemProductRegister(input, context);
174
+ expect(result.exitCode).toBe(1);
175
+ expect(result.data?.errors[0]?.ruleId).toBe("SYSTEM-PRODUCTS-03");
176
+ });
177
+
178
+ test("new product without --remote refuses", async () => {
179
+ const { input, context } = ctx({ id: "gamma" });
180
+ const result = await runSystemProductRegister(input, context);
181
+ expect(result.exitCode).toBe(1);
182
+ expect(result.data?.errors[0]?.ruleId).toBe("SYSTEM-PRODUCTS-03");
183
+ });
184
+
185
+ test("a folder already mapped to another product refuses", async () => {
186
+ await writeHub({ "system/products.local.yaml": localMapFor({ alpha: "../shared" }) });
187
+ const { input, context } = ctx({
188
+ id: "gamma",
189
+ remote: "https://x.invalid/g.git",
190
+ folder: "../shared",
191
+ });
192
+ const result = await runSystemProductRegister(input, context);
193
+ expect(result.exitCode).toBe(1);
194
+ expect(result.data?.errors[0]?.ruleId).toBe("SYSTEM-PRODUCTS-03");
195
+ expect(foldersOf(await readYaml("system/products.local.yaml"))["gamma"]).toBeUndefined();
196
+ });
197
+
198
+ test("missing --id and --discover refuses", async () => {
199
+ const result = await runSystemProductRegister({ argv: [], flags: {} }, makeContext(hub));
200
+ expect(result.exitCode).toBe(1);
201
+ expect(result.data?.errors[0]?.ruleId).toBe("SYSTEM-PRODUCTS-03");
202
+ });
203
+
204
+ test("a missing --folder on disk warns SYSTEM-PRODUCTS-04 but still writes", async () => {
205
+ const { input, context } = ctx({
206
+ id: "gamma",
207
+ remote: "https://x.invalid/g.git",
208
+ folder: "../absent",
209
+ });
210
+ const result = await runSystemProductRegister(input, context);
211
+ expect(result.exitCode).toBe(0);
212
+ expect(result.data?.warnings.some((d) => d.ruleId === "SYSTEM-PRODUCTS-04")).toBe(true);
213
+ expect(foldersOf(await readYaml("system/products.local.yaml"))["gamma"]).toBe("../absent");
214
+ });
215
+
216
+ test("--dry-run resolves the result and writes nothing", async () => {
217
+ const { input, context } = ctx({
218
+ id: "gamma",
219
+ remote: "https://x.invalid/g.git",
220
+ "dry-run": true,
221
+ });
222
+ const result = await runSystemProductRegister(input, context);
223
+ expect(result.exitCode).toBe(0);
224
+ expect(result.data?.dryRun).toBe(true);
225
+ expect(result.data?.written).toContain("system/products.yaml");
226
+ expect(
227
+ await fs.stat(path.join(hub, "system/products.local.yaml")).catch(() => null),
228
+ ).toBeNull();
229
+ expect(productsOf(await readYaml("system/products.yaml")).map((p) => p.id)).toEqual(["alpha"]);
230
+ });
231
+ });
232
+
233
+ describe("system.product.register — discover (RFC-1641 AC-3)", () => {
234
+ test("registers forge siblings with remotes; skips ignored, hidden, @-dirs, non-forge and remoteless candidates", async () => {
235
+ // gamma — a real git checkout with forge.yaml and an origin remote.
236
+ const gammaDir = path.join(parent, "gamma");
237
+ const seeded = await initRepo({ prefix: "sys-gamma-", branch: "develop" });
238
+ await fs.rename(seeded, gammaDir);
239
+ await fs.writeFile(path.join(gammaDir, "forge.yaml"), MEMBER_FORGE_YAML);
240
+ await gitExec(gammaDir, ["remote", "add", "origin", "https://example.invalid/gamma.git"]);
241
+ // remoteless — forge.yaml, git, but no origin.
242
+ const remotelessDir = path.join(parent, "remoteless");
243
+ const seeded2 = await initRepo({ prefix: "sys-remoteless-", branch: "develop" });
244
+ await fs.rename(seeded2, remotelessDir);
245
+ await fs.writeFile(path.join(remotelessDir, "forge.yaml"), MEMBER_FORGE_YAML);
246
+ // ignored-one — named in ignored[].
247
+ await fs.mkdir(path.join(parent, "ignored-one"), { recursive: true });
248
+ await fs.writeFile(path.join(parent, "ignored-one", "forge.yaml"), MEMBER_FORGE_YAML);
249
+ // hidden, @-worktree, plain non-forge dirs — never candidates.
250
+ await fs.mkdir(path.join(parent, ".cache"), { recursive: true });
251
+ await fs.writeFile(path.join(parent, ".cache", "forge.yaml"), MEMBER_FORGE_YAML);
252
+ await fs.mkdir(path.join(parent, "delta@auto-x"), { recursive: true });
253
+ await fs.writeFile(path.join(parent, "delta@auto-x", "forge.yaml"), MEMBER_FORGE_YAML);
254
+ await fs.mkdir(path.join(parent, "plain-docs"), { recursive: true });
255
+ // alpha — dir on disk, already registered: skip reason already-registered.
256
+ const alphaDir = path.join(parent, "alpha");
257
+ const seeded3 = await initRepo({ prefix: "sys-alpha-", branch: "develop" });
258
+ await fs.rename(seeded3, alphaDir);
259
+ await fs.writeFile(path.join(alphaDir, "forge.yaml"), MEMBER_FORGE_YAML);
260
+
261
+ const { input, context } = ctx({ discover: true });
262
+ const result = await runSystemProductRegister(input, context);
263
+ expect(result.exitCode).toBe(0);
264
+ expect(result.data?.mode).toBe("discover");
265
+
266
+ const registeredIds = result.data?.registered.map((r) => r.id) ?? [];
267
+ expect(registeredIds).toEqual(["gamma"]);
268
+ const products = productsOf(await readYaml("system/products.yaml"));
269
+ expect(products.map((p) => p.id)).toEqual(["alpha", "gamma"]);
270
+ expect(products.find((p) => p.id === "gamma")?.remote).toBe(
271
+ "https://example.invalid/gamma.git",
272
+ );
273
+ expect(foldersOf(await readYaml("system/products.local.yaml"))["gamma"]).toBe("../gamma");
274
+
275
+ const skip = Object.fromEntries((result.data?.skipped ?? []).map((s) => [s.name, s.reason]));
276
+ expect(skip["ignored-one"]).toBe("ignored[]");
277
+ expect(skip["remoteless"]).toContain("no origin remote");
278
+ expect(skip["alpha"]).toBe("already-registered");
279
+ expect(skip[".cache"]).toBeUndefined();
280
+ expect(skip["delta@auto-x"]).toBeUndefined();
281
+ expect(skip["plain-docs"]).toBeUndefined();
282
+ expect(skip["warpgogol-verbund"]).toBeUndefined();
283
+ });
284
+
285
+ test("a non-kebab sibling name warns and skips", async () => {
286
+ await fs.mkdir(path.join(parent, "Not_Kebab"), { recursive: true });
287
+ await fs.writeFile(path.join(parent, "Not_Kebab", "forge.yaml"), MEMBER_FORGE_YAML);
288
+ const { input, context } = ctx({ discover: true });
289
+ const result = await runSystemProductRegister(input, context);
290
+ expect(result.exitCode).toBe(0);
291
+ expect(result.data?.warnings.some((d) => d.ruleId === "SYSTEM-PRODUCTS-04")).toBe(true);
292
+ expect(result.data?.skipped.find((s) => s.name === "Not_Kebab")?.reason).toContain("kebab");
293
+ });
294
+ });
295
+
296
+ describe("system.product.register — SYSTEM-01 gate", () => {
297
+ test("refuses outside the system profile", async () => {
298
+ await fs.writeFile(path.join(hub, "forge.yaml"), `profile: typescript\n`);
299
+ const { input, context } = ctx({ id: "gamma", remote: "https://x.invalid/g.git" });
300
+ const result = await runSystemProductRegister(input, context);
301
+ expect(result.exitCode).toBe(1);
302
+ expect(result.data?.errors[0]?.ruleId).toBe("SYSTEM-01");
303
+ });
304
+ });
@@ -0,0 +1,154 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>Unit tests for system.products.status (RFC-1639) — member health probing (AC-2), sibling-scan warnings (AC-3), frozen-product semantics (AC-6).</purpose>
4
+ <non-goals>
5
+ <item>Not a contract source of truth — the implementation under test owns the behaviour.</item>
6
+ </non-goals>
7
+ </MODULE_CONTRACT>
8
+ <CHANGE_SUMMARY>
9
+ <item>RFC-1639: step 5-6 — acceptance tests, system-hub reference, regenerated manifests</item>
10
+ <item>RFC-1639: review — SYSTEM-MAP-01 rules decl, git-probe warnings, sibling kind/path discriminants, friction.add provenance, ingest hardening</item>
11
+ </CHANGE_SUMMARY>
12
+ */
13
+
14
+ import { test, expect, describe, beforeEach, afterEach } from "vitest";
15
+ import fs from "node:fs/promises";
16
+ import path from "node:path";
17
+ import os from "node:os";
18
+
19
+ import { runSystemProductsStatus } from "../handlers/system-products-status.ts";
20
+ import { gitExec, initRepo } from "../../flow/tests/helpers.ts";
21
+ import { localMapFor, makeContext, VALID_EDGES_YAML, VALID_SYSTEM_YAML } from "./helpers.ts";
22
+
23
+ // The sibling scan walks dirname(root), so the hub must sit inside a
24
+ // controlled parent — never directly under os.tmpdir() where concurrent
25
+ // fixtures would read as unregistered siblings.
26
+ let parent: string;
27
+ let hub: string;
28
+ let alphaDir: string;
29
+ let betaDir: string;
30
+
31
+ const PRODUCTS_YAML = `schema: forge/system-products@1
32
+ products:
33
+ - id: alpha
34
+ remote: https://example.invalid/alpha.git
35
+ offers: []
36
+ - id: beta
37
+ remote: https://example.invalid/beta.git
38
+ offers: []
39
+ - id: ghost
40
+ remote: https://example.invalid/ghost.git
41
+ offers: []
42
+ frozen: true
43
+ ignored:
44
+ - id: ignored-one
45
+ note: scratch area
46
+ `;
47
+
48
+ const MEMBER_FORGE_YAML = `schema: forge/workspace@1
49
+ profile: typescript
50
+ forge:
51
+ syncedVersion: "9.7.0"
52
+ `;
53
+
54
+ beforeEach(async () => {
55
+ parent = await fs.mkdtemp(path.join(os.tmpdir(), "sys-status-parent-"));
56
+ hub = path.join(parent, "warpgogol-verbund");
57
+ alphaDir = path.join(parent, "alpha");
58
+ betaDir = path.join(parent, "beta");
59
+ // alpha — a real git checkout: commit forge.yaml, then dirty a tracked file.
60
+ let seeded = await initRepo({ prefix: "sys-alpha-", branch: "develop" });
61
+ await fs.rename(seeded, alphaDir);
62
+ await fs.writeFile(path.join(alphaDir, "forge.yaml"), MEMBER_FORGE_YAML);
63
+ await gitExec(alphaDir, ["add", "forge.yaml"]);
64
+ await gitExec(alphaDir, ["commit", "-m", "forge.yaml"]);
65
+ await fs.appendFile(path.join(alphaDir, "seed.txt"), "dirty\n");
66
+ // beta — a second real checkout, clean.
67
+ seeded = await initRepo({ prefix: "sys-beta-", branch: "develop" });
68
+ await fs.rename(seeded, betaDir);
69
+ await fs.writeFile(path.join(betaDir, "forge.yaml"), MEMBER_FORGE_YAML);
70
+ await gitExec(betaDir, ["add", "forge.yaml"]);
71
+ await gitExec(betaDir, ["commit", "-m", "forge.yaml"]);
72
+
73
+ const hubFiles: Record<string, string> = {
74
+ "forge.yaml": `schema: forge/workspace@1\nprofile: system\nforge:\n syncedVersion: "9.7.0"\n`,
75
+ "system/system.yaml": VALID_SYSTEM_YAML,
76
+ "system/products.yaml": PRODUCTS_YAML,
77
+ "system/edges.yaml": VALID_EDGES_YAML,
78
+ "system/products.local.yaml": localMapFor({
79
+ alpha: alphaDir,
80
+ beta: betaDir,
81
+ ghost: path.join(parent, "ghost"),
82
+ }),
83
+ };
84
+ for (const [rel, content] of Object.entries(hubFiles)) {
85
+ const abs = path.join(hub, rel);
86
+ await fs.mkdir(path.dirname(abs), { recursive: true });
87
+ await fs.writeFile(abs, content);
88
+ }
89
+ });
90
+
91
+ afterEach(async () => {
92
+ await fs.rm(parent, { recursive: true, force: true });
93
+ });
94
+
95
+ describe("system.products.status — member health (RFC-1639 AC-2)", () => {
96
+ test("reports presence, profile, version parity and git fields per member", async () => {
97
+ const result = await runSystemProductsStatus({ argv: [], flags: {} }, makeContext(hub));
98
+ expect(result.exitCode).toBe(0);
99
+ const data = result.data;
100
+ expect(data?.baseline).toBe("9.7.0");
101
+ const alpha = data?.products.find((p) => p.id === "alpha");
102
+ expect(alpha?.folder).toBe(alphaDir);
103
+ expect(alpha?.profile).toBe("typescript");
104
+ expect(alpha?.forgeVersion).toBe("9.7.0");
105
+ expect(alpha?.versionOk).toBe(true);
106
+ expect(alpha?.dirty).toBe(true); // tracked seed.txt modified post-commit
107
+ const beta = data?.products.find((p) => p.id === "beta");
108
+ expect(beta?.folder).toBe(betaDir);
109
+ expect(beta?.dirty).toBe(false);
110
+ // alpha/beta carry no upstream — aheadOfOrigin degrades to null + warning.
111
+ expect(alpha?.aheadOfOrigin).toBeNull();
112
+ });
113
+ });
114
+
115
+ describe("system.products.status — sibling scan (RFC-1639 AC-3)", () => {
116
+ test("warns on an unregistered forge.yaml sibling and a git sibling without forge.yaml", async () => {
117
+ await fs.mkdir(path.join(parent, "rogue"), { recursive: true });
118
+ await fs.writeFile(path.join(parent, "rogue", "forge.yaml"), MEMBER_FORGE_YAML);
119
+ await fs.mkdir(path.join(parent, "ignored-one"), { recursive: true });
120
+ await fs.writeFile(path.join(parent, "ignored-one", "forge.yaml"), MEMBER_FORGE_YAML);
121
+ await fs.mkdir(path.join(parent, "git-only"), { recursive: true });
122
+ const init = await gitExec(path.join(parent, "git-only"), ["init", "-b", "main"]);
123
+ expect(init.exitCode).toBe(0);
124
+
125
+ const result = await runSystemProductsStatus({ argv: [], flags: {} }, makeContext(hub));
126
+ expect(result.exitCode).toBe(0);
127
+ const warned = result.data?.warnings.map((w) => w.message).join("\n") ?? "";
128
+ expect(warned).toContain("rogue");
129
+ expect(warned).toContain("git-only");
130
+ expect(warned).not.toContain("ignored-one");
131
+ });
132
+ });
133
+
134
+ describe("system.products.status — frozen members (RFC-1639 AC-6)", () => {
135
+ test("a missing frozen member reports null probes with a warning, never an error", async () => {
136
+ const result = await runSystemProductsStatus({ argv: [], flags: {} }, makeContext(hub));
137
+ expect(result.exitCode).toBe(0);
138
+ const ghost = result.data?.products.find((p) => p.id === "ghost");
139
+ expect(ghost?.frozen).toBe(true);
140
+ expect(ghost?.versionOk).toBeNull();
141
+ expect(result.data?.errors ?? []).toHaveLength(0);
142
+ const warned = result.data?.warnings.map((w) => w.message).join("\n") ?? "";
143
+ expect(warned).toContain("ghost");
144
+ });
145
+
146
+ test("a missing non-frozen member is an error and fails the command", async () => {
147
+ const products = PRODUCTS_YAML.replace(" frozen: true\n", "");
148
+ await fs.writeFile(path.join(hub, "system", "products.yaml"), products);
149
+ const result = await runSystemProductsStatus({ argv: [], flags: {} }, makeContext(hub));
150
+ expect(result.exitCode).toBe(1);
151
+ const errors = result.data?.errors.map((e) => e.message).join("\n") ?? "";
152
+ expect(errors).toContain("ghost");
153
+ });
154
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warpgogol/forge",
3
- "version": "9.7.0",
3
+ "version": "9.7.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -0,0 +1,82 @@
1
+ <!-- Root AGENTS.md template for system-profile hub repositories.
2
+ Static prose only — dynamic sections (skills, capabilities, behavioral layer)
3
+ are inserted at the dynamicSections marker by runAgentsGenerate.
4
+ Placeholders: projectName, projectStack, projectPm,
5
+ rfcsDir, adrsDir, plansDir, auditsDir, specsDir,
6
+ skillsDir, dynamicSections -->
7
+
8
+ # Agent Guide: {{projectName}}
9
+
10
+ > This file is generated by `forge.agents.generate` from `forge.yaml`. It is a living document — edit freely to add project-specific guidance.
11
+
12
+ ## Project
13
+
14
+ - **Name:** {{projectName}}
15
+ - **Stack:** {{projectStack}}
16
+ - **Package manager:** {{projectPm}}
17
+ - **Role:** system hub — the coordination repository for a folder of product repositories (RFC-1508, RFC-1639)
18
+
19
+ ## Paths
20
+
21
+ - RFCs: `{{rfcsDir}}`
22
+ - ADRs: `{{adrsDir}}`
23
+ - Plans: `{{plansDir}}`
24
+ - Audits: `{{auditsDir}}`
25
+ - Specs: `{{specsDir}}`
26
+ - Skills: `{{skillsDir}}`
27
+
28
+ ## What this repository is
29
+
30
+ This is a **system hub**: it coordinates the product repositories around it but ships no product code itself. The canonical member roster lives in `system/products.yaml` (committed: `id`, `remote`, `offers[]`, `frozen`), the local checkout map in `system/products.local.yaml` (gitignored — machine-local), the allowed/forbidden contract matrix in `system/edges.yaml`, and cross-product work in `queue/`.
31
+
32
+ ## Member registry
33
+
34
+ - Register a product with `system.product.register --id <kebab> --remote <url> --folder ../<dir>`; adopt a folder of forge repositories at once with `system.product.register --discover` (scans the parent directory, skips `ignored[]`, `@`-worktrees, and remote-less candidates). Preview with `--dry-run`.
35
+ - `system/products.local.yaml` is gitignored per-machine state — recreate it by re-running `system.product.register --folder` on each checkout machine.
36
+ - `frozen: true` members are pinned by contract — health reports stay informational, never error.
37
+ - `ignored[]` names siblings that are deliberately not products (frozen snapshots, test clones) — it silences the unregistered-sibling warning.
38
+
39
+ ## Health sweep
40
+
41
+ - `system.products.status` reports each member against disk reality: resolved folder, declared profile, `forge.syncedVersion` vs this hub's baseline, dirty state, live `@`-worktrees, commits ahead — plus registry-vs-disk warnings for unregistered forge siblings and git checkouts without `forge.yaml`.
42
+ - `system.map.validate` is the registry contract gate (the integration gate runs it) — run it after any `system/` edit.
43
+
44
+ ## Frictions
45
+
46
+ - Frictions about **this hub's own machinery** are repo-level: `friction.add`.
47
+ - Frictions about **member repos or the folder as a whole** are folder-level: `friction.add --level folder` — records carry `origin` + `migratedFrom` provenance and live in this repo's `docs/frictions/`.
48
+
49
+ ## Task queue
50
+
51
+ Cross-product work flows through `queue/`: `system.task.create` → `system.task.move` → `system.task.dispatch` (opens a product worktree with the brief) → `system.task.collect`. `system.outbox.scan` turns committed product-side `docs/outbox/` requests into proposed tasks.
52
+
53
+ {{dynamicSections}}
54
+
55
+ ## RTK — Token Optimization
56
+
57
+ Always prefix shell commands with `rtk` to minimize token consumption. RTK filters and compresses command output before it reaches the LLM context, cutting up to 90% of bash output on common operations.
58
+
59
+ ```bash
60
+ rtk git status
61
+ rtk pnpm test
62
+ rtk ls src/
63
+ rtk grep "pattern" src/
64
+ rtk find "*.ts" .
65
+ ```
66
+
67
+ Meta commands:
68
+
69
+ ```bash
70
+ rtk gain # Show token savings
71
+ rtk gain --history # Command history with savings
72
+ rtk discover # Find missed RTK opportunities
73
+ rtk proxy <cmd> # Run raw (no filtering, for debugging)
74
+ ```
75
+
76
+ Use default RTK settings only — do not enable `--ultra-compact` or aggressive `read` modes unless the operator explicitly requests it.
77
+
78
+ ## Conventions
79
+
80
+ - Use `forge.yaml` as the single source of truth for project configuration.
81
+ - Regenerate this file with `forge.agents.generate` after changing `forge.yaml`.
82
+ - Follow the closest `AGENTS.md` for workspace or directory details.
@@ -1,6 +1,7 @@
1
1
  schema: forge/stack-profile@1
2
2
  id: system
3
3
  displayName: System repository
4
+ rootAgentsMdTemplate: root-agents-system.md
4
5
  detect:
5
6
  anyOf:
6
7
  - system.marker
@@ -6,19 +6,12 @@
6
6
  </non-goals>
7
7
  </MODULE_CONTRACT>
8
8
  <CHANGE_SUMMARY>
9
- <item>RFC-1615: round-1 acceptance counterexamples CX-6..CX-12</item>
10
- <item>RFC-1616: external verification trust boundary
11
-
12
- policy.digest (canonical SHA-256 over the frozen surface), adversarial.run
13
- with a 12-scenario catalog replayed through the real gate in a scratch
14
- clone, flow.push verifier-trailer hard stop (fail-closed on unreadable
15
- forge.yaml), project.owner + push.requireVerifierReview config, trust-boundary
16
- scaffold (CODEOWNERS + forge-policy workflow) and reference docs.</item>
17
- <item>RFC-1616: close verifier r1 counterexamples for the RFC-1616 trust boundary</item>
18
9
  <item>RFC-1616: close RFC-1616 r2 trust-boundary counterexamples</item>
19
10
  <item>RFC-1616: close RFC-1616 r5 trust-boundary counterexamples</item>
20
11
  <item>RFC-1617: outcomeBuildTimeoutMs binding for sites exceeding the 15-minute probe build cap; regenerate command manifest; heal SKILL-17 id + twin drift</item>
21
- <history>RFC-0391, RFC-0393, RFC-0537, RFC-0538, RFC-0539, RFC-0540, RFC-0543, RFC-0546, RFC-0639, RFC-0640, RFC-0643, RFC-0661, RFC-0662, RFC-0704, RFC-1097, RFC-1224, RFC-1332, RFC-1365, RFC-1391, RFC-1453, RFC-1481, RFC-1493, RFC-1539, RFC-1578, RFC-1579, RFC-1580, RFC-1591, RFC-1596, RFC-1615</history>
12
+ <item>RFC-1639: revert container-scope contracts — superfolder governance moves to the system hub</item>
13
+ <item>RFC-1643: committed verifier-review baseline for flow.push</item>
14
+ <history>RFC-0391, RFC-0393, RFC-0537, RFC-0538, RFC-0539, RFC-0540, RFC-0543, RFC-0546, RFC-0639, RFC-0640, RFC-0643, RFC-0661, RFC-0662, RFC-0704, RFC-1097, RFC-1224, RFC-1332, RFC-1365, RFC-1391, RFC-1453, RFC-1481, RFC-1493, RFC-1539, RFC-1578, RFC-1579, RFC-1580, RFC-1591, RFC-1596, RFC-1615, RFC-1616</history>
22
15
  </CHANGE_SUMMARY>
23
16
  */
24
17
 
@@ -464,6 +457,14 @@ export const forgeConfigSchema = z
464
457
  push: z
465
458
  .object({
466
459
  requireVerifierReview: z.boolean().optional(),
460
+ /**
461
+ * RFC-1643: committed review baseline — a full commit sha. Trailer
462
+ * commits that are ancestors of it no longer stop FLOW-PUSH-08
463
+ * (still scanned and reported). Loosely typed on purpose: shape is
464
+ * judged at push time (FLOW-PUSH-16), a malformed value must not
465
+ * brick every command that loads forge.yaml.
466
+ */
467
+ verifierReviewedThrough: z.string().optional(),
467
468
  /**
468
469
  * RFC-1616 r5 (CX-80): the declared trusted remote — the anchor
469
470
  * outside session-writable config that `flow.push` parity checks
@@ -539,7 +540,11 @@ export interface ForgeConfig {
539
540
  /** RFC-1578: raw `correctness:` section — validated by correctness.manifest.validate (CORR-02). */
540
541
  correctness?: Record<string, unknown>;
541
542
  /** RFC-1616 (Q-5): push-time trust-boundary controls — `requireVerifierReview` defaults to true; `expectedRemote` anchors the trusted remote. */
542
- push?: { requireVerifierReview?: boolean; expectedRemote?: string };
543
+ push?: {
544
+ requireVerifierReview?: boolean;
545
+ verifierReviewedThrough?: string;
546
+ expectedRemote?: string;
547
+ };
543
548
  /** RFC-1615: the declared policy surface — judged frozen by correctness.gate. */
544
549
  policy?: ForgePolicy;
545
550
  }