@warpgogol/forge 9.1.1 → 9.3.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 (539) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/bin/cli.ts +5 -3
  3. package/dist/bin/cli.js +5 -3
  4. package/dist/bin/cli.js.map +1 -1
  5. package/dist/os/adr/handlers/implement-stamp.d.ts +6 -0
  6. package/dist/os/adr/handlers/implement-stamp.d.ts.map +1 -1
  7. package/dist/os/adr/handlers/implement-stamp.js +23 -15
  8. package/dist/os/adr/handlers/implement-stamp.js.map +1 -1
  9. package/dist/os/checks/handlers/counters-journal.d.ts.map +1 -1
  10. package/dist/os/checks/handlers/counters-journal.js +9 -1
  11. package/dist/os/checks/handlers/counters-journal.js.map +1 -1
  12. package/dist/os/core/core.module.d.ts.map +1 -1
  13. package/dist/os/core/core.module.js +32 -39
  14. package/dist/os/core/core.module.js.map +1 -1
  15. package/dist/os/core/lock-holder.d.ts +32 -0
  16. package/dist/os/core/lock-holder.d.ts.map +1 -0
  17. package/dist/os/core/lock-holder.js +81 -0
  18. package/dist/os/core/lock-holder.js.map +1 -0
  19. package/dist/os/core/stamp-lock.d.ts +30 -0
  20. package/dist/os/core/stamp-lock.d.ts.map +1 -0
  21. package/dist/os/core/stamp-lock.js +112 -0
  22. package/dist/os/core/stamp-lock.js.map +1 -0
  23. package/dist/os/flow/branch-name.d.ts +56 -0
  24. package/dist/os/flow/branch-name.d.ts.map +1 -0
  25. package/dist/os/flow/branch-name.js +108 -0
  26. package/dist/os/flow/branch-name.js.map +1 -0
  27. package/dist/os/flow/digest.d.ts +92 -0
  28. package/dist/os/flow/digest.d.ts.map +1 -0
  29. package/dist/os/flow/digest.js +663 -0
  30. package/dist/os/flow/digest.js.map +1 -0
  31. package/dist/os/flow/flow.module.d.ts +3 -0
  32. package/dist/os/flow/flow.module.d.ts.map +1 -0
  33. package/dist/os/flow/flow.module.js +771 -0
  34. package/dist/os/flow/flow.module.js.map +1 -0
  35. package/dist/os/flow/git.d.ts +68 -0
  36. package/dist/os/flow/git.d.ts.map +1 -0
  37. package/dist/os/flow/git.js +257 -0
  38. package/dist/os/flow/git.js.map +1 -0
  39. package/dist/os/flow/guard-files.d.ts +50 -0
  40. package/dist/os/flow/guard-files.d.ts.map +1 -0
  41. package/dist/os/flow/guard-files.js +147 -0
  42. package/dist/os/flow/guard-files.js.map +1 -0
  43. package/dist/os/flow/handlers/flow-backmerge.d.ts +27 -0
  44. package/dist/os/flow/handlers/flow-backmerge.d.ts.map +1 -0
  45. package/dist/os/flow/handlers/flow-backmerge.js +332 -0
  46. package/dist/os/flow/handlers/flow-backmerge.js.map +1 -0
  47. package/dist/os/flow/handlers/flow-check.d.ts +42 -0
  48. package/dist/os/flow/handlers/flow-check.d.ts.map +1 -0
  49. package/dist/os/flow/handlers/flow-check.js +347 -0
  50. package/dist/os/flow/handlers/flow-check.js.map +1 -0
  51. package/dist/os/flow/handlers/flow-cut.d.ts +71 -0
  52. package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -0
  53. package/dist/os/flow/handlers/flow-cut.js +722 -0
  54. package/dist/os/flow/handlers/flow-cut.js.map +1 -0
  55. package/dist/os/flow/handlers/flow-digest.d.ts +5 -0
  56. package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -0
  57. package/dist/os/flow/handlers/flow-digest.js +116 -0
  58. package/dist/os/flow/handlers/flow-digest.js.map +1 -0
  59. package/dist/os/flow/handlers/flow-discard.d.ts +22 -0
  60. package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -0
  61. package/dist/os/flow/handlers/flow-discard.js +204 -0
  62. package/dist/os/flow/handlers/flow-discard.js.map +1 -0
  63. package/dist/os/flow/handlers/flow-fix.d.ts +47 -0
  64. package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -0
  65. package/dist/os/flow/handlers/flow-fix.js +532 -0
  66. package/dist/os/flow/handlers/flow-fix.js.map +1 -0
  67. package/dist/os/flow/handlers/flow-hold.d.ts +32 -0
  68. package/dist/os/flow/handlers/flow-hold.d.ts.map +1 -0
  69. package/dist/os/flow/handlers/flow-hold.js +359 -0
  70. package/dist/os/flow/handlers/flow-hold.js.map +1 -0
  71. package/dist/os/flow/handlers/flow-install.d.ts +92 -0
  72. package/dist/os/flow/handlers/flow-install.d.ts.map +1 -0
  73. package/dist/os/flow/handlers/flow-install.js +883 -0
  74. package/dist/os/flow/handlers/flow-install.js.map +1 -0
  75. package/dist/os/flow/handlers/flow-integrate.d.ts +35 -0
  76. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -0
  77. package/dist/os/flow/handlers/flow-integrate.js +436 -0
  78. package/dist/os/flow/handlers/flow-integrate.js.map +1 -0
  79. package/dist/os/flow/handlers/flow-open.d.ts +63 -0
  80. package/dist/os/flow/handlers/flow-open.d.ts.map +1 -0
  81. package/dist/os/flow/handlers/flow-open.js +294 -0
  82. package/dist/os/flow/handlers/flow-open.js.map +1 -0
  83. package/dist/os/flow/handlers/flow-publication-retire.d.ts +17 -0
  84. package/dist/os/flow/handlers/flow-publication-retire.d.ts.map +1 -0
  85. package/dist/os/flow/handlers/flow-publication-retire.js +132 -0
  86. package/dist/os/flow/handlers/flow-publication-retire.js.map +1 -0
  87. package/dist/os/flow/handlers/flow-push.d.ts +29 -0
  88. package/dist/os/flow/handlers/flow-push.d.ts.map +1 -0
  89. package/dist/os/flow/handlers/flow-push.js +397 -0
  90. package/dist/os/flow/handlers/flow-push.js.map +1 -0
  91. package/dist/os/flow/handlers/flow-status.d.ts +65 -0
  92. package/dist/os/flow/handlers/flow-status.d.ts.map +1 -0
  93. package/dist/os/flow/handlers/flow-status.js +193 -0
  94. package/dist/os/flow/handlers/flow-status.js.map +1 -0
  95. package/dist/os/flow/handlers/flow-unhold.d.ts +20 -0
  96. package/dist/os/flow/handlers/flow-unhold.d.ts.map +1 -0
  97. package/dist/os/flow/handlers/flow-unhold.js +158 -0
  98. package/dist/os/flow/handlers/flow-unhold.js.map +1 -0
  99. package/dist/os/flow/handlers/flow-version.d.ts +39 -0
  100. package/dist/os/flow/handlers/flow-version.d.ts.map +1 -0
  101. package/dist/os/flow/handlers/flow-version.js +122 -0
  102. package/dist/os/flow/handlers/flow-version.js.map +1 -0
  103. package/dist/os/flow/index.d.ts +30 -0
  104. package/dist/os/flow/index.d.ts.map +1 -0
  105. package/dist/os/flow/index.js +83 -0
  106. package/dist/os/flow/index.js.map +1 -0
  107. package/dist/os/flow/line-version.d.ts +23 -0
  108. package/dist/os/flow/line-version.d.ts.map +1 -0
  109. package/dist/os/flow/line-version.js +83 -0
  110. package/dist/os/flow/line-version.js.map +1 -0
  111. package/dist/os/flow/locks.d.ts +39 -0
  112. package/dist/os/flow/locks.d.ts.map +1 -0
  113. package/dist/os/flow/locks.js +177 -0
  114. package/dist/os/flow/locks.js.map +1 -0
  115. package/dist/os/flow/markers.d.ts +49 -0
  116. package/dist/os/flow/markers.d.ts.map +1 -0
  117. package/dist/os/flow/markers.js +112 -0
  118. package/dist/os/flow/markers.js.map +1 -0
  119. package/dist/os/flow/publication-order.d.ts +25 -0
  120. package/dist/os/flow/publication-order.d.ts.map +1 -0
  121. package/dist/os/flow/publication-order.js +75 -0
  122. package/dist/os/flow/publication-order.js.map +1 -0
  123. package/dist/os/flow/publish.d.ts +46 -0
  124. package/dist/os/flow/publish.d.ts.map +1 -0
  125. package/dist/os/flow/publish.js +209 -0
  126. package/dist/os/flow/publish.js.map +1 -0
  127. package/dist/os/flow/registry.d.ts +142 -0
  128. package/dist/os/flow/registry.d.ts.map +1 -0
  129. package/dist/os/flow/registry.js +199 -0
  130. package/dist/os/flow/registry.js.map +1 -0
  131. package/dist/os/flow/release-level.d.ts +23 -0
  132. package/dist/os/flow/release-level.d.ts.map +1 -0
  133. package/dist/os/flow/release-level.js +102 -0
  134. package/dist/os/flow/release-level.js.map +1 -0
  135. package/dist/os/flow/release-lines.d.ts +25 -0
  136. package/dist/os/flow/release-lines.d.ts.map +1 -0
  137. package/dist/os/flow/release-lines.js +172 -0
  138. package/dist/os/flow/release-lines.js.map +1 -0
  139. package/dist/os/flow/release-tags.d.ts +73 -0
  140. package/dist/os/flow/release-tags.d.ts.map +1 -0
  141. package/dist/os/flow/release-tags.js +167 -0
  142. package/dist/os/flow/release-tags.js.map +1 -0
  143. package/dist/os/flow/repo-kind.d.ts +41 -0
  144. package/dist/os/flow/repo-kind.d.ts.map +1 -0
  145. package/dist/os/flow/repo-kind.js +92 -0
  146. package/dist/os/flow/repo-kind.js.map +1 -0
  147. package/dist/os/flow/scripts.d.ts +20 -0
  148. package/dist/os/flow/scripts.d.ts.map +1 -0
  149. package/dist/os/flow/scripts.js +50 -0
  150. package/dist/os/flow/scripts.js.map +1 -0
  151. package/dist/os/flow/semver.d.ts +21 -0
  152. package/dist/os/flow/semver.d.ts.map +1 -0
  153. package/dist/os/flow/semver.js +73 -0
  154. package/dist/os/flow/semver.js.map +1 -0
  155. package/dist/os/flow/task-files.d.ts +11 -0
  156. package/dist/os/flow/task-files.d.ts.map +1 -0
  157. package/dist/os/flow/task-files.js +51 -0
  158. package/dist/os/flow/task-files.js.map +1 -0
  159. package/dist/os/flow/tests/helpers.d.ts +55 -0
  160. package/dist/os/flow/tests/helpers.d.ts.map +1 -0
  161. package/dist/os/flow/tests/helpers.js +193 -0
  162. package/dist/os/flow/tests/helpers.js.map +1 -0
  163. package/dist/os/flow/version-files.d.ts +21 -0
  164. package/dist/os/flow/version-files.d.ts.map +1 -0
  165. package/dist/os/flow/version-files.js +94 -0
  166. package/dist/os/flow/version-files.js.map +1 -0
  167. package/dist/os/flow/worktree-path.d.ts +31 -0
  168. package/dist/os/flow/worktree-path.d.ts.map +1 -0
  169. package/dist/os/flow/worktree-path.js +80 -0
  170. package/dist/os/flow/worktree-path.js.map +1 -0
  171. package/dist/os/mission/handlers/archive.d.ts.map +1 -1
  172. package/dist/os/mission/handlers/archive.js +44 -51
  173. package/dist/os/mission/handlers/archive.js.map +1 -1
  174. package/dist/os/mission/lockfile.d.ts +21 -0
  175. package/dist/os/mission/lockfile.d.ts.map +1 -0
  176. package/dist/os/mission/lockfile.js +76 -0
  177. package/dist/os/mission/lockfile.js.map +1 -0
  178. package/dist/os/mission/mission.module.d.ts.map +1 -1
  179. package/dist/os/mission/mission.module.js +2 -1
  180. package/dist/os/mission/mission.module.js.map +1 -1
  181. package/dist/os/program/handlers/seal.d.ts.map +1 -1
  182. package/dist/os/program/handlers/seal.js +1 -1
  183. package/dist/os/program/handlers/seal.js.map +1 -1
  184. package/dist/os/program/handlers/validate.d.ts.map +1 -1
  185. package/dist/os/program/handlers/validate.js +1 -1
  186. package/dist/os/program/handlers/validate.js.map +1 -1
  187. package/dist/os/program/program.module.d.ts.map +1 -1
  188. package/dist/os/program/program.module.js +2 -1
  189. package/dist/os/program/program.module.js.map +1 -1
  190. package/dist/os/program/schemas.d.ts +4 -6
  191. package/dist/os/program/schemas.d.ts.map +1 -1
  192. package/dist/os/program/schemas.js +16 -6
  193. package/dist/os/program/schemas.js.map +1 -1
  194. package/dist/os/program/state.d.ts +0 -1
  195. package/dist/os/program/state.d.ts.map +1 -1
  196. package/dist/os/program/state.js +1 -7
  197. package/dist/os/program/state.js.map +1 -1
  198. package/dist/os/rfc/acceptance.d.ts +21 -0
  199. package/dist/os/rfc/acceptance.d.ts.map +1 -1
  200. package/dist/os/rfc/acceptance.js +62 -13
  201. package/dist/os/rfc/acceptance.js.map +1 -1
  202. package/dist/os/rfc/frontmatter-io.d.ts +19 -0
  203. package/dist/os/rfc/frontmatter-io.d.ts.map +1 -1
  204. package/dist/os/rfc/frontmatter-io.js +65 -12
  205. package/dist/os/rfc/frontmatter-io.js.map +1 -1
  206. package/dist/os/rfc/handlers/implement-stamp.d.ts +6 -0
  207. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  208. package/dist/os/rfc/handlers/implement-stamp.js +24 -19
  209. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  210. package/dist/os/rfc/handlers/validate-rules.d.ts +2 -5
  211. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  212. package/dist/os/rfc/handlers/validate-rules.js +10 -8
  213. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  214. package/dist/os/rfc/handlers/validate.d.ts.map +1 -1
  215. package/dist/os/rfc/handlers/validate.js +15 -5
  216. package/dist/os/rfc/handlers/validate.js.map +1 -1
  217. package/dist/os/rfc/index.d.ts +2 -2
  218. package/dist/os/rfc/index.d.ts.map +1 -1
  219. package/dist/os/rfc/index.js +5 -2
  220. package/dist/os/rfc/index.js.map +1 -1
  221. package/dist/os/rfc/probe-batch.d.ts +71 -0
  222. package/dist/os/rfc/probe-batch.d.ts.map +1 -0
  223. package/dist/os/rfc/probe-batch.js +251 -0
  224. package/dist/os/rfc/probe-batch.js.map +1 -0
  225. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  226. package/dist/os/rfc/rfc.module.js +16 -2
  227. package/dist/os/rfc/rfc.module.js.map +1 -1
  228. package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
  229. package/dist/os/rfc/verification-evidence.js +21 -10
  230. package/dist/os/rfc/verification-evidence.js.map +1 -1
  231. package/dist/os/rfc/verification-refresh.d.ts.map +1 -1
  232. package/dist/os/rfc/verification-refresh.js +20 -13
  233. package/dist/os/rfc/verification-refresh.js.map +1 -1
  234. package/dist/os/system/handlers/outbox-validate.d.ts +8 -0
  235. package/dist/os/system/handlers/outbox-validate.d.ts.map +1 -0
  236. package/dist/os/system/handlers/outbox-validate.js +102 -0
  237. package/dist/os/system/handlers/outbox-validate.js.map +1 -0
  238. package/dist/os/system/handlers/system-map-validate.d.ts +13 -0
  239. package/dist/os/system/handlers/system-map-validate.d.ts.map +1 -0
  240. package/dist/os/system/handlers/system-map-validate.js +78 -0
  241. package/dist/os/system/handlers/system-map-validate.js.map +1 -0
  242. package/dist/os/system/handlers/system-outbox-scan.d.ts +10 -0
  243. package/dist/os/system/handlers/system-outbox-scan.d.ts.map +1 -0
  244. package/dist/os/system/handlers/system-outbox-scan.js +195 -0
  245. package/dist/os/system/handlers/system-outbox-scan.js.map +1 -0
  246. package/dist/os/system/handlers/system-task-collect.d.ts +13 -0
  247. package/dist/os/system/handlers/system-task-collect.d.ts.map +1 -0
  248. package/dist/os/system/handlers/system-task-collect.js +238 -0
  249. package/dist/os/system/handlers/system-task-collect.js.map +1 -0
  250. package/dist/os/system/handlers/system-task-create.d.ts +32 -0
  251. package/dist/os/system/handlers/system-task-create.d.ts.map +1 -0
  252. package/dist/os/system/handlers/system-task-create.js +216 -0
  253. package/dist/os/system/handlers/system-task-create.js.map +1 -0
  254. package/dist/os/system/handlers/system-task-dispatch.d.ts +14 -0
  255. package/dist/os/system/handlers/system-task-dispatch.d.ts.map +1 -0
  256. package/dist/os/system/handlers/system-task-dispatch.js +290 -0
  257. package/dist/os/system/handlers/system-task-dispatch.js.map +1 -0
  258. package/dist/os/system/handlers/system-task-move.d.ts +12 -0
  259. package/dist/os/system/handlers/system-task-move.d.ts.map +1 -0
  260. package/dist/os/system/handlers/system-task-move.js +217 -0
  261. package/dist/os/system/handlers/system-task-move.js.map +1 -0
  262. package/dist/os/system/handlers/system-task-status.d.ts +20 -0
  263. package/dist/os/system/handlers/system-task-status.d.ts.map +1 -0
  264. package/dist/os/system/handlers/system-task-status.js +139 -0
  265. package/dist/os/system/handlers/system-task-status.js.map +1 -0
  266. package/dist/os/system/handlers/system-versionset-record.d.ts +12 -0
  267. package/dist/os/system/handlers/system-versionset-record.d.ts.map +1 -0
  268. package/dist/os/system/handlers/system-versionset-record.js +332 -0
  269. package/dist/os/system/handlers/system-versionset-record.js.map +1 -0
  270. package/dist/os/system/index.d.ts +6 -0
  271. package/dist/os/system/index.d.ts.map +1 -0
  272. package/dist/os/system/index.js +18 -0
  273. package/dist/os/system/index.js.map +1 -0
  274. package/dist/os/system/outbox-schema.d.ts +30 -0
  275. package/dist/os/system/outbox-schema.d.ts.map +1 -0
  276. package/dist/os/system/outbox-schema.js +29 -0
  277. package/dist/os/system/outbox-schema.js.map +1 -0
  278. package/dist/os/system/repo.d.ts +64 -0
  279. package/dist/os/system/repo.d.ts.map +1 -0
  280. package/dist/os/system/repo.js +364 -0
  281. package/dist/os/system/repo.js.map +1 -0
  282. package/dist/os/system/scenario-schemas.d.ts +26 -0
  283. package/dist/os/system/scenario-schemas.d.ts.map +1 -0
  284. package/dist/os/system/scenario-schemas.js +53 -0
  285. package/dist/os/system/scenario-schemas.js.map +1 -0
  286. package/dist/os/system/schemas.d.ts +63 -0
  287. package/dist/os/system/schemas.d.ts.map +1 -0
  288. package/dist/os/system/schemas.js +83 -0
  289. package/dist/os/system/schemas.js.map +1 -0
  290. package/dist/os/system/system.module.d.ts +3 -0
  291. package/dist/os/system/system.module.d.ts.map +1 -0
  292. package/dist/os/system/system.module.js +429 -0
  293. package/dist/os/system/system.module.js.map +1 -0
  294. package/dist/os/system/task-schemas.d.ts +108 -0
  295. package/dist/os/system/task-schemas.d.ts.map +1 -0
  296. package/dist/os/system/task-schemas.js +152 -0
  297. package/dist/os/system/task-schemas.js.map +1 -0
  298. package/dist/os/system/task-store.d.ts +41 -0
  299. package/dist/os/system/task-store.d.ts.map +1 -0
  300. package/dist/os/system/task-store.js +142 -0
  301. package/dist/os/system/task-store.js.map +1 -0
  302. package/dist/os/system/tests/helpers.d.ts +30 -0
  303. package/dist/os/system/tests/helpers.d.ts.map +1 -0
  304. package/dist/os/system/tests/helpers.js +178 -0
  305. package/dist/os/system/tests/helpers.js.map +1 -0
  306. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts.map +1 -1
  307. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js +21 -7
  308. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js.map +1 -1
  309. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts.map +1 -1
  310. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js +1 -1
  311. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js.map +1 -1
  312. package/dist/os/werkstatt/werkstatt.module.d.ts.map +1 -1
  313. package/dist/os/werkstatt/werkstatt.module.js +2 -82
  314. package/dist/os/werkstatt/werkstatt.module.js.map +1 -1
  315. package/dist/src/config/forge-config.d.ts +0 -3
  316. package/dist/src/config/forge-config.d.ts.map +1 -1
  317. package/dist/src/config/forge-config.js +2 -4
  318. package/dist/src/config/forge-config.js.map +1 -1
  319. package/dist/src/index.d.ts +6 -0
  320. package/dist/src/index.d.ts.map +1 -1
  321. package/dist/src/index.js +7 -4
  322. package/dist/src/index.js.map +1 -1
  323. package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
  324. package/dist/src/onboarding/agents-generate.js +49 -4
  325. package/dist/src/onboarding/agents-generate.js.map +1 -1
  326. package/dist/src/onboarding/create.d.ts +13 -0
  327. package/dist/src/onboarding/create.d.ts.map +1 -1
  328. package/dist/src/onboarding/create.js +95 -9
  329. package/dist/src/onboarding/create.js.map +1 -1
  330. package/dist/src/onboarding/doctor.d.ts.map +1 -1
  331. package/dist/src/onboarding/doctor.js +2 -47
  332. package/dist/src/onboarding/doctor.js.map +1 -1
  333. package/dist/src/onboarding/upgrade.d.ts +5 -0
  334. package/dist/src/onboarding/upgrade.d.ts.map +1 -1
  335. package/dist/src/onboarding/upgrade.js +70 -1
  336. package/dist/src/onboarding/upgrade.js.map +1 -1
  337. package/dist/src/types.d.ts +9 -0
  338. package/dist/src/types.d.ts.map +1 -1
  339. package/dist/src/types.js +2 -2
  340. package/docs/branch-model.md +98 -0
  341. package/docs/maintainers/publishing.md +10 -8
  342. package/docs/reference/cli.md +0 -3
  343. package/os/adr/handlers/implement-stamp-lock.test.ts +90 -0
  344. package/os/adr/handlers/implement-stamp.ts +29 -20
  345. package/os/checks/handlers/counters-journal.test.ts +10 -0
  346. package/os/checks/handlers/counters-journal.ts +8 -1
  347. package/os/core/core.module.ts +38 -39
  348. package/os/core/lock-holder.ts +88 -0
  349. package/os/core/stamp-lock.ts +142 -0
  350. package/os/flow/assets/flow-guard.sh +176 -0
  351. package/os/flow/branch-name.ts +139 -0
  352. package/os/flow/digest.ts +803 -0
  353. package/os/flow/flow.module.ts +796 -0
  354. package/os/flow/git.ts +342 -0
  355. package/os/flow/guard-files.ts +172 -0
  356. package/os/flow/handlers/flow-backmerge.ts +488 -0
  357. package/os/flow/handlers/flow-check.ts +450 -0
  358. package/os/flow/handlers/flow-cut.ts +1025 -0
  359. package/os/flow/handlers/flow-digest.ts +130 -0
  360. package/os/flow/handlers/flow-discard.ts +310 -0
  361. package/os/flow/handlers/flow-fix.ts +703 -0
  362. package/os/flow/handlers/flow-hold.ts +500 -0
  363. package/os/flow/handlers/flow-install.ts +1185 -0
  364. package/os/flow/handlers/flow-integrate.ts +623 -0
  365. package/os/flow/handlers/flow-open.ts +447 -0
  366. package/os/flow/handlers/flow-publication-retire.ts +156 -0
  367. package/os/flow/handlers/flow-push.ts +488 -0
  368. package/os/flow/handlers/flow-status.ts +283 -0
  369. package/os/flow/handlers/flow-unhold.ts +220 -0
  370. package/os/flow/handlers/flow-version.ts +196 -0
  371. package/os/flow/index.ts +102 -0
  372. package/os/flow/line-version.ts +113 -0
  373. package/os/flow/locks.ts +227 -0
  374. package/os/flow/markers.ts +135 -0
  375. package/os/flow/publication-order.ts +99 -0
  376. package/os/flow/publish.ts +272 -0
  377. package/os/flow/registry.ts +269 -0
  378. package/os/flow/release-level.ts +139 -0
  379. package/os/flow/release-lines.ts +208 -0
  380. package/os/flow/release-tags.ts +232 -0
  381. package/os/flow/repo-kind.ts +117 -0
  382. package/os/flow/scripts.ts +75 -0
  383. package/os/flow/semver.ts +82 -0
  384. package/os/flow/task-files.ts +59 -0
  385. package/os/flow/tests/branch-name.test.ts +136 -0
  386. package/os/flow/tests/fixtures/branch-names.yaml +56 -0
  387. package/os/flow/tests/flow-backmerge.test.ts +267 -0
  388. package/os/flow/tests/flow-check-version.test.ts +138 -0
  389. package/os/flow/tests/flow-check.test.ts +213 -0
  390. package/os/flow/tests/flow-cut-prepare.test.ts +298 -0
  391. package/os/flow/tests/flow-cut.rerun.test.ts +95 -0
  392. package/os/flow/tests/flow-cut.test.ts +323 -0
  393. package/os/flow/tests/flow-digest.test.ts +313 -0
  394. package/os/flow/tests/flow-discard.test.ts +220 -0
  395. package/os/flow/tests/flow-fix.test.ts +359 -0
  396. package/os/flow/tests/flow-guard-merge.test.ts +100 -0
  397. package/os/flow/tests/flow-guard-parity.test.ts +115 -0
  398. package/os/flow/tests/flow-guard-push.test.ts +100 -0
  399. package/os/flow/tests/flow-guard.test.ts +135 -0
  400. package/os/flow/tests/flow-hold.test.ts +465 -0
  401. package/os/flow/tests/flow-install-baseline.rerun.test.ts +73 -0
  402. package/os/flow/tests/flow-install-baseline.test.ts +164 -0
  403. package/os/flow/tests/flow-install-markers.test.ts +161 -0
  404. package/os/flow/tests/flow-install.rerun.test.ts +212 -0
  405. package/os/flow/tests/flow-install.test.ts +330 -0
  406. package/os/flow/tests/flow-integrate.rerun.test.ts +92 -0
  407. package/os/flow/tests/flow-integrate.test.ts +229 -0
  408. package/os/flow/tests/flow-open.test.ts +200 -0
  409. package/os/flow/tests/flow-publication-retire.test.ts +191 -0
  410. package/os/flow/tests/flow-push-publish.test.ts +282 -0
  411. package/os/flow/tests/flow-push-supersede.test.ts +221 -0
  412. package/os/flow/tests/flow-push.test.ts +160 -0
  413. package/os/flow/tests/flow-stale.test.ts +136 -0
  414. package/os/flow/tests/flow-status.test.ts +93 -0
  415. package/os/flow/tests/flow-task-files.test.ts +59 -0
  416. package/os/flow/tests/flow-version-level.test.ts +116 -0
  417. package/os/flow/tests/flow-version.test.ts +169 -0
  418. package/os/flow/tests/helpers.ts +239 -0
  419. package/os/flow/tests/is-flow-adopted.test.ts +71 -0
  420. package/os/flow/tests/locks.test.ts +219 -0
  421. package/os/flow/tests/publication-order.test.ts +102 -0
  422. package/os/flow/tests/registry.test.ts +150 -0
  423. package/os/flow/tests/repository-line-version.test.ts +100 -0
  424. package/os/flow/tests/scripts.test.ts +97 -0
  425. package/os/flow/tests/state-roots.test.ts +127 -0
  426. package/os/flow/tests/version-files.test.ts +145 -0
  427. package/os/flow/version-files.ts +115 -0
  428. package/os/flow/worktree-path.ts +107 -0
  429. package/os/mission/handlers/archive.test.ts +108 -36
  430. package/os/mission/handlers/archive.ts +46 -51
  431. package/os/mission/lockfile.ts +84 -0
  432. package/os/mission/mission.module.ts +2 -1
  433. package/os/program/handlers/seal.ts +1 -1
  434. package/os/program/handlers/validate.ts +1 -1
  435. package/os/program/program.module.ts +2 -1
  436. package/os/program/schemas.ts +51 -34
  437. package/os/program/state.ts +1 -9
  438. package/os/rfc/acceptance.ts +84 -19
  439. package/os/rfc/frontmatter-io.ts +78 -12
  440. package/os/rfc/handlers/implement-stamp-lock.test.ts +133 -0
  441. package/os/rfc/handlers/implement-stamp-stale.test.ts +22 -0
  442. package/os/rfc/handlers/implement-stamp.ts +30 -24
  443. package/os/rfc/handlers/validate-rules.test.ts +9 -6
  444. package/os/rfc/handlers/validate-rules.ts +12 -10
  445. package/os/rfc/handlers/validate.ts +17 -5
  446. package/os/rfc/index.ts +13 -1
  447. package/os/rfc/probe-batch.ts +329 -0
  448. package/os/rfc/rfc.module.ts +19 -2
  449. package/os/rfc/verification-emit-check.test.ts +22 -0
  450. package/os/rfc/verification-emit-freshness.test.ts +22 -0
  451. package/os/rfc/verification-emit.test.ts +22 -0
  452. package/os/rfc/verification-evidence.ts +21 -16
  453. package/os/rfc/verification-refresh.test.ts +22 -0
  454. package/os/rfc/verification-refresh.ts +20 -18
  455. package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +9 -0
  456. package/os/system/handlers/outbox-validate.ts +120 -0
  457. package/os/system/handlers/system-map-validate.ts +107 -0
  458. package/os/system/handlers/system-outbox-scan.ts +320 -0
  459. package/os/system/handlers/system-task-collect.ts +305 -0
  460. package/os/system/handlers/system-task-create.ts +271 -0
  461. package/os/system/handlers/system-task-dispatch.ts +387 -0
  462. package/os/system/handlers/system-task-move.ts +353 -0
  463. package/os/system/handlers/system-task-status.ts +176 -0
  464. package/os/system/handlers/system-versionset-record.ts +476 -0
  465. package/os/system/index.ts +47 -0
  466. package/os/system/outbox-schema.ts +47 -0
  467. package/os/system/repo.ts +451 -0
  468. package/os/system/scenario-schemas.ts +62 -0
  469. package/os/system/schemas.ts +102 -0
  470. package/os/system/system.module.ts +449 -0
  471. package/os/system/task-schemas.ts +190 -0
  472. package/os/system/task-store.ts +184 -0
  473. package/os/system/tests/helpers.ts +189 -0
  474. package/os/system/tests/outbox-validate.test.ts +92 -0
  475. package/os/system/tests/system-map-validate.test.ts +321 -0
  476. package/os/system/tests/system-outbox-scan.test.ts +273 -0
  477. package/os/system/tests/system-profile.test.ts +90 -0
  478. package/os/system/tests/system-task-collect.test.ts +293 -0
  479. package/os/system/tests/system-task-dispatch.test.ts +279 -0
  480. package/os/system/tests/system-task-status.test.ts +153 -0
  481. package/os/system/tests/system-task.test.ts +330 -0
  482. package/os/system/tests/system-versionset.test.ts +314 -0
  483. package/os/werkstatt/handlers/werkstatt-lock-recover.ts +22 -5
  484. package/os/werkstatt/handlers/werkstatt-operation-validate.ts +1 -1
  485. package/os/werkstatt/werkstatt.module.ts +2 -85
  486. package/package.json +49 -1
  487. package/profiles/forge-shell.yaml +22 -10
  488. package/profiles/godot-game.yaml +24 -13
  489. package/profiles/knowledge.yaml +19 -0
  490. package/profiles/phaser-game.yaml +25 -13
  491. package/profiles/site-workshop.yaml +27 -10
  492. package/profiles/system.yaml +650 -0
  493. package/profiles/typescript.yaml +26 -9
  494. package/skills/fo/fo-outbox/SKILL.md +71 -0
  495. package/skills/fo/fo-session-retro/SKILL.md +18 -7
  496. package/skills/fo/fo-step-commit/SKILL.md +2 -1
  497. package/skills/fo/fo-system-dispatch/SKILL.md +65 -0
  498. package/skills/fo/fo-task-run/SKILL.md +75 -0
  499. package/src/config/forge-config.ts +2 -6
  500. package/src/index.ts +19 -4
  501. package/src/onboarding/agents-generate.ts +49 -5
  502. package/src/onboarding/create.ts +101 -9
  503. package/src/onboarding/doctor.ts +2 -51
  504. package/src/onboarding/upgrade.ts +86 -1
  505. package/src/tests/agents-generate-flow.test.ts +132 -0
  506. package/src/tests/create-flow.test.ts +114 -0
  507. package/src/tests/create.test.ts +22 -21
  508. package/src/tests/doctor-autonomy.test.ts +2 -1
  509. package/src/tests/fixtures/agents-generate-business-before.txt +6 -0
  510. package/src/tests/implement-stamp.test.ts +26 -3
  511. package/src/tests/profile-flow-hooks.test.ts +77 -0
  512. package/src/tests/profile-schema.test.ts +2 -1
  513. package/src/tests/program-schemas.test.ts +66 -6
  514. package/src/tests/program-spec-node.test.ts +1 -5
  515. package/src/tests/rfc-evidence-sync.test.ts +22 -0
  516. package/src/tests/rfc-implement-stamp-governance.test.ts +25 -1
  517. package/src/tests/rfc-verification-verdict-ingest.test.ts +22 -0
  518. package/src/tests/upgrade-flow.test.ts +174 -0
  519. package/src/types.ts +11 -2
  520. package/dist/os/werkstatt/handlers/session-close.d.ts +0 -13
  521. package/dist/os/werkstatt/handlers/session-close.d.ts.map +0 -1
  522. package/dist/os/werkstatt/handlers/session-close.js +0 -56
  523. package/dist/os/werkstatt/handlers/session-close.js.map +0 -1
  524. package/dist/os/werkstatt/handlers/session-engine.d.ts +0 -3
  525. package/dist/os/werkstatt/handlers/session-engine.d.ts.map +0 -1
  526. package/dist/os/werkstatt/handlers/session-engine.js +0 -28
  527. package/dist/os/werkstatt/handlers/session-engine.js.map +0 -1
  528. package/dist/os/werkstatt/handlers/session-open.d.ts +0 -10
  529. package/dist/os/werkstatt/handlers/session-open.d.ts.map +0 -1
  530. package/dist/os/werkstatt/handlers/session-open.js +0 -46
  531. package/dist/os/werkstatt/handlers/session-open.js.map +0 -1
  532. package/dist/os/werkstatt/handlers/session-status.d.ts +0 -9
  533. package/dist/os/werkstatt/handlers/session-status.d.ts.map +0 -1
  534. package/dist/os/werkstatt/handlers/session-status.js +0 -34
  535. package/dist/os/werkstatt/handlers/session-status.js.map +0 -1
  536. package/os/werkstatt/handlers/session-close.ts +0 -82
  537. package/os/werkstatt/handlers/session-engine.ts +0 -34
  538. package/os/werkstatt/handlers/session-open.ts +0 -68
  539. package/os/werkstatt/handlers/session-status.ts +0 -55
@@ -0,0 +1,722 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>flow.cut — the ordinary release on the fixed branch model
4
+ (RFC-1490). Plan phase refuses before any mutation (FLOW-CUT-01..07);
5
+ execute runs under the integration lock: release branch via openFlowBranchCore,
6
+ verified version-file writes, release commit, gate+ff through
7
+ integrateFlowBranch(lockHeld), fingerprints hook, main compare-and-swap,
8
+ release tags, journal. Rerun-safe: a develop tip already carrying the
9
+ release subject resumes at fingerprints; a fully tagged tip reports
10
+ released with no mutation.</purpose>
11
+ <non-goals>
12
+ <item>No fix releases — flow.cut's fix mode lives alongside (step 6).</item>
13
+ <item>No pushing — outbound is the next RFC.</item>
14
+ </non-goals>
15
+ </MODULE_CONTRACT>
16
+ <KEY_DECISIONS>
17
+ <item>The integration lock spans open→main-move so no second integration can interleave between the gate and the main fast-forward.</item>
18
+ <item>Version writes are verified textual replacements (VersionWriteError → FLOW-CUT-11); the release branch is removed on that failure per AUDIT-RFC-1490-C3.</item>
19
+ <item>Resume keys on the develop tip's `chore(release):` subject — the subject is the persisted declaration of which tags the release intends.</item>
20
+ <item>RFC-1502: `git add -u` folds the release-prepare hook's tracked edits in; its untracked leftovers are listed as FLOW-CUT-14 then removed via io.rm (the integrate gate demands a clean tree, and `git clean -f` is blocked in agent sessions). Pre-tag verification extracts every named line at the release commit — a failure deletes worktree+branch before any ref or tag moves (FLOW-CUT-13).</item>
21
+ </KEY_DECISIONS>
22
+ <CHANGE_SUMMARY>
23
+ <item>RFC-1490: independent-review pass — lock-held planning, fix-branch verification, spec-shaped data, coverage</item>
24
+ <item>RFC-1491: step 1 — journal base/rewrites + held registry widening, W1-1 discard tip, FLOW-INT-11</item>
25
+ <item>RFC-1494: step 1 — isFlowAdopted public export</item>
26
+ <item>RFC-1502: steps 1-5 — release-prepare hook, pre-tag extract verification, ordered steps</item>
27
+ <item>RFC-1502: review r1 — fix-cut rollback on FLOW-CUT-12/13, populated steps[], hook validation, GIT_* env scrub</item>
28
+ <history>RFC-1490</history>
29
+ </CHANGE_SUMMARY>
30
+ */
31
+ import { join } from "node:path";
32
+ import { parse as yamlParse } from "yaml";
33
+ import { resolveIo } from "../../../src/utils/io.js";
34
+ import { branchExists, currentBranch, git, gitCommit, isAncestor, requireGit, statusTracked, topLevel, worktreeList, } from "../git.js";
35
+ import { LockTimeoutError, withFlowLock } from "../locks.js";
36
+ import { isFlowAdopted } from "../index.js";
37
+ import { appendJournal, commonGitDir, FlowRegistrySchemaError, INTEGRATE_LOCK_RELATIVE_PATH, readRegistry, registryPath, } from "../registry.js";
38
+ import { bumpVersion, formatVersion } from "../semver.js";
39
+ import { discoverReleaseLines } from "../release-lines.js";
40
+ import { pendingLevel } from "../release-level.js";
41
+ import { listLineTags, releaseTagAnnotation, writeReleaseTag, } from "../release-tags.js";
42
+ import { runFlowScript } from "../scripts.js";
43
+ import { VersionWriteError, writeLineVersion, writeSyncedForgeVersion } from "../version-files.js";
44
+ import { verifyLineAtRef } from "../publish.js";
45
+ import { primaryWorktree } from "../worktree-path.js";
46
+ import { integrateFlowBranch } from "./flow-integrate.js";
47
+ import { openFlowBranchCore } from "./flow-open.js";
48
+ import { INTEGRATE_LOCK_STALE_MS, INTEGRATE_LOCK_WAIT_MS } from "./flow-integrate.js";
49
+ function refuse(ruleId, message, fixHint, partial) {
50
+ return {
51
+ mode: partial?.mode ?? "ordinary",
52
+ released: false,
53
+ resumed: false,
54
+ releaseBranch: null,
55
+ releaseCommit: null,
56
+ mainBefore: null,
57
+ mainAfter: null,
58
+ mainGains: 0,
59
+ tags: partial?.tags ?? [],
60
+ versions: {},
61
+ lines: [],
62
+ fingerprints: {},
63
+ gate: null,
64
+ backmerge: null,
65
+ steps: [],
66
+ diagnostics: [{ ruleId, severity: "error", message, fixHint }],
67
+ };
68
+ }
69
+ /** Flat YAML mapping of string→string; anything else fails FLOW-CUT-08. */
70
+ function parseFingerprints(stdout) {
71
+ try {
72
+ const parsed = yamlParse(stdout);
73
+ if (parsed === null || parsed === undefined)
74
+ return {};
75
+ if (typeof parsed !== "object" || Array.isArray(parsed))
76
+ return null;
77
+ const out = {};
78
+ for (const [k, v] of Object.entries(parsed)) {
79
+ if (typeof v !== "string")
80
+ return null;
81
+ out[k] = v;
82
+ }
83
+ return out;
84
+ }
85
+ catch {
86
+ return null;
87
+ }
88
+ }
89
+ /**
90
+ * Plan phase — every refusal before any mutation. The mutation path runs
91
+ * this INSIDE the integration lock so a landing integration between the
92
+ * dry-plan and the branch-open can never sneak unvetted commits into the
93
+ * release (all refs are resolved at lock time).
94
+ */
95
+ async function planOrdinaryCut(repoRoot, io, opts) {
96
+ const primary = await primaryWorktree(io, repoRoot);
97
+ const guardInstalled = await isFlowAdopted(repoRoot, io);
98
+ if (!guardInstalled) {
99
+ return {
100
+ kind: "refusal",
101
+ data: refuse("FLOW-CUT-01", "repository is not adopted into the fixed branch model (governed + guard installed + develop)", "run pnpm exec forge flow.install, then re-run flow.cut"),
102
+ };
103
+ }
104
+ const mainExists = await branchExists(repoRoot, io, "main");
105
+ if (mainExists && !(await isAncestor(repoRoot, io, "main", "develop"))) {
106
+ return {
107
+ kind: "refusal",
108
+ data: refuse("FLOW-CUT-02", "main carries a release not yet back-merged into develop", "run pnpm exec forge flow.backmerge first"),
109
+ };
110
+ }
111
+ const { lines, diagnostics: discoveryDiags } = await discoverReleaseLines(repoRoot, io);
112
+ if (discoveryDiags.some((d) => d.severity === "error")) {
113
+ return {
114
+ kind: "refusal",
115
+ data: refuse("FLOW-CUT-01", discoveryDiags.map((d) => d.message).join("; "), "fix the release-line discovery errors"),
116
+ };
117
+ }
118
+ const repoLine = lines.find((l) => l.paths.length === 0) ?? lines[0];
119
+ if (repoLine === undefined) {
120
+ return {
121
+ kind: "refusal",
122
+ data: refuse("FLOW-CUT-01", "no release lines discovered — the repository line is mandatory", "check pnpm-workspace.yaml and package.json"),
123
+ };
124
+ }
125
+ const selected = [repoLine];
126
+ for (const id of opts.lines) {
127
+ const found = lines.find((l) => l.id === id);
128
+ if (found === undefined || found.id === repoLine.id) {
129
+ return {
130
+ kind: "refusal",
131
+ data: refuse("FLOW-CUT-03", `unknown release line '${id}' — known lines: ${lines.map((l) => l.id).join(", ")}`, "pass only ids from flow.version --json"),
132
+ };
133
+ }
134
+ selected.push(found);
135
+ }
136
+ const ref = (await git(repoRoot, io, ["rev-parse", "develop"])).stdout.trim();
137
+ const mainTip = mainExists
138
+ ? (await git(repoRoot, io, ["rev-parse", "main"])).stdout.trim()
139
+ : "";
140
+ // Resume detection runs before the pending-level loop: a develop tip
141
+ // carrying `chore(release):` is this cut's own persisted declaration. All
142
+ // named tags present AND main already at the tip → the release completed
143
+ // (rerun reports, no mutation); any missing or a rewound main → the plan
144
+ // still runs but the tail completes exactly the subject's tags (and tags
145
+ // the subject names cannot block as FLOW-CUT-06).
146
+ const tipSubject = (await git(repoRoot, io, ["log", "-1", "--format=%s", ref])).stdout.trim();
147
+ let resumeTags = null;
148
+ if (tipSubject.startsWith("chore(release): ")) {
149
+ const named = tipSubject
150
+ .slice("chore(release): ".length)
151
+ .split(",")
152
+ .map((t) => t.trim())
153
+ .filter((t) => t.length > 0);
154
+ const existence = await Promise.all(named.map(async (t) => (await git(repoRoot, io, ["rev-parse", "--verify", "-q", `refs/tags/${t}`])).exitCode ===
155
+ 0));
156
+ if (named.length > 0 && existence.every((e) => e) && mainTip === ref) {
157
+ return { kind: "completed", ref, tags: named, allLines: lines, mainTip };
158
+ }
159
+ if (named.length > 0)
160
+ resumeTags = named;
161
+ }
162
+ const cutLines = [];
163
+ const majorDemands = [];
164
+ for (const line of selected) {
165
+ const tags = await listLineTags(repoRoot, line, io, ref);
166
+ if (tags.lastTag === null) {
167
+ return {
168
+ kind: "refusal",
169
+ data: refuse("FLOW-CUT-04", `release line '${line.id}' has no baseline tag`, "run pnpm exec forge flow.install to create the baseline tag"),
170
+ };
171
+ }
172
+ const pending = await pendingLevel(line, tags.lastTag.name, io, repoRoot, tags.lastTag.version, ref);
173
+ if (pending.level === "none") {
174
+ return {
175
+ kind: "refusal",
176
+ data: refuse("FLOW-CUT-04", line.id === repoLine.id
177
+ ? "nothing to release — the repository line has no pending commits"
178
+ : `release line '${line.id}' has no pending commits`, "drop the line from --lines, or land work touching its paths first"),
179
+ };
180
+ }
181
+ const next = formatVersion(bumpVersion(tags.lastTag.version, pending.level));
182
+ if (pending.level === "major") {
183
+ majorDemands.push(`${line.id} (${pending.rfcs.map((r) => r.id).join(", ") || "no RFC trailer"})`);
184
+ }
185
+ const tagName = `${line.tagPrefix}${next}`;
186
+ const tagRef = `refs/tags/${tagName}`;
187
+ const namedInSubject = resumeTags !== null && resumeTags.includes(tagName);
188
+ if (!namedInSubject &&
189
+ (await git(repoRoot, io, ["rev-parse", "--verify", "-q", tagRef])).exitCode === 0) {
190
+ return {
191
+ kind: "refusal",
192
+ data: refuse("FLOW-CUT-06", `target tag ${line.tagPrefix}${next} already exists`, "pick a different version or delete the stray tag if it was never published"),
193
+ };
194
+ }
195
+ cutLines.push({
196
+ line,
197
+ tag: tagName,
198
+ level: pending.level,
199
+ nextVersion: next,
200
+ previousTag: tags.lastTag.name,
201
+ rfcs: pending.rfcs.map((r) => r.id),
202
+ });
203
+ }
204
+ if (majorDemands.length > 0 && process.env["ALLOW_MAJOR_BUMP"] !== "1") {
205
+ return {
206
+ kind: "refusal",
207
+ data: refuse("FLOW-CUT-05", `release requires a major bump on: ${majorDemands.join("; ")}`, "re-run with ALLOW_MAJOR_BUMP=1 in the environment — major cuts are operator-only"),
208
+ };
209
+ }
210
+ const primaryBranch = await currentBranch(primary, io);
211
+ const primaryDirty = await statusTracked(primary, io);
212
+ const worktrees = await worktreeList(repoRoot, io);
213
+ const mainCheckedOut = worktrees.some((w) => w.branch === "main");
214
+ if (primaryBranch !== "develop" || primaryDirty.length > 0 || mainCheckedOut) {
215
+ return {
216
+ kind: "refusal",
217
+ data: refuse("FLOW-CUT-07", primaryBranch !== "develop"
218
+ ? `primary worktree is on ${primaryBranch ?? "detached HEAD"}, not develop`
219
+ : mainCheckedOut
220
+ ? "a worktree has main checked out — the cut must own the main ref"
221
+ : `primary worktree has ${primaryDirty.length} tracked uncommitted change(s)`, "switch the primary to develop, commit or revert its changes, and ensure no worktree holds main"),
222
+ };
223
+ }
224
+ const tagList = cutLines.map((c) => c.tag);
225
+ return {
226
+ kind: "plan",
227
+ plan: {
228
+ ref,
229
+ resumeTags,
230
+ cutLines,
231
+ tagList,
232
+ subject: `chore(release): ${tagList.join(", ")}`,
233
+ allLines: lines,
234
+ repoLine,
235
+ mainTip,
236
+ primary,
237
+ },
238
+ };
239
+ }
240
+ /** The line a subject-named tag belongs to — longest matching prefix wins. */
241
+ function lineForTag(tag, allLines, repoLine) {
242
+ const match = allLines
243
+ .filter((l) => l.id !== repoLine.id && tag.startsWith(l.tagPrefix))
244
+ .sort((a, b) => b.tagPrefix.length - a.tagPrefix.length)[0];
245
+ return match ?? repoLine;
246
+ }
247
+ /** Spec-shape `lines[]` for the report — one entry per applied tag. */
248
+ export function toFlowCutLines(tagNames, cutLines, allLines, repoLine) {
249
+ return tagNames.map((tag) => {
250
+ const c = cutLines.find((cl) => cl.tag === tag);
251
+ if (c !== undefined) {
252
+ return {
253
+ line: c.line.id,
254
+ tag,
255
+ previous: c.previousTag,
256
+ level: c.level,
257
+ version: c.nextVersion,
258
+ rfcs: c.rfcs,
259
+ };
260
+ }
261
+ const line = lineForTag(tag, allLines, repoLine);
262
+ return {
263
+ line: line.id,
264
+ tag,
265
+ previous: null,
266
+ level: "patch",
267
+ version: tag.slice(line.tagPrefix.length),
268
+ rfcs: [],
269
+ };
270
+ });
271
+ }
272
+ /**
273
+ * `extract-verify:<line>` steps for named non-repository lines with an
274
+ * extract.config.yaml — anchored on the primary checkout, same probe the
275
+ * execution path uses (RFC-1502).
276
+ */
277
+ export async function plannedExtractVerifySteps(primary, io, cutLines, repoLine) {
278
+ const steps = [];
279
+ for (const c of cutLines) {
280
+ if (c.line.id === repoLine.id)
281
+ continue;
282
+ const dir = c.line.paths[0];
283
+ if (dir !== undefined && (await io.exists(join(primary, dir, "extract.config.yaml")))) {
284
+ steps.push(`extract-verify:${c.line.id}`);
285
+ }
286
+ }
287
+ return steps;
288
+ }
289
+ /** Ordered step names the --dry-run plan reports (RFC-1502 AC-6). */
290
+ async function plannedCutSteps(primary, io, plan) {
291
+ const steps = ["open-branch", "version-writes", "release-prepare", "release-commit"];
292
+ steps.push(...(await plannedExtractVerifySteps(primary, io, plan.cutLines, plan.repoLine)));
293
+ steps.push("integrate", "fingerprints", "main", "tags", "journal");
294
+ return steps;
295
+ }
296
+ function completedReleaseData(outcome) {
297
+ const repoLine = outcome.allLines.find((l) => l.paths.length === 0) ?? outcome.allLines[0];
298
+ return {
299
+ mode: "ordinary",
300
+ released: true,
301
+ resumed: true,
302
+ releaseBranch: null,
303
+ releaseCommit: outcome.ref,
304
+ mainBefore: outcome.mainTip,
305
+ mainAfter: outcome.ref,
306
+ mainGains: 0,
307
+ tags: outcome.tags,
308
+ versions: {},
309
+ lines: toFlowCutLines(outcome.tags, [], outcome.allLines, repoLine),
310
+ fingerprints: {},
311
+ gate: null,
312
+ backmerge: null,
313
+ steps: [],
314
+ diagnostics: [],
315
+ };
316
+ }
317
+ /**
318
+ * Ordinary cut core — callable with an injected clock. Plan-phase refusals
319
+ * resolve inside the integration lock (the world can change while a caller
320
+ * waits), then the release runs open→integrate→fingerprints→main→tags→journal
321
+ * without ever dropping the lock. A develop tip already carrying the release
322
+ * subject resumes at fingerprints; a fully landed release reports released.
323
+ */
324
+ export async function runOrdinaryCut(repoRoot, io, opts) {
325
+ const now = opts.now ?? new Date();
326
+ if (opts.dryRun) {
327
+ const outcome = await planOrdinaryCut(repoRoot, io, opts);
328
+ if (outcome.kind === "refusal")
329
+ return outcome.data;
330
+ if (outcome.kind === "completed")
331
+ return completedReleaseData(outcome);
332
+ const { plan } = outcome;
333
+ return {
334
+ mode: "ordinary",
335
+ released: false,
336
+ resumed: false,
337
+ releaseBranch: null,
338
+ releaseCommit: null,
339
+ mainBefore: plan.mainTip.length > 0 ? plan.mainTip : null,
340
+ mainAfter: null,
341
+ mainGains: 0,
342
+ tags: plan.tagList,
343
+ versions: Object.fromEntries(plan.cutLines.map((c) => [c.line.id, c.nextVersion])),
344
+ lines: toFlowCutLines(plan.tagList, plan.cutLines, plan.allLines, plan.repoLine),
345
+ fingerprints: {},
346
+ gate: null,
347
+ backmerge: null,
348
+ steps: await plannedCutSteps(plan.primary, io, plan),
349
+ diagnostics: [],
350
+ };
351
+ }
352
+ const common = await commonGitDir(io, repoRoot);
353
+ await io.mkdir(join(common, "forge"));
354
+ const lockPath = join(common, INTEGRATE_LOCK_RELATIVE_PATH);
355
+ let releaseBranch = null;
356
+ try {
357
+ return await withFlowLock(lockPath, {
358
+ waitMs: INTEGRATE_LOCK_WAIT_MS,
359
+ staleMs: INTEGRATE_LOCK_STALE_MS,
360
+ progressEveryMs: 60_000,
361
+ onProgress: opts.onProgress,
362
+ }, async () => {
363
+ // Plan at lock time — no stale-ref races against landing integrations.
364
+ const outcome = await planOrdinaryCut(repoRoot, io, opts);
365
+ if (outcome.kind === "refusal")
366
+ return outcome.data;
367
+ if (outcome.kind === "completed")
368
+ return completedReleaseData(outcome);
369
+ const plan = outcome.plan;
370
+ const { cutLines, tagList, subject, repoLine, primary } = plan;
371
+ // Resume tail: release commit integrated earlier; finish at
372
+ // fingerprints → main → tags with exactly the subject's named tags.
373
+ if (plan.resumeTags !== null) {
374
+ // The release branch is linear — tip^ is the develop tip the
375
+ // integration started from, the honest journal base on a rerun.
376
+ const base = (await git(repoRoot, io, ["rev-parse", `${plan.ref}^`])).stdout.trim();
377
+ const resume = await finishCutTail(repoRoot, io, {
378
+ developTip: plan.ref,
379
+ tagNames: plan.resumeTags,
380
+ cutLines,
381
+ allLines: plan.allLines,
382
+ repoLine,
383
+ primary,
384
+ now,
385
+ gate: null,
386
+ journalBranch: "release",
387
+ journalBase: base,
388
+ });
389
+ return { ...resume, resumed: true };
390
+ }
391
+ // 1. release branch.
392
+ const open = await openFlowBranchCore(repoRoot, io, {
393
+ kind: "session",
394
+ slug: `release-${cutLines[0].nextVersion.replaceAll(".", "-")}`,
395
+ brief: `release ${tagList.join(", ")}`,
396
+ owner: { kind: "session", id: "release" },
397
+ dryRun: false,
398
+ now,
399
+ });
400
+ if (!open.opened || open.branch === null || open.worktree === null) {
401
+ const d = open.diagnostics[0];
402
+ return refuse(d?.ruleId ?? "FLOW-CUT-01", d?.message ?? "release branch did not open", d?.fixHint ?? "inspect flow.status");
403
+ }
404
+ releaseBranch = open.branch;
405
+ const wt = open.worktree;
406
+ // 2. version files (verified writes).
407
+ try {
408
+ for (const c of cutLines) {
409
+ await writeLineVersion(wt, c.line, c.nextVersion, io);
410
+ if (c.line.id !== repoLine.id) {
411
+ const pkg = JSON.parse(await io.readFile(join(wt, c.line.versionFile ?? "package.json")));
412
+ if (pkg.name === "@warpgogol/forge") {
413
+ const forgeYaml = join(wt, "forge.yaml");
414
+ if ((await io.exists(forgeYaml)) && /syncedVersion:/.test(await io.readFile(forgeYaml))) {
415
+ await writeSyncedForgeVersion(wt, c.nextVersion, io);
416
+ }
417
+ }
418
+ }
419
+ }
420
+ }
421
+ catch (error) {
422
+ if (error instanceof VersionWriteError) {
423
+ await git(repoRoot, io, ["worktree", "remove", "--force", wt]);
424
+ await git(repoRoot, io, ["branch", "-D", releaseBranch]);
425
+ return refuse("FLOW-CUT-11", `${error.message}`, "fix the version file so the top-level version field is the release version", { releaseBranch });
426
+ }
427
+ throw error;
428
+ }
429
+ // 2b. release-prepare hook (RFC-1502): the repository regenerates
430
+ // version-hashed derived artifacts into the release commit. The
431
+ // script always comes from the primary — a session cannot weaken it.
432
+ const warnings = [];
433
+ const prep = await runFlowScript(io, "release-prepare", {
434
+ primary,
435
+ cwd: wt,
436
+ env: {
437
+ FORGE_FLOW_RELEASE_TAGS: tagList.join(" "),
438
+ FORGE_FLOW_RELEASE_VERSIONS: JSON.stringify(Object.fromEntries(cutLines.map((c) => [c.line.id, c.nextVersion]))),
439
+ },
440
+ });
441
+ if (prep.status === "failed") {
442
+ await git(repoRoot, io, ["worktree", "remove", "--force", wt]);
443
+ await git(repoRoot, io, ["branch", "-D", releaseBranch]);
444
+ return refuse("FLOW-CUT-12", `hooks/release-prepare.sh failed (exit ${prep.exitCode}): ${prep.stderrTail}`, "fix the release-prepare hook and re-run flow.cut", { releaseBranch });
445
+ }
446
+ // 3. release commit — `add -u` folds the hook's tracked edits in;
447
+ // untracked files it left stay out and are reported.
448
+ await git(wt, io, ["add", "-u"]);
449
+ const untrackedFiles = (await git(wt, io, [
450
+ "-c",
451
+ "core.quotepath=false",
452
+ "ls-files",
453
+ "-z",
454
+ "--others",
455
+ "--exclude-standard",
456
+ ])).stdout
457
+ .split("\0")
458
+ .filter((f) => f.length > 0);
459
+ if (untrackedFiles.length > 0) {
460
+ warnings.push({
461
+ ruleId: "FLOW-CUT-14",
462
+ severity: "warning",
463
+ message: `release-prepare left untracked file(s) excluded from the release commit and removed from the release worktree: ${untrackedFiles.join(", ")}`,
464
+ });
465
+ // The cut continues — the same unignored-untracked set comes out of
466
+ // the worktree so the integrate gate sees a clean tree. Removed via
467
+ // io.rm: `git clean -f` is blocked in agent sessions.
468
+ for (const file of untrackedFiles) {
469
+ await io.rm(join(wt, file));
470
+ }
471
+ }
472
+ const body = cutLines
473
+ .map((c) => `${c.tag} ${c.level} ${c.previousTag ?? "null"}`)
474
+ .join("\n");
475
+ const commit = await gitCommit(wt, io, ["commit", "-m", `${subject}\n\n${body}`], "cut");
476
+ if (commit.exitCode !== 0) {
477
+ return refuse("FLOW-CUT-01", `release commit failed: ${commit.stderr.trim()}`, "inspect the release worktree state", { releaseBranch });
478
+ }
479
+ // 3b. pre-tag extract verification (RFC-1502): every named package
480
+ // line extracts at the release commit into a scratch and runs
481
+ // extract-verify — before the integration that makes it a release.
482
+ const releaseSha = (await git(wt, io, ["rev-parse", "HEAD"])).stdout.trim();
483
+ for (const c of cutLines) {
484
+ if (c.line.id === repoLine.id)
485
+ continue;
486
+ const verify = await verifyLineAtRef(primary, io, { line: c.line, ref: releaseSha });
487
+ if (!verify.ok) {
488
+ await git(repoRoot, io, ["worktree", "remove", "--force", wt]);
489
+ await git(repoRoot, io, ["branch", "-D", releaseBranch]);
490
+ return refuse("FLOW-CUT-13", `pre-tag extract verification failed for line ${c.line.id}: ${verify.detail}`, "fix the extract or verify failure and re-run flow.cut", { releaseBranch });
491
+ }
492
+ }
493
+ // 4. integrate (gate + ff + cleanup) with the lock already held.
494
+ const integrated = await integrateFlowBranch(repoRoot, io, {
495
+ branch: releaseBranch,
496
+ dryRun: false,
497
+ now,
498
+ lockHeld: true,
499
+ target: "develop",
500
+ });
501
+ if (!integrated.integrated || integrated.diagnostics.length > 0) {
502
+ const d = integrated.diagnostics[0];
503
+ return refuse(d?.ruleId ?? "FLOW-INT-05", d?.message ?? "integration failed", d?.fixHint ?? "inspect the gate output", { releaseBranch, gate: integrated.gate });
504
+ }
505
+ // 5–8. fingerprints → main → tags → journal.
506
+ const tail = await finishCutTail(repoRoot, io, {
507
+ developTip: integrated.developAfter ?? plan.ref,
508
+ tagNames: tagList,
509
+ cutLines,
510
+ allLines: plan.allLines,
511
+ repoLine,
512
+ primary,
513
+ now,
514
+ gate: integrated.gate,
515
+ journalBranch: releaseBranch,
516
+ journalBase: integrated.developBefore ?? plan.ref,
517
+ });
518
+ return { ...tail, diagnostics: [...warnings, ...tail.diagnostics] };
519
+ }, io);
520
+ }
521
+ catch (error) {
522
+ if (error instanceof LockTimeoutError) {
523
+ return refuse("FLOW-INT-08", `integration lock ${error.lockPath} is held by another integration`, "wait for the running integration to finish, or break the stale lock after 2 h automatically", { releaseBranch });
524
+ }
525
+ if (error instanceof FlowRegistrySchemaError) {
526
+ return refuse("FLOW-07", error.message, `repair or remove ${registryPath(common)}`, { releaseBranch });
527
+ }
528
+ throw error;
529
+ }
530
+ }
531
+ /** Steps 5–8 shared by the fresh path and the resume path. */
532
+ async function finishCutTail(repoRoot, io, args) {
533
+ const { developTip, tagNames, cutLines, allLines, repoLine, primary, gate } = args;
534
+ // 5. fingerprints.
535
+ const fpResult = await runFlowScript(io, "release-fingerprints", {
536
+ primary,
537
+ cwd: primary,
538
+ env: {
539
+ FORGE_FLOW_RELEASE_SHA: developTip,
540
+ FORGE_FLOW_RELEASE_TAGS: tagNames.join(","),
541
+ },
542
+ });
543
+ let fingerprints = {};
544
+ if (fpResult.status === "failed") {
545
+ return refuse("FLOW-CUT-08", `hooks/release-fingerprints.sh failed (exit ${fpResult.exitCode}): ${fpResult.stderrTail}`, "fix the fingerprint hook and re-run flow.cut — main has not moved");
546
+ }
547
+ if (fpResult.status === "done") {
548
+ const parsed = parseFingerprints(fpResult.stdout);
549
+ if (parsed === null) {
550
+ return refuse("FLOW-CUT-08", "hooks/release-fingerprints.sh stdout is not a flat YAML mapping of string keys to string values", "emit only 'key: value' string pairs on stdout");
551
+ }
552
+ fingerprints = parsed;
553
+ }
554
+ // 6. main compare-and-swap.
555
+ const mainTipBefore = (await git(repoRoot, io, ["rev-parse", "main"])).stdout.trim();
556
+ if (await branchExists(repoRoot, io, "main")) {
557
+ if (!(await isAncestor(repoRoot, io, "main", "develop"))) {
558
+ return refuse("FLOW-CUT-02", "main moved past develop mid-cut", "run pnpm exec forge flow.backmerge, then re-run flow.cut");
559
+ }
560
+ const upd = await git(repoRoot, io, ["update-ref", "refs/heads/main", developTip, mainTipBefore]);
561
+ if (upd.exitCode !== 0) {
562
+ return refuse("FLOW-CUT-01", `update-ref main failed: ${upd.stderr.trim()}`, "inspect refs/heads/main");
563
+ }
564
+ }
565
+ else {
566
+ const upd = await git(repoRoot, io, ["update-ref", "refs/heads/main", developTip]);
567
+ if (upd.exitCode !== 0) {
568
+ return refuse("FLOW-CUT-01", `update-ref main failed: ${upd.stderr.trim()}`, "inspect refs/heads/main");
569
+ }
570
+ }
571
+ // 7. tags — iterate the declared names (subject tags on resume) and look
572
+ // each up in the computed cut lines; a named-only tag gets a patch stub on
573
+ // its own line (matched by tag prefix). A tag already pointing at the tip
574
+ // is skipped — rerun-safe against a crash between two git tag calls; a tag
575
+ // pointing elsewhere refuses instead of silently moving it.
576
+ for (const tag of tagNames) {
577
+ const existing = await git(repoRoot, io, ["rev-parse", "-q", "--verify", `refs/tags/${tag}^{}`]);
578
+ if (existing.exitCode === 0) {
579
+ if (existing.stdout.trim() === developTip)
580
+ continue;
581
+ return refuse("FLOW-CUT-06", `tag ${tag} already exists at ${existing.stdout.trim().slice(0, 9)}, not the release tip`, "delete the stray tag if it was never published, or pick a different version");
582
+ }
583
+ const c = cutLines.find((cl) => cl.tag === tag) ?? (() => {
584
+ const line = lineForTag(tag, allLines, repoLine);
585
+ return {
586
+ line,
587
+ tag,
588
+ level: "patch",
589
+ nextVersion: tag.slice(line.tagPrefix.length),
590
+ previousTag: null,
591
+ rfcs: [],
592
+ };
593
+ })();
594
+ const wr = await writeReleaseTag(repoRoot, io, {
595
+ name: tag,
596
+ target: developTip,
597
+ annotation: releaseTagAnnotation({
598
+ tag,
599
+ line: c.line.id,
600
+ version: c.nextVersion,
601
+ level: c.level,
602
+ previous: c.previousTag,
603
+ rfcs: c.rfcs,
604
+ fingerprints: c.line.id === repoLine.id ? fingerprints : {},
605
+ }),
606
+ });
607
+ if (wr.exitCode !== 0) {
608
+ return refuse("FLOW-CUT-01", `tag ${tag} failed: ${wr.stderr.trim()}`, "inspect the tag state");
609
+ }
610
+ }
611
+ // 8. journal.
612
+ const common = await commonGitDir(io, repoRoot);
613
+ try {
614
+ await appendJournal(io, common, {
615
+ event: "cut",
616
+ branch: args.journalBranch,
617
+ sha: developTip,
618
+ base: args.journalBase,
619
+ detail: tagNames.join(", "),
620
+ at: args.now.toISOString(),
621
+ });
622
+ }
623
+ catch {
624
+ // journal failure is non-fatal bookkeeping.
625
+ }
626
+ const mainGains = mainTipBefore.length > 0
627
+ ? Number((await git(repoRoot, io, ["rev-list", "--count", `${mainTipBefore}..${developTip}`])).stdout.trim() || 0)
628
+ : 0;
629
+ return {
630
+ mode: "ordinary",
631
+ released: true,
632
+ resumed: false,
633
+ releaseBranch: null,
634
+ releaseCommit: developTip,
635
+ mainBefore: mainTipBefore.length > 0 ? mainTipBefore : null,
636
+ mainAfter: developTip,
637
+ mainGains: Number.isFinite(mainGains) ? mainGains : 0,
638
+ tags: tagNames,
639
+ versions: Object.fromEntries(cutLines.map((c) => [c.line.id, c.nextVersion])),
640
+ lines: toFlowCutLines(tagNames, cutLines, allLines, repoLine),
641
+ fingerprints,
642
+ gate,
643
+ backmerge: null,
644
+ steps: await plannedCutSteps(primary, io, { cutLines, repoLine }),
645
+ diagnostics: [],
646
+ };
647
+ }
648
+ export async function runFlowCut(input, context) {
649
+ const { workspaceRoot, logger, outputFormat } = context;
650
+ const io = resolveIo(context.io);
651
+ await requireGit(io);
652
+ const repoRoot = await topLevel(workspaceRoot, io);
653
+ if (repoRoot === null) {
654
+ throw new Error("flow.cut must run inside a git repository");
655
+ }
656
+ const linesFlag = input.flags["lines"];
657
+ const lines = typeof linesFlag === "string" && linesFlag.length > 0
658
+ ? linesFlag.split(",").map((s) => s.trim())
659
+ : [];
660
+ const dryRun = context.dryRun || input.flags["dry-run"] === true;
661
+ // Fix mode: --branch names a registered fix branch, or the cwd worktree is
662
+ // itself a registered fix worktree.
663
+ const branchFlag = input.flags["branch"];
664
+ const candidate = typeof branchFlag === "string" && branchFlag.length > 0
665
+ ? branchFlag
666
+ : await currentBranch(repoRoot, io);
667
+ let data;
668
+ if (candidate !== null) {
669
+ const common = await commonGitDir(io, repoRoot);
670
+ let entry = null;
671
+ try {
672
+ entry =
673
+ (await readRegistry(io, common)).branches.find((b) => b.name === candidate) ?? null;
674
+ }
675
+ catch (error) {
676
+ if (error instanceof FlowRegistrySchemaError) {
677
+ data = refuse("FLOW-07", error.message, `repair or remove ${registryPath(common)}`);
678
+ return finishCutResult(data, outputFormat, logger);
679
+ }
680
+ throw error;
681
+ }
682
+ if (entry !== null && entry.kind === "fix") {
683
+ const { runFixCutWithBackmerge } = await import("./flow-fix.js");
684
+ data = await runFixCutWithBackmerge(repoRoot, io, {
685
+ entry,
686
+ linesGiven: lines.length > 0,
687
+ dryRun,
688
+ });
689
+ return finishCutResult(data, outputFormat, logger);
690
+ }
691
+ if (typeof branchFlag === "string" && entry?.kind !== "fix") {
692
+ data = refuse("FLOW-INT-06", `${candidate} is not a fix branch — --branch targets a registered fix worktree only`, "run flow.cut without --branch for an ordinary release, or open a fix with flow.fix");
693
+ return finishCutResult(data, outputFormat, logger);
694
+ }
695
+ }
696
+ data = await runOrdinaryCut(repoRoot, io, { lines, dryRun });
697
+ return finishCutResult(data, outputFormat, logger);
698
+ }
699
+ function finishCutResult(data, outputFormat, logger) {
700
+ const refused = data.diagnostics.find((d) => d.severity === "error");
701
+ if (outputFormat === "pretty") {
702
+ if (refused) {
703
+ logger.error(`flow.cut refused: ${refused.ruleId} ${refused.message}`);
704
+ }
705
+ else if (data.released) {
706
+ logger.section("flow.cut");
707
+ logger.info(` ${data.resumed ? "resumed release" : "released"}: ${data.tags.join(", ")}`);
708
+ logger.info(` main gained ${data.mainGains} commit(s) — now at ${data.mainAfter?.slice(0, 9)}`);
709
+ if (data.mainGains > 0 && !data.resumed) {
710
+ logger.info(" the first cut after flow.install includes the guard-adoption commit");
711
+ }
712
+ }
713
+ }
714
+ return {
715
+ data,
716
+ exitCode: refused ? 1 : 0,
717
+ summary: refused
718
+ ? `[flow.cut] refused: ${refused.ruleId} ${refused.message}`
719
+ : `[flow.cut] ${data.released ? `released ${data.tags.join(", ")}` : "dry-run"}`,
720
+ };
721
+ }
722
+ //# sourceMappingURL=flow-cut.js.map