@warpgogol/forge 9.7.0 → 10.0.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 (327) hide show
  1. package/AGENTS.md +50 -27
  2. package/CHANGELOG.md +52 -0
  3. package/bin/cli.js +0 -0
  4. package/dist/os/adr/handlers/archive.d.ts.map +1 -1
  5. package/dist/os/adr/handlers/archive.js +3 -7
  6. package/dist/os/adr/handlers/archive.js.map +1 -1
  7. package/dist/os/adr/handlers/list-create.d.ts.map +1 -1
  8. package/dist/os/adr/handlers/list-create.js +8 -6
  9. package/dist/os/adr/handlers/list-create.js.map +1 -1
  10. package/dist/os/audit/handlers/archive.d.ts.map +1 -1
  11. package/dist/os/audit/handlers/archive.js +3 -7
  12. package/dist/os/audit/handlers/archive.js.map +1 -1
  13. package/dist/os/codebase/handlers/codebase-measure-symbols.d.ts.map +1 -1
  14. package/dist/os/codebase/handlers/codebase-measure-symbols.js +35 -4
  15. package/dist/os/codebase/handlers/codebase-measure-symbols.js.map +1 -1
  16. package/dist/os/core/archive-regen.d.ts +1 -0
  17. package/dist/os/core/archive-regen.d.ts.map +1 -1
  18. package/dist/os/core/archive-regen.js +31 -6
  19. package/dist/os/core/archive-regen.js.map +1 -1
  20. package/dist/os/core/core.module.d.ts.map +1 -1
  21. package/dist/os/core/core.module.js +6 -69
  22. package/dist/os/core/core.module.js.map +1 -1
  23. package/dist/os/core/handlers/assets-helpers.d.ts.map +1 -1
  24. package/dist/os/core/handlers/assets-helpers.js +2 -3
  25. package/dist/os/core/handlers/assets-helpers.js.map +1 -1
  26. package/dist/os/core/handlers/determinism-check.d.ts.map +1 -1
  27. package/dist/os/core/handlers/determinism-check.js +2 -3
  28. package/dist/os/core/handlers/determinism-check.js.map +1 -1
  29. package/dist/os/core/handlers/pinned-check.d.ts +13 -0
  30. package/dist/os/core/handlers/pinned-check.d.ts.map +1 -1
  31. package/dist/os/core/handlers/pinned-check.js +25 -0
  32. package/dist/os/core/handlers/pinned-check.js.map +1 -1
  33. package/dist/os/core/handlers/pinned-types.d.ts +7 -0
  34. package/dist/os/core/handlers/pinned-types.d.ts.map +1 -1
  35. package/dist/os/core/handlers/pinned-validate.d.ts.map +1 -1
  36. package/dist/os/core/handlers/pinned-validate.js +24 -1
  37. package/dist/os/core/handlers/pinned-validate.js.map +1 -1
  38. package/dist/os/core/handlers/release-prepare.d.ts.map +1 -1
  39. package/dist/os/core/handlers/release-prepare.js +2 -4
  40. package/dist/os/core/handlers/release-prepare.js.map +1 -1
  41. package/dist/os/flow/digest.d.ts +73 -1
  42. package/dist/os/flow/digest.d.ts.map +1 -1
  43. package/dist/os/flow/digest.js +344 -92
  44. package/dist/os/flow/digest.js.map +1 -1
  45. package/dist/os/flow/evidence-lock.d.ts +36 -0
  46. package/dist/os/flow/evidence-lock.d.ts.map +1 -0
  47. package/dist/os/flow/evidence-lock.js +156 -0
  48. package/dist/os/flow/evidence-lock.js.map +1 -0
  49. package/dist/os/flow/flow.module.d.ts.map +1 -1
  50. package/dist/os/flow/flow.module.js +36 -14
  51. package/dist/os/flow/flow.module.js.map +1 -1
  52. package/dist/os/flow/git.d.ts +50 -3
  53. package/dist/os/flow/git.d.ts.map +1 -1
  54. package/dist/os/flow/git.js +144 -12
  55. package/dist/os/flow/git.js.map +1 -1
  56. package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -1
  57. package/dist/os/flow/handlers/flow-digest.js +3 -5
  58. package/dist/os/flow/handlers/flow-digest.js.map +1 -1
  59. package/dist/os/flow/handlers/flow-peers.js +1 -1
  60. package/dist/os/flow/handlers/flow-peers.js.map +1 -1
  61. package/dist/os/flow/handlers/flow-push.d.ts +81 -0
  62. package/dist/os/flow/handlers/flow-push.d.ts.map +1 -1
  63. package/dist/os/flow/handlers/flow-push.js +642 -138
  64. package/dist/os/flow/handlers/flow-push.js.map +1 -1
  65. package/dist/os/flow/locks.d.ts +8 -0
  66. package/dist/os/flow/locks.d.ts.map +1 -1
  67. package/dist/os/flow/locks.js +6 -3
  68. package/dist/os/flow/locks.js.map +1 -1
  69. package/dist/os/{mission → flow}/open-missions.d.ts +1 -2
  70. package/dist/os/flow/open-missions.d.ts.map +1 -0
  71. package/dist/os/flow/open-missions.js +37 -0
  72. package/dist/os/flow/open-missions.js.map +1 -0
  73. package/dist/os/flow/preflight.d.ts.map +1 -1
  74. package/dist/os/flow/preflight.js +5 -3
  75. package/dist/os/flow/preflight.js.map +1 -1
  76. package/dist/os/flow/registry.d.ts +9 -5
  77. package/dist/os/flow/registry.d.ts.map +1 -1
  78. package/dist/os/flow/registry.js +2 -2
  79. package/dist/os/flow/registry.js.map +1 -1
  80. package/dist/os/friction/friction.module.d.ts.map +1 -1
  81. package/dist/os/friction/friction.module.js +30 -5
  82. package/dist/os/friction/friction.module.js.map +1 -1
  83. package/dist/os/friction/handlers/friction-add.d.ts.map +1 -1
  84. package/dist/os/friction/handlers/friction-add.js +10 -17
  85. package/dist/os/friction/handlers/friction-add.js.map +1 -1
  86. package/dist/os/friction/handlers/friction-migrate.d.ts.map +1 -1
  87. package/dist/os/friction/handlers/friction-migrate.js +188 -2
  88. package/dist/os/friction/handlers/friction-migrate.js.map +1 -1
  89. package/dist/os/friction/store.d.ts +4 -0
  90. package/dist/os/friction/store.d.ts.map +1 -1
  91. package/dist/os/friction/store.js +20 -0
  92. package/dist/os/friction/store.js.map +1 -1
  93. package/dist/os/friction/types.d.ts +12 -0
  94. package/dist/os/friction/types.d.ts.map +1 -1
  95. package/dist/os/friction/types.js +8 -0
  96. package/dist/os/friction/types.js.map +1 -1
  97. package/dist/os/gate/handlers/gate-probe-catalog.d.ts.map +1 -1
  98. package/dist/os/gate/handlers/gate-probe-catalog.js +38 -5
  99. package/dist/os/gate/handlers/gate-probe-catalog.js.map +1 -1
  100. package/dist/os/plan/handlers/archive.d.ts.map +1 -1
  101. package/dist/os/plan/handlers/archive.js +3 -7
  102. package/dist/os/plan/handlers/archive.js.map +1 -1
  103. package/dist/os/rfc/handlers/archive.d.ts.map +1 -1
  104. package/dist/os/rfc/handlers/archive.js +3 -7
  105. package/dist/os/rfc/handlers/archive.js.map +1 -1
  106. package/dist/os/rfc/handlers/list-create.d.ts.map +1 -1
  107. package/dist/os/rfc/handlers/list-create.js +15 -7
  108. package/dist/os/rfc/handlers/list-create.js.map +1 -1
  109. package/dist/os/session/handlers/archive.d.ts.map +1 -1
  110. package/dist/os/session/handlers/archive.js +3 -7
  111. package/dist/os/session/handlers/archive.js.map +1 -1
  112. package/dist/os/system/handlers/system-product-register.d.ts +24 -0
  113. package/dist/os/system/handlers/system-product-register.d.ts.map +1 -0
  114. package/dist/os/system/handlers/system-product-register.js +322 -0
  115. package/dist/os/system/handlers/system-product-register.js.map +1 -0
  116. package/dist/os/system/handlers/system-products-status.d.ts +23 -0
  117. package/dist/os/system/handlers/system-products-status.d.ts.map +1 -0
  118. package/dist/os/system/handlers/system-products-status.js +235 -0
  119. package/dist/os/system/handlers/system-products-status.js.map +1 -0
  120. package/dist/os/system/schemas.d.ts +13 -0
  121. package/dist/os/system/schemas.d.ts.map +1 -1
  122. package/dist/os/system/schemas.js +15 -0
  123. package/dist/os/system/schemas.js.map +1 -1
  124. package/dist/os/system/system.module.d.ts.map +1 -1
  125. package/dist/os/system/system.module.js +113 -3
  126. package/dist/os/system/system.module.js.map +1 -1
  127. package/dist/src/command-modules.d.ts.map +1 -1
  128. package/dist/src/command-modules.js +0 -2
  129. package/dist/src/command-modules.js.map +1 -1
  130. package/dist/src/config/forge-config.d.ts +2 -0
  131. package/dist/src/config/forge-config.d.ts.map +1 -1
  132. package/dist/src/config/forge-config.js +11 -10
  133. package/dist/src/config/forge-config.js.map +1 -1
  134. package/dist/src/index.d.ts +0 -2
  135. package/dist/src/index.d.ts.map +1 -1
  136. package/dist/src/index.js +0 -2
  137. package/dist/src/index.js.map +1 -1
  138. package/dist/src/onboarding/create.d.ts.map +1 -1
  139. package/dist/src/onboarding/create.js +27 -2
  140. package/dist/src/onboarding/create.js.map +1 -1
  141. package/dist/src/onboarding/doctor.d.ts +0 -5
  142. package/dist/src/onboarding/doctor.d.ts.map +1 -1
  143. package/dist/src/onboarding/doctor.js +6 -79
  144. package/dist/src/onboarding/doctor.js.map +1 -1
  145. package/dist/src/onboarding/npm-token-check.d.ts +1 -1
  146. package/dist/src/onboarding/npm-token-check.d.ts.map +1 -1
  147. package/dist/src/onboarding/npm-token-check.js +2 -2
  148. package/dist/src/onboarding/npm-token-check.js.map +1 -1
  149. package/dist/src/profiles/stack-profile.js +2 -2
  150. package/dist/src/types.js +2 -2
  151. package/dist/src/utils/hash.d.ts +1 -0
  152. package/dist/src/utils/hash.d.ts.map +1 -1
  153. package/dist/src/utils/hash.js +4 -0
  154. package/dist/src/utils/hash.js.map +1 -1
  155. package/dist/{os/mission → src/utils}/lockfile.d.ts +1 -18
  156. package/dist/src/utils/lockfile.d.ts.map +1 -0
  157. package/dist/src/utils/lockfile.js +70 -0
  158. package/dist/src/utils/lockfile.js.map +1 -0
  159. package/dist/src/utils/verifier-git.d.ts +27 -1
  160. package/dist/src/utils/verifier-git.d.ts.map +1 -1
  161. package/dist/src/utils/verifier-git.js +36 -6
  162. package/dist/src/utils/verifier-git.js.map +1 -1
  163. package/docs/reference/system-hub.md +104 -0
  164. package/os/adr/handlers/archive.ts +3 -11
  165. package/os/adr/handlers/list-create.test.ts +174 -0
  166. package/os/adr/handlers/list-create.ts +16 -8
  167. package/os/audit/handlers/archive.ts +3 -11
  168. package/os/codebase/handlers/codebase-measure-symbols.ts +32 -4
  169. package/os/core/archive-regen.ts +33 -7
  170. package/os/core/core.module.ts +10 -76
  171. package/os/core/docs-archive.test.ts +25 -0
  172. package/os/core/handlers/assets-helpers.ts +2 -4
  173. package/os/core/handlers/determinism-check.ts +2 -3
  174. package/os/core/handlers/lifecycle-handlers.test.ts +529 -0
  175. package/os/core/handlers/pinned-check.ts +30 -0
  176. package/os/core/handlers/pinned-types.ts +7 -0
  177. package/os/core/handlers/pinned-validate.ts +28 -3
  178. package/os/core/handlers/release-prepare.ts +2 -4
  179. package/os/correctness/gate/trust-boundary-cx18.test.ts +1 -1
  180. package/os/flow/digest.ts +436 -95
  181. package/os/flow/evidence-lock.ts +184 -0
  182. package/os/flow/flow.module.ts +37 -14
  183. package/os/flow/git.ts +206 -11
  184. package/os/flow/handlers/flow-digest.ts +12 -8
  185. package/os/flow/handlers/flow-peers.ts +1 -1
  186. package/os/flow/handlers/flow-push.ts +725 -137
  187. package/os/flow/locks.ts +24 -7
  188. package/os/flow/open-missions.ts +45 -0
  189. package/os/flow/preflight.ts +5 -3
  190. package/os/flow/registry.ts +7 -3
  191. package/os/flow/tests/digest-id-inputs.test.ts +106 -0
  192. package/os/flow/tests/digest-persist.test.ts +243 -0
  193. package/os/flow/tests/evidence-preflight-surface-skip.test.ts +218 -0
  194. package/os/flow/tests/flow-push-attest.test.ts +137 -0
  195. package/os/flow/tests/flow-push-review-baseline.test.ts +339 -0
  196. package/os/flow/tests/flow-push-verifier-batch.test.ts +134 -0
  197. package/os/flow/tests/release-lines.test.ts +136 -0
  198. package/os/flow/tests/state-roots.test.ts +1 -48
  199. package/os/friction/friction-add.test.ts +42 -0
  200. package/os/friction/friction-migrate.test.ts +67 -2
  201. package/os/friction/friction.module.ts +33 -5
  202. package/os/friction/handlers/friction-add.ts +10 -15
  203. package/os/friction/handlers/friction-migrate.ts +220 -1
  204. package/os/friction/store.ts +19 -0
  205. package/os/friction/types.ts +8 -0
  206. package/os/gate/handlers/gate-probe-catalog.ts +39 -7
  207. package/os/gate/handlers/gate-probe-ratchet.test.ts +57 -22
  208. package/os/plan/handlers/archive.ts +3 -11
  209. package/os/rfc/handlers/archive.ts +3 -11
  210. package/os/rfc/handlers/list-create.ts +22 -17
  211. package/os/rfc/handlers/validate-corpus.test.ts +149 -0
  212. package/os/rfc/probe-batch.test.ts +253 -0
  213. package/os/rfc/verifier/rfc-1391/ac10-operating-model-policy.acceptance.test.ts +63 -0
  214. package/os/session/handlers/archive.ts +3 -11
  215. package/os/system/handlers/system-product-register.ts +492 -0
  216. package/os/system/handlers/system-products-status.ts +395 -0
  217. package/os/system/schemas.ts +17 -0
  218. package/os/system/system.module.ts +117 -3
  219. package/os/system/tests/system-product-register.test.ts +304 -0
  220. package/os/system/tests/system-products-status.test.ts +154 -0
  221. package/package.json +161 -506
  222. package/profiles/root-agents-system.md +82 -0
  223. package/profiles/system.yaml +1 -0
  224. package/src/command-modules.ts +0 -2
  225. package/src/config/forge-config.ts +16 -11
  226. package/src/index.ts +0 -2
  227. package/src/onboarding/create-superfolder-guard.test.ts +73 -0
  228. package/src/onboarding/create.ts +28 -2
  229. package/src/onboarding/doctor.ts +9 -96
  230. package/src/onboarding/npm-token-check.ts +3 -3
  231. package/src/profiles/stack-profile.ts +2 -2
  232. package/src/tests/evidence-consult-serialization.test.ts +202 -0
  233. package/src/tests/pinned-validate.test.ts +194 -0
  234. package/src/tests/pkg-health-self-scan.test.ts +29 -0
  235. package/src/tests/profile-flow-hooks.test.ts +1 -0
  236. package/src/tests/profile-schema.test.ts +1 -0
  237. package/src/tests/rfc-evidence-sync.test.ts +369 -0
  238. package/src/tests/skill-agents-sync.test.ts +192 -0
  239. package/src/tests/stack-profile.test.ts +1 -0
  240. package/src/types.ts +2 -2
  241. package/src/utils/hash.ts +5 -0
  242. package/src/utils/lockfile.ts +78 -0
  243. package/src/utils/verifier-git.ts +53 -5
  244. package/dist/os/core/handlers/forge-autonomy-validate.d.ts +0 -25
  245. package/dist/os/core/handlers/forge-autonomy-validate.d.ts.map +0 -1
  246. package/dist/os/core/handlers/forge-autonomy-validate.js +0 -208
  247. package/dist/os/core/handlers/forge-autonomy-validate.js.map +0 -1
  248. package/dist/os/mission/handlers/archive.d.ts +0 -4
  249. package/dist/os/mission/handlers/archive.d.ts.map +0 -1
  250. package/dist/os/mission/handlers/archive.js +0 -587
  251. package/dist/os/mission/handlers/archive.js.map +0 -1
  252. package/dist/os/mission/importer-block.d.ts +0 -19
  253. package/dist/os/mission/importer-block.d.ts.map +0 -1
  254. package/dist/os/mission/importer-block.js +0 -124
  255. package/dist/os/mission/importer-block.js.map +0 -1
  256. package/dist/os/mission/index.d.ts +0 -2
  257. package/dist/os/mission/index.d.ts.map +0 -1
  258. package/dist/os/mission/index.js +0 -15
  259. package/dist/os/mission/index.js.map +0 -1
  260. package/dist/os/mission/lockfile.d.ts.map +0 -1
  261. package/dist/os/mission/lockfile.js +0 -138
  262. package/dist/os/mission/lockfile.js.map +0 -1
  263. package/dist/os/mission/mission.module.d.ts +0 -3
  264. package/dist/os/mission/mission.module.d.ts.map +0 -1
  265. package/dist/os/mission/mission.module.js +0 -63
  266. package/dist/os/mission/mission.module.js.map +0 -1
  267. package/dist/os/mission/open-missions.d.ts.map +0 -1
  268. package/dist/os/mission/open-missions.js +0 -42
  269. package/dist/os/mission/open-missions.js.map +0 -1
  270. package/dist/os/mission/types.d.ts +0 -23
  271. package/dist/os/mission/types.d.ts.map +0 -1
  272. package/dist/os/mission/types.js +0 -19
  273. package/dist/os/mission/types.js.map +0 -1
  274. package/dist/os/werkstatt/handlers/lock.d.ts +0 -10
  275. package/dist/os/werkstatt/handlers/lock.d.ts.map +0 -1
  276. package/dist/os/werkstatt/handlers/lock.js +0 -153
  277. package/dist/os/werkstatt/handlers/lock.js.map +0 -1
  278. package/dist/os/werkstatt/handlers/schema.d.ts +0 -33
  279. package/dist/os/werkstatt/handlers/schema.d.ts.map +0 -1
  280. package/dist/os/werkstatt/handlers/schema.js +0 -42
  281. package/dist/os/werkstatt/handlers/schema.js.map +0 -1
  282. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts +0 -15
  283. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts.map +0 -1
  284. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js +0 -171
  285. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js.map +0 -1
  286. package/dist/os/werkstatt/handlers/werkstatt-lock-status.d.ts +0 -18
  287. package/dist/os/werkstatt/handlers/werkstatt-lock-status.d.ts.map +0 -1
  288. package/dist/os/werkstatt/handlers/werkstatt-lock-status.js +0 -51
  289. package/dist/os/werkstatt/handlers/werkstatt-lock-status.js.map +0 -1
  290. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts +0 -11
  291. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts.map +0 -1
  292. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js +0 -86
  293. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js.map +0 -1
  294. package/dist/os/werkstatt/handlers/workspace-deps.d.ts +0 -12
  295. package/dist/os/werkstatt/handlers/workspace-deps.d.ts.map +0 -1
  296. package/dist/os/werkstatt/handlers/workspace-deps.js +0 -42
  297. package/dist/os/werkstatt/handlers/workspace-deps.js.map +0 -1
  298. package/dist/os/werkstatt/index.d.ts +0 -7
  299. package/dist/os/werkstatt/index.d.ts.map +0 -1
  300. package/dist/os/werkstatt/index.js +0 -18
  301. package/dist/os/werkstatt/index.js.map +0 -1
  302. package/dist/os/werkstatt/werkstatt.module.d.ts +0 -3
  303. package/dist/os/werkstatt/werkstatt.module.d.ts.map +0 -1
  304. package/dist/os/werkstatt/werkstatt.module.js +0 -91
  305. package/dist/os/werkstatt/werkstatt.module.js.map +0 -1
  306. package/os/core/handlers/forge-autonomy-validate.ts +0 -276
  307. package/os/correctness/gate/trust-boundary-cx19.test.ts +0 -514
  308. package/os/mission/handlers/archive.test.ts +0 -764
  309. package/os/mission/handlers/archive.ts +0 -719
  310. package/os/mission/handlers/ship-inflight-degraded.test.ts +0 -105
  311. package/os/mission/importer-block.ts +0 -119
  312. package/os/mission/index.ts +0 -15
  313. package/os/mission/lockfile.ts +0 -152
  314. package/os/mission/mission.module.ts +0 -68
  315. package/os/mission/open-missions.ts +0 -50
  316. package/os/mission/types.ts +0 -42
  317. package/os/werkstatt/handlers/lock.ts +0 -168
  318. package/os/werkstatt/handlers/schema.ts +0 -47
  319. package/os/werkstatt/handlers/werkstatt-lock-recover.ts +0 -206
  320. package/os/werkstatt/handlers/werkstatt-lock-status.ts +0 -82
  321. package/os/werkstatt/handlers/werkstatt-operation-validate.ts +0 -112
  322. package/os/werkstatt/handlers/workspace-deps.ts +0 -56
  323. package/os/werkstatt/index.ts +0 -39
  324. package/os/werkstatt/werkstatt.module.ts +0 -95
  325. package/src/tests/doctor-autonomy.test.ts +0 -246
  326. package/src/tests/forge-autonomy-validate.test.ts +0 -159
  327. package/src/tests/werkstatt-lock.test.ts +0 -357
@@ -505,6 +505,31 @@ describe("RFC-1535 stageMovedPairs", () => {
505
505
  expect(status).toMatch(/docs\/rfcs\/archive\/rfc-1\.md/);
506
506
  });
507
507
 
508
+ it("a gitignored move destination surfaces in the ignored diagnostic", async () => {
509
+ const root = mkdtempSync(path.join(tmpdir(), "docs-archive-ignored-"));
510
+ execFileSync("git", ["-C", root, "init", "-q"], { stdio: "pipe" });
511
+ execFileSync("git", ["-C", root, "config", "user.email", "t@t"], { stdio: "pipe" });
512
+ execFileSync("git", ["-C", root, "config", "user.name", "T"], { stdio: "pipe" });
513
+ // F-0004 shape: a consumer's `archive/` ignore rule silently swallows the
514
+ // destination add — the commit would carry the source delete alone.
515
+ writeFileSync(path.join(root, ".gitignore"), "archive/\n");
516
+ mkdirSync(path.join(root, "docs/rfcs"), { recursive: true });
517
+ writeFileSync(path.join(root, "docs/rfcs/rfc-1.md"), "# rfc\n");
518
+ execFileSync("git", ["-C", root, "add", ".", "-f"], { stdio: "pipe" });
519
+ execFileSync("git", ["-C", root, "commit", "-qm", "init"], { stdio: "pipe" });
520
+ mkdirSync(path.join(root, "docs/rfcs/archive"), { recursive: true });
521
+ renameSync(
522
+ path.join(root, "docs/rfcs/rfc-1.md"),
523
+ path.join(root, "docs/rfcs/archive/rfc-1.md"),
524
+ );
525
+ const outcome = await stageMovedPairs({
526
+ movedPaths: ["docs/rfcs/rfc-1.md", "docs/rfcs/archive/rfc-1.md"],
527
+ workspaceRoot: root,
528
+ });
529
+ expect(outcome.error).toBeUndefined();
530
+ expect(outcome.ignored).toEqual(["docs/rfcs/archive/rfc-1.md"]);
531
+ });
532
+
508
533
  it("a non-git tree reports the error without throwing", async () => {
509
534
  const root = mkdtempSync(path.join(tmpdir(), "docs-archive-nogit-"));
510
535
  const outcome = await stageMovedPairs({
@@ -13,7 +13,8 @@
13
13
 
14
14
  import { join, relative, extname } from "node:path";
15
15
  import { ambientIo } from "../../../src/utils/io.ts";
16
- import { loadWorkspaceDeps } from "../../werkstatt/handlers/workspace-deps.ts";
16
+ import { collectFiles } from "../../../src/utils/fs.ts";
17
+ import { byteHashFile } from "../../../src/utils/hash.ts";
17
18
  import type { ProfileAsset, ProfileAssetType } from "../../../src/profiles/profile-schema.ts";
18
19
 
19
20
  // Ambient default for helper fns without a context param — handlers override
@@ -43,7 +44,6 @@ export async function scanAssets(
43
44
  assetsConfig: ProfileAsset,
44
45
  options: { dryRun?: boolean; typeFilter?: string } = {},
45
46
  ): Promise<AssetEntry[]> {
46
- const { collectFiles, byteHashFile } = await loadWorkspaceDeps();
47
47
  const assetsDir = join(workspaceRoot, assetsConfig.dir);
48
48
  const allFiles = await collectFiles(assetsDir, {
49
49
  ignore: (name) => name.startsWith("-") || name.startsWith("old-") || name === ".DS_Store",
@@ -92,8 +92,6 @@ export async function extractReferences(
92
92
  compositionExtensions: string[],
93
93
  ): Promise<Map<string, string[]>> {
94
94
  const refMap = new Map<string, string[]>();
95
-
96
- const { collectFiles } = await loadWorkspaceDeps();
97
95
  const allFiles = await collectFiles(workspaceRoot, {
98
96
  extensions: compositionExtensions,
99
97
  ignore: (name) =>
@@ -13,12 +13,13 @@
13
13
 
14
14
  import { exec } from "../../../src/utils/sync-fs.ts";
15
15
  import { ambientIo, resolveIo } from "../../../src/utils/io.ts";
16
+ import { collectFiles } from "../../../src/utils/fs.ts";
17
+ import { byteHashFile } from "../../../src/utils/hash.ts";
16
18
  import { promisify } from "node:util";
17
19
 
18
20
  import { existsSync } from "../../../src/utils/sync-fs.ts";
19
21
  import { join, relative, dirname } from "node:path";
20
22
  import { createHash } from "node:crypto";
21
- import { loadWorkspaceDeps } from "../../werkstatt/handlers/workspace-deps.ts";
22
23
  import type {
23
24
  ForgeCommandInput,
24
25
  ForgeCommandResult,
@@ -95,7 +96,6 @@ function matchesGlob(filePath: string, patterns: string[]): boolean {
95
96
  }
96
97
 
97
98
  async function computeInputHash(workspaceRoot: string, inputPatterns: string[]): Promise<string> {
98
- const { collectFiles, byteHashFile } = await loadWorkspaceDeps();
99
99
  const allFiles = await collectFiles(workspaceRoot, {
100
100
  ignore: (name) =>
101
101
  name.startsWith("-") ||
@@ -292,7 +292,6 @@ export async function runDeterminismCheck(
292
292
  const absOutputPath = join(workspaceRoot, outputPath);
293
293
 
294
294
  try {
295
- const { byteHashFile } = await loadWorkspaceDeps();
296
295
  await execAsync(produceCommand, { cwd: workspaceRoot, timeout: 60_000 });
297
296
  const firstHash = await byteHashFile(absOutputPath);
298
297
 
@@ -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
+ });
@@ -107,11 +107,18 @@ export async function loadPinnedManifest(repoRoot: string): Promise<PinnedManife
107
107
  `pinned.yaml: entry "${entryPath}" must have a non-empty reason string`,
108
108
  );
109
109
  }
110
+ const entryArchive = entry["archive"];
111
+ if (entryArchive !== undefined && typeof entryArchive !== "boolean") {
112
+ throw new PinnedManifestMalformedError(
113
+ `pinned.yaml: entry "${entryPath}" has invalid archive "${String(entryArchive)}" — must be a boolean`,
114
+ );
115
+ }
110
116
 
111
117
  entries.push({
112
118
  path: entryPath,
113
119
  mode: entryMode as PinnedMode,
114
120
  reason: entryReason,
121
+ archive: entryArchive,
115
122
  });
116
123
  }
117
124
 
@@ -178,6 +185,29 @@ export function isIntraDirMove(
178
185
  return false;
179
186
  }
180
187
 
188
+ /**
189
+ * Check whether an archive handler must NOT relocate sourceRel to destRel.
190
+ * Returns the blocking PinnedEntry or null when the move is allowed.
191
+ *
192
+ * Blocked cases:
193
+ * - Source matches a `freeze` entry — freeze means no relocation at all,
194
+ * even inside the pinned directory.
195
+ * - Source matches an entry declared `archive: false` — the consumer's
196
+ * explicit opt-out (F-0004): docs.archive family leaves it alone.
197
+ * - Any pinned source whose destination leaves the same pinned directory
198
+ * (i.e. not an intra-directory move).
199
+ */
200
+ export function isArchiveBlocked(
201
+ manifest: PinnedManifest,
202
+ sourceRel: string,
203
+ destRel: string,
204
+ ): PinnedEntry | null {
205
+ const entry = isPinned(manifest, sourceRel);
206
+ if (!entry) return null;
207
+ if (entry.mode === "freeze" || entry.archive === false) return entry;
208
+ return isIntraDirMove(manifest, sourceRel, destRel) ? null : entry;
209
+ }
210
+
181
211
  /**
182
212
  * Batch-check multiple file paths against the manifest.
183
213
  * Returns violations for files that match a pinned entry.