@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
@@ -3,7 +3,7 @@
3
3
  <purpose>flow.open tests (RFC-1487 step 3, AC-1/AC-2): the session worktree
4
4
  lands beside the primary as &lt;repo&gt;@&lt;branch-slug&gt; from the develop
5
5
  tip, NN increments across local and remote-tracking names, refusals
6
- FLOW-OPEN-01/03/05, and a failing setup script exits 1 while keeping the
6
+ FLOW-OPEN-10/03/05, and a failing setup script exits 1 while keeping the
7
7
  worktree and registry entry.</purpose>
8
8
  <non-goals>
9
9
  <item>No lifecycle coverage beyond open — integrate/discard have their own files.</item>
@@ -12,12 +12,15 @@ worktree and registry entry.</purpose>
12
12
  <CHANGE_SUMMARY>
13
13
  <item>RFC-1487: step 3 — flow.open tests</item>
14
14
  <item>RFC-1487: step 3 — flow.open with NN assignment over local/remote/registry names</item>
15
+ <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
16
  </CHANGE_SUMMARY>
16
17
  */
17
18
 
18
19
  import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
19
20
  import { tmpdir } from "node:os";
20
- import { dirname, join } from "node:path";
21
+ import { basename, dirname, join } from "node:path";
22
+
23
+ import { canonicalRepoDir } from "../../../src/utils/repo-path.ts";
21
24
 
22
25
  import { afterEach, describe, expect, it } from "vitest";
23
26
 
@@ -66,10 +69,13 @@ describe("flow.open", () => {
66
69
 
67
70
  expect(data.diagnostics).toEqual([]);
68
71
  const name = formatFlowBranch({ kind: "session", date: NOW, seq: 1, slug: "forge-flow" });
69
- const expectedPath = join(dirname(repo), `${repo.split("/").pop()}@${name.replaceAll("/", "-")}`);
72
+ // Product answers in the canonical frame (git's worktree list) — on
73
+ // Windows the mkdtemp 8.3 alias resolves to a different spelling of the
74
+ // same directory, so comparisons go through realpath.
75
+ const expectedPath = join(dirname(repo), `${basename(repo)}@${name.replaceAll("/", "-")}`);
70
76
  expect(data.branch).toBe(name);
71
- expect(data.worktree).toBe(expectedPath);
72
- expect(data.worktree?.startsWith(dirname(repo))).toBe(true);
77
+ expect(data.worktree).toBe(canonicalRepoDir(expectedPath));
78
+ expect(data.worktree?.startsWith(dirname(canonicalRepoDir(repo)))).toBe(true);
73
79
  dirs.push(expectedPath);
74
80
  expect(await sha(repo, name)).toBe(developSha);
75
81
  expect(data.opened).toBe(true);
@@ -77,7 +83,7 @@ describe("flow.open", () => {
77
83
  const common = await commonGitDir(ambientIo, repo);
78
84
  const registry = await readRegistry(ambientIo, common);
79
85
  const entry = registry.branches.find((b) => b.name === name);
80
- expect(entry?.worktree).toBe(expectedPath);
86
+ expect(entry?.worktree).toBe(canonicalRepoDir(expectedPath));
81
87
  expect(entry?.baseSha).toBe(developSha);
82
88
  expect(entry?.owner).toEqual({ kind: "session", id: "unspecified" });
83
89
  expect(entry?.held).toBeNull();
@@ -130,7 +136,7 @@ describe("flow.open", () => {
130
136
  if (data.worktree) dirs.push(data.worktree);
131
137
  }, 15_000);
132
138
 
133
- it("refuses FLOW-OPEN-01 on an invalid slug", async () => {
139
+ it("refuses FLOW-OPEN-10 on an invalid slug", async () => {
134
140
  const repo = await governedRepo();
135
141
  const data = await openFlowBranch(repo, ambientIo, {
136
142
  kind: "session",
@@ -140,7 +146,7 @@ describe("flow.open", () => {
140
146
  dryRun: false,
141
147
  now: NOW,
142
148
  });
143
- expect(data.diagnostics[0]?.ruleId).toBe("FLOW-OPEN-01");
149
+ expect(data.diagnostics[0]?.ruleId).toBe("FLOW-OPEN-10");
144
150
  expect(data.opened).toBe(false);
145
151
  }, 15_000);
146
152
 
@@ -160,7 +166,7 @@ describe("flow.open", () => {
160
166
  it("refuses FLOW-OPEN-03 when the target path exists", async () => {
161
167
  const repo = await governedRepo();
162
168
  const name = formatFlowBranch({ kind: "session", date: NOW, seq: 1, slug: "taken" });
163
- const target = join(dirname(repo), `${repo.split("/").pop()}@${name.replaceAll("/", "-")}`);
169
+ const target = join(dirname(repo), `${basename(repo)}@${name.replaceAll("/", "-")}`);
164
170
  await mkdir(target, { recursive: true });
165
171
  dirs.push(target);
166
172
 
@@ -197,4 +203,41 @@ describe("flow.open", () => {
197
203
  const registry = await readRegistry(ambientIo, common);
198
204
  expect(registry.branches.some((b) => b.name === data.branch)).toBe(true);
199
205
  }, 15_000);
206
+
207
+ it("warns FLOW-OPEN-01 when the primary carries tracked mutations (RFC-1536 AC-2)", async () => {
208
+ const repo = await governedRepo();
209
+ // A tracked mutation in the primary — forge.yaml is committed, then edited.
210
+ await gitExec(repo, ["add", "forge.yaml"]);
211
+ await gitExec(repo, ["commit", "-m", "seed forge.yaml"]);
212
+ await writeFile(join(repo, "forge.yaml"), 'schema: "forge/workspace@1"\ndirty: true\n');
213
+
214
+ const data = await openFlowBranch(repo, ambientIo, {
215
+ kind: "session",
216
+ slug: "dirty-primary",
217
+ brief: null,
218
+ owner: null,
219
+ dryRun: false,
220
+ now: NOW,
221
+ });
222
+ if (data.worktree) dirs.push(data.worktree);
223
+ expect(data.opened).toBe(true);
224
+ const warning = data.diagnostics.find((d) => d.ruleId === "FLOW-OPEN-01");
225
+ expect(warning?.severity).toBe("warning");
226
+ expect(warning?.message).toContain("forge.yaml");
227
+ expect(warning?.message).toContain("NOT swept");
228
+ }, 15_000);
229
+
230
+ it("emits no FLOW-OPEN-01 when the primary is clean (RFC-1536 AC-2)", async () => {
231
+ const repo = await governedRepo();
232
+ const data = await openFlowBranch(repo, ambientIo, {
233
+ kind: "session",
234
+ slug: "clean-primary",
235
+ brief: null,
236
+ owner: null,
237
+ dryRun: false,
238
+ now: NOW,
239
+ });
240
+ if (data.worktree) dirs.push(data.worktree);
241
+ expect(data.diagnostics.some((d) => d.ruleId === "FLOW-OPEN-01")).toBe(false);
242
+ }, 15_000);
200
243
  });
@@ -17,6 +17,8 @@ with an ours-merge and never force-pushes.</purpose>
17
17
  <item>RFC-1491: step 5 — flow.push publication tests</item>
18
18
  <item>RFC-1491: step 5 — flow.push atomic outbound path + extract publication</item>
19
19
  <item>RFC-1491: independent-review pass — shared lock constants, publishable pending filter, declared rules, hold ordering, sha-pinned refspecs</item>
20
+ <item>RFC-1517: add preflight-extract-gates — FLOW-PUB-01 changelog check at ref plus shared PKG-HEALTH-10 fixture-path scan for RFC-1517</item>
21
+ <item>RFC-1517: make pkg-health-10 shipped-set faithful and scan the publish ref</item>
20
22
  </CHANGE_SUMMARY>
21
23
  */
22
24
 
@@ -28,6 +30,7 @@ import { afterEach, describe, expect, it } from "vitest";
28
30
  import { ambientIo } from "../../../src/utils/io.ts";
29
31
  import { collectDigest } from "../digest.ts";
30
32
  import { pushFlow } from "../handlers/flow-push.ts";
33
+ import { verifyLineAtRef } from "../publish.ts";
31
34
  import { markerContent } from "../markers.ts";
32
35
  import { releaseTagAnnotation, writeReleaseTag } from "../release-tags.ts";
33
36
  import { commonGitDir, readJournal } from "../registry.ts";
@@ -243,6 +246,127 @@ describe("flow.push publications", () => {
243
246
  expect(await extractLog(log)).toBe("");
244
247
  }, 90_000);
245
248
 
249
+ it("a CHANGELOG missing the [version] section refuses FLOW-PUB-01 before any extract spawn (AC-1)", async () => {
250
+ const { repo, extractLog: log } = await initRepoWithOrigin(dirs, {
251
+ prefix: "flow-pub-",
252
+ fakeExtract: true,
253
+ });
254
+ await addPackageLine(repo);
255
+ await writeFile(
256
+ join(repo, "packages", "lib", "CHANGELOG.md"),
257
+ "# Changelog\n\n## [2.0.0] - 2026-01-01\n\n- earlier release\n",
258
+ );
259
+ await gitExec(repo, ["add", "-A"]);
260
+ await gitExec(repo, ["commit", "-m", "changelog without the publish section"]);
261
+ await gitExec(repo, ["push", "origin", "develop"]);
262
+ await tag(repo, "lib@2.1.0", "lib", "2.1.0", "minor");
263
+
264
+ const digest = await collectDigest(repo, ambientIo, { fetch: false });
265
+ const data = await pushFlow(repo, ambientIo, { digest: digest.digestId, dryRun: false });
266
+ const pub = data.publications.find((p) => p.tag === "lib@2.1.0");
267
+ expect(pub?.status).toBe("failed");
268
+ expect(pub?.error).toContain("preflight-extract-gates");
269
+ expect(pub?.error).toContain("FLOW-PUB-01");
270
+ expect(pub?.error).toContain("[2.1.0]");
271
+ // The whole point of the preflight — repo-extract never ran.
272
+ expect(await extractLog(log)).toBe("");
273
+ }, 90_000);
274
+
275
+ it("verifyLineAtRef refuses FLOW-PUB-01 pre-extract when the ref's CHANGELOG lacks the section (AC-1)", async () => {
276
+ const { repo, extractLog: log } = await initRepoWithOrigin(dirs, {
277
+ prefix: "flow-pub-",
278
+ fakeExtract: true,
279
+ });
280
+ await addPackageLine(repo);
281
+ await writeFile(
282
+ join(repo, "packages", "lib", "CHANGELOG.md"),
283
+ "# Changelog\n\n## [2.0.0] - 2026-01-01\n\n- earlier release\n",
284
+ );
285
+ await gitExec(repo, ["add", "-A"]);
286
+ await gitExec(repo, ["commit", "-m", "changelog without the publish section"]);
287
+ const sha = (await gitExec(repo, ["rev-parse", "HEAD"])).stdout.trim();
288
+
289
+ const result = await verifyLineAtRef(repo, ambientIo, {
290
+ line: { id: "lib", tagPrefix: "lib@", versionFile: "packages/lib/package.json", paths: ["packages/lib"] },
291
+ ref: sha,
292
+ });
293
+ expect(result.ok).toBe(false);
294
+ expect(result.detail).toContain("preflight-extract-gates");
295
+ expect(result.detail).toContain("FLOW-PUB-01");
296
+ expect(result.detail).toContain("[2.1.0]");
297
+ expect(await extractLog(log)).toBe("");
298
+ }, 90_000);
299
+
300
+ it("a bare [version]: link reference without a release heading refuses FLOW-PUB-01", async () => {
301
+ const { repo, extractLog: log } = await initRepoWithOrigin(dirs, {
302
+ prefix: "flow-pub-",
303
+ fakeExtract: true,
304
+ });
305
+ await addPackageLine(repo);
306
+ await writeFile(
307
+ join(repo, "packages", "lib", "CHANGELOG.md"),
308
+ "# Changelog\n\n## [2.0.0] - 2026-01-01\n\n- earlier release\n\n[2.1.0]: https://example.com/diff\n",
309
+ );
310
+ await gitExec(repo, ["add", "-A"]);
311
+ await gitExec(repo, ["commit", "-m", "changelog with only a link reference"]);
312
+ await gitExec(repo, ["push", "origin", "develop"]);
313
+ await tag(repo, "lib@2.1.0", "lib", "2.1.0", "minor");
314
+
315
+ const digest = await collectDigest(repo, ambientIo, { fetch: false });
316
+ const data = await pushFlow(repo, ambientIo, { digest: digest.digestId, dryRun: false });
317
+ const pub = data.publications.find((p) => p.tag === "lib@2.1.0");
318
+ expect(pub?.status).toBe("failed");
319
+ expect(pub?.error).toContain("FLOW-PUB-01");
320
+ expect(await extractLog(log)).toBe("");
321
+ }, 90_000);
322
+
323
+ it("a shipped file's root-escaping ../ literal refuses PKG-HEALTH-10 at file:line (AC-7)", async () => {
324
+ const { repo, extractLog: log } = await initRepoWithOrigin(dirs, {
325
+ prefix: "flow-pub-",
326
+ fakeExtract: true,
327
+ });
328
+ await addPackageLine(repo);
329
+ await mkdir(join(repo, "packages", "lib", "src", "tests"), { recursive: true });
330
+ await writeFile(
331
+ join(repo, "packages", "lib", "src", "tests", "fixture.test.ts"),
332
+ 'const fixture = "../../../docs/rfcs/rfc-0000-template.md";\nexport { fixture };\n',
333
+ );
334
+ await gitExec(repo, ["add", "-A"]);
335
+ await gitExec(repo, ["commit", "-m", "fixture path escaping the package root"]);
336
+ await gitExec(repo, ["push", "origin", "develop"]);
337
+ await tag(repo, "lib@2.1.0", "lib", "2.1.0", "minor");
338
+
339
+ const digest = await collectDigest(repo, ambientIo, { fetch: false });
340
+ const data = await pushFlow(repo, ambientIo, { digest: digest.digestId, dryRun: false });
341
+ const pub = data.publications.find((p) => p.tag === "lib@2.1.0");
342
+ expect(pub?.status).toBe("failed");
343
+ expect(pub?.error).toContain("PKG-HEALTH-10");
344
+ expect(pub?.error).toContain("packages/lib/src/tests/fixture.test.ts:1");
345
+ expect(await extractLog(log)).toBe("");
346
+ }, 90_000);
347
+
348
+ it("an uncommitted root-escaping file does NOT refuse — the scan reads the tag's tree (RFC-1517 r1)", async () => {
349
+ const { repo, extractLog: log } = await initRepoWithOrigin(dirs, {
350
+ prefix: "flow-pub-",
351
+ fakeExtract: true,
352
+ });
353
+ await addPackageLine(repo);
354
+ // Untracked escape: never enters the tag's tree, so the extract never
355
+ // ships it — flagging it would be a false refusal.
356
+ await mkdir(join(repo, "packages", "lib", "src"), { recursive: true });
357
+ await writeFile(
358
+ join(repo, "packages", "lib", "src", "scratch.ts"),
359
+ 'const scratch = "../../../outside.md";\n',
360
+ );
361
+ await tag(repo, "lib@2.1.0", "lib", "2.1.0", "minor");
362
+
363
+ const digest = await collectDigest(repo, ambientIo, { fetch: false });
364
+ const data = await pushFlow(repo, ambientIo, { digest: digest.digestId, dryRun: false });
365
+ const pub = data.publications.find((p) => p.tag === "lib@2.1.0");
366
+ expect(pub?.status).toBe("published");
367
+ expect(await extractLog(log)).not.toBe("");
368
+ }, 90_000);
369
+
246
370
  it("a non-fast-forward destination reconciles once with an ours-merge", async () => {
247
371
  const { repo, parent } = await initRepoWithOrigin(dirs, {
248
372
  prefix: "flow-pub-",
@@ -10,6 +10,7 @@ lastCommitAt/stale/held fields matching the RFC's example shape.</purpose>
10
10
  <CHANGE_SUMMARY>
11
11
  <item>RFC-1487: step 5 — flow.status tests</item>
12
12
  <item>RFC-1487: step 5 — flow.discard, flow.status, flow.check FLOW-06/07</item>
13
+ <item>RFC-1515: close rfc-1515 review findings — delete tolerated paths before worktree remove, prune vanished registrations, verified branch -D, shared held-lock render, gated e2e throw, journal toleratedState, edge tests</item>
13
14
  </CHANGE_SUMMARY>
14
15
  */
15
16
 
@@ -19,6 +20,7 @@ import { join } from "node:path";
19
20
  import { afterEach, describe, expect, it } from "vitest";
20
21
 
21
22
  import { ambientIo } from "../../../src/utils/io.ts";
23
+ import { canonicalRepoDir } from "../../../src/utils/repo-path.ts";
22
24
  import { openFlowBranch } from "../handlers/flow-open.ts";
23
25
  import { collectFlowStatus } from "../handlers/flow-status.ts";
24
26
  import { gitExec, initRepo } from "./helpers.ts";
@@ -58,7 +60,9 @@ describe("flow.status", () => {
58
60
  await gitExec(repo, ["commit", "-m", "add d.txt"]); // develop ahead by 1
59
61
 
60
62
  const outcome = await collectFlowStatus(repo, ambientIo, { now: NOW });
61
- expect(outcome.data.primary.path).toBe(repo);
63
+ // primary.path is canonicalized (git's worktree frame) — compare the
64
+ // real spelling of the same directory, not the mkdtemp 8.3 alias.
65
+ expect(outcome.data.primary.path).toBe(canonicalRepoDir(repo));
62
66
  expect(outcome.data.primary.branch).toBe("develop");
63
67
  expect(outcome.data.primary.clean).toBe(true);
64
68
 
@@ -90,4 +94,30 @@ describe("flow.status", () => {
90
94
  expect(row?.worktree).toBeNull();
91
95
  expect(row?.worktreeExists).toBe(false);
92
96
  }, 15_000);
97
+
98
+ it("renders a registered entry whose worktree path vanished as vanished, distinct from absent (RFC-1515)", async () => {
99
+ const repo = await initRepo({ prefix: "flow-status-vanished-" });
100
+ dirs.push(repo);
101
+ await writeFile(join(repo, "forge.yaml"), 'schema: "forge/workspace@1"\n');
102
+ await gitExec(repo, ["branch", "develop", "HEAD"]);
103
+ await gitExec(repo, ["switch", "develop"]);
104
+
105
+ const session = await openFlowBranch(repo, ambientIo, {
106
+ kind: "session",
107
+ slug: "gone",
108
+ brief: "status test",
109
+ owner: null,
110
+ dryRun: false,
111
+ now: NOW,
112
+ });
113
+ await rm(session.worktree!, { recursive: true, force: true });
114
+ await gitExec(repo, ["worktree", "prune"]);
115
+
116
+ const outcome = await collectFlowStatus(repo, ambientIo, { now: NOW });
117
+ const row = outcome.data.branches.find((b) => b.name === session.branch);
118
+ expect(row?.registered).toBe(true);
119
+ expect(row?.worktreeExists).toBe(false);
120
+ expect(row?.vanished).toBe(true);
121
+ expect(row?.dirty).toBeNull();
122
+ }, 15_000);
93
123
  });
@@ -11,6 +11,7 @@ id on this host is treated as dead. Uses injected now/sleep — no real waits.</
11
11
  <CHANGE_SUMMARY>
12
12
  <item>RFC-1504: step 1 — dead-holder lock tests</item>
13
13
  <item>RFC-1504: review fixes — legacy acquiredAt fallback, atomic break claim, verified stamp release, onStale warnings</item>
14
+ <item>RFC-1515: close rfc-1515 review findings — delete tolerated paths before worktree remove, prune vanished registrations, verified branch -D, shared held-lock render, gated e2e throw, journal toleratedState, edge tests</item>
14
15
  </CHANGE_SUMMARY>
15
16
  */
16
17
 
@@ -22,7 +23,7 @@ import { spawnSync } from "node:child_process";
22
23
  import { afterEach, describe, expect, it } from "vitest";
23
24
 
24
25
  import { currentBootId, holderIsDead } from "../../core/lock-holder.ts";
25
- import { withFlowLock, LockTimeoutError } from "../locks.ts";
26
+ import { describeHeldLock, withFlowLock, LockTimeoutError } from "../locks.ts";
26
27
 
27
28
  const dirs: string[] = [];
28
29
  afterEach(async () => {
@@ -80,8 +81,10 @@ describe("holderIsDead (RFC-1504)", () => {
80
81
  });
81
82
 
82
83
  it("a pid we cannot signal (EPERM) counts as alive — fail closed", () => {
83
- // pid 1 belongs to init: signal-0 either succeeds or EPERMs, never ESRCH.
84
- expect(holderIsDead({ pid: 1, host: HOST })).toBe(false);
84
+ // init (pid 1) on POSIX; the System process (pid 4) on Windows — each
85
+ // survives or EPERMs a signal-0 on its own platform, never ESRCH.
86
+ const unsignalablePid = process.platform === "win32" ? 4 : 1;
87
+ expect(holderIsDead({ pid: unsignalablePid, host: HOST })).toBe(false);
85
88
  });
86
89
 
87
90
  it("different boot id on this host → dead even with a live pid (AC-4 basis)", () => {
@@ -217,3 +220,36 @@ describe("withFlowLock dead-holder recovery (RFC-1504)", () => {
217
220
  else expect(content?.bootId).toBe(boot);
218
221
  });
219
222
  });
223
+
224
+ describe("describeHeldLock — RFC-1515 lock payload classification", () => {
225
+ it("reports a live local holder with a numeric heldMs", () => {
226
+ const at = new Date(Date.now() - 5_000).toISOString();
227
+ const lock = describeHeldLock({ pid: livePid(), host: HOST, at }, 3_600_000);
228
+ expect(lock.disposition).toBe("live");
229
+ expect(lock.heldMs).toBeGreaterThanOrEqual(5_000);
230
+ expect(lock.pid).toBe(process.pid);
231
+ expect(lock.host).toBe(HOST);
232
+ expect(lock.at).toBe(at);
233
+ });
234
+
235
+ it("reports a dead local pid as dead-holder even inside the stale budget", () => {
236
+ const lock = describeHeldLock(
237
+ { pid: deadPid(), host: HOST, at: new Date().toISOString() },
238
+ 3_600_000,
239
+ );
240
+ expect(lock.disposition).toBe("dead-holder");
241
+ });
242
+
243
+ it("reports a live holder beyond the stale budget as stale", () => {
244
+ const at = new Date(Date.now() - 7_200_000).toISOString();
245
+ const lock = describeHeldLock({ pid: livePid(), host: HOST, at }, 3_600_000);
246
+ expect(lock.disposition).toBe("stale");
247
+ expect(lock.heldMs).toBeGreaterThan(3_600_000);
248
+ });
249
+
250
+ it("degrades heldMs to null when the holder timestamp never parsed", () => {
251
+ const lock = describeHeldLock({ pid: livePid(), host: HOST, at: "garbage" }, 3_600_000);
252
+ expect(lock.heldMs).toBeNull();
253
+ expect(lock.disposition).toBe("live");
254
+ });
255
+ });
@@ -17,7 +17,7 @@ runs even when the branch worktree carries a different one
17
17
 
18
18
  import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
19
19
  import { tmpdir } from "node:os";
20
- import { join } from "node:path";
20
+ import { basename, join } from "node:path";
21
21
 
22
22
  import { afterEach, describe, expect, it } from "vitest";
23
23
 
@@ -62,7 +62,10 @@ describe("runFlowScript", () => {
62
62
  });
63
63
  expect(result.status).toBe("done");
64
64
  const { readFile } = await import("node:fs/promises");
65
- expect(await readFile(join(branch, "out.txt"), "utf8")).toContain(branch);
65
+ // The script runs through sh — on Windows pwd answers MSYS-style
66
+ // (/c/Users/…), so the assertion keys on the directory's basename,
67
+ // which survives the translation while still pinning cwd to `branch`.
68
+ expect(await readFile(join(branch, "out.txt"), "utf8")).toContain(basename(branch));
66
69
  expect(await readFile(join(branch, "branch.txt"), "utf8")).toContain("auto/x");
67
70
  });
68
71
 
@@ -23,6 +23,7 @@ import { tmpdir } from "node:os";
23
23
  import { basename, dirname, join } from "node:path";
24
24
 
25
25
  import { ambientIo } from "../../../src/utils/io.ts";
26
+ import { canonicalRepoDir } from "../../../src/utils/repo-path.ts";
26
27
  import type { ForgeCommandInput, ForgeRuntimeContext } from "../../../src/types.ts";
27
28
 
28
29
  import { resolveStateRoots } from "../worktree-path.ts";
@@ -61,8 +62,10 @@ describe("resolveStateRoots (RFC-1495)", () => {
61
62
  const repo = await initRepo({ prefix: "state-roots-" });
62
63
  dirs.push(repo);
63
64
  const roots = await resolveStateRoots(repo, io);
64
- expect(roots.worktreeRoot).toBe(repo);
65
- expect(roots.primaryRoot).toBe(repo);
65
+ // Roots come back canonicalized (git's resolved frame) — compare real
66
+ // spellings, not the mkdtemp 8.3 alias Windows may hand out.
67
+ expect(roots.worktreeRoot).toBe(canonicalRepoDir(repo));
68
+ expect(roots.primaryRoot).toBe(canonicalRepoDir(repo));
66
69
  expect(roots.isPrimary).toBe(true);
67
70
  });
68
71
 
@@ -77,13 +80,13 @@ describe("resolveStateRoots (RFC-1495)", () => {
77
80
  dirs.push(wt);
78
81
 
79
82
  const roots = await resolveStateRoots(wt, io);
80
- expect(roots.worktreeRoot).toBe(wt);
81
- expect(roots.primaryRoot).toBe(repo);
83
+ expect(roots.worktreeRoot).toBe(canonicalRepoDir(wt));
84
+ expect(roots.primaryRoot).toBe(canonicalRepoDir(repo));
82
85
  expect(roots.isPrimary).toBe(false);
83
86
 
84
87
  const primary = await resolveStateRoots(repo, io);
85
88
  expect(primary.isPrimary).toBe(true);
86
- expect(primary.worktreeRoot).toBe(repo);
89
+ expect(primary.worktreeRoot).toBe(canonicalRepoDir(repo));
87
90
  });
88
91
 
89
92
  test("non-git directory degrades to itself", async () => {
@@ -34,6 +34,7 @@ and integrate exposes teardown as its own field.</item>
34
34
  import { basename, dirname, join } from "node:path";
35
35
 
36
36
  import type { WorkspaceIO } from "../../src/types.ts";
37
+ import { canonicalRepoDir } from "../../src/utils/repo-path.ts";
37
38
 
38
39
  import { topLevel, worktreeList } from "./git.ts";
39
40
 
@@ -85,10 +86,15 @@ export async function resolveStateRoots(
85
86
  io: WorkspaceIO,
86
87
  ): Promise<StateRoots> {
87
88
  const top = await topLevel(repoRoot, io);
89
+ // Both frames canonicalized — git's toplevel and worktreeList paths are
90
+ // native real paths, while the caller's repoRoot may be an 8.3 alias or
91
+ // symlinked spelling of the same directory. Comparing raw strings would
92
+ // silently degrade every Windows call to single-root.
93
+ const canonicalRoot = canonicalRepoDir(repoRoot.replace(/[/\\]+$/, ""));
88
94
  // The workshop anchor is the caller's root — only when that root IS the
89
95
  // repository worktree root does worktree topology apply. A subdirectory
90
96
  // of a repo (or a non-git dir) has no workshop layout to resolve.
91
- if (!top || top !== repoRoot.replace(/[/\\]+$/, "")) {
97
+ if (!top || top !== canonicalRoot) {
92
98
  return { worktreeRoot: repoRoot, primaryRoot: repoRoot, isPrimary: true };
93
99
  }
94
100
  let primaryRoot: string;
@@ -100,8 +106,8 @@ export async function resolveStateRoots(
100
106
  return { worktreeRoot: repoRoot, primaryRoot: repoRoot, isPrimary: true };
101
107
  }
102
108
  return {
103
- worktreeRoot: repoRoot,
109
+ worktreeRoot: top,
104
110
  primaryRoot,
105
- isPrimary: repoRoot === primaryRoot,
111
+ isPrimary: top === primaryRoot,
106
112
  };
107
113
  }
@@ -75,14 +75,17 @@ function forgeYaml(tools: Record<string, FormalToolEntry>): void {
75
75
  if (Object.keys(tools).length > 0) lines[1] = " tools:";
76
76
  for (const [name, t] of Object.entries(tools)) {
77
77
  lines.push(` ${name}:`);
78
+ // JSON.stringify is valid YAML double-quoted quoting — it escapes both
79
+ // `"` and `\`, so a Windows execPath (C:\Program Files\…) survives the
80
+ // round trip instead of dissolving into invalid \P/\n escape sequences.
78
81
  lines.push(
79
- ` command: [${t.command.map((a) => `"${a.replaceAll('"', '\\"')}"`).join(", ")}]`,
82
+ ` command: [${t.command.map((a) => JSON.stringify(a)).join(", ")}]`,
80
83
  );
81
84
  lines.push(
82
- ` versionCommand: [${t.versionCommand.map((a) => `"${a.replaceAll('"', '\\"')}"`).join(", ")}]`,
85
+ ` versionCommand: [${t.versionCommand.map((a) => JSON.stringify(a)).join(", ")}]`,
83
86
  );
84
87
  lines.push(` versionPattern: '${t.versionPattern.replaceAll("'", "''")}'`);
85
- if (t.installHint) lines.push(` installHint: "${t.installHint}"`);
88
+ if (t.installHint) lines.push(` installHint: ${JSON.stringify(t.installHint)}`);
86
89
  }
87
90
  writeFileSync(
88
91
  join(ws, "forge.yaml"),
@@ -7,6 +7,9 @@
7
7
  </MODULE_CONTRACT>
8
8
  <CHANGE_SUMMARY>
9
9
  <item>RFC-1485: sweep compass headers — forge-os-tail</item>
10
+ <item>RFC-1522: slim AGENTS.md to injection-safe skeletons + extract docs/agent-guides + budget gate
11
+
12
+ 8 rule files (1.19 MB -> 50.6 KB total) split into <=12,288-byte skeletons; 212 moved ## sections preserved verbatim across 21 guides (heading parity verified). forge.yaml instructions.budget.enforce promotes INSTR-01 to an error gate at the 3072-token ceiling. Withdrawn rules.budget.check removed — dedupe onto the RFC-1466 command. fo-doctor invokes the real gate.</item>
10
13
  </CHANGE_SUMMARY>
11
14
  */
12
15
 
@@ -72,6 +75,34 @@ describe("instructions.budget.validate (RFC-1466)", () => {
72
75
  const res = await runInstructionsBudgetValidate(flags({}), ctx());
73
76
  expect(res.data?.diagnostics.some((d) => d.ruleId === "INSTR-03")).toBe(true);
74
77
  });
78
+
79
+ test("RFC-1522: enforce promotes INSTR-01 to error and exits 1", async () => {
80
+ await writeFile(
81
+ join(root, "forge.yaml"),
82
+ `schema: forge/config@1\ninstructions:\n budget:\n maxLinesPerFile: 3\n maxTokensPerFile: 40\n enforce: true\n`,
83
+ );
84
+ await writeFile(
85
+ join(root, "AGENTS.md"),
86
+ Array.from({ length: 10 }, (_, i) => `- line ${i}`).join("\n") + "\n",
87
+ );
88
+ await mkdir(join(root, "docs"), { recursive: true });
89
+ const res = await runInstructionsBudgetValidate(flags({}), ctx());
90
+ const instr = res.data?.diagnostics.find((d) => d.ruleId === "INSTR-01");
91
+ expect(instr?.severity).toBe("error");
92
+ expect(res.exitCode).toBe(1);
93
+ });
94
+
95
+ test("RFC-1522: enforce still exits 0 when every file is under budget", async () => {
96
+ await writeFile(
97
+ join(root, "forge.yaml"),
98
+ `schema: forge/config@1\ninstructions:\n budget:\n maxLinesPerFile: 400\n maxTokensPerFile: 3072\n enforce: true\n`,
99
+ );
100
+ await writeFile(join(root, "AGENTS.md"), "## Section A\n- ok\n");
101
+ await mkdir(join(root, "docs"), { recursive: true });
102
+ const res = await runInstructionsBudgetValidate(flags({}), ctx());
103
+ expect(res.exitCode).toBe(0);
104
+ expect(res.data?.diagnostics.every((d) => d.severity !== "error")).toBe(true);
105
+ });
75
106
  });
76
107
 
77
108
  describe("scar.migrate (RFC-1466)", () => {
@@ -5,17 +5,22 @@ RFC-1466: instructions.budget.validate — bound the instruction layer.
5
5
  INSTR-01 AGENTS.md file over declared budget; INSTR-2 scar-classified bullet
6
6
  in an exempt section (informational); INSTR-03 migrated scar still present
7
7
  as prose (fragment entry exists, bullet not removed).
8
+ RFC-1522: forge.yaml instructions.budget.enforce promotes INSTR-01 from
9
+ warning to error and exits 1 — the injection-safe ceiling becomes a gate.
8
10
  Autonomous — scans repo files only (FORGE-AUTONOMY-01).
9
11
  </purpose>
10
12
  <non-goals>
11
13
  <item>Does not migrate scars — scar.migrate owns that.</item>
12
- <item>Wave-1 rollout: reporting-only diagnostics until the first migration pass brings files under ceiling.</item>
14
+ <item>INSTR-02/03 stay warnings under enforce — only the budget ceiling is a gate.</item>
13
15
  </non-goals>
14
16
  </MODULE_CONTRACT>
15
17
  <CHANGE_SUMMARY>
16
18
  <item>RFC-1466: INSTR-01/02/03 budget + scar-classification audit over AGENTS.md files</item>
17
19
  <item>RFC-1466: bound the instruction layer — instructions.budget.validate, scar.migrate, catalog fragment merge</item>
18
20
  <item>RFC-1466: apply r1 repairs — fragment remedies reachable via lookupRemediation, pending-marker ordering, comment-preserving catalogRefs</item>
21
+ <item>RFC-1522: slim AGENTS.md to injection-safe skeletons + extract docs/agent-guides + budget gate
22
+
23
+ 8 rule files (1.19 MB -> 50.6 KB total) split into <=12,288-byte skeletons; 212 moved ## sections preserved verbatim across 21 guides (heading parity verified). forge.yaml instructions.budget.enforce promotes INSTR-01 to an error gate at the 3072-token ceiling. Withdrawn rules.budget.check removed — dedupe onto the RFC-1466 command. fo-doctor invokes the real gate.</item>
19
24
  </CHANGE_SUMMARY>
20
25
  */
21
26
 
@@ -49,6 +54,7 @@ export interface InstructionsBudget {
49
54
  maxTokensPerFile: number;
50
55
  exemptSections: string[];
51
56
  overrides: Record<string, { maxLinesPerFile?: number; maxTokensPerFile?: number }>;
57
+ enforce: boolean;
52
58
  }
53
59
 
54
60
  export const DEFAULT_BUDGET: InstructionsBudget = {
@@ -56,6 +62,7 @@ export const DEFAULT_BUDGET: InstructionsBudget = {
56
62
  maxTokensPerFile: 12000,
57
63
  exemptSections: ["Verbund", "Monorepo layout"],
58
64
  overrides: {},
65
+ enforce: false,
59
66
  };
60
67
 
61
68
  const SCAR_RE =
@@ -72,7 +79,8 @@ export function loadBudget(raw: unknown): InstructionsBudget {
72
79
  }
73
80
  const b = raw as Record<string, unknown>;
74
81
  const unknown = Object.keys(b).filter(
75
- (k) => !["maxLinesPerFile", "maxTokensPerFile", "exemptSections", "overrides"].includes(k),
82
+ (k) =>
83
+ !["maxLinesPerFile", "maxTokensPerFile", "exemptSections", "overrides", "enforce"].includes(k),
76
84
  );
77
85
  if (unknown.length > 0) {
78
86
  throw new Error(`instructions.budget: unknown field(s) ${unknown.join(", ")}`);
@@ -83,6 +91,7 @@ export function loadBudget(raw: unknown): InstructionsBudget {
83
91
  if (b.overrides != null && typeof b.overrides === "object" && !Array.isArray(b.overrides)) {
84
92
  out.overrides = b.overrides as InstructionsBudget["overrides"];
85
93
  }
94
+ if (b.enforce === true) out.enforce = true;
86
95
  return out;
87
96
  }
88
97
 
@@ -143,7 +152,7 @@ export async function runInstructionsBudgetValidate(
143
152
  if (lines.length > maxLines || estTokens > maxTokens) {
144
153
  diagnostics.push({
145
154
  ruleId: "INSTR-01",
146
- severity: "warning",
155
+ severity: budget.enforce ? "error" : "warning",
147
156
  file: rel,
148
157
  message: `${rel}: ${lines.length} lines (~${estTokens} tokens) exceeds budget ${maxLines} lines / ${maxTokens} tokens — migrate friction scars via scar.migrate or declare an override`,
149
158
  });
@@ -192,6 +201,6 @@ export async function runInstructionsBudgetValidate(
192
201
  diagnostics,
193
202
  },
194
203
  summary: `${diagnostics.length} instruction diagnostic(s) over ${files.length} file(s)`,
195
- exitCode: 0,
204
+ exitCode: diagnostics.some((d) => d.severity === "error") ? 1 : 0,
196
205
  };
197
206
  }
@@ -9,6 +9,9 @@
9
9
  <item>RFC-1466: forgeInstructionsModule registering instructions.budget.validate + scar.migrate</item>
10
10
  <item>RFC-1466: bound the instruction layer — instructions.budget.validate, scar.migrate, catalog fragment merge</item>
11
11
  <item>RFC-1485: sweep compass headers — forge-os-tail</item>
12
+ <item>RFC-1522: slim AGENTS.md to injection-safe skeletons + extract docs/agent-guides + budget gate
13
+
14
+ 8 rule files (1.19 MB -> 50.6 KB total) split into <=12,288-byte skeletons; 212 moved ## sections preserved verbatim across 21 guides (heading parity verified). forge.yaml instructions.budget.enforce promotes INSTR-01 to an error gate at the 3072-token ceiling. Withdrawn rules.budget.check removed — dedupe onto the RFC-1466 command. fo-doctor invokes the real gate.</item>
12
15
  </CHANGE_SUMMARY>
13
16
  */
14
17
 
@@ -33,7 +36,7 @@ export const forgeInstructionsModule: ForgeModule = {
33
36
  { id: "INSTR-03", severity: "warning" },
34
37
  ],
35
38
  description:
36
- "RFC-1466: bound the instruction layer — INSTR-01 AGENTS.md over declared budget, INSTR-02 scar-classified bullet in an exempt section (informational), INSTR-03 migrated scar still present as prose. Wave-1 reporting-only.",
39
+ "RFC-1466: bound the instruction layer — INSTR-01 AGENTS.md over declared budget, INSTR-02 scar-classified bullet in an exempt section (informational), INSTR-03 migrated scar still present as prose. RFC-1522: forge.yaml instructions.budget.enforce promotes INSTR-01 to error and exits 1.",
37
40
  scope: "workspace",
38
41
  acceptsAllFlag: false,
39
42
  flags: {},