@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,50 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>Open-mission scan for forge's flow gates (RFC-1537) — a forge-local
4
+ port of werkstatt.worktree.gate's openMissionsIn semantics: glob the
5
+ missions/<id>/mission.yaml manifests under a checkout, count `state: "open"`,
6
+ and treat an unreadable manifest as open (a corrupt live mission must never
7
+ silently pass — DNA-106). Forge cannot import the site plugin
8
+ (FORGE-AUTONOMY-01), so parity is pinned by the contract the preflight mission
9
+ check consumes.</purpose>
10
+ <non-goals>
11
+ <item>Read-only — never mutates mission state; mission lifecycle lives in mission.* commands.</item>
12
+ </non-goals>
13
+ </MODULE_CONTRACT>
14
+ <CHANGE_SUMMARY>
15
+ <item>RFC-1537: open-mission scan shared by the integrate preflight's cheap-first check and the importer-materialize dirt class</item>
16
+ <item>RFC-1537: classify regenerable worktree dirt and journal integrate refusals cheapest-first</item>
17
+ </CHANGE_SUMMARY>
18
+ */
19
+
20
+ import { basename, dirname, join } from "node:path";
21
+
22
+ import { parse as yamlParse } from "yaml";
23
+
24
+ import type { WorkspaceIO } from "../../src/types.ts";
25
+
26
+ /**
27
+ * Mission ids whose `missions/<id>/mission.yaml` declares `state: "open"`.
28
+ * An unreadable manifest counts as open — same closed-shape semantics as the
29
+ * site plugin's worktree gate. Sorted for deterministic output.
30
+ */
31
+ export async function openMissionsIn(
32
+ worktree: string,
33
+ io: WorkspaceIO,
34
+ ): Promise<string[]> {
35
+ const manifests = await io.glob("missions/*/mission.yaml", { cwd: worktree });
36
+ const open: string[] = [];
37
+ for (const rel of manifests) {
38
+ try {
39
+ const parsed = yamlParse(await io.readFile(join(worktree, rel))) as {
40
+ state?: unknown;
41
+ } | null;
42
+ if (parsed?.state === "open") {
43
+ open.push(basename(dirname(rel)));
44
+ }
45
+ } catch {
46
+ open.push(basename(dirname(rel)));
47
+ }
48
+ }
49
+ return open.sort();
50
+ }
@@ -11,6 +11,7 @@ Unit tests for decision ledger covering decisionLedgerSchema (RFC-1250); decisio
11
11
  <item>RFC-1311: Compass header sweep — declares the decision suite's contract for test-file scaffold coverage.</item>
12
12
  <item>RFC-1350: queue-batch hardening — ledger baseline field, manifest packagesImpacted + QUEUE-09, COMMIT-GOV-02 manifest scope, test-first policy</item>
13
13
  <item>RFC-1482: emit validation-compliant RFC skeletons and surface contract breaches at authoring time</item>
14
+ <item>RFC-1534: lint probe patterns, sync amends counterparts, name next free ledger id</item>
14
15
  </CHANGE_SUMMARY>
15
16
  */
16
17
 
@@ -253,4 +254,21 @@ describe("decisionLedgerPath / loadDecisionLedger (RFC-1250)", () => {
253
254
  expect(queue01.length).toBeGreaterThan(0);
254
255
  expect(queue01.every((e) => !e.message.includes("minimal shape"))).toBe(true);
255
256
  });
257
+
258
+ // RFC-1534 AC-3: the collision diagnostic names the colliding id AND the
259
+ // next free id computed at read time (max suffix + 1, never a counter).
260
+ test("duplicate decision id → QUEUE-05 names the collision and next free id", async () => {
261
+ await fs.writeFile(
262
+ path.join(tmpDir, "docs/queues/block-f.decisions.yaml"),
263
+ "id: block-f.decisions\nqueue: block-f\ncreatedAt: 2026-10-09\nitems:\n" +
264
+ " - id: Q-1\n doc: RFC-1243\n stage: enhance\n question: first\n resolutionPath: none\n status: open\n" +
265
+ " - id: Q-7\n doc: RFC-1243\n stage: enhance\n question: second\n resolutionPath: none\n status: open\n" +
266
+ " - id: Q-1\n doc: RFC-1244\n stage: plan\n question: dup\n resolutionPath: none\n status: open\n",
267
+ );
268
+ const { errors } = await loadDecisionLedger(tmpDir, "docs/queues/block-f.yaml");
269
+ const q5 = errors.filter((e) => e.ruleId === "QUEUE-05");
270
+ expect(q5).toHaveLength(1);
271
+ expect(q5[0]!.message).toContain('"Q-1"');
272
+ expect(q5[0]!.message).toContain("next free id: Q-8");
273
+ });
256
274
  });
@@ -28,6 +28,7 @@ maturation skips parked/deferred items; uncovered imperative ask sites
28
28
  gain collect riders (ADR code-trace, NC markers, audit-verdict guard).</item>
29
29
  <item>RFC-1250: re-review wave — blocked dependsOn cascade, manifest-failure gating, generated artifacts</item>
30
30
  <item>RFC-1482: emit validation-compliant RFC skeletons and surface contract breaches at authoring time</item>
31
+ <item>RFC-1534: QUEUE-05 decision-ledger collision diagnostic names the next free Q-id computed at read time (max numeric suffix + 1).</item>
31
32
  <history>RFC-1250</history>
32
33
  </CHANGE_SUMMARY>
33
34
  */
@@ -345,11 +346,26 @@ export async function loadDecisionLedger(
345
346
 
346
347
  // QUEUE-05-family: decision ids are queue-global — window codes and
347
348
  // PENDING DECISION markers address them, so duplicates corrupt arbitration.
349
+ // RFC-1534: the diagnostic names the next free id computed at read time
350
+ // (max numeric suffix + 1 across the ledger — never a remembered counter).
351
+ let maxQ = 0;
352
+ for (const entry of ledger.items) {
353
+ const m = entry.id.match(/^Q-(\d+)$/);
354
+ if (m) maxQ = Math.max(maxQ, parseInt(m[1]!, 10));
355
+ }
356
+ const nextFree = `Q-${maxQ + 1}`;
348
357
  const seenDecisions = new Set<string>();
349
358
  const manifestDocs = new Set((manifest?.items ?? []).map((i) => i.id.trim().toUpperCase()));
350
359
  for (const entry of ledger.items) {
351
360
  if (seenDecisions.has(entry.id)) {
352
- errors.push(diag("QUEUE-05", "error", `Duplicate decision id "${entry.id}"`, displayPath));
361
+ errors.push(
362
+ diag(
363
+ "QUEUE-05",
364
+ "error",
365
+ `Duplicate decision id "${entry.id}" — collides with an earlier entry; next free id: ${nextFree}`,
366
+ displayPath,
367
+ ),
368
+ );
353
369
  continue;
354
370
  }
355
371
  seenDecisions.add(entry.id);
@@ -13,21 +13,14 @@ prose checklist.
13
13
  </non-goals>
14
14
  </MODULE_CONTRACT>
15
15
  <CHANGE_SUMMARY>
16
- <item>RFC-1453: page probes execute through an OutcomeSession (outcomeBuild/outcomeServe bindings); tri-state verdicts; RFC-ACC-03 skip removed; RFC-ACC-04 reports unverified.</item>
17
- <item>RFC-1391: close RFC-1391 review r1 findings — evidence freshness, config classification, contract guards
18
-
19
- REVIEW-CODE-2026-10-24-04 (warning): a stale .cache/proofs report could
20
- fabricate proved; forge.yaml now resolves inside runProofCheck so a malformed
21
- config is error not unavailable, and both surfaces share one path; {entry} is
22
- required in formal.tools.command; spec/entry paths are confined to the
23
- workspace; the exhaustive entry dispatches per packageManager; proved runs
24
- record log, counterexample stays the refuted-path record.</item>
25
16
  <item>RFC-1445: run-probe timeoutMs + RFC-1445 outcome probe AC-9 (RFC-1445)</item>
26
17
  <item>RFC-1489: batch test probes through one instrumented Vitest run + frontmatter corpus reads
27
18
 
28
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>
29
20
  <item>RFC-1489: resolve REVIEW-RFC-1489-R1 soft-block — spec-exact barrier semantics, dedup, verdict parity; DEV-1489-001 amend recorded</item>
30
- <history>RFC-0268, RFC-0998, RFC-1271, RFC-1334, RFC-1391, RFC-1401</history>
21
+ <item>RFC-1516: add an evidence-freshness window to the stamp-sync chain for rfc-1516</item>
22
+ <item>RFC-1516: bind evidence reuse to the oldest replayed result and harden committed-envelope reads for rfc-1516</item>
23
+ <history>RFC-0268, RFC-0998, RFC-1271, RFC-1334, RFC-1391, RFC-1401, RFC-1453</history>
31
24
  </CHANGE_SUMMARY>
32
25
  */
33
26
 
@@ -540,6 +533,33 @@ export async function runProbe(
540
533
  }
541
534
  }
542
535
 
536
+ /**
537
+ * RFC-1516: probe-kind reuse classification for the evidence-freshness
538
+ * window. `reusable` kinds cost real wall-clock (subprocess runs, vitest,
539
+ * outcome build+serve, proof checkers) — their recorded results may carry
540
+ * across a matching green envelope within the bounded window. A `run` probe
541
+ * CAN still observe inputs outside the acceptance list (e.g. a validator
542
+ * reading the live RFC bytes); the window bounds that residual staleness.
543
+ * `cheap` kinds re-resolve every emit: they cost nothing and read the live
544
+ * tree. `unchecked` is the default side for any kind this table does not
545
+ * know — a future probe kind must opt into reuse explicitly, never inherit
546
+ * it silently.
547
+ */
548
+ export type ProbeReuseClass = "cheap" | "reusable" | "unchecked";
549
+ const REUSABLE_PROBE_KINDS = new Set(["run", "test", "page", "proof"]);
550
+ const CHEAP_PROBE_KINDS = new Set([
551
+ "file-exists",
552
+ "file-contains",
553
+ "command-registered",
554
+ "json-schema",
555
+ "reachable",
556
+ ]);
557
+ export function classifyProbeReuse(kind: string): ProbeReuseClass {
558
+ if (CHEAP_PROBE_KINDS.has(kind)) return "cheap";
559
+ if (REUSABLE_PROBE_KINDS.has(kind)) return "reusable";
560
+ return "unchecked";
561
+ }
562
+
543
563
  export interface ProbeSetOptions {
544
564
  workspaceRoot: string;
545
565
  commandRegistry?: CommandRegistry;
@@ -14,6 +14,7 @@ keywords for rfc.create consultation, and generate/validate projections.
14
14
  <item>RFC-0329: initial implementation.</item>
15
15
  <item>RFC-1320 review-r1: writes migrated writeFileAtomic → context.io; dry-run returns renderedFiles for both projections (ambient writes bypassed dry-run interception and self-healed stale artifacts inside emit's freshness precheck).</item>
16
16
  <item>RFC-1467: block rfc.create on terminal-kind near-duplicates until --revisit acknowledges + V-52 validate mirror</item>
17
+ <item>RFC-1514: attach corrected invocations to blocking diagnostics so retry is one-shot</item>
17
18
  </CHANGE_SUMMARY>
18
19
  */
19
20
 
@@ -156,9 +157,17 @@ export function scoreDecisions(
156
157
  ]);
157
158
 
158
159
  let score = 0;
160
+ const matchedTitleTokens = new Set<string>();
161
+ const matchedTextTokens = new Set<string>();
159
162
  for (const token of titleTokens) {
160
- if (entryTitleTokens.includes(token)) score += 3;
161
- if (entryTextTokens.has(token)) score += 1;
163
+ if (entryTitleTokens.includes(token)) {
164
+ score += 3;
165
+ matchedTitleTokens.add(token);
166
+ }
167
+ if (entryTextTokens.has(token)) {
168
+ score += 1;
169
+ matchedTextTokens.add(token);
170
+ }
162
171
  }
163
172
 
164
173
  if (score > 0) {
@@ -168,6 +177,8 @@ export function scoreDecisions(
168
177
  title: entry.title,
169
178
  score,
170
179
  file: entry.file,
180
+ matchedTitleTokens: [...matchedTitleTokens].sort(),
181
+ matchedTextTokens: [...matchedTextTokens].sort(),
171
182
  });
172
183
  }
173
184
  }
@@ -21,11 +21,13 @@ Sweep batch 4: 73 Compass headers on headerless engine files (certification, com
21
21
  <item>RFC-1489: batch test probes through one instrumented Vitest run + frontmatter corpus reads
22
22
 
23
23
  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>
24
+ <item>RFC-1534: frontmatterSource captured on both parse paths (probe-meta marker scan); mergeFrontmatterListEntry / appendRfcFrontmatterListEntry — line-level list merge preserving comments and key order (F-0056 discipline, never a YAML.stringify round-trip).</item>
24
25
  <history>RFC-0268</history>
25
26
  </CHANGE_SUMMARY>
26
27
  */
27
28
 
28
29
  import { ambientIo as fs } from "../../src/utils/io.ts";
30
+ import { writeFileAtomic } from "../../src/utils/fs-atomic.ts";
29
31
  import path from "node:path";
30
32
  import { open as fsOpen } from "node:fs/promises";
31
33
  import YAML from "yaml";
@@ -33,6 +35,9 @@ import YAML from "yaml";
33
35
  export interface ParsedRfc {
34
36
  frontmatter: Record<string, unknown>;
35
37
  body: string;
38
+ /** RFC-1534: raw YAML frontmatter text — marker scans (probe-meta) need the
39
+ * un-parsed source because YAML comments never reach the parsed map. */
40
+ frontmatterSource?: string;
36
41
  }
37
42
 
38
43
  export function parseRfcFile(source: string): ParsedRfc {
@@ -43,9 +48,92 @@ export function parseRfcFile(source: string): ParsedRfc {
43
48
  return {
44
49
  frontmatter: (YAML.parse(match[1]!) ?? {}) as Record<string, unknown>,
45
50
  body: match[2] ?? "",
51
+ frontmatterSource: match[1]!,
46
52
  };
47
53
  }
48
54
 
55
+ /**
56
+ * RFC-1534: merges `ids` into a frontmatter list `key` by line-level edit —
57
+ * preserves comments, key order, and existing entries (F-0056 discipline;
58
+ * a YAML.stringify round-trip would strip the template's comment lines).
59
+ * Returns the rewritten source plus the ids actually added; `undefined` when
60
+ * every id was already present.
61
+ */
62
+ export function mergeFrontmatterListEntry(
63
+ source: string,
64
+ key: string,
65
+ ids: string[],
66
+ ): { content: string; added: string[] } | undefined {
67
+ const match = source.match(/^(---\r?\n)([\s\S]*?)(\r?\n---\r?\n?)([\s\S]*)$/);
68
+ if (!match) return undefined;
69
+ const [, open, fm, close, body] = match;
70
+ const lines = fm!.split("\n");
71
+ const keyRe = new RegExp(`^${key}:(.*)$`);
72
+ const keyIdx = lines.findIndex((l) => keyRe.test(l));
73
+ const existing = new Set<string>();
74
+ let insertAt = -1;
75
+
76
+ if (keyIdx !== -1) {
77
+ const inline = keyRe.exec(lines[keyIdx]!)![1]!.trim();
78
+ if (inline.startsWith("[")) {
79
+ for (const m of inline.replace(/^\[/, "").replace(/\]$/, "").split(",")) {
80
+ const item = m.trim().replace(/^["']|["']$/g, "");
81
+ if (item) existing.add(item);
82
+ }
83
+ lines[keyIdx] = `${key}:`;
84
+ insertAt = keyIdx + 1;
85
+ } else {
86
+ insertAt = keyIdx + 1;
87
+ while (insertAt < lines.length && /^\s+-\s+/.test(lines[insertAt]!)) {
88
+ existing.add(lines[insertAt]!.replace(/^\s+-\s+/, "").trim().replace(/^["']|["']$/g, ""));
89
+ insertAt++;
90
+ }
91
+ }
92
+ } else {
93
+ // No key — anchor after amends:/amendedBy:/supersededBy: block when one
94
+ // exists so relationship keys stay adjacent, else end of frontmatter.
95
+ let anchor = lines.length;
96
+ for (const anchorKey of ["amends", "amendedBy", "supersededBy", "supersedes"]) {
97
+ const idx = lines.findIndex((l) => new RegExp(`^${anchorKey}:`).test(l));
98
+ if (idx !== -1) {
99
+ anchor = idx + 1;
100
+ while (anchor < lines.length && /^\s+-\s+/.test(lines[anchor]!)) anchor++;
101
+ break;
102
+ }
103
+ }
104
+ lines.splice(anchor, 0, `${key}:`);
105
+ insertAt = anchor + 1;
106
+ }
107
+
108
+ const added = ids.filter((id) => !existing.has(id));
109
+ if (added.length === 0) return undefined;
110
+ lines.splice(insertAt, 0, ...added.map((id) => ` - ${id}`));
111
+ return { content: `${open}${lines.join("\n")}${close}${body}`, added };
112
+ }
113
+
114
+ /**
115
+ * RFC-1534: re-reads the file immediately before merging (never a
116
+ * blind-append over a cached parse — the counterpart write races a parallel
117
+ * edit of the amended file). Returns `{ added }`; `undefined` when the file
118
+ * was unreadable or every id was already present.
119
+ */
120
+ export async function appendRfcFrontmatterListEntry(
121
+ filePath: string,
122
+ key: string,
123
+ ids: string[],
124
+ ): Promise<{ added: string[] } | undefined> {
125
+ let source: string;
126
+ try {
127
+ source = await fs.readFile(filePath);
128
+ } catch {
129
+ return undefined;
130
+ }
131
+ const merged = mergeFrontmatterListEntry(source, key, ids);
132
+ if (!merged) return undefined;
133
+ await writeFileAtomic(filePath, merged.content);
134
+ return { added: merged.added };
135
+ }
136
+
49
137
  export async function listRfcFiles(rfcDirPath: string): Promise<string[]> {
50
138
  const results: string[] = [];
51
139
 
@@ -162,7 +250,7 @@ export async function readRfcFrontmatter(
162
250
  }
163
251
  try {
164
252
  const frontmatter = (YAML.parse(match[1]!) ?? {}) as Record<string, unknown>;
165
- return { fileName, parsed: { frontmatter, body: "" } };
253
+ return { fileName, parsed: { frontmatter, body: "", frontmatterSource: match[1]! } };
166
254
  } catch (e) {
167
255
  return parseErrorResult(fileName, e);
168
256
  }
@@ -14,6 +14,7 @@ reports, null reviewsDir, and fenced-example immunity.
14
14
  <CHANGE_SUMMARY>
15
15
  <item>RFC-1454: RFC-IMP-15 deviation gate unit tests.</item>
16
16
  <item>RFC-1454: review deviations recorded in the RFC — IMP-15 gate, V-49 provenance, skill contract</item>
17
+ <item>RFC-1513: batched committed-review reads evidence (AC-2, AC-3)</item>
17
18
  </CHANGE_SUMMARY>
18
19
  */
19
20
 
@@ -121,6 +122,88 @@ describe("RFC-IMP-15 — amend deviations must land in ## Deviations", () => {
121
122
  });
122
123
  });
123
124
 
125
+ describe("RFC-1513 — batched committed-review reads (AC-2/AC-3)", () => {
126
+ const FILES: Record<string, string> = {
127
+ "docs/reviews/code/r1.md": amendReport(),
128
+ "docs/reviews/code/r2.md": report({ reviewId: "REVIEW-2", rfcId: RFC_ID }),
129
+ "docs/reviews/code/r3.md": report({ reviewId: "REVIEW-3", rfcId: "RFC-0001" }),
130
+ };
131
+
132
+ /** OriginGit stub — mode picks showMany absent, answering specs, or failing wholesale. */
133
+ function batchedGit(
134
+ files: Record<string, string>,
135
+ mode: "absent" | "specs" | "null",
136
+ ): { git: OriginGit; counters: { showManyCalls: number; showCalls: number } } {
137
+ const counters = { showManyCalls: 0, showCalls: 0 };
138
+ return {
139
+ counters,
140
+ git: {
141
+ run: async (args: string[]) => {
142
+ if (args[0] === "ls-tree") return Object.keys(files).join("\n") + "\n";
143
+ if (args[0] === "show") {
144
+ counters.showCalls++;
145
+ return files[String(args[1] ?? "").replace(/^HEAD:/, "")] ?? null;
146
+ }
147
+ return null;
148
+ },
149
+ ...(mode === "absent"
150
+ ? {}
151
+ : {
152
+ showMany: async (specs: string[]) => {
153
+ counters.showManyCalls++;
154
+ if (mode === "null") return null;
155
+ return specs.map((s) => files[s.replace(/^HEAD:/, "")] ?? null);
156
+ },
157
+ }),
158
+ },
159
+ };
160
+ }
161
+
162
+ it("AC-2: one batched showMany call and zero per-file show calls when supported", async () => {
163
+ const { git, counters } = batchedGit(FILES, "specs");
164
+ const res = await evaluateDeviationGate({
165
+ rfcId: RFC_ID,
166
+ strippedRfcBody: "# RFC-9001\n",
167
+ git,
168
+ reviewsDir: REVIEWS_DIR,
169
+ });
170
+ expect(counters.showManyCalls, "exactly one batched read per collection").toBe(1);
171
+ expect(counters.showCalls, "no per-file git show once showMany answers").toBe(0);
172
+ expect(res.errors).toHaveLength(1);
173
+ expect(res.errors[0]!.message).toContain("DEV-1");
174
+ });
175
+
176
+ it("AC-3: batched and sequential paths produce the identical violation set", async () => {
177
+ const body = "# RFC-9001\n\n## Deviations\n\n- DEV-9 (review REVIEW-9): unrelated.\n";
178
+ const seq = await evaluateDeviationGate({
179
+ rfcId: RFC_ID,
180
+ strippedRfcBody: body,
181
+ git: fakeGit(FILES),
182
+ reviewsDir: REVIEWS_DIR,
183
+ });
184
+ const { git } = batchedGit(FILES, "specs");
185
+ const batched = await evaluateDeviationGate({
186
+ rfcId: RFC_ID,
187
+ strippedRfcBody: body,
188
+ git,
189
+ reviewsDir: REVIEWS_DIR,
190
+ });
191
+ expect(batched.errors).toEqual(seq.errors);
192
+ });
193
+
194
+ it("falls back to sequential show calls when showMany resolves null wholesale", async () => {
195
+ const { git, counters } = batchedGit(FILES, "null");
196
+ const res = await evaluateDeviationGate({
197
+ rfcId: RFC_ID,
198
+ strippedRfcBody: "# RFC-9001\n",
199
+ git,
200
+ reviewsDir: REVIEWS_DIR,
201
+ });
202
+ expect(counters.showCalls).toBe(Object.keys(FILES).length);
203
+ expect(res.errors).toHaveLength(1);
204
+ });
205
+ });
206
+
124
207
  describe("parseDeviationsSection", () => {
125
208
  it("ignores the grammar example inside a fenced block (caller strips)", () => {
126
209
  // The caller passes a fence-stripped body; fenced example content never arrives.
@@ -20,6 +20,13 @@ provenance in `## Deviations` entries.
20
20
  <item>RFC-1454: deviation gate — committed-review index, RFC-IMP-15, deviations-section parser for V-49.</item>
21
21
  <item>RFC-1454: review deviations recorded in the RFC — IMP-15 gate, V-49 provenance, skill contract</item>
22
22
  <item>RFC-1483: self-sufficient implement stamp — default repair pass, ordered remediation checklist, --no-repair</item>
23
+ <item>RFC-1513: steps 2-4 — batched committed-review reads + run-scoped index
24
+
25
+ OriginGit gains optional showMany backed by one git cat-file --batch
26
+ process (per-spec null on missing objects, wholesale null on spawn or
27
+ framing failure). collectCommittedReviews prefers it and keeps the
28
+ sequential show loop for stubs. rfc.validate memoizes the index once
29
+ per run and V-49 consumes it — identical diagnostics, one batched read.</item>
23
30
  </CHANGE_SUMMARY>
24
31
  */
25
32
 
@@ -76,9 +83,22 @@ export async function collectCommittedReviews(
76
83
  .split("\n")
77
84
  .map((l) => l.trim())
78
85
  .filter((p) => p.endsWith(".md"));
86
+ // RFC-1513: one batched `cat-file --batch` read when the port supports it —
87
+ // a wholesale failure (or a stub without showMany) keeps the sequential
88
+ // `git show` loop so the review list stays identical either way.
89
+ const specs = paths.map((p) => `HEAD:${p}`);
90
+ let contents: (string | null)[];
91
+ const batched = git.showMany ? await git.showMany(specs) : null;
92
+ if (batched) {
93
+ contents = batched;
94
+ } else {
95
+ contents = [];
96
+ for (const spec of specs) contents.push(await git.run(["show", spec]));
97
+ }
79
98
  const reviews: CommittedReview[] = [];
80
- for (const path of paths) {
81
- const content = await git.run(["show", `HEAD:${path}`]);
99
+ for (let i = 0; i < paths.length; i++) {
100
+ const path = paths[i]!;
101
+ const content = contents[i] ?? null;
82
102
  if (content === null) continue;
83
103
  const fm = frontmatterOf(content);
84
104
  if (!fm) continue;
@@ -14,6 +14,7 @@ Unit tests for implement stamp stale covering rfc.implement.stamp — RFC-IMP-09
14
14
  <item>RFC-1489: batch test probes through one instrumented Vitest run + frontmatter corpus reads
15
15
 
16
16
  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>
17
+ <item>RFC-1516: add an evidence-freshness window to the stamp-sync chain for rfc-1516</item>
17
18
  </CHANGE_SUMMARY>
18
19
  */
19
20
 
@@ -33,7 +34,10 @@ const { mockRunProbe } = vi.hoisted(() => ({
33
34
  mockRunProbe: vi.fn(),
34
35
  }));
35
36
 
36
- vi.mock("../acceptance.ts", () => ({
37
+ vi.mock("../acceptance.ts", async (importOriginal) => ({
38
+ // RFC-1516: keep classifyProbeReuse (and every non-execution export) real —
39
+ // emit's reuse path calls it when a committed envelope is present.
40
+ ...(await importOriginal<typeof import("../acceptance.ts")>()),
37
41
  runProbe: mockRunProbe,
38
42
  // RFC-1489: emit (which stamp composes) drives runProbeSet — the shim
39
43
  // preserves the per-probe mock contract.
@@ -12,12 +12,12 @@ verification evidence, and atomically mutates RFC frontmatter.
12
12
  </non-goals>
13
13
  </MODULE_CONTRACT>
14
14
  <CHANGE_SUMMARY>
15
- <item>RFC-1453: executed outcome probes, IMP-14 surface gate, outcome.serve + V-47/V-48</item>
16
15
  <item>RFC-1454: review deviations recorded in the RFC — IMP-15 gate, V-49 provenance, skill contract</item>
17
16
  <item>RFC-1483: self-sufficient implement stamp — default repair pass, ordered remediation checklist, --no-repair</item>
18
17
  <item>RFC-1504: step 4 — shared stamp lock for rfc and adr stamp handlers</item>
19
18
  <item>RFC-1504: review fixes — legacy acquiredAt fallback, atomic break claim, verified stamp release, onStale warnings</item>
20
- <history>RFC-0268, RFC-0476, RFC-0756, RFC-0795, RFC-0997, RFC-1053, RFC-1097, RFC-1249, RFC-1271, RFC-1306, RFC-1310, RFC-1321, RFC-1322, RFC-1330, RFC-1333, RFC-1383, RFC-1391, RFC-IMP-07</history>
19
+ <item>RFC-1516: add an evidence-freshness window to the stamp-sync chain for rfc-1516</item>
20
+ <history>RFC-0268, RFC-0476, RFC-0756, RFC-0795, RFC-0997, RFC-1053, RFC-1097, RFC-1249, RFC-1271, RFC-1306, RFC-1310, RFC-1321, RFC-1322, RFC-1330, RFC-1333, RFC-1383, RFC-1391, RFC-1453, RFC-IMP-07</history>
21
21
  </CHANGE_SUMMARY>
22
22
  */
23
23
 
@@ -895,7 +895,14 @@ export async function runRfcImplementStamp(
895
895
  }
896
896
  let syncReport: Awaited<ReturnType<NonNullable<typeof context.invoke>>>;
897
897
  try {
898
- syncReport = await context.invoke("rfc.evidence.sync", { id: targetId });
898
+ // RFC-1516: --no-evidence-reuse reaches the emit step through the
899
+ // sync chain — probes re-execute even inside the freshness window.
900
+ syncReport = await context.invoke("rfc.evidence.sync", {
901
+ id: targetId,
902
+ ...(input.flags["no-evidence-reuse"] === true
903
+ ? { "no-evidence-reuse": "true" }
904
+ : {}),
905
+ });
899
906
  } catch (err) {
900
907
  violations.push({
901
908
  rule: "EVIDENCE-SYNC-02",
@@ -1231,6 +1238,9 @@ export async function runRfcImplementStamp(
1231
1238
  flags: {
1232
1239
  id: targetId,
1233
1240
  ...(waiveOutcome ? { "waive-outcome": waiveOutcome } : {}),
1241
+ ...(input.flags["no-evidence-reuse"] === true
1242
+ ? { "no-evidence-reuse": true }
1243
+ : {}),
1234
1244
  },
1235
1245
  },
1236
1246
  context,
@@ -1449,6 +1459,9 @@ export async function runRfcImplementStamp(
1449
1459
  flags: {
1450
1460
  id: targetId,
1451
1461
  ...(waiveOutcome ? { "waive-outcome": waiveOutcome } : {}),
1462
+ ...(input.flags["no-evidence-reuse"] === true
1463
+ ? { "no-evidence-reuse": true }
1464
+ : {}),
1452
1465
  },
1453
1466
  },
1454
1467
  context,
@@ -74,7 +74,8 @@ export async function runRfcIndexGenerate(
74
74
  if (!result) {
75
75
  parseFailures.push({
76
76
  rule: "RFC-IDX-04",
77
- file: path.join(RFC_DIR, fileName),
77
+ // Reported paths are repo-relative — forward slashes on all platforms.
78
+ file: `${RFC_DIR}/${fileName}`,
78
79
  message: "file not readable",
79
80
  });
80
81
  continue;
@@ -82,7 +83,7 @@ export async function runRfcIndexGenerate(
82
83
  if ("error" in result) {
83
84
  parseFailures.push({
84
85
  rule: "RFC-IDX-04",
85
- file: path.join(RFC_DIR, fileName),
86
+ file: `${RFC_DIR}/${fileName}`,
86
87
  message: result.error,
87
88
  });
88
89
  continue;
@@ -103,7 +104,7 @@ export async function runRfcIndexGenerate(
103
104
  amends: arr("amends"),
104
105
  amendedBy: arr("amendedBy"),
105
106
  related: arr("related"),
106
- file: path.join(RFC_DIR, fileName),
107
+ file: `${RFC_DIR}/${fileName}`,
107
108
  });
108
109
  }
109
110
  entries.sort((a, b) => a.id.localeCompare(b.id));
@@ -133,7 +134,7 @@ export async function runRfcIndexGenerate(
133
134
 
134
135
  let written: string | undefined;
135
136
  if (input.flags["write"] === true) {
136
- const outRel = path.join(RFC_DIR, "index.yaml");
137
+ const outRel = `${RFC_DIR}/index.yaml`;
137
138
  const payload = {
138
139
  command: "rfc.index.generate",
139
140
  generatedAt: toIsoDate(new Date()),