@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
@@ -0,0 +1,279 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>docs.archive owner-regeneration (RFC-1528) — collect the generated artifacts
4
+ invalidated by archive moves and re-invoke their owner commands through
5
+ context.invoke. Owner selection is registry-driven: a command owns a generated
6
+ artifact when it declares it via generates[].path, or via a writes[] entry that
7
+ resolves to a generated file (marker, .generated. infix, or command:/generatedAt:
8
+ header convention — index.yaml/ecosystem.generated.yaml carry no GENERATED_MARKER
9
+ line). Manifest-generation logic itself is never duplicated here.</purpose>
10
+ <non-goals>
11
+ <item>No generation logic — owners are invoked by name through the kernel port.</item>
12
+ <item>Standalone forge CLI has no invoke port — degrade with a note, never block.</item>
13
+ </non-goals>
14
+ </MODULE_CONTRACT>
15
+ <CHANGE_SUMMARY>
16
+ <item>RFC-1528: docs.archive regenerates invalidated generated artifacts
17
+
18
+ After moves, invoke owner commands whose reads[] match a moved path via context.invoke (manifest generator last); report regenerated paths; degrade with a note without a kernel host.</item>
19
+ <item>RFC-1528: extract dry-run regen gate for AC-6 evidence
20
+
21
+ shouldRunArchiveRegen makes the report-only contract a tested unit instead of an inline closure check.</item>
22
+ <item>RFC-1528: close review findings — manifest-union command inventory for regen/preflight</item>
23
+ <item>F-0126: tighten owner predicate — generates[] or all-generated writes[]; required flags must be REGEN_FLAGS-covered; excluded[] diagnostics</item>
24
+ <item>RFC-1528: exclude non-generator commands from docs.archive owner regen (F-0126)</item>
25
+ <item>RFC-1535: stageMovedPairs — self-staging helper for move pairs (F-0038)</item>
26
+ <history>RFC-1528</history>
27
+ </CHANGE_SUMMARY>
28
+ */
29
+
30
+ import { existsSync, readFileSync } from "node:fs";
31
+ import path from "node:path";
32
+ import picomatch from "picomatch";
33
+ import { hasGeneratedMarker } from "../../src/utils/generated-marker.ts";
34
+ import { loadLiveCommandInventory } from "../../src/utils/command-inventory.ts";
35
+ import type {
36
+ ExecResult,
37
+ ForgeFlagValue,
38
+ ForgeRegisteredCommandInfo,
39
+ ForgeRuntimeContext,
40
+ } from "../../src/types.ts";
41
+
42
+ /** Per-owner flag overrides — generator commands that persist only under a flag. */
43
+ export const REGEN_FLAGS: Record<string, Record<string, ForgeFlagValue>> = {
44
+ "rfc.index.generate": { write: true },
45
+ };
46
+
47
+ /**
48
+ * Ordering contract: ecosystem.manifest.generate hashes the other generated
49
+ * artifacts, so it always runs last among the invalidated owners.
50
+ */
51
+ const MANIFEST_GENERATOR = "ecosystem.manifest.generate";
52
+
53
+ /** The invoking command can never be its own regen owner. */
54
+ const SELF_COMMAND = "docs.archive";
55
+
56
+ export interface ArchiveRegenCandidate {
57
+ command: string;
58
+ flags: Record<string, ForgeFlagValue>;
59
+ artifactPaths: string[];
60
+ }
61
+
62
+ export interface ArchiveRegenOutcome {
63
+ /** Workspace-relative paths owner invokes reported as modified. */
64
+ regenerated: string[];
65
+ /** Owner commands invoked. */
66
+ invoked: string[];
67
+ /** Candidate owners skipped because context.invoke is absent. */
68
+ skipped: string[];
69
+ /** Per-owner failures — reported, never fatal to the archive run. */
70
+ failures: Array<{ command: string; error: string }>;
71
+ /** Reads-matched commands excluded from ownership (F-0126 diagnostics). */
72
+ excluded: Array<{ command: string; reason: RegenExcludeReason }>;
73
+ /** Why regen did not invoke, when it did not invoke at all. */
74
+ skipReason: "no-invoke" | "no-inventory" | null;
75
+ }
76
+
77
+ /** Generated-by-name: the `.generated.` infix convention (ecosystem.generated.yaml). */
78
+ export function isGeneratedPathName(relPath: string): boolean {
79
+ return path.basename(relPath).includes(".generated.");
80
+ }
81
+
82
+ /**
83
+ * Generated-by-content: GENERATED_MARKER/EDITABLE_GENERATED_MARKER, or the
84
+ * self-describing YAML header (`command:` + `generatedAt:`) emitted by the
85
+ * manifest family of generators (docs/rfcs/index.yaml carries no marker line).
86
+ */
87
+ export function isGeneratedContent(content: string): boolean {
88
+ if (hasGeneratedMarker(content)) return true;
89
+ const head = content
90
+ .split("\n")
91
+ .filter((line) => line.trim().length > 0)
92
+ .slice(0, 10);
93
+ return (
94
+ head.some((line) => /^command:\s*\S/.test(line)) &&
95
+ head.some((line) => /^generatedAt:/.test(line))
96
+ );
97
+ }
98
+
99
+ /** Workspace-backed probe for declared writes[] paths. */
100
+ export function generatedPathProbe(workspaceRoot: string): (relPath: string) => boolean {
101
+ return (relPath) => {
102
+ if (isGeneratedPathName(relPath)) return true;
103
+ if (relPath.includes("*")) return false;
104
+ const abs = path.join(workspaceRoot, relPath);
105
+ if (!existsSync(abs)) return false;
106
+ try {
107
+ return isGeneratedContent(readFileSync(abs, "utf8"));
108
+ } catch {
109
+ return false;
110
+ }
111
+ };
112
+ }
113
+
114
+ /** Why a reads-matched command was excluded from owner selection (F-0126). */
115
+ export type RegenExcludeReason = "mixed-writes" | "required-flags";
116
+
117
+ export interface ArchiveRegenSelection {
118
+ candidates: ArchiveRegenCandidate[];
119
+ /**
120
+ * Commands whose reads[] intersected a moved path but that cannot act as
121
+ * regen owners — diagnostics only, never invoked.
122
+ */
123
+ excluded: Array<{ command: string; reason: RegenExcludeReason }>;
124
+ }
125
+
126
+ /**
127
+ * Pure selection: owners whose declared generated artifacts are invalidated by
128
+ * the moved paths — i.e. the command reads at least one glob matching a moved
129
+ * from/to path. Order: registry order with ecosystem.manifest.generate last.
130
+ *
131
+ * F-0126 ownership contract: a mutator that emits generated side-artifacts
132
+ * among hand-authored writes (e.g. rfc.implement.stamp writing verification
133
+ * envelopes alongside docs/rfcs/**\/*.md) is not a regen owner — ownership
134
+ * requires an explicit generates[] declaration or a fully generated writes[]
135
+ * surface. Batch regen invokes owners bare, so any required flag not covered
136
+ * by REGEN_FLAGS excludes the command outright.
137
+ */
138
+ export function collectInvalidatedGenerators(
139
+ movedPaths: string[],
140
+ commands: ForgeRegisteredCommandInfo[],
141
+ isGeneratedPath: (relPath: string) => boolean,
142
+ ): ArchiveRegenSelection {
143
+ const candidates: ArchiveRegenCandidate[] = [];
144
+ const excluded: ArchiveRegenSelection["excluded"] = [];
145
+ for (const command of commands) {
146
+ if (command.name === SELF_COMMAND) continue;
147
+ const writes = command.writes ?? [];
148
+ const generatedWrites = writes.filter((w) => isGeneratedPath(w));
149
+ const declared = (command.generates ?? []).map((g) => g.path);
150
+ if (declared.length === 0 && generatedWrites.length === 0) continue;
151
+ const reads = command.reads ?? [];
152
+ const invalidated = movedPaths.some((moved) =>
153
+ reads.some((glob) => picomatch.isMatch(moved, glob)),
154
+ );
155
+ if (!invalidated) continue;
156
+ if (declared.length === 0 && generatedWrites.length !== writes.length) {
157
+ excluded.push({ command: command.name, reason: "mixed-writes" });
158
+ continue;
159
+ }
160
+ const flags = REGEN_FLAGS[command.name] ?? {};
161
+ const uncoveredRequired = Object.entries(command.flags ?? {}).some(
162
+ ([flagName, spec]) => spec?.required === true && !(flagName in flags),
163
+ );
164
+ if (uncoveredRequired) {
165
+ excluded.push({ command: command.name, reason: "required-flags" });
166
+ continue;
167
+ }
168
+ candidates.push({
169
+ command: command.name,
170
+ flags,
171
+ artifactPaths: [...declared, ...generatedWrites],
172
+ });
173
+ }
174
+ return {
175
+ candidates: candidates.sort((a, b) => {
176
+ if (a.command === MANIFEST_GENERATOR) return 1;
177
+ if (b.command === MANIFEST_GENERATOR) return -1;
178
+ return 0;
179
+ }),
180
+ excluded,
181
+ };
182
+ }
183
+
184
+ /**
185
+ * AC-6 gate: owner regeneration fires only on a real run that moved files —
186
+ * a `--dry-run` docs.archive is report-only and never invokes generators.
187
+ */
188
+ export function shouldRunArchiveRegen(dryRun: boolean, totalMoved: number): boolean {
189
+ return !dryRun && totalMoved > 0;
190
+ }
191
+
192
+ /**
193
+ * Invoke seam: run each invalidated owner through context.invoke. Absent invoke
194
+ * (standalone forge CLI) → all candidates skipped with a note, never a crash.
195
+ */
196
+ export async function runArchiveRegen(options: {
197
+ movedPaths: string[];
198
+ context: ForgeRuntimeContext;
199
+ isGeneratedPath?: (relPath: string) => boolean;
200
+ /** Test seam — overrides the live inventory union (registry + command manifest). */
201
+ commands?: ForgeRegisteredCommandInfo[];
202
+ }): Promise<ArchiveRegenOutcome> {
203
+ const { movedPaths, context } = options;
204
+ const commands =
205
+ options.commands ?? loadLiveCommandInventory(context.workspaceRoot, context.commandRegistry);
206
+ const probe = options.isGeneratedPath ?? generatedPathProbe(context.workspaceRoot);
207
+ const { candidates, excluded } = collectInvalidatedGenerators(movedPaths, commands, probe);
208
+ const outcome: ArchiveRegenOutcome = {
209
+ regenerated: [],
210
+ invoked: [],
211
+ skipped: [],
212
+ failures: [],
213
+ excluded,
214
+ skipReason: null,
215
+ };
216
+
217
+ if (!context.invoke || commands.length === 0) {
218
+ outcome.skipped = candidates.map((c) => c.command);
219
+ outcome.skipReason = !context.invoke ? "no-invoke" : "no-inventory";
220
+ return outcome;
221
+ }
222
+
223
+ for (const candidate of candidates) {
224
+ try {
225
+ const result = await context.invoke(candidate.command, candidate.flags);
226
+ if (result.ok === false || (result.exitCode !== undefined && result.exitCode !== 0)) {
227
+ outcome.failures.push({
228
+ command: candidate.command,
229
+ error: result.summary ?? `exit code ${result.exitCode}`,
230
+ });
231
+ continue;
232
+ }
233
+ outcome.invoked.push(candidate.command);
234
+ // Prefer the child's reported writes; fall back to the invalidated
235
+ // declared paths so `regenerated` always names what refreshed (AC-7).
236
+ const reported =
237
+ result.filesModified && result.filesModified.length > 0
238
+ ? result.filesModified
239
+ : candidate.artifactPaths.filter((p) => !p.includes("*"));
240
+ for (const modified of reported) {
241
+ if (!outcome.regenerated.includes(modified)) outcome.regenerated.push(modified);
242
+ }
243
+ } catch (error) {
244
+ outcome.failures.push({
245
+ command: candidate.command,
246
+ error: error instanceof Error ? error.message : String(error),
247
+ });
248
+ }
249
+ }
250
+ return outcome;
251
+ }
252
+
253
+ /**
254
+ * RFC-1535 (F-0038): self-staging — every moved pair lands BOTH sides in the
255
+ * index (destination add + source delete) so the next commit captures the
256
+ * move as one unit instead of a split add/delete across two commits.
257
+ * `git add -A` on the union of moved from/to paths covers both sides; a
258
+ * non-git or already-clean tree degrades to a warn-only outcome — the
259
+ * commit-side EC-31 check is the safety net for any half-staged survivor.
260
+ */
261
+ export async function stageMovedPairs(options: {
262
+ movedPaths: string[];
263
+ workspaceRoot: string;
264
+ exec: (command: string, args: string[], opts?: { cwd?: string }) => Promise<ExecResult>;
265
+ }): Promise<{ staged: number; error?: string }> {
266
+ const { movedPaths, workspaceRoot, exec } = options;
267
+ if (movedPaths.length === 0) return { staged: 0 };
268
+ try {
269
+ const result = await exec("git", ["add", "-A", "--", ...movedPaths], {
270
+ cwd: workspaceRoot,
271
+ });
272
+ if (result.exitCode !== 0) {
273
+ return { staged: 0, error: result.stderr || `git add exit ${result.exitCode}` };
274
+ }
275
+ return { staged: movedPaths.length };
276
+ } catch (error) {
277
+ return { staged: 0, error: error instanceof Error ? error.message : String(error) };
278
+ }
279
+ }
@@ -6,12 +6,15 @@
6
6
  </non-goals>
7
7
  </MODULE_CONTRACT>
8
8
  <CHANGE_SUMMARY>
9
- <item>RFC-1461: declare rules[] severity via CommandRuleDecl workspace-wide (RFC-1461)</item>
10
- <item>RFC-1500: step 2 — forge.create adopts the fixed branch model</item>
11
- <item>RFC-1505: review r1 — durable projections and lockfile restore hardening</item>
12
- <item>RFC-1505: review r2 — clone-only sternsystem enumeration and mission-gated lockfile net</item>
13
- <item>RFC-1508: implement RFC-1508 — system profile, system map schemas and system.map.validate</item>
14
- <history>ADR-0021, RFC-0374, RFC-0521, RFC-0539, RFC-0542, RFC-0543, RFC-0544, RFC-0546, RFC-0640, RFC-0662, RFC-0674, RFC-0678, RFC-0679, RFC-0680, RFC-0711, RFC-0733, RFC-0877, RFC-0940, RFC-1080, RFC-1088, RFC-1089, RFC-1097, RFC-1173, RFC-1230, RFC-1231, RFC-1235, RFC-1248, RFC-1251, RFC-1254, RFC-1255, RFC-1351, RFC-1354, RFC-1360, RFC-1366</history>
9
+ <item>RFC-1528: extract dry-run regen gate for AC-6 evidence
10
+
11
+ shouldRunArchiveRegen makes the report-only contract a tested unit instead of an inline closure check.</item>
12
+ <item>RFC-1528: close review findings — manifest-union command inventory for regen/preflight</item>
13
+ <item>RFC-1528: note moved[] under-count on archiver throw (review F-10)</item>
14
+ <item>RFC-1528: exclude non-generator commands from docs.archive owner regen (F-0126)</item>
15
+ <item>RFC-1536: owning-checkout routing, FLOW-OPEN-01 dirty-primary warning, shared governance-id allocation (RFC+ADR)</item>
16
+ <item>RFC-1535: docs.archive self-stages both sides of every move pair — no half-staged EC-31 pairs (F-0038)</item>
17
+ <history>ADR-0021, RFC-0374, RFC-0521, RFC-0539, RFC-0542, RFC-0543, RFC-0544, RFC-0546, RFC-0640, RFC-0662, RFC-0674, RFC-0678, RFC-0679, RFC-0680, RFC-0711, RFC-0733, RFC-0877, RFC-0940, RFC-1080, RFC-1088, RFC-1089, RFC-1097, RFC-1173, RFC-1230, RFC-1231, RFC-1235, RFC-1248, RFC-1251, RFC-1254, RFC-1255, RFC-1351, RFC-1354, RFC-1360, RFC-1366, RFC-1461, RFC-1500, RFC-1505, RFC-1508, RFC-1517, RFC-1518, RFC-1522, RFC-1528</history>
15
18
  </CHANGE_SUMMARY>
16
19
  */
17
20
 
@@ -23,10 +26,7 @@ import type {
23
26
  ForgeRuntimeContext,
24
27
  } from "../../src/types.ts";
25
28
  import path from "node:path";
26
- import {
27
- restoreTrackedLockfile,
28
- execFileSyncAdapter,
29
- } from "../mission/lockfile.ts";
29
+ import { restoreTrackedLockfile, execFileSyncAdapter } from "../mission/lockfile.ts";
30
30
  import { writeFileIfChanged } from "../../src/utils/fs-idempotent.ts";
31
31
  import {
32
32
  FORGE_SKILLS,
@@ -35,6 +35,8 @@ import {
35
35
  type PackSkillEntry,
36
36
  } from "../../src/registry.ts";
37
37
  import { loadForgeConfig } from "../../src/config/forge-config.ts";
38
+ import { resolveIo } from "../../src/utils/io.ts";
39
+ import { resolveOwningCheckout } from "../flow/session-checkout.ts";
38
40
 
39
41
  export async function createForgeCoreModule(): Promise<ForgeModule> {
40
42
  const { runScaffold } = await import("../../src/onboarding/scaffold.ts");
@@ -262,7 +264,7 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
262
264
  coverage: "operator" as const,
263
265
  mutatesState: true,
264
266
  writes: ["packages/forge/skills/**", "packages/forge/os/**"],
265
- generates: [],
267
+ generates: [],
266
268
  description: "Generate a skeleton for a new forge skill or command.",
267
269
  scope: "workspace",
268
270
  acceptsAllFlag: false,
@@ -333,7 +335,7 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
333
335
  coverageNote: "agent memory compaction",
334
336
  mutatesState: true,
335
337
  writes: [".agents/memory/MEMORY.md"],
336
- generates: [],
338
+ generates: [],
337
339
  description:
338
340
  "Enforce the MEMORY.md character budget by removing oldest Environment notes bullets (RFC-1151).",
339
341
  scope: "workspace",
@@ -377,7 +379,7 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
377
379
  coverage: "operator" as const,
378
380
  mutatesState: true,
379
381
  writes: ["**"],
380
- generates: [],
382
+ generates: [],
381
383
  execOnReadOnly: true,
382
384
  description:
383
385
  "Create a working pnpm + Turborepo monorepo from a stack profile in an empty directory. Required flags: `--profile`, `--name`.",
@@ -403,7 +405,7 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
403
405
  name: "forge.create",
404
406
  mutatesState: true,
405
407
  writes: ["**"],
406
- generates: [],
408
+ generates: [],
407
409
  execOnReadOnly: true,
408
410
  description:
409
411
  "Create a forge project in-place: scaffold + init + binding defaults. The target directory must be empty (only .git/ tolerated). Usage: forge create --in-place --profile <profile-id> [--name <name>] [--package-manager pnpm]",
@@ -453,7 +455,7 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
453
455
  name: "forge.init",
454
456
  mutatesState: true,
455
457
  writes: ["forge.yaml", "PREFERENCES.md", ".agents/skills/**"],
456
- generates: [],
458
+ generates: [],
457
459
  description:
458
460
  "Deploy forge into a project: create forge.yaml, PREFERENCES.md, copy skills, create docs dirs. Hidden recovery command — normally called by forge.create.",
459
461
  scope: "workspace",
@@ -685,7 +687,15 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
685
687
  execute: runReleasePrepare,
686
688
  },
687
689
  {
688
- envInputs: [{ name: "R2_AXIOM_ACCESS_KEY_ID", required: false }, { name: "R2_AXIOM_ACCOUNT_ID", required: false }, { name: "R2_AXIOM_SECRET_ACCESS_KEY", required: false }, { name: "S3_ACCESS_KEY_ID", required: false }, { name: "S3_BUCKET", required: false }, { name: "S3_ENDPOINT", required: false }, { name: "S3_SECRET_ACCESS_KEY", required: false }],
690
+ envInputs: [
691
+ { name: "R2_AXIOM_ACCESS_KEY_ID", required: false },
692
+ { name: "R2_AXIOM_ACCOUNT_ID", required: false },
693
+ { name: "R2_AXIOM_SECRET_ACCESS_KEY", required: false },
694
+ { name: "S3_ACCESS_KEY_ID", required: false },
695
+ { name: "S3_BUCKET", required: false },
696
+ { name: "S3_ENDPOINT", required: false },
697
+ { name: "S3_SECRET_ACCESS_KEY", required: false },
698
+ ],
689
699
  name: "forge.release.publish",
690
700
  coverage: "operator" as const,
691
701
  coverageNote: "forge release publish step",
@@ -828,8 +838,15 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
828
838
  description:
829
839
  "Validate all published packages (private: false) for standalone extraction readiness. " +
830
840
  "Checks engines.node, embedded .github/workflows/ci.yml, extract.config.yaml, " +
831
- "devDependencies completeness (no hoisted tool deps), and per-package lint-surface " +
832
- "(extractable packages run their own lint contract). " +
841
+ "devDependencies completeness (no hoisted tool deps), per-package lint-surface " +
842
+ "(extractable packages run their own lint contract), and PKG-HEALTH-10 " +
843
+ "fixture-path scan — shipped ../ literals must resolve inside the package " +
844
+ 'root (same-line "// pkg-health-10:" or pkgHealth10Suppressions in ' +
845
+ "extract.config.yaml), and the RFC-1518 docs-drift gate: PKG-HEALTH-11 " +
846
+ "(registered command absent from the package DOCS_SURFACE) and " +
847
+ "PKG-HEALTH-12 (dead x.y doc tokens) — same-line " +
848
+ '"<!-- pkg-health-11|pkg-health-12: <reason> -->" markers journal ' +
849
+ "intentional exceptions. " +
833
850
  "Exits non-zero on errors. Use --json for machine-readable output.",
834
851
  scope: "workspace",
835
852
  acceptsAllFlag: false,
@@ -871,7 +888,13 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
871
888
  "Enforces SURFACE-01..05 rules: README length, Node version match, " +
872
889
  "no .tgz in root, docs/ structure, required root files (RFC-1080).",
873
890
  contract: "forge",
874
- rules: [{ id: "SURFACE-01", severity: "error" }, { id: "SURFACE-02", severity: "error" }, { id: "SURFACE-03", severity: "error" }, { id: "SURFACE-04", severity: "error" }, { id: "SURFACE-05", severity: "error" }],
891
+ rules: [
892
+ { id: "SURFACE-01", severity: "error" },
893
+ { id: "SURFACE-02", severity: "error" },
894
+ { id: "SURFACE-03", severity: "error" },
895
+ { id: "SURFACE-04", severity: "error" },
896
+ { id: "SURFACE-05", severity: "error" },
897
+ ],
875
898
  scope: "workspace",
876
899
  acceptsAllFlag: false,
877
900
  reads: ["README.md", "package.json", "docs/**"],
@@ -913,6 +936,9 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
913
936
  "audit.archive, session.archive, and mission.archive in sequence. " +
914
937
  "Passes --dry-run and --status through to all sub-commands. Not atomic " +
915
938
  "— if one sub-command fails, prior moves are not rolled back. " +
939
+ "After the moves, re-invokes the owner generator of every generated " +
940
+ "artifact invalidated by them (manifest last) through the kernel " +
941
+ "invoke port and reports the regenerated paths (RFC-1528). " +
916
942
  "Re-running is safe (idempotent).",
917
943
  scope: "workspace",
918
944
  mutatesState: true,
@@ -931,6 +957,10 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
931
957
  "missions/archive/**",
932
958
  "docs/specs/live/*.md",
933
959
  "pnpm-lock.yaml",
960
+ // RFC-1528: owner-regen writes the generated artifacts invalidated by
961
+ // the moves (via context.invoke — never duplicated generator logic).
962
+ "docs/ecosystem.generated.yaml",
963
+ "docs/rfcs/index.yaml",
934
964
  ],
935
965
  generates: [],
936
966
  reads: [
@@ -955,6 +985,31 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
955
985
  },
956
986
  execute: async (input, context) => {
957
987
  const { logger, outputFormat } = context;
988
+
989
+ // RFC-1536: route the moves to the owning checkout — a docs.archive
990
+ // run from the primary cwd moves files inside the registered
991
+ // session worktree (or refuses when none is attributable).
992
+ const io = resolveIo(context.io);
993
+ const owning = await resolveOwningCheckout(io, context.workspaceRoot);
994
+ if (!owning.ok) {
995
+ throw new Error(
996
+ `SESSION-WRITE-01: ${owning.reason} — candidates: ${owning.candidates.join(", ")}. ` +
997
+ `Fix: open a session worktree with 'pnpm exec forge flow.open --kind session --slug <slug>' and archive there.`,
998
+ );
999
+ }
1000
+ for (const warning of owning.warnings) {
1001
+ logger.warn(`docs.archive: ${warning}`);
1002
+ }
1003
+ const routedContext =
1004
+ owning.checkout.kind === "worktree" && owning.checkout.worktreePath
1005
+ ? { ...context, workspaceRoot: owning.checkout.worktreePath }
1006
+ : context;
1007
+ if (routedContext !== context && outputFormat === "pretty") {
1008
+ logger.info(
1009
+ `docs.archive: routed into worktree ${routedContext.workspaceRoot} (branch ${owning.checkout.sessionBranch})`,
1010
+ );
1011
+ }
1012
+
958
1013
  const dryRun = context.dryRun || input.flags["dry-run"] === true;
959
1014
  const results: Record<string, unknown> = {};
960
1015
  let totalMoved = 0;
@@ -983,7 +1038,7 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
983
1038
 
984
1039
  for (const { name: cmdName, fn } of subCommands) {
985
1040
  try {
986
- const result = await fn(input, context);
1041
+ const result = await fn(input, routedContext);
987
1042
  const data = (result as { data?: { moved?: unknown[]; skipped?: unknown[] } })?.data;
988
1043
  if (data) {
989
1044
  totalMoved += Array.isArray(data.moved) ? data.moved.length : 0;
@@ -1009,7 +1064,7 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
1009
1064
  formatLiveMergeFailure,
1010
1065
  buildLiveMergeBlock,
1011
1066
  } = await import("../spec/live-spec-shared.ts");
1012
- const rfcDirPath = path.join(context.workspaceRoot, RFC_DIR);
1067
+ const rfcDirPath = path.join(routedContext.workspaceRoot, RFC_DIR);
1013
1068
  const rfcArchiveData = results["rfc.archive"] as
1014
1069
  | {
1015
1070
  moved?: Array<{
@@ -1114,15 +1169,11 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
1114
1169
  // lockfile; gating on them alone means an rfc/adr/plan-only archive run
1115
1170
  // never touches a locally edited pnpm-lock.yaml. Restore HEAD bytes
1116
1171
  // instead of staging — mission churn is never committed.
1117
- const missionData = results["mission.archive"] as
1118
- | { moved?: unknown[] }
1119
- | undefined;
1120
- const missionMoved = Array.isArray(missionData?.moved)
1121
- ? missionData.moved.length
1122
- : 0;
1172
+ const missionData = results["mission.archive"] as { moved?: unknown[] } | undefined;
1173
+ const missionMoved = Array.isArray(missionData?.moved) ? missionData.moved.length : 0;
1123
1174
  if (!dryRun && missionMoved > 0) {
1124
1175
  try {
1125
- const restored = await restoreTrackedLockfile(context.workspaceRoot, {
1176
+ const restored = await restoreTrackedLockfile(routedContext.workspaceRoot, {
1126
1177
  ...execFileSyncAdapter(),
1127
1178
  writeFile: async (target, content) => {
1128
1179
  await writeFileIfChanged(target, content);
@@ -1140,6 +1191,96 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
1140
1191
  }
1141
1192
  }
1142
1193
 
1194
+ // ── RFC-1528: owner-regen — every generated artifact whose owner
1195
+ // reads a moved path is re-invoked through context.invoke (AC-1/6/7).
1196
+ // Runs after the lockfile safety net; absent invoke degrades with a
1197
+ // note, never blocks. Owner failure → diagnostics + non-zero exit. ──
1198
+ let regenerated: string[] = [];
1199
+ let regenSkipped: string[] = [];
1200
+ let regenExcluded: Array<{ command: string; reason: string }> = [];
1201
+ let regenFailures: Array<{ command: string; error: string }> = [];
1202
+ const { shouldRunArchiveRegen, runArchiveRegen, stageMovedPairs } = await import(
1203
+ "./archive-regen.ts"
1204
+ );
1205
+ if (shouldRunArchiveRegen(dryRun, totalMoved)) {
1206
+ const movedPaths = new Set<string>();
1207
+ for (const data of Object.values(results)) {
1208
+ // An archiver that threw records `{error}` with no moved[] — the
1209
+ // regen set under-counts its partial moves (pre-existing shape).
1210
+ const moved = (data as { moved?: Array<Record<string, unknown>> })?.moved;
1211
+ if (!Array.isArray(moved)) continue;
1212
+ for (const entry of moved) {
1213
+ for (const key of ["from", "to", "file"] as const) {
1214
+ const value = entry[key];
1215
+ if (typeof value === "string" && value.length > 0) movedPaths.add(value);
1216
+ }
1217
+ }
1218
+ }
1219
+ const regen = await runArchiveRegen({ movedPaths: [...movedPaths], context: routedContext });
1220
+ regenerated = regen.regenerated;
1221
+ regenFailures = regen.failures;
1222
+ regenSkipped = regen.skipped;
1223
+ regenExcluded = regen.excluded;
1224
+ if (outputFormat === "pretty") {
1225
+ for (const regeneratedPath of regenerated) {
1226
+ logger.info(` docs.archive: regenerated ${regeneratedPath}`);
1227
+ }
1228
+ for (const item of regenExcluded) {
1229
+ logger.info(` docs.archive: regen excluded ${item.command} (${item.reason})`);
1230
+ }
1231
+ if (regen.skipReason === "no-invoke") {
1232
+ logger.info(" docs.archive: regen skipped — no invoke port (standalone CLI)");
1233
+ } else if (regen.skipReason === "no-inventory") {
1234
+ logger.info(" docs.archive: regen skipped — no command inventory");
1235
+ }
1236
+ for (const failure of regenFailures) {
1237
+ logger.error(
1238
+ ` docs.archive: regen failed for ${failure.command}: ${failure.error}`,
1239
+ );
1240
+ }
1241
+ }
1242
+ }
1243
+
1244
+ // RFC-1535 (F-0038): self-staging — every move lands BOTH sides in
1245
+ // the index (destination add + source delete) so the next commit
1246
+ // captures the move as one unit instead of splitting it across two
1247
+ // commits. --dry-run stays report-only: nothing is staged.
1248
+ let stagedMovePairs = 0;
1249
+ if (!dryRun && totalMoved > 0) {
1250
+ const stagePaths = new Set<string>();
1251
+ for (const data of Object.values(results)) {
1252
+ const moved = (data as { moved?: Array<Record<string, unknown>> })?.moved;
1253
+ if (!Array.isArray(moved)) continue;
1254
+ for (const entry of moved) {
1255
+ for (const key of ["from", "to"] as const) {
1256
+ const value = entry[key];
1257
+ if (typeof value === "string" && value.length > 0) stagePaths.add(value);
1258
+ }
1259
+ }
1260
+ }
1261
+ const staged = await stageMovedPairs({
1262
+ movedPaths: [...stagePaths],
1263
+ workspaceRoot: routedContext.workspaceRoot,
1264
+ exec: (command, args, opts) => io.exec(command, args, opts),
1265
+ });
1266
+ if (staged.error) {
1267
+ // Non-fatal — the commit-side EC-31 check is the safety net
1268
+ // for any pair that stayed half-staged.
1269
+ if (outputFormat === "pretty") {
1270
+ logger.warn(
1271
+ ` docs.archive: move staging failed — run 'git add -A docs/' before committing: ${staged.error}`,
1272
+ );
1273
+ }
1274
+ } else if (staged.staged > 0) {
1275
+ stagedMovePairs = staged.staged;
1276
+ if (outputFormat === "pretty") {
1277
+ logger.info(
1278
+ ` docs.archive: staged ${staged.staged} move path(s) (both sides)`,
1279
+ );
1280
+ }
1281
+ }
1282
+ }
1283
+
1143
1284
  if (outputFormat === "pretty") {
1144
1285
  if (dryRun) {
1145
1286
  logger.info(
@@ -1153,9 +1294,10 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
1153
1294
  }
1154
1295
 
1155
1296
  return {
1297
+ ...(regenFailures.length > 0 ? { exitCode: 1 } : {}),
1156
1298
  data: {
1157
1299
  command: "docs.archive",
1158
- status: "ok",
1300
+ status: regenFailures.length > 0 ? "fail" : "ok",
1159
1301
  totalMoved,
1160
1302
  totalSkipped,
1161
1303
  results,
@@ -1163,6 +1305,11 @@ export async function createForgeCoreModule(): Promise<ForgeModule> {
1163
1305
  liveSpecMerges: liveMergeResults.length,
1164
1306
  liveSpecSkipped: liveMergeSkipped,
1165
1307
  liveSpecFailures: liveMergeFailures.length,
1308
+ regenerated,
1309
+ regenSkipped,
1310
+ regenExcluded,
1311
+ regenFailures,
1312
+ stagedMovePairs,
1166
1313
  },
1167
1314
  summary: dryRun
1168
1315
  ? `[dry-run] Would move ${totalMoved} file(s), skip ${totalSkipped}`