@warpgogol/forge 9.3.1 → 9.4.1

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 (509) hide show
  1. package/AGENTS.md +32 -0
  2. package/CHANGELOG.md +40 -0
  3. package/README.md +6 -4
  4. package/README.uk.md +10 -8
  5. package/bin/cli.ts +4 -4
  6. package/dist/bin/cli.js +4 -4
  7. package/dist/bin/cli.js.map +1 -1
  8. package/dist/os/adr/handlers/list-create.d.ts.map +1 -1
  9. package/dist/os/adr/handlers/list-create.js +23 -2
  10. package/dist/os/adr/handlers/list-create.js.map +1 -1
  11. package/dist/os/adr/types.d.ts +2 -0
  12. package/dist/os/adr/types.d.ts.map +1 -1
  13. package/dist/os/adr/types.js +2 -2
  14. package/dist/os/adr/types.js.map +1 -1
  15. package/dist/os/compass/handlers/compass-audit-handler.d.ts.map +1 -1
  16. package/dist/os/compass/handlers/compass-audit-handler.js +3 -1
  17. package/dist/os/compass/handlers/compass-audit-handler.js.map +1 -1
  18. package/dist/os/compass/handlers/compass-header-scaffold-handler.d.ts.map +1 -1
  19. package/dist/os/compass/handlers/compass-header-scaffold-handler.js +6 -12
  20. package/dist/os/compass/handlers/compass-header-scaffold-handler.js.map +1 -1
  21. package/dist/os/compass/handlers/git-revision.d.ts +2 -0
  22. package/dist/os/compass/handlers/git-revision.d.ts.map +1 -1
  23. package/dist/os/compass/handlers/git-revision.js +7 -2
  24. package/dist/os/compass/handlers/git-revision.js.map +1 -1
  25. package/dist/os/compass/handlers/summary-record.d.ts.map +1 -1
  26. package/dist/os/compass/handlers/summary-record.js +24 -14
  27. package/dist/os/compass/handlers/summary-record.js.map +1 -1
  28. package/dist/os/conformance/conformance.module.d.ts.map +1 -1
  29. package/dist/os/conformance/conformance.module.js +21 -4
  30. package/dist/os/conformance/conformance.module.js.map +1 -1
  31. package/dist/os/conformance/handlers/conformance-validate.d.ts.map +1 -1
  32. package/dist/os/conformance/handlers/conformance-validate.js +64 -8
  33. package/dist/os/conformance/handlers/conformance-validate.js.map +1 -1
  34. package/dist/os/core/archive-regen.d.ts +99 -0
  35. package/dist/os/core/archive-regen.d.ts.map +1 -0
  36. package/dist/os/core/archive-regen.js +220 -0
  37. package/dist/os/core/archive-regen.js.map +1 -0
  38. package/dist/os/core/core.module.d.ts.map +1 -1
  39. package/dist/os/core/core.module.js +159 -18
  40. package/dist/os/core/core.module.js.map +1 -1
  41. package/dist/os/core/handlers/assets-helpers.d.ts.map +1 -1
  42. package/dist/os/core/handlers/assets-helpers.js +8 -3
  43. package/dist/os/core/handlers/assets-helpers.js.map +1 -1
  44. package/dist/os/core/handlers/forge-autonomy-validate.d.ts.map +1 -1
  45. package/dist/os/core/handlers/forge-autonomy-validate.js +3 -1
  46. package/dist/os/core/handlers/forge-autonomy-validate.js.map +1 -1
  47. package/dist/os/core/handlers/package-health.d.ts +130 -0
  48. package/dist/os/core/handlers/package-health.d.ts.map +1 -1
  49. package/dist/os/core/handlers/package-health.js +548 -7
  50. package/dist/os/core/handlers/package-health.js.map +1 -1
  51. package/dist/os/core/handlers/release-prepare.d.ts.map +1 -1
  52. package/dist/os/core/handlers/release-prepare.js +5 -2
  53. package/dist/os/core/handlers/release-prepare.js.map +1 -1
  54. package/dist/os/flow/digest.d.ts.map +1 -1
  55. package/dist/os/flow/digest.js +3 -1
  56. package/dist/os/flow/digest.js.map +1 -1
  57. package/dist/os/flow/dirty-classify.d.ts +51 -0
  58. package/dist/os/flow/dirty-classify.d.ts.map +1 -0
  59. package/dist/os/flow/dirty-classify.js +83 -0
  60. package/dist/os/flow/dirty-classify.js.map +1 -0
  61. package/dist/os/flow/flow.module.d.ts.map +1 -1
  62. package/dist/os/flow/flow.module.js +110 -19
  63. package/dist/os/flow/flow.module.js.map +1 -1
  64. package/dist/os/flow/gate-engine.d.ts +13 -0
  65. package/dist/os/flow/gate-engine.d.ts.map +1 -0
  66. package/dist/os/flow/gate-engine.js +32 -0
  67. package/dist/os/flow/gate-engine.js.map +1 -0
  68. package/dist/os/flow/git.d.ts +45 -4
  69. package/dist/os/flow/git.d.ts.map +1 -1
  70. package/dist/os/flow/git.js +95 -27
  71. package/dist/os/flow/git.js.map +1 -1
  72. package/dist/os/flow/handlers/flow-backmerge.d.ts.map +1 -1
  73. package/dist/os/flow/handlers/flow-backmerge.js +12 -5
  74. package/dist/os/flow/handlers/flow-backmerge.js.map +1 -1
  75. package/dist/os/flow/handlers/flow-check.d.ts.map +1 -1
  76. package/dist/os/flow/handlers/flow-check.js +25 -3
  77. package/dist/os/flow/handlers/flow-check.js.map +1 -1
  78. package/dist/os/flow/handlers/flow-cut.d.ts +4 -1
  79. package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -1
  80. package/dist/os/flow/handlers/flow-cut.js +75 -38
  81. package/dist/os/flow/handlers/flow-cut.js.map +1 -1
  82. package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -1
  83. package/dist/os/flow/handlers/flow-discard.js +33 -5
  84. package/dist/os/flow/handlers/flow-discard.js.map +1 -1
  85. package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -1
  86. package/dist/os/flow/handlers/flow-fix.js +13 -10
  87. package/dist/os/flow/handlers/flow-fix.js.map +1 -1
  88. package/dist/os/flow/handlers/flow-hold.d.ts.map +1 -1
  89. package/dist/os/flow/handlers/flow-hold.js +13 -7
  90. package/dist/os/flow/handlers/flow-hold.js.map +1 -1
  91. package/dist/os/flow/handlers/flow-install.d.ts +2 -1
  92. package/dist/os/flow/handlers/flow-install.d.ts.map +1 -1
  93. package/dist/os/flow/handlers/flow-install.js +56 -13
  94. package/dist/os/flow/handlers/flow-install.js.map +1 -1
  95. package/dist/os/flow/handlers/flow-integrate.d.ts +54 -2
  96. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
  97. package/dist/os/flow/handlers/flow-integrate.js +614 -65
  98. package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
  99. package/dist/os/flow/handlers/flow-open.d.ts +14 -0
  100. package/dist/os/flow/handlers/flow-open.d.ts.map +1 -1
  101. package/dist/os/flow/handlers/flow-open.js +117 -12
  102. package/dist/os/flow/handlers/flow-open.js.map +1 -1
  103. package/dist/os/flow/handlers/flow-peers.d.ts +24 -0
  104. package/dist/os/flow/handlers/flow-peers.d.ts.map +1 -0
  105. package/dist/os/flow/handlers/flow-peers.js +99 -0
  106. package/dist/os/flow/handlers/flow-peers.js.map +1 -0
  107. package/dist/os/flow/handlers/flow-status.d.ts +13 -0
  108. package/dist/os/flow/handlers/flow-status.d.ts.map +1 -1
  109. package/dist/os/flow/handlers/flow-status.js +35 -14
  110. package/dist/os/flow/handlers/flow-status.js.map +1 -1
  111. package/dist/os/flow/index.d.ts +3 -0
  112. package/dist/os/flow/index.d.ts.map +1 -1
  113. package/dist/os/flow/index.js +7 -2
  114. package/dist/os/flow/index.js.map +1 -1
  115. package/dist/os/flow/line-version.d.ts.map +1 -1
  116. package/dist/os/flow/line-version.js +2 -1
  117. package/dist/os/flow/line-version.js.map +1 -1
  118. package/dist/os/flow/locks.d.ts +37 -1
  119. package/dist/os/flow/locks.d.ts.map +1 -1
  120. package/dist/os/flow/locks.js +34 -14
  121. package/dist/os/flow/locks.js.map +1 -1
  122. package/dist/os/flow/ops-registry.d.ts +33 -0
  123. package/dist/os/flow/ops-registry.d.ts.map +1 -0
  124. package/dist/os/flow/ops-registry.js +177 -0
  125. package/dist/os/flow/ops-registry.js.map +1 -0
  126. package/dist/os/flow/preflight.d.ts +157 -0
  127. package/dist/os/flow/preflight.d.ts.map +1 -0
  128. package/dist/os/flow/preflight.js +772 -0
  129. package/dist/os/flow/preflight.js.map +1 -0
  130. package/dist/os/flow/publish.d.ts +7 -0
  131. package/dist/os/flow/publish.d.ts.map +1 -1
  132. package/dist/os/flow/publish.js +165 -3
  133. package/dist/os/flow/publish.js.map +1 -1
  134. package/dist/os/flow/registry.d.ts +26 -1
  135. package/dist/os/flow/registry.d.ts.map +1 -1
  136. package/dist/os/flow/registry.js +27 -6
  137. package/dist/os/flow/registry.js.map +1 -1
  138. package/dist/os/flow/scripts.d.ts +4 -0
  139. package/dist/os/flow/scripts.d.ts.map +1 -1
  140. package/dist/os/flow/scripts.js +8 -2
  141. package/dist/os/flow/scripts.js.map +1 -1
  142. package/dist/os/flow/session-checkout.d.ts +33 -0
  143. package/dist/os/flow/session-checkout.d.ts.map +1 -0
  144. package/dist/os/flow/session-checkout.js +151 -0
  145. package/dist/os/flow/session-checkout.js.map +1 -0
  146. package/dist/os/flow/standalone-invoke.d.ts +11 -0
  147. package/dist/os/flow/standalone-invoke.d.ts.map +1 -0
  148. package/dist/os/flow/standalone-invoke.js +75 -0
  149. package/dist/os/flow/standalone-invoke.js.map +1 -0
  150. package/dist/os/flow/worktree-path.d.ts.map +1 -1
  151. package/dist/os/flow/worktree-path.js +9 -3
  152. package/dist/os/flow/worktree-path.js.map +1 -1
  153. package/dist/os/instructions/handlers/budget-validate.d.ts +1 -0
  154. package/dist/os/instructions/handlers/budget-validate.d.ts.map +1 -1
  155. package/dist/os/instructions/handlers/budget-validate.js +12 -4
  156. package/dist/os/instructions/handlers/budget-validate.js.map +1 -1
  157. package/dist/os/instructions/instructions.module.d.ts.map +1 -1
  158. package/dist/os/instructions/instructions.module.js +4 -1
  159. package/dist/os/instructions/instructions.module.js.map +1 -1
  160. package/dist/os/mission/handlers/archive.d.ts.map +1 -1
  161. package/dist/os/mission/handlers/archive.js +12 -8
  162. package/dist/os/mission/handlers/archive.js.map +1 -1
  163. package/dist/os/mission/importer-block.d.ts +19 -0
  164. package/dist/os/mission/importer-block.d.ts.map +1 -0
  165. package/dist/os/mission/importer-block.js +124 -0
  166. package/dist/os/mission/importer-block.js.map +1 -0
  167. package/dist/os/mission/lockfile.d.ts +17 -0
  168. package/dist/os/mission/lockfile.d.ts.map +1 -1
  169. package/dist/os/mission/lockfile.js +38 -0
  170. package/dist/os/mission/lockfile.js.map +1 -1
  171. package/dist/os/mission/open-missions.d.ts +8 -0
  172. package/dist/os/mission/open-missions.d.ts.map +1 -0
  173. package/dist/os/mission/open-missions.js +42 -0
  174. package/dist/os/mission/open-missions.js.map +1 -0
  175. package/dist/os/queue/manifest.d.ts.map +1 -1
  176. package/dist/os/queue/manifest.js +11 -1
  177. package/dist/os/queue/manifest.js.map +1 -1
  178. package/dist/os/rfc/acceptance.d.ts +14 -0
  179. package/dist/os/rfc/acceptance.d.ts.map +1 -1
  180. package/dist/os/rfc/acceptance.js +18 -10
  181. package/dist/os/rfc/acceptance.js.map +1 -1
  182. package/dist/os/rfc/decision-log.d.ts.map +1 -1
  183. package/dist/os/rfc/decision-log.js +11 -2
  184. package/dist/os/rfc/decision-log.js.map +1 -1
  185. package/dist/os/rfc/frontmatter-io.d.ts +23 -0
  186. package/dist/os/rfc/frontmatter-io.d.ts.map +1 -1
  187. package/dist/os/rfc/frontmatter-io.js +82 -1
  188. package/dist/os/rfc/frontmatter-io.js.map +1 -1
  189. package/dist/os/rfc/handlers/implement-stamp-deviations.d.ts.map +1 -1
  190. package/dist/os/rfc/handlers/implement-stamp-deviations.js +24 -2
  191. package/dist/os/rfc/handlers/implement-stamp-deviations.js.map +1 -1
  192. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  193. package/dist/os/rfc/handlers/implement-stamp.js +16 -3
  194. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  195. package/dist/os/rfc/handlers/index-graph.d.ts.map +1 -1
  196. package/dist/os/rfc/handlers/index-graph.js +5 -4
  197. package/dist/os/rfc/handlers/index-graph.js.map +1 -1
  198. package/dist/os/rfc/handlers/list-create.d.ts.map +1 -1
  199. package/dist/os/rfc/handlers/list-create.js +107 -10
  200. package/dist/os/rfc/handlers/list-create.js.map +1 -1
  201. package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts +48 -0
  202. package/dist/os/rfc/handlers/rfc-evidence-sync.d.ts.map +1 -1
  203. package/dist/os/rfc/handlers/rfc-evidence-sync.js +131 -2
  204. package/dist/os/rfc/handlers/rfc-evidence-sync.js.map +1 -1
  205. package/dist/os/rfc/handlers/validate-rules.d.ts +21 -1
  206. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  207. package/dist/os/rfc/handlers/validate-rules.js +77 -5
  208. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  209. package/dist/os/rfc/handlers/validate.d.ts.map +1 -1
  210. package/dist/os/rfc/handlers/validate.js +64 -6
  211. package/dist/os/rfc/handlers/validate.js.map +1 -1
  212. package/dist/os/rfc/next-id.d.ts +38 -0
  213. package/dist/os/rfc/next-id.d.ts.map +1 -0
  214. package/dist/os/rfc/next-id.js +165 -0
  215. package/dist/os/rfc/next-id.js.map +1 -0
  216. package/dist/os/rfc/probe-batch.d.ts.map +1 -1
  217. package/dist/os/rfc/probe-batch.js +6 -1
  218. package/dist/os/rfc/probe-batch.js.map +1 -1
  219. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  220. package/dist/os/rfc/rfc.module.js +36 -8
  221. package/dist/os/rfc/rfc.module.js.map +1 -1
  222. package/dist/os/rfc/types.d.ts +42 -6
  223. package/dist/os/rfc/types.d.ts.map +1 -1
  224. package/dist/os/rfc/types.js +6 -6
  225. package/dist/os/rfc/types.js.map +1 -1
  226. package/dist/os/rfc/verification-evidence.d.ts +1 -1
  227. package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
  228. package/dist/os/rfc/verification-evidence.js +81 -28
  229. package/dist/os/rfc/verification-evidence.js.map +1 -1
  230. package/dist/os/rfc/verification-origin.d.ts +8 -0
  231. package/dist/os/rfc/verification-origin.d.ts.map +1 -1
  232. package/dist/os/rfc/verification-origin.js +47 -0
  233. package/dist/os/rfc/verification-origin.js.map +1 -1
  234. package/dist/os/session/handlers/save.d.ts.map +1 -1
  235. package/dist/os/session/handlers/save.js +31 -7
  236. package/dist/os/session/handlers/save.js.map +1 -1
  237. package/dist/os/spec/spec-schema.d.ts +8 -0
  238. package/dist/os/spec/spec-schema.d.ts.map +1 -1
  239. package/dist/os/spec/spec-schema.js +1 -0
  240. package/dist/os/spec/spec-schema.js.map +1 -1
  241. package/dist/os/spec/spec-status.d.ts +8 -0
  242. package/dist/os/spec/spec-status.d.ts.map +1 -1
  243. package/dist/os/spec/spec-status.js +18 -6
  244. package/dist/os/spec/spec-status.js.map +1 -1
  245. package/dist/os/spec/spec-validate.d.ts.map +1 -1
  246. package/dist/os/spec/spec-validate.js +62 -15
  247. package/dist/os/spec/spec-validate.js.map +1 -1
  248. package/dist/os/spec/spec.module.d.ts.map +1 -1
  249. package/dist/os/spec/spec.module.js +13 -5
  250. package/dist/os/spec/spec.module.js.map +1 -1
  251. package/dist/os/system/handlers/system-map-validate.d.ts.map +1 -1
  252. package/dist/os/system/handlers/system-map-validate.js +2 -1
  253. package/dist/os/system/handlers/system-map-validate.js.map +1 -1
  254. package/dist/os/system/handlers/system-outbox-scan.d.ts +11 -0
  255. package/dist/os/system/handlers/system-outbox-scan.d.ts.map +1 -1
  256. package/dist/os/system/handlers/system-outbox-scan.js +54 -6
  257. package/dist/os/system/handlers/system-outbox-scan.js.map +1 -1
  258. package/dist/os/system/handlers/system-task-collect.d.ts.map +1 -1
  259. package/dist/os/system/handlers/system-task-collect.js +11 -5
  260. package/dist/os/system/handlers/system-task-collect.js.map +1 -1
  261. package/dist/os/system/handlers/system-task-create.d.ts.map +1 -1
  262. package/dist/os/system/handlers/system-task-create.js +6 -1
  263. package/dist/os/system/handlers/system-task-create.js.map +1 -1
  264. package/dist/os/system/handlers/system-versionset-record.d.ts +14 -0
  265. package/dist/os/system/handlers/system-versionset-record.d.ts.map +1 -1
  266. package/dist/os/system/handlers/system-versionset-record.js +246 -6
  267. package/dist/os/system/handlers/system-versionset-record.js.map +1 -1
  268. package/dist/os/system/repo.d.ts +1 -1
  269. package/dist/os/system/repo.d.ts.map +1 -1
  270. package/dist/os/system/repo.js +53 -3
  271. package/dist/os/system/repo.js.map +1 -1
  272. package/dist/os/system/scenario-schemas.d.ts +109 -3
  273. package/dist/os/system/scenario-schemas.d.ts.map +1 -1
  274. package/dist/os/system/scenario-schemas.js +66 -10
  275. package/dist/os/system/scenario-schemas.js.map +1 -1
  276. package/dist/os/system/system.module.d.ts.map +1 -1
  277. package/dist/os/system/system.module.js +69 -17
  278. package/dist/os/system/system.module.js.map +1 -1
  279. package/dist/os/system/tests/contract-fixtures.d.ts +17 -0
  280. package/dist/os/system/tests/contract-fixtures.d.ts.map +1 -0
  281. package/dist/os/system/tests/contract-fixtures.js +109 -0
  282. package/dist/os/system/tests/contract-fixtures.js.map +1 -0
  283. package/dist/src/config/forge-config.d.ts +54 -18
  284. package/dist/src/config/forge-config.d.ts.map +1 -1
  285. package/dist/src/config/forge-config.js +41 -9
  286. package/dist/src/config/forge-config.js.map +1 -1
  287. package/dist/src/conformance/index.d.ts +6 -0
  288. package/dist/src/conformance/index.d.ts.map +1 -1
  289. package/dist/src/conformance/index.js +36 -1
  290. package/dist/src/conformance/index.js.map +1 -1
  291. package/dist/src/formal/proof-runner.d.ts.map +1 -1
  292. package/dist/src/formal/proof-runner.js +10 -2
  293. package/dist/src/formal/proof-runner.js.map +1 -1
  294. package/dist/src/migration-adapters/node-typescript-pnpm/index.js +3 -1
  295. package/dist/src/migration-adapters/node-typescript-pnpm/index.js.map +1 -1
  296. package/dist/src/migration-adapters/phaser-pnpm/index.js +3 -1
  297. package/dist/src/migration-adapters/phaser-pnpm/index.js.map +1 -1
  298. package/dist/src/onboarding/agents-generate.js +4 -4
  299. package/dist/src/onboarding/agents-generate.js.map +1 -1
  300. package/dist/src/onboarding/nested-agents-generate.d.ts.map +1 -1
  301. package/dist/src/onboarding/nested-agents-generate.js +3 -1
  302. package/dist/src/onboarding/nested-agents-generate.js.map +1 -1
  303. package/dist/src/onboarding/prettierignore.d.ts.map +1 -1
  304. package/dist/src/onboarding/prettierignore.js +2 -0
  305. package/dist/src/onboarding/prettierignore.js.map +1 -1
  306. package/dist/src/onboarding/scaffold-project.js +2 -2
  307. package/dist/src/onboarding/scaffold-project.js.map +1 -1
  308. package/dist/src/onboarding/upgrade.d.ts.map +1 -1
  309. package/dist/src/onboarding/upgrade.js +14 -2
  310. package/dist/src/onboarding/upgrade.js.map +1 -1
  311. package/dist/src/onboarding/workspace-discovery.d.ts.map +1 -1
  312. package/dist/src/onboarding/workspace-discovery.js +3 -1
  313. package/dist/src/onboarding/workspace-discovery.js.map +1 -1
  314. package/dist/src/skill-schema.d.ts +3 -0
  315. package/dist/src/skill-schema.d.ts.map +1 -1
  316. package/dist/src/skill-schema.js +9 -2
  317. package/dist/src/skill-schema.js.map +1 -1
  318. package/dist/src/spec/resolve-spec-source.d.ts +45 -0
  319. package/dist/src/spec/resolve-spec-source.d.ts.map +1 -0
  320. package/dist/src/spec/resolve-spec-source.js +153 -0
  321. package/dist/src/spec/resolve-spec-source.js.map +1 -0
  322. package/dist/src/utils/command-inventory.d.ts +28 -0
  323. package/dist/src/utils/command-inventory.d.ts.map +1 -0
  324. package/dist/src/utils/command-inventory.js +84 -0
  325. package/dist/src/utils/command-inventory.js.map +1 -0
  326. package/dist/src/utils/io.d.ts.map +1 -1
  327. package/dist/src/utils/io.js +6 -1
  328. package/dist/src/utils/io.js.map +1 -1
  329. package/dist/src/utils/repo-path.d.ts +10 -0
  330. package/dist/src/utils/repo-path.d.ts.map +1 -0
  331. package/dist/src/utils/repo-path.js +52 -0
  332. package/dist/src/utils/repo-path.js.map +1 -0
  333. package/dist/src/utils/spawn.d.ts +23 -0
  334. package/dist/src/utils/spawn.d.ts.map +1 -0
  335. package/dist/src/utils/spawn.js +83 -0
  336. package/dist/src/utils/spawn.js.map +1 -0
  337. package/docs/branch-model.md +1 -1
  338. package/docs/guides/existing-project.md +1 -1
  339. package/docs/maintainers/publishing.md +1 -1
  340. package/docs/reference/cli.md +8 -2
  341. package/docs/reference/profiles.md +1 -1
  342. package/os/adr/handlers/list-create.ts +26 -2
  343. package/os/adr/types.ts +4 -2
  344. package/os/compass/handlers/compass-audit-handler.ts +6 -1
  345. package/os/compass/handlers/compass-header-scaffold-handler.ts +12 -11
  346. package/os/compass/handlers/git-revision.ts +8 -2
  347. package/os/compass/handlers/summary-record.ts +25 -14
  348. package/os/compass/handlers/tests/compass-invariant-binding.test.ts +3 -2
  349. package/os/conformance/conformance.module.ts +21 -4
  350. package/os/conformance/handlers/conformance-validate.ts +108 -16
  351. package/os/conformance/handlers/tests/conformance-package-consumer.test.ts +200 -0
  352. package/os/core/archive-regen.ts +279 -0
  353. package/os/core/core.module.ts +176 -29
  354. package/os/core/docs-archive.test.ts +413 -3
  355. package/os/core/handlers/assets-helpers.ts +8 -3
  356. package/os/core/handlers/forge-autonomy-validate.ts +3 -1
  357. package/os/core/handlers/package-health.test.ts +418 -4
  358. package/os/core/handlers/package-health.ts +629 -7
  359. package/os/core/handlers/release-prepare.ts +5 -2
  360. package/os/flow/digest.ts +3 -1
  361. package/os/flow/dirty-classify.ts +120 -0
  362. package/os/flow/flow.module.ts +119 -24
  363. package/os/flow/gate-engine.ts +45 -0
  364. package/os/flow/git.ts +117 -29
  365. package/os/flow/handlers/flow-backmerge.ts +14 -4
  366. package/os/flow/handlers/flow-check.ts +27 -2
  367. package/os/flow/handlers/flow-cut.ts +124 -56
  368. package/os/flow/handlers/flow-discard.ts +33 -5
  369. package/os/flow/handlers/flow-fix.ts +22 -10
  370. package/os/flow/handlers/flow-hold.ts +20 -7
  371. package/os/flow/handlers/flow-install.ts +59 -12
  372. package/os/flow/handlers/flow-integrate.ts +933 -180
  373. package/os/flow/handlers/flow-open.ts +135 -11
  374. package/os/flow/handlers/flow-peers.ts +142 -0
  375. package/os/flow/handlers/flow-status.ts +45 -13
  376. package/os/flow/index.ts +8 -2
  377. package/os/flow/line-version.ts +2 -1
  378. package/os/flow/locks.ts +56 -14
  379. package/os/flow/ops-registry.ts +194 -0
  380. package/os/flow/preflight.ts +974 -0
  381. package/os/flow/publish.ts +200 -5
  382. package/os/flow/registry.ts +43 -7
  383. package/os/flow/scripts.ts +13 -2
  384. package/os/flow/session-checkout.ts +186 -0
  385. package/os/flow/standalone-invoke.ts +85 -0
  386. package/os/flow/tests/dirty-classify.test.ts +251 -0
  387. package/os/flow/tests/fixtures/branch-names.yaml +40 -40
  388. package/os/flow/tests/flow-cut.test.ts +21 -0
  389. package/os/flow/tests/flow-discard.test.ts +32 -0
  390. package/os/flow/tests/flow-guard-parity.test.ts +10 -2
  391. package/os/flow/tests/flow-install.test.ts +7 -3
  392. package/os/flow/tests/flow-integrate.gate-report.test.ts +144 -0
  393. package/os/flow/tests/flow-integrate.preflight.test.ts +565 -0
  394. package/os/flow/tests/flow-integrate.reattach.test.ts +197 -0
  395. package/os/flow/tests/flow-integrate.remediation.test.ts +254 -0
  396. package/os/flow/tests/flow-integrate.test.ts +698 -17
  397. package/os/flow/tests/flow-open.pending.test.ts +277 -0
  398. package/os/flow/tests/flow-open.test.ts +52 -9
  399. package/os/flow/tests/flow-push-publish.test.ts +124 -0
  400. package/os/flow/tests/flow-status.test.ts +31 -1
  401. package/os/flow/tests/locks.test.ts +39 -3
  402. package/os/flow/tests/ops-registry.test.ts +136 -0
  403. package/os/flow/tests/scripts.test.ts +5 -2
  404. package/os/flow/tests/state-roots.test.ts +8 -5
  405. package/os/flow/worktree-path.ts +9 -3
  406. package/os/formal/handlers/proof-check.test.ts +6 -3
  407. package/os/instructions/budget.test.ts +31 -0
  408. package/os/instructions/handlers/budget-validate.ts +13 -4
  409. package/os/instructions/instructions.module.ts +4 -1
  410. package/os/mission/handlers/archive.ts +22 -14
  411. package/os/mission/importer-block.ts +119 -0
  412. package/os/mission/lockfile.ts +41 -0
  413. package/os/mission/open-missions.ts +50 -0
  414. package/os/queue/decision-ledger.test.ts +18 -0
  415. package/os/queue/manifest.ts +17 -1
  416. package/os/rfc/acceptance.ts +30 -10
  417. package/os/rfc/decision-log.ts +13 -2
  418. package/os/rfc/frontmatter-io.ts +89 -1
  419. package/os/rfc/handlers/implement-stamp-deviations.test.ts +83 -0
  420. package/os/rfc/handlers/implement-stamp-deviations.ts +22 -2
  421. package/os/rfc/handlers/implement-stamp-stale.test.ts +5 -1
  422. package/os/rfc/handlers/implement-stamp.ts +16 -3
  423. package/os/rfc/handlers/index-graph.ts +5 -4
  424. package/os/rfc/handlers/lifecycle.test.ts +136 -0
  425. package/os/rfc/handlers/list-create.test.ts +126 -0
  426. package/os/rfc/handlers/list-create.ts +130 -10
  427. package/os/rfc/handlers/rfc-evidence-sync.test.ts +504 -0
  428. package/os/rfc/handlers/rfc-evidence-sync.ts +192 -2
  429. package/os/rfc/handlers/tests/index-graph.test.ts +2 -1
  430. package/os/rfc/handlers/validate-rules-rfc1454.test.ts +73 -0
  431. package/os/rfc/handlers/validate-rules.ts +103 -7
  432. package/os/rfc/handlers/validate.ts +68 -4
  433. package/os/rfc/next-id.ts +232 -0
  434. package/os/rfc/probe-batch.ts +6 -1
  435. package/os/rfc/rfc.module.ts +41 -8
  436. package/os/rfc/types.ts +31 -6
  437. package/os/rfc/verification-emit-freshness.test.ts +5 -1
  438. package/os/rfc/verification-emit.test.ts +5 -1
  439. package/os/rfc/verification-evidence.ts +99 -33
  440. package/os/rfc/verification-origin.ts +59 -0
  441. package/os/rfc/verification-refresh.test.ts +5 -1
  442. package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +5 -1
  443. package/os/session/handlers/save.ts +35 -7
  444. package/os/session/tests/session-save.test.ts +154 -0
  445. package/os/spec/spec-schema.ts +3 -0
  446. package/os/spec/spec-status.ts +22 -6
  447. package/os/spec/spec-validate.package-source.test.ts +187 -0
  448. package/os/spec/spec-validate.ts +65 -14
  449. package/os/spec/spec.module.ts +13 -5
  450. package/os/system/handlers/system-map-validate.ts +4 -2
  451. package/os/system/handlers/system-outbox-scan.ts +65 -21
  452. package/os/system/handlers/system-task-collect.ts +11 -5
  453. package/os/system/handlers/system-task-create.ts +6 -1
  454. package/os/system/handlers/system-versionset-record.ts +301 -16
  455. package/os/system/repo.ts +59 -18
  456. package/os/system/scenario-schemas.ts +91 -12
  457. package/os/system/system.module.ts +70 -17
  458. package/os/system/tests/contract-fixtures.ts +139 -0
  459. package/os/system/tests/scenario-pin-drift-check.test.ts +114 -0
  460. package/os/system/tests/scenario-validator-check.test.ts +96 -0
  461. package/os/system/tests/system-task-collect.test.ts +16 -0
  462. package/os/system/tests/system-task-dispatch.test.ts +4 -1
  463. package/os/system/tests/system-versionset.test.ts +7 -3
  464. package/os/system/tests/version-set-v2.test.ts +78 -0
  465. package/package.json +9 -1
  466. package/skills/fo/fo-doctor/SKILL.md +151 -0
  467. package/skills/fo/fo-handoff/SKILL.md +22 -0
  468. package/skills/fo/fo-idea-create-rfc/acceptance-criteria-standard.md +2 -1
  469. package/skills/fo/fo-idea-implement/SKILL.md +5 -2
  470. package/skills/fo/fo-idea-plan/SKILL.md +5 -5
  471. package/skills/fo/fo-session-retro/SKILL.md +45 -13
  472. package/skills/fo/fo-spec-ingest/SKILL.md +8 -0
  473. package/skills/fo/fo-system-dispatch/SKILL.md +1 -0
  474. package/skills/meta/skill-create/SKILL.md +2 -1
  475. package/src/bin-entry.test.ts +3 -1
  476. package/src/config/forge-config.ts +57 -13
  477. package/src/conformance/index.ts +46 -1
  478. package/src/formal/proof-runner.ts +10 -2
  479. package/src/migration-adapters/node-typescript-pnpm/index.ts +3 -1
  480. package/src/migration-adapters/phaser-pnpm/index.ts +3 -1
  481. package/src/onboarding/agents-generate.ts +4 -4
  482. package/src/onboarding/nested-agents-generate.ts +3 -1
  483. package/src/onboarding/prettierignore.ts +2 -0
  484. package/src/onboarding/scaffold-project.ts +2 -2
  485. package/src/onboarding/upgrade.ts +13 -2
  486. package/src/onboarding/workspace-discovery.ts +3 -1
  487. package/src/pipeline-status.test.ts +1 -1
  488. package/src/skill-schema.ts +9 -2
  489. package/src/spec/resolve-spec-source.ts +184 -0
  490. package/src/tests/acceptance-probe-kinds.test.ts +3 -1
  491. package/src/tests/agents-generate-domain.test.ts +3 -2
  492. package/src/tests/agents-generate.test.ts +2 -1
  493. package/src/tests/create-flow.test.ts +3 -1
  494. package/src/tests/create.test.ts +12 -2
  495. package/src/tests/editable-generated-region.test.ts +2 -2
  496. package/src/tests/fixtures/agents-generate-business-before.txt +2 -0
  497. package/src/tests/implement-stamp.test.ts +5 -2
  498. package/src/tests/prettierignore-manage.test.ts +11 -0
  499. package/src/tests/rfc-implement-stamp-governance.test.ts +6 -2
  500. package/src/tests/rfc-verification-verdict-ingest.test.ts +5 -1
  501. package/src/tests/scaffold-project.test.ts +3 -1
  502. package/src/tests/upgrade.test.ts +79 -3
  503. package/src/tests/workspace-discovery.test.ts +4 -3
  504. package/src/utils/command-inventory.ts +105 -0
  505. package/src/utils/io.ts +6 -1
  506. package/src/utils/repo-path.ts +49 -0
  507. package/src/utils/spawn.ts +88 -0
  508. package/src/tests/rfc-evidence-sync.test.ts +0 -369
  509. package/src/tests/skill-agents-sync.test.ts +0 -192
@@ -0,0 +1,136 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>ops-registry tests (RFC-1543 AC-2/AC-5): claim write lands under the
4
+ shared git dir, liveness requires pid-alive ∧ bootId-match ∧ fresh heartbeat,
5
+ dead records are swept by the next reader, and claimCoversPath honors the
6
+ exact/prefix contract.</purpose>
7
+ <non-goals>
8
+ <item>No classifyDirt coverage — claim→class wiring lives in dirty-classify.test.ts.</item>
9
+ </non-goals>
10
+ </MODULE_CONTRACT>
11
+ <CHANGE_SUMMARY>
12
+ <item>RFC-1543: op-claim registry probes</item>
13
+ <item>RFC-1543: attribute shared-checkout dirt to live ops and expose peers (RFC-1543)</item>
14
+ </CHANGE_SUMMARY>
15
+ */
16
+
17
+ import { rm, writeFile, mkdir } from "node:fs/promises";
18
+ import { join } from "node:path";
19
+ import { afterEach, describe, expect, it } from "vitest";
20
+
21
+ import { ambientIo } from "../../../src/utils/io.ts";
22
+ import {
23
+ claimCoversPath,
24
+ claimOp,
25
+ isClaimLive,
26
+ liveClaims,
27
+ OP_CLAIM_SCHEMA,
28
+ releaseOp,
29
+ } from "../ops-registry.ts";
30
+ import { initRepo } from "./helpers.ts";
31
+
32
+ const dirs: string[] = [];
33
+ afterEach(async () => {
34
+ for (const dir of dirs.splice(0)) {
35
+ await rm(dir, { recursive: true, force: true });
36
+ }
37
+ });
38
+
39
+ async function repo(): Promise<string> {
40
+ const dir = await initRepo({ prefix: "ops-reg-" });
41
+ dirs.push(dir);
42
+ return dir;
43
+ }
44
+
45
+ async function opsDir(repo: string): Promise<string> {
46
+ return join(repo, ".git", "forge", "ops");
47
+ }
48
+
49
+ describe("ops-registry — claim lifecycle (RFC-1543 AC-2)", () => {
50
+ it("claimOp writes a forge/op-claim@1 record the reader reports live", async () => {
51
+ const r = await repo();
52
+ const ok = await claimOp(r, ambientIo, {
53
+ opId: "op-1",
54
+ command: "leitstand.ship",
55
+ workspaceRoot: r,
56
+ paths: ["docs/", "pnpm-lock.yaml"],
57
+ });
58
+ expect(ok).toBe(true);
59
+
60
+ const live = await liveClaims(r, ambientIo);
61
+ expect(live).toHaveLength(1);
62
+ expect(live[0]?.schema).toBe(OP_CLAIM_SCHEMA);
63
+ expect(live[0]?.pid).toBe(process.pid);
64
+ expect(live[0]?.paths).toEqual(["docs/", "pnpm-lock.yaml"]);
65
+ expect(live[0]?.bootId).toBeDefined();
66
+ });
67
+
68
+ it("releaseOp removes the record; a dead pid is swept on read", async () => {
69
+ const r = await repo();
70
+ await claimOp(r, ambientIo, {
71
+ opId: "op-2",
72
+ command: "ecosystem.commit",
73
+ workspaceRoot: r,
74
+ paths: ["docs/"],
75
+ });
76
+ await releaseOp(r, ambientIo, "op-2");
77
+ expect(await liveClaims(r, ambientIo)).toEqual([]);
78
+
79
+ // Hand-write a claim on a pid that cannot be alive.
80
+ const ops = await opsDir(r);
81
+ await mkdir(ops, { recursive: true });
82
+ await writeFile(
83
+ join(ops, "zombie.yaml"),
84
+ [
85
+ `schema: ${OP_CLAIM_SCHEMA}`,
86
+ "opId: zombie",
87
+ "command: mission.git.commit",
88
+ "pid: 999999999",
89
+ `host: ${(await import("node:os")).hostname()}`,
90
+ "startedAt: 2026-11-09T00:00:00Z",
91
+ "heartbeatAt: 2026-11-09T00:00:00Z",
92
+ `workspaceRoot: ${r}`,
93
+ "paths: [docs/]",
94
+ ].join("\n"),
95
+ );
96
+ expect(await liveClaims(r, ambientIo)).toEqual([]);
97
+ // Dead record was swept, not just filtered.
98
+ expect(await ambientIo.exists(join(ops, "zombie.yaml"))).toBe(false);
99
+ });
100
+
101
+ it("an expired heartbeat disqualifies an otherwise-live pid", async () => {
102
+ const r = await repo();
103
+ const stale: import("../ops-registry.ts").OpClaim = {
104
+ schema: OP_CLAIM_SCHEMA,
105
+ opId: "stale-beat",
106
+ command: "x",
107
+ pid: process.pid,
108
+ host: (await import("node:os")).hostname(),
109
+ startedAt: new Date(Date.now() - 600_000).toISOString(),
110
+ heartbeatAt: new Date(Date.now() - 600_000).toISOString(),
111
+ workspaceRoot: r,
112
+ paths: ["docs/"],
113
+ };
114
+ expect(isClaimLive({ ...stale })).toBe(false);
115
+ expect(isClaimLive({ ...stale, heartbeatAt: new Date().toISOString() })).toBe(true);
116
+ });
117
+
118
+ it("claimCoversPath matches exact paths and declared prefixes only", () => {
119
+ const claim: import("../ops-registry.ts").OpClaim = {
120
+ schema: OP_CLAIM_SCHEMA,
121
+ opId: "c",
122
+ command: "x",
123
+ pid: 1,
124
+ host: "h",
125
+ startedAt: "t",
126
+ heartbeatAt: "t",
127
+ workspaceRoot: "/w",
128
+ paths: ["docs/", "pnpm-lock.yaml"],
129
+ };
130
+ expect(claimCoversPath(claim, "pnpm-lock.yaml")).toBe(true);
131
+ expect(claimCoversPath(claim, "docs/rfcs/x.md")).toBe(true);
132
+ expect(claimCoversPath(claim, "docs")).toBe(false); // a FILE named docs is not under docs/
133
+ expect(claimCoversPath(claim, "documentation/x.md")).toBe(false);
134
+ expect(claimCoversPath(claim, "src/docs/x.ts")).toBe(false);
135
+ });
136
+ });
@@ -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: {},
@@ -13,11 +13,11 @@ archive subdirectories back to missions/.
13
13
  </non-goals>
14
14
  </MODULE_CONTRACT>
15
15
  <CHANGE_SUMMARY>
16
- <item>RFC-1397: harden ship-in-flight guard per independent review (RFC-1397)</item>
17
16
  <item>RFC-1495: step 1 - forge state roots</item>
18
17
  <item>RFC-1505: steps 3-5 — tracked lockfile restore, no side-effect commits</item>
19
18
  <item>RFC-1505: review r1 — durable projections and lockfile restore hardening</item>
20
19
  <item>RFC-1505: review r2 — clone-only sternsystem enumeration and mission-gated lockfile net</item>
20
+ <item>RFC-1544: attribute mission lockfile churn to owning checkout and auto-resolve foreign importer diffs (RFC-1544)</item>
21
21
  <history>RFC-0573, RFC-0733, RFC-0801, RFC-0804, RFC-0982, RFC-1097, RFC-1138, RFC-1397, warpgogol-m000175</history>
22
22
  </CHANGE_SUMMARY>
23
23
  */
@@ -47,7 +47,7 @@ import {
47
47
  type MissionArchiveResult,
48
48
  } from "../types.ts";
49
49
  import { loadPinnedManifest, isPinned, isIntraDirMove } from "../../core/handlers/pinned-check.ts";
50
- import { restoreTrackedLockfile, execFileSyncAdapter } from "../lockfile.ts";
50
+ import { pruneMissionImportersFromLockfile, execFileSyncAdapter } from "../lockfile.ts";
51
51
  import { resolveStateRoots } from "../../flow/worktree-path.ts";
52
52
 
53
53
  const SERVICE_FOLDERS = [
@@ -668,20 +668,28 @@ export async function runMissionArchive(
668
668
  );
669
669
  }
670
670
  try {
671
- // Restore runs even when install failed — a partially-rewritten
672
- // lockfile is still mission-local churn, never tracked bytes.
673
- const restored = await restoreTrackedLockfile(workspaceRoot, {
674
- ...execFileSyncAdapter(),
675
- writeFile: async (target, content) => {
676
- await writeFileIfChanged(target, content);
671
+ // RFC-1544 AC-5: the moved missions' importer blocks are legitimate
672
+ // tracked removals — HEAD-minus-importers is staged for the archive
673
+ // bookkeeping commit; every other install churn is still discarded.
674
+ const pruned = await pruneMissionImportersFromLockfile(
675
+ workspaceRoot,
676
+ moved.map((m) => m.missionId),
677
+ {
678
+ ...execFileSyncAdapter(),
679
+ writeFile: async (target, content) => {
680
+ await writeFileIfChanged(target, content);
681
+ },
677
682
  },
678
- });
679
- if (restored) {
680
- logger.info(" Restored pnpm-lock.yaml to HEAD bytes (install churn discarded)");
681
- } else {
682
- logger.warn(
683
- " No tracked pnpm-lock.yaml at HEAD — install churn left in place; nothing to restore",
683
+ );
684
+ if (pruned.pruned.length > 0) {
685
+ logger.info(
686
+ ` Pruned importer(s) ${pruned.pruned.map((id) => `missions/${id}/workpiece`).join(", ")} from pnpm-lock.yaml` +
687
+ (pruned.staged
688
+ ? " — staged for the bookkeeping commit"
689
+ : " — staging failed; prune left in the working tree"),
684
690
  );
691
+ } else {
692
+ logger.info(" Restored pnpm-lock.yaml to HEAD bytes (install churn discarded)");
685
693
  }
686
694
  } catch (refreshErr) {
687
695
  logger.warn(
@@ -0,0 +1,119 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>Text-splice primitives for a single importer subtree inside
4
+ pnpm-lock.yaml (RFC-1544). A mission workpiece registers as the importer key
5
+ `missions/<id>/workpiece:` at the fixed two-space indent under `importers:`;
6
+ both consumers — flow.integrate's foreign-open-mission restore and
7
+ mission.archive's bookkeeping prune — must move exactly that key's block and
8
+ nothing else, so a whole-file checkout or a YAML round-trip (which rewrites
9
+ unrelated formatting) is never the mechanism.</purpose>
10
+ <non-goals>
11
+ <item>No YAML semantics — block boundaries are indent arithmetic on the pnpm-lock layout, not a parse.</item>
12
+ <item>No git/file I/O — pure string transforms; callers own reads and writes.</item>
13
+ </non-goals>
14
+ </MODULE_CONTRACT>
15
+ <CHANGE_SUMMARY>
16
+ <item>RFC-1544: importer-block extract/insert/remove text splices shared by flow.integrate restore and mission.archive prune</item>
17
+ <item>RFC-1544: attribute mission lockfile churn to owning checkout and auto-resolve foreign importer diffs (RFC-1544)</item>
18
+ </CHANGE_SUMMARY>
19
+ */
20
+
21
+ const IMPORTER_INDENT = 2;
22
+
23
+ function indentOf(line: string): number {
24
+ return line.length - line.trimStart().length;
25
+ }
26
+
27
+ /** Locate ` <key>:` at the importer indent — exact key, no prefix bleed. */
28
+ function importerKeyIndex(lines: string[], key: string): number {
29
+ const wanted = `${" ".repeat(IMPORTER_INDENT)}${key}:`;
30
+ return lines.findIndex((l) => l.trimEnd() === wanted);
31
+ }
32
+
33
+ /**
34
+ * The importer block lines for `key` inside lockfile `text`: the key line
35
+ * plus every deeper-indented member, trailing blanks excluded. Null when the
36
+ * key is absent.
37
+ */
38
+ export function extractImporterBlock(text: string, key: string): string[] | null {
39
+ const lines = text.split("\n");
40
+ const start = importerKeyIndex(lines, key);
41
+ if (start === -1) return null;
42
+ let end = start + 1;
43
+ while (end < lines.length) {
44
+ const l = lines[end];
45
+ if (l.trim().length === 0) {
46
+ end += 1;
47
+ continue;
48
+ }
49
+ if (indentOf(l) <= IMPORTER_INDENT) break;
50
+ end += 1;
51
+ }
52
+ while (end > start + 1 && lines[end - 1].trim().length === 0) end -= 1;
53
+ return lines.slice(start, end);
54
+ }
55
+
56
+ /**
57
+ * `text` without `key`'s importer block — the block plus its separating
58
+ * blank line(s), so removal leaves the surrounding layout intact. Returns
59
+ * the input unchanged when the key is absent.
60
+ */
61
+ export function removeImporterBlock(text: string, key: string): string {
62
+ const lines = text.split("\n");
63
+ const start = importerKeyIndex(lines, key);
64
+ if (start === -1) return text;
65
+ let end = start + 1;
66
+ while (end < lines.length) {
67
+ const l = lines[end];
68
+ if (l.trim().length === 0) {
69
+ end += 1;
70
+ continue;
71
+ }
72
+ if (indentOf(l) <= IMPORTER_INDENT) break;
73
+ end += 1;
74
+ }
75
+ // Also absorb the blank separator BEFORE the block when one exists —
76
+ // pnpm separates importer stanzas with a single blank line.
77
+ let s = start;
78
+ if (s > 0 && lines[s - 1].trim().length === 0) s -= 1;
79
+ const out = [...lines.slice(0, s), ...lines.slice(end)];
80
+ // Collapse a doubled blank left at the seam when both sides kept one.
81
+ return out.join("\n").replace(/\n{3,}/g, "\n\n");
82
+ }
83
+
84
+ /**
85
+ * `text` with `block` inserted under `importers:` at pnpm's alphabetical
86
+ * position — before the first importer key sorting after `key`, else at the
87
+ * end of the importers section. Null when no `importers:` section exists.
88
+ */
89
+ export function insertImporterBlock(text: string, key: string, block: string[]): string | null {
90
+ const lines = text.split("\n");
91
+ const importersIdx = lines.findIndex((l) => l.trimEnd() === "importers:");
92
+ if (importersIdx === -1) return null;
93
+ // Section end: first non-blank line with indent < 2 (or EOF).
94
+ let sectionEnd = lines.length;
95
+ for (let i = importersIdx + 1; i < lines.length; i += 1) {
96
+ const l = lines[i];
97
+ if (l.trim().length === 0) continue;
98
+ if (indentOf(l) < IMPORTER_INDENT) {
99
+ sectionEnd = i;
100
+ break;
101
+ }
102
+ }
103
+ // First importer key sorting after ours — mid-section insert.
104
+ for (let i = importersIdx + 1; i < sectionEnd; i += 1) {
105
+ const l = lines[i];
106
+ if (l.trim().length === 0 || indentOf(l) !== IMPORTER_INDENT) continue;
107
+ const other = l.trim().replace(/:$/, "");
108
+ if (other > key) {
109
+ return [...lines.slice(0, i), ...block, "", ...lines.slice(i)].join("\n");
110
+ }
111
+ }
112
+ // End-of-section insert: splice before the trailing blank run when one
113
+ // exists (it already separates the last block from the next section).
114
+ let at = sectionEnd;
115
+ while (at > importersIdx + 1 && lines[at - 1].trim().length === 0) at -= 1;
116
+ const hadTrailingBlanks = at < sectionEnd;
117
+ const payload = ["", ...block, ...(hadTrailingBlanks ? [] : [""])];
118
+ return [...lines.slice(0, at), ...payload, ...lines.slice(at)].join("\n");
119
+ }
@@ -16,12 +16,14 @@ restores the file committed at HEAD so the worktree returns clean.
16
16
  <item>RFC-1505: steps 3-5 — tracked lockfile restore, no side-effect commits</item>
17
17
  <item>RFC-1505: review r1 — durable projections and lockfile restore hardening</item>
18
18
  <item>RFC-1505: review r2 — clone-only sternsystem enumeration and mission-gated lockfile net</item>
19
+ <item>RFC-1544: attribute mission lockfile churn to owning checkout and auto-resolve foreign importer diffs (RFC-1544)</item>
19
20
  </CHANGE_SUMMARY>
20
21
  */
21
22
 
22
23
  import path from "node:path";
23
24
  import { execFileSync } from "../../src/utils/sync-fs.ts";
24
25
  import type { ExecOptions, ExecResult, WorkspaceIO } from "../../src/types.ts";
26
+ import { extractImporterBlock, removeImporterBlock } from "./importer-block.ts";
25
27
 
26
28
  const LOCKFILE_NAME = "pnpm-lock.yaml";
27
29
 
@@ -82,3 +84,42 @@ export function execFileSyncAdapter(): Pick<WorkspaceIO, "exec"> {
82
84
  },
83
85
  };
84
86
  }
87
+
88
+ /**
89
+ * RFC-1544 AC-5: drop the listed missions' `missions/<id>/workpiece`
90
+ * importer subtrees from the tracked `pnpm-lock.yaml` and stage the result
91
+ * for the archive bookkeeping commit. The written bytes are HEAD-minus-
92
+ * importers — the post-archive `pnpm install` may churn unrelated lockfile
93
+ * state, and only the importer removal is legitimate tracked change, so
94
+ * everything else is discarded exactly like `restoreTrackedLockfile` did.
95
+ *
96
+ * Returns `pruned` = mission ids whose importer block was actually removed;
97
+ * `staged` = whether `pnpm-lock.yaml` reached the index. When no listed
98
+ * importer exists at HEAD the tracked file is restored instead (the old
99
+ * churn-discard behavior) and `staged` stays false.
100
+ */
101
+ export async function pruneMissionImportersFromLockfile(
102
+ root: string,
103
+ missionIds: string[],
104
+ io: Pick<WorkspaceIO, "exec" | "writeFile">,
105
+ ): Promise<{ pruned: string[]; staged: boolean }> {
106
+ const head = await io.exec("git", ["show", `HEAD:${LOCKFILE_NAME}`], { cwd: root });
107
+ if (head.exitCode !== 0) return { pruned: [], staged: false };
108
+ let next = head.stdout;
109
+ const pruned: string[] = [];
110
+ for (const missionId of missionIds) {
111
+ const key = `missions/${missionId}/workpiece`;
112
+ if (extractImporterBlock(next, key) === null) continue;
113
+ next = removeImporterBlock(next, key);
114
+ pruned.push(missionId);
115
+ }
116
+ const target = path.join(root, LOCKFILE_NAME);
117
+ if (pruned.length === 0) {
118
+ // Nothing legitimately prunes — keep the discard-churn restore.
119
+ await io.writeFile(target, head.stdout);
120
+ return { pruned, staged: false };
121
+ }
122
+ await io.writeFile(target, next);
123
+ const add = await io.exec("git", ["add", LOCKFILE_NAME], { cwd: root });
124
+ return { pruned, staged: add.exitCode === 0 };
125
+ }