@warpgogol/forge 9.7.1 → 10.1.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 (262) hide show
  1. package/AGENTS.md +50 -27
  2. package/CHANGELOG.md +39 -0
  3. package/bin/cli.js +0 -0
  4. package/dist/os/codebase/handlers/codebase-measure-symbols.d.ts.map +1 -1
  5. package/dist/os/codebase/handlers/codebase-measure-symbols.js +35 -4
  6. package/dist/os/codebase/handlers/codebase-measure-symbols.js.map +1 -1
  7. package/dist/os/core/core.module.d.ts.map +1 -1
  8. package/dist/os/core/core.module.js +1 -69
  9. package/dist/os/core/core.module.js.map +1 -1
  10. package/dist/os/core/handlers/assets-helpers.d.ts.map +1 -1
  11. package/dist/os/core/handlers/assets-helpers.js +2 -3
  12. package/dist/os/core/handlers/assets-helpers.js.map +1 -1
  13. package/dist/os/core/handlers/determinism-check.d.ts.map +1 -1
  14. package/dist/os/core/handlers/determinism-check.js +2 -3
  15. package/dist/os/core/handlers/determinism-check.js.map +1 -1
  16. package/dist/os/core/handlers/release-prepare.d.ts.map +1 -1
  17. package/dist/os/core/handlers/release-prepare.js +2 -4
  18. package/dist/os/core/handlers/release-prepare.js.map +1 -1
  19. package/dist/os/flow/handlers/flow-peers.js +1 -1
  20. package/dist/os/flow/handlers/flow-peers.js.map +1 -1
  21. package/dist/os/{mission → flow}/open-missions.d.ts +1 -2
  22. package/dist/os/flow/open-missions.d.ts.map +1 -0
  23. package/dist/os/flow/open-missions.js +37 -0
  24. package/dist/os/flow/open-missions.js.map +1 -0
  25. package/dist/os/flow/preflight.js +1 -1
  26. package/dist/os/flow/preflight.js.map +1 -1
  27. package/dist/os/rfc/probe-batch.d.ts.map +1 -1
  28. package/dist/os/rfc/probe-batch.js +13 -6
  29. package/dist/os/rfc/probe-batch.js.map +1 -1
  30. package/dist/src/command-modules.d.ts.map +1 -1
  31. package/dist/src/command-modules.js +0 -2
  32. package/dist/src/command-modules.js.map +1 -1
  33. package/dist/src/contract/core-nodes.d.ts +8 -0
  34. package/dist/src/contract/core-nodes.d.ts.map +1 -0
  35. package/dist/src/contract/core-nodes.js +101 -0
  36. package/dist/src/contract/core-nodes.js.map +1 -0
  37. package/dist/src/contract/evaluator.d.ts +48 -0
  38. package/dist/src/contract/evaluator.d.ts.map +1 -0
  39. package/dist/src/contract/evaluator.js +158 -0
  40. package/dist/src/contract/evaluator.js.map +1 -0
  41. package/dist/src/contract/evidence-store.d.ts +17 -0
  42. package/dist/src/contract/evidence-store.d.ts.map +1 -0
  43. package/dist/src/contract/evidence-store.js +113 -0
  44. package/dist/src/contract/evidence-store.js.map +1 -0
  45. package/dist/src/contract/executors/zero-deps.d.ts +3 -0
  46. package/dist/src/contract/executors/zero-deps.d.ts.map +1 -0
  47. package/dist/src/contract/executors/zero-deps.js +88 -0
  48. package/dist/src/contract/executors/zero-deps.js.map +1 -0
  49. package/dist/src/contract/fingerprint.d.ts +34 -0
  50. package/dist/src/contract/fingerprint.d.ts.map +1 -0
  51. package/dist/src/contract/fingerprint.js +153 -0
  52. package/dist/src/contract/fingerprint.js.map +1 -0
  53. package/dist/src/contract/graph.d.ts +23 -0
  54. package/dist/src/contract/graph.d.ts.map +1 -0
  55. package/dist/src/contract/graph.js +158 -0
  56. package/dist/src/contract/graph.js.map +1 -0
  57. package/dist/src/contract/migration-map.d.ts +51 -0
  58. package/dist/src/contract/migration-map.d.ts.map +1 -0
  59. package/dist/src/contract/migration-map.js +130 -0
  60. package/dist/src/contract/migration-map.js.map +1 -0
  61. package/dist/src/contract/types.d.ts +108 -0
  62. package/dist/src/contract/types.d.ts.map +1 -0
  63. package/dist/src/contract/types.js +23 -0
  64. package/dist/src/contract/types.js.map +1 -0
  65. package/dist/src/index.d.ts +0 -2
  66. package/dist/src/index.d.ts.map +1 -1
  67. package/dist/src/index.js +0 -2
  68. package/dist/src/index.js.map +1 -1
  69. package/dist/src/integration/drain.d.ts +31 -0
  70. package/dist/src/integration/drain.d.ts.map +1 -0
  71. package/dist/src/integration/drain.js +195 -0
  72. package/dist/src/integration/drain.js.map +1 -0
  73. package/dist/src/integration/enqueue.d.ts +30 -0
  74. package/dist/src/integration/enqueue.d.ts.map +1 -0
  75. package/dist/src/integration/enqueue.js +64 -0
  76. package/dist/src/integration/enqueue.js.map +1 -0
  77. package/dist/src/integration/gitops.d.ts +33 -0
  78. package/dist/src/integration/gitops.d.ts.map +1 -0
  79. package/dist/src/integration/gitops.js +128 -0
  80. package/dist/src/integration/gitops.js.map +1 -0
  81. package/dist/src/integration/lease.d.ts +16 -0
  82. package/dist/src/integration/lease.d.ts.map +1 -0
  83. package/dist/src/integration/lease.js +140 -0
  84. package/dist/src/integration/lease.js.map +1 -0
  85. package/dist/src/integration/materialize.d.ts +7 -0
  86. package/dist/src/integration/materialize.d.ts.map +1 -0
  87. package/dist/src/integration/materialize.js +34 -0
  88. package/dist/src/integration/materialize.js.map +1 -0
  89. package/dist/src/integration/store.d.ts +21 -0
  90. package/dist/src/integration/store.d.ts.map +1 -0
  91. package/dist/src/integration/store.js +131 -0
  92. package/dist/src/integration/store.js.map +1 -0
  93. package/dist/src/integration/types.d.ts +71 -0
  94. package/dist/src/integration/types.d.ts.map +1 -0
  95. package/dist/src/integration/types.js +18 -0
  96. package/dist/src/integration/types.js.map +1 -0
  97. package/dist/src/onboarding/doctor.d.ts +0 -5
  98. package/dist/src/onboarding/doctor.d.ts.map +1 -1
  99. package/dist/src/onboarding/doctor.js +6 -79
  100. package/dist/src/onboarding/doctor.js.map +1 -1
  101. package/dist/src/onboarding/npm-token-check.d.ts +1 -1
  102. package/dist/src/onboarding/npm-token-check.d.ts.map +1 -1
  103. package/dist/src/onboarding/npm-token-check.js +2 -2
  104. package/dist/src/onboarding/npm-token-check.js.map +1 -1
  105. package/dist/src/sdk/context.d.ts +13 -0
  106. package/dist/src/sdk/context.d.ts.map +1 -0
  107. package/dist/src/sdk/context.js +128 -0
  108. package/dist/src/sdk/context.js.map +1 -0
  109. package/dist/src/sdk/loader.d.ts +25 -0
  110. package/dist/src/sdk/loader.d.ts.map +1 -0
  111. package/dist/src/sdk/loader.js +155 -0
  112. package/dist/src/sdk/loader.js.map +1 -0
  113. package/dist/src/sdk/scan.d.ts +16 -0
  114. package/dist/src/sdk/scan.d.ts.map +1 -0
  115. package/dist/src/sdk/scan.js +126 -0
  116. package/dist/src/sdk/scan.js.map +1 -0
  117. package/dist/src/sdk/skills-gen.d.ts +27 -0
  118. package/dist/src/sdk/skills-gen.d.ts.map +1 -0
  119. package/dist/src/sdk/skills-gen.js +87 -0
  120. package/dist/src/sdk/skills-gen.js.map +1 -0
  121. package/dist/src/sdk/types.d.ts +124 -0
  122. package/dist/src/sdk/types.d.ts.map +1 -0
  123. package/dist/src/sdk/types.js +34 -0
  124. package/dist/src/sdk/types.js.map +1 -0
  125. package/dist/src/utils/hash.d.ts +1 -0
  126. package/dist/src/utils/hash.d.ts.map +1 -1
  127. package/dist/src/utils/hash.js +4 -0
  128. package/dist/src/utils/hash.js.map +1 -1
  129. package/dist/{os/mission → src/utils}/lockfile.d.ts +1 -18
  130. package/dist/src/utils/lockfile.d.ts.map +1 -0
  131. package/dist/src/utils/lockfile.js +70 -0
  132. package/dist/src/utils/lockfile.js.map +1 -0
  133. package/os/codebase/handlers/codebase-measure-symbols.ts +32 -4
  134. package/os/core/core.module.ts +3 -76
  135. package/os/core/handlers/assets-helpers.ts +2 -4
  136. package/os/core/handlers/determinism-check.ts +2 -3
  137. package/os/core/handlers/lifecycle-handlers.test.ts +529 -0
  138. package/os/core/handlers/release-prepare.ts +2 -4
  139. package/os/correctness/gate/trust-boundary-cx18.test.ts +1 -1
  140. package/os/flow/handlers/flow-peers.ts +1 -1
  141. package/os/flow/open-missions.ts +45 -0
  142. package/os/flow/preflight.ts +1 -1
  143. package/os/flow/tests/release-lines.test.ts +136 -0
  144. package/os/flow/tests/state-roots.test.ts +1 -48
  145. package/os/rfc/handlers/validate-corpus.test.ts +149 -0
  146. package/os/rfc/probe-batch.test.ts +253 -0
  147. package/os/rfc/probe-batch.ts +13 -6
  148. package/os/rfc/verifier/rfc-1391/ac10-operating-model-policy.acceptance.test.ts +63 -0
  149. package/package.json +177 -506
  150. package/src/command-modules.ts +0 -2
  151. package/src/contract/core-nodes.ts +111 -0
  152. package/src/contract/evaluator.ts +207 -0
  153. package/src/contract/evidence-store.ts +119 -0
  154. package/src/contract/executors/zero-deps.ts +92 -0
  155. package/src/contract/fingerprint.ts +176 -0
  156. package/src/contract/graph.ts +181 -0
  157. package/src/contract/migration-map.ts +174 -0
  158. package/src/contract/types.ts +125 -0
  159. package/src/index.ts +0 -2
  160. package/src/integration/drain.ts +271 -0
  161. package/src/integration/enqueue.ts +92 -0
  162. package/src/integration/gitops.ts +174 -0
  163. package/src/integration/lease.ts +144 -0
  164. package/src/integration/materialize.ts +40 -0
  165. package/src/integration/store.ts +153 -0
  166. package/src/integration/types.ts +79 -0
  167. package/src/onboarding/doctor.ts +9 -96
  168. package/src/onboarding/npm-token-check.ts +3 -3
  169. package/src/sdk/context.ts +135 -0
  170. package/src/sdk/loader.ts +170 -0
  171. package/src/sdk/scan.ts +132 -0
  172. package/src/sdk/skills-gen.ts +104 -0
  173. package/src/sdk/types.ts +135 -0
  174. package/src/tests/pkg-health-self-scan.test.ts +29 -0
  175. package/src/tests/rfc-evidence-sync.test.ts +369 -0
  176. package/src/tests/skill-agents-sync.test.ts +192 -0
  177. package/src/utils/hash.ts +5 -0
  178. package/src/utils/lockfile.ts +78 -0
  179. package/dist/os/core/handlers/forge-autonomy-validate.d.ts +0 -25
  180. package/dist/os/core/handlers/forge-autonomy-validate.d.ts.map +0 -1
  181. package/dist/os/core/handlers/forge-autonomy-validate.js +0 -208
  182. package/dist/os/core/handlers/forge-autonomy-validate.js.map +0 -1
  183. package/dist/os/mission/handlers/archive.d.ts +0 -4
  184. package/dist/os/mission/handlers/archive.d.ts.map +0 -1
  185. package/dist/os/mission/handlers/archive.js +0 -583
  186. package/dist/os/mission/handlers/archive.js.map +0 -1
  187. package/dist/os/mission/importer-block.d.ts +0 -19
  188. package/dist/os/mission/importer-block.d.ts.map +0 -1
  189. package/dist/os/mission/importer-block.js +0 -124
  190. package/dist/os/mission/importer-block.js.map +0 -1
  191. package/dist/os/mission/index.d.ts +0 -2
  192. package/dist/os/mission/index.d.ts.map +0 -1
  193. package/dist/os/mission/index.js +0 -15
  194. package/dist/os/mission/index.js.map +0 -1
  195. package/dist/os/mission/lockfile.d.ts.map +0 -1
  196. package/dist/os/mission/lockfile.js +0 -138
  197. package/dist/os/mission/lockfile.js.map +0 -1
  198. package/dist/os/mission/mission.module.d.ts +0 -3
  199. package/dist/os/mission/mission.module.d.ts.map +0 -1
  200. package/dist/os/mission/mission.module.js +0 -63
  201. package/dist/os/mission/mission.module.js.map +0 -1
  202. package/dist/os/mission/open-missions.d.ts.map +0 -1
  203. package/dist/os/mission/open-missions.js +0 -42
  204. package/dist/os/mission/open-missions.js.map +0 -1
  205. package/dist/os/mission/types.d.ts +0 -23
  206. package/dist/os/mission/types.d.ts.map +0 -1
  207. package/dist/os/mission/types.js +0 -19
  208. package/dist/os/mission/types.js.map +0 -1
  209. package/dist/os/werkstatt/handlers/lock.d.ts +0 -10
  210. package/dist/os/werkstatt/handlers/lock.d.ts.map +0 -1
  211. package/dist/os/werkstatt/handlers/lock.js +0 -153
  212. package/dist/os/werkstatt/handlers/lock.js.map +0 -1
  213. package/dist/os/werkstatt/handlers/schema.d.ts +0 -33
  214. package/dist/os/werkstatt/handlers/schema.d.ts.map +0 -1
  215. package/dist/os/werkstatt/handlers/schema.js +0 -42
  216. package/dist/os/werkstatt/handlers/schema.js.map +0 -1
  217. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts +0 -15
  218. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts.map +0 -1
  219. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js +0 -171
  220. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js.map +0 -1
  221. package/dist/os/werkstatt/handlers/werkstatt-lock-status.d.ts +0 -18
  222. package/dist/os/werkstatt/handlers/werkstatt-lock-status.d.ts.map +0 -1
  223. package/dist/os/werkstatt/handlers/werkstatt-lock-status.js +0 -51
  224. package/dist/os/werkstatt/handlers/werkstatt-lock-status.js.map +0 -1
  225. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts +0 -11
  226. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts.map +0 -1
  227. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js +0 -86
  228. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js.map +0 -1
  229. package/dist/os/werkstatt/handlers/workspace-deps.d.ts +0 -12
  230. package/dist/os/werkstatt/handlers/workspace-deps.d.ts.map +0 -1
  231. package/dist/os/werkstatt/handlers/workspace-deps.js +0 -42
  232. package/dist/os/werkstatt/handlers/workspace-deps.js.map +0 -1
  233. package/dist/os/werkstatt/index.d.ts +0 -7
  234. package/dist/os/werkstatt/index.d.ts.map +0 -1
  235. package/dist/os/werkstatt/index.js +0 -18
  236. package/dist/os/werkstatt/index.js.map +0 -1
  237. package/dist/os/werkstatt/werkstatt.module.d.ts +0 -3
  238. package/dist/os/werkstatt/werkstatt.module.d.ts.map +0 -1
  239. package/dist/os/werkstatt/werkstatt.module.js +0 -91
  240. package/dist/os/werkstatt/werkstatt.module.js.map +0 -1
  241. package/os/core/handlers/forge-autonomy-validate.ts +0 -276
  242. package/os/correctness/gate/trust-boundary-cx19.test.ts +0 -514
  243. package/os/mission/handlers/archive.test.ts +0 -764
  244. package/os/mission/handlers/archive.ts +0 -711
  245. package/os/mission/handlers/ship-inflight-degraded.test.ts +0 -105
  246. package/os/mission/importer-block.ts +0 -119
  247. package/os/mission/index.ts +0 -15
  248. package/os/mission/lockfile.ts +0 -152
  249. package/os/mission/mission.module.ts +0 -68
  250. package/os/mission/open-missions.ts +0 -50
  251. package/os/mission/types.ts +0 -42
  252. package/os/werkstatt/handlers/lock.ts +0 -168
  253. package/os/werkstatt/handlers/schema.ts +0 -47
  254. package/os/werkstatt/handlers/werkstatt-lock-recover.ts +0 -206
  255. package/os/werkstatt/handlers/werkstatt-lock-status.ts +0 -82
  256. package/os/werkstatt/handlers/werkstatt-operation-validate.ts +0 -112
  257. package/os/werkstatt/handlers/workspace-deps.ts +0 -56
  258. package/os/werkstatt/index.ts +0 -39
  259. package/os/werkstatt/werkstatt.module.ts +0 -95
  260. package/src/tests/doctor-autonomy.test.ts +0 -246
  261. package/src/tests/forge-autonomy-validate.test.ts +0 -159
  262. package/src/tests/werkstatt-lock.test.ts +0 -357
@@ -0,0 +1,529 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>Unit tests for RFC-0674/RFC-0677/RFC-0678/RFC-0679 lifecycle handlers — profile resolution, dry-run, build execution, validate with --artifact and violation parsing, determinism check, asset management.</purpose>
4
+ <non-goals>
5
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
6
+ </non-goals>
7
+ </MODULE_CONTRACT>
8
+ <CHANGE_SUMMARY>
9
+ <item>RFC-0674: initial lifecycle handler tests — profile resolution, dry-run, build execution.</item>
10
+ <item>RFC-0677: added tests for --artifact filtering, violation parsing (json/plain), allPassed, empty-state.</item>
11
+ <item>RFC-0678: added tests for determinism check — dry-run, --artifact, no-hashable, cache hit, non-deterministic detection.</item>
12
+ <item>RFC-0679: added tests for asset list/check — dry-run, --type, missing, orphaned, --strict.</item>
13
+ <item>RFC-0680: added tests for release prepare/publish — dry-run, manifest generation, publish dry-run, no-release-config.</item>
14
+ </CHANGE_SUMMARY>
15
+ */
16
+
17
+ import { test, expect, beforeEach, afterEach } from "vitest";
18
+ import { join } from "node:path";
19
+ import { writeFileSync, mkdirSync, rmSync } from "node:fs";
20
+ import { tmpdir } from "node:os";
21
+ import type { ForgeCommandInput, ForgeRuntimeContext } from "../../../src/types.ts";
22
+ import { resolveActiveProfile } from "./profile-resolve.ts";
23
+ import { runBuild } from "./build.ts";
24
+ import { runValidate, parseViolations } from "./validate.ts";
25
+ import { runDeterminismCheck } from "./determinism-check.ts";
26
+ import { runAssetsList } from "./assets-list.ts";
27
+ import { runAssetsCheck } from "./assets-check.ts";
28
+ import { runReleasePrepare } from "./release-prepare.ts";
29
+ import { runReleasePublish } from "./release-publish.ts";
30
+ import { runDev } from "./dev.ts";
31
+
32
+ const FORGE_ROOT = join(import.meta.dirname, "..", "..", "..");
33
+
34
+ function makeTempWorkspace(profileYaml?: string): string {
35
+ const dir = join(
36
+ tmpdir(),
37
+ `forge-lifecycle-test-${Date.now()}-${Math.random().toString(36).slice(2)}`,
38
+ );
39
+ mkdirSync(dir, { recursive: true });
40
+
41
+ if (profileYaml) {
42
+ writeFileSync(join(dir, "forge.yaml"), profileYaml);
43
+ }
44
+
45
+ return dir;
46
+ }
47
+
48
+ function makeContext(workspaceRoot: string): ForgeRuntimeContext {
49
+ return {
50
+ workspaceRoot,
51
+ logger: {
52
+ section: () => {},
53
+ info: () => {},
54
+ warn: () => {},
55
+ error: () => {},
56
+ success: () => {},
57
+ },
58
+ dryRun: false,
59
+ outputFormat: "pretty",
60
+ forgeRoot: FORGE_ROOT,
61
+ };
62
+ }
63
+
64
+ const input = (flags: Record<string, unknown> = {}): ForgeCommandInput => ({
65
+ argv: [],
66
+ flags: flags as Record<string, boolean | string | string[]>,
67
+ });
68
+
69
+ const godotYaml = `profile: godot-game\n`;
70
+
71
+ let tmpDir: string;
72
+
73
+ beforeEach(() => {
74
+ tmpDir = makeTempWorkspace(godotYaml);
75
+ });
76
+
77
+ afterEach(() => {
78
+ rmSync(tmpDir, { recursive: true, force: true });
79
+ });
80
+
81
+ // ── resolveActiveProfile ──────────────────────────────────────────────────
82
+
83
+ test("resolveActiveProfile returns the godot-game profile when forge.yaml declares it", () => {
84
+ const resolved = resolveActiveProfile(tmpDir, FORGE_ROOT);
85
+ expect(resolved).not.toBeNull();
86
+ expect(resolved!.profile.id).toBe("godot-game");
87
+ });
88
+
89
+ test("resolveActiveProfile returns null when forge.yaml has no profile field", () => {
90
+ const dir = makeTempWorkspace(`project:\n name: test\n`);
91
+ const resolved = resolveActiveProfile(dir, FORGE_ROOT);
92
+ expect(resolved).toBeNull();
93
+ rmSync(dir, { recursive: true, force: true });
94
+ });
95
+
96
+ test("resolveActiveProfile returns null when forge.yaml is missing", () => {
97
+ const dir = makeTempWorkspace();
98
+ const resolved = resolveActiveProfile(dir, FORGE_ROOT);
99
+ expect(resolved).toBeNull();
100
+ });
101
+
102
+ test("resolveActiveProfile uses profileIdOverride when provided", () => {
103
+ const resolved = resolveActiveProfile(tmpDir, FORGE_ROOT, "godot-game");
104
+ expect(resolved).not.toBeNull();
105
+ expect(resolved!.profile.id).toBe("godot-game");
106
+ });
107
+
108
+ // ── runBuild ───────────────────────────────────────────────────────────────
109
+
110
+ test("runBuild --dry-run does not execute child process and prints resolved commands", async () => {
111
+ const result = await runBuild(input({ "dry-run": true }), makeContext(tmpDir));
112
+ expect(result.exitCode).toBeUndefined();
113
+ expect(result.data?.profileId).toBe("godot-game");
114
+ expect(result.data?.artifacts.length).toBeGreaterThan(0);
115
+ const game = result.data?.artifacts.find((a) => a.id === "game");
116
+ expect(game).toBeDefined();
117
+ });
118
+
119
+ test("runBuild returns exit 1 when no active profile found", async () => {
120
+ const dir = makeTempWorkspace();
121
+ const result = await runBuild(input({}), makeContext(dir));
122
+ expect(result.exitCode).toBe(1);
123
+ rmSync(dir, { recursive: true, force: true });
124
+ });
125
+
126
+ test("runBuild --dry-run resolves commands without execution", async () => {
127
+ const result = await runBuild(input({ "dry-run": true }), makeContext(tmpDir));
128
+ expect(result.data?.artifacts.length).toBeGreaterThan(0);
129
+ expect(result.summary).toContain("[dry-run]");
130
+ });
131
+
132
+ // ── runValidate ─────────────────────────────────────────────────────────────
133
+
134
+ test("runValidate --dry-run does not execute child process and prints resolved commands", async () => {
135
+ const result = await runValidate(input({ "dry-run": true }), makeContext(tmpDir));
136
+ expect(result.data?.profileId).toBe("godot-game");
137
+ expect(result.data?.artifacts.length).toBeGreaterThan(0);
138
+ const game = result.data?.artifacts.find((a) => a.id === "game");
139
+ expect(game).toBeDefined();
140
+ expect(game!.command).toBe("godot --path . --headless --quit");
141
+ });
142
+
143
+ test("runValidate returns exit 1 when no active profile found", async () => {
144
+ const dir = makeTempWorkspace();
145
+ const result = await runValidate(input({}), makeContext(dir));
146
+ expect(result.exitCode).toBe(1);
147
+ rmSync(dir, { recursive: true, force: true });
148
+ });
149
+
150
+ // ── runValidate RFC-0677: --artifact, violation parsing, allPassed ─────────
151
+
152
+ test("runValidate --artifact game filters to a single artifact in dry-run", async () => {
153
+ const result = await runValidate(
154
+ input({ "dry-run": true, artifact: "game" }),
155
+ makeContext(tmpDir),
156
+ );
157
+ expect(result.data?.artifacts.length).toBe(1);
158
+ expect(result.data?.artifacts[0].id).toBe("game");
159
+ });
160
+
161
+ test("runValidate --artifact unknown returns exit 1 with not-declared message", async () => {
162
+ const result = await runValidate(
163
+ input({ "dry-run": true, artifact: "nonexistent" }),
164
+ makeContext(tmpDir),
165
+ );
166
+ expect(result.exitCode).toBe(1);
167
+ expect(result.summary).toContain("not declared");
168
+ });
169
+
170
+ test("runValidate --dry-run includes passed and violations fields", async () => {
171
+ const result = await runValidate(input({ "dry-run": true }), makeContext(tmpDir));
172
+ expect(result.data?.allPassed).toBe(true);
173
+ const game = result.data?.artifacts.find((a) => a.id === "game");
174
+ expect(game?.passed).toBe(true);
175
+ expect(game?.violations).toEqual([]);
176
+ });
177
+
178
+ test("parseViolations extracts structured violations from JSON output", () => {
179
+ const jsonOutput = JSON.stringify([
180
+ { file: "Main.tscn", line: 12, severity: "error", message: "missing script" },
181
+ { file: "Player.cs", line: 5, severity: "warning", message: "deprecated method" },
182
+ ]);
183
+ const violations = parseViolations(jsonOutput, "json", undefined);
184
+ expect(violations.length).toBe(2);
185
+ expect(violations[0].file).toBe("Main.tscn");
186
+ expect(violations[0].line).toBe(12);
187
+ expect(violations[0].severity).toBe("error");
188
+ expect(violations[1].severity).toBe("warning");
189
+ });
190
+
191
+ test("parseViolations extracts structured violations from plain text with regex", () => {
192
+ const plainOutput = [
193
+ "Scenes/Main.tscn:12: error: scene missing script attribute",
194
+ "Scripts/Player.cs:5: warning: deprecated method call",
195
+ ].join("\n");
196
+ const pattern =
197
+ "^(?<file>[^:]+):(?<line>\\d+):\\s*(?<severity>error|warning):\\s*(?<message>.+)$";
198
+ const violations = parseViolations(plainOutput, "plain", pattern);
199
+ expect(violations.length).toBe(2);
200
+ expect(violations[0].file).toBe("Scenes/Main.tscn");
201
+ expect(violations[0].line).toBe(12);
202
+ expect(violations[0].severity).toBe("error");
203
+ expect(violations[0].message).toContain("missing script");
204
+ expect(violations[1].severity).toBe("warning");
205
+ });
206
+
207
+ test("parseViolations returns empty array when outputFormat is not set", () => {
208
+ const violations = parseViolations("some output", undefined, undefined);
209
+ expect(violations).toEqual([]);
210
+ });
211
+
212
+ test("parseViolations returns empty array on malformed JSON", () => {
213
+ const violations = parseViolations("not json", "json", undefined);
214
+ expect(violations).toEqual([]);
215
+ });
216
+
217
+ test("parseViolations returns empty array on malformed regex pattern", () => {
218
+ const violations = parseViolations("some output", "plain", "[invalid(");
219
+ expect(violations).toEqual([]);
220
+ });
221
+
222
+ // ── runDev ──────────────────────────────────────────────────────────────────
223
+
224
+ test("runDev --dry-run does not spawn child process and prints resolved command", async () => {
225
+ const result = await runDev(input({ "dry-run": true }), makeContext(tmpDir));
226
+ expect(result.data?.profileId).toBe("godot-game");
227
+ expect(result.data?.devServerCommand).toBe("godot --path . --editor");
228
+ expect(result.data?.port).toBe(6005);
229
+ expect(result.data?.exitCode).toBe(0);
230
+ });
231
+
232
+ test("runDev returns exit 1 when profile has no devServer", async () => {
233
+ // forge-shell profile has no devServer
234
+ const dir = makeTempWorkspace(`profile: forge-shell\n`);
235
+ const result = await runDev(input({}), makeContext(dir));
236
+ expect(result.exitCode).toBe(1);
237
+ expect(result.summary).toContain("does not declare a devServer");
238
+ rmSync(dir, { recursive: true, force: true });
239
+ });
240
+
241
+ test("runDev returns exit 1 when no active profile found", async () => {
242
+ const dir = makeTempWorkspace();
243
+ const result = await runDev(input({}), makeContext(dir));
244
+ expect(result.exitCode).toBe(1);
245
+ rmSync(dir, { recursive: true, force: true });
246
+ });
247
+
248
+ // ── runDeterminismCheck RFC-0678 ─────────────────────────────────────────────
249
+
250
+ test("runDeterminismCheck --dry-run prints resolved inputs without executing builds", async () => {
251
+ const result = await runDeterminismCheck(input({ "dry-run": true }), makeContext(tmpDir));
252
+ expect(result.data?.profileId).toBe("godot-game");
253
+ expect(result.data?.artifacts.length).toBe(1);
254
+ expect(result.data?.artifacts[0].artifactId).toBe("game");
255
+ expect(result.data?.artifacts[0].inputs).toContain("Scenes/**/*.tscn");
256
+ expect(result.data?.artifacts[0].inputs).toContain("project.godot");
257
+ expect(result.summary).toContain("[dry-run]");
258
+ });
259
+
260
+ test("runDeterminismCheck --artifact game filters to a single artifact", async () => {
261
+ const result = await runDeterminismCheck(
262
+ input({ "dry-run": true, artifact: "game" }),
263
+ makeContext(tmpDir),
264
+ );
265
+ expect(result.data?.artifacts.length).toBe(1);
266
+ expect(result.data?.artifacts[0].artifactId).toBe("game");
267
+ });
268
+
269
+ test("runDeterminismCheck --artifact unknown returns exit 1", async () => {
270
+ const result = await runDeterminismCheck(
271
+ input({ "dry-run": true, artifact: "nonexistent" }),
272
+ makeContext(tmpDir),
273
+ );
274
+ expect(result.exitCode).toBe(1);
275
+ expect(result.summary).toContain("not declared");
276
+ });
277
+
278
+ test("runDeterminismCheck returns exit 1 when no active profile found", async () => {
279
+ const dir = makeTempWorkspace();
280
+ const result = await runDeterminismCheck(input({}), makeContext(dir));
281
+ expect(result.exitCode).toBe(1);
282
+ rmSync(dir, { recursive: true, force: true });
283
+ });
284
+
285
+ test("runDeterminismCheck returns exit 0 when profile has no hashable artifacts", async () => {
286
+ // Create a custom profile with an artifact that has no determinism field
287
+ // We can't easily do this without modifying forge profiles, so instead
288
+ // test with a profile that has no artifacts at all — the handler returns
289
+ // exit 1 for "no artifacts" and exit 0 for "no hashable artifacts".
290
+ // Since forge-shell has no artifacts, we test the no-artifacts path.
291
+ const dir = makeTempWorkspace(`profile: forge-shell\n`);
292
+ const result = await runDeterminismCheck(input({}), makeContext(dir));
293
+ expect(result.exitCode).toBe(1);
294
+ expect(result.summary).toContain("does not declare any artifacts");
295
+ rmSync(dir, { recursive: true, force: true });
296
+ });
297
+
298
+ test("runDeterminismCheck cache hit skips double-build", async () => {
299
+ // Create input files matching the glob patterns
300
+ mkdirSync(join(tmpDir, "Scenes"), { recursive: true });
301
+ writeFileSync(join(tmpDir, "Scenes", "Main.tscn"), "[gd_scene]");
302
+ mkdirSync(join(tmpDir, "Scripts"), { recursive: true });
303
+ writeFileSync(join(tmpDir, "Scripts", "Main.cs"), "using Godot;");
304
+ writeFileSync(join(tmpDir, "project.godot"), "[application]\n");
305
+
306
+ // Create the output file that the produce command would create
307
+ mkdirSync(join(tmpDir, "bin"), { recursive: true });
308
+ writeFileSync(join(tmpDir, "bin", "Debug"), "fake-build-content");
309
+
310
+ // First run: the produce command "dotnet build" will fail, but the input hash
311
+ // is computed before the build. We can read it from the result.
312
+ const result1 = await runDeterminismCheck(input({}), makeContext(tmpDir));
313
+ expect(result1.exitCode).toBe(1); // build fails
314
+ const inputHash = result1.data?.artifacts[0].inputHash;
315
+ expect(inputHash).toBeTruthy();
316
+
317
+ // Write a cache entry with the correct input hash
318
+ const cachePath = join(tmpDir, "dist", ".determinism-cache.json");
319
+ mkdirSync(join(tmpDir, "dist"), { recursive: true });
320
+ const cache = {
321
+ entries: {
322
+ [`game:${inputHash}:dotnet build`]: {
323
+ inputHash,
324
+ produceCommand: "dotnet build",
325
+ outputHash: "sha256:cached-hash",
326
+ deterministic: true,
327
+ },
328
+ },
329
+ };
330
+ writeFileSync(cachePath, JSON.stringify(cache, null, 2) + "\n");
331
+
332
+ // Second run: should hit the cache and skip the build
333
+ const result2 = await runDeterminismCheck(input({}), makeContext(tmpDir));
334
+ expect(result2.exitCode).toBe(0); // cached as deterministic
335
+ expect(result2.data?.artifacts[0].cached).toBe(true);
336
+ expect(result2.data?.artifacts[0].deterministic).toBe(true);
337
+ expect(result2.data?.artifacts[0].firstBuildHash).toBe("sha256:cached-hash");
338
+ // Generous timeout: on runners where `dotnet` is genuinely installed
339
+ // (windows-2022) the expected-failure build takes real CLI warmup time.
340
+ }, 120000);
341
+
342
+ // ── runAssetsList RFC-0679 ───────────────────────────────────────────────────
343
+
344
+ test("runAssetsList --dry-run lists assets without hashing", async () => {
345
+ // Create asset files
346
+ mkdirSync(join(tmpDir, "Assets", "images"), { recursive: true });
347
+ writeFileSync(join(tmpDir, "Assets", "images", "bg.png"), "fake-png");
348
+ mkdirSync(join(tmpDir, "Assets", "audio"), { recursive: true });
349
+ writeFileSync(join(tmpDir, "Assets", "audio", "narration.wav"), "fake-wav");
350
+
351
+ const result = await runAssetsList(input({ "dry-run": true }), makeContext(tmpDir));
352
+ expect(result.data?.profileId).toBe("godot-game");
353
+ expect(result.data?.assets.length).toBe(2);
354
+ const image = result.data?.assets.find((a) => a.type === "image");
355
+ expect(image).toBeDefined();
356
+ expect(image!.path).toBe("Assets/images/bg.png");
357
+ expect(image!.hash).toBe(""); // dry-run skips hashing
358
+ expect(image!.size).toBe(0);
359
+ });
360
+
361
+ test("runAssetsList --type image filters by type", async () => {
362
+ mkdirSync(join(tmpDir, "Assets", "images"), { recursive: true });
363
+ writeFileSync(join(tmpDir, "Assets", "images", "bg.png"), "fake-png");
364
+ mkdirSync(join(tmpDir, "Assets", "audio"), { recursive: true });
365
+ writeFileSync(join(tmpDir, "Assets", "audio", "narration.wav"), "fake-wav");
366
+
367
+ const result = await runAssetsList(
368
+ input({ "dry-run": true, type: "image" }),
369
+ makeContext(tmpDir),
370
+ );
371
+ expect(result.data?.assets.length).toBe(1);
372
+ expect(result.data?.assets[0].type).toBe("image");
373
+ });
374
+
375
+ test("runAssetsList returns exit 1 when no active profile found", async () => {
376
+ const dir = makeTempWorkspace();
377
+ const result = await runAssetsList(input({}), makeContext(dir));
378
+ expect(result.exitCode).toBe(1);
379
+ rmSync(dir, { recursive: true, force: true });
380
+ });
381
+
382
+ test("runAssetsList returns exit 0 when profile has no assets declaration", async () => {
383
+ const dir = makeTempWorkspace(`profile: forge-shell\n`);
384
+ const result = await runAssetsList(input({}), makeContext(dir));
385
+ expect(result.exitCode).toBe(0);
386
+ expect(result.summary).toContain("does not declare assets");
387
+ rmSync(dir, { recursive: true, force: true });
388
+ });
389
+
390
+ // ── runAssetsCheck RFC-0679 ──────────────────────────────────────────────────
391
+
392
+ test("runAssetsCheck detects missing assets referenced by scenes", async () => {
393
+ // Create a scene that references a non-existent asset
394
+ mkdirSync(join(tmpDir, "Scenes"), { recursive: true });
395
+ writeFileSync(join(tmpDir, "Scenes", "Main.tscn"), '"res://Assets/images/missing.png"');
396
+
397
+ const result = await runAssetsCheck(input({ "dry-run": true }), makeContext(tmpDir));
398
+ expect(result.exitCode).toBe(1);
399
+ expect(result.data?.check.missing.length).toBeGreaterThan(0);
400
+ const missing = result.data?.check.missing.find((m) => m.path.includes("missing.png"));
401
+ expect(missing).toBeDefined();
402
+ expect(missing!.referencedBy).toContain("Scenes/Main.tscn");
403
+ });
404
+
405
+ test("runAssetsCheck detects orphaned assets not referenced by any scene", async () => {
406
+ // Create an asset with no scene referencing it
407
+ mkdirSync(join(tmpDir, "Assets", "audio"), { recursive: true });
408
+ writeFileSync(join(tmpDir, "Assets", "audio", "unused.wav"), "fake-wav");
409
+
410
+ const result = await runAssetsCheck(input({ "dry-run": true }), makeContext(tmpDir));
411
+ // Without --strict, orphaned assets are warnings (exit 0)
412
+ expect(result.data?.check.orphaned.length).toBeGreaterThan(0);
413
+ const orphaned = result.data?.check.orphaned.find((o) => o.path.includes("unused.wav"));
414
+ expect(orphaned).toBeDefined();
415
+ expect(orphaned!.type).toBe("audio");
416
+ });
417
+
418
+ test("runAssetsCheck --strict exits non-zero when orphaned assets are found", async () => {
419
+ mkdirSync(join(tmpDir, "Assets", "audio"), { recursive: true });
420
+ writeFileSync(join(tmpDir, "Assets", "audio", "unused.wav"), "fake-wav");
421
+
422
+ const result = await runAssetsCheck(
423
+ input({ "dry-run": true, strict: true }),
424
+ makeContext(tmpDir),
425
+ );
426
+ expect(result.exitCode).toBe(1);
427
+ expect(result.data?.check.orphaned.length).toBeGreaterThan(0);
428
+ });
429
+
430
+ test("runAssetsCheck --dry-run only checks file existence", async () => {
431
+ mkdirSync(join(tmpDir, "Assets", "images"), { recursive: true });
432
+ writeFileSync(join(tmpDir, "Assets", "images", "bg.png"), "fake-png");
433
+ mkdirSync(join(tmpDir, "Scenes"), { recursive: true });
434
+ writeFileSync(join(tmpDir, "Scenes", "Main.tscn"), '"Assets/images/bg.png"');
435
+
436
+ const result = await runAssetsCheck(input({ "dry-run": true }), makeContext(tmpDir));
437
+ expect(result.exitCode).toBe(0);
438
+ expect(result.data?.check.missing).toEqual([]);
439
+ expect(result.data?.check.orphaned).toEqual([]);
440
+ expect(result.data?.allOk).toBe(true);
441
+ });
442
+
443
+ test("runAssetsCheck returns exit 1 when no active profile found", async () => {
444
+ const dir = makeTempWorkspace();
445
+ const result = await runAssetsCheck(input({}), makeContext(dir));
446
+ expect(result.exitCode).toBe(1);
447
+ rmSync(dir, { recursive: true, force: true });
448
+ });
449
+
450
+ // ── runReleasePrepare RFC-0680 ───────────────────────────────────────────────
451
+
452
+ test("runReleasePrepare --dry-run prints resolved release steps", async () => {
453
+ // Create a built artifact at the produce.output path
454
+ mkdirSync(join(tmpDir, "bin"), { recursive: true });
455
+ writeFileSync(join(tmpDir, "bin", "Debug"), "fake-build-content");
456
+
457
+ const result = await runReleasePrepare(input({ "dry-run": true }), makeContext(tmpDir));
458
+ expect(result.data?.profileId).toBe("godot-game");
459
+ expect(result.data?.manifest.schemaVersion).toBe("1");
460
+ expect(result.data?.manifest.artifacts.length).toBeGreaterThan(0);
461
+ expect(result.data?.manifest.artifacts[0].artifactId).toBe("game");
462
+ expect(result.data?.manifest.determinismChecked).toBe(false);
463
+ expect(result.data?.manifest.validationPassed).toBe(true);
464
+ });
465
+
466
+ test("runReleasePrepare generates manifest with artifact hashes", async () => {
467
+ mkdirSync(join(tmpDir, "bin"), { recursive: true });
468
+ writeFileSync(join(tmpDir, "bin", "Debug"), "fake-build-content");
469
+
470
+ const result = await runReleasePrepare(input({}), makeContext(tmpDir));
471
+ expect(result.exitCode ?? 0).toBe(0);
472
+ expect(result.data?.manifest.artifacts.length).toBeGreaterThan(0);
473
+ expect(result.data?.manifest.artifacts[0].hash).toBeTruthy();
474
+ expect(result.data?.manifest.artifacts[0].size).toBeGreaterThan(0);
475
+ expect(result.data?.manifest.releaseId).toContain("godot-game-");
476
+ expect(result.data?.manifest.schemaVersion).toBe("1");
477
+ });
478
+
479
+ test("runReleasePrepare returns exit 1 when no release config", async () => {
480
+ const dir = makeTempWorkspace(`profile: forge-shell\n`);
481
+ const result = await runReleasePrepare(input({}), makeContext(dir));
482
+ expect(result.exitCode).toBe(1);
483
+ expect(result.summary).toContain("does not declare a release");
484
+ rmSync(dir, { recursive: true, force: true });
485
+ });
486
+
487
+ test("runReleasePrepare returns exit 1 when no active profile", async () => {
488
+ const dir = makeTempWorkspace();
489
+ const result = await runReleasePrepare(input({}), makeContext(dir));
490
+ expect(result.exitCode).toBe(1);
491
+ rmSync(dir, { recursive: true, force: true });
492
+ });
493
+
494
+ test("runReleasePrepare returns exit 1 when build output not found", async () => {
495
+ // No build/ directory created
496
+ const result = await runReleasePrepare(input({}), makeContext(tmpDir));
497
+ expect(result.exitCode).toBe(1);
498
+ expect(result.summary).toContain("no built output");
499
+ });
500
+
501
+ // ── runReleasePublish RFC-0680 ───────────────────────────────────────────────
502
+
503
+ test("runReleasePublish --dry-run does not upload anything", async () => {
504
+ // Prepare a release first
505
+ mkdirSync(join(tmpDir, "bin"), { recursive: true });
506
+ writeFileSync(join(tmpDir, "bin", "Debug"), "fake-build-content");
507
+ await runReleasePrepare(input({}), makeContext(tmpDir));
508
+
509
+ const result = await runReleasePublish(input({ "dry-run": true }), makeContext(tmpDir));
510
+ expect(result.exitCode ?? 0).toBe(0);
511
+ expect(result.data?.target).toBe("local");
512
+ expect(result.data?.publishedFiles.length).toBeGreaterThan(0);
513
+ // Should not have created a published/ directory
514
+ expect(result.summary).toContain("[dry-run]");
515
+ });
516
+
517
+ test("runReleasePublish returns exit 1 when no manifest found", async () => {
518
+ // No release prepared — release dir doesn't exist
519
+ const result = await runReleasePublish(input({}), makeContext(tmpDir));
520
+ expect(result.exitCode).toBe(1);
521
+ expect(result.summary).toContain("No release manifest found");
522
+ });
523
+
524
+ test("runReleasePublish returns exit 1 when no active profile", async () => {
525
+ const dir = makeTempWorkspace();
526
+ const result = await runReleasePublish(input({}), makeContext(dir));
527
+ expect(result.exitCode).toBe(1);
528
+ rmSync(dir, { recursive: true, force: true });
529
+ });
@@ -16,6 +16,8 @@
16
16
 
17
17
  import { join, basename, relative } from "node:path";
18
18
  import { ambientIo, resolveIo } from "../../../src/utils/io.ts";
19
+ import { collectFiles } from "../../../src/utils/fs.ts";
20
+ import { byteHashFile } from "../../../src/utils/hash.ts";
19
21
  import { createHash } from "node:crypto";
20
22
  import type {
21
23
  ForgeCommandInput,
@@ -23,7 +25,6 @@ import type {
23
25
  ForgeRuntimeContext,
24
26
  } from "../../../src/types.ts";
25
27
  import { resolveActiveProfile, resolveLifecycleFlags } from "./profile-resolve.ts";
26
- import { loadWorkspaceDeps } from "../../werkstatt/handlers/workspace-deps.ts";
27
28
  import { writeFileIfChanged } from "../../../src/utils/fs-idempotent.ts";
28
29
  import type { ProfileRelease } from "../../../src/profiles/profile-schema.ts";
29
30
 
@@ -76,7 +77,6 @@ async function findBuiltArtifacts(
76
77
  produceOutput?: string,
77
78
  ): Promise<string[]> {
78
79
  if (produceOutput) {
79
- const { collectFiles } = await loadWorkspaceDeps();
80
80
  const outputPattern = produceOutput.replace("{composition}", "*");
81
81
  const basePattern = basename(outputPattern);
82
82
  const isGlob = basePattern.includes("*");
@@ -102,7 +102,6 @@ async function findBuiltArtifacts(
102
102
  );
103
103
  return files.filter((f) => regex.test(basename(f)));
104
104
  }
105
- const { collectFiles } = await loadWorkspaceDeps();
106
105
  const distDir = join(workspaceRoot, "dist");
107
106
  return collectFiles(distDir, {
108
107
  extensions,
@@ -218,7 +217,6 @@ export async function runReleasePrepare(
218
217
  let size = 0;
219
218
 
220
219
  if (!dryRun) {
221
- const { byteHashFile } = await loadWorkspaceDeps();
222
220
  hash = await byteHashFile(builtFile);
223
221
  const stats = await io.stat(builtFile);
224
222
  size = stats.size;
@@ -89,7 +89,7 @@ import { isFlowAdopted } from "../../flow/index.ts";
89
89
  import { renderManagedPreCommit } from "../../flow/guard-files.ts";
90
90
  import { collectFlowCheck } from "../../flow/handlers/flow-check.ts";
91
91
  import { runCompassAuditValidate } from "../../compass/handlers/compass-audit-handler.ts";
92
- import { restoreTrackedLockfile } from "../../mission/lockfile.ts";
92
+ import { restoreTrackedLockfile } from "../../../src/utils/lockfile.ts";
93
93
  import { runValidate as runProgramPacketValidate } from "../../program/handlers/validate.ts";
94
94
  import { runAdrImplementStamp } from "../../adr/handlers/implement-stamp.ts";
95
95
  import { runAdrValidate } from "../../adr/handlers/validate.ts";
@@ -22,7 +22,7 @@ import type {
22
22
  ForgeRuntimeContext,
23
23
  } from "../../../src/types.ts";
24
24
  import { resolveIo } from "../../../src/utils/io.ts";
25
- import { openMissionsIn } from "../../mission/open-missions.ts";
25
+ import { openMissionsIn } from "../open-missions.ts";
26
26
  import { commonGitDir, INTEGRATE_LOCK_RELATIVE_PATH, readRegistry } from "../registry.ts";
27
27
  import { requireGit, topLevel } from "../git.ts";
28
28
  import { describeHeldLock } from "../locks.ts";
@@ -0,0 +1,45 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>Open-mission scan for forge's flow gates — globs missions/<id>/mission.yaml
4
+ under a checkout, counts `state: "open"`, treats an unreadable manifest as open
5
+ (a corrupt live work unit must never silently pass). Transitional host-layout
6
+ awareness retained in core: inert in repos without a missions/ tree. Target state
7
+ per Werkstatt RFC-1645 is a host-port extension registered by the host's plugin
8
+ (extraction at program WP-4/5/8) — recorded in the protection migration map.
9
+ </purpose>
10
+ <non-goals>
11
+ <item>Read-only — never mutates mission state; mission lifecycle operations are studio-private and did not transfer to core.</item>
12
+ </non-goals>
13
+ </MODULE_CONTRACT>
14
+ */
15
+
16
+ import { basename, dirname, join } from "node:path";
17
+
18
+ import { parse as yamlParse } from "yaml";
19
+
20
+ import type { WorkspaceIO } from "../../src/types.ts";
21
+
22
+ /**
23
+ * Mission ids whose `missions/<id>/mission.yaml` declares `state: "open"`.
24
+ * An unreadable manifest counts as open. Sorted for deterministic output.
25
+ */
26
+ export async function openMissionsIn(
27
+ worktree: string,
28
+ io: WorkspaceIO,
29
+ ): Promise<string[]> {
30
+ const manifests = await io.glob("missions/*/mission.yaml", { cwd: worktree });
31
+ const open: string[] = [];
32
+ for (const rel of manifests) {
33
+ try {
34
+ const parsed = yamlParse(await io.readFile(join(worktree, rel))) as {
35
+ state?: unknown;
36
+ } | null;
37
+ if (parsed?.state === "open") {
38
+ open.push(basename(dirname(rel)));
39
+ }
40
+ } catch {
41
+ open.push(basename(dirname(rel)));
42
+ }
43
+ }
44
+ return open.sort();
45
+ }
@@ -35,7 +35,7 @@ import type {
35
35
  } from "../../src/types.ts";
36
36
  import { loadLiveCommandInventory } from "../../src/utils/command-inventory.ts";
37
37
  import { isGeneratedContent, isGeneratedPathName, REGEN_FLAGS } from "../core/archive-regen.ts";
38
- import { openMissionsIn } from "../mission/open-missions.ts";
38
+ import { openMissionsIn } from "./open-missions.ts";
39
39
  import {
40
40
  classifyDirtyPath,
41
41
  FOREIGN_PRIMARY_DIRT_HINT,