@warpgogol/forge 9.3.1 → 9.4.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 (467) hide show
  1. package/AGENTS.md +32 -0
  2. package/CHANGELOG.md +25 -0
  3. package/README.md +2 -2
  4. package/bin/cli.ts +4 -4
  5. package/dist/bin/cli.js +4 -4
  6. package/dist/bin/cli.js.map +1 -1
  7. package/dist/os/adr/handlers/list-create.d.ts.map +1 -1
  8. package/dist/os/adr/handlers/list-create.js +23 -2
  9. package/dist/os/adr/handlers/list-create.js.map +1 -1
  10. package/dist/os/adr/types.d.ts +2 -0
  11. package/dist/os/adr/types.d.ts.map +1 -1
  12. package/dist/os/adr/types.js +2 -2
  13. package/dist/os/adr/types.js.map +1 -1
  14. package/dist/os/compass/handlers/compass-audit-handler.d.ts.map +1 -1
  15. package/dist/os/compass/handlers/compass-audit-handler.js +3 -1
  16. package/dist/os/compass/handlers/compass-audit-handler.js.map +1 -1
  17. package/dist/os/compass/handlers/compass-header-scaffold-handler.d.ts.map +1 -1
  18. package/dist/os/compass/handlers/compass-header-scaffold-handler.js +6 -12
  19. package/dist/os/compass/handlers/compass-header-scaffold-handler.js.map +1 -1
  20. package/dist/os/compass/handlers/git-revision.d.ts +2 -0
  21. package/dist/os/compass/handlers/git-revision.d.ts.map +1 -1
  22. package/dist/os/compass/handlers/git-revision.js +7 -2
  23. package/dist/os/compass/handlers/git-revision.js.map +1 -1
  24. package/dist/os/compass/handlers/summary-record.d.ts.map +1 -1
  25. package/dist/os/compass/handlers/summary-record.js +24 -14
  26. package/dist/os/compass/handlers/summary-record.js.map +1 -1
  27. package/dist/os/conformance/conformance.module.d.ts.map +1 -1
  28. package/dist/os/conformance/conformance.module.js +21 -4
  29. package/dist/os/conformance/conformance.module.js.map +1 -1
  30. package/dist/os/conformance/handlers/conformance-validate.d.ts.map +1 -1
  31. package/dist/os/conformance/handlers/conformance-validate.js +64 -8
  32. package/dist/os/conformance/handlers/conformance-validate.js.map +1 -1
  33. package/dist/os/core/archive-regen.d.ts +99 -0
  34. package/dist/os/core/archive-regen.d.ts.map +1 -0
  35. package/dist/os/core/archive-regen.js +220 -0
  36. package/dist/os/core/archive-regen.js.map +1 -0
  37. package/dist/os/core/core.module.d.ts.map +1 -1
  38. package/dist/os/core/core.module.js +159 -18
  39. package/dist/os/core/core.module.js.map +1 -1
  40. package/dist/os/core/handlers/assets-helpers.d.ts.map +1 -1
  41. package/dist/os/core/handlers/assets-helpers.js +8 -3
  42. package/dist/os/core/handlers/assets-helpers.js.map +1 -1
  43. package/dist/os/core/handlers/forge-autonomy-validate.d.ts.map +1 -1
  44. package/dist/os/core/handlers/forge-autonomy-validate.js +3 -1
  45. package/dist/os/core/handlers/forge-autonomy-validate.js.map +1 -1
  46. package/dist/os/core/handlers/package-health.d.ts +130 -0
  47. package/dist/os/core/handlers/package-health.d.ts.map +1 -1
  48. package/dist/os/core/handlers/package-health.js +548 -7
  49. package/dist/os/core/handlers/package-health.js.map +1 -1
  50. package/dist/os/core/handlers/release-prepare.d.ts.map +1 -1
  51. package/dist/os/core/handlers/release-prepare.js +5 -2
  52. package/dist/os/core/handlers/release-prepare.js.map +1 -1
  53. package/dist/os/flow/digest.d.ts.map +1 -1
  54. package/dist/os/flow/digest.js +3 -1
  55. package/dist/os/flow/digest.js.map +1 -1
  56. package/dist/os/flow/dirty-classify.d.ts +48 -0
  57. package/dist/os/flow/dirty-classify.d.ts.map +1 -0
  58. package/dist/os/flow/dirty-classify.js +81 -0
  59. package/dist/os/flow/dirty-classify.js.map +1 -0
  60. package/dist/os/flow/flow.module.d.ts.map +1 -1
  61. package/dist/os/flow/flow.module.js +85 -19
  62. package/dist/os/flow/flow.module.js.map +1 -1
  63. package/dist/os/flow/gate-engine.d.ts +13 -0
  64. package/dist/os/flow/gate-engine.d.ts.map +1 -0
  65. package/dist/os/flow/gate-engine.js +32 -0
  66. package/dist/os/flow/gate-engine.js.map +1 -0
  67. package/dist/os/flow/git.d.ts +45 -4
  68. package/dist/os/flow/git.d.ts.map +1 -1
  69. package/dist/os/flow/git.js +95 -27
  70. package/dist/os/flow/git.js.map +1 -1
  71. package/dist/os/flow/handlers/flow-backmerge.d.ts.map +1 -1
  72. package/dist/os/flow/handlers/flow-backmerge.js +12 -5
  73. package/dist/os/flow/handlers/flow-backmerge.js.map +1 -1
  74. package/dist/os/flow/handlers/flow-check.d.ts.map +1 -1
  75. package/dist/os/flow/handlers/flow-check.js +25 -3
  76. package/dist/os/flow/handlers/flow-check.js.map +1 -1
  77. package/dist/os/flow/handlers/flow-cut.d.ts +4 -1
  78. package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -1
  79. package/dist/os/flow/handlers/flow-cut.js +54 -31
  80. package/dist/os/flow/handlers/flow-cut.js.map +1 -1
  81. package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -1
  82. package/dist/os/flow/handlers/flow-discard.js +33 -5
  83. package/dist/os/flow/handlers/flow-discard.js.map +1 -1
  84. package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -1
  85. package/dist/os/flow/handlers/flow-fix.js +13 -10
  86. package/dist/os/flow/handlers/flow-fix.js.map +1 -1
  87. package/dist/os/flow/handlers/flow-hold.d.ts.map +1 -1
  88. package/dist/os/flow/handlers/flow-hold.js +13 -7
  89. package/dist/os/flow/handlers/flow-hold.js.map +1 -1
  90. package/dist/os/flow/handlers/flow-install.d.ts +2 -1
  91. package/dist/os/flow/handlers/flow-install.d.ts.map +1 -1
  92. package/dist/os/flow/handlers/flow-install.js +56 -13
  93. package/dist/os/flow/handlers/flow-install.js.map +1 -1
  94. package/dist/os/flow/handlers/flow-integrate.d.ts +48 -2
  95. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
  96. package/dist/os/flow/handlers/flow-integrate.js +536 -65
  97. package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
  98. package/dist/os/flow/handlers/flow-open.d.ts +14 -0
  99. package/dist/os/flow/handlers/flow-open.d.ts.map +1 -1
  100. package/dist/os/flow/handlers/flow-open.js +117 -12
  101. package/dist/os/flow/handlers/flow-open.js.map +1 -1
  102. package/dist/os/flow/handlers/flow-status.d.ts +13 -0
  103. package/dist/os/flow/handlers/flow-status.d.ts.map +1 -1
  104. package/dist/os/flow/handlers/flow-status.js +35 -14
  105. package/dist/os/flow/handlers/flow-status.js.map +1 -1
  106. package/dist/os/flow/index.d.ts +1 -0
  107. package/dist/os/flow/index.d.ts.map +1 -1
  108. package/dist/os/flow/index.js +3 -1
  109. package/dist/os/flow/index.js.map +1 -1
  110. package/dist/os/flow/line-version.d.ts.map +1 -1
  111. package/dist/os/flow/line-version.js +2 -1
  112. package/dist/os/flow/line-version.js.map +1 -1
  113. package/dist/os/flow/locks.d.ts +37 -1
  114. package/dist/os/flow/locks.d.ts.map +1 -1
  115. package/dist/os/flow/locks.js +34 -14
  116. package/dist/os/flow/locks.js.map +1 -1
  117. package/dist/os/flow/preflight.d.ts +114 -0
  118. package/dist/os/flow/preflight.d.ts.map +1 -0
  119. package/dist/os/flow/preflight.js +620 -0
  120. package/dist/os/flow/preflight.js.map +1 -0
  121. package/dist/os/flow/publish.d.ts +7 -0
  122. package/dist/os/flow/publish.d.ts.map +1 -1
  123. package/dist/os/flow/publish.js +165 -3
  124. package/dist/os/flow/publish.js.map +1 -1
  125. package/dist/os/flow/registry.d.ts +26 -1
  126. package/dist/os/flow/registry.d.ts.map +1 -1
  127. package/dist/os/flow/registry.js +27 -6
  128. package/dist/os/flow/registry.js.map +1 -1
  129. package/dist/os/flow/scripts.d.ts +4 -0
  130. package/dist/os/flow/scripts.d.ts.map +1 -1
  131. package/dist/os/flow/scripts.js +8 -2
  132. package/dist/os/flow/scripts.js.map +1 -1
  133. package/dist/os/flow/session-checkout.d.ts +33 -0
  134. package/dist/os/flow/session-checkout.d.ts.map +1 -0
  135. package/dist/os/flow/session-checkout.js +151 -0
  136. package/dist/os/flow/session-checkout.js.map +1 -0
  137. package/dist/os/flow/worktree-path.d.ts.map +1 -1
  138. package/dist/os/flow/worktree-path.js +9 -3
  139. package/dist/os/flow/worktree-path.js.map +1 -1
  140. package/dist/os/instructions/handlers/budget-validate.d.ts +1 -0
  141. package/dist/os/instructions/handlers/budget-validate.d.ts.map +1 -1
  142. package/dist/os/instructions/handlers/budget-validate.js +12 -4
  143. package/dist/os/instructions/handlers/budget-validate.js.map +1 -1
  144. package/dist/os/instructions/instructions.module.d.ts.map +1 -1
  145. package/dist/os/instructions/instructions.module.js +4 -1
  146. package/dist/os/instructions/instructions.module.js.map +1 -1
  147. package/dist/os/mission/open-missions.d.ts +8 -0
  148. package/dist/os/mission/open-missions.d.ts.map +1 -0
  149. package/dist/os/mission/open-missions.js +42 -0
  150. package/dist/os/mission/open-missions.js.map +1 -0
  151. package/dist/os/queue/manifest.d.ts.map +1 -1
  152. package/dist/os/queue/manifest.js +11 -1
  153. package/dist/os/queue/manifest.js.map +1 -1
  154. package/dist/os/rfc/acceptance.d.ts +14 -0
  155. package/dist/os/rfc/acceptance.d.ts.map +1 -1
  156. package/dist/os/rfc/acceptance.js +18 -10
  157. package/dist/os/rfc/acceptance.js.map +1 -1
  158. package/dist/os/rfc/decision-log.d.ts.map +1 -1
  159. package/dist/os/rfc/decision-log.js +11 -2
  160. package/dist/os/rfc/decision-log.js.map +1 -1
  161. package/dist/os/rfc/frontmatter-io.d.ts +23 -0
  162. package/dist/os/rfc/frontmatter-io.d.ts.map +1 -1
  163. package/dist/os/rfc/frontmatter-io.js +82 -1
  164. package/dist/os/rfc/frontmatter-io.js.map +1 -1
  165. package/dist/os/rfc/handlers/implement-stamp-deviations.d.ts.map +1 -1
  166. package/dist/os/rfc/handlers/implement-stamp-deviations.js +24 -2
  167. package/dist/os/rfc/handlers/implement-stamp-deviations.js.map +1 -1
  168. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  169. package/dist/os/rfc/handlers/implement-stamp.js +16 -3
  170. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  171. package/dist/os/rfc/handlers/index-graph.d.ts.map +1 -1
  172. package/dist/os/rfc/handlers/index-graph.js +5 -4
  173. package/dist/os/rfc/handlers/index-graph.js.map +1 -1
  174. package/dist/os/rfc/handlers/list-create.d.ts.map +1 -1
  175. package/dist/os/rfc/handlers/list-create.js +83 -8
  176. package/dist/os/rfc/handlers/list-create.js.map +1 -1
  177. package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts +48 -0
  178. package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts.map +1 -1
  179. package/dist/os/rfc/handlers/rfc-evidence-sync.js +131 -2
  180. package/dist/os/rfc/handlers/rfc-evidence-sync.js.map +1 -1
  181. package/dist/os/rfc/handlers/validate-rules.d.ts +21 -1
  182. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  183. package/dist/os/rfc/handlers/validate-rules.js +77 -5
  184. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  185. package/dist/os/rfc/handlers/validate.d.ts.map +1 -1
  186. package/dist/os/rfc/handlers/validate.js +64 -6
  187. package/dist/os/rfc/handlers/validate.js.map +1 -1
  188. package/dist/os/rfc/next-id.d.ts +38 -0
  189. package/dist/os/rfc/next-id.d.ts.map +1 -0
  190. package/dist/os/rfc/next-id.js +165 -0
  191. package/dist/os/rfc/next-id.js.map +1 -0
  192. package/dist/os/rfc/probe-batch.d.ts.map +1 -1
  193. package/dist/os/rfc/probe-batch.js +6 -1
  194. package/dist/os/rfc/probe-batch.js.map +1 -1
  195. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  196. package/dist/os/rfc/rfc.module.js +36 -8
  197. package/dist/os/rfc/rfc.module.js.map +1 -1
  198. package/dist/os/rfc/types.d.ts +35 -6
  199. package/dist/os/rfc/types.d.ts.map +1 -1
  200. package/dist/os/rfc/types.js +6 -6
  201. package/dist/os/rfc/types.js.map +1 -1
  202. package/dist/os/rfc/verification-evidence.d.ts +1 -1
  203. package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
  204. package/dist/os/rfc/verification-evidence.js +81 -28
  205. package/dist/os/rfc/verification-evidence.js.map +1 -1
  206. package/dist/os/rfc/verification-origin.d.ts +8 -0
  207. package/dist/os/rfc/verification-origin.d.ts.map +1 -1
  208. package/dist/os/rfc/verification-origin.js +47 -0
  209. package/dist/os/rfc/verification-origin.js.map +1 -1
  210. package/dist/os/session/handlers/save.d.ts.map +1 -1
  211. package/dist/os/session/handlers/save.js +31 -7
  212. package/dist/os/session/handlers/save.js.map +1 -1
  213. package/dist/os/spec/spec-schema.d.ts +8 -0
  214. package/dist/os/spec/spec-schema.d.ts.map +1 -1
  215. package/dist/os/spec/spec-schema.js +1 -0
  216. package/dist/os/spec/spec-schema.js.map +1 -1
  217. package/dist/os/spec/spec-status.d.ts +8 -0
  218. package/dist/os/spec/spec-status.d.ts.map +1 -1
  219. package/dist/os/spec/spec-status.js +18 -6
  220. package/dist/os/spec/spec-status.js.map +1 -1
  221. package/dist/os/spec/spec-validate.d.ts.map +1 -1
  222. package/dist/os/spec/spec-validate.js +62 -15
  223. package/dist/os/spec/spec-validate.js.map +1 -1
  224. package/dist/os/spec/spec.module.d.ts.map +1 -1
  225. package/dist/os/spec/spec.module.js +13 -5
  226. package/dist/os/spec/spec.module.js.map +1 -1
  227. package/dist/os/system/handlers/system-map-validate.d.ts.map +1 -1
  228. package/dist/os/system/handlers/system-map-validate.js +2 -1
  229. package/dist/os/system/handlers/system-map-validate.js.map +1 -1
  230. package/dist/os/system/handlers/system-outbox-scan.d.ts +11 -0
  231. package/dist/os/system/handlers/system-outbox-scan.d.ts.map +1 -1
  232. package/dist/os/system/handlers/system-outbox-scan.js +54 -6
  233. package/dist/os/system/handlers/system-outbox-scan.js.map +1 -1
  234. package/dist/os/system/handlers/system-task-create.d.ts.map +1 -1
  235. package/dist/os/system/handlers/system-task-create.js +6 -1
  236. package/dist/os/system/handlers/system-task-create.js.map +1 -1
  237. package/dist/os/system/handlers/system-versionset-record.d.ts +14 -0
  238. package/dist/os/system/handlers/system-versionset-record.d.ts.map +1 -1
  239. package/dist/os/system/handlers/system-versionset-record.js +246 -6
  240. package/dist/os/system/handlers/system-versionset-record.js.map +1 -1
  241. package/dist/os/system/repo.d.ts +1 -1
  242. package/dist/os/system/repo.d.ts.map +1 -1
  243. package/dist/os/system/repo.js +53 -3
  244. package/dist/os/system/repo.js.map +1 -1
  245. package/dist/os/system/scenario-schemas.d.ts +109 -3
  246. package/dist/os/system/scenario-schemas.d.ts.map +1 -1
  247. package/dist/os/system/scenario-schemas.js +66 -10
  248. package/dist/os/system/scenario-schemas.js.map +1 -1
  249. package/dist/os/system/system.module.d.ts.map +1 -1
  250. package/dist/os/system/system.module.js +69 -17
  251. package/dist/os/system/system.module.js.map +1 -1
  252. package/dist/os/system/tests/contract-fixtures.d.ts +17 -0
  253. package/dist/os/system/tests/contract-fixtures.d.ts.map +1 -0
  254. package/dist/os/system/tests/contract-fixtures.js +109 -0
  255. package/dist/os/system/tests/contract-fixtures.js.map +1 -0
  256. package/dist/src/config/forge-config.d.ts +54 -18
  257. package/dist/src/config/forge-config.d.ts.map +1 -1
  258. package/dist/src/config/forge-config.js +41 -9
  259. package/dist/src/config/forge-config.js.map +1 -1
  260. package/dist/src/conformance/index.d.ts +6 -0
  261. package/dist/src/conformance/index.d.ts.map +1 -1
  262. package/dist/src/conformance/index.js +36 -1
  263. package/dist/src/conformance/index.js.map +1 -1
  264. package/dist/src/formal/proof-runner.d.ts.map +1 -1
  265. package/dist/src/formal/proof-runner.js +10 -2
  266. package/dist/src/formal/proof-runner.js.map +1 -1
  267. package/dist/src/migration-adapters/node-typescript-pnpm/index.js +3 -1
  268. package/dist/src/migration-adapters/node-typescript-pnpm/index.js.map +1 -1
  269. package/dist/src/migration-adapters/phaser-pnpm/index.js +3 -1
  270. package/dist/src/migration-adapters/phaser-pnpm/index.js.map +1 -1
  271. package/dist/src/onboarding/agents-generate.js +4 -4
  272. package/dist/src/onboarding/agents-generate.js.map +1 -1
  273. package/dist/src/onboarding/nested-agents-generate.d.ts.map +1 -1
  274. package/dist/src/onboarding/nested-agents-generate.js +3 -1
  275. package/dist/src/onboarding/nested-agents-generate.js.map +1 -1
  276. package/dist/src/onboarding/scaffold-project.js +2 -2
  277. package/dist/src/onboarding/scaffold-project.js.map +1 -1
  278. package/dist/src/onboarding/upgrade.d.ts.map +1 -1
  279. package/dist/src/onboarding/upgrade.js +14 -2
  280. package/dist/src/onboarding/upgrade.js.map +1 -1
  281. package/dist/src/onboarding/workspace-discovery.d.ts.map +1 -1
  282. package/dist/src/onboarding/workspace-discovery.js +3 -1
  283. package/dist/src/onboarding/workspace-discovery.js.map +1 -1
  284. package/dist/src/skill-schema.d.ts +3 -0
  285. package/dist/src/skill-schema.d.ts.map +1 -1
  286. package/dist/src/skill-schema.js +9 -2
  287. package/dist/src/skill-schema.js.map +1 -1
  288. package/dist/src/spec/resolve-spec-source.d.ts +45 -0
  289. package/dist/src/spec/resolve-spec-source.d.ts.map +1 -0
  290. package/dist/src/spec/resolve-spec-source.js +153 -0
  291. package/dist/src/spec/resolve-spec-source.js.map +1 -0
  292. package/dist/src/utils/command-inventory.d.ts +28 -0
  293. package/dist/src/utils/command-inventory.d.ts.map +1 -0
  294. package/dist/src/utils/command-inventory.js +84 -0
  295. package/dist/src/utils/command-inventory.js.map +1 -0
  296. package/dist/src/utils/io.d.ts.map +1 -1
  297. package/dist/src/utils/io.js +6 -1
  298. package/dist/src/utils/io.js.map +1 -1
  299. package/dist/src/utils/repo-path.d.ts +10 -0
  300. package/dist/src/utils/repo-path.d.ts.map +1 -0
  301. package/dist/src/utils/repo-path.js +52 -0
  302. package/dist/src/utils/repo-path.js.map +1 -0
  303. package/dist/src/utils/spawn.d.ts +23 -0
  304. package/dist/src/utils/spawn.d.ts.map +1 -0
  305. package/dist/src/utils/spawn.js +83 -0
  306. package/dist/src/utils/spawn.js.map +1 -0
  307. package/docs/branch-model.md +1 -1
  308. package/docs/guides/existing-project.md +1 -1
  309. package/docs/maintainers/publishing.md +1 -1
  310. package/docs/reference/cli.md +8 -2
  311. package/docs/reference/profiles.md +1 -1
  312. package/os/adr/handlers/list-create.ts +26 -2
  313. package/os/adr/types.ts +4 -2
  314. package/os/compass/handlers/compass-audit-handler.ts +6 -1
  315. package/os/compass/handlers/compass-header-scaffold-handler.ts +12 -11
  316. package/os/compass/handlers/git-revision.ts +8 -2
  317. package/os/compass/handlers/summary-record.ts +25 -14
  318. package/os/compass/handlers/tests/compass-invariant-binding.test.ts +3 -2
  319. package/os/conformance/conformance.module.ts +21 -4
  320. package/os/conformance/handlers/conformance-validate.ts +108 -16
  321. package/os/conformance/handlers/tests/conformance-package-consumer.test.ts +200 -0
  322. package/os/core/archive-regen.ts +279 -0
  323. package/os/core/core.module.ts +176 -29
  324. package/os/core/docs-archive.test.ts +413 -3
  325. package/os/core/handlers/assets-helpers.ts +8 -3
  326. package/os/core/handlers/forge-autonomy-validate.ts +3 -1
  327. package/os/core/handlers/package-health.test.ts +418 -4
  328. package/os/core/handlers/package-health.ts +629 -7
  329. package/os/core/handlers/release-prepare.ts +5 -2
  330. package/os/flow/digest.ts +3 -1
  331. package/os/flow/dirty-classify.ts +112 -0
  332. package/os/flow/flow.module.ts +92 -24
  333. package/os/flow/gate-engine.ts +45 -0
  334. package/os/flow/git.ts +117 -29
  335. package/os/flow/handlers/flow-backmerge.ts +14 -4
  336. package/os/flow/handlers/flow-check.ts +27 -2
  337. package/os/flow/handlers/flow-cut.ts +97 -46
  338. package/os/flow/handlers/flow-discard.ts +33 -5
  339. package/os/flow/handlers/flow-fix.ts +22 -10
  340. package/os/flow/handlers/flow-hold.ts +20 -7
  341. package/os/flow/handlers/flow-install.ts +59 -12
  342. package/os/flow/handlers/flow-integrate.ts +808 -182
  343. package/os/flow/handlers/flow-open.ts +135 -11
  344. package/os/flow/handlers/flow-status.ts +45 -13
  345. package/os/flow/index.ts +3 -1
  346. package/os/flow/line-version.ts +2 -1
  347. package/os/flow/locks.ts +56 -14
  348. package/os/flow/preflight.ts +763 -0
  349. package/os/flow/publish.ts +200 -5
  350. package/os/flow/registry.ts +43 -7
  351. package/os/flow/scripts.ts +13 -2
  352. package/os/flow/session-checkout.ts +186 -0
  353. package/os/flow/tests/dirty-classify.test.ts +116 -0
  354. package/os/flow/tests/fixtures/branch-names.yaml +40 -40
  355. package/os/flow/tests/flow-discard.test.ts +32 -0
  356. package/os/flow/tests/flow-guard-parity.test.ts +10 -2
  357. package/os/flow/tests/flow-install.test.ts +7 -3
  358. package/os/flow/tests/flow-integrate.gate-report.test.ts +144 -0
  359. package/os/flow/tests/flow-integrate.preflight.test.ts +561 -0
  360. package/os/flow/tests/flow-integrate.reattach.test.ts +197 -0
  361. package/os/flow/tests/flow-integrate.remediation.test.ts +254 -0
  362. package/os/flow/tests/flow-integrate.test.ts +348 -17
  363. package/os/flow/tests/flow-open.pending.test.ts +277 -0
  364. package/os/flow/tests/flow-open.test.ts +52 -9
  365. package/os/flow/tests/flow-push-publish.test.ts +124 -0
  366. package/os/flow/tests/flow-status.test.ts +31 -1
  367. package/os/flow/tests/locks.test.ts +39 -3
  368. package/os/flow/tests/scripts.test.ts +5 -2
  369. package/os/flow/tests/state-roots.test.ts +8 -5
  370. package/os/flow/worktree-path.ts +9 -3
  371. package/os/formal/handlers/proof-check.test.ts +6 -3
  372. package/os/instructions/budget.test.ts +31 -0
  373. package/os/instructions/handlers/budget-validate.ts +13 -4
  374. package/os/instructions/instructions.module.ts +4 -1
  375. package/os/mission/open-missions.ts +50 -0
  376. package/os/queue/decision-ledger.test.ts +18 -0
  377. package/os/queue/manifest.ts +17 -1
  378. package/os/rfc/acceptance.ts +30 -10
  379. package/os/rfc/decision-log.ts +13 -2
  380. package/os/rfc/frontmatter-io.ts +89 -1
  381. package/os/rfc/handlers/implement-stamp-deviations.test.ts +83 -0
  382. package/os/rfc/handlers/implement-stamp-deviations.ts +22 -2
  383. package/os/rfc/handlers/implement-stamp-stale.test.ts +5 -1
  384. package/os/rfc/handlers/implement-stamp.ts +16 -3
  385. package/os/rfc/handlers/index-graph.ts +5 -4
  386. package/os/rfc/handlers/lifecycle.test.ts +136 -0
  387. package/os/rfc/handlers/list-create.test.ts +82 -0
  388. package/os/rfc/handlers/list-create.ts +101 -8
  389. package/os/rfc/handlers/rfc-evidence-sync.test.ts +504 -0
  390. package/os/rfc/handlers/rfc-evidence-sync.ts +192 -2
  391. package/os/rfc/handlers/tests/index-graph.test.ts +2 -1
  392. package/os/rfc/handlers/validate-rules-rfc1454.test.ts +73 -0
  393. package/os/rfc/handlers/validate-rules.ts +103 -7
  394. package/os/rfc/handlers/validate.ts +68 -4
  395. package/os/rfc/next-id.ts +232 -0
  396. package/os/rfc/probe-batch.ts +6 -1
  397. package/os/rfc/rfc.module.ts +41 -8
  398. package/os/rfc/types.ts +28 -6
  399. package/os/rfc/verification-emit-freshness.test.ts +5 -1
  400. package/os/rfc/verification-emit.test.ts +5 -1
  401. package/os/rfc/verification-evidence.ts +99 -33
  402. package/os/rfc/verification-origin.ts +59 -0
  403. package/os/rfc/verification-refresh.test.ts +5 -1
  404. package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +5 -1
  405. package/os/session/handlers/save.ts +35 -7
  406. package/os/session/tests/session-save.test.ts +154 -0
  407. package/os/spec/spec-schema.ts +3 -0
  408. package/os/spec/spec-status.ts +22 -6
  409. package/os/spec/spec-validate.package-source.test.ts +187 -0
  410. package/os/spec/spec-validate.ts +65 -14
  411. package/os/spec/spec.module.ts +13 -5
  412. package/os/system/handlers/system-map-validate.ts +4 -2
  413. package/os/system/handlers/system-outbox-scan.ts +65 -21
  414. package/os/system/handlers/system-task-create.ts +6 -1
  415. package/os/system/handlers/system-versionset-record.ts +301 -16
  416. package/os/system/repo.ts +59 -18
  417. package/os/system/scenario-schemas.ts +91 -12
  418. package/os/system/system.module.ts +70 -17
  419. package/os/system/tests/contract-fixtures.ts +139 -0
  420. package/os/system/tests/scenario-pin-drift-check.test.ts +114 -0
  421. package/os/system/tests/scenario-validator-check.test.ts +96 -0
  422. package/os/system/tests/system-task-dispatch.test.ts +4 -1
  423. package/os/system/tests/system-versionset.test.ts +7 -3
  424. package/os/system/tests/version-set-v2.test.ts +78 -0
  425. package/package.json +9 -1
  426. package/skills/fo/fo-doctor/SKILL.md +151 -0
  427. package/skills/fo/fo-handoff/SKILL.md +22 -0
  428. package/skills/fo/fo-idea-create-rfc/acceptance-criteria-standard.md +2 -1
  429. package/skills/fo/fo-idea-implement/SKILL.md +5 -2
  430. package/skills/fo/fo-idea-plan/SKILL.md +5 -5
  431. package/skills/fo/fo-session-retro/SKILL.md +37 -11
  432. package/skills/fo/fo-spec-ingest/SKILL.md +8 -0
  433. package/skills/fo/fo-system-dispatch/SKILL.md +1 -0
  434. package/skills/meta/skill-create/SKILL.md +2 -1
  435. package/src/bin-entry.test.ts +3 -1
  436. package/src/config/forge-config.ts +57 -13
  437. package/src/conformance/index.ts +46 -1
  438. package/src/formal/proof-runner.ts +10 -2
  439. package/src/migration-adapters/node-typescript-pnpm/index.ts +3 -1
  440. package/src/migration-adapters/phaser-pnpm/index.ts +3 -1
  441. package/src/onboarding/agents-generate.ts +4 -4
  442. package/src/onboarding/nested-agents-generate.ts +3 -1
  443. package/src/onboarding/scaffold-project.ts +2 -2
  444. package/src/onboarding/upgrade.ts +13 -2
  445. package/src/onboarding/workspace-discovery.ts +3 -1
  446. package/src/pipeline-status.test.ts +1 -1
  447. package/src/skill-schema.ts +9 -2
  448. package/src/spec/resolve-spec-source.ts +184 -0
  449. package/src/tests/acceptance-probe-kinds.test.ts +3 -1
  450. package/src/tests/agents-generate-domain.test.ts +3 -2
  451. package/src/tests/agents-generate.test.ts +2 -1
  452. package/src/tests/create-flow.test.ts +3 -1
  453. package/src/tests/create.test.ts +12 -2
  454. package/src/tests/editable-generated-region.test.ts +2 -2
  455. package/src/tests/fixtures/agents-generate-business-before.txt +2 -0
  456. package/src/tests/implement-stamp.test.ts +5 -2
  457. package/src/tests/rfc-implement-stamp-governance.test.ts +6 -2
  458. package/src/tests/rfc-verification-verdict-ingest.test.ts +5 -1
  459. package/src/tests/scaffold-project.test.ts +3 -1
  460. package/src/tests/upgrade.test.ts +79 -3
  461. package/src/tests/workspace-discovery.test.ts +4 -3
  462. package/src/utils/command-inventory.ts +105 -0
  463. package/src/utils/io.ts +6 -1
  464. package/src/utils/repo-path.ts +49 -0
  465. package/src/utils/spawn.ts +88 -0
  466. package/src/tests/rfc-evidence-sync.test.ts +0 -369
  467. package/src/tests/skill-agents-sync.test.ts +0 -192
@@ -20,6 +20,8 @@ steps. --redo discards an existing port for the same mainSha first.</purpose>
20
20
  <item>RFC-1490: step 5 — flow.backmerge with port branch, conflict reporting, --redo</item>
21
21
  <item>RFC-1490: step 5 — flow.backmerge (port branch, fixed merge message, conflict + --redo paths)</item>
22
22
  <item>RFC-1490: independent-review pass — lock-held planning, fix-branch verification, spec-shaped data, coverage</item>
23
+ <item>RFC-1515: harden forge flow worktree lifecycle against vanished paths, forge-local state, dead-holder locks and generated drift</item>
24
+ <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>
23
25
  </CHANGE_SUMMARY>
24
26
  */
25
27
 
@@ -43,7 +45,7 @@ import {
43
45
  statusTracked,
44
46
  topLevel,
45
47
  } from "../git.ts";
46
- import { LockTimeoutError, withFlowLock } from "../locks.ts";
48
+ import { describeHeldLock, LockTimeoutError, withFlowLock } from "../locks.ts";
47
49
  import { discoverReleaseLines } from "../release-lines.ts";
48
50
  import {
49
51
  commonGitDir,
@@ -103,11 +105,12 @@ function refuse(
103
105
  message: string,
104
106
  fixHint: string,
105
107
  partial?: Partial<FlowBackmergeData>,
108
+ diagData?: Record<string, unknown>,
106
109
  ): FlowBackmergeData {
107
110
  return result({
108
111
  ...partial,
109
112
  status: "refused",
110
- diagnostics: [{ ruleId, severity: "error", message, fixHint }],
113
+ diagnostics: [{ ruleId, severity: "error", message, fixHint, data: diagData }],
111
114
  });
112
115
  }
113
116
 
@@ -219,7 +222,7 @@ async function planBackmerge(
219
222
 
220
223
  const primary = await primaryWorktree(io, repoRoot);
221
224
  const primaryBranch = await currentBranch(primary, io);
222
- const primaryDirty = await statusTracked(primary, io);
225
+ const primaryDirty = (await statusTracked(primary, io)).entries;
223
226
  if (primaryBranch !== "develop" || primaryDirty.length > 0) {
224
227
  return {
225
228
  kind: "refusal",
@@ -432,11 +435,18 @@ export async function backmergeFlow(
432
435
  );
433
436
  } catch (error) {
434
437
  if (error instanceof LockTimeoutError) {
438
+ const lock =
439
+ error.holder === undefined
440
+ ? undefined
441
+ : describeHeldLock(error.holder, INTEGRATE_LOCK_STALE_MS);
435
442
  return refuse(
436
443
  "FLOW-INT-08",
437
- `integration lock ${error.lockPath} is held by another integration`,
444
+ lock === undefined
445
+ ? `integration lock ${error.lockPath} is held by another integration (holder unknown)`
446
+ : `integration lock ${error.lockPath} is held by pid ${lock.pid} on ${lock.host ?? "unknown host"} since ${lock.at} (${lock.disposition})`,
438
447
  "wait for the running integration to finish, or break the stale lock after 2 h automatically",
439
448
  { portBranch },
449
+ { lock },
440
450
  );
441
451
  }
442
452
  throw error;
@@ -16,7 +16,6 @@ by flow.install step 9.</purpose>
16
16
  <item>A stray auto branch (RFC-1498) reports FLOW-07 the moment it exists — it has no registry entry and no worktree, so the 72 h staleness grace never applied to it.</item>
17
17
  </KEY_DECISIONS>
18
18
  <CHANGE_SUMMARY>
19
- <item>RFC-1487: step 5 — flow.discard, flow.status, flow.check FLOW-06/07</item>
20
19
  <item>RFC-1490: pre-merge-commit guard mode + per-mode op vocabulary; amends the wave-1 guard RFC's backmerge escape (AC-11)</item>
21
20
  <item>RFC-1491: step 2 — pre-push guard mode, install steps pre-push + markers, FLOW-10</item>
22
21
  <item>RFC-1498: step 1 — FLOW-07 for stray auto branches
@@ -25,7 +24,8 @@ collectFlowStatus exposes unregisteredBranchesWithoutWorktree — local auto/* b
25
24
  <item>RFC-1498: step 2 — network-only marker source
26
25
 
27
26
  markerSource accepts only network-shaped origins — http/https/ssh/git schemes or the scp user-at-host form — and returns { source, rejectedOrigin }. A local path or file:// URL falls back to the repository directory basename with rejectedOrigin naming the kind (local-path or file-url), so no machine-local path is ever written into an extract repository marker; embedded credentials are still stripped from network URLs. flow.install resolves the source at plan time, stores it on the plan for the execute phase, and the markers step warns origin rejected (kind) — using the directory name, never printing the path. Tests AC-3 (local path and file:// rejected, basename used, path absent from the step detail) and AC-4 (scp URL kept verbatim, https credentials stripped). Also carries the KEY_DECISIONS compass notes for step 1's stray-branch rule.</item>
28
- <history>RFC-1486, RFC-1488</history>
27
+ <item>RFC-1536: owning-checkout routing, FLOW-OPEN-01 dirty-primary warning, shared governance-id allocation (RFC+ADR)</item>
28
+ <history>RFC-1486, RFC-1487, RFC-1488</history>
29
29
  </CHANGE_SUMMARY>
30
30
  */
31
31
 
@@ -46,8 +46,10 @@ import {
46
46
  listLocalBranches,
47
47
  requireGit,
48
48
  revListCount,
49
+ statusTracked,
49
50
  topLevel,
50
51
  } from "../git.ts";
52
+ import { primaryWorktree } from "../worktree-path.ts";
51
53
  import {
52
54
  guardFileMatches,
53
55
  GUARD_FILE,
@@ -164,6 +166,29 @@ export async function collectFlowCheck(
164
166
  });
165
167
  }
166
168
 
169
+ // RFC-1536/RFC-1533 FLOW-OPEN-01: tracked mutations in the primary checkout
170
+ // are not swept into session worktrees — warn, never refuse.
171
+ try {
172
+ const primary = await primaryWorktree(io, repoRoot);
173
+ const primaryStatus = await statusTracked(primary, io);
174
+ if (!primaryStatus.vanished && primaryStatus.entries.length > 0) {
175
+ const paths = primaryStatus.entries.map((e) => e.slice(3));
176
+ const shown = paths.slice(0, 10);
177
+ diagnostics.push({
178
+ ruleId: "FLOW-OPEN-01",
179
+ severity: "warning",
180
+ message:
181
+ `primary checkout carries ${paths.length} tracked mutation(s): ${shown.join(", ")}` +
182
+ (paths.length > shown.length ? ` (+${paths.length - shown.length} more)` : "") +
183
+ " — they are NOT swept into the worktree; commit or move them first",
184
+ fixHint:
185
+ "commit them in the primary checkout or move them into the session worktree before integrating",
186
+ });
187
+ }
188
+ } catch {
189
+ // A repo whose worktree list cannot be read keeps every other check.
190
+ }
191
+
167
192
  const developExists = await branchExists(repoRoot, io, "develop");
168
193
  const mainExists = await branchExists(repoRoot, io, "main");
169
194
  if (!developExists) {
@@ -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
23
  <item>RFC-1502: steps 1-5 — release-prepare hook, pre-tag extract verification, ordered steps</item>
27
24
  <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>
25
+ <item>RFC-1515: harden forge flow worktree lifecycle against vanished paths, forge-local state, dead-holder locks and generated drift</item>
26
+ <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>
27
+ <item>RFC-1528: close review findings — manifest-union command inventory for regen/preflight</item>
28
+ <history>RFC-1490, RFC-1491, RFC-1494</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
@@ -374,7 +369,7 @@ async function planOrdinaryCut(
374
369
  }
375
370
 
376
371
  const primaryBranch = await currentBranch(primary, io);
377
- const primaryDirty = await statusTracked(primary, io);
372
+ const primaryDirty = (await statusTracked(primary, io)).entries;
378
373
  const worktrees = await worktreeList(repoRoot, io);
379
374
  const mainCheckedOut = worktrees.some((w) => w.branch === "main");
380
375
  if (primaryBranch !== "develop" || primaryDirty.length > 0 || mainCheckedOut) {
@@ -524,6 +519,9 @@ export async function runOrdinaryCut(
524
519
  dryRun: boolean;
525
520
  now?: Date;
526
521
  onProgress?: (m: string) => void;
522
+ /** RFC-1528: forwarded to flow.integrate's bounded preflight. */
523
+ invoke?: ForgeInvokeCommand;
524
+ commandRegistry?: CommandRegistry;
527
525
  },
528
526
  ): Promise<FlowCutData> {
529
527
  const now = opts.now ?? new Date();
@@ -626,7 +624,10 @@ export async function runOrdinaryCut(
626
624
  ) as { name?: string };
627
625
  if (pkg.name === "@warpgogol/forge") {
628
626
  const forgeYaml = join(wt, "forge.yaml");
629
- if ((await io.exists(forgeYaml)) && /syncedVersion:/.test(await io.readFile(forgeYaml))) {
627
+ if (
628
+ (await io.exists(forgeYaml)) &&
629
+ /syncedVersion:/.test(await io.readFile(forgeYaml))
630
+ ) {
630
631
  await writeSyncedForgeVersion(wt, c.nextVersion, io);
631
632
  }
632
633
  }
@@ -704,7 +705,12 @@ export async function runOrdinaryCut(
704
705
  .join("\n");
705
706
  const commit = await gitCommit(wt, io, ["commit", "-m", `${subject}\n\n${body}`], "cut");
706
707
  if (commit.exitCode !== 0) {
707
- return refuse("FLOW-CUT-01", `release commit failed: ${commit.stderr.trim()}`, "inspect the release worktree state", { releaseBranch });
708
+ return refuse(
709
+ "FLOW-CUT-01",
710
+ `release commit failed: ${commit.stderr.trim()}`,
711
+ "inspect the release worktree state",
712
+ { releaseBranch },
713
+ );
708
714
  }
709
715
 
710
716
  // 3b. pre-tag extract verification (RFC-1502): every named package
@@ -733,6 +739,8 @@ export async function runOrdinaryCut(
733
739
  now,
734
740
  lockHeld: true,
735
741
  target: "develop",
742
+ invoke: opts.invoke,
743
+ commandRegistry: opts.commandRegistry,
736
744
  });
737
745
  if (!integrated.integrated || integrated.diagnostics.length > 0) {
738
746
  const d = integrated.diagnostics[0];
@@ -763,15 +771,24 @@ export async function runOrdinaryCut(
763
771
  );
764
772
  } catch (error) {
765
773
  if (error instanceof LockTimeoutError) {
774
+ const lock =
775
+ error.holder === undefined
776
+ ? undefined
777
+ : describeHeldLock(error.holder, INTEGRATE_LOCK_STALE_MS);
766
778
  return refuse(
767
779
  "FLOW-INT-08",
768
- `integration lock ${error.lockPath} is held by another integration`,
780
+ lock === undefined
781
+ ? `integration lock ${error.lockPath} is held by another integration (holder unknown)`
782
+ : `integration lock ${error.lockPath} is held by pid ${lock.pid} on ${lock.host ?? "unknown host"} since ${lock.at} (${lock.disposition})`,
769
783
  "wait for the running integration to finish, or break the stale lock after 2 h automatically",
770
784
  { releaseBranch },
785
+ { lock },
771
786
  );
772
787
  }
773
788
  if (error instanceof FlowRegistrySchemaError) {
774
- return refuse("FLOW-07", error.message, `repair or remove ${registryPath(common)}`, { releaseBranch });
789
+ return refuse("FLOW-07", error.message, `repair or remove ${registryPath(common)}`, {
790
+ releaseBranch,
791
+ });
775
792
  }
776
793
  throw error;
777
794
  }
@@ -837,14 +854,27 @@ async function finishCutTail(
837
854
  "run pnpm exec forge flow.backmerge, then re-run flow.cut",
838
855
  );
839
856
  }
840
- const upd = await git(repoRoot, io, ["update-ref", "refs/heads/main", developTip, mainTipBefore]);
857
+ const upd = await git(repoRoot, io, [
858
+ "update-ref",
859
+ "refs/heads/main",
860
+ developTip,
861
+ mainTipBefore,
862
+ ]);
841
863
  if (upd.exitCode !== 0) {
842
- return refuse("FLOW-CUT-01", `update-ref main failed: ${upd.stderr.trim()}`, "inspect refs/heads/main");
864
+ return refuse(
865
+ "FLOW-CUT-01",
866
+ `update-ref main failed: ${upd.stderr.trim()}`,
867
+ "inspect refs/heads/main",
868
+ );
843
869
  }
844
870
  } else {
845
871
  const upd = await git(repoRoot, io, ["update-ref", "refs/heads/main", developTip]);
846
872
  if (upd.exitCode !== 0) {
847
- return refuse("FLOW-CUT-01", `update-ref main failed: ${upd.stderr.trim()}`, "inspect refs/heads/main");
873
+ return refuse(
874
+ "FLOW-CUT-01",
875
+ `update-ref main failed: ${upd.stderr.trim()}`,
876
+ "inspect refs/heads/main",
877
+ );
848
878
  }
849
879
  }
850
880
 
@@ -854,7 +884,12 @@ async function finishCutTail(
854
884
  // is skipped — rerun-safe against a crash between two git tag calls; a tag
855
885
  // pointing elsewhere refuses instead of silently moving it.
856
886
  for (const tag of tagNames) {
857
- const existing = await git(repoRoot, io, ["rev-parse", "-q", "--verify", `refs/tags/${tag}^{}`]);
887
+ const existing = await git(repoRoot, io, [
888
+ "rev-parse",
889
+ "-q",
890
+ "--verify",
891
+ `refs/tags/${tag}^{}`,
892
+ ]);
858
893
  if (existing.exitCode === 0) {
859
894
  if (existing.stdout.trim() === developTip) continue;
860
895
  return refuse(
@@ -863,17 +898,19 @@ async function finishCutTail(
863
898
  "delete the stray tag if it was never published, or pick a different version",
864
899
  );
865
900
  }
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
- })();
901
+ const c =
902
+ cutLines.find((cl) => cl.tag === tag) ??
903
+ (() => {
904
+ const line = lineForTag(tag, allLines, repoLine);
905
+ return {
906
+ line,
907
+ tag,
908
+ level: "patch" as const,
909
+ nextVersion: tag.slice(line.tagPrefix.length),
910
+ previousTag: null,
911
+ rfcs: [] as string[],
912
+ };
913
+ })();
877
914
  const wr = await writeReleaseTag(repoRoot, io, {
878
915
  name: tag,
879
916
  target: developTip,
@@ -888,7 +925,11 @@ async function finishCutTail(
888
925
  }),
889
926
  });
890
927
  if (wr.exitCode !== 0) {
891
- return refuse("FLOW-CUT-01", `tag ${tag} failed: ${wr.stderr.trim()}`, "inspect the tag state");
928
+ return refuse(
929
+ "FLOW-CUT-01",
930
+ `tag ${tag} failed: ${wr.stderr.trim()}`,
931
+ "inspect the tag state",
932
+ );
892
933
  }
893
934
  }
894
935
 
@@ -907,9 +948,14 @@ async function finishCutTail(
907
948
  // journal failure is non-fatal bookkeeping.
908
949
  }
909
950
 
910
- const mainGains = mainTipBefore.length > 0
911
- ? Number((await git(repoRoot, io, ["rev-list", "--count", `${mainTipBefore}..${developTip}`])).stdout.trim() || 0)
912
- : 0;
951
+ const mainGains =
952
+ mainTipBefore.length > 0
953
+ ? Number(
954
+ (
955
+ await git(repoRoot, io, ["rev-list", "--count", `${mainTipBefore}..${developTip}`])
956
+ ).stdout.trim() || 0,
957
+ )
958
+ : 0;
913
959
 
914
960
  return {
915
961
  mode: "ordinary",
@@ -963,8 +1009,7 @@ export async function runFlowCut(
963
1009
  const common = await commonGitDir(io, repoRoot);
964
1010
  let entry = null;
965
1011
  try {
966
- entry =
967
- (await readRegistry(io, common)).branches.find((b) => b.name === candidate) ?? null;
1012
+ entry = (await readRegistry(io, common)).branches.find((b) => b.name === candidate) ?? null;
968
1013
  } catch (error) {
969
1014
  if (error instanceof FlowRegistrySchemaError) {
970
1015
  data = refuse("FLOW-07", error.message, `repair or remove ${registryPath(common)}`);
@@ -991,7 +1036,12 @@ export async function runFlowCut(
991
1036
  }
992
1037
  }
993
1038
 
994
- data = await runOrdinaryCut(repoRoot, io, { lines, dryRun });
1039
+ data = await runOrdinaryCut(repoRoot, io, {
1040
+ lines,
1041
+ dryRun,
1042
+ invoke: context.invoke,
1043
+ commandRegistry: context.commandRegistry,
1044
+ });
995
1045
  return finishCutResult(data, outputFormat, logger);
996
1046
  }
997
1047
 
@@ -1000,7 +1050,6 @@ function finishCutResult(
1000
1050
  outputFormat: string,
1001
1051
  logger: ForgeRuntimeContext["logger"],
1002
1052
  ): ForgeCommandResult<FlowCutData> {
1003
-
1004
1053
  const refused = data.diagnostics.find((d) => d.severity === "error");
1005
1054
  if (outputFormat === "pretty") {
1006
1055
  if (refused) {
@@ -1008,7 +1057,9 @@ function finishCutResult(
1008
1057
  } else if (data.released) {
1009
1058
  logger.section("flow.cut");
1010
1059
  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)}`);
1060
+ logger.info(
1061
+ ` main gained ${data.mainGains} commit(s) — now at ${data.mainAfter?.slice(0, 9)}`,
1062
+ );
1012
1063
  if (data.mainGains > 0 && !data.resumed) {
1013
1064
  logger.info(" the first cut after flow.install includes the guard-adoption commit");
1014
1065
  }
@@ -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;