@warpgogol/forge 9.3.1 → 9.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (509) hide show
  1. package/AGENTS.md +32 -0
  2. package/CHANGELOG.md +40 -0
  3. package/README.md +6 -4
  4. package/README.uk.md +10 -8
  5. package/bin/cli.ts +4 -4
  6. package/dist/bin/cli.js +4 -4
  7. package/dist/bin/cli.js.map +1 -1
  8. package/dist/os/adr/handlers/list-create.d.ts.map +1 -1
  9. package/dist/os/adr/handlers/list-create.js +23 -2
  10. package/dist/os/adr/handlers/list-create.js.map +1 -1
  11. package/dist/os/adr/types.d.ts +2 -0
  12. package/dist/os/adr/types.d.ts.map +1 -1
  13. package/dist/os/adr/types.js +2 -2
  14. package/dist/os/adr/types.js.map +1 -1
  15. package/dist/os/compass/handlers/compass-audit-handler.d.ts.map +1 -1
  16. package/dist/os/compass/handlers/compass-audit-handler.js +3 -1
  17. package/dist/os/compass/handlers/compass-audit-handler.js.map +1 -1
  18. package/dist/os/compass/handlers/compass-header-scaffold-handler.d.ts.map +1 -1
  19. package/dist/os/compass/handlers/compass-header-scaffold-handler.js +6 -12
  20. package/dist/os/compass/handlers/compass-header-scaffold-handler.js.map +1 -1
  21. package/dist/os/compass/handlers/git-revision.d.ts +2 -0
  22. package/dist/os/compass/handlers/git-revision.d.ts.map +1 -1
  23. package/dist/os/compass/handlers/git-revision.js +7 -2
  24. package/dist/os/compass/handlers/git-revision.js.map +1 -1
  25. package/dist/os/compass/handlers/summary-record.d.ts.map +1 -1
  26. package/dist/os/compass/handlers/summary-record.js +24 -14
  27. package/dist/os/compass/handlers/summary-record.js.map +1 -1
  28. package/dist/os/conformance/conformance.module.d.ts.map +1 -1
  29. package/dist/os/conformance/conformance.module.js +21 -4
  30. package/dist/os/conformance/conformance.module.js.map +1 -1
  31. package/dist/os/conformance/handlers/conformance-validate.d.ts.map +1 -1
  32. package/dist/os/conformance/handlers/conformance-validate.js +64 -8
  33. package/dist/os/conformance/handlers/conformance-validate.js.map +1 -1
  34. package/dist/os/core/archive-regen.d.ts +99 -0
  35. package/dist/os/core/archive-regen.d.ts.map +1 -0
  36. package/dist/os/core/archive-regen.js +220 -0
  37. package/dist/os/core/archive-regen.js.map +1 -0
  38. package/dist/os/core/core.module.d.ts.map +1 -1
  39. package/dist/os/core/core.module.js +159 -18
  40. package/dist/os/core/core.module.js.map +1 -1
  41. package/dist/os/core/handlers/assets-helpers.d.ts.map +1 -1
  42. package/dist/os/core/handlers/assets-helpers.js +8 -3
  43. package/dist/os/core/handlers/assets-helpers.js.map +1 -1
  44. package/dist/os/core/handlers/forge-autonomy-validate.d.ts.map +1 -1
  45. package/dist/os/core/handlers/forge-autonomy-validate.js +3 -1
  46. package/dist/os/core/handlers/forge-autonomy-validate.js.map +1 -1
  47. package/dist/os/core/handlers/package-health.d.ts +130 -0
  48. package/dist/os/core/handlers/package-health.d.ts.map +1 -1
  49. package/dist/os/core/handlers/package-health.js +548 -7
  50. package/dist/os/core/handlers/package-health.js.map +1 -1
  51. package/dist/os/core/handlers/release-prepare.d.ts.map +1 -1
  52. package/dist/os/core/handlers/release-prepare.js +5 -2
  53. package/dist/os/core/handlers/release-prepare.js.map +1 -1
  54. package/dist/os/flow/digest.d.ts.map +1 -1
  55. package/dist/os/flow/digest.js +3 -1
  56. package/dist/os/flow/digest.js.map +1 -1
  57. package/dist/os/flow/dirty-classify.d.ts +51 -0
  58. package/dist/os/flow/dirty-classify.d.ts.map +1 -0
  59. package/dist/os/flow/dirty-classify.js +83 -0
  60. package/dist/os/flow/dirty-classify.js.map +1 -0
  61. package/dist/os/flow/flow.module.d.ts.map +1 -1
  62. package/dist/os/flow/flow.module.js +110 -19
  63. package/dist/os/flow/flow.module.js.map +1 -1
  64. package/dist/os/flow/gate-engine.d.ts +13 -0
  65. package/dist/os/flow/gate-engine.d.ts.map +1 -0
  66. package/dist/os/flow/gate-engine.js +32 -0
  67. package/dist/os/flow/gate-engine.js.map +1 -0
  68. package/dist/os/flow/git.d.ts +45 -4
  69. package/dist/os/flow/git.d.ts.map +1 -1
  70. package/dist/os/flow/git.js +95 -27
  71. package/dist/os/flow/git.js.map +1 -1
  72. package/dist/os/flow/handlers/flow-backmerge.d.ts.map +1 -1
  73. package/dist/os/flow/handlers/flow-backmerge.js +12 -5
  74. package/dist/os/flow/handlers/flow-backmerge.js.map +1 -1
  75. package/dist/os/flow/handlers/flow-check.d.ts.map +1 -1
  76. package/dist/os/flow/handlers/flow-check.js +25 -3
  77. package/dist/os/flow/handlers/flow-check.js.map +1 -1
  78. package/dist/os/flow/handlers/flow-cut.d.ts +4 -1
  79. package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -1
  80. package/dist/os/flow/handlers/flow-cut.js +75 -38
  81. package/dist/os/flow/handlers/flow-cut.js.map +1 -1
  82. package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -1
  83. package/dist/os/flow/handlers/flow-discard.js +33 -5
  84. package/dist/os/flow/handlers/flow-discard.js.map +1 -1
  85. package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -1
  86. package/dist/os/flow/handlers/flow-fix.js +13 -10
  87. package/dist/os/flow/handlers/flow-fix.js.map +1 -1
  88. package/dist/os/flow/handlers/flow-hold.d.ts.map +1 -1
  89. package/dist/os/flow/handlers/flow-hold.js +13 -7
  90. package/dist/os/flow/handlers/flow-hold.js.map +1 -1
  91. package/dist/os/flow/handlers/flow-install.d.ts +2 -1
  92. package/dist/os/flow/handlers/flow-install.d.ts.map +1 -1
  93. package/dist/os/flow/handlers/flow-install.js +56 -13
  94. package/dist/os/flow/handlers/flow-install.js.map +1 -1
  95. package/dist/os/flow/handlers/flow-integrate.d.ts +54 -2
  96. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
  97. package/dist/os/flow/handlers/flow-integrate.js +614 -65
  98. package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
  99. package/dist/os/flow/handlers/flow-open.d.ts +14 -0
  100. package/dist/os/flow/handlers/flow-open.d.ts.map +1 -1
  101. package/dist/os/flow/handlers/flow-open.js +117 -12
  102. package/dist/os/flow/handlers/flow-open.js.map +1 -1
  103. package/dist/os/flow/handlers/flow-peers.d.ts +24 -0
  104. package/dist/os/flow/handlers/flow-peers.d.ts.map +1 -0
  105. package/dist/os/flow/handlers/flow-peers.js +99 -0
  106. package/dist/os/flow/handlers/flow-peers.js.map +1 -0
  107. package/dist/os/flow/handlers/flow-status.d.ts +13 -0
  108. package/dist/os/flow/handlers/flow-status.d.ts.map +1 -1
  109. package/dist/os/flow/handlers/flow-status.js +35 -14
  110. package/dist/os/flow/handlers/flow-status.js.map +1 -1
  111. package/dist/os/flow/index.d.ts +3 -0
  112. package/dist/os/flow/index.d.ts.map +1 -1
  113. package/dist/os/flow/index.js +7 -2
  114. package/dist/os/flow/index.js.map +1 -1
  115. package/dist/os/flow/line-version.d.ts.map +1 -1
  116. package/dist/os/flow/line-version.js +2 -1
  117. package/dist/os/flow/line-version.js.map +1 -1
  118. package/dist/os/flow/locks.d.ts +37 -1
  119. package/dist/os/flow/locks.d.ts.map +1 -1
  120. package/dist/os/flow/locks.js +34 -14
  121. package/dist/os/flow/locks.js.map +1 -1
  122. package/dist/os/flow/ops-registry.d.ts +33 -0
  123. package/dist/os/flow/ops-registry.d.ts.map +1 -0
  124. package/dist/os/flow/ops-registry.js +177 -0
  125. package/dist/os/flow/ops-registry.js.map +1 -0
  126. package/dist/os/flow/preflight.d.ts +157 -0
  127. package/dist/os/flow/preflight.d.ts.map +1 -0
  128. package/dist/os/flow/preflight.js +772 -0
  129. package/dist/os/flow/preflight.js.map +1 -0
  130. package/dist/os/flow/publish.d.ts +7 -0
  131. package/dist/os/flow/publish.d.ts.map +1 -1
  132. package/dist/os/flow/publish.js +165 -3
  133. package/dist/os/flow/publish.js.map +1 -1
  134. package/dist/os/flow/registry.d.ts +26 -1
  135. package/dist/os/flow/registry.d.ts.map +1 -1
  136. package/dist/os/flow/registry.js +27 -6
  137. package/dist/os/flow/registry.js.map +1 -1
  138. package/dist/os/flow/scripts.d.ts +4 -0
  139. package/dist/os/flow/scripts.d.ts.map +1 -1
  140. package/dist/os/flow/scripts.js +8 -2
  141. package/dist/os/flow/scripts.js.map +1 -1
  142. package/dist/os/flow/session-checkout.d.ts +33 -0
  143. package/dist/os/flow/session-checkout.d.ts.map +1 -0
  144. package/dist/os/flow/session-checkout.js +151 -0
  145. package/dist/os/flow/session-checkout.js.map +1 -0
  146. package/dist/os/flow/standalone-invoke.d.ts +11 -0
  147. package/dist/os/flow/standalone-invoke.d.ts.map +1 -0
  148. package/dist/os/flow/standalone-invoke.js +75 -0
  149. package/dist/os/flow/standalone-invoke.js.map +1 -0
  150. package/dist/os/flow/worktree-path.d.ts.map +1 -1
  151. package/dist/os/flow/worktree-path.js +9 -3
  152. package/dist/os/flow/worktree-path.js.map +1 -1
  153. package/dist/os/instructions/handlers/budget-validate.d.ts +1 -0
  154. package/dist/os/instructions/handlers/budget-validate.d.ts.map +1 -1
  155. package/dist/os/instructions/handlers/budget-validate.js +12 -4
  156. package/dist/os/instructions/handlers/budget-validate.js.map +1 -1
  157. package/dist/os/instructions/instructions.module.d.ts.map +1 -1
  158. package/dist/os/instructions/instructions.module.js +4 -1
  159. package/dist/os/instructions/instructions.module.js.map +1 -1
  160. package/dist/os/mission/handlers/archive.d.ts.map +1 -1
  161. package/dist/os/mission/handlers/archive.js +12 -8
  162. package/dist/os/mission/handlers/archive.js.map +1 -1
  163. package/dist/os/mission/importer-block.d.ts +19 -0
  164. package/dist/os/mission/importer-block.d.ts.map +1 -0
  165. package/dist/os/mission/importer-block.js +124 -0
  166. package/dist/os/mission/importer-block.js.map +1 -0
  167. package/dist/os/mission/lockfile.d.ts +17 -0
  168. package/dist/os/mission/lockfile.d.ts.map +1 -1
  169. package/dist/os/mission/lockfile.js +38 -0
  170. package/dist/os/mission/lockfile.js.map +1 -1
  171. package/dist/os/mission/open-missions.d.ts +8 -0
  172. package/dist/os/mission/open-missions.d.ts.map +1 -0
  173. package/dist/os/mission/open-missions.js +42 -0
  174. package/dist/os/mission/open-missions.js.map +1 -0
  175. package/dist/os/queue/manifest.d.ts.map +1 -1
  176. package/dist/os/queue/manifest.js +11 -1
  177. package/dist/os/queue/manifest.js.map +1 -1
  178. package/dist/os/rfc/acceptance.d.ts +14 -0
  179. package/dist/os/rfc/acceptance.d.ts.map +1 -1
  180. package/dist/os/rfc/acceptance.js +18 -10
  181. package/dist/os/rfc/acceptance.js.map +1 -1
  182. package/dist/os/rfc/decision-log.d.ts.map +1 -1
  183. package/dist/os/rfc/decision-log.js +11 -2
  184. package/dist/os/rfc/decision-log.js.map +1 -1
  185. package/dist/os/rfc/frontmatter-io.d.ts +23 -0
  186. package/dist/os/rfc/frontmatter-io.d.ts.map +1 -1
  187. package/dist/os/rfc/frontmatter-io.js +82 -1
  188. package/dist/os/rfc/frontmatter-io.js.map +1 -1
  189. package/dist/os/rfc/handlers/implement-stamp-deviations.d.ts.map +1 -1
  190. package/dist/os/rfc/handlers/implement-stamp-deviations.js +24 -2
  191. package/dist/os/rfc/handlers/implement-stamp-deviations.js.map +1 -1
  192. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  193. package/dist/os/rfc/handlers/implement-stamp.js +16 -3
  194. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  195. package/dist/os/rfc/handlers/index-graph.d.ts.map +1 -1
  196. package/dist/os/rfc/handlers/index-graph.js +5 -4
  197. package/dist/os/rfc/handlers/index-graph.js.map +1 -1
  198. package/dist/os/rfc/handlers/list-create.d.ts.map +1 -1
  199. package/dist/os/rfc/handlers/list-create.js +107 -10
  200. package/dist/os/rfc/handlers/list-create.js.map +1 -1
  201. package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts +48 -0
  202. package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts.map +1 -1
  203. package/dist/os/rfc/handlers/rfc-evidence-sync.js +131 -2
  204. package/dist/os/rfc/handlers/rfc-evidence-sync.js.map +1 -1
  205. package/dist/os/rfc/handlers/validate-rules.d.ts +21 -1
  206. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  207. package/dist/os/rfc/handlers/validate-rules.js +77 -5
  208. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  209. package/dist/os/rfc/handlers/validate.d.ts.map +1 -1
  210. package/dist/os/rfc/handlers/validate.js +64 -6
  211. package/dist/os/rfc/handlers/validate.js.map +1 -1
  212. package/dist/os/rfc/next-id.d.ts +38 -0
  213. package/dist/os/rfc/next-id.d.ts.map +1 -0
  214. package/dist/os/rfc/next-id.js +165 -0
  215. package/dist/os/rfc/next-id.js.map +1 -0
  216. package/dist/os/rfc/probe-batch.d.ts.map +1 -1
  217. package/dist/os/rfc/probe-batch.js +6 -1
  218. package/dist/os/rfc/probe-batch.js.map +1 -1
  219. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  220. package/dist/os/rfc/rfc.module.js +36 -8
  221. package/dist/os/rfc/rfc.module.js.map +1 -1
  222. package/dist/os/rfc/types.d.ts +42 -6
  223. package/dist/os/rfc/types.d.ts.map +1 -1
  224. package/dist/os/rfc/types.js +6 -6
  225. package/dist/os/rfc/types.js.map +1 -1
  226. package/dist/os/rfc/verification-evidence.d.ts +1 -1
  227. package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
  228. package/dist/os/rfc/verification-evidence.js +81 -28
  229. package/dist/os/rfc/verification-evidence.js.map +1 -1
  230. package/dist/os/rfc/verification-origin.d.ts +8 -0
  231. package/dist/os/rfc/verification-origin.d.ts.map +1 -1
  232. package/dist/os/rfc/verification-origin.js +47 -0
  233. package/dist/os/rfc/verification-origin.js.map +1 -1
  234. package/dist/os/session/handlers/save.d.ts.map +1 -1
  235. package/dist/os/session/handlers/save.js +31 -7
  236. package/dist/os/session/handlers/save.js.map +1 -1
  237. package/dist/os/spec/spec-schema.d.ts +8 -0
  238. package/dist/os/spec/spec-schema.d.ts.map +1 -1
  239. package/dist/os/spec/spec-schema.js +1 -0
  240. package/dist/os/spec/spec-schema.js.map +1 -1
  241. package/dist/os/spec/spec-status.d.ts +8 -0
  242. package/dist/os/spec/spec-status.d.ts.map +1 -1
  243. package/dist/os/spec/spec-status.js +18 -6
  244. package/dist/os/spec/spec-status.js.map +1 -1
  245. package/dist/os/spec/spec-validate.d.ts.map +1 -1
  246. package/dist/os/spec/spec-validate.js +62 -15
  247. package/dist/os/spec/spec-validate.js.map +1 -1
  248. package/dist/os/spec/spec.module.d.ts.map +1 -1
  249. package/dist/os/spec/spec.module.js +13 -5
  250. package/dist/os/spec/spec.module.js.map +1 -1
  251. package/dist/os/system/handlers/system-map-validate.d.ts.map +1 -1
  252. package/dist/os/system/handlers/system-map-validate.js +2 -1
  253. package/dist/os/system/handlers/system-map-validate.js.map +1 -1
  254. package/dist/os/system/handlers/system-outbox-scan.d.ts +11 -0
  255. package/dist/os/system/handlers/system-outbox-scan.d.ts.map +1 -1
  256. package/dist/os/system/handlers/system-outbox-scan.js +54 -6
  257. package/dist/os/system/handlers/system-outbox-scan.js.map +1 -1
  258. package/dist/os/system/handlers/system-task-collect.d.ts.map +1 -1
  259. package/dist/os/system/handlers/system-task-collect.js +11 -5
  260. package/dist/os/system/handlers/system-task-collect.js.map +1 -1
  261. package/dist/os/system/handlers/system-task-create.d.ts.map +1 -1
  262. package/dist/os/system/handlers/system-task-create.js +6 -1
  263. package/dist/os/system/handlers/system-task-create.js.map +1 -1
  264. package/dist/os/system/handlers/system-versionset-record.d.ts +14 -0
  265. package/dist/os/system/handlers/system-versionset-record.d.ts.map +1 -1
  266. package/dist/os/system/handlers/system-versionset-record.js +246 -6
  267. package/dist/os/system/handlers/system-versionset-record.js.map +1 -1
  268. package/dist/os/system/repo.d.ts +1 -1
  269. package/dist/os/system/repo.d.ts.map +1 -1
  270. package/dist/os/system/repo.js +53 -3
  271. package/dist/os/system/repo.js.map +1 -1
  272. package/dist/os/system/scenario-schemas.d.ts +109 -3
  273. package/dist/os/system/scenario-schemas.d.ts.map +1 -1
  274. package/dist/os/system/scenario-schemas.js +66 -10
  275. package/dist/os/system/scenario-schemas.js.map +1 -1
  276. package/dist/os/system/system.module.d.ts.map +1 -1
  277. package/dist/os/system/system.module.js +69 -17
  278. package/dist/os/system/system.module.js.map +1 -1
  279. package/dist/os/system/tests/contract-fixtures.d.ts +17 -0
  280. package/dist/os/system/tests/contract-fixtures.d.ts.map +1 -0
  281. package/dist/os/system/tests/contract-fixtures.js +109 -0
  282. package/dist/os/system/tests/contract-fixtures.js.map +1 -0
  283. package/dist/src/config/forge-config.d.ts +54 -18
  284. package/dist/src/config/forge-config.d.ts.map +1 -1
  285. package/dist/src/config/forge-config.js +41 -9
  286. package/dist/src/config/forge-config.js.map +1 -1
  287. package/dist/src/conformance/index.d.ts +6 -0
  288. package/dist/src/conformance/index.d.ts.map +1 -1
  289. package/dist/src/conformance/index.js +36 -1
  290. package/dist/src/conformance/index.js.map +1 -1
  291. package/dist/src/formal/proof-runner.d.ts.map +1 -1
  292. package/dist/src/formal/proof-runner.js +10 -2
  293. package/dist/src/formal/proof-runner.js.map +1 -1
  294. package/dist/src/migration-adapters/node-typescript-pnpm/index.js +3 -1
  295. package/dist/src/migration-adapters/node-typescript-pnpm/index.js.map +1 -1
  296. package/dist/src/migration-adapters/phaser-pnpm/index.js +3 -1
  297. package/dist/src/migration-adapters/phaser-pnpm/index.js.map +1 -1
  298. package/dist/src/onboarding/agents-generate.js +4 -4
  299. package/dist/src/onboarding/agents-generate.js.map +1 -1
  300. package/dist/src/onboarding/nested-agents-generate.d.ts.map +1 -1
  301. package/dist/src/onboarding/nested-agents-generate.js +3 -1
  302. package/dist/src/onboarding/nested-agents-generate.js.map +1 -1
  303. package/dist/src/onboarding/prettierignore.d.ts.map +1 -1
  304. package/dist/src/onboarding/prettierignore.js +2 -0
  305. package/dist/src/onboarding/prettierignore.js.map +1 -1
  306. package/dist/src/onboarding/scaffold-project.js +2 -2
  307. package/dist/src/onboarding/scaffold-project.js.map +1 -1
  308. package/dist/src/onboarding/upgrade.d.ts.map +1 -1
  309. package/dist/src/onboarding/upgrade.js +14 -2
  310. package/dist/src/onboarding/upgrade.js.map +1 -1
  311. package/dist/src/onboarding/workspace-discovery.d.ts.map +1 -1
  312. package/dist/src/onboarding/workspace-discovery.js +3 -1
  313. package/dist/src/onboarding/workspace-discovery.js.map +1 -1
  314. package/dist/src/skill-schema.d.ts +3 -0
  315. package/dist/src/skill-schema.d.ts.map +1 -1
  316. package/dist/src/skill-schema.js +9 -2
  317. package/dist/src/skill-schema.js.map +1 -1
  318. package/dist/src/spec/resolve-spec-source.d.ts +45 -0
  319. package/dist/src/spec/resolve-spec-source.d.ts.map +1 -0
  320. package/dist/src/spec/resolve-spec-source.js +153 -0
  321. package/dist/src/spec/resolve-spec-source.js.map +1 -0
  322. package/dist/src/utils/command-inventory.d.ts +28 -0
  323. package/dist/src/utils/command-inventory.d.ts.map +1 -0
  324. package/dist/src/utils/command-inventory.js +84 -0
  325. package/dist/src/utils/command-inventory.js.map +1 -0
  326. package/dist/src/utils/io.d.ts.map +1 -1
  327. package/dist/src/utils/io.js +6 -1
  328. package/dist/src/utils/io.js.map +1 -1
  329. package/dist/src/utils/repo-path.d.ts +10 -0
  330. package/dist/src/utils/repo-path.d.ts.map +1 -0
  331. package/dist/src/utils/repo-path.js +52 -0
  332. package/dist/src/utils/repo-path.js.map +1 -0
  333. package/dist/src/utils/spawn.d.ts +23 -0
  334. package/dist/src/utils/spawn.d.ts.map +1 -0
  335. package/dist/src/utils/spawn.js +83 -0
  336. package/dist/src/utils/spawn.js.map +1 -0
  337. package/docs/branch-model.md +1 -1
  338. package/docs/guides/existing-project.md +1 -1
  339. package/docs/maintainers/publishing.md +1 -1
  340. package/docs/reference/cli.md +8 -2
  341. package/docs/reference/profiles.md +1 -1
  342. package/os/adr/handlers/list-create.ts +26 -2
  343. package/os/adr/types.ts +4 -2
  344. package/os/compass/handlers/compass-audit-handler.ts +6 -1
  345. package/os/compass/handlers/compass-header-scaffold-handler.ts +12 -11
  346. package/os/compass/handlers/git-revision.ts +8 -2
  347. package/os/compass/handlers/summary-record.ts +25 -14
  348. package/os/compass/handlers/tests/compass-invariant-binding.test.ts +3 -2
  349. package/os/conformance/conformance.module.ts +21 -4
  350. package/os/conformance/handlers/conformance-validate.ts +108 -16
  351. package/os/conformance/handlers/tests/conformance-package-consumer.test.ts +200 -0
  352. package/os/core/archive-regen.ts +279 -0
  353. package/os/core/core.module.ts +176 -29
  354. package/os/core/docs-archive.test.ts +413 -3
  355. package/os/core/handlers/assets-helpers.ts +8 -3
  356. package/os/core/handlers/forge-autonomy-validate.ts +3 -1
  357. package/os/core/handlers/package-health.test.ts +418 -4
  358. package/os/core/handlers/package-health.ts +629 -7
  359. package/os/core/handlers/release-prepare.ts +5 -2
  360. package/os/flow/digest.ts +3 -1
  361. package/os/flow/dirty-classify.ts +120 -0
  362. package/os/flow/flow.module.ts +119 -24
  363. package/os/flow/gate-engine.ts +45 -0
  364. package/os/flow/git.ts +117 -29
  365. package/os/flow/handlers/flow-backmerge.ts +14 -4
  366. package/os/flow/handlers/flow-check.ts +27 -2
  367. package/os/flow/handlers/flow-cut.ts +124 -56
  368. package/os/flow/handlers/flow-discard.ts +33 -5
  369. package/os/flow/handlers/flow-fix.ts +22 -10
  370. package/os/flow/handlers/flow-hold.ts +20 -7
  371. package/os/flow/handlers/flow-install.ts +59 -12
  372. package/os/flow/handlers/flow-integrate.ts +933 -180
  373. package/os/flow/handlers/flow-open.ts +135 -11
  374. package/os/flow/handlers/flow-peers.ts +142 -0
  375. package/os/flow/handlers/flow-status.ts +45 -13
  376. package/os/flow/index.ts +8 -2
  377. package/os/flow/line-version.ts +2 -1
  378. package/os/flow/locks.ts +56 -14
  379. package/os/flow/ops-registry.ts +194 -0
  380. package/os/flow/preflight.ts +974 -0
  381. package/os/flow/publish.ts +200 -5
  382. package/os/flow/registry.ts +43 -7
  383. package/os/flow/scripts.ts +13 -2
  384. package/os/flow/session-checkout.ts +186 -0
  385. package/os/flow/standalone-invoke.ts +85 -0
  386. package/os/flow/tests/dirty-classify.test.ts +251 -0
  387. package/os/flow/tests/fixtures/branch-names.yaml +40 -40
  388. package/os/flow/tests/flow-cut.test.ts +21 -0
  389. package/os/flow/tests/flow-discard.test.ts +32 -0
  390. package/os/flow/tests/flow-guard-parity.test.ts +10 -2
  391. package/os/flow/tests/flow-install.test.ts +7 -3
  392. package/os/flow/tests/flow-integrate.gate-report.test.ts +144 -0
  393. package/os/flow/tests/flow-integrate.preflight.test.ts +565 -0
  394. package/os/flow/tests/flow-integrate.reattach.test.ts +197 -0
  395. package/os/flow/tests/flow-integrate.remediation.test.ts +254 -0
  396. package/os/flow/tests/flow-integrate.test.ts +698 -17
  397. package/os/flow/tests/flow-open.pending.test.ts +277 -0
  398. package/os/flow/tests/flow-open.test.ts +52 -9
  399. package/os/flow/tests/flow-push-publish.test.ts +124 -0
  400. package/os/flow/tests/flow-status.test.ts +31 -1
  401. package/os/flow/tests/locks.test.ts +39 -3
  402. package/os/flow/tests/ops-registry.test.ts +136 -0
  403. package/os/flow/tests/scripts.test.ts +5 -2
  404. package/os/flow/tests/state-roots.test.ts +8 -5
  405. package/os/flow/worktree-path.ts +9 -3
  406. package/os/formal/handlers/proof-check.test.ts +6 -3
  407. package/os/instructions/budget.test.ts +31 -0
  408. package/os/instructions/handlers/budget-validate.ts +13 -4
  409. package/os/instructions/instructions.module.ts +4 -1
  410. package/os/mission/handlers/archive.ts +22 -14
  411. package/os/mission/importer-block.ts +119 -0
  412. package/os/mission/lockfile.ts +41 -0
  413. package/os/mission/open-missions.ts +50 -0
  414. package/os/queue/decision-ledger.test.ts +18 -0
  415. package/os/queue/manifest.ts +17 -1
  416. package/os/rfc/acceptance.ts +30 -10
  417. package/os/rfc/decision-log.ts +13 -2
  418. package/os/rfc/frontmatter-io.ts +89 -1
  419. package/os/rfc/handlers/implement-stamp-deviations.test.ts +83 -0
  420. package/os/rfc/handlers/implement-stamp-deviations.ts +22 -2
  421. package/os/rfc/handlers/implement-stamp-stale.test.ts +5 -1
  422. package/os/rfc/handlers/implement-stamp.ts +16 -3
  423. package/os/rfc/handlers/index-graph.ts +5 -4
  424. package/os/rfc/handlers/lifecycle.test.ts +136 -0
  425. package/os/rfc/handlers/list-create.test.ts +126 -0
  426. package/os/rfc/handlers/list-create.ts +130 -10
  427. package/os/rfc/handlers/rfc-evidence-sync.test.ts +504 -0
  428. package/os/rfc/handlers/rfc-evidence-sync.ts +192 -2
  429. package/os/rfc/handlers/tests/index-graph.test.ts +2 -1
  430. package/os/rfc/handlers/validate-rules-rfc1454.test.ts +73 -0
  431. package/os/rfc/handlers/validate-rules.ts +103 -7
  432. package/os/rfc/handlers/validate.ts +68 -4
  433. package/os/rfc/next-id.ts +232 -0
  434. package/os/rfc/probe-batch.ts +6 -1
  435. package/os/rfc/rfc.module.ts +41 -8
  436. package/os/rfc/types.ts +31 -6
  437. package/os/rfc/verification-emit-freshness.test.ts +5 -1
  438. package/os/rfc/verification-emit.test.ts +5 -1
  439. package/os/rfc/verification-evidence.ts +99 -33
  440. package/os/rfc/verification-origin.ts +59 -0
  441. package/os/rfc/verification-refresh.test.ts +5 -1
  442. package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +5 -1
  443. package/os/session/handlers/save.ts +35 -7
  444. package/os/session/tests/session-save.test.ts +154 -0
  445. package/os/spec/spec-schema.ts +3 -0
  446. package/os/spec/spec-status.ts +22 -6
  447. package/os/spec/spec-validate.package-source.test.ts +187 -0
  448. package/os/spec/spec-validate.ts +65 -14
  449. package/os/spec/spec.module.ts +13 -5
  450. package/os/system/handlers/system-map-validate.ts +4 -2
  451. package/os/system/handlers/system-outbox-scan.ts +65 -21
  452. package/os/system/handlers/system-task-collect.ts +11 -5
  453. package/os/system/handlers/system-task-create.ts +6 -1
  454. package/os/system/handlers/system-versionset-record.ts +301 -16
  455. package/os/system/repo.ts +59 -18
  456. package/os/system/scenario-schemas.ts +91 -12
  457. package/os/system/system.module.ts +70 -17
  458. package/os/system/tests/contract-fixtures.ts +139 -0
  459. package/os/system/tests/scenario-pin-drift-check.test.ts +114 -0
  460. package/os/system/tests/scenario-validator-check.test.ts +96 -0
  461. package/os/system/tests/system-task-collect.test.ts +16 -0
  462. package/os/system/tests/system-task-dispatch.test.ts +4 -1
  463. package/os/system/tests/system-versionset.test.ts +7 -3
  464. package/os/system/tests/version-set-v2.test.ts +78 -0
  465. package/package.json +9 -1
  466. package/skills/fo/fo-doctor/SKILL.md +151 -0
  467. package/skills/fo/fo-handoff/SKILL.md +22 -0
  468. package/skills/fo/fo-idea-create-rfc/acceptance-criteria-standard.md +2 -1
  469. package/skills/fo/fo-idea-implement/SKILL.md +5 -2
  470. package/skills/fo/fo-idea-plan/SKILL.md +5 -5
  471. package/skills/fo/fo-session-retro/SKILL.md +45 -13
  472. package/skills/fo/fo-spec-ingest/SKILL.md +8 -0
  473. package/skills/fo/fo-system-dispatch/SKILL.md +1 -0
  474. package/skills/meta/skill-create/SKILL.md +2 -1
  475. package/src/bin-entry.test.ts +3 -1
  476. package/src/config/forge-config.ts +57 -13
  477. package/src/conformance/index.ts +46 -1
  478. package/src/formal/proof-runner.ts +10 -2
  479. package/src/migration-adapters/node-typescript-pnpm/index.ts +3 -1
  480. package/src/migration-adapters/phaser-pnpm/index.ts +3 -1
  481. package/src/onboarding/agents-generate.ts +4 -4
  482. package/src/onboarding/nested-agents-generate.ts +3 -1
  483. package/src/onboarding/prettierignore.ts +2 -0
  484. package/src/onboarding/scaffold-project.ts +2 -2
  485. package/src/onboarding/upgrade.ts +13 -2
  486. package/src/onboarding/workspace-discovery.ts +3 -1
  487. package/src/pipeline-status.test.ts +1 -1
  488. package/src/skill-schema.ts +9 -2
  489. package/src/spec/resolve-spec-source.ts +184 -0
  490. package/src/tests/acceptance-probe-kinds.test.ts +3 -1
  491. package/src/tests/agents-generate-domain.test.ts +3 -2
  492. package/src/tests/agents-generate.test.ts +2 -1
  493. package/src/tests/create-flow.test.ts +3 -1
  494. package/src/tests/create.test.ts +12 -2
  495. package/src/tests/editable-generated-region.test.ts +2 -2
  496. package/src/tests/fixtures/agents-generate-business-before.txt +2 -0
  497. package/src/tests/implement-stamp.test.ts +5 -2
  498. package/src/tests/prettierignore-manage.test.ts +11 -0
  499. package/src/tests/rfc-implement-stamp-governance.test.ts +6 -2
  500. package/src/tests/rfc-verification-verdict-ingest.test.ts +5 -1
  501. package/src/tests/scaffold-project.test.ts +3 -1
  502. package/src/tests/upgrade.test.ts +79 -3
  503. package/src/tests/workspace-discovery.test.ts +4 -3
  504. package/src/utils/command-inventory.ts +105 -0
  505. package/src/utils/io.ts +6 -1
  506. package/src/utils/repo-path.ts +49 -0
  507. package/src/utils/spawn.ts +88 -0
  508. package/src/tests/rfc-evidence-sync.test.ts +0 -369
  509. package/src/tests/skill-agents-sync.test.ts +0 -192
@@ -20,12 +20,12 @@ released with no mutation.</purpose>
20
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
21
  </KEY_DECISIONS>
22
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
23
  <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>
24
+ <item>RFC-1515: harden forge flow worktree lifecycle against vanished paths, forge-local state, dead-holder locks and generated drift</item>
25
+ <item>RFC-1515: close rfc-1515 review findings — delete tolerated paths before worktree remove, prune vanished registrations, verified branch -D, shared held-lock render, gated e2e throw, journal toleratedState, edge tests</item>
26
+ <item>RFC-1528: close review findings — manifest-union command inventory for regen/preflight</item>
27
+ <item>RFC-1546: derive-and-repair recoverable state across flow surfaces (AC-1..AC-5)</item>
28
+ <history>RFC-1490, RFC-1491, RFC-1494, RFC-1502</history>
29
29
  </CHANGE_SUMMARY>
30
30
  */
31
31
 
@@ -34,9 +34,11 @@ import { join } from "node:path";
34
34
  import { parse as yamlParse } from "yaml";
35
35
 
36
36
  import type {
37
+ CommandRegistry,
37
38
  Diagnostic,
38
39
  ForgeCommandInput,
39
40
  ForgeCommandResult,
41
+ ForgeInvokeCommand,
40
42
  ForgeRuntimeContext,
41
43
  WorkspaceIO,
42
44
  } from "../../../src/types.ts";
@@ -53,7 +55,7 @@ import {
53
55
  topLevel,
54
56
  worktreeList,
55
57
  } from "../git.ts";
56
- import { LockTimeoutError, withFlowLock } from "../locks.ts";
58
+ import { describeHeldLock, LockTimeoutError, withFlowLock } from "../locks.ts";
57
59
  import { isFlowAdopted } from "../index.ts";
58
60
  import {
59
61
  appendJournal,
@@ -66,11 +68,7 @@ import {
66
68
  import { bumpVersion, formatVersion, type ReleaseLevel } from "../semver.ts";
67
69
  import { discoverReleaseLines, type ReleaseLine } from "../release-lines.ts";
68
70
  import { pendingLevel } from "../release-level.ts";
69
- import {
70
- listLineTags,
71
- releaseTagAnnotation,
72
- writeReleaseTag,
73
- } from "../release-tags.ts";
71
+ import { listLineTags, releaseTagAnnotation, writeReleaseTag } from "../release-tags.ts";
74
72
  import { runFlowScript, type FlowScriptResult } from "../scripts.ts";
75
73
  import { VersionWriteError, writeLineVersion, writeSyncedForgeVersion } from "../version-files.ts";
76
74
  import { verifyLineAtRef } from "../publish.ts";
@@ -131,6 +129,7 @@ function refuse(
131
129
  message: string,
132
130
  fixHint: string,
133
131
  partial?: Partial<FlowCutData>,
132
+ diagData?: Record<string, unknown>,
134
133
  ): FlowCutData {
135
134
  return {
136
135
  mode: partial?.mode ?? "ordinary",
@@ -148,7 +147,7 @@ function refuse(
148
147
  gate: null,
149
148
  backmerge: null,
150
149
  steps: [],
151
- diagnostics: [{ ruleId, severity: "error", message, fixHint }],
150
+ diagnostics: [{ ruleId, severity: "error", message, fixHint, data: diagData }],
152
151
  };
153
152
  }
154
153
 
@@ -263,9 +262,7 @@ async function planOrdinaryCut(
263
262
  }
264
263
 
265
264
  const ref = (await git(repoRoot, io, ["rev-parse", "develop"])).stdout.trim();
266
- const mainTip = mainExists
267
- ? (await git(repoRoot, io, ["rev-parse", "main"])).stdout.trim()
268
- : "";
265
+ const mainTip = mainExists ? (await git(repoRoot, io, ["rev-parse", "main"])).stdout.trim() : "";
269
266
 
270
267
  // Resume detection runs before the pending-level loop: a develop tip
271
268
  // carrying `chore(release):` is this cut's own persisted declaration. All
@@ -273,9 +270,7 @@ async function planOrdinaryCut(
273
270
  // (rerun reports, no mutation); any missing or a rewound main → the plan
274
271
  // still runs but the tail completes exactly the subject's tags (and tags
275
272
  // the subject names cannot block as FLOW-CUT-06).
276
- const tipSubject = (
277
- await git(repoRoot, io, ["log", "-1", "--format=%s", ref])
278
- ).stdout.trim();
273
+ const tipSubject = (await git(repoRoot, io, ["log", "-1", "--format=%s", ref])).stdout.trim();
279
274
  let resumeTags: string[] | null = null;
280
275
  if (tipSubject.startsWith("chore(release): ")) {
281
276
  const named = tipSubject
@@ -283,17 +278,34 @@ async function planOrdinaryCut(
283
278
  .split(",")
284
279
  .map((t) => t.trim())
285
280
  .filter((t) => t.length > 0);
286
- const existence = await Promise.all(
287
- named.map(
288
- async (t) =>
289
- (await git(repoRoot, io, ["rev-parse", "--verify", "-q", `refs/tags/${t}`])).exitCode ===
290
- 0,
281
+ // RFC-1546: the subject only keys a resume when its tags encode the same
282
+ // line set this invocation requested — a mismatched --lines cut proceeds
283
+ // fresh instead of "resuming" somebody else's release declaration.
284
+ const byPrefixDesc = [...lines].sort((a, b) => b.tagPrefix.length - a.tagPrefix.length);
285
+ const subjectLineIds = [
286
+ ...new Set(
287
+ named
288
+ .map((t) => byPrefixDesc.find((l) => t.startsWith(l.tagPrefix))?.id)
289
+ .filter((id): id is string => id !== undefined),
291
290
  ),
292
- );
293
- if (named.length > 0 && existence.every((e) => e) && mainTip === ref) {
294
- return { kind: "completed", ref, tags: named, allLines: lines, mainTip };
291
+ ].sort();
292
+ const requestedIds = selected.map((l) => l.id).sort();
293
+ const linesMatch =
294
+ subjectLineIds.length === requestedIds.length &&
295
+ subjectLineIds.every((id, i) => id === requestedIds[i]);
296
+ if (linesMatch) {
297
+ const existence = await Promise.all(
298
+ named.map(
299
+ async (t) =>
300
+ (await git(repoRoot, io, ["rev-parse", "--verify", "-q", `refs/tags/${t}`])).exitCode ===
301
+ 0,
302
+ ),
303
+ );
304
+ if (named.length > 0 && existence.every((e) => e) && mainTip === ref) {
305
+ return { kind: "completed", ref, tags: named, allLines: lines, mainTip };
306
+ }
307
+ if (named.length > 0) resumeTags = named;
295
308
  }
296
- if (named.length > 0) resumeTags = named;
297
309
  }
298
310
 
299
311
  const cutLines: CutLine[] = [];
@@ -374,7 +386,7 @@ async function planOrdinaryCut(
374
386
  }
375
387
 
376
388
  const primaryBranch = await currentBranch(primary, io);
377
- const primaryDirty = await statusTracked(primary, io);
389
+ const primaryDirty = (await statusTracked(primary, io)).entries;
378
390
  const worktrees = await worktreeList(repoRoot, io);
379
391
  const mainCheckedOut = worktrees.some((w) => w.branch === "main");
380
392
  if (primaryBranch !== "develop" || primaryDirty.length > 0 || mainCheckedOut) {
@@ -524,6 +536,9 @@ export async function runOrdinaryCut(
524
536
  dryRun: boolean;
525
537
  now?: Date;
526
538
  onProgress?: (m: string) => void;
539
+ /** RFC-1528: forwarded to flow.integrate's bounded preflight. */
540
+ invoke?: ForgeInvokeCommand;
541
+ commandRegistry?: CommandRegistry;
527
542
  },
528
543
  ): Promise<FlowCutData> {
529
544
  const now = opts.now ?? new Date();
@@ -626,7 +641,10 @@ export async function runOrdinaryCut(
626
641
  ) as { name?: string };
627
642
  if (pkg.name === "@warpgogol/forge") {
628
643
  const forgeYaml = join(wt, "forge.yaml");
629
- if ((await io.exists(forgeYaml)) && /syncedVersion:/.test(await io.readFile(forgeYaml))) {
644
+ if (
645
+ (await io.exists(forgeYaml)) &&
646
+ /syncedVersion:/.test(await io.readFile(forgeYaml))
647
+ ) {
630
648
  await writeSyncedForgeVersion(wt, c.nextVersion, io);
631
649
  }
632
650
  }
@@ -704,7 +722,12 @@ export async function runOrdinaryCut(
704
722
  .join("\n");
705
723
  const commit = await gitCommit(wt, io, ["commit", "-m", `${subject}\n\n${body}`], "cut");
706
724
  if (commit.exitCode !== 0) {
707
- return refuse("FLOW-CUT-01", `release commit failed: ${commit.stderr.trim()}`, "inspect the release worktree state", { releaseBranch });
725
+ return refuse(
726
+ "FLOW-CUT-01",
727
+ `release commit failed: ${commit.stderr.trim()}`,
728
+ "inspect the release worktree state",
729
+ { releaseBranch },
730
+ );
708
731
  }
709
732
 
710
733
  // 3b. pre-tag extract verification (RFC-1502): every named package
@@ -733,6 +756,8 @@ export async function runOrdinaryCut(
733
756
  now,
734
757
  lockHeld: true,
735
758
  target: "develop",
759
+ invoke: opts.invoke,
760
+ commandRegistry: opts.commandRegistry,
736
761
  });
737
762
  if (!integrated.integrated || integrated.diagnostics.length > 0) {
738
763
  const d = integrated.diagnostics[0];
@@ -763,15 +788,24 @@ export async function runOrdinaryCut(
763
788
  );
764
789
  } catch (error) {
765
790
  if (error instanceof LockTimeoutError) {
791
+ const lock =
792
+ error.holder === undefined
793
+ ? undefined
794
+ : describeHeldLock(error.holder, INTEGRATE_LOCK_STALE_MS);
766
795
  return refuse(
767
796
  "FLOW-INT-08",
768
- `integration lock ${error.lockPath} is held by another integration`,
797
+ lock === undefined
798
+ ? `integration lock ${error.lockPath} is held by another integration (holder unknown)`
799
+ : `integration lock ${error.lockPath} is held by pid ${lock.pid} on ${lock.host ?? "unknown host"} since ${lock.at} (${lock.disposition})`,
769
800
  "wait for the running integration to finish, or break the stale lock after 2 h automatically",
770
801
  { releaseBranch },
802
+ { lock },
771
803
  );
772
804
  }
773
805
  if (error instanceof FlowRegistrySchemaError) {
774
- return refuse("FLOW-07", error.message, `repair or remove ${registryPath(common)}`, { releaseBranch });
806
+ return refuse("FLOW-07", error.message, `repair or remove ${registryPath(common)}`, {
807
+ releaseBranch,
808
+ });
775
809
  }
776
810
  throw error;
777
811
  }
@@ -837,14 +871,27 @@ async function finishCutTail(
837
871
  "run pnpm exec forge flow.backmerge, then re-run flow.cut",
838
872
  );
839
873
  }
840
- const upd = await git(repoRoot, io, ["update-ref", "refs/heads/main", developTip, mainTipBefore]);
874
+ const upd = await git(repoRoot, io, [
875
+ "update-ref",
876
+ "refs/heads/main",
877
+ developTip,
878
+ mainTipBefore,
879
+ ]);
841
880
  if (upd.exitCode !== 0) {
842
- return refuse("FLOW-CUT-01", `update-ref main failed: ${upd.stderr.trim()}`, "inspect refs/heads/main");
881
+ return refuse(
882
+ "FLOW-CUT-01",
883
+ `update-ref main failed: ${upd.stderr.trim()}`,
884
+ "inspect refs/heads/main",
885
+ );
843
886
  }
844
887
  } else {
845
888
  const upd = await git(repoRoot, io, ["update-ref", "refs/heads/main", developTip]);
846
889
  if (upd.exitCode !== 0) {
847
- return refuse("FLOW-CUT-01", `update-ref main failed: ${upd.stderr.trim()}`, "inspect refs/heads/main");
890
+ return refuse(
891
+ "FLOW-CUT-01",
892
+ `update-ref main failed: ${upd.stderr.trim()}`,
893
+ "inspect refs/heads/main",
894
+ );
848
895
  }
849
896
  }
850
897
 
@@ -854,7 +901,12 @@ async function finishCutTail(
854
901
  // is skipped — rerun-safe against a crash between two git tag calls; a tag
855
902
  // pointing elsewhere refuses instead of silently moving it.
856
903
  for (const tag of tagNames) {
857
- const existing = await git(repoRoot, io, ["rev-parse", "-q", "--verify", `refs/tags/${tag}^{}`]);
904
+ const existing = await git(repoRoot, io, [
905
+ "rev-parse",
906
+ "-q",
907
+ "--verify",
908
+ `refs/tags/${tag}^{}`,
909
+ ]);
858
910
  if (existing.exitCode === 0) {
859
911
  if (existing.stdout.trim() === developTip) continue;
860
912
  return refuse(
@@ -863,17 +915,19 @@ async function finishCutTail(
863
915
  "delete the stray tag if it was never published, or pick a different version",
864
916
  );
865
917
  }
866
- const c = cutLines.find((cl) => cl.tag === tag) ?? (() => {
867
- const line = lineForTag(tag, allLines, repoLine);
868
- return {
869
- line,
870
- tag,
871
- level: "patch" as const,
872
- nextVersion: tag.slice(line.tagPrefix.length),
873
- previousTag: null,
874
- rfcs: [] as string[],
875
- };
876
- })();
918
+ const c =
919
+ cutLines.find((cl) => cl.tag === tag) ??
920
+ (() => {
921
+ const line = lineForTag(tag, allLines, repoLine);
922
+ return {
923
+ line,
924
+ tag,
925
+ level: "patch" as const,
926
+ nextVersion: tag.slice(line.tagPrefix.length),
927
+ previousTag: null,
928
+ rfcs: [] as string[],
929
+ };
930
+ })();
877
931
  const wr = await writeReleaseTag(repoRoot, io, {
878
932
  name: tag,
879
933
  target: developTip,
@@ -888,7 +942,11 @@ async function finishCutTail(
888
942
  }),
889
943
  });
890
944
  if (wr.exitCode !== 0) {
891
- return refuse("FLOW-CUT-01", `tag ${tag} failed: ${wr.stderr.trim()}`, "inspect the tag state");
945
+ return refuse(
946
+ "FLOW-CUT-01",
947
+ `tag ${tag} failed: ${wr.stderr.trim()}`,
948
+ "inspect the tag state",
949
+ );
892
950
  }
893
951
  }
894
952
 
@@ -907,9 +965,14 @@ async function finishCutTail(
907
965
  // journal failure is non-fatal bookkeeping.
908
966
  }
909
967
 
910
- const mainGains = mainTipBefore.length > 0
911
- ? Number((await git(repoRoot, io, ["rev-list", "--count", `${mainTipBefore}..${developTip}`])).stdout.trim() || 0)
912
- : 0;
968
+ const mainGains =
969
+ mainTipBefore.length > 0
970
+ ? Number(
971
+ (
972
+ await git(repoRoot, io, ["rev-list", "--count", `${mainTipBefore}..${developTip}`])
973
+ ).stdout.trim() || 0,
974
+ )
975
+ : 0;
913
976
 
914
977
  return {
915
978
  mode: "ordinary",
@@ -963,8 +1026,7 @@ export async function runFlowCut(
963
1026
  const common = await commonGitDir(io, repoRoot);
964
1027
  let entry = null;
965
1028
  try {
966
- entry =
967
- (await readRegistry(io, common)).branches.find((b) => b.name === candidate) ?? null;
1029
+ entry = (await readRegistry(io, common)).branches.find((b) => b.name === candidate) ?? null;
968
1030
  } catch (error) {
969
1031
  if (error instanceof FlowRegistrySchemaError) {
970
1032
  data = refuse("FLOW-07", error.message, `repair or remove ${registryPath(common)}`);
@@ -991,7 +1053,12 @@ export async function runFlowCut(
991
1053
  }
992
1054
  }
993
1055
 
994
- data = await runOrdinaryCut(repoRoot, io, { lines, dryRun });
1056
+ data = await runOrdinaryCut(repoRoot, io, {
1057
+ lines,
1058
+ dryRun,
1059
+ invoke: context.invoke,
1060
+ commandRegistry: context.commandRegistry,
1061
+ });
995
1062
  return finishCutResult(data, outputFormat, logger);
996
1063
  }
997
1064
 
@@ -1000,7 +1067,6 @@ function finishCutResult(
1000
1067
  outputFormat: string,
1001
1068
  logger: ForgeRuntimeContext["logger"],
1002
1069
  ): ForgeCommandResult<FlowCutData> {
1003
-
1004
1070
  const refused = data.diagnostics.find((d) => d.severity === "error");
1005
1071
  if (outputFormat === "pretty") {
1006
1072
  if (refused) {
@@ -1008,7 +1074,9 @@ function finishCutResult(
1008
1074
  } else if (data.released) {
1009
1075
  logger.section("flow.cut");
1010
1076
  logger.info(` ${data.resumed ? "resumed release" : "released"}: ${data.tags.join(", ")}`);
1011
- logger.info(` main gained ${data.mainGains} commit(s) — now at ${data.mainAfter?.slice(0, 9)}`);
1077
+ logger.info(
1078
+ ` main gained ${data.mainGains} commit(s) — now at ${data.mainAfter?.slice(0, 9)}`,
1079
+ );
1012
1080
  if (data.mainGains > 0 && !data.resumed) {
1013
1081
  logger.info(" the first cut after flow.install includes the guard-adoption commit");
1014
1082
  }
@@ -16,12 +16,12 @@ the registry entry and journals the operator's reason.</purpose>
16
16
  <item>Task-file preservation runs BEFORE the worktree-teardown hook and only for owner.kind task — a `git clean -fdx` teardown would destroy `.forge/task/` first, and a copy failure refuses the discard (FLOW-DIS-02) so the branch and its evidence survive (RFC-1509 Q-16).</item>
17
17
  </KEY_DECISIONS>
18
18
  <CHANGE_SUMMARY>
19
- <item>RFC-1491: independent-review pass — shared lock constants, publishable pending filter, declared rules, hold ordering, sha-pinned refspecs</item>
20
- <item>RFC-1509: implement RFC-1509 — system task queue, dispatch briefs and task reports</item>
21
19
  <item>RFC-1509: record task-file preservation decisions in flow handlers</item>
22
20
  <item>RFC-1509: close RFC-1509 review r1 findings — mark-failed escape, open-error refusal, dry-run coverage</item>
23
21
  <item>RFC-1509: record RFC-1509 preserve-before-teardown ordering in key decisions</item>
24
- <history>RFC-1487, RFC-1491</history>
22
+ <item>RFC-1515: harden forge flow worktree lifecycle against vanished paths, forge-local state, dead-holder locks and generated drift</item>
23
+ <item>RFC-1515: close rfc-1515 review findings — delete tolerated paths before worktree remove, prune vanished registrations, verified branch -D, shared held-lock render, gated e2e throw, journal toleratedState, edge tests</item>
24
+ <history>RFC-1487, RFC-1491, RFC-1509</history>
25
25
  </CHANGE_SUMMARY>
26
26
  */
27
27
 
@@ -54,6 +54,8 @@ import {
54
54
  import { runFlowScript, type FlowScriptResult } from "../scripts.ts";
55
55
  import { preserveTaskFiles } from "../task-files.ts";
56
56
  import { primaryWorktree } from "../worktree-path.ts";
57
+ import { rm } from "node:fs/promises";
58
+ import { join } from "node:path";
57
59
 
58
60
  export interface FlowDiscardData {
59
61
  branch: string | null;
@@ -145,7 +147,9 @@ export async function discardFlowBranch(
145
147
 
146
148
  const worktreePresent = worktree !== null && (await io.exists(worktree));
147
149
  if (opts.dryRun) {
148
- const dirty = worktreePresent ? await statusDirty(worktree, io) : [];
150
+ const dirty = worktreePresent
151
+ ? (await statusDirty(worktree, io)).entries
152
+ : [];
149
153
  return {
150
154
  branch,
151
155
  discarded: false,
@@ -167,8 +171,12 @@ export async function discardFlowBranch(
167
171
  }
168
172
 
169
173
  let teardownRan: FlowScriptResult | null = null;
174
+ let toleratedPaths: string[] = [];
175
+ // RFC-1515 AC-3: a vanished worktree skips the dirty gate and teardown —
176
+ // cleanup proceeds to `git branch -D` + the registry drop, recovering the
177
+ // orphaned entry in one command.
170
178
  if (worktreePresent) {
171
- const dirty = await statusDirty(worktree, io);
179
+ const dirty = (await statusDirty(worktree, io)).entries;
172
180
  if (dirty.length > 0 && !opts.dirty) {
173
181
  return refuse(
174
182
  "FLOW-DIS-03",
@@ -208,6 +216,20 @@ export async function discardFlowBranch(
208
216
  );
209
217
  }
210
218
 
219
+ // RFC-1515: `statusDirty` predicts `git worktree remove` — allowlisted
220
+ // forge-local state is untracked-not-ignored, so a tolerated-only tree
221
+ // still refuses removal. Delete the tolerated paths first (declared-
222
+ // disposable state; task payloads are already preserved above); real
223
+ // entries leave remove to report them.
224
+ if (!opts.dirty) {
225
+ const residual = await statusDirty(worktree, io);
226
+ if (residual.entries.length === 0 && residual.toleratedState.length > 0) {
227
+ toleratedPaths = residual.toleratedState;
228
+ for (const rel of residual.toleratedState) {
229
+ await rm(join(worktree, rel), { force: true, recursive: true });
230
+ }
231
+ }
232
+ }
211
233
  const rmArgs = ["worktree", "remove"];
212
234
  if (opts.dirty) rmArgs.push("--force");
213
235
  rmArgs.push(worktree);
@@ -228,6 +250,11 @@ export async function discardFlowBranch(
228
250
  ? (await git(primary, io, ["rev-parse", branch])).stdout.trim()
229
251
  : entry.baseSha;
230
252
  if (await branchExists(primary, io, branch)) {
253
+ // RFC-1515 AC-3: a vanished worktree leaves a stale `git worktree`
254
+ // registration that pins the branch — prune it so `branch -D` proceeds.
255
+ if (worktree !== null && !worktreePresent) {
256
+ await git(primary, io, ["worktree", "prune"]);
257
+ }
231
258
  const del = await git(primary, io, ["branch", "-D", branch]);
232
259
  if (del.exitCode !== 0) {
233
260
  return refuse(
@@ -251,6 +278,7 @@ export async function discardFlowBranch(
251
278
  sha: deletedTip,
252
279
  base: entry.baseSha,
253
280
  detail: opts.reason,
281
+ ...(toleratedPaths.length > 0 ? { toleratedState: toleratedPaths } : {}),
254
282
  });
255
283
  } catch (error) {
256
284
  if (error instanceof LockTimeoutError || error instanceof FlowRegistrySchemaError) {
@@ -18,14 +18,12 @@ conflicted port still reports released: true (DNA-106 per step).</purpose>
18
18
  <item>RFC-1502 r1: a refused fix cut rolls the branch back to its pre-release tip via `update-ref` + `read-tree --reset -u HEAD` (the session guard blocks reset --hard/restore/checkout --), so FLOW-CUT-12/13 stay rerun-safe without removing the fix worktree.</item>
19
19
  </KEY_DECISIONS>
20
20
  <CHANGE_SUMMARY>
21
- <item>RFC-1491: step 1 — journal base/rewrites + held registry widening, W1-1 discard tip, FLOW-INT-11</item>
22
- <item>RFC-1490: fix-mode cut run inside the fix worktree tears down and back-merges through the primary
23
-
24
- Steering-session verification of wave 2 (W2-1): flow.cut run inside the fix worktree, the documented path and the one flow.fix's nextSteps print, released main and the tags, then removed that worktree and kept using it as repoRoot. branch -D failed unobserved, leaving an unregistered auto/fix branch, and the trailing back-merge crashed on the vanished directory. The primary is now resolved before the cut and used for every step after the teardown; a failed branch delete surfaces as a FLOW-07 warning. Back-merge refusals are appended to the cut diagnostics instead of replacing them.</item>
25
21
  <item>RFC-1494: step 1 — isFlowAdopted public export</item>
26
22
  <item>RFC-1502: steps 1-5 — release-prepare hook, pre-tag extract verification, ordered steps</item>
27
23
  <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>
24
+ <item>RFC-1515: harden forge flow worktree lifecycle against vanished paths, forge-local state, dead-holder locks and generated drift</item>
25
+ <item>RFC-1515: close rfc-1515 review findings — delete tolerated paths before worktree remove, prune vanished registrations, verified branch -D, shared held-lock render, gated e2e throw, journal toleratedState, edge tests</item>
26
+ <history>RFC-1490, RFC-1491</history>
29
27
  </CHANGE_SUMMARY>
30
28
  */
31
29
 
@@ -49,7 +47,7 @@ import {
49
47
  topLevel,
50
48
  worktreeList,
51
49
  } from "../git.ts";
52
- import { LockTimeoutError, withFlowLock } from "../locks.ts";
50
+ import { describeHeldLock, LockTimeoutError, withFlowLock } from "../locks.ts";
53
51
  import { discoverReleaseLines } from "../release-lines.ts";
54
52
  import { pendingLevel } from "../release-level.ts";
55
53
  import { bumpVersion, formatVersion } from "../semver.ts";
@@ -226,10 +224,16 @@ export async function runFixCut(
226
224
  steps: [],
227
225
  diagnostics: [],
228
226
  };
229
- const cutRefuse = (ruleId: string, message: string, fixHint: string, p?: Partial<FlowCutData>): FlowCutData => ({
227
+ const cutRefuse = (
228
+ ruleId: string,
229
+ message: string,
230
+ fixHint: string,
231
+ p?: Partial<FlowCutData>,
232
+ diagData?: Record<string, unknown>,
233
+ ): FlowCutData => ({
230
234
  ...base,
231
235
  ...p,
232
- diagnostics: [{ ruleId, severity: "error", message, fixHint }],
236
+ diagnostics: [{ ruleId, severity: "error", message, fixHint, data: diagData }],
233
237
  });
234
238
 
235
239
  if (opts.linesGiven) {
@@ -251,7 +255,7 @@ export async function runFixCut(
251
255
  // The release commit stages tracked changes only (git add -u, RFC-1502) —
252
256
  // the dirty check still reports untracked files so the operator sees what
253
257
  // the release deliberately leaves out, and main must be free for the CAS.
254
- const dirty = await statusDirty(fixWt, io);
258
+ const dirty = (await statusDirty(fixWt, io)).entries;
255
259
  const mainCheckedOut = live.some((w) => w.branch === "main");
256
260
  if (dirty.length > 0 || mainCheckedOut) {
257
261
  return cutRefuse(
@@ -607,10 +611,18 @@ export async function runFixCut(
607
611
  );
608
612
  } catch (error) {
609
613
  if (error instanceof LockTimeoutError) {
614
+ const lock =
615
+ error.holder === undefined
616
+ ? undefined
617
+ : describeHeldLock(error.holder, INTEGRATE_LOCK_STALE_MS);
610
618
  return cutRefuse(
611
619
  "FLOW-INT-08",
612
- `integration lock ${error.lockPath} is held by another integration`,
620
+ lock === undefined
621
+ ? `integration lock ${error.lockPath} is held by another integration (holder unknown)`
622
+ : `integration lock ${error.lockPath} is held by pid ${lock.pid} on ${lock.host ?? "unknown host"} since ${lock.at} (${lock.disposition})`,
613
623
  "wait for the running integration to finish, or break the stale lock after 2 h automatically",
624
+ undefined,
625
+ { lock },
614
626
  );
615
627
  }
616
628
  throw error;
@@ -15,8 +15,6 @@ replayed tip and journal the hold with per-item rewrites.</purpose>
15
15
  <item>Rewrites are journaled only for attributed replayed items — unattributed runs re-form from unclaimed commits on the new tail on their own.</item>
16
16
  </KEY_DECISIONS>
17
17
  <CHANGE_SUMMARY>
18
- <item>RFC-1491: step 4 — flow.hold (replay, held branch, registry held entry, journal rewrites)</item>
19
- <item>RFC-1491: step 4 — flow.hold replay + flow.unhold worktree restore</item>
20
18
  <item>RFC-1491: independent-review pass — shared lock constants, publishable pending filter, declared rules, hold ordering, sha-pinned refspecs</item>
21
19
  <item>RFC-1491: digest segments develop by first-parent chain; hold of the topmost item skips the empty replay
22
20
 
@@ -30,6 +28,9 @@ first-argument allowlist; the read-only adapter and the static scan use the same
30
28
  table. The kernel forwards --dry-run into commands that declare a dry-run flag,
31
29
  and flow.push / flow.hold dry-runs no longer fetch. The switch-over runbook goes
32
30
  back to werkstatt run flow.install --dry-run.</item>
31
+ <item>RFC-1515: harden forge flow worktree lifecycle against vanished paths, forge-local state, dead-holder locks and generated drift</item>
32
+ <item>RFC-1515: close rfc-1515 review findings — delete tolerated paths before worktree remove, prune vanished registrations, verified branch -D, shared held-lock render, gated e2e throw, journal toleratedState, edge tests</item>
33
+ <history>RFC-1491</history>
33
34
  </CHANGE_SUMMARY>
34
35
  */
35
36
 
@@ -54,7 +55,7 @@ import {
54
55
  statusTracked,
55
56
  topLevel,
56
57
  } from "../git.ts";
57
- import { LockTimeoutError, withFlowLock } from "../locks.ts";
58
+ import { describeHeldLock, LockTimeoutError, withFlowLock } from "../locks.ts";
58
59
  import { INTEGRATE_LOCK_STALE_MS, INTEGRATE_LOCK_WAIT_MS } from "./flow-integrate.ts";
59
60
  import {
60
61
  appendJournal,
@@ -83,14 +84,19 @@ export interface FlowHoldData {
83
84
  diagnostics: Diagnostic[];
84
85
  }
85
86
 
86
- function refuse(ruleId: string, message: string, fixHint?: string): FlowHoldData {
87
+ function refuse(
88
+ ruleId: string,
89
+ message: string,
90
+ fixHint?: string,
91
+ diagData?: Record<string, unknown>,
92
+ ): FlowHoldData {
87
93
  return {
88
94
  held: false,
89
95
  item: null,
90
96
  branch: null,
91
97
  replayedTip: null,
92
98
  rewrites: [],
93
- diagnostics: [{ ruleId, severity: "error", message, fixHint }],
99
+ diagnostics: [{ ruleId, severity: "error", message, fixHint, data: diagData }],
94
100
  };
95
101
  }
96
102
 
@@ -212,7 +218,7 @@ export async function holdFlowItem(
212
218
  const primaryBranch = (
213
219
  await git(primary, io, ["symbolic-ref", "--short", "-q", "HEAD"])
214
220
  ).stdout.trim();
215
- const dirty = await statusTracked(primary, io);
221
+ const dirty = (await statusTracked(primary, io)).entries;
216
222
  if (primaryBranch !== "develop" || dirty.length > 0) {
217
223
  return refuse(
218
224
  "FLOW-HOLD-04",
@@ -273,10 +279,17 @@ export async function holdFlowItem(
273
279
  );
274
280
  } catch (error) {
275
281
  if (error instanceof LockTimeoutError) {
282
+ const lock =
283
+ error.holder === undefined
284
+ ? undefined
285
+ : describeHeldLock(error.holder, INTEGRATE_LOCK_STALE_MS);
276
286
  return refuse(
277
287
  "FLOW-07",
278
- `integration lock ${error.lockPath} still held`,
288
+ lock === undefined
289
+ ? `integration lock ${error.lockPath} still held (holder unknown)`
290
+ : `integration lock ${error.lockPath} still held by pid ${lock.pid} on ${lock.host ?? "unknown host"} since ${lock.at} (${lock.disposition})`,
279
291
  "a live flow command holds the lock — retry, or remove it if the holder died",
292
+ { lock },
280
293
  );
281
294
  }
282
295
  if (error instanceof FlowRegistrySchemaError) {