@warpgogol/forge 9.3.0 → 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 (472) hide show
  1. package/AGENTS.md +32 -0
  2. package/CHANGELOG.md +33 -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 +13 -3
  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 +23 -7
  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 +18 -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/profiles/forge-shell.yaml +1 -2
  427. package/profiles/knowledge.yaml +1 -1
  428. package/profiles/system.yaml +2 -2
  429. package/profiles/typescript.yaml +0 -1
  430. package/skills/fo/fo-doctor/SKILL.md +151 -0
  431. package/skills/fo/fo-handoff/SKILL.md +22 -0
  432. package/skills/fo/fo-idea-create-rfc/acceptance-criteria-standard.md +2 -1
  433. package/skills/fo/fo-idea-implement/SKILL.md +5 -2
  434. package/skills/fo/fo-idea-plan/SKILL.md +5 -5
  435. package/skills/fo/fo-session-retro/SKILL.md +37 -11
  436. package/skills/fo/fo-spec-ingest/SKILL.md +8 -0
  437. package/skills/fo/fo-system-dispatch/SKILL.md +1 -0
  438. package/skills/meta/skill-create/SKILL.md +2 -1
  439. package/src/bin-entry.test.ts +3 -1
  440. package/src/config/forge-config.ts +57 -13
  441. package/src/conformance/index.ts +46 -1
  442. package/src/formal/proof-runner.ts +10 -2
  443. package/src/migration-adapters/node-typescript-pnpm/index.ts +3 -1
  444. package/src/migration-adapters/phaser-pnpm/index.ts +3 -1
  445. package/src/onboarding/agents-generate.ts +4 -4
  446. package/src/onboarding/nested-agents-generate.ts +3 -1
  447. package/src/onboarding/scaffold-project.ts +2 -2
  448. package/src/onboarding/upgrade.ts +13 -2
  449. package/src/onboarding/workspace-discovery.ts +3 -1
  450. package/src/pipeline-status.test.ts +1 -1
  451. package/src/skill-schema.ts +9 -2
  452. package/src/spec/resolve-spec-source.ts +184 -0
  453. package/src/tests/acceptance-probe-kinds.test.ts +3 -1
  454. package/src/tests/agents-generate-domain.test.ts +3 -2
  455. package/src/tests/agents-generate.test.ts +2 -1
  456. package/src/tests/create-flow.test.ts +3 -1
  457. package/src/tests/create.test.ts +12 -2
  458. package/src/tests/editable-generated-region.test.ts +2 -2
  459. package/src/tests/fixtures/agents-generate-business-before.txt +2 -0
  460. package/src/tests/implement-stamp.test.ts +5 -2
  461. package/src/tests/profile-flow-hooks.test.ts +15 -0
  462. package/src/tests/rfc-implement-stamp-governance.test.ts +6 -2
  463. package/src/tests/rfc-verification-verdict-ingest.test.ts +5 -1
  464. package/src/tests/scaffold-project.test.ts +3 -1
  465. package/src/tests/upgrade.test.ts +79 -3
  466. package/src/tests/workspace-discovery.test.ts +4 -3
  467. package/src/utils/command-inventory.ts +105 -0
  468. package/src/utils/io.ts +6 -1
  469. package/src/utils/repo-path.ts +49 -0
  470. package/src/utils/spawn.ts +88 -0
  471. package/src/tests/rfc-evidence-sync.test.ts +0 -369
  472. package/src/tests/skill-agents-sync.test.ts +0 -192
@@ -18,12 +18,13 @@ hooks/worktree-setup.sh.</purpose>
18
18
  <item>A failed setup script is reported, never rolled back — the worktree and registry entry stay, and the command exits 1 (DNA-106).</item>
19
19
  </KEY_DECISIONS>
20
20
  <CHANGE_SUMMARY>
21
- <item>RFC-1490: step 2 — registry fix/port widening, FORGE_FLOW_COMMIT gitCommit helper, verified version-files writes</item>
22
- <item>RFC-1490: step 4 — ordinary flow.cut (release branch, verified versions, gate, main swap, tags, resume)</item>
23
- <item>RFC-1490: step 5 — flow.backmerge (port branch, fixed merge message, conflict + --redo paths)</item>
24
21
  <item>RFC-1490: step 6 — flow.fix + fix-mode cut (patch-only, rebase on moved main, gate target main, trailing back-merge)</item>
25
22
  <item>RFC-1490: independent-review pass — lock-held planning, fix-branch verification, spec-shaped data, coverage</item>
26
- <history>RFC-1487</history>
23
+ <item>ADR-0124: enable git rerere in flow-managed repositories</item>
24
+ <item>RFC-1536: owning-checkout routing, FLOW-OPEN-01 dirty-primary warning, shared governance-id allocation (RFC+ADR)</item>
25
+ <item>RFC-1536: evidence — routing/warning tests, FLOW-OPEN-10 validation renumber, owning-worktree doc rule, frictions F-0091/F-0096/F-0106/F-0119 addressed</item>
26
+ <item>RFC-1533: pending-branch summary + primaryMutations on the result; FLOW-OPEN-02 freed for the registry-unreadable warning (refusal renumbered to FLOW-OPEN-11)</item>
27
+ <history>RFC-1487, RFC-1490</history>
27
28
  </CHANGE_SUMMARY>
28
29
  */
29
30
 
@@ -37,10 +38,12 @@ import type {
37
38
  import { resolveIo } from "../../../src/utils/io.ts";
38
39
  import {
39
40
  branchExists,
41
+ ensureRerere,
40
42
  git,
41
43
  listLocalBranches,
42
44
  listRemoteBranches,
43
45
  requireGit,
46
+ statusTracked,
44
47
  topLevel,
45
48
  } from "../git.ts";
46
49
  import { formatFlowBranch, parseFlowBranch, type FlowBranchKind } from "../branch-name.ts";
@@ -56,6 +59,7 @@ import {
56
59
  type FlowRegistryEntry,
57
60
  } from "../registry.ts";
58
61
  import { runFlowScript, type FlowScriptResult } from "../scripts.ts";
62
+ import { collectFlowStatus } from "./flow-status.ts";
59
63
  import { flowWorktreePath, primaryWorktree } from "../worktree-path.ts";
60
64
 
61
65
  const OPEN_MAX_ATTEMPTS = 3;
@@ -99,6 +103,16 @@ export interface FlowOpenData {
99
103
  baseSha: string | null;
100
104
  opened: boolean;
101
105
  setup: FlowScriptResult | null;
106
+ /** RFC-1533: tracked-dirty paths in the primary at open time (the sweep's
107
+ * input — empty when clean or already refused before the status read). */
108
+ primaryMutations: string[];
109
+ /** RFC-1533: registered siblings excluding the branch just opened;
110
+ * null when the registry could not be read for the summary (FLOW-OPEN-02). */
111
+ pending: {
112
+ total: number;
113
+ byKind: { session: number; task: number; fix: number };
114
+ stale: number;
115
+ } | null;
102
116
  diagnostics: Diagnostic[];
103
117
  }
104
118
 
@@ -111,6 +125,8 @@ function refuse(ruleId: string, message: string, fixHint: string): FlowOpenData
111
125
  baseSha: null,
112
126
  opened: false,
113
127
  setup: null,
128
+ primaryMutations: [],
129
+ pending: null,
114
130
  diagnostics: [{ ruleId, severity: "error", message, fixHint }],
115
131
  };
116
132
  }
@@ -139,9 +155,9 @@ export async function openFlowBranch(
139
155
  io: WorkspaceIO,
140
156
  opts: FlowOpenOptions,
141
157
  ): Promise<FlowOpenData> {
142
- // Flags — FLOW-OPEN-01/05 first, before any git fact is consulted.
158
+ // Flags — FLOW-OPEN-10/05 first, before any git fact is consulted.
143
159
  if (opts.kind !== "session" && opts.kind !== "task") {
144
- return refuse("FLOW-OPEN-01", `invalid --kind '${opts.kind}'`, "use --kind session or --kind task");
160
+ return refuse("FLOW-OPEN-10", `invalid --kind '${opts.kind}'`, "use --kind session or --kind task");
145
161
  }
146
162
  if (opts.kind === "task" && (opts.owner === null || opts.owner === "")) {
147
163
  return refuse(
@@ -176,7 +192,7 @@ export async function openFlowBranchCore(
176
192
 
177
193
  if (!SLUG_RE.test(opts.slug) || opts.slug.length < 3 || opts.slug.length > 48) {
178
194
  return refuse(
179
- "FLOW-OPEN-01",
195
+ "FLOW-OPEN-10",
180
196
  `invalid --slug '${opts.slug}'`,
181
197
  "slug must match ^[a-z0-9]+(-[a-z0-9]+)*$ and be 3..48 characters",
182
198
  );
@@ -202,7 +218,7 @@ export async function openFlowBranchCore(
202
218
 
203
219
  if (!(await branchExists(repoRoot, io, baseRef))) {
204
220
  return refuse(
205
- "FLOW-OPEN-02",
221
+ "FLOW-OPEN-11",
206
222
  `local branch ${baseRef} does not exist`,
207
223
  base === "develop"
208
224
  ? "adopt the fixed branch model with flow.install first"
@@ -215,6 +231,32 @@ export async function openFlowBranchCore(
215
231
  const primary = await primaryWorktree(io, repoRoot);
216
232
  const common = await commonGitDir(io, repoRoot);
217
233
 
234
+ // RFC-1536/RFC-1533 FLOW-OPEN-01: warn when the primary checkout carries
235
+ // tracked mutations — the sweep does NOT move them into the worktree.
236
+ // Warning severity, exit code unchanged; the same diagnostic fires at
237
+ // flow.check so the condition is visible between opens.
238
+ const dirtyPrimaryDiags: Diagnostic[] = [];
239
+ let primaryMutations: string[] = [];
240
+ {
241
+ const primaryStatus = await statusTracked(primary, io);
242
+ if (!primaryStatus.vanished) {
243
+ primaryMutations = primaryStatus.entries.map((e) => e.slice(3));
244
+ }
245
+ if (primaryMutations.length > 0) {
246
+ const shown = primaryMutations.slice(0, 10);
247
+ dirtyPrimaryDiags.push({
248
+ ruleId: "FLOW-OPEN-01",
249
+ severity: "warning",
250
+ message:
251
+ `primary checkout carries ${primaryMutations.length} tracked mutation(s): ${shown.join(", ")}` +
252
+ (primaryMutations.length > shown.length ? ` (+${primaryMutations.length - shown.length} more)` : "") +
253
+ " — they are NOT swept into the worktree; commit or move them first",
254
+ fixHint:
255
+ "commit them in the primary checkout or move them into the session worktree before integrating",
256
+ });
257
+ }
258
+ }
259
+
218
260
  // Candidate names — local branches, remote-tracking auto refs, registry.
219
261
  let registryNames: string[];
220
262
  try {
@@ -256,6 +298,67 @@ export async function openFlowBranchCore(
256
298
  const ownerId = opts.owner.id;
257
299
  const iso = now.toISOString();
258
300
 
301
+ // ADR-0124: repair shared rerere config idempotently at worktree setup —
302
+ // a repo adopted before ADR-0124 self-heals on the next session open.
303
+ // Never blocks: a config write failure is a warning, not a refusal.
304
+ const rerereDiags: Diagnostic[] = [];
305
+ if (!opts.dryRun) {
306
+ for (const failure of await ensureRerere(repoRoot, io)) {
307
+ rerereDiags.push({
308
+ ruleId: "FLOW-OPEN-08",
309
+ severity: "warning",
310
+ message: `rerere config repair failed: ${failure}`,
311
+ fixHint: `run git config rerere.enabled true && git config rerere.autoupdate true in ${repoRoot}`,
312
+ });
313
+ }
314
+ }
315
+
316
+ // RFC-1533 pending summary — registered siblings excluding the branch just
317
+ // opened, computed through collectFlowStatus (single fact source). A
318
+ // registry read failure degrades to `pending: null` + FLOW-OPEN-02 warning;
319
+ // surfacing must never wedge worktree creation.
320
+ const pendingSummary = async (
321
+ excludeName: string,
322
+ ): Promise<{ pending: FlowOpenData["pending"]; diags: Diagnostic[] }> => {
323
+ const unreadable = {
324
+ pending: null,
325
+ diags: [
326
+ {
327
+ ruleId: "FLOW-OPEN-02" as const,
328
+ severity: "warning" as const,
329
+ message:
330
+ "flow registry absent or unreadable — pending-branch summary unavailable",
331
+ fixHint: `run flow.check for registry diagnostics; repair or remove ${registryPath(common)}`,
332
+ },
333
+ ],
334
+ };
335
+ try {
336
+ // On the success path the registry always exists (registration wrote
337
+ // it) — the absent branch is reachable on a dry-run over a repo that
338
+ // never opened a flow branch.
339
+ if (!(await io.exists(registryPath(common)))) return unreadable;
340
+ const status = await collectFlowStatus(repoRoot, io, { now });
341
+ if (status.registryError) throw status.registryError;
342
+ const siblings = status.data.branches.filter(
343
+ (b) => b.registered && b.name !== excludeName,
344
+ );
345
+ return {
346
+ pending: {
347
+ total: siblings.length,
348
+ byKind: {
349
+ session: siblings.filter((b) => b.kind === "session").length,
350
+ task: siblings.filter((b) => b.kind === "task").length,
351
+ fix: siblings.filter((b) => b.kind === "fix").length,
352
+ },
353
+ stale: siblings.filter((b) => b.stale).length,
354
+ },
355
+ diags: [],
356
+ };
357
+ } catch {
358
+ return unreadable;
359
+ }
360
+ };
361
+
259
362
  for (let attempt = 1; attempt <= OPEN_MAX_ATTEMPTS; attempt++) {
260
363
  const name = formatFlowBranch({ kind: opts.kind as FlowBranchKind, date: now, seq, slug: opts.slug });
261
364
  // candidates gains each tried name so a collision retry picks the next NN.
@@ -270,6 +373,7 @@ export async function openFlowBranchCore(
270
373
  }
271
374
 
272
375
  if (opts.dryRun) {
376
+ const pending = await pendingSummary(name);
273
377
  return {
274
378
  repoKind: "governed",
275
379
  branch: name,
@@ -278,7 +382,9 @@ export async function openFlowBranchCore(
278
382
  baseSha,
279
383
  opened: false,
280
384
  setup: { status: "skipped", exitCode: null, stderrTail: "", stdout: "" },
281
- diagnostics: [],
385
+ primaryMutations,
386
+ pending: pending.pending,
387
+ diagnostics: [...dirtyPrimaryDiags, ...pending.diags],
282
388
  };
283
389
  }
284
390
 
@@ -311,7 +417,7 @@ export async function openFlowBranchCore(
311
417
  );
312
418
  }
313
419
  return refuse(
314
- "FLOW-OPEN-01",
420
+ "FLOW-OPEN-09",
315
421
  `git worktree add -b ${name} failed (exit ${add.exitCode}): ${add.stderr.trim()}`,
316
422
  "inspect the git error — a stale ref or lock may need cleanup",
317
423
  );
@@ -373,6 +479,7 @@ export async function openFlowBranchCore(
373
479
  ]
374
480
  : [];
375
481
 
482
+ const pending = await pendingSummary(name);
376
483
  return {
377
484
  repoKind: "governed",
378
485
  branch: name,
@@ -381,7 +488,14 @@ export async function openFlowBranchCore(
381
488
  baseSha,
382
489
  opened: true,
383
490
  setup,
384
- diagnostics: setupDiag,
491
+ primaryMutations,
492
+ pending: pending.pending,
493
+ diagnostics: [
494
+ ...dirtyPrimaryDiags,
495
+ ...pending.diags,
496
+ ...rerereDiags,
497
+ ...setupDiag,
498
+ ],
385
499
  };
386
500
  }
387
501
  return refuse(
@@ -426,6 +540,16 @@ export async function runFlowOpen(
426
540
  logger.info(` worktree: ${data.worktree}`);
427
541
  logger.info(` base: ${data.base} @ ${data.baseSha?.slice(0, 9)}`);
428
542
  logger.info(` setup: ${data.setup?.status ?? "skipped"}`);
543
+ for (const d of data.diagnostics) {
544
+ if (d.severity === "error") logger.error(` ${d.ruleId}: ${d.message}`);
545
+ else logger.warn(` ${d.ruleId}: ${d.message}`);
546
+ }
547
+ if (data.pending !== null && data.pending.total > 0) {
548
+ logger.info(
549
+ ` pending: ${data.pending.total} registered branch(es) — ` +
550
+ `${data.pending.stale} stale (>72h); inspect with flow.status`,
551
+ );
552
+ }
429
553
  }
430
554
  }
431
555
 
@@ -15,16 +15,6 @@ for both surfaces.</purpose>
15
15
  <item>Stray (RFC-1498): a local auto branch with no registry entry and no worktree checkout anywhere is exposed as unregisteredBranchesWithoutWorktree regardless of age — the leftover shape a failed branch -D leaves.</item>
16
16
  </KEY_DECISIONS>
17
17
  <CHANGE_SUMMARY>
18
- <item>RFC-1487: close rfc-1487 review findings — dirty-check parity with git worktree remove, ownership-verified lock release, FLOW-07 registry-error mapping, residual RFC-1462 docs removed
19
-
20
- The dirty gate for session worktrees now uses full porcelain status
21
- (untracked files included) because it predicts 'git worktree remove';
22
- the primary-clean gate keeps tracked-only semantics because it predicts
23
- 'merge --ff-only'. Lock release verifies the held payload before
24
- unlinking. Registry/journal failures map to FLOW-07 in every handler.
25
- The final branch-name collision reports FLOW-OPEN-04, flow.discard
26
- propagates its teardown result and predicts FLOW-DIS-03 on --dry-run,
27
- and integrate exposes teardown as its own field.</item>
28
18
  <item>RFC-1490: independent-review pass — lock-held planning, fix-branch verification, spec-shaped data, coverage</item>
29
19
  <item>RFC-1491: step 1 — journal base/rewrites + held registry widening, W1-1 discard tip, FLOW-INT-11</item>
30
20
  <item>RFC-1498: step 1 — FLOW-07 for stray auto branches
@@ -33,6 +23,8 @@ collectFlowStatus exposes unregisteredBranchesWithoutWorktree — local auto/* b
33
23
  <item>RFC-1498: step 2 — network-only marker source
34
24
 
35
25
  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>
26
+ <item>RFC-1515: harden forge flow worktree lifecycle against vanished paths, forge-local state, dead-holder locks and generated drift</item>
27
+ <item>RFC-1537: branches[].lastRefusal + derived orphaned flag — the newest integrate-refusal journal event per branch is the discoverable escape path after a refused flow.integrate</item>
36
28
  <history>RFC-1487</history>
37
29
  </CHANGE_SUMMARY>
38
30
  */
@@ -60,8 +52,10 @@ import {
60
52
  import {
61
53
  commonGitDir,
62
54
  FlowRegistrySchemaError,
55
+ readJournal,
63
56
  readRegistry,
64
57
  STALE_AFTER_HOURS,
58
+ type FlowJournalEvent,
65
59
  type FlowRegistryEntry,
66
60
  } from "../registry.ts";
67
61
  import { primaryWorktree } from "../worktree-path.ts";
@@ -72,6 +66,9 @@ export interface FlowBranchStatus {
72
66
  kind: "session" | "task" | "fix" | null;
73
67
  worktree: string | null;
74
68
  worktreeExists: boolean;
69
+ /** RFC-1515: a registered worktree path that is gone from disk — distinct
70
+ * from a null worktree (held entries legitimately have none). */
71
+ vanished: boolean;
75
72
  /** Tracked-modification count in the worktree; null when no worktree exists. */
76
73
  dirty: number | null;
77
74
  aheadOfDevelop: number | null;
@@ -82,6 +79,12 @@ export interface FlowBranchStatus {
82
79
  held: { heldAt: string; riskCategory: string; reason: string; tip: string } | null;
83
80
  /** Back-merge port payload when the entry is a port branch (RFC-1490). */
84
81
  port: { mainSha: string; tags: string[] } | null;
82
+ /** RFC-1537: newest journaled integrate refusal for this branch — the
83
+ * discoverable escape path after a refused flow.integrate. */
84
+ lastRefusal: { rule: string | null; at: string; summary: string } | null;
85
+ /** RFC-1537: the branch's newest journal event is an integrate refusal
86
+ * while the branch still exists — nothing reclaimed it since. */
87
+ orphaned: boolean;
85
88
  }
86
89
 
87
90
  export interface FlowStatusData {
@@ -123,14 +126,30 @@ export async function collectFlowStatus(
123
126
 
124
127
  const diagnostics: Diagnostic[] = [];
125
128
  const primary = await primaryWorktree(io, repoRoot);
126
- const [primaryBranch, primaryDirty, worktrees, local] = await Promise.all([
129
+ const [primaryBranch, primaryStatus, worktrees, local] = await Promise.all([
127
130
  currentBranch(primary, io),
128
131
  statusTracked(primary, io),
129
132
  worktreeList(repoRoot, io),
130
133
  listLocalBranches(repoRoot, io),
131
134
  ]);
135
+ const primaryDirty = primaryStatus.entries;
132
136
 
133
137
  const common = await commonGitDir(io, repoRoot);
138
+ // RFC-1537: journal is read-only here — a corrupt or unreadable journal
139
+ // degrades lastRefusal/orphaned to absent, never breaks status.
140
+ let journal: FlowJournalEvent[] = [];
141
+ try {
142
+ journal = await readJournal(io, common);
143
+ } catch {
144
+ journal = [];
145
+ }
146
+ // Append order keeps the newest event last — the last hit per branch wins.
147
+ const lastEventByBranch = new Map<string, FlowJournalEvent>();
148
+ const lastRefusalByBranch = new Map<string, FlowJournalEvent>();
149
+ for (const e of journal) {
150
+ lastEventByBranch.set(e.branch, e);
151
+ if (e.event === "integrate-refusal") lastRefusalByBranch.set(e.branch, e);
152
+ }
134
153
  let entries: FlowRegistryEntry[] = [];
135
154
  let registryError: FlowRegistrySchemaError | null = null;
136
155
  try {
@@ -189,7 +208,7 @@ export async function collectFlowStatus(
189
208
  behind = Number(behindStr) || 0;
190
209
  ahead = Number(aheadStr) || 0;
191
210
  }
192
- const dirty = worktreeExists ? (await statusDirty(worktree, io)).length : null;
211
+ const dirty = worktreeExists ? (await statusDirty(worktree, io)).entries.length : null;
193
212
 
194
213
  const held = entry?.held ?? null;
195
214
  let stale = false;
@@ -211,6 +230,7 @@ export async function collectFlowStatus(
211
230
  kind: entry?.kind ?? parseFlowBranch(name)?.kind ?? null,
212
231
  worktree,
213
232
  worktreeExists,
233
+ vanished: worktree !== null && !worktreeExists,
214
234
  dirty,
215
235
  aheadOfDevelop: ahead,
216
236
  behindDevelop: behind,
@@ -218,6 +238,13 @@ export async function collectFlowStatus(
218
238
  stale,
219
239
  held,
220
240
  port: entry?.port ?? null,
241
+ lastRefusal: (() => {
242
+ const r = lastRefusalByBranch.get(name);
243
+ return r === undefined
244
+ ? null
245
+ : { rule: r.rule ?? null, at: r.at, summary: r.detail };
246
+ })(),
247
+ orphaned: lastEventByBranch.get(name)?.event === "integrate-refusal",
221
248
  });
222
249
  }
223
250
 
@@ -267,8 +294,13 @@ export async function runFlowStatus(
267
294
  logger.info(
268
295
  b.held !== null
269
296
  ? ` ${b.name}: held (${b.held.riskCategory}): ${b.held.reason}`
270
- : ` ${b.name}: ${b.registered ? "registered" : "unregistered"}, worktree ${b.worktreeExists ? "present" : "absent"}, dirty ${b.dirty ?? "-"}, +${b.aheadOfDevelop ?? "-"}/-${b.behindDevelop ?? "-"}, stale ${b.stale}`,
297
+ : ` ${b.name}: ${b.registered ? "registered" : "unregistered"}, worktree ${b.worktreeExists ? "present" : b.vanished ? "vanished" : "absent"}, dirty ${b.dirty ?? "-"}, +${b.aheadOfDevelop ?? "-"}/-${b.behindDevelop ?? "-"}, stale ${b.stale}`,
271
298
  );
299
+ if (b.orphaned && b.lastRefusal !== null) {
300
+ logger.info(
301
+ ` └─ last integrate refused (${b.lastRefusal.rule ?? "unknown"}) at ${b.lastRefusal.at}: ${b.lastRefusal.summary}`,
302
+ );
303
+ }
272
304
  }
273
305
  for (const d of outcome.diagnostics) {
274
306
  logger.error(` ${d.ruleId}: ${d.message}`);
package/os/flow/index.ts CHANGED
@@ -15,11 +15,12 @@ reachable, else the version-file value.</purpose>
15
15
  <item>Untagged is not an error — it resolves to the version-file value; only a missing or unparsable version file throws.</item>
16
16
  </KEY_DECISIONS>
17
17
  <CHANGE_SUMMARY>
18
- <item>RFC-1493: step 1 — public os/flow export resolveRepositoryLineVersion</item>
19
18
  <item>RFC-1493: step 1 — forge public release-line version reader</item>
20
19
  <item>RFC-1494: step 1 — isFlowAdopted public export</item>
21
20
  <item>RFC-1495: step 1 - forge state roots</item>
22
21
  <item>RFC-1495: steps 2-3 - workshop paths resolver and call-site migration</item>
22
+ <item>RFC-1519: add advisory gate-verdict store for scoped pass reuse across reruns and the commit-integrate boundary</item>
23
+ <history>RFC-1493</history>
23
24
  </CHANGE_SUMMARY>
24
25
  */
25
26
 
@@ -39,6 +40,7 @@ import {
39
40
  // werkstatt.lock.recover build state paths and Forge must not import
40
41
  // @warpgogol/*). The engine's workshop-paths builds the names on top.
41
42
  export { primaryWorktree, resolveStateRoots, worktreeList };
43
+ export { FORGE_STATE_FILES } from "./git.ts";
42
44
  export type { StateRoots };
43
45
  export type { FlowWorktree } from "./git.ts";
44
46
 
@@ -18,6 +18,7 @@ re-reads the tag grammar itself.</purpose>
18
18
  <item>RFC-1493: step 1 — shared derived-version extraction consumed by flow.version and resolveRepositoryLineVersion</item>
19
19
  <item>RFC-1493: step 1 — forge public release-line version reader</item>
20
20
  <item>RFC-1493: step 2 — platform identity command, migrator-cursor pin comparison</item>
21
+ <item>RFC-1515: harden forge flow worktree lifecycle against vanished paths, forge-local state, dead-holder locks and generated drift</item>
21
22
  </CHANGE_SUMMARY>
22
23
  */
23
24
 
@@ -60,7 +61,7 @@ async function dirtyPaths(
60
61
  ): Promise<number> {
61
62
  let entries: string[];
62
63
  try {
63
- entries = await statusTracked(repoRoot, io);
64
+ entries = (await statusTracked(repoRoot, io)).entries;
64
65
  } catch {
65
66
  return 0;
66
67
  }
package/os/flow/locks.ts CHANGED
@@ -12,22 +12,15 @@ locks broken, always released in finally. Used for the short registry lock
12
12
  <KEY_DECISIONS>
13
13
  <item>Staleness reads the lock file's `at` timestamp, not mtime — a crashed holder leaves a frozen file whose content is authoritative (DNA-105).</item>
14
14
  <item>Timeout throws LockTimeoutError naming the file — each command maps it to its own diagnostic (FLOW-07 for the registry, FLOW-INT-08 for integrate).</item>
15
+ <item>Refused attempts render the last observed holder via describeHeldLock — the `stale` disposition is near-unreachable from withFlowLock (age-stale locks are broken before the deadline check) and exists for callers classifying a lock they never waited on (RFC-1515).</item>
15
16
  </KEY_DECISIONS>
16
17
  <CHANGE_SUMMARY>
17
- <item>RFC-1487: step 1 — exclusive file locks</item>
18
- <item>RFC-1487: step 1 — worktree path contracts, O_EXCL locks, branch registry and journal</item>
19
- <item>RFC-1487: close rfc-1487 review findings — dirty-check parity with git worktree remove, ownership-verified lock release, FLOW-07 registry-error mapping, residual RFC-1462 docs removed
20
-
21
- The dirty gate for session worktrees now uses full porcelain status
22
- (untracked files included) because it predicts 'git worktree remove';
23
- the primary-clean gate keeps tracked-only semantics because it predicts
24
- 'merge --ff-only'. Lock release verifies the held payload before
25
- unlinking. Registry/journal failures map to FLOW-07 in every handler.
26
- The final branch-name collision reports FLOW-OPEN-04, flow.discard
27
- propagates its teardown result and predicts FLOW-DIS-03 on --dry-run,
28
- and integrate exposes teardown as its own field.</item>
29
18
  <item>RFC-1504: steps 2-3 — holderIsDead, boot-id payload, dead-holder break in withFlowLock</item>
30
19
  <item>RFC-1504: review fixes — single io.readFile parse per iteration, real ageMs on dead-holder onStale, atomic break claim</item>
20
+ <item>RFC-1515: harden forge flow worktree lifecycle against vanished paths, forge-local state, dead-holder locks and generated drift</item>
21
+ <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>
22
+ <item>RFC-1515: record rfc-1515 review r1 fixes, key decisions and corrected probe path</item>
23
+ <history>RFC-1487</history>
31
24
  </CHANGE_SUMMARY>
32
25
  */
33
26
 
@@ -64,10 +57,18 @@ export interface FlowLockOptions {
64
57
  /** Thrown when the wait budget elapses while a live lock is held. */
65
58
  export class LockTimeoutError extends Error {
66
59
  readonly lockPath: string;
67
- constructor(lockPath: string, waitedMs: number) {
60
+ /** RFC-1515: last observed holder payload — absent when the lock file was
61
+ * unreadable or vanished between polls ("holder unknown"). */
62
+ readonly holder?: { pid: number; host?: string; at: string; bootId?: string };
63
+ constructor(
64
+ lockPath: string,
65
+ waitedMs: number,
66
+ holder?: { pid: number; host?: string; at: string; bootId?: string },
67
+ ) {
68
68
  super(`lock ${lockPath} still held after ${waitedMs} ms`);
69
69
  this.name = "LockTimeoutError";
70
70
  this.lockPath = lockPath;
71
+ this.holder = holder;
71
72
  }
72
73
  }
73
74
 
@@ -79,6 +80,43 @@ interface LockFileContent {
79
80
  bootId?: string;
80
81
  }
81
82
 
83
+ /** RFC-1515 AC-4: the holder payload a refused lock attempt renders. */
84
+ export interface HeldLockDiagnostic {
85
+ pid: number;
86
+ host?: string;
87
+ at: string;
88
+ /** ms since the holder's `at` — null when the timestamp never parsed. */
89
+ heldMs: number | null;
90
+ disposition: "live" | "dead-holder" | "stale";
91
+ }
92
+
93
+ /**
94
+ * Classify a refused attempt's last observed holder — `dead-holder` via the
95
+ * RFC-1504 classifier (dead pid on this host, or a foreign boot id), `stale`
96
+ * when the observed age exceeds the command's stale budget. The `stale` arm
97
+ * is near-unreachable from `withFlowLock` (age-stale locks are broken before
98
+ * the deadline check each poll) — it exists for callers classifying a lock
99
+ * they never waited on.
100
+ */
101
+ export function describeHeldLock(
102
+ holder: { pid: number; host?: string; at: string; bootId?: string },
103
+ staleMs: number,
104
+ ): HeldLockDiagnostic {
105
+ const heldAtMs = Date.parse(holder.at);
106
+ const heldMs = Number.isNaN(heldAtMs) ? null : Math.max(0, Date.now() - heldAtMs);
107
+ return {
108
+ pid: holder.pid,
109
+ host: holder.host,
110
+ at: holder.at,
111
+ heldMs,
112
+ disposition: holderIsDead(holder, currentBootId())
113
+ ? "dead-holder"
114
+ : heldMs !== null && heldMs > staleMs
115
+ ? "stale"
116
+ : "live",
117
+ };
118
+ }
119
+
82
120
  const defaultSleep = (ms: number): Promise<void> =>
83
121
  new Promise((resolve) => setTimeout(resolve, ms));
84
122
 
@@ -195,7 +233,11 @@ export async function withFlowLock<T>(
195
233
  continue;
196
234
  }
197
235
  if (now() >= deadline) {
198
- throw new LockTimeoutError(lockPath, now() - (deadline - opts.waitMs));
236
+ throw new LockTimeoutError(
237
+ lockPath,
238
+ now() - (deadline - opts.waitMs),
239
+ holder ?? undefined,
240
+ );
199
241
  }
200
242
  if (opts.progressEveryMs && now() >= nextProgress) {
201
243
  opts.onProgress?.(`waiting for ${lockPath}`);