@warpgogol/forge 9.4.1 → 9.6.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 (411) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +30 -0
  3. package/README.uk.md +30 -0
  4. package/bin/cli.ts +163 -53
  5. package/dist/bin/cli.js +137 -42
  6. package/dist/bin/cli.js.map +1 -1
  7. package/dist/os/codebase/codebase.module.d.ts +3 -0
  8. package/dist/os/codebase/codebase.module.d.ts.map +1 -0
  9. package/dist/os/codebase/codebase.module.js +53 -0
  10. package/dist/os/codebase/codebase.module.js.map +1 -0
  11. package/dist/os/codebase/handlers/codebase-measure-symbols.d.ts +15 -0
  12. package/dist/os/codebase/handlers/codebase-measure-symbols.d.ts.map +1 -0
  13. package/dist/os/codebase/handlers/codebase-measure-symbols.js +97 -0
  14. package/dist/os/codebase/handlers/codebase-measure-symbols.js.map +1 -0
  15. package/dist/os/codebase/handlers/codebase-measure.d.ts +22 -0
  16. package/dist/os/codebase/handlers/codebase-measure.d.ts.map +1 -0
  17. package/dist/os/codebase/handlers/codebase-measure.js +435 -0
  18. package/dist/os/codebase/handlers/codebase-measure.js.map +1 -0
  19. package/dist/os/codebase/index.d.ts +4 -0
  20. package/dist/os/codebase/index.d.ts.map +1 -0
  21. package/dist/os/codebase/index.js +13 -0
  22. package/dist/os/codebase/index.js.map +1 -0
  23. package/dist/os/codebase/types.d.ts +35 -0
  24. package/dist/os/codebase/types.d.ts.map +1 -0
  25. package/dist/os/codebase/types.js +17 -0
  26. package/dist/os/codebase/types.js.map +1 -0
  27. package/dist/os/core/handlers/package-health.d.ts +6 -4
  28. package/dist/os/core/handlers/package-health.d.ts.map +1 -1
  29. package/dist/os/core/handlers/package-health.js +15 -20
  30. package/dist/os/core/handlers/package-health.js.map +1 -1
  31. package/dist/os/correctness/anchors.d.ts +24 -0
  32. package/dist/os/correctness/anchors.d.ts.map +1 -0
  33. package/dist/os/correctness/anchors.js +156 -0
  34. package/dist/os/correctness/anchors.js.map +1 -0
  35. package/dist/os/correctness/audit/bindings-verify-substance.d.ts +7 -0
  36. package/dist/os/correctness/audit/bindings-verify-substance.d.ts.map +1 -0
  37. package/dist/os/correctness/audit/bindings-verify-substance.js +145 -0
  38. package/dist/os/correctness/audit/bindings-verify-substance.js.map +1 -0
  39. package/dist/os/correctness/audit/differential.d.ts +7 -0
  40. package/dist/os/correctness/audit/differential.d.ts.map +1 -0
  41. package/dist/os/correctness/audit/differential.js +105 -0
  42. package/dist/os/correctness/audit/differential.js.map +1 -0
  43. package/dist/os/correctness/audit/ledger-orphans.d.ts +6 -0
  44. package/dist/os/correctness/audit/ledger-orphans.d.ts.map +1 -0
  45. package/dist/os/correctness/audit/ledger-orphans.js +71 -0
  46. package/dist/os/correctness/audit/ledger-orphans.js.map +1 -0
  47. package/dist/os/correctness/audit/ledger.d.ts +29 -0
  48. package/dist/os/correctness/audit/ledger.d.ts.map +1 -0
  49. package/dist/os/correctness/audit/ledger.js +72 -0
  50. package/dist/os/correctness/audit/ledger.js.map +1 -0
  51. package/dist/os/correctness/audit/run.d.ts +27 -0
  52. package/dist/os/correctness/audit/run.d.ts.map +1 -0
  53. package/dist/os/correctness/audit/run.js +184 -0
  54. package/dist/os/correctness/audit/run.js.map +1 -0
  55. package/dist/os/correctness/audit/schema-db.d.ts +32 -0
  56. package/dist/os/correctness/audit/schema-db.d.ts.map +1 -0
  57. package/dist/os/correctness/audit/schema-db.js +166 -0
  58. package/dist/os/correctness/audit/schema-db.js.map +1 -0
  59. package/dist/os/correctness/audit/snapshot.d.ts +34 -0
  60. package/dist/os/correctness/audit/snapshot.d.ts.map +1 -0
  61. package/dist/os/correctness/audit/snapshot.js +190 -0
  62. package/dist/os/correctness/audit/snapshot.js.map +1 -0
  63. package/dist/os/correctness/audit/sql-scanner.d.ts +28 -0
  64. package/dist/os/correctness/audit/sql-scanner.d.ts.map +1 -0
  65. package/dist/os/correctness/audit/sql-scanner.js +279 -0
  66. package/dist/os/correctness/audit/sql-scanner.js.map +1 -0
  67. package/dist/os/correctness/audit/sql-schema-conform.d.ts +17 -0
  68. package/dist/os/correctness/audit/sql-schema-conform.d.ts.map +1 -0
  69. package/dist/os/correctness/audit/sql-schema-conform.js +163 -0
  70. package/dist/os/correctness/audit/sql-schema-conform.js.map +1 -0
  71. package/dist/os/correctness/audit/state-transitions-coverage.d.ts +19 -0
  72. package/dist/os/correctness/audit/state-transitions-coverage.d.ts.map +1 -0
  73. package/dist/os/correctness/audit/state-transitions-coverage.js +263 -0
  74. package/dist/os/correctness/audit/state-transitions-coverage.js.map +1 -0
  75. package/dist/os/correctness/audit/tests/git-fixture.d.ts +15 -0
  76. package/dist/os/correctness/audit/tests/git-fixture.d.ts.map +1 -0
  77. package/dist/os/correctness/audit/tests/git-fixture.js +85 -0
  78. package/dist/os/correctness/audit/tests/git-fixture.js.map +1 -0
  79. package/dist/os/correctness/audit/types.d.ts +58 -0
  80. package/dist/os/correctness/audit/types.d.ts.map +1 -0
  81. package/dist/os/correctness/audit/types.js +34 -0
  82. package/dist/os/correctness/audit/types.js.map +1 -0
  83. package/dist/os/correctness/correctness.module.d.ts +3 -0
  84. package/dist/os/correctness/correctness.module.d.ts.map +1 -0
  85. package/dist/os/correctness/correctness.module.js +173 -0
  86. package/dist/os/correctness/correctness.module.js.map +1 -0
  87. package/dist/os/correctness/gate/frozen.d.ts +52 -0
  88. package/dist/os/correctness/gate/frozen.d.ts.map +1 -0
  89. package/dist/os/correctness/gate/frozen.js +322 -0
  90. package/dist/os/correctness/gate/frozen.js.map +1 -0
  91. package/dist/os/correctness/gate/origin.d.ts +28 -0
  92. package/dist/os/correctness/gate/origin.d.ts.map +1 -0
  93. package/dist/os/correctness/gate/origin.js +139 -0
  94. package/dist/os/correctness/gate/origin.js.map +1 -0
  95. package/dist/os/correctness/gate/repo.d.ts +25 -0
  96. package/dist/os/correctness/gate/repo.d.ts.map +1 -0
  97. package/dist/os/correctness/gate/repo.js +88 -0
  98. package/dist/os/correctness/gate/repo.js.map +1 -0
  99. package/dist/os/correctness/gate/run.d.ts +22 -0
  100. package/dist/os/correctness/gate/run.d.ts.map +1 -0
  101. package/dist/os/correctness/gate/run.js +430 -0
  102. package/dist/os/correctness/gate/run.js.map +1 -0
  103. package/dist/os/correctness/gate/runner.d.ts +18 -0
  104. package/dist/os/correctness/gate/runner.d.ts.map +1 -0
  105. package/dist/os/correctness/gate/runner.js +123 -0
  106. package/dist/os/correctness/gate/runner.js.map +1 -0
  107. package/dist/os/correctness/gate/tests/gate-fixture.d.ts +36 -0
  108. package/dist/os/correctness/gate/tests/gate-fixture.d.ts.map +1 -0
  109. package/dist/os/correctness/gate/tests/gate-fixture.js +153 -0
  110. package/dist/os/correctness/gate/tests/gate-fixture.js.map +1 -0
  111. package/dist/os/correctness/gate/types.d.ts +102 -0
  112. package/dist/os/correctness/gate/types.d.ts.map +1 -0
  113. package/dist/os/correctness/gate/types.js +64 -0
  114. package/dist/os/correctness/gate/types.js.map +1 -0
  115. package/dist/os/correctness/handlers/audit.d.ts +4 -0
  116. package/dist/os/correctness/handlers/audit.d.ts.map +1 -0
  117. package/dist/os/correctness/handlers/audit.js +95 -0
  118. package/dist/os/correctness/handlers/audit.js.map +1 -0
  119. package/dist/os/correctness/handlers/gate.d.ts +4 -0
  120. package/dist/os/correctness/handlers/gate.d.ts.map +1 -0
  121. package/dist/os/correctness/handlers/gate.js +62 -0
  122. package/dist/os/correctness/handlers/gate.js.map +1 -0
  123. package/dist/os/correctness/handlers/validate.d.ts +19 -0
  124. package/dist/os/correctness/handlers/validate.d.ts.map +1 -0
  125. package/dist/os/correctness/handlers/validate.js +367 -0
  126. package/dist/os/correctness/handlers/validate.js.map +1 -0
  127. package/dist/os/correctness/index.d.ts +8 -0
  128. package/dist/os/correctness/index.d.ts.map +1 -0
  129. package/dist/os/correctness/index.js +23 -0
  130. package/dist/os/correctness/index.js.map +1 -0
  131. package/dist/os/correctness/manifest-schema.d.ts +155 -0
  132. package/dist/os/correctness/manifest-schema.d.ts.map +1 -0
  133. package/dist/os/correctness/manifest-schema.js +110 -0
  134. package/dist/os/correctness/manifest-schema.js.map +1 -0
  135. package/dist/os/correctness/references.d.ts +22 -0
  136. package/dist/os/correctness/references.d.ts.map +1 -0
  137. package/dist/os/correctness/references.js +129 -0
  138. package/dist/os/correctness/references.js.map +1 -0
  139. package/dist/os/correctness/tests/fixture-workspace.d.ts +23 -0
  140. package/dist/os/correctness/tests/fixture-workspace.d.ts.map +1 -0
  141. package/dist/os/correctness/tests/fixture-workspace.js +104 -0
  142. package/dist/os/correctness/tests/fixture-workspace.js.map +1 -0
  143. package/dist/os/correctness/workspace.d.ts +32 -0
  144. package/dist/os/correctness/workspace.d.ts.map +1 -0
  145. package/dist/os/correctness/workspace.js +147 -0
  146. package/dist/os/correctness/workspace.js.map +1 -0
  147. package/dist/os/flow/correctness-step.d.ts +19 -0
  148. package/dist/os/flow/correctness-step.d.ts.map +1 -0
  149. package/dist/os/flow/correctness-step.js +133 -0
  150. package/dist/os/flow/correctness-step.js.map +1 -0
  151. package/dist/os/flow/digest.d.ts +18 -0
  152. package/dist/os/flow/digest.d.ts.map +1 -1
  153. package/dist/os/flow/digest.js +28 -1
  154. package/dist/os/flow/digest.js.map +1 -1
  155. package/dist/os/flow/dirty-classify.d.ts +7 -0
  156. package/dist/os/flow/dirty-classify.d.ts.map +1 -1
  157. package/dist/os/flow/dirty-classify.js +11 -0
  158. package/dist/os/flow/dirty-classify.js.map +1 -1
  159. package/dist/os/flow/flow.module.d.ts.map +1 -1
  160. package/dist/os/flow/flow.module.js +19 -4
  161. package/dist/os/flow/flow.module.js.map +1 -1
  162. package/dist/os/flow/handlers/flow-check.d.ts.map +1 -1
  163. package/dist/os/flow/handlers/flow-check.js +9 -9
  164. package/dist/os/flow/handlers/flow-check.js.map +1 -1
  165. package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -1
  166. package/dist/os/flow/handlers/flow-digest.js +11 -1
  167. package/dist/os/flow/handlers/flow-digest.js.map +1 -1
  168. package/dist/os/flow/handlers/flow-integrate.d.ts +11 -0
  169. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
  170. package/dist/os/flow/handlers/flow-integrate.js +148 -30
  171. package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
  172. package/dist/os/flow/handlers/flow-open.d.ts.map +1 -1
  173. package/dist/os/flow/handlers/flow-open.js +14 -19
  174. package/dist/os/flow/handlers/flow-open.js.map +1 -1
  175. package/dist/os/flow/index.d.ts +1 -0
  176. package/dist/os/flow/index.d.ts.map +1 -1
  177. package/dist/os/flow/index.js +5 -3
  178. package/dist/os/flow/index.js.map +1 -1
  179. package/dist/os/flow/post-rebase-regen.d.ts +33 -0
  180. package/dist/os/flow/post-rebase-regen.d.ts.map +1 -0
  181. package/dist/os/flow/post-rebase-regen.js +120 -0
  182. package/dist/os/flow/post-rebase-regen.js.map +1 -0
  183. package/dist/os/flow/preflight.d.ts +24 -0
  184. package/dist/os/flow/preflight.d.ts.map +1 -1
  185. package/dist/os/flow/preflight.js +364 -24
  186. package/dist/os/flow/preflight.js.map +1 -1
  187. package/dist/os/flow/publish.d.ts.map +1 -1
  188. package/dist/os/flow/publish.js +23 -4
  189. package/dist/os/flow/publish.js.map +1 -1
  190. package/dist/os/flow/registry.d.ts +6 -6
  191. package/dist/os/flow/tests/helpers.d.ts +9 -1
  192. package/dist/os/flow/tests/helpers.d.ts.map +1 -1
  193. package/dist/os/flow/tests/helpers.js +36 -2
  194. package/dist/os/flow/tests/helpers.js.map +1 -1
  195. package/dist/os/friction/types.d.ts +2 -2
  196. package/dist/os/gate-run/detach.d.ts +27 -0
  197. package/dist/os/gate-run/detach.d.ts.map +1 -0
  198. package/dist/os/gate-run/detach.js +85 -0
  199. package/dist/os/gate-run/detach.js.map +1 -0
  200. package/dist/os/gate-run/gate-run.module.d.ts +3 -0
  201. package/dist/os/gate-run/gate-run.module.d.ts.map +1 -0
  202. package/dist/os/gate-run/gate-run.module.js +23 -0
  203. package/dist/os/gate-run/gate-run.module.js.map +1 -0
  204. package/dist/os/gate-run/index.d.ts +7 -0
  205. package/dist/os/gate-run/index.d.ts.map +1 -0
  206. package/dist/os/gate-run/index.js +5 -0
  207. package/dist/os/gate-run/index.js.map +1 -0
  208. package/dist/os/gate-run/record.d.ts +47 -0
  209. package/dist/os/gate-run/record.d.ts.map +1 -0
  210. package/dist/os/gate-run/record.js +157 -0
  211. package/dist/os/gate-run/record.js.map +1 -0
  212. package/dist/os/gate-run/status.d.ts +53 -0
  213. package/dist/os/gate-run/status.d.ts.map +1 -0
  214. package/dist/os/gate-run/status.js +163 -0
  215. package/dist/os/gate-run/status.js.map +1 -0
  216. package/dist/os/gate-run/types.d.ts +47 -0
  217. package/dist/os/gate-run/types.d.ts.map +1 -0
  218. package/dist/os/gate-run/types.js +24 -0
  219. package/dist/os/gate-run/types.js.map +1 -0
  220. package/dist/os/program/schemas.d.ts +3 -3
  221. package/dist/os/queue/types.d.ts +2 -2
  222. package/dist/os/rfc/evidence-annotation.d.ts +26 -0
  223. package/dist/os/rfc/evidence-annotation.d.ts.map +1 -0
  224. package/dist/os/rfc/evidence-annotation.js +52 -0
  225. package/dist/os/rfc/evidence-annotation.js.map +1 -0
  226. package/dist/os/rfc/handlers/fixed-inputs.d.ts.map +1 -1
  227. package/dist/os/rfc/handlers/fixed-inputs.js +7 -1
  228. package/dist/os/rfc/handlers/fixed-inputs.js.map +1 -1
  229. package/dist/os/rfc/handlers/implement-stamp-promotes.d.ts +8 -0
  230. package/dist/os/rfc/handlers/implement-stamp-promotes.d.ts.map +1 -0
  231. package/dist/os/rfc/handlers/implement-stamp-promotes.js +65 -0
  232. package/dist/os/rfc/handlers/implement-stamp-promotes.js.map +1 -0
  233. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  234. package/dist/os/rfc/handlers/implement-stamp.js +35 -29
  235. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  236. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  237. package/dist/os/rfc/handlers/validate-rules.js +152 -11
  238. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  239. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  240. package/dist/os/rfc/rfc.module.js +20 -7
  241. package/dist/os/rfc/rfc.module.js.map +1 -1
  242. package/dist/os/rfc/types.d.ts +12 -3
  243. package/dist/os/rfc/types.d.ts.map +1 -1
  244. package/dist/os/rfc/types.js +5 -2
  245. package/dist/os/rfc/types.js.map +1 -1
  246. package/dist/os/rfc/verify-workspace.d.ts +12 -0
  247. package/dist/os/rfc/verify-workspace.d.ts.map +1 -1
  248. package/dist/os/rfc/verify-workspace.js +155 -0
  249. package/dist/os/rfc/verify-workspace.js.map +1 -1
  250. package/dist/os/system/task-schemas.d.ts +1 -1
  251. package/dist/os/system/tests/helpers.d.ts.map +1 -1
  252. package/dist/os/system/tests/helpers.js +6 -1
  253. package/dist/os/system/tests/helpers.js.map +1 -1
  254. package/dist/os/werkstatt/handlers/schema.d.ts +1 -1
  255. package/dist/src/cli-flags.d.ts.map +1 -1
  256. package/dist/src/cli-flags.js +6 -0
  257. package/dist/src/cli-flags.js.map +1 -1
  258. package/dist/src/command-modules.d.ts +4 -0
  259. package/dist/src/command-modules.d.ts.map +1 -0
  260. package/dist/src/command-modules.js +42 -0
  261. package/dist/src/command-modules.js.map +1 -0
  262. package/dist/src/config/forge-config.d.ts +16 -1
  263. package/dist/src/config/forge-config.d.ts.map +1 -1
  264. package/dist/src/config/forge-config.js +27 -11
  265. package/dist/src/config/forge-config.js.map +1 -1
  266. package/dist/src/correctness/index.d.ts +32 -0
  267. package/dist/src/correctness/index.d.ts.map +1 -0
  268. package/dist/src/correctness/index.js +157 -0
  269. package/dist/src/correctness/index.js.map +1 -0
  270. package/dist/src/correctness/schema-hash.d.ts +15 -0
  271. package/dist/src/correctness/schema-hash.d.ts.map +1 -0
  272. package/dist/src/correctness/schema-hash.js +44 -0
  273. package/dist/src/correctness/schema-hash.js.map +1 -0
  274. package/dist/src/knowledge/schema.d.ts +1 -1
  275. package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
  276. package/dist/src/onboarding/agents-generate.js +20 -3
  277. package/dist/src/onboarding/agents-generate.js.map +1 -1
  278. package/dist/src/onboarding/create.d.ts +7 -0
  279. package/dist/src/onboarding/create.d.ts.map +1 -1
  280. package/dist/src/onboarding/create.js +62 -9
  281. package/dist/src/onboarding/create.js.map +1 -1
  282. package/dist/src/types.d.ts +7 -0
  283. package/dist/src/types.d.ts.map +1 -1
  284. package/dist/src/types.js +2 -8
  285. package/dist/src/types.js.map +1 -1
  286. package/docs/reference/correctness-audit.md +91 -0
  287. package/docs/reference/correctness-gate.md +102 -0
  288. package/docs/reference/correctness-manifest.md +142 -0
  289. package/docs/reference/forge-yaml.md +15 -0
  290. package/os/codebase/codebase.module.ts +57 -0
  291. package/os/codebase/handlers/codebase-measure-symbols.ts +131 -0
  292. package/os/codebase/handlers/codebase-measure.ts +503 -0
  293. package/os/codebase/index.ts +21 -0
  294. package/os/codebase/types.ts +55 -0
  295. package/os/core/handlers/package-health.test.ts +24 -2
  296. package/os/core/handlers/package-health.ts +16 -19
  297. package/os/correctness/anchors.ts +182 -0
  298. package/os/correctness/audit/bindings-verify-substance.test.ts +79 -0
  299. package/os/correctness/audit/bindings-verify-substance.ts +155 -0
  300. package/os/correctness/audit/differential.test.ts +113 -0
  301. package/os/correctness/audit/differential.ts +131 -0
  302. package/os/correctness/audit/ledger-orphans.test.ts +96 -0
  303. package/os/correctness/audit/ledger-orphans.ts +84 -0
  304. package/os/correctness/audit/ledger.test.ts +65 -0
  305. package/os/correctness/audit/ledger.ts +103 -0
  306. package/os/correctness/audit/run.ts +220 -0
  307. package/os/correctness/audit/schema-db.ts +208 -0
  308. package/os/correctness/audit/snapshot.ts +211 -0
  309. package/os/correctness/audit/sql-scanner.test.ts +84 -0
  310. package/os/correctness/audit/sql-scanner.ts +289 -0
  311. package/os/correctness/audit/sql-schema-conform.test.ts +170 -0
  312. package/os/correctness/audit/sql-schema-conform.ts +178 -0
  313. package/os/correctness/audit/state-transitions-coverage.test.ts +141 -0
  314. package/os/correctness/audit/state-transitions-coverage.ts +271 -0
  315. package/os/correctness/audit/tests/git-fixture.ts +98 -0
  316. package/os/correctness/audit/types.ts +91 -0
  317. package/os/correctness/correctness-capture.test.ts +107 -0
  318. package/os/correctness/correctness-chain.test.ts +232 -0
  319. package/os/correctness/correctness-coverage.test.ts +86 -0
  320. package/os/correctness/correctness-mode.test.ts +108 -0
  321. package/os/correctness/correctness-substrate.test.ts +64 -0
  322. package/os/correctness/correctness.module.ts +182 -0
  323. package/os/correctness/gate/anchor-events.test.ts +77 -0
  324. package/os/correctness/gate/freeze-coverage.test.ts +218 -0
  325. package/os/correctness/gate/freeze-diff.test.ts +110 -0
  326. package/os/correctness/gate/frozen.ts +399 -0
  327. package/os/correctness/gate/gate-mode.test.ts +76 -0
  328. package/os/correctness/gate/hardening.test.ts +175 -0
  329. package/os/correctness/gate/oracle-edit.test.ts +83 -0
  330. package/os/correctness/gate/oracle-origin.test.ts +142 -0
  331. package/os/correctness/gate/origin.ts +175 -0
  332. package/os/correctness/gate/repo.ts +102 -0
  333. package/os/correctness/gate/run.ts +547 -0
  334. package/os/correctness/gate/runner.ts +136 -0
  335. package/os/correctness/gate/substrate-attestation.test.ts +71 -0
  336. package/os/correctness/gate/tests/gate-fixture.ts +205 -0
  337. package/os/correctness/gate/tier-high.test.ts +92 -0
  338. package/os/correctness/gate/types.ts +144 -0
  339. package/os/correctness/handlers/audit.ts +107 -0
  340. package/os/correctness/handlers/gate.ts +75 -0
  341. package/os/correctness/handlers/validate.ts +514 -0
  342. package/os/correctness/index.ts +24 -0
  343. package/os/correctness/manifest-schema.ts +174 -0
  344. package/os/correctness/references.ts +143 -0
  345. package/os/correctness/tests/fixture-workspace.ts +119 -0
  346. package/os/correctness/workspace.ts +167 -0
  347. package/os/flow/correctness-step.ts +166 -0
  348. package/os/flow/digest.ts +40 -1
  349. package/os/flow/dirty-classify.ts +13 -0
  350. package/os/flow/flow.module.ts +20 -4
  351. package/os/flow/handlers/flow-check.ts +17 -18
  352. package/os/flow/handlers/flow-digest.ts +11 -1
  353. package/os/flow/handlers/flow-integrate.ts +191 -39
  354. package/os/flow/handlers/flow-open.ts +24 -31
  355. package/os/flow/index.ts +5 -7
  356. package/os/flow/post-rebase-regen.ts +170 -0
  357. package/os/flow/preflight.ts +361 -27
  358. package/os/flow/publish.ts +23 -4
  359. package/os/flow/tests/flow-detachable.test.ts +31 -0
  360. package/os/flow/tests/flow-digest-correctness-trail.test.ts +55 -0
  361. package/os/flow/tests/flow-integrate-correctness-gate.test.ts +275 -0
  362. package/os/flow/tests/flow-integrate.post-rebase-regen.test.ts +234 -0
  363. package/os/flow/tests/flow-integrate.preflight.test.ts +26 -5
  364. package/os/flow/tests/flow-integrate.test.ts +77 -10
  365. package/os/flow/tests/helpers.ts +45 -24
  366. package/os/flow/tests/lockfile-induced.test.ts +328 -0
  367. package/os/gate-run/detach.ts +106 -0
  368. package/os/gate-run/gate-run.module.ts +25 -0
  369. package/os/gate-run/index.ts +16 -0
  370. package/os/gate-run/record.ts +194 -0
  371. package/os/gate-run/status.ts +201 -0
  372. package/os/gate-run/tests/gate-run-detach.test.ts +144 -0
  373. package/os/gate-run/tests/gate-run-record.test.ts +200 -0
  374. package/os/gate-run/tests/gate-run-status.test.ts +114 -0
  375. package/os/gate-run/types.ts +73 -0
  376. package/os/rfc/evidence-annotation.ts +61 -0
  377. package/os/rfc/handlers/fixed-inputs.test.ts +70 -0
  378. package/os/rfc/handlers/fixed-inputs.ts +11 -1
  379. package/os/rfc/handlers/implement-stamp-promotes.test.ts +214 -0
  380. package/os/rfc/handlers/implement-stamp-promotes.ts +79 -0
  381. package/os/rfc/handlers/implement-stamp.ts +40 -29
  382. package/os/rfc/handlers/list-create.test.ts +14 -5
  383. package/os/rfc/handlers/validate-evidence-shape.test.ts +218 -0
  384. package/os/rfc/handlers/validate-probe-meta.test.ts +71 -0
  385. package/os/rfc/handlers/validate-rules.ts +211 -21
  386. package/os/rfc/handlers/validate-transient-probes.test.ts +222 -0
  387. package/os/rfc/rfc-0000-template.md +10 -10
  388. package/os/rfc/rfc.module.ts +21 -7
  389. package/os/rfc/types.ts +16 -2
  390. package/os/rfc/verify-workspace-manifest.test.ts +55 -0
  391. package/os/rfc/verify-workspace.ts +167 -0
  392. package/os/system/tests/helpers.ts +6 -1
  393. package/package.json +57 -1
  394. package/profiles/typescript.yaml +16 -0
  395. package/skills/_shared/agent-operating-model.md +4 -0
  396. package/skills/fo/fo-idea-audit/SKILL.md +4 -0
  397. package/skills/fo/fo-idea-create-rfc/SKILL.md +6 -2
  398. package/skills/fo/fo-idea-implement/SKILL.md +8 -2
  399. package/skills/fo/fo-review/SKILL.md +16 -2
  400. package/skills/fo/fo-session-retro/SKILL.md +4 -2
  401. package/src/cli-flags.ts +7 -0
  402. package/src/command-modules.ts +62 -0
  403. package/src/config/forge-config.ts +37 -11
  404. package/src/correctness/index.ts +192 -0
  405. package/src/correctness/schema-hash.ts +59 -0
  406. package/src/onboarding/agents-generate.ts +20 -3
  407. package/src/onboarding/create.ts +59 -9
  408. package/src/tests/agents-generate-detach.test.ts +126 -0
  409. package/src/tests/codebase-measure-rfc-1581.test.ts +260 -0
  410. package/src/tests/command-modules.test.ts +34 -0
  411. package/src/types.ts +9 -8
@@ -0,0 +1,222 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>RFC-1569 V-54 — transient probe target lint: missions/ paths,
4
+ --mission flags, app-scoped run commands, outcomeBuild exemption.</purpose>
5
+ <non-goals>
6
+ <item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
7
+ </non-goals>
8
+ </MODULE_CONTRACT>
9
+ <CHANGE_SUMMARY>
10
+ <item>RFC-1569: V-54 rule tests (AC-4, AC-5, --mission/app-scope arms)</item>
11
+ <item>RFC-1569: lint rfc evidence annotations and transient probe targets</item>
12
+ </CHANGE_SUMMARY>
13
+ */
14
+
15
+ import { test, expect, describe, beforeAll } from "vitest";
16
+ import { mkdirSync, writeFileSync } from "node:fs";
17
+ import { validateSingleRfc, type AddViolationFn } from "./validate-rules.ts";
18
+ import type { ParsedRfc } from "../frontmatter-io.ts";
19
+ import { join } from "node:path";
20
+ import { tmpdir } from "node:os";
21
+
22
+ const testWorkspace = join(tmpdir(), "test-workspace-rfc1569-v54");
23
+
24
+ beforeAll(() => {
25
+ mkdirSync(join(testWorkspace, "docs"), { recursive: true });
26
+ writeFileSync(
27
+ join(testWorkspace, "forge.yaml"),
28
+ 'bindings:\n commands:\n outcomeBuild: "werkstatt run leitstand.build --id {target}"\n',
29
+ );
30
+ writeFileSync(
31
+ join(testWorkspace, "docs", "command-manifest.generated.yaml"),
32
+ "commands:\n - name: agent.api-catalog.validate\n scope: app\n - name: rfc.validate\n scope: workspace\n",
33
+ );
34
+ });
35
+
36
+ function makeParsed(body: string, acceptance: unknown[]): ParsedRfc {
37
+ return {
38
+ frontmatter: {
39
+ id: "RFC-9999",
40
+ title: "Test RFC",
41
+ status: "draft",
42
+ kind: "command",
43
+ scope: "workspace",
44
+ owners: ["architecture"],
45
+ createdAt: "2026-09-01",
46
+ updatedAt: "2026-09-01",
47
+ acceptance,
48
+ },
49
+ body,
50
+ };
51
+ }
52
+
53
+ const BASE_BODY = `
54
+ # RFC-9999: Test RFC
55
+
56
+ ## Context
57
+
58
+ Test context.
59
+
60
+ ## Problem
61
+
62
+ Test problem.
63
+
64
+ ## Decision
65
+
66
+ Test decision.
67
+
68
+ ## Architectural fit
69
+
70
+ Test fit.
71
+
72
+ ## Design
73
+
74
+ ### CLI surface
75
+
76
+ Test CLI.
77
+
78
+ ### TypeScript contracts
79
+
80
+ Test types.
81
+
82
+ ### File system responsibilities
83
+
84
+ | Path | Role |
85
+ |---|---|
86
+ | \`test.ts\` | test |
87
+
88
+ ### Output format
89
+
90
+ Test output.
91
+
92
+ ### Failure modes
93
+
94
+ Test failures.
95
+
96
+ ## Rollout
97
+
98
+ Test rollout.
99
+
100
+ ## Alternatives considered
101
+
102
+ Test alternatives.
103
+
104
+ ## Risks
105
+
106
+ Test risks.
107
+
108
+ ## Acceptance criteria
109
+
110
+ - [ ] AC-1: first criterion
111
+ - [ ] AC-2: second criterion
112
+
113
+ ## Implementation notes for agents
114
+
115
+ Test notes.
116
+ `;
117
+
118
+ async function runValidate(
119
+ parsed: ParsedRfc,
120
+ ): Promise<{ rfcId: string; rule: string; message: string; severity: string }[]> {
121
+ const violations: { rfcId: string; rule: string; message: string; severity: string }[] = [];
122
+ const add: AddViolationFn = (rfcId, _file, rule, message, severity = "error") => {
123
+ violations.push({ rfcId, rule, message, severity });
124
+ };
125
+ await validateSingleRfc(
126
+ "rfc-9999-test.md",
127
+ parsed,
128
+ new Map(),
129
+ new Map(),
130
+ new Set(),
131
+ new Set(),
132
+ new Set(Object.keys(parsed.frontmatter)),
133
+ testWorkspace,
134
+ add,
135
+ );
136
+ return violations.filter((v) => v.rule === "V-54");
137
+ }
138
+
139
+ describe("V-54: transient probe targets (RFC-1569)", () => {
140
+ test("AC-4: file-contains probe under missions/ reports warning", async () => {
141
+ const violations = await runValidate(
142
+ makeParsed(BASE_BODY, [
143
+ {
144
+ probe: "file-contains",
145
+ criterion: "AC-1",
146
+ path: "missions/warpgogol-m000219/workpiece/src/index.astro",
147
+ pattern: "hero",
148
+ },
149
+ ]),
150
+ );
151
+ expect(violations.length).toBe(1);
152
+ expect(violations[0]!.severity).toBe("warning");
153
+ expect(violations[0]!.message).toContain("missions/");
154
+ });
155
+
156
+ test("missions/archive/ path is durable — no V-54", async () => {
157
+ const violations = await runValidate(
158
+ makeParsed(BASE_BODY, [
159
+ {
160
+ probe: "file-exists",
161
+ criterion: "AC-1",
162
+ path: "missions/archive/warpgogol-m000219/report.json",
163
+ },
164
+ ]),
165
+ );
166
+ expect(violations).toEqual([]);
167
+ });
168
+
169
+ test("run probe carrying --mission reports warning", async () => {
170
+ const violations = await runValidate(
171
+ makeParsed(BASE_BODY, [
172
+ {
173
+ probe: "run",
174
+ criterion: "AC-1",
175
+ command: "werkstatt run mission.validate --mission m000219 --json",
176
+ },
177
+ ]),
178
+ );
179
+ expect(violations.length).toBe(1);
180
+ expect(violations[0]!.message).toContain("--mission");
181
+ });
182
+
183
+ test("app-scoped run command reports warning", async () => {
184
+ const violations = await runValidate(
185
+ makeParsed(BASE_BODY, [
186
+ {
187
+ probe: "run",
188
+ criterion: "AC-1",
189
+ command: "pnpm exec werkstatt run agent.api-catalog.validate --app warpgogol",
190
+ },
191
+ ]),
192
+ );
193
+ expect(violations.length).toBe(1);
194
+ expect(violations[0]!.message).toContain("agent.api-catalog.validate");
195
+ });
196
+
197
+ test("AC-5: outcomeBuild binding command is exempt", async () => {
198
+ const violations = await runValidate(
199
+ makeParsed(BASE_BODY, [
200
+ {
201
+ probe: "run",
202
+ criterion: "AC-1",
203
+ command: "werkstatt run leitstand.build --id warpgogol",
204
+ },
205
+ ]),
206
+ );
207
+ expect(violations).toEqual([]);
208
+ });
209
+
210
+ test("workspace-scoped run command is clean", async () => {
211
+ const violations = await runValidate(
212
+ makeParsed(BASE_BODY, [
213
+ {
214
+ probe: "run",
215
+ criterion: "AC-1",
216
+ command: "pnpm exec werkstatt run rfc.validate --id RFC-9999",
217
+ },
218
+ ]),
219
+ );
220
+ expect(violations).toEqual([]);
221
+ });
222
+ });
@@ -225,8 +225,8 @@ interface ExampleResult {
225
225
  system behavior — they are checks that the document is complete.
226
226
  Use DR-N: identifiers. V-38 enforces completeness for accepted+ post-cutoff RFCs.
227
227
 
228
- - [ ] DR-1: Every considered alternative has a stated reason for rejection (evidence: file: <path:line>)
229
- - [ ] DR-2: The RFC enumerates every existing artifact it touches (evidence: file: <path:line>)
228
+ - [ ] DR-1: Every considered alternative has a stated reason for rejection (evidence: file:<path>:<line>)
229
+ - [ ] DR-2: The RFC enumerates every existing artifact it touches (evidence: file:<path>:<line>)
230
230
  - [ ] DR-3: The RFC states whether the decision is reversible and at what cost
231
231
  -->
232
232
 
@@ -235,12 +235,12 @@ interface ExampleResult {
235
235
  <!-- V-50 contract (RFC-1455): every value this RFC pins for the shipped
236
236
  result (verbatim copy, labels, names, decided option values) is a row
237
237
  bound to exactly one AC-N criterion whose probes observe the value.
238
- Emit the header schema only — a live placeholder row would itself trip
238
+ V-50 containment compares each literal against the regex-UNESCAPED probe pattern — escaping a metachar literal keeps coverage. Emit the header schema only — a live placeholder row would itself trip
239
239
  V-50. Add rows only when the draft fixes real inputs; delete this
240
240
  section's table when none exist. -->
241
241
 
242
- | ID | Value | Source | Checked by |
243
- | --- | --- | --- | --- |
242
+ | ID | Value | Source | Checked by |
243
+ | --- | ----- | ------ | ---------- |
244
244
 
245
245
  ## Acceptance criteria
246
246
 
@@ -248,11 +248,11 @@ interface ExampleResult {
248
248
  Each criterion is a falsifiable claim about an observable artifact, written in EARS form with a stable AC-N: identifier.
249
249
  Required mix: behavior, contract, negative, sync. 3–10 items. One claim = one checking mechanism. -->
250
250
 
251
- - [ ] AC-1: WHEN `<command> --json` is invoked, THE command SHALL return a JSON object matching the documented output schema (evidence: probe:AC-1 or test: <path>)
252
- - [ ] AC-2: THE `<command>` SHALL be registered in the kernel module with the correct name and scope (evidence: file: <module-path>)
253
- - [ ] AC-3: IF `<command>` receives invalid input, THEN THE command SHALL report a blocking error (evidence: test: <path/to/test>)
254
- - [ ] AC-4: IF `<command>` receives invalid input, THEN THE command SHALL exit non-zero (evidence: test: <path/to/test>)
255
- - [ ] AC-5: THE relevant `AGENTS.md` SHALL reference this RFC where agent behavior rules changed (evidence: file: <path:line>)
251
+ - [ ] AC-1: WHEN `<command> --json` is invoked, THE command SHALL return a JSON object matching the documented output schema (evidence: probe:AC-1)
252
+ - [ ] AC-2: THE `<command>` SHALL be registered in the kernel module with the correct name and scope (evidence: file:<module-path>)
253
+ - [ ] AC-3: IF `<command>` receives invalid input, THEN THE command SHALL report a blocking error (evidence: test:<path/to/test>)
254
+ - [ ] AC-4: IF `<command>` receives invalid input, THEN THE command SHALL exit non-zero (evidence: test:<path/to/test>)
255
+ - [ ] AC-5: THE relevant `AGENTS.md` SHALL reference this RFC where agent behavior rules changed (evidence: file:<path>:<line>)
256
256
 
257
257
  ## Implementation notes for agents
258
258
 
@@ -7,14 +7,14 @@
7
7
  </non-goals>
8
8
  </MODULE_CONTRACT>
9
9
  <CHANGE_SUMMARY>
10
- <item>RFC-1483: self-sufficient implement stamp — default repair pass, ordered remediation checklist, --no-repair</item>
11
- <item>RFC-1489: batch test probes through one instrumented Vitest run + frontmatter corpus reads
12
-
13
- runProbeSet is the single shared execution point: barrier-free segments of test probes sharing one effective bound run in one vitest --reporter=json --outputFile process with per-(file,testName) attribution; missing files/reports yield unverified. run/page/proof and all non-test kinds are barriers. --no-batch escapes to the legacy path on acceptance.run, verification.emit and verification.refresh. rfc.validate reads non-target corpus files frontmatter-only via readRfcFrontmatter (64 KiB bound, full-parse fallback); emit/refresh/acceptance corpus scans use the same accessor. Corpus map slimmed to RfcCorpusEntry {fileName, frontmatter}.</item>
14
10
  <item>RFC-1516: add an evidence-freshness window to the stamp-sync chain for rfc-1516</item>
15
11
  <item>RFC-1528: close review findings — manifest-union command inventory for regen/preflight</item>
16
12
  <item>RFC-1534: lint probe patterns, sync amends counterparts, name next free ledger id</item>
17
- <history>RFC-0260, RFC-0795, RFC-1097, RFC-1173, RFC-1231, RFC-1237, RFC-1249, RFC-1271, RFC-1306, RFC-1322, RFC-1333, RFC-1351, RFC-1354, RFC-1364, RFC-1453, RFC-1458, RFC-1461, RFC-1463, RFC-1467, RFC-1474, RFC-1482</history>
13
+ <item>RFC-1568: durable gate-run records, --detach mechanics, and forge CLI wiring</item>
14
+ <item>RFC-1580: digest trail, manifest review export, operating model and skills
15
+
16
+ flow.digest lists X-Correctness-Weakening trailers and verifier-trailer commits (correctnessTrail, part of digestId); rfc.verify.workspace --manifest exports the oracle-review surface with MANIFEST-REVIEW-BUNDLE.md hashes; operating model §7 product tiers and §8 'a self oracle never covers an anchor of a product correctness manifest'; fo-review oracle review mode producing forge/oracle-review@1; fo-idea-implement step 4.4c; correctness-gate reference page; forge AGENTS.md gate rules.</item>
17
+ <history>RFC-0260, RFC-0795, RFC-1097, RFC-1173, RFC-1231, RFC-1237, RFC-1249, RFC-1271, RFC-1306, RFC-1322, RFC-1333, RFC-1351, RFC-1354, RFC-1364, RFC-1453, RFC-1458, RFC-1461, RFC-1463, RFC-1467, RFC-1474, RFC-1482, RFC-1483, RFC-1489</history>
18
18
  </CHANGE_SUMMARY>
19
19
  */
20
20
 
@@ -294,7 +294,10 @@ export async function createForgeRfcModule(): Promise<ForgeModule> {
294
294
  "clean-context acceptance verifier — implementer in-range tests, the RFC's plan/review/" +
295
295
  "session/queue documents, and its evidence envelope are stripped; VERIFY-BUNDLE.md carries " +
296
296
  "only the RFC's Context/Problem/Decision/Design/Acceptance criteria. Writes nothing in the repository. " +
297
- "Required flags: `--id`, `--candidate`.",
297
+ "Required flags: `--id`, `--candidate`. RFC-1580: `--manifest --candidate <sha>` exports the " +
298
+ "candidate for an oracle review instead — the product correctness manifest, requirement documents, " +
299
+ "anchored code, oracle/support files and captures stay; plans, reviews, sessions, handoffs, audits, " +
300
+ "queues, explorations, and evidence are stripped; MANIFEST-REVIEW-BUNDLE.md lists each oracle with its sha256.",
298
301
  scope: "workspace",
299
302
  // Exports via `git archive | tar -x` subprocesses + temp-dir writes —
300
303
  // read-only toward the repository; execOnReadOnly keeps the subprocess
@@ -308,12 +311,22 @@ export async function createForgeRfcModule(): Promise<ForgeModule> {
308
311
  reads: ["docs/rfcs/**/*.md"],
309
312
  cacheable: false,
310
313
  flags: {
311
- id: { kind: "string", required: true, description: "Target RFC id." },
314
+ id: {
315
+ kind: "string",
316
+ required: false,
317
+ description: "Target RFC id (required unless --manifest).",
318
+ },
312
319
  candidate: {
313
320
  kind: "string",
314
321
  required: true,
315
322
  description: "Committed candidate SHA to export.",
316
323
  },
324
+ manifest: {
325
+ kind: "boolean",
326
+ required: false,
327
+ description:
328
+ "RFC-1580: export for a clean-context oracle review of the product correctness manifest.",
329
+ },
317
330
  },
318
331
  execute: runRfcVerifyWorkspace,
319
332
  },
@@ -556,6 +569,7 @@ export async function createForgeRfcModule(): Promise<ForgeModule> {
556
569
  },
557
570
  {
558
571
  name: "rfc.implement.stamp",
572
+ detachable: true,
559
573
  // gate-completeness: handlers/implement-stamp.ts accumulates
560
574
  // violations[] across every independent precondition gate and emits
561
575
  // one stampFailResult — the complete set in a single run (RFC-1463).
package/os/rfc/types.ts CHANGED
@@ -12,14 +12,16 @@
12
12
  * </non-goals>
13
13
  * </MODULE_CONTRACT>
14
14
  * * <CHANGE_SUMMARY>
15
- <item>RFC-1516: bind evidence reuse to the oldest replayed result and harden committed-envelope reads for rfc-1516</item>
16
15
  <item>RFC-1514: attach corrected invocations to blocking diagnostics so retry is one-shot</item>
17
16
  <item>RFC-1536: owning-checkout routing, FLOW-OPEN-01 dirty-primary warning, shared governance-id allocation (RFC+ADR)</item>
18
17
  <item>RFC-1534: lint probe patterns, sync amends counterparts, name next free ledger id</item>
19
18
  <item>RFC-1546: derive-and-repair recoverable state across flow surfaces (AC-1..AC-5)</item>
19
+ <item>RFC-1578: correctness manifest, validator, promotes gate
20
+
21
+ Add os/correctness (forge/correctness-manifest@1, correctness.manifest.validate CORR-01..09), bindings.paths.correctnessManifest, bindings.commands.checkRun and the correctness section, promotes with V-55 and RFC-IMP-16, the typescript profile skeleton, reference pages, and the promotes marking in fo-idea-create-rfc/fo-idea-audit. Repoint the RFC-1391 AC-8 registry test at src/command-modules.ts (stale since RFC-1573) and close the types.ts header comment without a glob-shaped terminator (EC-33).</item>
20
22
  <history>RFC-0465, RFC-0478, RFC-0480, RFC-0795, RFC-0998, RFC-0999, RFC-1097, RFC-1249, RFC-1271, RFC-1306, RFC-1310, RFC-1320, RFC-1322, RFC-1330, RFC-1333, RFC-1334, RFC-1336, RFC-1364, RFC-1383, RFC-1391, RFC-1401, RFC-1445, RFC-1453, RFC-1454, RFC-1455, RFC-1458, RFC-1467, RFC-1483, RFC-1516</history>
21
23
  </CHANGE_SUMMARY>
22
- ***************************************************************/
24
+ */
23
25
 
24
26
  import type { Diagnostic } from "../../src/types.ts";
25
27
 
@@ -296,6 +298,14 @@ export interface RfcFrontmatter {
296
298
  * Filterable via `rfc.list --batch <slug>`.
297
299
  */
298
300
  batch?: string;
301
+
302
+ /**
303
+ * RFC-1578: acceptance criteria (`AC-N`) that describe lasting behaviour.
304
+ * Each must be one of this RFC's criteria (V-55); in a project with a
305
+ * correctness-manifest binding, `rfc.implement.stamp` refuses while a
306
+ * promoted criterion has no `source: rfc-ac` manifest entry (RFC-IMP-16).
307
+ */
308
+ promotes?: string[];
299
309
  } // ─── RFC-0268: acceptance probes ───────────────────────────────────────────
300
310
 
301
311
  /**
@@ -820,6 +830,9 @@ export type RfcImplementStampRule =
820
830
  // RFC-1454: a committed review report's amend designDeviation is absent
821
831
  // from the RFC's "## Deviations" section, or the record is malformed.
822
832
  | "RFC-IMP-15"
833
+ // RFC-1578: a promoted criterion has no `source: rfc-ac` entry in the
834
+ // product correctness manifest (warning when no manifest is bound).
835
+ | "RFC-IMP-16"
823
836
  // RFC-1310: commit-time governance provenance — the implementation commit
824
837
  // must carry the X-RFC trailer or an injected CHANGE_SUMMARY item.
825
838
  | "STAMP-GOV-01"
@@ -917,6 +930,7 @@ export const RFC_KNOWN_KEYS: readonly string[] = [
917
930
  "liveSpec",
918
931
  "dependsOn",
919
932
  "batch",
933
+ "promotes",
920
934
  ] as const;
921
935
 
922
936
  /**
@@ -0,0 +1,55 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>RFC-1580: `rfc.verify.workspace --manifest` — the oracle-review
4
+ export keeps the manifest, requirements, anchored code, and oracles, strips
5
+ narrative directories, and lists every oracle with the sha256 a
6
+ forge/oracle-review@1 record must name.</purpose>
7
+ <non-goals>
8
+ <item>Not an RFC-1333 acceptance-export test — verify-workspace.test.ts owns that mode.</item>
9
+ </non-goals>
10
+ </MODULE_CONTRACT>
11
+ <CHANGE_SUMMARY>
12
+ <item>RFC-1580: initial suite.</item>
13
+ <item>RFC-1580: digest trail, manifest review export, operating model and skills
14
+
15
+ flow.digest lists X-Correctness-Weakening trailers and verifier-trailer commits (correctnessTrail, part of digestId); rfc.verify.workspace --manifest exports the oracle-review surface with MANIFEST-REVIEW-BUNDLE.md hashes; operating model §7 product tiers and §8 'a self oracle never covers an anchor of a product correctness manifest'; fo-review oracle review mode producing forge/oracle-review@1; fo-idea-implement step 4.4c; correctness-gate reference page; forge AGENTS.md gate rules.</item>
16
+ </CHANGE_SUMMARY>
17
+ */
18
+
19
+ import { createHash } from "node:crypto";
20
+ import { existsSync, readFileSync, rmSync } from "node:fs";
21
+ import path from "node:path";
22
+
23
+ import { afterEach, describe, expect, it } from "vitest";
24
+
25
+ import {
26
+ L1_ORACLE,
27
+ ORACLE_PATH,
28
+ makeGateFixture,
29
+ type GateFixture,
30
+ } from "../correctness/gate/tests/gate-fixture.ts";
31
+ import { buildManifestReviewWorkspace } from "./verify-workspace.ts";
32
+
33
+ const cleanups: (() => void)[] = [];
34
+ afterEach(() => cleanups.splice(0).forEach((c) => c()));
35
+
36
+ describe("rfc.verify.workspace --manifest", () => {
37
+ it("exports the review surface, strips narrative, and lists oracle hashes", async () => {
38
+ const f: GateFixture = makeGateFixture({});
39
+ cleanups.push(f.cleanup);
40
+ f.write("docs/plans/plan-x.md", "# narrative\n");
41
+ f.write("docs/sessions/s.md", "# narrative\n");
42
+ const head = f.commit("narrative");
43
+ const res = await buildManifestReviewWorkspace({ workspaceRoot: f.root, candidateSha: head });
44
+ expect(res.status, res.error).toBe("pass");
45
+ cleanups.push(() => rmSync(res.path!, { recursive: true, force: true }));
46
+ expect(existsSync(path.join(res.path!, "docs/correctness.yaml"))).toBe(true);
47
+ expect(existsSync(path.join(res.path!, ORACLE_PATH))).toBe(true);
48
+ expect(existsSync(path.join(res.path!, "apps/api/src/dispatch.ts"))).toBe(true);
49
+ expect(existsSync(path.join(res.path!, "docs/plans"))).toBe(false);
50
+ expect(existsSync(path.join(res.path!, "docs/sessions"))).toBe(false);
51
+ const bundle = readFileSync(path.join(res.path!, "MANIFEST-REVIEW-BUNDLE.md"), "utf8");
52
+ expect(bundle).toContain(createHash("sha256").update(L1_ORACLE).digest("hex"));
53
+ expect(bundle).toContain("CM-dispatch-01");
54
+ });
55
+ });
@@ -22,6 +22,12 @@ documents, with a VERIFY-BUNDLE.md carrying only the RFC's normative prose.
22
22
  <CHANGE_SUMMARY>
23
23
  <item>RFC-1333: initial implementation — git-free export, self-test and RFC-document stripping, VERIFY-BUNDLE.md.</item>
24
24
  <item>RFC-1333: review hardening — piped export, root node_modules mirroring, failure cleanup, sha resolution, Windows links.</item>
25
+ <item>RFC-1580: digest trail, manifest review export, operating model and skills
26
+
27
+ flow.digest lists X-Correctness-Weakening trailers and verifier-trailer commits (correctnessTrail, part of digestId); rfc.verify.workspace --manifest exports the oracle-review surface with MANIFEST-REVIEW-BUNDLE.md hashes; operating model §7 product tiers and §8 'a self oracle never covers an anchor of a product correctness manifest'; fo-review oracle review mode producing forge/oracle-review@1; fo-idea-implement step 4.4c; correctness-gate reference page; forge AGENTS.md gate rules.</item>
28
+ <item>RFC-1580: close review REVIEW-CODE-2026-11-13-04 findings
29
+
30
+ F1 bootstrap degrade only on an exact unknown-command stderr line with no JSON; F2 review records count only from a verifier-trailer commit naming them; F3 any frozen substrate change or dropped capture is a weakening, declared L3 needs loaded captures; F4 requirement origin needs acceptance before --base; F5 anchor events only for L2+ runs; F6 proof oracles via proof.check only, non-self; F7 bundle naming; F8/F9 limitations; F10 every anchor copy; F11 base entry refs; F12 unreadable base manifest refuses; F13 dirty worktree warning; F14 source/statement diffs; F15 process-group kill; F16 run root cleanup; F20 review dir stripped, blob hashes. Regression tests for spoofing, plain-commit review, L3, requirement origin, rewording, timeout, formal tier, rebind, real-gate pass, accept-weakening. DEV-1..DEV-6 recorded in the RFC.</item>
25
31
  </CHANGE_SUMMARY>
26
32
  */
27
33
 
@@ -304,12 +310,173 @@ export async function buildVerifyWorkspace(opts: {
304
310
  return result;
305
311
  }
306
312
 
313
+ /** RFC-1580: narrative directories stripped from an oracle-review export. */
314
+ const MANIFEST_STRIP_DIRS = [
315
+ "docs/plans/",
316
+ "docs/reviews/",
317
+ "docs/sessions/",
318
+ "docs/handoffs/",
319
+ "docs/audits/",
320
+ "docs/queues/",
321
+ "docs/explorations/",
322
+ "docs/metrics/",
323
+ "docs/rfcs/verification/",
324
+ ".agents/memory/",
325
+ ".agents/notes/",
326
+ ];
327
+
328
+ /**
329
+ * RFC-1580: export a committed candidate for a clean-context oracle review —
330
+ * the manifest, requirement documents, anchored code, oracle and support
331
+ * files, and captures stay; narrative directories are stripped;
332
+ * MANIFEST-REVIEW-BUNDLE.md lists every manifest oracle with its sha256 (the
333
+ * value a forge/oracle-review@1 record must name).
334
+ */
335
+ export async function buildManifestReviewWorkspace(opts: {
336
+ workspaceRoot: string;
337
+ candidateSha: string;
338
+ outDir?: string;
339
+ }): Promise<RfcVerifyWorkspaceResult> {
340
+ const { workspaceRoot } = opts;
341
+ const resolved = (
342
+ await run(workspaceRoot, "git", ["rev-parse", "--verify", `${opts.candidateSha}^{commit}`])
343
+ ).stdout.trim();
344
+ const candidateSha = resolved || opts.candidateSha;
345
+ const fail = (error: string): RfcVerifyWorkspaceResult => ({
346
+ command: "rfc.verify.workspace",
347
+ status: "fail",
348
+ rfcId: "",
349
+ candidateSha,
350
+ path: null,
351
+ removed: [],
352
+ error,
353
+ });
354
+ if (!resolved) return fail(`candidate ${opts.candidateSha} is not a commit`);
355
+ const selfCreated = opts.outDir === undefined;
356
+ const out = opts.outDir ?? (await mkdtemp(join(tmpdir(), "rfc-verify-manifest-")));
357
+ let result: RfcVerifyWorkspaceResult;
358
+ try {
359
+ await mkdir(out, { recursive: true });
360
+ const exportError = await exportTree(workspaceRoot, candidateSha, out);
361
+ if (exportError) {
362
+ result = fail(`export failed: ${exportError}`);
363
+ } else {
364
+ const tracked = (
365
+ await run(workspaceRoot, "git", ["ls-tree", "-r", "--name-only", candidateSha])
366
+ ).stdout.split("\n");
367
+ const removed: string[] = [];
368
+ // Earlier review verdicts stay hidden from the reviewer.
369
+ const stripDirs = [...MANIFEST_STRIP_DIRS];
370
+ try {
371
+ const cfgText = await readFile(join(out, "forge.yaml"), "utf8");
372
+ const rd = /^\s*oracleReviewsDir:\s*["']?([^"'\s#]+)/m.exec(cfgText)?.[1];
373
+ stripDirs.push(`${(rd ?? "docs/correctness/reviews").replace(/\/$/, "")}/`);
374
+ } catch {
375
+ stripDirs.push("docs/correctness/reviews/");
376
+ }
377
+ for (const dir of stripDirs) {
378
+ if (tracked.some((f) => f.startsWith(dir)) && existsSync(join(out, dir))) {
379
+ await rm(join(out, dir), { recursive: true, force: true });
380
+ removed.push(dir.replace(/\/$/, ""));
381
+ }
382
+ }
383
+ await mirrorNodeModules(workspaceRoot, out, ".");
384
+ for (const pj of tracked.filter(
385
+ (f) => f.endsWith("/package.json") && !f.includes("node_modules/"),
386
+ )) {
387
+ await mirrorNodeModules(workspaceRoot, out, dirname(pj));
388
+ }
389
+ const { parse } = await import("yaml");
390
+ const { createHash } = await import("node:crypto");
391
+ let manifestRel: string | null = null;
392
+ try {
393
+ const cfg = parse(await readFile(join(out, "forge.yaml"), "utf8")) as {
394
+ bindings?: { paths?: { correctnessManifest?: unknown } };
395
+ };
396
+ const p = cfg?.bindings?.paths?.correctnessManifest;
397
+ manifestRel = typeof p === "string" ? p : null;
398
+ } catch {
399
+ manifestRel = null;
400
+ }
401
+ const lines = [
402
+ "# Oracle review bundle (forge/oracle-review@1)",
403
+ "",
404
+ `Candidate: ${candidateSha}`,
405
+ `Manifest: ${manifestRel ?? "(none bound)"}`,
406
+ "",
407
+ "For every oracle: does it exercise its entry's requirement, assert against the attested handle (not a second, mocked one), and make its substrate claim plausibly? Record verdicts in a forge/oracle-review@1 file naming each check with the sha256 below.",
408
+ "",
409
+ "Removed from this tree (narrative, intentionally hidden):",
410
+ ...removed.map((r) => `- ${r}`),
411
+ "",
412
+ "| Entry | Check | Substrate | sha256 |",
413
+ "| --- | --- | --- | --- |",
414
+ ];
415
+ if (manifestRel) {
416
+ try {
417
+ const manifest = parse(await readFile(join(out, manifestRel), "utf8")) as {
418
+ entries?: { id?: string; oracles?: { check?: string; substrate?: string }[] }[];
419
+ };
420
+ for (const entry of manifest?.entries ?? []) {
421
+ for (const o of entry.oracles ?? []) {
422
+ const target = String(o.check ?? "")
423
+ .replace(/^[a-z]+:/, "")
424
+ .replace(/^\.\//, "");
425
+ // Hash the committed blob (git show) — the bytes the gate hashes —
426
+ // not the archive export, which eol/export-subst attributes may alter.
427
+ const blob = await run(workspaceRoot, "git", ["show", `${candidateSha}:${target}`]);
428
+ const digest = blob.ok
429
+ ? createHash("sha256").update(blob.stdout).digest("hex")
430
+ : "(missing)";
431
+ lines.push(
432
+ `| ${entry.id ?? "?"} | ${o.check ?? "?"} | ${o.substrate ?? "?"} | ${digest} |`,
433
+ );
434
+ }
435
+ }
436
+ } catch {
437
+ lines.push("| (manifest unreadable) | | | |");
438
+ }
439
+ }
440
+ await writeFile(join(out, "MANIFEST-REVIEW-BUNDLE.md"), `${lines.join("\n")}\n`);
441
+ result = {
442
+ command: "rfc.verify.workspace",
443
+ status: "pass",
444
+ rfcId: "",
445
+ candidateSha,
446
+ path: out,
447
+ removed,
448
+ };
449
+ }
450
+ } catch (e) {
451
+ result = fail(e instanceof Error ? e.message : String(e));
452
+ }
453
+ if (result.status === "fail" && selfCreated) await rm(out, { recursive: true, force: true });
454
+ return result;
455
+ }
456
+
307
457
  export async function runRfcVerifyWorkspace(
308
458
  input: ForgeCommandInput,
309
459
  context: ForgeRuntimeContext,
310
460
  ): Promise<ForgeCommandResult<RfcVerifyWorkspaceResult>> {
311
461
  const rfcId = String(input.flags["id"] ?? "").toUpperCase();
312
462
  const candidateSha = String(input.flags["candidate"] ?? "");
463
+ if (input.flags["manifest"] === true) {
464
+ if (!candidateSha) {
465
+ return { exitCode: 1, summary: "rfc.verify.workspace --manifest: --candidate is required" };
466
+ }
467
+ const data = await buildManifestReviewWorkspace({
468
+ workspaceRoot: context.workspaceRoot,
469
+ candidateSha,
470
+ });
471
+ return {
472
+ data,
473
+ exitCode: data.status === "pass" ? 0 : 1,
474
+ summary:
475
+ data.status === "pass"
476
+ ? `rfc.verify.workspace --manifest: ${candidateSha.slice(0, 9)} → ${data.path} (${data.removed.length} narrative dir(s) hidden; see MANIFEST-REVIEW-BUNDLE.md)`
477
+ : `rfc.verify.workspace --manifest: ${data.error}`,
478
+ };
479
+ }
313
480
  if (!rfcId || !candidateSha) {
314
481
  const data: RfcVerifyWorkspaceResult = {
315
482
  command: "rfc.verify.workspace",
@@ -13,6 +13,9 @@ canonical YAML fixture strings keep tests focused on the variable under test.</p
13
13
  <item>RFC-1508: implement RFC-1508 — system profile, system map schemas and system.map.validate</item>
14
14
  <item>RFC-1508: align rfc-1508 schemas with the normative contract after review r1</item>
15
15
  <item>RFC-1509: implement RFC-1509 — system task queue, dispatch briefs and task reports</item>
16
+ <item>RFC-1580: correctness.gate and the flow.integrate step
17
+
18
+ Add os/correctness/gate (frozen set at --base, weakening diff incl. byte changes without verifier trailers and frozen exempt mode, git-derived oracle origin with forge/oracle-review@1 records, argv oracle runner with timeout, schema-hash substrate attestation, anchor events, tier high/formal, forge/correctness-bundle@1), the correctness.gate command, test-side helpers @warpgogol/forge/correctness, bindings.paths.oracleReviewsDir, and flow.integrate spawning the primary install's gate after hooks/integration-gate.sh (FLOW-INT-18, --accept-weakening with an X-Correctness-Weakening trailer commit). Flow and system test primaries get a stand-in forge binary; integration warnings now survive the cleanup report.</item>
16
19
  </CHANGE_SUMMARY>
17
20
  */
18
21
 
@@ -111,10 +114,12 @@ launcher:
111
114
  * Returns the absolute product root.
112
115
  */
113
116
  export async function makeProduct(prefix = "forge-product-"): Promise<string> {
114
- const { gitExec } = await import("../../flow/tests/helpers.ts");
117
+ const { gitExec, installFakePrimaryForge } = await import("../../flow/tests/helpers.ts");
115
118
  const root = await mkdtemp(path.join(os.tmpdir(), prefix));
116
119
  const init = await gitExec(root, ["init", "-b", "main"]);
117
120
  if (init.exitCode !== 0) throw new Error(`git init failed: ${init.stderr}`);
121
+ // RFC-1580: flow.integrate spawns the primary install's correctness.gate.
122
+ await installFakePrimaryForge(root);
118
123
  await gitExec(root, ["config", "user.email", "system-test@example.invalid"]);
119
124
  await gitExec(root, ["config", "user.name", "system-test"]);
120
125
  await gitExec(root, ["config", "commit.gpgsign", "false"]);