@warpgogol/forge 9.1.1 → 9.2.3

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 (377) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/bin/cli.ts +3 -2
  3. package/dist/bin/cli.js +3 -2
  4. package/dist/bin/cli.js.map +1 -1
  5. package/dist/os/core/core.module.d.ts.map +1 -1
  6. package/dist/os/core/core.module.js +6 -4
  7. package/dist/os/core/core.module.js.map +1 -1
  8. package/dist/os/flow/branch-name.d.ts +56 -0
  9. package/dist/os/flow/branch-name.d.ts.map +1 -0
  10. package/dist/os/flow/branch-name.js +108 -0
  11. package/dist/os/flow/branch-name.js.map +1 -0
  12. package/dist/os/flow/digest.d.ts +73 -0
  13. package/dist/os/flow/digest.d.ts.map +1 -0
  14. package/dist/os/flow/digest.js +634 -0
  15. package/dist/os/flow/digest.js.map +1 -0
  16. package/dist/os/flow/flow.module.d.ts +3 -0
  17. package/dist/os/flow/flow.module.d.ts.map +1 -0
  18. package/dist/os/flow/flow.module.js +716 -0
  19. package/dist/os/flow/flow.module.js.map +1 -0
  20. package/dist/os/flow/git.d.ts +68 -0
  21. package/dist/os/flow/git.d.ts.map +1 -0
  22. package/dist/os/flow/git.js +257 -0
  23. package/dist/os/flow/git.js.map +1 -0
  24. package/dist/os/flow/guard-files.d.ts +50 -0
  25. package/dist/os/flow/guard-files.d.ts.map +1 -0
  26. package/dist/os/flow/guard-files.js +147 -0
  27. package/dist/os/flow/guard-files.js.map +1 -0
  28. package/dist/os/flow/handlers/flow-backmerge.d.ts +27 -0
  29. package/dist/os/flow/handlers/flow-backmerge.d.ts.map +1 -0
  30. package/dist/os/flow/handlers/flow-backmerge.js +332 -0
  31. package/dist/os/flow/handlers/flow-backmerge.js.map +1 -0
  32. package/dist/os/flow/handlers/flow-check.d.ts +42 -0
  33. package/dist/os/flow/handlers/flow-check.d.ts.map +1 -0
  34. package/dist/os/flow/handlers/flow-check.js +347 -0
  35. package/dist/os/flow/handlers/flow-check.js.map +1 -0
  36. package/dist/os/flow/handlers/flow-cut.d.ts +63 -0
  37. package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -0
  38. package/dist/os/flow/handlers/flow-cut.js +636 -0
  39. package/dist/os/flow/handlers/flow-cut.js.map +1 -0
  40. package/dist/os/flow/handlers/flow-digest.d.ts +5 -0
  41. package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -0
  42. package/dist/os/flow/handlers/flow-digest.js +110 -0
  43. package/dist/os/flow/handlers/flow-digest.js.map +1 -0
  44. package/dist/os/flow/handlers/flow-discard.d.ts +22 -0
  45. package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -0
  46. package/dist/os/flow/handlers/flow-discard.js +200 -0
  47. package/dist/os/flow/handlers/flow-discard.js.map +1 -0
  48. package/dist/os/flow/handlers/flow-fix.d.ts +47 -0
  49. package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -0
  50. package/dist/os/flow/handlers/flow-fix.js +443 -0
  51. package/dist/os/flow/handlers/flow-fix.js.map +1 -0
  52. package/dist/os/flow/handlers/flow-hold.d.ts +32 -0
  53. package/dist/os/flow/handlers/flow-hold.d.ts.map +1 -0
  54. package/dist/os/flow/handlers/flow-hold.js +359 -0
  55. package/dist/os/flow/handlers/flow-hold.js.map +1 -0
  56. package/dist/os/flow/handlers/flow-install.d.ts +92 -0
  57. package/dist/os/flow/handlers/flow-install.d.ts.map +1 -0
  58. package/dist/os/flow/handlers/flow-install.js +883 -0
  59. package/dist/os/flow/handlers/flow-install.js.map +1 -0
  60. package/dist/os/flow/handlers/flow-integrate.d.ts +35 -0
  61. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -0
  62. package/dist/os/flow/handlers/flow-integrate.js +419 -0
  63. package/dist/os/flow/handlers/flow-integrate.js.map +1 -0
  64. package/dist/os/flow/handlers/flow-open.d.ts +63 -0
  65. package/dist/os/flow/handlers/flow-open.d.ts.map +1 -0
  66. package/dist/os/flow/handlers/flow-open.js +294 -0
  67. package/dist/os/flow/handlers/flow-open.js.map +1 -0
  68. package/dist/os/flow/handlers/flow-push.d.ts +22 -0
  69. package/dist/os/flow/handlers/flow-push.d.ts.map +1 -0
  70. package/dist/os/flow/handlers/flow-push.js +306 -0
  71. package/dist/os/flow/handlers/flow-push.js.map +1 -0
  72. package/dist/os/flow/handlers/flow-status.d.ts +65 -0
  73. package/dist/os/flow/handlers/flow-status.d.ts.map +1 -0
  74. package/dist/os/flow/handlers/flow-status.js +193 -0
  75. package/dist/os/flow/handlers/flow-status.js.map +1 -0
  76. package/dist/os/flow/handlers/flow-unhold.d.ts +20 -0
  77. package/dist/os/flow/handlers/flow-unhold.d.ts.map +1 -0
  78. package/dist/os/flow/handlers/flow-unhold.js +158 -0
  79. package/dist/os/flow/handlers/flow-unhold.js.map +1 -0
  80. package/dist/os/flow/handlers/flow-version.d.ts +39 -0
  81. package/dist/os/flow/handlers/flow-version.d.ts.map +1 -0
  82. package/dist/os/flow/handlers/flow-version.js +122 -0
  83. package/dist/os/flow/handlers/flow-version.js.map +1 -0
  84. package/dist/os/flow/index.d.ts +30 -0
  85. package/dist/os/flow/index.d.ts.map +1 -0
  86. package/dist/os/flow/index.js +83 -0
  87. package/dist/os/flow/index.js.map +1 -0
  88. package/dist/os/flow/line-version.d.ts +23 -0
  89. package/dist/os/flow/line-version.d.ts.map +1 -0
  90. package/dist/os/flow/line-version.js +83 -0
  91. package/dist/os/flow/line-version.js.map +1 -0
  92. package/dist/os/flow/locks.d.ts +34 -0
  93. package/dist/os/flow/locks.d.ts.map +1 -0
  94. package/dist/os/flow/locks.js +147 -0
  95. package/dist/os/flow/locks.js.map +1 -0
  96. package/dist/os/flow/markers.d.ts +49 -0
  97. package/dist/os/flow/markers.d.ts.map +1 -0
  98. package/dist/os/flow/markers.js +112 -0
  99. package/dist/os/flow/markers.js.map +1 -0
  100. package/dist/os/flow/publish.d.ts +28 -0
  101. package/dist/os/flow/publish.d.ts.map +1 -0
  102. package/dist/os/flow/publish.js +153 -0
  103. package/dist/os/flow/publish.js.map +1 -0
  104. package/dist/os/flow/registry.d.ts +142 -0
  105. package/dist/os/flow/registry.d.ts.map +1 -0
  106. package/dist/os/flow/registry.js +198 -0
  107. package/dist/os/flow/registry.js.map +1 -0
  108. package/dist/os/flow/release-level.d.ts +23 -0
  109. package/dist/os/flow/release-level.d.ts.map +1 -0
  110. package/dist/os/flow/release-level.js +102 -0
  111. package/dist/os/flow/release-level.js.map +1 -0
  112. package/dist/os/flow/release-lines.d.ts +25 -0
  113. package/dist/os/flow/release-lines.d.ts.map +1 -0
  114. package/dist/os/flow/release-lines.js +172 -0
  115. package/dist/os/flow/release-lines.js.map +1 -0
  116. package/dist/os/flow/release-tags.d.ts +72 -0
  117. package/dist/os/flow/release-tags.d.ts.map +1 -0
  118. package/dist/os/flow/release-tags.js +166 -0
  119. package/dist/os/flow/release-tags.js.map +1 -0
  120. package/dist/os/flow/repo-kind.d.ts +41 -0
  121. package/dist/os/flow/repo-kind.d.ts.map +1 -0
  122. package/dist/os/flow/repo-kind.js +92 -0
  123. package/dist/os/flow/repo-kind.js.map +1 -0
  124. package/dist/os/flow/scripts.d.ts +20 -0
  125. package/dist/os/flow/scripts.d.ts.map +1 -0
  126. package/dist/os/flow/scripts.js +49 -0
  127. package/dist/os/flow/scripts.js.map +1 -0
  128. package/dist/os/flow/semver.d.ts +21 -0
  129. package/dist/os/flow/semver.d.ts.map +1 -0
  130. package/dist/os/flow/semver.js +73 -0
  131. package/dist/os/flow/semver.js.map +1 -0
  132. package/dist/os/flow/tests/helpers.d.ts +52 -0
  133. package/dist/os/flow/tests/helpers.d.ts.map +1 -0
  134. package/dist/os/flow/tests/helpers.js +189 -0
  135. package/dist/os/flow/tests/helpers.js.map +1 -0
  136. package/dist/os/flow/version-files.d.ts +21 -0
  137. package/dist/os/flow/version-files.d.ts.map +1 -0
  138. package/dist/os/flow/version-files.js +94 -0
  139. package/dist/os/flow/version-files.js.map +1 -0
  140. package/dist/os/flow/worktree-path.d.ts +31 -0
  141. package/dist/os/flow/worktree-path.d.ts.map +1 -0
  142. package/dist/os/flow/worktree-path.js +80 -0
  143. package/dist/os/flow/worktree-path.js.map +1 -0
  144. package/dist/os/mission/handlers/archive.d.ts.map +1 -1
  145. package/dist/os/mission/handlers/archive.js +43 -6
  146. package/dist/os/mission/handlers/archive.js.map +1 -1
  147. package/dist/os/program/handlers/seal.d.ts.map +1 -1
  148. package/dist/os/program/handlers/seal.js +1 -1
  149. package/dist/os/program/handlers/seal.js.map +1 -1
  150. package/dist/os/program/handlers/validate.d.ts.map +1 -1
  151. package/dist/os/program/handlers/validate.js +1 -1
  152. package/dist/os/program/handlers/validate.js.map +1 -1
  153. package/dist/os/program/program.module.d.ts.map +1 -1
  154. package/dist/os/program/program.module.js +2 -1
  155. package/dist/os/program/program.module.js.map +1 -1
  156. package/dist/os/program/schemas.d.ts +4 -6
  157. package/dist/os/program/schemas.d.ts.map +1 -1
  158. package/dist/os/program/schemas.js +16 -6
  159. package/dist/os/program/schemas.js.map +1 -1
  160. package/dist/os/program/state.d.ts +0 -1
  161. package/dist/os/program/state.d.ts.map +1 -1
  162. package/dist/os/program/state.js +1 -7
  163. package/dist/os/program/state.js.map +1 -1
  164. package/dist/os/rfc/acceptance.d.ts +21 -0
  165. package/dist/os/rfc/acceptance.d.ts.map +1 -1
  166. package/dist/os/rfc/acceptance.js +62 -13
  167. package/dist/os/rfc/acceptance.js.map +1 -1
  168. package/dist/os/rfc/frontmatter-io.d.ts +19 -0
  169. package/dist/os/rfc/frontmatter-io.d.ts.map +1 -1
  170. package/dist/os/rfc/frontmatter-io.js +65 -12
  171. package/dist/os/rfc/frontmatter-io.js.map +1 -1
  172. package/dist/os/rfc/handlers/validate-rules.d.ts +2 -5
  173. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  174. package/dist/os/rfc/handlers/validate-rules.js +10 -8
  175. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  176. package/dist/os/rfc/handlers/validate.d.ts.map +1 -1
  177. package/dist/os/rfc/handlers/validate.js +15 -5
  178. package/dist/os/rfc/handlers/validate.js.map +1 -1
  179. package/dist/os/rfc/index.d.ts +2 -2
  180. package/dist/os/rfc/index.d.ts.map +1 -1
  181. package/dist/os/rfc/index.js +5 -2
  182. package/dist/os/rfc/index.js.map +1 -1
  183. package/dist/os/rfc/probe-batch.d.ts +71 -0
  184. package/dist/os/rfc/probe-batch.d.ts.map +1 -0
  185. package/dist/os/rfc/probe-batch.js +251 -0
  186. package/dist/os/rfc/probe-batch.js.map +1 -0
  187. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  188. package/dist/os/rfc/rfc.module.js +16 -2
  189. package/dist/os/rfc/rfc.module.js.map +1 -1
  190. package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
  191. package/dist/os/rfc/verification-evidence.js +21 -10
  192. package/dist/os/rfc/verification-evidence.js.map +1 -1
  193. package/dist/os/rfc/verification-refresh.d.ts.map +1 -1
  194. package/dist/os/rfc/verification-refresh.js +20 -13
  195. package/dist/os/rfc/verification-refresh.js.map +1 -1
  196. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts.map +1 -1
  197. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js +21 -7
  198. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js.map +1 -1
  199. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts.map +1 -1
  200. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js +1 -1
  201. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js.map +1 -1
  202. package/dist/os/werkstatt/werkstatt.module.d.ts.map +1 -1
  203. package/dist/os/werkstatt/werkstatt.module.js +2 -82
  204. package/dist/os/werkstatt/werkstatt.module.js.map +1 -1
  205. package/dist/src/config/forge-config.d.ts +0 -3
  206. package/dist/src/config/forge-config.d.ts.map +1 -1
  207. package/dist/src/config/forge-config.js +2 -4
  208. package/dist/src/config/forge-config.js.map +1 -1
  209. package/dist/src/index.d.ts +3 -0
  210. package/dist/src/index.d.ts.map +1 -1
  211. package/dist/src/index.js +2 -0
  212. package/dist/src/index.js.map +1 -1
  213. package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
  214. package/dist/src/onboarding/agents-generate.js +49 -4
  215. package/dist/src/onboarding/agents-generate.js.map +1 -1
  216. package/dist/src/onboarding/create.d.ts +13 -0
  217. package/dist/src/onboarding/create.d.ts.map +1 -1
  218. package/dist/src/onboarding/create.js +95 -9
  219. package/dist/src/onboarding/create.js.map +1 -1
  220. package/dist/src/onboarding/doctor.d.ts.map +1 -1
  221. package/dist/src/onboarding/doctor.js +2 -47
  222. package/dist/src/onboarding/doctor.js.map +1 -1
  223. package/dist/src/onboarding/upgrade.d.ts +5 -0
  224. package/dist/src/onboarding/upgrade.d.ts.map +1 -1
  225. package/dist/src/onboarding/upgrade.js +70 -1
  226. package/dist/src/onboarding/upgrade.js.map +1 -1
  227. package/dist/src/types.d.ts +9 -0
  228. package/dist/src/types.d.ts.map +1 -1
  229. package/dist/src/types.js +2 -2
  230. package/docs/branch-model.md +98 -0
  231. package/docs/maintainers/publishing.md +10 -8
  232. package/docs/reference/cli.md +0 -3
  233. package/os/core/core.module.ts +7 -4
  234. package/os/flow/assets/flow-guard.sh +176 -0
  235. package/os/flow/branch-name.ts +139 -0
  236. package/os/flow/digest.ts +761 -0
  237. package/os/flow/flow.module.ts +740 -0
  238. package/os/flow/git.ts +342 -0
  239. package/os/flow/guard-files.ts +172 -0
  240. package/os/flow/handlers/flow-backmerge.ts +488 -0
  241. package/os/flow/handlers/flow-check.ts +450 -0
  242. package/os/flow/handlers/flow-cut.ts +912 -0
  243. package/os/flow/handlers/flow-digest.ts +124 -0
  244. package/os/flow/handlers/flow-discard.ts +301 -0
  245. package/os/flow/handlers/flow-fix.ts +597 -0
  246. package/os/flow/handlers/flow-hold.ts +500 -0
  247. package/os/flow/handlers/flow-install.ts +1185 -0
  248. package/os/flow/handlers/flow-integrate.ts +607 -0
  249. package/os/flow/handlers/flow-open.ts +447 -0
  250. package/os/flow/handlers/flow-push.ts +373 -0
  251. package/os/flow/handlers/flow-status.ts +283 -0
  252. package/os/flow/handlers/flow-unhold.ts +220 -0
  253. package/os/flow/handlers/flow-version.ts +196 -0
  254. package/os/flow/index.ts +102 -0
  255. package/os/flow/line-version.ts +113 -0
  256. package/os/flow/locks.ts +177 -0
  257. package/os/flow/markers.ts +135 -0
  258. package/os/flow/publish.ts +201 -0
  259. package/os/flow/registry.ts +266 -0
  260. package/os/flow/release-level.ts +139 -0
  261. package/os/flow/release-lines.ts +208 -0
  262. package/os/flow/release-tags.ts +231 -0
  263. package/os/flow/repo-kind.ts +117 -0
  264. package/os/flow/scripts.ts +73 -0
  265. package/os/flow/semver.ts +82 -0
  266. package/os/flow/tests/branch-name.test.ts +136 -0
  267. package/os/flow/tests/fixtures/branch-names.yaml +56 -0
  268. package/os/flow/tests/flow-backmerge.test.ts +267 -0
  269. package/os/flow/tests/flow-check-version.test.ts +138 -0
  270. package/os/flow/tests/flow-check.test.ts +213 -0
  271. package/os/flow/tests/flow-cut.rerun.test.ts +95 -0
  272. package/os/flow/tests/flow-cut.test.ts +319 -0
  273. package/os/flow/tests/flow-digest.test.ts +313 -0
  274. package/os/flow/tests/flow-discard.test.ts +220 -0
  275. package/os/flow/tests/flow-fix.test.ts +359 -0
  276. package/os/flow/tests/flow-guard-merge.test.ts +100 -0
  277. package/os/flow/tests/flow-guard-parity.test.ts +115 -0
  278. package/os/flow/tests/flow-guard-push.test.ts +100 -0
  279. package/os/flow/tests/flow-guard.test.ts +135 -0
  280. package/os/flow/tests/flow-hold.test.ts +465 -0
  281. package/os/flow/tests/flow-install-baseline.rerun.test.ts +73 -0
  282. package/os/flow/tests/flow-install-baseline.test.ts +164 -0
  283. package/os/flow/tests/flow-install-markers.test.ts +161 -0
  284. package/os/flow/tests/flow-install.rerun.test.ts +212 -0
  285. package/os/flow/tests/flow-install.test.ts +330 -0
  286. package/os/flow/tests/flow-integrate.rerun.test.ts +92 -0
  287. package/os/flow/tests/flow-integrate.test.ts +229 -0
  288. package/os/flow/tests/flow-open.test.ts +200 -0
  289. package/os/flow/tests/flow-push-publish.test.ts +282 -0
  290. package/os/flow/tests/flow-push.test.ts +160 -0
  291. package/os/flow/tests/flow-stale.test.ts +136 -0
  292. package/os/flow/tests/flow-status.test.ts +93 -0
  293. package/os/flow/tests/flow-version-level.test.ts +116 -0
  294. package/os/flow/tests/flow-version.test.ts +169 -0
  295. package/os/flow/tests/helpers.ts +235 -0
  296. package/os/flow/tests/is-flow-adopted.test.ts +71 -0
  297. package/os/flow/tests/registry.test.ts +150 -0
  298. package/os/flow/tests/repository-line-version.test.ts +100 -0
  299. package/os/flow/tests/scripts.test.ts +97 -0
  300. package/os/flow/tests/state-roots.test.ts +127 -0
  301. package/os/flow/tests/version-files.test.ts +145 -0
  302. package/os/flow/version-files.ts +115 -0
  303. package/os/flow/worktree-path.ts +107 -0
  304. package/os/mission/handlers/archive.test.ts +27 -0
  305. package/os/mission/handlers/archive.ts +46 -6
  306. package/os/program/handlers/seal.ts +1 -1
  307. package/os/program/handlers/validate.ts +1 -1
  308. package/os/program/program.module.ts +2 -1
  309. package/os/program/schemas.ts +51 -34
  310. package/os/program/state.ts +1 -9
  311. package/os/rfc/acceptance.ts +84 -19
  312. package/os/rfc/frontmatter-io.ts +78 -12
  313. package/os/rfc/handlers/implement-stamp-stale.test.ts +22 -0
  314. package/os/rfc/handlers/validate-rules.test.ts +9 -6
  315. package/os/rfc/handlers/validate-rules.ts +12 -10
  316. package/os/rfc/handlers/validate.ts +17 -5
  317. package/os/rfc/index.ts +13 -1
  318. package/os/rfc/probe-batch.ts +329 -0
  319. package/os/rfc/rfc.module.ts +19 -2
  320. package/os/rfc/verification-emit-check.test.ts +22 -0
  321. package/os/rfc/verification-emit-freshness.test.ts +22 -0
  322. package/os/rfc/verification-emit.test.ts +22 -0
  323. package/os/rfc/verification-evidence.ts +21 -16
  324. package/os/rfc/verification-refresh.test.ts +22 -0
  325. package/os/rfc/verification-refresh.ts +20 -18
  326. package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +9 -0
  327. package/os/werkstatt/handlers/werkstatt-lock-recover.ts +22 -5
  328. package/os/werkstatt/handlers/werkstatt-operation-validate.ts +1 -1
  329. package/os/werkstatt/werkstatt.module.ts +2 -85
  330. package/package.json +17 -1
  331. package/profiles/forge-shell.yaml +22 -10
  332. package/profiles/godot-game.yaml +24 -13
  333. package/profiles/knowledge.yaml +19 -0
  334. package/profiles/phaser-game.yaml +25 -13
  335. package/profiles/site-workshop.yaml +27 -10
  336. package/profiles/typescript.yaml +26 -9
  337. package/skills/fo/fo-session-retro/SKILL.md +18 -7
  338. package/skills/fo/fo-step-commit/SKILL.md +2 -1
  339. package/src/config/forge-config.ts +2 -6
  340. package/src/index.ts +8 -0
  341. package/src/onboarding/agents-generate.ts +49 -5
  342. package/src/onboarding/create.ts +101 -9
  343. package/src/onboarding/doctor.ts +2 -51
  344. package/src/onboarding/upgrade.ts +86 -1
  345. package/src/tests/agents-generate-flow.test.ts +132 -0
  346. package/src/tests/create-flow.test.ts +114 -0
  347. package/src/tests/create.test.ts +22 -21
  348. package/src/tests/doctor-autonomy.test.ts +2 -1
  349. package/src/tests/implement-stamp.test.ts +26 -3
  350. package/src/tests/profile-flow-hooks.test.ts +77 -0
  351. package/src/tests/program-schemas.test.ts +66 -6
  352. package/src/tests/program-spec-node.test.ts +1 -5
  353. package/src/tests/rfc-evidence-sync.test.ts +22 -0
  354. package/src/tests/rfc-implement-stamp-governance.test.ts +25 -1
  355. package/src/tests/rfc-verification-verdict-ingest.test.ts +22 -0
  356. package/src/tests/upgrade-flow.test.ts +174 -0
  357. package/src/types.ts +11 -2
  358. package/dist/os/werkstatt/handlers/session-close.d.ts +0 -13
  359. package/dist/os/werkstatt/handlers/session-close.d.ts.map +0 -1
  360. package/dist/os/werkstatt/handlers/session-close.js +0 -56
  361. package/dist/os/werkstatt/handlers/session-close.js.map +0 -1
  362. package/dist/os/werkstatt/handlers/session-engine.d.ts +0 -3
  363. package/dist/os/werkstatt/handlers/session-engine.d.ts.map +0 -1
  364. package/dist/os/werkstatt/handlers/session-engine.js +0 -28
  365. package/dist/os/werkstatt/handlers/session-engine.js.map +0 -1
  366. package/dist/os/werkstatt/handlers/session-open.d.ts +0 -10
  367. package/dist/os/werkstatt/handlers/session-open.d.ts.map +0 -1
  368. package/dist/os/werkstatt/handlers/session-open.js +0 -46
  369. package/dist/os/werkstatt/handlers/session-open.js.map +0 -1
  370. package/dist/os/werkstatt/handlers/session-status.d.ts +0 -9
  371. package/dist/os/werkstatt/handlers/session-status.d.ts.map +0 -1
  372. package/dist/os/werkstatt/handlers/session-status.js +0 -34
  373. package/dist/os/werkstatt/handlers/session-status.js.map +0 -1
  374. package/os/werkstatt/handlers/session-close.ts +0 -82
  375. package/os/werkstatt/handlers/session-engine.ts +0 -34
  376. package/os/werkstatt/handlers/session-open.ts +0 -68
  377. package/os/werkstatt/handlers/session-status.ts +0 -55
@@ -0,0 +1,164 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>flow.install baseline-tag tests (RFC-1488: AC-5, AC-6 plus the
4
+ FLOW-ADOPT-07 refusals): a stale reachable tag never hides a higher version
5
+ file, the pickaxe finds the version-introduction commit (canonical and
6
+ whitespace-variant formatting), backwards versions refuse, and a baseline
7
+ commit outside main refuses. All tags are created only in throwaway repos
8
+ under the OS temp dir.</purpose>
9
+ <non-goals>
10
+ <item>No rerun coverage — flow-install-baseline.rerun.test.ts owns the second-run identity.</item>
11
+ </non-goals>
12
+ </MODULE_CONTRACT>
13
+ <CHANGE_SUMMARY>
14
+ <item>RFC-1488: step 5 — baseline-tag plan/execute tests</item>
15
+ <item>RFC-1488: steps 5-6 — flow.install baseline tags step, flow.check FLOW-08/FLOW-09</item>
16
+ <item>RFC-1488: review r1 — parse guard, door/rules metadata, id-exact RFC binding, refname precision, FLOW-09 top-level anchor, test cleanup</item>
17
+ </CHANGE_SUMMARY>
18
+ */
19
+
20
+ import { mkdir, rm, writeFile } from "node:fs/promises";
21
+ import { join } from "node:path";
22
+
23
+ import { afterEach, describe, expect, it } from "vitest";
24
+
25
+ import { ambientIo } from "../../../src/utils/io.ts";
26
+ import { executeInstall, planInstall } from "../handlers/flow-install.ts";
27
+ import { gitExec, initRepo } from "./helpers.ts";
28
+
29
+ const dirs: string[] = [];
30
+
31
+ afterEach(async () => {
32
+ for (const dir of dirs.splice(0)) {
33
+ await rm(dir, { recursive: true, force: true });
34
+ }
35
+ });
36
+
37
+ async function seedRepo(version: string): Promise<string> {
38
+ const repo = await initRepo({ prefix: "flow-base-" });
39
+ dirs.push(repo);
40
+ await mkdir(join(repo, "packages/forge"), { recursive: true });
41
+ await writeFile(join(repo, "pnpm-workspace.yaml"), "packages:\n - 'packages/*'\n");
42
+ await writeFile(
43
+ join(repo, "packages/forge/extract.config.yaml"),
44
+ "forgePlugin: true\n",
45
+ );
46
+ await writeFile(join(repo, "package.json"), `{ "version": "${version}" }\n`);
47
+ await writeFile(
48
+ join(repo, "packages/forge/package.json"),
49
+ `{ "version": "${version}" }\n`,
50
+ );
51
+ await writeFile(join(repo, "forge.yaml"), "name: test\n");
52
+ await gitExec(repo, ["add", "."]);
53
+ await gitExec(repo, ["commit", "-m", `version ${version}`]);
54
+ return repo;
55
+ }
56
+
57
+ async function listTags(repo: string): Promise<string[]> {
58
+ const r = await gitExec(repo, ["tag", "--list"]);
59
+ return r.stdout.split("\n").map((t) => t.trim()).filter(Boolean).sort();
60
+ }
61
+
62
+ async function tagTarget(repo: string, tag: string): Promise<string> {
63
+ const r = await gitExec(repo, ["rev-list", "-n", "1", tag]);
64
+ return r.stdout.trim();
65
+ }
66
+
67
+ describe("flow.install baseline tags", () => {
68
+ it("AC-5: stale forge@0.15.0 + version file 9.0.0 → forge@9.0.0 at the version commit", async () => {
69
+ const repo = await seedRepo("9.0.0");
70
+ const versionCommit = (await gitExec(repo, ["rev-parse", "HEAD"])).stdout.trim();
71
+ // Stale tag on an older ancestor — the audit-G1 trap.
72
+ const stale = await gitExec(repo, ["commit", "--allow-empty", "-m", "stale era"]);
73
+ if (stale.exitCode !== 0) throw new Error(stale.stderr);
74
+ await gitExec(repo, ["tag", "-a", "forge@0.15.0", "-m", "release forge@0.15.0", "HEAD~1"]);
75
+
76
+ const plan = await planInstall(repo, ambientIo);
77
+ expect(plan.refusal).toBeNull();
78
+ const tagPlans = plan.tagPlans;
79
+ expect(tagPlans.map((t) => t.tag).sort()).toEqual(["forge@9.0.0", "v9.0.0"]);
80
+ expect(tagPlans.find((t) => t.tag === "forge@9.0.0")?.commit).toBe(versionCommit);
81
+ expect(tagPlans.find((t) => t.tag === "forge@9.0.0")?.previous).toBe("forge@0.15.0");
82
+
83
+ const { check } = await executeInstall(plan, ambientIo);
84
+ expect(check).not.toBeNull();
85
+ const tags = await listTags(repo);
86
+ expect(tags).toContain("forge@9.0.0");
87
+ expect(tags).toContain("v9.0.0");
88
+ expect(await tagTarget(repo, "forge@9.0.0")).toBe(versionCommit);
89
+ // Baseline annotation follows forge/release-tag@1.
90
+ const message = (await gitExec(repo, ["tag", "-l", "--format=%(contents)", "forge@9.0.0"])).stdout;
91
+ expect(message).toContain("schema: forge/release-tag@1");
92
+ expect(message).toContain("level: baseline");
93
+ expect(message).toContain("previous: forge@0.15.0");
94
+ });
95
+
96
+ it("pickaxe fallback: version file without canonical spacing still finds the commit", async () => {
97
+ const repo = await initRepo({ prefix: "flow-base-" });
98
+ dirs.push(repo);
99
+ await writeFile(join(repo, "forge.yaml"), "name: test\n");
100
+ await writeFile(join(repo, "package.json"), '{"version":"3.1.4"}\n');
101
+ await gitExec(repo, ["add", "."]);
102
+ await gitExec(repo, ["commit", "-m", "version 3.1.4"]);
103
+ const versionCommit = (await gitExec(repo, ["rev-parse", "HEAD"])).stdout.trim();
104
+
105
+ const plan = await planInstall(repo, ambientIo);
106
+ expect(plan.refusal).toBeNull();
107
+ expect(plan.tagPlans).toEqual([
108
+ {
109
+ line: "repo",
110
+ tag: "v3.1.4",
111
+ version: "3.1.4",
112
+ commit: versionCommit,
113
+ previous: null,
114
+ },
115
+ ]);
116
+ });
117
+
118
+ it("version file lower than the last tag refuses FLOW-ADOPT-07 and tags nothing", async () => {
119
+ const repo = await seedRepo("9.0.0");
120
+ await gitExec(repo, ["tag", "-a", "v9.5.0", "-m", "release v9.5.0"]);
121
+
122
+ const plan = await planInstall(repo, ambientIo);
123
+ expect(plan.refusal?.ruleId).toBe("FLOW-ADOPT-07");
124
+ expect(plan.refusal?.message).toContain("9.0.0");
125
+ expect(plan.refusal?.message).toContain("v9.5.0");
126
+ // No tag was created during the refused plan.
127
+ expect(await listTags(repo)).toEqual(["v9.5.0"]);
128
+ });
129
+
130
+ it("a version commit reachable only on develop refuses FLOW-ADOPT-07", async () => {
131
+ const repo = await seedRepo("1.0.0");
132
+ // First install: adopted, primary now on develop, v1.0.0 baselined.
133
+ const first = await planInstall(repo, ambientIo);
134
+ expect(first.refusal).toBeNull();
135
+ await executeInstall(first, ambientIo);
136
+ expect(await listTags(repo)).toContain("v1.0.0");
137
+
138
+ // Bump the version on develop — a commit main has never seen.
139
+ await writeFile(join(repo, "package.json"), '{ "version": "2.0.0" }\n');
140
+ await gitExec(repo, ["add", "package.json"]);
141
+ const bump = await gitExec(repo, ["commit", "-m", "version 2.0.0"], {
142
+ FORGE_FLOW_OP: "install",
143
+ });
144
+ if (bump.exitCode !== 0) throw new Error(bump.stderr);
145
+
146
+ const plan = await planInstall(repo, ambientIo);
147
+ expect(plan.refusal?.ruleId).toBe("FLOW-ADOPT-07");
148
+ expect(plan.refusal?.message).toContain("not an ancestor of main");
149
+ });
150
+
151
+ it("equal tag and version file → no tag plan", async () => {
152
+ const repo = await seedRepo("1.0.0");
153
+ await gitExec(repo, ["tag", "-a", "v1.0.0", "-m", "release v1.0.0"]);
154
+ await gitExec(repo, ["tag", "-a", "forge@1.0.0", "-m", "release forge@1.0.0"]);
155
+
156
+ const plan = await planInstall(repo, ambientIo);
157
+ expect(plan.refusal).toBeNull();
158
+ expect(plan.tagPlans).toEqual([]);
159
+ const { check } = await executeInstall(plan, ambientIo);
160
+ expect(check).not.toBeNull();
161
+ expect(plan.steps.find((s) => s.step === "tags")?.status).toBe("skipped");
162
+ expect(await listTags(repo)).toEqual(["forge@1.0.0", "v1.0.0"]);
163
+ });
164
+ });
@@ -0,0 +1,161 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>flow.install markers step tests (RFC-1491, AC-10): adoption writes
4
+ forge.generated.yaml (generator: repo-extract) into every package-line
5
+ directory in the adoption commit; a rerun with all markers present creates
6
+ no commit; deleting a marker flips flow.check to FLOW-10.</purpose>
7
+ <non-goals>
8
+ <item>No baseline-tag coverage — flow-install-baseline tests own that.</item>
9
+ <item>Never touches the enclosing repository — all fixtures are mkdtemp repos.</item>
10
+ </non-goals>
11
+ </MODULE_CONTRACT>
12
+ <CHANGE_SUMMARY>
13
+ <item>RFC-1491: step 2 — markers step + FLOW-10 tests</item>
14
+ <item>RFC-1491: step 2 — pre-push guard mode, install steps pre-push + markers, FLOW-10</item>
15
+ <item>RFC-1498: step 2 — network-only marker source
16
+
17
+ markerSource accepts only network-shaped origins — http/https/ssh/git schemes or the scp user-at-host form — and returns { source, rejectedOrigin }. A local path or file:// URL falls back to the repository directory basename with rejectedOrigin naming the kind (local-path or file-url), so no machine-local path is ever written into an extract repository marker; embedded credentials are still stripped from network URLs. flow.install resolves the source at plan time, stores it on the plan for the execute phase, and the markers step warns origin rejected (kind) — using the directory name, never printing the path. Tests AC-3 (local path and file:// rejected, basename used, path absent from the step detail) and AC-4 (scp URL kept verbatim, https credentials stripped). Also carries the KEY_DECISIONS compass notes for step 1's stray-branch rule.</item>
18
+ </CHANGE_SUMMARY>
19
+ */
20
+
21
+ import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
22
+ import { tmpdir } from "node:os";
23
+ import { basename, join } from "node:path";
24
+
25
+ import { afterEach, describe, expect, it } from "vitest";
26
+
27
+ import { ambientIo } from "../../../src/utils/io.ts";
28
+ import { collectFlowCheck } from "../handlers/flow-check.ts";
29
+ import { executeInstall, planInstall } from "../handlers/flow-install.ts";
30
+ import { MARKER_FILE, markerSource } from "../markers.ts";
31
+ import { gitExec, initRepo } from "./helpers.ts";
32
+
33
+ const dirs: string[] = [];
34
+ afterEach(async () => {
35
+ for (const dir of dirs.splice(0)) {
36
+ await rm(dir, { recursive: true, force: true });
37
+ }
38
+ }, 20_000);
39
+
40
+ /** Governed repo with one package line packages/lib + a bare origin. */
41
+ async function repoWithPackageLine(): Promise<{ repo: string; origin: string }> {
42
+ const repo = await initRepo({ prefix: "flow-markers-" });
43
+ dirs.push(repo);
44
+ await writeFile(join(repo, "forge.yaml"), 'schema: "forge/workspace@1"\n');
45
+ await writeFile(join(repo, "pnpm-workspace.yaml"), "packages:\n - packages/*\n");
46
+ await writeFile(
47
+ join(repo, "package.json"),
48
+ '{\n "name": "fixture",\n "version": "0.1.0"\n}\n',
49
+ );
50
+ await mkdir(join(repo, "packages", "lib"), { recursive: true });
51
+ await writeFile(
52
+ join(repo, "packages", "lib", "package.json"),
53
+ '{\n "name": "lib",\n "version": "0.1.0"\n}\n',
54
+ );
55
+ await writeFile(
56
+ join(repo, "packages", "lib", "extract.config.yaml"),
57
+ "standalone: true\n",
58
+ );
59
+ await gitExec(repo, ["add", "-A"]);
60
+ await gitExec(repo, ["commit", "-m", "config"]);
61
+
62
+ const origin = await mkdtemp(join(tmpdir(), "flow-markers-origin-"));
63
+ dirs.push(origin);
64
+ await gitExec(origin, ["init", "--bare", "-b", "develop", "."]);
65
+ await gitExec(repo, ["remote", "add", "origin", origin]);
66
+ return { repo, origin };
67
+ }
68
+
69
+ describe("flow.install markers step (RFC-1491)", () => {
70
+ it("writes packages/lib/forge.generated.yaml into the adoption commit (AC-10)", async () => {
71
+ const { repo } = await repoWithPackageLine();
72
+ const plan = await planInstall(repo, ambientIo);
73
+ expect(plan.refusal).toBeNull();
74
+ expect(plan.markerPlans.map((m) => m.dir)).toEqual(["packages/lib"]);
75
+ expect(plan.steps.find((s) => s.step === "markers")?.status).toBe("planned");
76
+ await executeInstall(plan, ambientIo);
77
+ expect(plan.steps.find((s) => s.step === "markers")?.status).toBe("done");
78
+
79
+ // The marker is committed content — worktrees must check it out.
80
+ const committed = await gitExec(repo, [
81
+ "show",
82
+ `develop:packages/lib/${MARKER_FILE}`,
83
+ ]);
84
+ expect(committed.stdout).toContain("schema: forge/generated@1");
85
+ expect(committed.stdout).toContain("generator: repo-extract");
86
+ // And the source names the line directory.
87
+ expect(committed.stdout).toContain("#packages/lib");
88
+ }, 40_000);
89
+
90
+ it("a rerun with all markers present creates no commit", async () => {
91
+ const { repo } = await repoWithPackageLine();
92
+ await executeInstall(await planInstall(repo, ambientIo), ambientIo);
93
+ const tip = (await gitExec(repo, ["rev-parse", "develop"])).stdout.trim();
94
+
95
+ const plan = await planInstall(repo, ambientIo);
96
+ expect(plan.refusal).toBeNull();
97
+ expect(plan.markerPlans).toEqual([]);
98
+ await executeInstall(plan, ambientIo);
99
+ expect(plan.steps.find((s) => s.step === "markers")?.status).toBe("skipped");
100
+ expect((await gitExec(repo, ["rev-parse", "develop"])).stdout.trim()).toBe(tip);
101
+ }, 40_000);
102
+
103
+ it("RFC-1498 AC-3: a local-path origin falls back to the directory basename", async () => {
104
+ const { repo, origin } = await repoWithPackageLine();
105
+ const result = await markerSource(repo, ambientIo);
106
+ expect(result.rejectedOrigin).toBe("local-path");
107
+ expect(result.source).toBe(basename(repo));
108
+ // The plan step warns — naming the kind, never the path itself.
109
+ const plan = await planInstall(repo, ambientIo);
110
+ const detail = plan.steps.find((s) => s.step === "markers")?.detail ?? "";
111
+ expect(detail).toContain("origin rejected (local-path)");
112
+ expect(detail).not.toContain(origin);
113
+ }, 40_000);
114
+
115
+ it("RFC-1498 AC-3: a file:// origin is rejected as file-url", async () => {
116
+ const { repo, origin } = await repoWithPackageLine();
117
+ await gitExec(repo, ["remote", "set-url", "origin", `file://${origin}`]);
118
+ const result = await markerSource(repo, ambientIo);
119
+ expect(result.rejectedOrigin).toBe("file-url");
120
+ expect(result.source).toBe(basename(repo));
121
+ expect(result.source).not.toContain(origin);
122
+ }, 40_000);
123
+
124
+ it("RFC-1498 AC-4: scp-style and credential-bearing origins stay usable", async () => {
125
+ const { repo } = await repoWithPackageLine();
126
+ await gitExec(repo, [
127
+ "remote",
128
+ "set-url",
129
+ "origin",
130
+ "git@github.com:owner/repo.git",
131
+ ]);
132
+ const scp = await markerSource(repo, ambientIo);
133
+ expect(scp.source).toBe("git@github.com:owner/repo.git");
134
+ expect(scp.rejectedOrigin).toBeNull();
135
+
136
+ await gitExec(repo, [
137
+ "remote",
138
+ "set-url",
139
+ "origin",
140
+ "https://alice:secret-token@github.com/owner/repo.git",
141
+ ]);
142
+ const cred = await markerSource(repo, ambientIo);
143
+ expect(cred.source).toBe("https://github.com/owner/repo.git");
144
+ expect(cred.rejectedOrigin).toBeNull();
145
+ expect(cred.source).not.toContain("secret-token");
146
+ }, 40_000);
147
+
148
+ it("flow.check reports FLOW-10 after a marker is deleted", async () => {
149
+ const { repo } = await repoWithPackageLine();
150
+ await executeInstall(await planInstall(repo, ambientIo), ambientIo);
151
+ const { diagnostics: clean } = await collectFlowCheck(repo, ambientIo);
152
+ expect(clean.filter((d) => d.ruleId === "FLOW-10")).toEqual([]);
153
+
154
+ await gitExec(repo, ["rm", `packages/lib/${MARKER_FILE}`]);
155
+ await gitExec(repo, ["commit", "-m", "drop marker"], { FORGE_FLOW_OP: "install" });
156
+ const { diagnostics } = await collectFlowCheck(repo, ambientIo);
157
+ const flow10 = diagnostics.filter((d) => d.ruleId === "FLOW-10");
158
+ expect(flow10).toHaveLength(1);
159
+ expect(flow10[0]?.message).toContain("packages/lib");
160
+ }, 40_000);
161
+ });
@@ -0,0 +1,212 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>AC-8 (RFC-1327 rerun-safety): running flow.install a second time on
4
+ an adopted repository reports every mutating step skipped, writes nothing,
5
+ adds no commit — proven by a recursive hash of hooks/ and a for-each-ref
6
+ snapshot taken before and after.</purpose>
7
+ </MODULE_CONTRACT>
8
+ <CHANGE_SUMMARY>
9
+ <item>RFC-1486: step 4 — flow.install rerun-safety test</item>
10
+ <item>RFC-1486: step 4 — flow.install two-phase adoption + rerun-safe</item>
11
+ <item>RFC-1486: review r2 — IO-throw step trail, drift-repair and uncommitted-commit tests</item>
12
+ <item>RFC-1490: pre-merge-commit guard mode + per-mode op vocabulary; amends the wave-1 guard RFC's backmerge escape (AC-11)</item>
13
+ <item>RFC-1490: independent-review pass — lock-held planning, fix-branch verification, spec-shaped data, coverage</item>
14
+ </CHANGE_SUMMARY>
15
+ */
16
+
17
+ import { readdir, readFile, rm, stat, writeFile } from "node:fs/promises";
18
+ import { createHash } from "node:crypto";
19
+ import { join } from "node:path";
20
+
21
+ import { afterEach, describe, expect, it } from "vitest";
22
+
23
+ import { ambientIo } from "../../../src/utils/io.ts";
24
+ import { executeInstall, planInstall } from "../handlers/flow-install.ts";
25
+ import { integrateFlowBranch } from "../handlers/flow-integrate.ts";
26
+ import { openFlowBranch } from "../handlers/flow-open.ts";
27
+ import { gitExec, initRepo } from "./helpers.ts";
28
+
29
+ const NOW = new Date("2026-11-02T12:00:00Z");
30
+
31
+ const dirs: string[] = [];
32
+
33
+ afterEach(async () => {
34
+ for (const dir of dirs.splice(0)) {
35
+ await rm(dir, { recursive: true, force: true });
36
+ }
37
+ });
38
+
39
+ /**
40
+ * Land a committed change on develop the model-normal way (RFC-1490): open a
41
+ * session branch, write + commit inside its worktree, integrate through the
42
+ * gate. Replaces the retired FORGE_FLOW_OP=backmerge escape.
43
+ */
44
+ async function landThroughSession(
45
+ repo: string,
46
+ slug: string,
47
+ file: string,
48
+ content: string,
49
+ ): Promise<void> {
50
+ const data = await openFlowBranch(repo, ambientIo, {
51
+ kind: "session",
52
+ slug,
53
+ brief: null,
54
+ owner: null,
55
+ dryRun: false,
56
+ now: NOW,
57
+ });
58
+ expect(data.diagnostics).toEqual([]);
59
+ dirs.push(data.worktree!);
60
+ const target = join(data.worktree!, file);
61
+ await rm(target, { force: true }).catch(() => {});
62
+ await writeFile(target, content);
63
+ await gitExec(data.worktree!, ["add", file]);
64
+ const commit = await gitExec(data.worktree!, ["commit", "-m", slug]);
65
+ expect(commit.exitCode).toBe(0);
66
+ const integrated = await integrateFlowBranch(repo, ambientIo, {
67
+ branch: data.branch!,
68
+ dryRun: false,
69
+ now: NOW,
70
+ });
71
+ expect(integrated.integrated).toBe(true);
72
+ }
73
+
74
+ async function hashTree(dir: string): Promise<string> {
75
+ const hash = createHash("sha256");
76
+ async function walk(d: string): Promise<void> {
77
+ for (const name of (await readdir(d)).sort()) {
78
+ const p = join(d, name);
79
+ const s = await stat(p);
80
+ if (s.isDirectory()) await walk(p);
81
+ else hash.update(`${name}:${s.mode}:`).update(await readFile(p));
82
+ }
83
+ }
84
+ await walk(dir);
85
+ return hash.digest("hex");
86
+ }
87
+
88
+ async function refSnapshot(repo: string): Promise<string> {
89
+ const r = await gitExec(repo, ["for-each-ref", "--format=%(refname) %(objectname)"]);
90
+ return r.stdout;
91
+ }
92
+
93
+ describe("flow.install rerun-safety (AC-8)", () => {
94
+ it("second run skips every mutating step and changes nothing", async () => {
95
+ const repo = await initRepo({ prefix: "flow-rerun-" });
96
+ dirs.push(repo);
97
+ await writeFile(join(repo, "forge.yaml"), 'schema: "forge/workspace@1"\n');
98
+
99
+ // First run — full adoption.
100
+ const first = await planInstall(repo, ambientIo);
101
+ expect(first.refusal).toBeNull();
102
+ await executeInstall(first, ambientIo);
103
+
104
+ const hooksHashBefore = await hashTree(join(repo, "hooks"));
105
+ const refsBefore = await refSnapshot(repo);
106
+
107
+ // Second run — every mutating step skipped, nothing new.
108
+ const second = await planInstall(repo, ambientIo);
109
+ expect(second.refusal).toBeNull();
110
+ const outcome = await executeInstall(second, ambientIo);
111
+
112
+ for (const stepName of ["develop", "hooksPath", "checkout", "guard", "pre-commit", "commit"] as const) {
113
+ const step = second.steps.find((s) => s.step === stepName);
114
+ expect(step?.status, `step ${stepName} must be skipped`).toBe("skipped");
115
+ }
116
+ expect(second.steps.find((s) => s.step === "detect")?.status).toBe("done");
117
+ expect(second.steps.find((s) => s.step === "primary")?.status).toBe("done");
118
+ expect(second.steps.find((s) => s.step === "report")?.status).toBe("done");
119
+
120
+ // The embedded check shows no adoption errors (stray-branch FLOW-01 may
121
+ // legitimately appear — never an adoption error).
122
+ expect(
123
+ outcome.checkDiagnostics.filter(
124
+ (d) => d.severity === "error" && d.ruleId !== "FLOW-01",
125
+ ),
126
+ ).toEqual([]);
127
+
128
+ expect(await hashTree(join(repo, "hooks"))).toBe(hooksHashBefore);
129
+ expect(await refSnapshot(repo)).toBe(refsBefore);
130
+ });
131
+
132
+ it("repairs a drifted core.hooksPath on an adopted repo — committed adoption is the exemption signal, not working-tree state", async () => {
133
+ const repo = await initRepo({ prefix: "flow-drift-" });
134
+ dirs.push(repo);
135
+ await writeFile(join(repo, "forge.yaml"), 'schema: "forge/workspace@1"\n');
136
+ await executeInstall(await planInstall(repo, ambientIo), ambientIo);
137
+
138
+ // Drift the config — the state whose remedy is "re-run flow.install".
139
+ await gitExec(repo, ["config", "--unset", "core.hooksPath"]);
140
+
141
+ // develop is ahead of main (the adoption commit): without the committed-
142
+ // state exemption this refuses FLOW-ADOPT-01 — the review-r1 dead-end.
143
+ const plan = await planInstall(repo, ambientIo);
144
+ expect(plan.refusal).toBeNull();
145
+ await executeInstall(plan, ambientIo);
146
+ const hooksPath = await gitExec(repo, ["config", "--get", "core.hooksPath"]);
147
+ expect(hooksPath.stdout.trim()).toBe("hooks");
148
+ });
149
+
150
+ it("repairs a drifted committed guard on an adopted repo", async () => {
151
+ const repo = await initRepo({ prefix: "flow-drift-guard-" });
152
+ dirs.push(repo);
153
+ await writeFile(join(repo, "forge.yaml"), 'schema: "forge/workspace@1"\n');
154
+ await executeInstall(await planInstall(repo, ambientIo), ambientIo);
155
+
156
+ // Committed drift on develop — model-normal operation: the drift lands
157
+ // through a session branch + the integration gate (RFC-1490 retires the
158
+ // FORGE_FLOW_OP=backmerge escape).
159
+ await landThroughSession(repo, "drift-guard", "hooks/flow-guard.sh", "# drifted\n");
160
+
161
+ const plan = await planInstall(repo, ambientIo);
162
+ expect(plan.refusal).toBeNull();
163
+ expect(plan.guardChange).toBe("write");
164
+ await executeInstall(plan, ambientIo);
165
+ const content = await gitExec(repo, ["show", "develop:hooks/flow-guard.sh"]);
166
+ expect(content.stdout).toContain("forge flow guard");
167
+ });
168
+
169
+ it("a wave-1-adopted repo gains hooks/pre-merge-commit on rerun (RFC-1490)", async () => {
170
+ const repo = await initRepo({ prefix: "flow-rerun-premerge-" });
171
+ dirs.push(repo);
172
+ await writeFile(join(repo, "forge.yaml"), 'schema: "forge/workspace@1"\n');
173
+ await executeInstall(await planInstall(repo, ambientIo), ambientIo);
174
+
175
+ // Simulate the wave-1 committed state: pre-merge-commit absent.
176
+ await gitExec(repo, ["rm", "hooks/pre-merge-commit"]);
177
+ const drop = await gitExec(repo, ["commit", "-m", "wave-1 state"], {
178
+ FORGE_FLOW_OP: "install",
179
+ });
180
+ expect(drop.exitCode).toBe(0);
181
+
182
+ const plan = await planInstall(repo, ambientIo);
183
+ expect(plan.refusal).toBeNull();
184
+ expect(plan.steps.find((s) => s.step === "pre-merge-commit")?.status).toBe("planned");
185
+ await executeInstall(plan, ambientIo);
186
+
187
+ const committed = await gitExec(repo, ["show", "develop:hooks/pre-merge-commit"]);
188
+ expect(committed.stdout).toContain("forge flow guard");
189
+ expect(committed.stdout).toContain("pre-merge-commit");
190
+ expect(plan.steps.find((s) => s.step === "pre-merge-commit")?.status).toBe("done");
191
+ }, 40_000);
192
+
193
+ it("a third run after normal work landed on develop still skips", async () => {
194
+ const repo = await initRepo({ prefix: "flow-rerun-ahead-" });
195
+ dirs.push(repo);
196
+ await writeFile(join(repo, "forge.yaml"), 'schema: "forge/workspace@1"\n');
197
+ await executeInstall(await planInstall(repo, ambientIo), ambientIo);
198
+
199
+ // Simulate model-normal state: develop ahead of main (as after
200
+ // integrated work) — must NOT trip FLOW-ADOPT-01. Work lands through a
201
+ // session branch + the gate (FORGE_FLOW_OP=backmerge is retired).
202
+ await landThroughSession(repo, "integrated-work", "work.txt", "integrated\n");
203
+
204
+ const refsBefore = await refSnapshot(repo);
205
+ const third = await planInstall(repo, ambientIo);
206
+ expect(third.refusal).toBeNull();
207
+ await executeInstall(third, ambientIo);
208
+ const dev = third.steps.find((s) => s.step === "develop");
209
+ expect(dev?.status).toBe("skipped");
210
+ expect(await refSnapshot(repo)).toBe(refsBefore);
211
+ });
212
+ });