@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
@@ -12,28 +12,13 @@ a JSON evidence envelope to docs/rfcs/verification/<slug>.generated.yaml.
12
12
  </non-goals>
13
13
  </MODULE_CONTRACT>
14
14
  <CHANGE_SUMMARY>
15
- <item>RFC-1391: unblock evidence emission for proof-probe RFCs (RFC-1391)
16
-
17
- probeArtifactCandidates lacked a `proof` branch — the default threw
18
- EVIDENCE-FRESH-03, so rfc.verification.emit could never produce an
19
- envelope for any RFC declaring `probe: proof`. The IMP-13 remediation
20
- path was dead end-to-end. A proof probe executes the checker live and
21
- carries no generated dependency — same mapping as run/test/page.
22
-
23
- Found by the independent acceptance verifier (rfc-1391 r0, CX-1).</item>
24
- <item>RFC-1391: close RFC-1391 review r1 findings — evidence freshness, config classification, contract guards
25
-
26
- REVIEW-CODE-2026-10-24-04 (warning): a stale .cache/proofs report could
27
- fabricate proved; forge.yaml now resolves inside runProofCheck so a malformed
28
- config is error not unavailable, and both surfaces share one path; {entry} is
29
- required in formal.tools.command; spec/entry paths are confined to the
30
- workspace; the exhaustive entry dispatches per packageManager; proved runs
31
- record log, counterexample stays the refuted-path record.</item>
32
15
  <item>RFC-1453: executed outcome probes, IMP-14 surface gate, outcome.serve + V-47/V-48</item>
33
16
  <item>RFC-1458: emit requirement-mapped verdict events from deploy.smoke.run</item>
34
17
  <item>RFC-1489: batch test probes through one instrumented Vitest run + frontmatter corpus reads
35
18
 
36
19
  runProbeSet is the single shared execution point: barrier-free segments of test probes sharing one effective bound run in one vitest --reporter=json --outputFile process with per-(file,testName) attribution; missing files/reports yield unverified. run/page/proof and all non-test kinds are barriers. --no-batch escapes to the legacy path on acceptance.run, verification.emit and verification.refresh. rfc.validate reads non-target corpus files frontmatter-only via readRfcFrontmatter (64 KiB bound, full-parse fallback); emit/refresh/acceptance corpus scans use the same accessor. Corpus map slimmed to RfcCorpusEntry {fileName, frontmatter}.</item>
20
+ <item>RFC-1516: add an evidence-freshness window to the stamp-sync chain for rfc-1516</item>
21
+ <item>RFC-1516: bind evidence reuse to the oldest replayed result and harden committed-envelope reads for rfc-1516</item>
37
22
  <history>RFC-0330, RFC-0999, RFC-1237, RFC-1249, RFC-1271, RFC-1320, RFC-1330, RFC-1334, RFC-1372, RFC-1391</history>
38
23
  </CHANGE_SUMMARY>
39
24
  */
@@ -44,7 +29,12 @@ import { ambientIo, resolveIo } from "../../src/utils/io.ts";
44
29
  import { join, relative } from "node:path";
45
30
  import { byteHash } from "../../src/utils/hash.ts";
46
31
 
47
- import { runProbeSet } from "./acceptance.ts";
32
+ import { classifyProbeReuse, runProbeSet } from "./acceptance.ts";
33
+ import {
34
+ evaluateEvidenceReuse,
35
+ readCommittedEnvelope,
36
+ type EvidenceReuseVerdict,
37
+ } from "./handlers/rfc-evidence-sync.ts";
48
38
  import { createOutcomeSession } from "./outcome-probe.ts";
49
39
  import { attachProbeOrigins } from "./verification-origin.ts";
50
40
  import { attachVerdictEvidence } from "./verification-verdicts.ts";
@@ -405,6 +395,7 @@ export function buildEvidenceEnvelope(
405
395
  kernelVersion: string,
406
396
  emittedAt: string,
407
397
  outcomeWaiver?: { reason: string; by: string },
398
+ resultsFrom?: string,
408
399
  ): VerificationEvidence {
409
400
  const overall: "pass" | "fail" = probeRecords.every((r) => r.ok) ? "pass" : "fail";
410
401
  return {
@@ -420,6 +411,7 @@ export function buildEvidenceEnvelope(
420
411
  probes: probeRecords,
421
412
  overall,
422
413
  ...(outcomeWaiver ? { outcomeWaiver } : {}),
414
+ ...(resultsFrom ? { resultsFrom } : {}),
423
415
  };
424
416
  }
425
417
 
@@ -557,18 +549,81 @@ export async function runRfcVerificationEmit(
557
549
  const rfcMarkdown = await io.readFile(rfcFilePath);
558
550
  const emittedAt = new Date().toISOString();
559
551
 
552
+ const slug = rfcId.toLowerCase();
553
+ const evidenceFileName = `${slug}.generated.yaml`;
554
+ const evidenceRelPath = join(VERIFICATION_DIR, evidenceFileName);
555
+ const evidenceAbsPath = join(workspaceRoot, evidenceRelPath);
556
+
557
+ // RFC-1516: evidence-freshness window. The committed (HEAD) envelope —
558
+ // never the worktree file — is eligible when it is well formed, green,
559
+ // acceptance-matching and its oldest replayed result
560
+ // (`resultsFrom ?? emittedAt`) is younger than EVIDENCE_REUSE_WINDOW_MS.
561
+ // On a hit, `reusable`-class probes (run/test/page/proof) replay their
562
+ // committed records while every cheap or unknown-kind probe still
563
+ // re-resolves against the live tree. `--check` never reuses: its whole
564
+ // contract is committed-vs-fresh comparison.
565
+ const reuseDisabled = input.flags["no-evidence-reuse"] === true;
566
+ let reuse: EvidenceReuseVerdict | undefined;
567
+ let committedEnvelope: VerificationEvidence | undefined;
568
+ if (!checkOnly) {
569
+ const committedRead = await readCommittedEnvelope(
570
+ workspaceRoot,
571
+ evidenceRelPath,
572
+ probes.length,
573
+ );
574
+ reuse = evaluateEvidenceReuse({
575
+ committed: committedRead.envelope ?? null,
576
+ malformed: committedRead.malformed === true,
577
+ probeCountMismatch: committedRead.probeCountMismatch === true,
578
+ acceptanceHashHex: byteHashHex(normalizeProbes(probes)),
579
+ disabled: reuseDisabled,
580
+ });
581
+ if (reuse.reusable) committedEnvelope = committedRead.envelope;
582
+ }
583
+
560
584
  // RFC-1489: batch-compatible test probes share one Vitest run via
561
- // runProbeSet; `--no-batch` forces the legacy per-probe path.
562
- const { results: setResults, durationsMs } = await runProbeSet(probes, {
563
- workspaceRoot,
564
- commandRegistry: context.commandRegistry,
565
- forgeRoot: context.forgeRoot,
566
- outcomeSession,
567
- noBatch: input.flags["no-batch"] === true,
568
- });
585
+ // runProbeSet; `--no-batch` forces the legacy per-probe path. RFC-1516:
586
+ // on a reuse hit only the non-reusable classes run.
587
+ const runIndexes = committedEnvelope
588
+ ? probes
589
+ .map((probe, index) => ({ class: classifyProbeReuse(probe.probe), index }))
590
+ .filter((e) => e.class !== "reusable")
591
+ .map((e) => e.index)
592
+ : probes.map((_, index) => index);
593
+ const { results: setResults, durationsMs } = await runProbeSet(
594
+ runIndexes.map((i) => probes[i]!),
595
+ {
596
+ workspaceRoot,
597
+ commandRegistry: context.commandRegistry,
598
+ forgeRoot: context.forgeRoot,
599
+ outcomeSession,
600
+ noBatch: input.flags["no-batch"] === true,
601
+ },
602
+ );
603
+ const heavyProbesReused: string[] = [];
604
+ const cheapProbesReRun: string[] = [];
569
605
  for (const [probeIndex, probe] of probes.entries()) {
570
- const result = setResults[probeIndex]!;
571
- const durationMs = durationsMs[probeIndex]!;
606
+ const label = probe.criterion ?? `#${probeIndex + 1}`;
607
+ const committedRecord = committedEnvelope?.probes[probeIndex];
608
+ const setPos = runIndexes.indexOf(probeIndex);
609
+ if (committedRecord !== undefined && setPos === -1) {
610
+ // Reused: the committed record's verdict fields carry over; the
611
+ // probe object is re-pinned to the live frontmatter so the emitted
612
+ // envelope still serializes the current probe declaration.
613
+ heavyProbesReused.push(label);
614
+ probeRecords.push({
615
+ probe,
616
+ ok: committedRecord.ok,
617
+ detail: committedRecord.detail,
618
+ durationMs: committedRecord.durationMs,
619
+ verdict: committedRecord.verdict,
620
+ ...(committedRecord.proof ? { proof: committedRecord.proof } : {}),
621
+ });
622
+ continue;
623
+ }
624
+ if (committedEnvelope) cheapProbesReRun.push(label);
625
+ const result = setResults[setPos]!;
626
+ const durationMs = durationsMs[setPos]!;
572
627
  probeRecords.push({
573
628
  probe,
574
629
  ok: result.ok,
@@ -603,13 +658,14 @@ export async function runRfcVerificationEmit(
603
658
  kernelVersion,
604
659
  emittedAt,
605
660
  outcomeWaiver,
661
+ // RFC-1516: the freshness anchor propagates — the emitted envelope's
662
+ // heaviest results still measure from the original execution, so a
663
+ // later emit evaluates THAT age, not this run's emittedAt.
664
+ committedEnvelope
665
+ ? (committedEnvelope.resultsFrom ?? committedEnvelope.emittedAt)
666
+ : undefined,
606
667
  );
607
668
 
608
- const slug = rfcId.toLowerCase();
609
- const evidenceFileName = `${slug}.generated.yaml`;
610
- const evidenceRelPath = join(VERIFICATION_DIR, evidenceFileName);
611
- const evidenceAbsPath = join(workspaceRoot, evidenceRelPath);
612
-
613
669
  // RFC-1271 --check: same probe run as emit, but the committed envelope is
614
670
  // compared to the fresh computation and nothing is written. A missing
615
671
  // envelope is itself a divergence.
@@ -649,6 +705,13 @@ export async function runRfcVerificationEmit(
649
705
  logger.info(
650
706
  `[evidence] ${rfcId} → ${evidenceRelPath} (${envelope.overall}, ${probeRecords.length} probes${drift}${dryRun ? ", dry-run" : ""})`,
651
707
  );
708
+ // RFC-1516: the replay stays visible in pretty output — an old pass
709
+ // must never read as a fresh execution.
710
+ if (reuse?.reusable === true) {
711
+ logger.info(
712
+ `[evidence] ${rfcId} envelope-reused — ${heavyProbesReused.length} heavy probe(s) replayed from ${reuse.reusedFrom}`,
713
+ );
714
+ }
652
715
  }
653
716
 
654
717
  return {
@@ -657,6 +720,9 @@ export async function runRfcVerificationEmit(
657
720
  file: evidenceRelPath,
658
721
  overall: envelope.overall,
659
722
  ...(previousOverall !== undefined ? { previousOverall } : {}),
723
+ ...(reuse ? { reuse } : {}),
724
+ ...(heavyProbesReused.length > 0 ? { heavyProbesReused } : {}),
725
+ ...(cheapProbesReRun.length > 0 ? { cheapProbesReRun } : {}),
660
726
  },
661
727
  ...(envelope.overall === "fail"
662
728
  ? {
@@ -23,6 +23,13 @@ the expectation instead of trusting the declared expectationSource.
23
23
  <CHANGE_SUMMARY>
24
24
  <item>RFC-1330: git-derived probe origin — range anchoring, declaration/test/run rules, verifier trailers, presence classes, attachProbeOrigins.</item>
25
25
  <item>RFC-1391: make the formal verification tier checker-bound (RFC-1391)</item>
26
+ <item>RFC-1513: steps 2-4 — batched committed-review reads + run-scoped index
27
+
28
+ OriginGit gains optional showMany backed by one git cat-file --batch
29
+ process (per-spec null on missing objects, wholesale null on spawn or
30
+ framing failure). collectCommittedReviews prefers it and keeps the
31
+ sequential show loop for stubs. rfc.validate memoizes the index once
32
+ per run and V-49 consumes it — identical diagnostics, one batched read.</item>
26
33
  </CHANGE_SUMMARY>
27
34
  */
28
35
 
@@ -42,6 +49,14 @@ import type {
42
49
  /** Git port — returns stdout, or null when the command failed. */
43
50
  export interface OriginGit {
44
51
  run(args: string[]): Promise<string | null>;
52
+ /**
53
+ * RFC-1513: optional batched object read. One `git cat-file --batch` process
54
+ * answers every spec — entry `i` answers `specs[i]` (`null` marks a missing
55
+ * or unreadable object). Resolves `null` on a wholesale spawn/parse failure
56
+ * so callers fall back to sequential `run(["show", spec])` reads; stubs that
57
+ * do not implement `showMany` take that fallback directly.
58
+ */
59
+ showMany?(specs: string[]): Promise<(string | null)[] | null>;
45
60
  }
46
61
 
47
62
  /**
@@ -64,6 +79,34 @@ export function gitEnvForCwd(): NodeJS.ProcessEnv {
64
79
  return env;
65
80
  }
66
81
 
82
+ /**
83
+ * Parse `git cat-file --batch` output back into per-spec entries. Each record
84
+ * is `<sha> <type> <size>\n<raw bytes>\n` or `<spec> missing\n`. Any framing
85
+ * anomaly resolves the whole call to null (wholesale failure → caller falls
86
+ * back); a `missing` record maps only its own entry to null.
87
+ */
88
+ function parseCatFileBatch(specs: string[], out: Buffer): (string | null)[] | null {
89
+ const results: (string | null)[] = [];
90
+ let off = 0;
91
+ for (const spec of specs) {
92
+ const nl = out.indexOf(0x0a, off);
93
+ if (nl === -1) return null;
94
+ const header = out.subarray(off, nl).toString("utf8");
95
+ off = nl + 1;
96
+ if (header === `${spec} missing`) {
97
+ results.push(null);
98
+ continue;
99
+ }
100
+ const meta = /^[0-9a-f]+ \S+ (\d+)$/.exec(header);
101
+ if (!meta) return null;
102
+ const size = Number(meta[1]);
103
+ if (off + size + 1 > out.length || out[off + size] !== 0x0a) return null;
104
+ results.push(out.subarray(off, off + size).toString("utf8"));
105
+ off += size + 1;
106
+ }
107
+ return results;
108
+ }
109
+
67
110
  export function createOriginGit(workspaceRoot: string): OriginGit {
68
111
  return {
69
112
  run: (args) =>
@@ -75,6 +118,22 @@ export function createOriginGit(workspaceRoot: string): OriginGit {
75
118
  (err, stdout) => resolve(err ? null : String(stdout)),
76
119
  );
77
120
  }),
121
+ showMany: (specs) =>
122
+ new Promise((resolve) => {
123
+ const child = execFile(
124
+ "git",
125
+ ["cat-file", "--batch"],
126
+ {
127
+ cwd: workspaceRoot,
128
+ timeout: 60000,
129
+ maxBuffer: 64 * 1024 * 1024,
130
+ env: gitEnvForCwd(),
131
+ encoding: "buffer",
132
+ },
133
+ (err, stdout) => resolve(err ? null : parseCatFileBatch(specs, stdout)),
134
+ );
135
+ child.stdin?.end(`${specs.join("\n")}\n`);
136
+ }),
78
137
  };
79
138
  }
80
139
 
@@ -20,6 +20,7 @@ output as log.</item>
20
20
  <item>RFC-1489: batch test probes through one instrumented Vitest run + frontmatter corpus reads
21
21
 
22
22
  runProbeSet is the single shared execution point: barrier-free segments of test probes sharing one effective bound run in one vitest --reporter=json --outputFile process with per-(file,testName) attribution; missing files/reports yield unverified. run/page/proof and all non-test kinds are barriers. --no-batch escapes to the legacy path on acceptance.run, verification.emit and verification.refresh. rfc.validate reads non-target corpus files frontmatter-only via readRfcFrontmatter (64 KiB bound, full-parse fallback); emit/refresh/acceptance corpus scans use the same accessor. Corpus map slimmed to RfcCorpusEntry {fileName, frontmatter}.</item>
23
+ <item>RFC-1516: add an evidence-freshness window to the stamp-sync chain for rfc-1516</item>
23
24
  </CHANGE_SUMMARY>
24
25
  */
25
26
 
@@ -39,7 +40,10 @@ const { mockRunProbe, mockCaptureGitContext, mockGetKernelVersion } = vi.hoisted
39
40
  mockGetKernelVersion: vi.fn(),
40
41
  }));
41
42
 
42
- vi.mock("./acceptance.ts", () => ({
43
+ vi.mock("./acceptance.ts", async (importOriginal) => ({
44
+ // RFC-1516: keep classifyProbeReuse (and every non-execution export) real —
45
+ // emit's reuse path calls it when a committed envelope is present.
46
+ ...(await importOriginal<typeof import("./acceptance.ts")>()),
43
47
  runProbe: mockRunProbe,
44
48
  // RFC-1489: refresh drives runProbeSet — the shim preserves the per-probe
45
49
  // mock contract so these tests observe the same probe calls as before.
@@ -10,6 +10,7 @@
10
10
  <item>RFC-1489: batch test probes through one instrumented Vitest run + frontmatter corpus reads
11
11
 
12
12
  runProbeSet is the single shared execution point: barrier-free segments of test probes sharing one effective bound run in one vitest --reporter=json --outputFile process with per-(file,testName) attribution; missing files/reports yield unverified. run/page/proof and all non-test kinds are barriers. --no-batch escapes to the legacy path on acceptance.run, verification.emit and verification.refresh. rfc.validate reads non-target corpus files frontmatter-only via readRfcFrontmatter (64 KiB bound, full-parse fallback); emit/refresh/acceptance corpus scans use the same accessor. Corpus map slimmed to RfcCorpusEntry {fileName, frontmatter}.</item>
13
+ <item>RFC-1516: add an evidence-freshness window to the stamp-sync chain for rfc-1516</item>
13
14
  </CHANGE_SUMMARY>
14
15
  */
15
16
 
@@ -26,7 +27,10 @@ import { describe, expect, test, vi } from "vitest";
26
27
  import { runRfcImplementStamp } from "../../handlers/implement-stamp.ts";
27
28
  import type { ForgeCommandInput, ForgeRuntimeContext } from "../../../../src/types.ts";
28
29
 
29
- vi.mock("../../acceptance.ts", () => ({
30
+ vi.mock("../../acceptance.ts", async (importOriginal) => ({
31
+ // RFC-1516: keep classifyProbeReuse (and every non-execution export) real —
32
+ // emit's reuse path calls it when a committed envelope is present.
33
+ ...(await importOriginal<typeof import("../../acceptance.ts")>()),
30
34
  runProbe: vi.fn(async (probe: unknown) => ({ probe, ok: true, detail: "ok" })),
31
35
  // RFC-1489: emit (which stamp composes) drives runProbeSet — the shim
32
36
  // preserves the per-probe mock contract.
@@ -11,7 +11,6 @@ Deterministic only — no LLM/intelligent annotation (that is fo-session-save sk
11
11
  </non-goals>
12
12
  </MODULE_CONTRACT>
13
13
  <CHANGE_SUMMARY>
14
- <item>RFC-0537: implement session.save command handler.</item>
15
14
  <item>RFC-1053: integrate generateSessionMetrics after markdown write (non-fatal, guarded by !dryRun).</item>
16
15
  <item>RFC-1097: step 6 — compass.migrate codemod run
17
16
 
@@ -20,10 +19,13 @@ Mechanical v1 to v2 header migration across the workspace: 942 files rewritten
20
19
 
21
20
  Sweep batch 4: 73 Compass headers on headerless engine files (certification, component-runtime, isolation, evolution, testing), real KEY_DECISIONS on 75 files (kernel, cache, dht, swim, gitmesh, runtime), ~80 purpose expansions (CONTRACT-02/PURPOSE-02), non-goals on 13 CONTRACT-03 files, CS-07 history literal fix repo-wide (253 files). Policy: .template.ts/.template.astro excludedPaths. werkstatt-engine now 0 diagnostics.</item>
22
21
  <item>RFC-1249: wire werkstatt.commands.validate into packages.check + retire CMD-OUTPUT debt</item>
22
+ <item>RFC-1536: owning-checkout routing, FLOW-OPEN-01 dirty-primary warning, shared governance-id allocation (RFC+ADR)</item>
23
+ <history>RFC-0537</history>
23
24
  </CHANGE_SUMMARY>
24
25
  */
25
26
 
26
- import { ambientIo as fs } from "../../../src/utils/io.ts";
27
+ import { ambientIo as fs, resolveIo } from "../../../src/utils/io.ts";
28
+ import { resolveOwningCheckout } from "../../flow/session-checkout.ts";
27
29
  import { execFile } from "../../../src/utils/sync-fs.ts";
28
30
  import path from "node:path";
29
31
  import { createHash } from "node:crypto";
@@ -206,8 +208,31 @@ export async function runSessionSave(
206
208
  context: ForgeRuntimeContext,
207
209
  ): Promise<ForgeCommandResult<SessionSaveResult & { skipped: SessionSaveSkip[] }>> {
208
210
  const { workspaceRoot, logger, outputFormat } = context;
209
- const sessionDirPath = path.join(workspaceRoot, SESSION_DIR);
210
- const rawDirPath = path.join(sessionDirPath, SESSION_RAW_SUBDIR);
211
+
212
+ // RFC-1536: route the session-artifact write to the owning checkout —
213
+ // a session.save run from the primary cwd lands inside the registered
214
+ // session worktree (or refuses when no worktree is attributable). Reads
215
+ // stay in the invocation workspace: the raw .atif lives where the agent
216
+ // dropped it.
217
+ const io = resolveIo(context.io);
218
+ const owning = await resolveOwningCheckout(io, workspaceRoot);
219
+ if (!owning.ok) {
220
+ throw new Error(
221
+ `SESSION-WRITE-01: ${owning.reason} — candidates: ${owning.candidates.join(", ")}. ` +
222
+ `Fix: open a session worktree with 'pnpm exec forge flow.open --kind session --slug <slug>' and write there.`,
223
+ );
224
+ }
225
+ for (const warning of owning.warnings) {
226
+ logger.warn(`session.save: ${warning}`);
227
+ }
228
+ const writeRoot = owning.checkout.worktreePath ?? workspaceRoot;
229
+ const routedTo = owning.checkout.kind === "worktree" ? writeRoot : null;
230
+ if (routedTo !== null && outputFormat === "pretty") {
231
+ logger.info(`session.save: routed into worktree ${writeRoot} (branch ${owning.checkout.sessionBranch})`);
232
+ }
233
+
234
+ const rawDirPath = path.join(workspaceRoot, SESSION_DIR, SESSION_RAW_SUBDIR);
235
+ const sessionDirPath = path.join(writeRoot, SESSION_DIR);
211
236
 
212
237
  const dryRun = context.dryRun || input.flags["dry-run"] === true;
213
238
  const keepRaw = input.flags["keep-raw"] === true;
@@ -322,7 +347,9 @@ export async function runSessionSave(
322
347
  // Check if output already exists (idempotency)
323
348
  const outputFileName = `${id}.md`;
324
349
  const outputPath = path.join(sessionDirPath, outputFileName);
325
- const outputRel = path.join(SESSION_DIR, outputFileName);
350
+ // Reported paths are repo-relative logical paths — posix separators on
351
+ // every platform (path.join would emit backslashes under Windows).
352
+ const outputRel = path.posix.join(SESSION_DIR, outputFileName);
326
353
 
327
354
  try {
328
355
  await fs.exists(outputPath).then((ok) => {
@@ -370,7 +397,7 @@ export async function runSessionSave(
370
397
  // ── RFC-1053: Generate session metrics from ATIF messages (non-fatal) ──
371
398
  try {
372
399
  metricsPath = await generateSessionMetrics(
373
- workspaceRoot,
400
+ writeRoot,
374
401
  id,
375
402
  atifResult.messages,
376
403
  { date: timestamp.toISOString(), relatedRfcs, commits },
@@ -405,7 +432,8 @@ export async function runSessionSave(
405
432
  command: "session.save",
406
433
  status: "ok",
407
434
  file: outputRel,
408
- rawFile: path.join(SESSION_DIR, SESSION_RAW_SUBDIR, rawFileName),
435
+ ...(routedTo !== null ? { routedTo } : {}),
436
+ rawFile: path.posix.join(SESSION_DIR, SESSION_RAW_SUBDIR, rawFileName),
409
437
  rawDeleted: !dryRun && !keepRaw,
410
438
  id,
411
439
  types,
@@ -0,0 +1,154 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>session.save owning-checkout routing tests (RFC-1536 AC-1/AC-4):
4
+ resolveOwningCheckout attributes a write invoked from the primary cwd to
5
+ the registered session worktree, refuses SESSION-WRITE-01 when several live
6
+ session worktrees exist without an attributable hint, and degrades to
7
+ primary semantics when no session worktree is registered.</purpose>
8
+ <non-goals>
9
+ <item>No ATIF parsing coverage — the transcript pipeline has its own tests; this file covers only the RFC-1536 routing contract.</item>
10
+ </non-goals>
11
+ </MODULE_CONTRACT>
12
+ <CHANGE_SUMMARY>
13
+ <item>RFC-1536: owning-checkout routing tests</item>
14
+ <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>
15
+ </CHANGE_SUMMARY>
16
+ */
17
+
18
+ import { rm } from "node:fs/promises";
19
+ import { dirname, join } from "node:path";
20
+
21
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
22
+
23
+ import { ambientIo } from "../../../src/utils/io.ts";
24
+ import { resolveOwningCheckout } from "../../flow/session-checkout.ts";
25
+ import { commonGitDir, updateRegistry, type FlowRegistryEntry } from "../../flow/registry.ts";
26
+ import { gitExec, initRepo } from "../../flow/tests/helpers.ts";
27
+
28
+ const dirs: string[] = [];
29
+ beforeEach(() => {
30
+ // Agent-session env vars must not leak ambient attribution into tests.
31
+ vi.stubEnv("WERKSTATT_AGENT_ID", "");
32
+ vi.stubEnv("AI_AGENT", "");
33
+ });
34
+ afterEach(async () => {
35
+ vi.unstubAllEnvs();
36
+ for (const dir of dirs.splice(0)) {
37
+ await rm(dir, { recursive: true, force: true });
38
+ }
39
+ }, 15_000);
40
+
41
+ async function repo(): Promise<string> {
42
+ const dir = await initRepo({ prefix: "session-save-", branch: "develop" });
43
+ dirs.push(dir);
44
+ return dir;
45
+ }
46
+
47
+ async function registerSession(
48
+ primary: string,
49
+ name: string,
50
+ worktreePath: string,
51
+ ownerId: string,
52
+ ): Promise<string> {
53
+ const baseSha = (await gitExec(primary, ["rev-parse", "HEAD"])).stdout.trim();
54
+ const common = await commonGitDir(ambientIo, primary);
55
+ const entry: FlowRegistryEntry = {
56
+ name,
57
+ kind: "session",
58
+ base: "develop",
59
+ baseSha,
60
+ worktree: worktreePath,
61
+ owner: { kind: "session", id: ownerId },
62
+ brief: null,
63
+ openedAt: new Date().toISOString(),
64
+ updatedAt: new Date().toISOString(),
65
+ held: null,
66
+ port: null,
67
+ };
68
+ await updateRegistry(ambientIo, common, (r) => ({
69
+ ...r,
70
+ branches: [...r.branches.filter((b) => b.name !== name), entry],
71
+ }));
72
+ return worktreePath;
73
+ }
74
+
75
+ /** Real linked worktree — resolveOwningCheckout needs topLevel() to answer. */
76
+ async function fakeWorktree(primary: string, name: string): Promise<string> {
77
+ const dir = join(dirname(primary), `wt-${name}`);
78
+ const add = await gitExec(primary, ["worktree", "add", "-b", `test/${name}`, dir, "develop"]);
79
+ if (add.exitCode !== 0) throw new Error(`worktree add failed: ${add.stderr}`);
80
+ dirs.push(dir);
81
+ return dir;
82
+ }
83
+
84
+ describe("resolveOwningCheckout (RFC-1536)", () => {
85
+ it("attributes a primary-cwd write to the single live session worktree (AC-1)", async () => {
86
+ const primary = await repo();
87
+ const wt = await fakeWorktree(primary, "one");
88
+ await registerSession(primary, "auto/session-260101-01-a", wt, "unspecified");
89
+
90
+ const result = await resolveOwningCheckout(ambientIo, primary);
91
+ expect(result.ok).toBe(true);
92
+ if (result.ok) {
93
+ expect(result.checkout.kind).toBe("worktree");
94
+ expect(result.checkout.sessionBranch).toBe("auto/session-260101-01-a");
95
+ }
96
+ });
97
+
98
+ it("keeps cwd semantics inside the registered worktree itself", async () => {
99
+ const primary = await repo();
100
+ const wt = await fakeWorktree(primary, "self");
101
+ await registerSession(primary, "auto/session-260101-02-b", wt, "devin");
102
+
103
+ const result = await resolveOwningCheckout(ambientIo, wt);
104
+ expect(result.ok).toBe(true);
105
+ if (result.ok) {
106
+ expect(result.checkout.kind).toBe("worktree");
107
+ expect(result.checkout.worktreePath).toBe(wt);
108
+ }
109
+ });
110
+
111
+ it("refuses when several live session worktrees exist and no hint attributes (AC-4)", async () => {
112
+ const primary = await repo();
113
+ const wt1 = await fakeWorktree(primary, "a");
114
+ const wt2 = await fakeWorktree(primary, "b");
115
+ await registerSession(primary, "auto/session-260101-01-a", wt1, "unspecified");
116
+ await registerSession(primary, "auto/session-260101-02-b", wt2, "unspecified");
117
+
118
+ const result = await resolveOwningCheckout(ambientIo, primary);
119
+ expect(result.ok).toBe(false);
120
+ if (!result.ok) {
121
+ expect(result.candidates.length).toBe(2);
122
+ }
123
+ });
124
+
125
+ it("routes via an explicit sessionId hint among several worktrees", async () => {
126
+ const primary = await repo();
127
+ const wt1 = await fakeWorktree(primary, "a");
128
+ const wt2 = await fakeWorktree(primary, "b");
129
+ await registerSession(primary, "auto/session-260101-01-a", wt1, "agent-a");
130
+ await registerSession(primary, "auto/session-260101-02-b", wt2, "agent-b");
131
+
132
+ const result = await resolveOwningCheckout(ambientIo, primary, "agent-b");
133
+ expect(result.ok).toBe(true);
134
+ if (result.ok) {
135
+ expect(result.checkout.sessionBranch).toBe("auto/session-260101-02-b");
136
+ }
137
+ });
138
+
139
+ it("refuses when the hint matches none of the live worktrees (never guess)", async () => {
140
+ const primary = await repo();
141
+ const wt = await fakeWorktree(primary, "a");
142
+ await registerSession(primary, "auto/session-260101-01-a", wt, "agent-a");
143
+
144
+ const result = await resolveOwningCheckout(ambientIo, primary, "agent-zzz");
145
+ expect(result.ok).toBe(false);
146
+ });
147
+
148
+ it("degrades to primary when no session worktree is registered", async () => {
149
+ const primary = await repo();
150
+ const result = await resolveOwningCheckout(ambientIo, primary);
151
+ expect(result.ok).toBe(true);
152
+ if (result.ok) expect(result.checkout.kind).toBe("primary");
153
+ });
154
+ });
@@ -10,6 +10,7 @@
10
10
  <item>RFC-0394: initial spec schema — forge/spec@1, integrity manifest, decision/rfc/wave types.</item>
11
11
  <item>RFC-1240: consumers field on roadmap nodes (consumer ownership filtering); severity field on SpecViolation for warning diagnostics.</item>
12
12
  <item>Handoff xrepo-personal-agent-to-forge-spec-validate-sweep: skippedDirs field on SpecValidateResult for sweep-mode transparency.</item>
13
+ <item>RFC-1539: package-sourced specs and published consumer validators in Forge</item>
13
14
  </CHANGE_SUMMARY>
14
15
  */
15
16
 
@@ -154,6 +155,8 @@ export interface SpecValidateResult {
154
155
  id: string;
155
156
  status: string;
156
157
  violations: SpecViolation[];
158
+ /** RFC-1539: where the spec was read from — a vendored dir or an installed package. */
159
+ source?: { kind: "vendored" } | { kind: "package"; package: string; version: string };
157
160
  }>;
158
161
  /** Dirs under specsDir skipped in sweep mode — non-package dirs carry no
159
162
  * forge-spec.yaml (authored/live work areas). Always [] under --spec. */
@@ -10,6 +10,7 @@
10
10
  <item>RFC-1240: consumer-aware front — foreignOwned flag/list, foreign deps are not local blockers, --consumer flag resolution.</item>
11
11
  <item>FIX: loadRfcStatuses delegated to loadRfcStatusMap (recursive) — archived implemented RFCs resolve their status, so terminal dependencies unblock the front instead of collapsing nodes to stale draft.</item>
12
12
  <item>RFC-1363: fail-closed amendment loader SPEC-14 + target repairs AMD-008..011</item>
13
+ <item>RFC-1539: package-sourced specs and published consumer validators in Forge</item>
13
14
  </CHANGE_SUMMARY>
14
15
  */
15
16
 
@@ -58,6 +59,8 @@ interface SpecStatusEntry {
58
59
  /** RFC-1240: nodes excluded from the front by consumer ownership. */
59
60
  foreignOwned: string[];
60
61
  progress: SpecProgress;
62
+ /** RFC-1539: where the spec was read from. */
63
+ source: { kind: "vendored" } | { kind: "package"; package: string; version: string };
61
64
  amendments?: {
62
65
  proposed: number;
63
66
  accepted: number;
@@ -100,6 +103,7 @@ async function loadRfcStatuses(
100
103
  }
101
104
 
102
105
  import { loadAmendments } from "./spec-amendments.ts";
106
+ import { listSpecSources, type SpecSource } from "../../src/spec/resolve-spec-source.ts";
103
107
 
104
108
  function computeFront(
105
109
  nodes: SpecNodeStatus[],
@@ -142,16 +146,27 @@ export async function runSpecStatus(
142
146
  const rfcDir = path.join(workspaceRoot, "docs", "rfcs");
143
147
  const filterSpec = input.flags["spec"] as string | undefined;
144
148
 
145
- let specDirs = await listSpecDirs(specsRoot);
146
- if (filterSpec) {
147
- specDirs = specDirs.filter((d) => d === filterSpec);
148
- }
149
+ const vendoredTargets = (await listSpecDirs(specsRoot)).map((specId) => ({
150
+ specId,
151
+ specDir: path.join(specsRoot, specId),
152
+ source: { kind: "vendored" } as SpecStatusEntry["source"],
153
+ }));
154
+ // RFC-1539: installed spec packages declared in forge.yaml specPackages[].
155
+ const packageTargets = listSpecSources(workspaceRoot)
156
+ .sources.filter((s): s is Extract<SpecSource, { kind: "package" }> => s.kind === "package")
157
+ .map((s) => ({
158
+ specId: s.specId,
159
+ specDir: s.dir,
160
+ source: { kind: "package", package: s.package, version: s.version } as SpecStatusEntry["source"],
161
+ }));
162
+ const targets = [...vendoredTargets, ...packageTargets].filter(
163
+ (t) => !filterSpec || t.specId === filterSpec,
164
+ );
149
165
 
150
166
  const rfcStatuses = await loadRfcStatuses(rfcDir);
151
167
  const results: SpecStatusEntry[] = [];
152
168
 
153
- for (const specId of specDirs) {
154
- const specDir = path.join(specsRoot, specId);
169
+ for (const { specId, specDir, source } of targets) {
155
170
  const forgeSpecPath = path.join(specDir, "forge-spec.yaml");
156
171
  const rawSpec = await readYaml<unknown>(forgeSpecPath);
157
172
  if (!rawSpec) continue;
@@ -243,6 +258,7 @@ export async function runSpecStatus(
243
258
  front,
244
259
  foreignOwned: nodes.filter((n) => n.foreignOwned).map((n) => n.id),
245
260
  progress,
261
+ source,
246
262
  amendments: {
247
263
  proposed: amendments.filter((a) => a.status === "proposed").length,
248
264
  accepted: acceptedAmendments.length,