@warpgogol/forge 9.5.0 → 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 (338) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +30 -0
  3. package/README.uk.md +30 -0
  4. package/bin/cli.ts +19 -50
  5. package/dist/bin/cli.js +18 -43
  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/flow.module.d.ts.map +1 -1
  156. package/dist/os/flow/flow.module.js +17 -3
  157. package/dist/os/flow/flow.module.js.map +1 -1
  158. package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -1
  159. package/dist/os/flow/handlers/flow-digest.js +11 -1
  160. package/dist/os/flow/handlers/flow-digest.js.map +1 -1
  161. package/dist/os/flow/handlers/flow-integrate.d.ts +11 -0
  162. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -1
  163. package/dist/os/flow/handlers/flow-integrate.js +90 -5
  164. package/dist/os/flow/handlers/flow-integrate.js.map +1 -1
  165. package/dist/os/flow/post-rebase-regen.d.ts +33 -0
  166. package/dist/os/flow/post-rebase-regen.d.ts.map +1 -0
  167. package/dist/os/flow/post-rebase-regen.js +120 -0
  168. package/dist/os/flow/post-rebase-regen.js.map +1 -0
  169. package/dist/os/flow/preflight.d.ts.map +1 -1
  170. package/dist/os/flow/preflight.js +11 -15
  171. package/dist/os/flow/preflight.js.map +1 -1
  172. package/dist/os/flow/publish.d.ts.map +1 -1
  173. package/dist/os/flow/publish.js +23 -4
  174. package/dist/os/flow/publish.js.map +1 -1
  175. package/dist/os/flow/registry.d.ts +4 -4
  176. package/dist/os/flow/tests/helpers.d.ts +9 -1
  177. package/dist/os/flow/tests/helpers.d.ts.map +1 -1
  178. package/dist/os/flow/tests/helpers.js +36 -2
  179. package/dist/os/flow/tests/helpers.js.map +1 -1
  180. package/dist/os/friction/types.d.ts +2 -2
  181. package/dist/os/gate-run/status.d.ts +12 -0
  182. package/dist/os/gate-run/status.d.ts.map +1 -1
  183. package/dist/os/gate-run/status.js +24 -3
  184. package/dist/os/gate-run/status.js.map +1 -1
  185. package/dist/os/program/schemas.d.ts +3 -3
  186. package/dist/os/queue/types.d.ts +2 -2
  187. package/dist/os/rfc/handlers/implement-stamp-promotes.d.ts +8 -0
  188. package/dist/os/rfc/handlers/implement-stamp-promotes.d.ts.map +1 -0
  189. package/dist/os/rfc/handlers/implement-stamp-promotes.js +65 -0
  190. package/dist/os/rfc/handlers/implement-stamp-promotes.js.map +1 -0
  191. package/dist/os/rfc/handlers/implement-stamp.d.ts.map +1 -1
  192. package/dist/os/rfc/handlers/implement-stamp.js +15 -2
  193. package/dist/os/rfc/handlers/implement-stamp.js.map +1 -1
  194. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  195. package/dist/os/rfc/handlers/validate-rules.js +26 -5
  196. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  197. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  198. package/dist/os/rfc/rfc.module.js +18 -6
  199. package/dist/os/rfc/rfc.module.js.map +1 -1
  200. package/dist/os/rfc/types.d.ts +12 -3
  201. package/dist/os/rfc/types.d.ts.map +1 -1
  202. package/dist/os/rfc/types.js +5 -2
  203. package/dist/os/rfc/types.js.map +1 -1
  204. package/dist/os/rfc/verify-workspace.d.ts +12 -0
  205. package/dist/os/rfc/verify-workspace.d.ts.map +1 -1
  206. package/dist/os/rfc/verify-workspace.js +155 -0
  207. package/dist/os/rfc/verify-workspace.js.map +1 -1
  208. package/dist/os/system/task-schemas.d.ts +1 -1
  209. package/dist/os/system/tests/helpers.d.ts.map +1 -1
  210. package/dist/os/system/tests/helpers.js +6 -1
  211. package/dist/os/system/tests/helpers.js.map +1 -1
  212. package/dist/os/werkstatt/handlers/schema.d.ts +1 -1
  213. package/dist/src/command-modules.d.ts +4 -0
  214. package/dist/src/command-modules.d.ts.map +1 -0
  215. package/dist/src/command-modules.js +42 -0
  216. package/dist/src/command-modules.js.map +1 -0
  217. package/dist/src/config/forge-config.d.ts +16 -1
  218. package/dist/src/config/forge-config.d.ts.map +1 -1
  219. package/dist/src/config/forge-config.js +27 -11
  220. package/dist/src/config/forge-config.js.map +1 -1
  221. package/dist/src/correctness/index.d.ts +32 -0
  222. package/dist/src/correctness/index.d.ts.map +1 -0
  223. package/dist/src/correctness/index.js +157 -0
  224. package/dist/src/correctness/index.js.map +1 -0
  225. package/dist/src/correctness/schema-hash.d.ts +15 -0
  226. package/dist/src/correctness/schema-hash.d.ts.map +1 -0
  227. package/dist/src/correctness/schema-hash.js +44 -0
  228. package/dist/src/correctness/schema-hash.js.map +1 -0
  229. package/dist/src/knowledge/schema.d.ts +1 -1
  230. package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
  231. package/dist/src/onboarding/agents-generate.js +20 -3
  232. package/dist/src/onboarding/agents-generate.js.map +1 -1
  233. package/dist/src/onboarding/create.d.ts +7 -0
  234. package/dist/src/onboarding/create.d.ts.map +1 -1
  235. package/dist/src/onboarding/create.js +62 -9
  236. package/dist/src/onboarding/create.js.map +1 -1
  237. package/docs/reference/correctness-audit.md +91 -0
  238. package/docs/reference/correctness-gate.md +102 -0
  239. package/docs/reference/correctness-manifest.md +142 -0
  240. package/docs/reference/forge-yaml.md +15 -0
  241. package/os/codebase/codebase.module.ts +57 -0
  242. package/os/codebase/handlers/codebase-measure-symbols.ts +131 -0
  243. package/os/codebase/handlers/codebase-measure.ts +503 -0
  244. package/os/codebase/index.ts +21 -0
  245. package/os/codebase/types.ts +55 -0
  246. package/os/core/handlers/package-health.test.ts +24 -2
  247. package/os/core/handlers/package-health.ts +16 -19
  248. package/os/correctness/anchors.ts +182 -0
  249. package/os/correctness/audit/bindings-verify-substance.test.ts +79 -0
  250. package/os/correctness/audit/bindings-verify-substance.ts +155 -0
  251. package/os/correctness/audit/differential.test.ts +113 -0
  252. package/os/correctness/audit/differential.ts +131 -0
  253. package/os/correctness/audit/ledger-orphans.test.ts +96 -0
  254. package/os/correctness/audit/ledger-orphans.ts +84 -0
  255. package/os/correctness/audit/ledger.test.ts +65 -0
  256. package/os/correctness/audit/ledger.ts +103 -0
  257. package/os/correctness/audit/run.ts +220 -0
  258. package/os/correctness/audit/schema-db.ts +208 -0
  259. package/os/correctness/audit/snapshot.ts +211 -0
  260. package/os/correctness/audit/sql-scanner.test.ts +84 -0
  261. package/os/correctness/audit/sql-scanner.ts +289 -0
  262. package/os/correctness/audit/sql-schema-conform.test.ts +170 -0
  263. package/os/correctness/audit/sql-schema-conform.ts +178 -0
  264. package/os/correctness/audit/state-transitions-coverage.test.ts +141 -0
  265. package/os/correctness/audit/state-transitions-coverage.ts +271 -0
  266. package/os/correctness/audit/tests/git-fixture.ts +98 -0
  267. package/os/correctness/audit/types.ts +91 -0
  268. package/os/correctness/correctness-capture.test.ts +107 -0
  269. package/os/correctness/correctness-chain.test.ts +232 -0
  270. package/os/correctness/correctness-coverage.test.ts +86 -0
  271. package/os/correctness/correctness-mode.test.ts +108 -0
  272. package/os/correctness/correctness-substrate.test.ts +64 -0
  273. package/os/correctness/correctness.module.ts +182 -0
  274. package/os/correctness/gate/anchor-events.test.ts +77 -0
  275. package/os/correctness/gate/freeze-coverage.test.ts +218 -0
  276. package/os/correctness/gate/freeze-diff.test.ts +110 -0
  277. package/os/correctness/gate/frozen.ts +399 -0
  278. package/os/correctness/gate/gate-mode.test.ts +76 -0
  279. package/os/correctness/gate/hardening.test.ts +175 -0
  280. package/os/correctness/gate/oracle-edit.test.ts +83 -0
  281. package/os/correctness/gate/oracle-origin.test.ts +142 -0
  282. package/os/correctness/gate/origin.ts +175 -0
  283. package/os/correctness/gate/repo.ts +102 -0
  284. package/os/correctness/gate/run.ts +547 -0
  285. package/os/correctness/gate/runner.ts +136 -0
  286. package/os/correctness/gate/substrate-attestation.test.ts +71 -0
  287. package/os/correctness/gate/tests/gate-fixture.ts +205 -0
  288. package/os/correctness/gate/tier-high.test.ts +92 -0
  289. package/os/correctness/gate/types.ts +144 -0
  290. package/os/correctness/handlers/audit.ts +107 -0
  291. package/os/correctness/handlers/gate.ts +75 -0
  292. package/os/correctness/handlers/validate.ts +514 -0
  293. package/os/correctness/index.ts +24 -0
  294. package/os/correctness/manifest-schema.ts +174 -0
  295. package/os/correctness/references.ts +143 -0
  296. package/os/correctness/tests/fixture-workspace.ts +119 -0
  297. package/os/correctness/workspace.ts +167 -0
  298. package/os/flow/correctness-step.ts +166 -0
  299. package/os/flow/digest.ts +40 -1
  300. package/os/flow/flow.module.ts +18 -3
  301. package/os/flow/handlers/flow-digest.ts +11 -1
  302. package/os/flow/handlers/flow-integrate.ts +117 -5
  303. package/os/flow/post-rebase-regen.ts +170 -0
  304. package/os/flow/preflight.ts +11 -19
  305. package/os/flow/publish.ts +23 -4
  306. package/os/flow/tests/flow-detachable.test.ts +31 -0
  307. package/os/flow/tests/flow-digest-correctness-trail.test.ts +55 -0
  308. package/os/flow/tests/flow-integrate-correctness-gate.test.ts +275 -0
  309. package/os/flow/tests/flow-integrate.post-rebase-regen.test.ts +234 -0
  310. package/os/flow/tests/flow-integrate.test.ts +10 -9
  311. package/os/flow/tests/helpers.ts +45 -24
  312. package/os/gate-run/status.ts +36 -3
  313. package/os/gate-run/tests/gate-run-status.test.ts +114 -0
  314. package/os/rfc/handlers/implement-stamp-promotes.test.ts +214 -0
  315. package/os/rfc/handlers/implement-stamp-promotes.ts +79 -0
  316. package/os/rfc/handlers/implement-stamp.ts +16 -2
  317. package/os/rfc/handlers/validate-rules.ts +43 -5
  318. package/os/rfc/rfc.module.ts +19 -6
  319. package/os/rfc/types.ts +16 -2
  320. package/os/rfc/verify-workspace-manifest.test.ts +55 -0
  321. package/os/rfc/verify-workspace.ts +167 -0
  322. package/os/system/tests/helpers.ts +6 -1
  323. package/package.json +41 -1
  324. package/profiles/typescript.yaml +16 -0
  325. package/skills/_shared/agent-operating-model.md +4 -0
  326. package/skills/fo/fo-idea-audit/SKILL.md +4 -0
  327. package/skills/fo/fo-idea-create-rfc/SKILL.md +6 -2
  328. package/skills/fo/fo-idea-implement/SKILL.md +8 -2
  329. package/skills/fo/fo-review/SKILL.md +16 -2
  330. package/src/command-modules.ts +62 -0
  331. package/src/config/forge-config.ts +37 -11
  332. package/src/correctness/index.ts +192 -0
  333. package/src/correctness/schema-hash.ts +59 -0
  334. package/src/onboarding/agents-generate.ts +20 -3
  335. package/src/onboarding/create.ts +59 -9
  336. package/src/tests/agents-generate-detach.test.ts +126 -0
  337. package/src/tests/codebase-measure-rfc-1581.test.ts +260 -0
  338. package/src/tests/command-modules.test.ts +34 -0
@@ -0,0 +1,166 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>RFC-1580: the flow.integrate correctness step — spawn the PRIMARY
4
+ checkout's forge install (`<primary>/node_modules/.bin/forge correctness.gate
5
+ --base <sha> --json`) with cwd = the session worktree, after
6
+ hooks/integration-gate.sh passed and before the fast-forward, and translate
7
+ the result into a FLOW-INT-18 refusal or warning.</purpose>
8
+ <non-goals>
9
+ <item>Never runs the gate in-process — the code under review must not judge its own gate (RFC-1538 deviation, deliberate).</item>
10
+ <item>Never decides a weakening — `--accept-weakening` is an operator flag passed through verbatim.</item>
11
+ </non-goals>
12
+ </MODULE_CONTRACT>
13
+ <KEY_DECISIONS>
14
+ <item>A missing primary binary, a spawn failure, unparseable output, or a failing gate refuse; only a primary install that answers "Unknown command: correctness.gate" (it predates RFC-1580) degrades to a FLOW-INT-18 warning — refusing would deadlock the very forge upgrade that installs the gate.</item>
15
+ </KEY_DECISIONS>
16
+ <CHANGE_SUMMARY>
17
+ <item>RFC-1580: initial correctness step.</item>
18
+ <item>RFC-1580: correctness.gate and the flow.integrate step
19
+
20
+ 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>
21
+ <item>RFC-1580: close review REVIEW-CODE-2026-11-13-04 findings
22
+
23
+ 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>
24
+ <item>RFC-1580: close review REVIEW-CODE-2026-11-13-05 findings
25
+
26
+ N1 bootstrap degrade only while the base has not adopted the contour (a forge downgrade refuses); N2 L3 on data/lifecycle counts at its attested level; N3 anchor events bound to the attested handle; N4 new support-glob files are frozen additions; N5/N6 isolated sessions may touch anchor files and only frozen forge.yaml keys; N7 RFC body amended; N8 regression tests; N9 run root in finally and grandchildren reaped; N10 every declared capture loaded. DEV-7 recorded; DEV-5 narrowed pending operator confirmation.</item>
27
+ </CHANGE_SUMMARY>
28
+ */
29
+
30
+ import { join } from "node:path";
31
+
32
+ import type { Diagnostic, WorkspaceIO } from "../../src/types.ts";
33
+
34
+ export interface CorrectnessStepResult {
35
+ status: "pass" | "fail" | "exempt" | "not-run";
36
+ bundlePath: string | null;
37
+ acceptedWeakening: string | null;
38
+ refusal?: { message: string; fixHint: string };
39
+ warning?: Diagnostic;
40
+ }
41
+
42
+ interface GateJson {
43
+ status?: string;
44
+ bundlePath?: string;
45
+ acceptedWeakening?: string | null;
46
+ violations?: { rule: string; severity: string; message: string }[];
47
+ }
48
+
49
+ function parseJson(stdout: string): GateJson | null {
50
+ const start = stdout.indexOf("{");
51
+ if (start === -1) return null;
52
+ try {
53
+ const parsed = JSON.parse(stdout.slice(start)) as GateJson & { data?: GateJson };
54
+ return parsed.data && typeof parsed.data === "object" ? parsed.data : parsed;
55
+ } catch {
56
+ return null;
57
+ }
58
+ }
59
+
60
+ /**
61
+ * True when forge.yaml at the integration base binds a correctness manifest or
62
+ * declares a correctness section — the repository has adopted the gate, so a
63
+ * primary forge that lacks it is a downgrade, not a bootstrap.
64
+ */
65
+ async function baseAdoptedGate(io: WorkspaceIO, worktree: string, base: string): Promise<boolean> {
66
+ const shown = await io.exec("git", ["show", `${base}:forge.yaml`], { cwd: worktree });
67
+ if (shown.exitCode !== 0) return false;
68
+ const text = shown.stdout;
69
+ const bound = /^\s*correctnessManifest:\s*(?!null\b|~|$)\S+/m.test(text);
70
+ const section = /^correctness:\s*$/m.test(text);
71
+ return bound || section;
72
+ }
73
+
74
+ export async function runCorrectnessStep(
75
+ io: WorkspaceIO,
76
+ opts: { primary: string; worktree: string; base: string; acceptWeakening?: string },
77
+ ): Promise<CorrectnessStepResult> {
78
+ const bin = join(opts.primary, "node_modules", ".bin", "forge");
79
+ const notRun = (message: string, fixHint: string): CorrectnessStepResult => ({
80
+ status: "not-run",
81
+ bundlePath: null,
82
+ acceptedWeakening: null,
83
+ refusal: { message, fixHint },
84
+ });
85
+ if (!(await io.exists(bin))) {
86
+ return notRun(
87
+ `the primary install's forge binary is missing (${bin}) — the correctness gate cannot run`,
88
+ `run pnpm install in ${opts.primary}; the gate always runs from the primary checkout`,
89
+ );
90
+ }
91
+ const args = ["correctness.gate", "--base", opts.base, "--json"];
92
+ if (opts.acceptWeakening) args.push("--accept-weakening", opts.acceptWeakening);
93
+ let result: { exitCode: number | null; stdout: string; stderr: string };
94
+ try {
95
+ result = await io.exec(bin, args, { cwd: opts.worktree });
96
+ } catch (err) {
97
+ return notRun(
98
+ `could not start ${bin}: ${(err as Error).message}`,
99
+ "repair the primary install, then re-run",
100
+ );
101
+ }
102
+ const text = `${result.stdout}\n${result.stderr}`;
103
+ const data = parseJson(result.stdout);
104
+ // Bootstrap degrade only when the gate never ran: no JSON at all, a failing
105
+ // exit, and a whole stderr line that is exactly the CLI's unknown-command
106
+ // notice. Gate output echoes session-controlled text (exemption refs, check
107
+ // names), so the phrase anywhere else must never switch the gate off.
108
+ const unknownCommand =
109
+ data === null &&
110
+ result.exitCode !== 0 &&
111
+ !result.stdout.includes("{") &&
112
+ result.stderr
113
+ .split("\n")
114
+ .some((line) => /^\s*(?:✖\s*)?Unknown command: correctness\.gate\s*$/.test(line));
115
+ if (unknownCommand && (await baseAdoptedGate(io, opts.worktree, opts.base))) {
116
+ return notRun(
117
+ "the primary install's forge does not know correctness.gate, but the base revision already adopted the correctness contour — a forge downgrade must not drop the gate",
118
+ `restore an @warpgogol/forge with correctness.gate in ${opts.primary} (pnpm install), then re-run`,
119
+ );
120
+ }
121
+ if (unknownCommand) {
122
+ return {
123
+ status: "not-run",
124
+ bundlePath: null,
125
+ acceptedWeakening: null,
126
+ warning: {
127
+ ruleId: "FLOW-INT-18",
128
+ severity: "warning",
129
+ message: `the primary install's forge predates correctness.gate (RFC-1580) — the correctness gate did not run for this integration`,
130
+ fixHint: `upgrade @warpgogol/forge in ${opts.primary} (pnpm install after this integration lands) so later integrations are gated`,
131
+ },
132
+ };
133
+ }
134
+ if (data === null) {
135
+ return notRun(
136
+ `correctness.gate printed no JSON result (exit ${result.exitCode}): ${text.trim().split("\n").slice(-3).join(" | ")}`,
137
+ "re-run the gate by hand from the session worktree to see its output",
138
+ );
139
+ }
140
+ const bundlePath = data.bundlePath ?? null;
141
+ if (result.exitCode !== 0 || data.status === "fail") {
142
+ const errors = (data.violations ?? []).filter((v) => v.severity === "error");
143
+ const detail = errors
144
+ .slice(0, 8)
145
+ .map((v) => `${v.rule} ${v.message}`)
146
+ .join("; ");
147
+ const mixed = errors.some((v) => /mixed-weakening/.test(v.message));
148
+ return {
149
+ status: "fail",
150
+ bundlePath,
151
+ acceptedWeakening: null,
152
+ refusal: {
153
+ message: `correctness.gate refused the integration${mixed ? " (mixed-weakening)" : ""}: ${detail}${errors.length > 8 ? ` …and ${errors.length - 8} more` : ""}${bundlePath ? ` — bundle ${bundlePath}` : ""}`,
154
+ fixHint:
155
+ 'fix the named entries/oracles; a weakening lands only in an isolated session via flow.integrate --accept-weakening "<reason>" (operator decision)',
156
+ },
157
+ };
158
+ }
159
+ return {
160
+ status: data.status === "exempt" ? "exempt" : "pass",
161
+ bundlePath,
162
+ acceptedWeakening: data.acceptedWeakening ?? null,
163
+ };
164
+ }
165
+
166
+ export const CORRECTNESS_WEAKENING_TRAILER = "X-Correctness-Weakening";
package/os/flow/digest.ts CHANGED
@@ -18,7 +18,6 @@ flow.push must quote.</purpose>
18
18
  <item>tagTriggers (RFC-1498) is part of digestId input: a workflow-file change between digest and push must invalidate the quoted id. Unparseable workflows and ununderstood patterns warn FLOW-11 and match nothing — never block the digest.</item>
19
19
  </KEY_DECISIONS>
20
20
  <CHANGE_SUMMARY>
21
- <item>RFC-1491: independent-review pass — shared lock constants, publishable pending filter, declared rules, hold ordering, sha-pinned refspecs</item>
22
21
  <item>RFC-1491: digest segments develop by first-parent chain; hold of the topmost item skips the empty replay
23
22
 
24
23
  Steering-session verification of wave 2 found two outbound defects:
@@ -29,6 +28,9 @@ Steering-session verification of wave 2 found two outbound defects:
29
28
  flow.digest now reads .github/workflows on the primary checkout and reports tagTriggers: for every digest tag the workflows whose on.push.tags filter matches its name. Matching evaluates the GitHub glob subset — star inside a segment, double-star across, question for one char; character classes and leading negations report FLOW-11 as pattern not understood and match nothing. A workflow that cannot be parsed reports FLOW-11 and contributes nothing, never blocking the digest. tagTriggers feeds digestId so a workflow change invalidates a quoted id, the pretty output prints one line per triggered tag, and flow.module declares FLOW-11 warning plus the workflows read glob. Tests AC-7 (a v1.0.1 tag maps to the v-star workflow only) and AC-8 (broken YAML and a bracket pattern warn while the digest still returns). Compass metadata updated.</item>
30
29
  <item>RFC-1503: steps 1-5 — highest-per-line pending selection, publish-superseded/publish-retired journal events, flow.publication.retire</item>
31
30
  <item>RFC-1503: review r1 — FLOW-07 on retire journal failure, journal re-read before publish, publication-order unit tests, stale catalog/inventory regen</item>
31
+ <item>RFC-1580: digest trail, manifest review export, operating model and skills
32
+
33
+ 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>
32
34
  <history>RFC-1491</history>
33
35
  </CHANGE_SUMMARY>
34
36
  */
@@ -104,6 +106,16 @@ export interface FlowDigestData {
104
106
  * get an entry.
105
107
  */
106
108
  tagTriggers: Array<{ tag: string; workflows: string[] }>;
109
+ /**
110
+ * RFC-1580: the correctness trail of the unpushed develop range — every
111
+ * `X-Correctness-Weakening` trailer (an accepted weakening) and every
112
+ * verifier-trailer commit (`X-Expectation-Origin: independent-verifier`),
113
+ * so the operator sees both at the flow.push hard stop.
114
+ */
115
+ correctnessTrail: {
116
+ weakenings: Array<{ sha: string; subject: string; reason: string }>;
117
+ verifierCommits: Array<{ sha: string; subject: string; report: string | null }>;
118
+ };
107
119
  diagnostics: Diagnostic[];
108
120
  }
109
121
 
@@ -168,6 +180,29 @@ async function readPathConfig(
168
180
  }
169
181
  }
170
182
 
183
+ /** RFC-1580: weakening and verifier trailers among the given commits (oldest first). */
184
+ async function correctnessTrailOf(
185
+ repoRoot: string,
186
+ io: WorkspaceIO,
187
+ shas: string[],
188
+ ): Promise<FlowDigestData["correctnessTrail"]> {
189
+ const trail: FlowDigestData["correctnessTrail"] = { weakenings: [], verifierCommits: [] };
190
+ if (shas.length === 0) return trail;
191
+ const result = await git(repoRoot, io, ["show", "-s", "--format=%H%x1f%s%x1f%B%x1e", ...shas]);
192
+ if (result.exitCode !== 0) return trail;
193
+ for (const chunk of result.stdout.split("\x1e")) {
194
+ const [sha, subject, body] = chunk.replace(/^\s+/, "").split("\x1f");
195
+ if (!sha || body === undefined) continue;
196
+ const weak = /^X-Correctness-Weakening:\s*(.+)$/m.exec(body);
197
+ if (weak) trail.weakenings.push({ sha: sha.trim(), subject: subject ?? "", reason: weak[1]!.trim() });
198
+ if (/^X-Expectation-Origin:\s*independent-verifier\s*$/m.test(body)) {
199
+ const report = /^X-Verifier-Report:\s*(\S+)\s*$/m.exec(body)?.[1] ?? null;
200
+ trail.verifierCommits.push({ sha: sha.trim(), subject: subject ?? "", report });
201
+ }
202
+ }
203
+ return trail;
204
+ }
205
+
171
206
  /** X-RFC trailer ids + subjects of the commits in (base, tip], oldest first. */
172
207
  async function commitMeta(
173
208
  repoRoot: string,
@@ -766,6 +801,8 @@ export async function collectDigest(
766
801
  if (workflows.length > 0) tagTriggers.push({ tag, workflows });
767
802
  }
768
803
 
804
+ const correctnessTrail = await correctnessTrailOf(repoRoot, io, developTail);
805
+
769
806
  const byCategory = Object.fromEntries(RISK_CATEGORIES.map((c) => [c, [] as string[]])) as Record<
770
807
  RiskCategory,
771
808
  string[]
@@ -779,6 +816,7 @@ export async function collectDigest(
779
816
  main: { local: mainLocal, remote: mainRemote, ahead: mainTail.length },
780
817
  tags,
781
818
  tagTriggers,
819
+ correctnessTrail,
782
820
  pendingPublications,
783
821
  supersededPublications,
784
822
  items: items.map((i) => ({ id: i.id, tip: i.tip })),
@@ -800,6 +838,7 @@ export async function collectDigest(
800
838
  pendingPublications,
801
839
  supersededPublications,
802
840
  tagTriggers,
841
+ correctnessTrail,
803
842
  diagnostics,
804
843
  };
805
844
  }
@@ -9,12 +9,16 @@ the idempotent two-phase repository adoption (FLOW-ADOPT-01..06, -08).</purpose>
9
9
  </non-goals>
10
10
  </MODULE_CONTRACT>
11
11
  <CHANGE_SUMMARY>
12
- <item>RFC-1537: classify regenerable worktree dirt and journal integrate refusals cheapest-first</item>
13
- <item>RFC-1538: revalidate integration preconditions post-lock and reuse the session engine</item>
14
12
  <item>RFC-1531: add flow.integrate remediation flags on the shared dirty classifier</item>
15
13
  <item>RFC-1543: attribute shared-checkout dirt to live ops and expose peers (RFC-1543)</item>
16
14
  <item>RFC-1568: durable gate-run records, --detach mechanics, and forge CLI wiring</item>
17
- <history>RFC-1486, RFC-1487, RFC-1488, RFC-1490, RFC-1491, RFC-1498, RFC-1502, RFC-1503, RFC-1517, RFC-1528, RFC-1533</history>
15
+ <item>RFC-1573: step 2 — declare flow.cut, flow.backmerge, mission.close detachable
16
+
17
+ Each runs a long gate (integrateFlowBranch / runMissionValidate); leitstand.ship stays attached (Q-1).</item>
18
+ <item>RFC-1580: correctness.gate and the flow.integrate step
19
+
20
+ 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>
21
+ <history>RFC-1486, RFC-1487, RFC-1488, RFC-1490, RFC-1491, RFC-1498, RFC-1502, RFC-1503, RFC-1517, RFC-1528, RFC-1533, RFC-1537, RFC-1538</history>
18
22
  </CHANGE_SUMMARY>
19
23
  */
20
24
 
@@ -287,6 +291,7 @@ export async function createForgeFlowModule(): Promise<ForgeModule> {
287
291
  { id: "FLOW-INT-15", severity: "error" },
288
292
  { id: "FLOW-INT-16", severity: "warning" },
289
293
  { id: "FLOW-INT-17", severity: "error" },
294
+ { id: "FLOW-INT-18", severity: "error" },
290
295
  { id: "FLOW-07", severity: "error" },
291
296
  { id: "WT-GATE-01", severity: "error" },
292
297
  ],
@@ -319,6 +324,12 @@ export async function createForgeFlowModule(): Promise<ForgeModule> {
319
324
  description:
320
325
  "RFC-1531: delete dirty paths in the closed disposable class (coverage/, tmp*/, *.log, *.stale), then re-evaluate.",
321
326
  },
327
+ "accept-weakening": {
328
+ kind: "string",
329
+ required: false,
330
+ description:
331
+ "RFC-1580: operator decision — accept the correctness weakening of an isolated session (frozen-set paths only); recorded as an X-Correctness-Weakening trailer and listed by flow.digest.",
332
+ },
322
333
  autocommit: {
323
334
  kind: "boolean",
324
335
  required: false,
@@ -341,6 +352,8 @@ export async function createForgeFlowModule(): Promise<ForgeModule> {
341
352
  },
342
353
  {
343
354
  name: "flow.cut",
355
+ // RFC-1573: runs the integration gate (integrateFlowBranch) under the lock.
356
+ detachable: true,
344
357
  description:
345
358
  "Cut a release on the fixed branch model (RFC-1490): plan refusals " +
346
359
  "FLOW-CUT-01..07, then under the integration lock — release branch " +
@@ -424,6 +437,8 @@ export async function createForgeFlowModule(): Promise<ForgeModule> {
424
437
  },
425
438
  {
426
439
  name: "flow.backmerge",
440
+ // RFC-1573: the clean path delegates to integrateFlowBranch under the lock.
441
+ detachable: true,
427
442
  description:
428
443
  "Port main into develop through a gated port branch (RFC-1490): " +
429
444
  "release tags on develop..main (oldest first) name the merge " +
@@ -8,13 +8,16 @@ flow.push must quote; --no-fetch skips the git fetch for offline review.</purpos
8
8
  </non-goals>
9
9
  </MODULE_CONTRACT>
10
10
  <CHANGE_SUMMARY>
11
- <item>RFC-1491: step 3 — flow.digest handler</item>
12
11
  <item>RFC-1491: step 3 — flow.digest risk digest with journal-attributed items, categories, digestId</item>
13
12
  <item>RFC-1491: independent-review pass — shared lock constants, publishable pending filter, declared rules, hold ordering, sha-pinned refspecs</item>
14
13
  <item>RFC-1498: step 4 — CI tag triggers and FLOW-11 in flow.digest
15
14
 
16
15
  flow.digest now reads .github/workflows on the primary checkout and reports tagTriggers: for every digest tag the workflows whose on.push.tags filter matches its name. Matching evaluates the GitHub glob subset — star inside a segment, double-star across, question for one char; character classes and leading negations report FLOW-11 as pattern not understood and match nothing. A workflow that cannot be parsed reports FLOW-11 and contributes nothing, never blocking the digest. tagTriggers feeds digestId so a workflow change invalidates a quoted id, the pretty output prints one line per triggered tag, and flow.module declares FLOW-11 warning plus the workflows read glob. Tests AC-7 (a v1.0.1 tag maps to the v-star workflow only) and AC-8 (broken YAML and a bracket pattern warn while the digest still returns). Compass metadata updated.</item>
17
16
  <item>RFC-1503: steps 1-5 — highest-per-line pending selection, publish-superseded/publish-retired journal events, flow.publication.retire</item>
17
+ <item>RFC-1580: digest trail, manifest review export, operating model and skills
18
+
19
+ 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>
20
+ <history>RFC-1491</history>
18
21
  </CHANGE_SUMMARY>
19
22
  */
20
23
 
@@ -47,6 +50,7 @@ function emptyDigestData(diagnostics: Diagnostic[]): FlowDigestData {
47
50
  pendingPublications: [],
48
51
  supersededPublications: [],
49
52
  tagTriggers: [],
53
+ correctnessTrail: { weakenings: [], verifierCommits: [] },
50
54
  diagnostics,
51
55
  };
52
56
  }
@@ -115,6 +119,12 @@ export async function runFlowDigest(
115
119
  for (const trigger of data.tagTriggers) {
116
120
  logger.info(` tag ${trigger.tag} triggers: ${trigger.workflows.join(", ")}`);
117
121
  }
122
+ for (const w of data.correctnessTrail.weakenings) {
123
+ logger.warn(` accepted correctness weakening ${w.sha.slice(0, 9)}: ${w.reason}`);
124
+ }
125
+ for (const v of data.correctnessTrail.verifierCommits) {
126
+ logger.info(` verifier-trailer commit ${v.sha.slice(0, 9)} ${v.subject}${v.report ? ` (report ${v.report})` : ""}`);
127
+ }
118
128
  for (const d of data.diagnostics) {
119
129
  if (d.severity === "error") logger.error(` ${d.ruleId}: ${d.message}`);
120
130
  else logger.warn(` ${d.ruleId}: ${d.message}`);
@@ -20,12 +20,18 @@ at cleanup without moving develop again.</purpose>
20
20
  <item>Task-file preservation runs inside the cleanup branch BEFORE the worktree-teardown hook and only for owner.kind task — a `git clean -fdx` teardown would destroy `.forge/task/` first, and a copy failure refuses cleanup (FLOW-INT-04) so the report is never lost with the worktree (RFC-1509 Q-16).</item>
21
21
  </KEY_DECISIONS>
22
22
  <CHANGE_SUMMARY>
23
- <item>RFC-1545: standalone generated-conflict regeneration in flow.integrate</item>
24
- <item>RFC-1543: attribute shared-checkout dirt to live ops and expose peers (RFC-1543)</item>
25
- <item>RFC-1544: attribute mission lockfile churn to owning checkout and auto-resolve foreign importer diffs (RFC-1544)</item>
26
23
  <item>ADR-0128: FLOW-INT-02 names rebase stderr tail + porcelain status when no unmerged paths; cap path list at 20 (+N more) (ADR-0128 F-0188)</item>
27
24
  <item>ADR-0130: foreign-open-mission restore writes HEAD verbatim — whole diff classified as importer churn, a block splice would leave induced additions to be swept</item>
28
- <history>RFC-1487, RFC-1490, RFC-1491, RFC-1504, RFC-1509, RFC-1515, RFC-1528, RFC-1531, RFC-1532, RFC-1536, RFC-1537, RFC-1538</history>
25
+ <item>RFC-1574: regenerate derived manifests after the integrate rebase and commit them
26
+
27
+ flow.integrate step (3b) runs GENERATED_BASENAME_OWNERS owners on the rebased tree (opts.invoke ?? standaloneInvoke), commits only owned paths with the fixed subject before the gate, refuses FLOW-INT-12 on owner failure, non-owned dirt or a still-red validate; the preflight no longer writes and refuses only without a resolvable owner.</item>
28
+ <item>RFC-1574: close review REVIEW-CODE-2026-11-12-05 findings
29
+
30
+ Step (3b) judges only paths the owner run changed, validates before staging, skips owners not runnable without an engine build, runs ecosystem.manifest.generate last; e2e log write guarded and run-stamped; Unhandled Errors rule out timeout-only; lost-run wait test; publish pre-filter comment. RFC-1574/1575/1576 record DEV-1..8.</item>
31
+ <item>RFC-1580: correctness.gate and the flow.integrate step
32
+
33
+ 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>
34
+ <history>RFC-1487, RFC-1490, RFC-1491, RFC-1504, RFC-1509, RFC-1515, RFC-1528, RFC-1531, RFC-1532, RFC-1536, RFC-1537, RFC-1538, RFC-1543, RFC-1544, RFC-1545</history>
29
35
  </CHANGE_SUMMARY>
30
36
  */
31
37
 
@@ -77,6 +83,11 @@ import {
77
83
  type FlowRegistryEntry,
78
84
  } from "../registry.ts";
79
85
  import { runFlowScript, type FlowScriptResult } from "../scripts.ts";
86
+ import {
87
+ postRebaseOwners,
88
+ regenerateAfterRebase,
89
+ type PostRebaseRegenResult,
90
+ } from "../post-rebase-regen.ts";
80
91
  import { standaloneInvoke } from "../standalone-invoke.ts";
81
92
  import { preserveTaskFiles } from "../task-files.ts";
82
93
  import { flowWorktreePath, primaryWorktree } from "../worktree-path.ts";
@@ -115,8 +126,12 @@ export interface FlowIntegrateData {
115
126
  /** RFC-1538: generated-file rebase conflicts auto-resolved via their owner
116
127
  * commands — journaled, never silently merged. */
117
128
  autoResolved?: string[];
129
+ /** RFC-1574: post-rebase regeneration of derived manifests (step 3b). */
130
+ postRebaseRegen?: PostRebaseRegenResult;
118
131
  /** RFC-1538: which checkout's build ran the integration gate. */
119
132
  gateEngine?: "session" | "primary";
133
+ /** RFC-1580: the primary install's correctness.gate verdict for this integration. */
134
+ correctnessGate?: { status: string; bundlePath: string | null; acceptedWeakening: string | null };
120
135
  /** RFC-1531: worktree path --reattach created this run. */
121
136
  reattachedTo?: string;
122
137
  /** RFC-1531: reattach target a --dry-run reports without mutating. */
@@ -471,6 +486,8 @@ async function integrateFlowBranchAttempt(
471
486
  autocommit?: boolean;
472
487
  /** RFC-1543: seconds to wait for live foreign claim-holders on primary (default 600, 0 = fail-fast). */
473
488
  waitForeignSeconds?: number;
489
+ /** RFC-1580: operator-accepted weakening reason (isolated weakening session only). */
490
+ acceptWeakening?: string;
474
491
  },
475
492
  ): Promise<FlowIntegrateData> {
476
493
  const now = opts.now ?? new Date();
@@ -1130,6 +1147,46 @@ async function integrateFlowBranchAttempt(
1130
1147
  }
1131
1148
  }
1132
1149
 
1150
+ // (3b) RFC-1574: post-rebase regeneration — derived manifests depend on
1151
+ // develop + branch, so they are regenerated on the rebased tree and the
1152
+ // change is committed before the gate judges it (F-0168).
1153
+ let postRebaseRegen: PostRebaseRegenResult | undefined;
1154
+ if (entry.port === null) {
1155
+ const owners = await postRebaseOwners(branchWorktree, io);
1156
+ if (owners.length > 0) {
1157
+ const invoker =
1158
+ opts.invoke ??
1159
+ standaloneInvoke(io, branchWorktree, [
1160
+ ...owners.map((o) => o.command),
1161
+ "ecosystem.manifest.validate",
1162
+ ]);
1163
+ // RFC-1574: the standalone fallback spawns `pnpm exec werkstatt run`
1164
+ // in the worktree — without an engine build there it cannot run, and
1165
+ // the owners are skipped rather than refused.
1166
+ const notRunnable =
1167
+ opts.invoke === undefined &&
1168
+ !(await io.exists(join(branchWorktree, "node_modules", ".bin", "werkstatt")))
1169
+ ? new Set(owners.map((o) => o.command))
1170
+ : undefined;
1171
+ const regen = await regenerateAfterRebase({
1172
+ branchWorktree,
1173
+ io,
1174
+ invoke: invoker,
1175
+ owners,
1176
+ onProgress: opts.onProgress,
1177
+ ...(notRunnable ? { notRunnable } : {}),
1178
+ });
1179
+ if ("refused" in regen) {
1180
+ return refuse("FLOW-INT-12", regen.message, regen.fixHint, {
1181
+ branch,
1182
+ developBefore,
1183
+ rebased: true,
1184
+ });
1185
+ }
1186
+ postRebaseRegen = regen;
1187
+ }
1188
+ }
1189
+
1133
1190
  // (4) integration gate — the primary's script, executed by the session
1134
1191
  // engine's build when the worktree carries one (RFC-1538): the code
1135
1192
  // under review judges itself; the checks it faces stay primary-owned.
@@ -1171,6 +1228,30 @@ async function integrateFlowBranchAttempt(
1171
1228
  );
1172
1229
  }
1173
1230
 
1231
+ // (4b) RFC-1580: correctness gate from the PRIMARY install, judging the
1232
+ // session worktree against the develop tip it integrates into.
1233
+ const { runCorrectnessStep, CORRECTNESS_WEAKENING_TRAILER } =
1234
+ await import("../correctness-step.ts");
1235
+ const correctness = await runCorrectnessStep(io, {
1236
+ primary,
1237
+ worktree: branchWorktree,
1238
+ base: rebaseBase,
1239
+ ...(opts.acceptWeakening ? { acceptWeakening: opts.acceptWeakening } : {}),
1240
+ });
1241
+ if (correctness.refusal) {
1242
+ return refuse(
1243
+ "FLOW-INT-18",
1244
+ correctness.refusal.message,
1245
+ correctness.refusal.fixHint,
1246
+ { branch, developBefore, rebased: entry.port === null, gate },
1247
+ correctness.bundlePath ? { bundlePath: correctness.bundlePath } : undefined,
1248
+ );
1249
+ }
1250
+ if (correctness.warning) warnings.push(correctness.warning);
1251
+ opts.onProgress?.(
1252
+ `correctness gate: ${correctness.status}${correctness.bundlePath ? ` (${correctness.bundlePath})` : ""}`,
1253
+ );
1254
+
1174
1255
  // (5) primary must sit clean on develop, then fast-forward. Mid-gate
1175
1256
  // importer churn from another session's open mission tolerates here too
1176
1257
  // (RFC-1537) — the same classifier the preflight ran.
@@ -1215,6 +1296,23 @@ async function integrateFlowBranchAttempt(
1215
1296
  { branch, developBefore, rebased: entry.port === null, gate },
1216
1297
  );
1217
1298
  }
1299
+ if (correctness.acceptedWeakening) {
1300
+ // RFC-1580: the accepted weakening is recorded on the integration itself.
1301
+ const trailer = await git(branchWorktree, io, [
1302
+ "commit",
1303
+ "--allow-empty",
1304
+ "-m",
1305
+ `flow: accept correctness weakening\n\n${CORRECTNESS_WEAKENING_TRAILER}: ${correctness.acceptedWeakening.replace(/\s+/g, " ").trim()}`,
1306
+ ]);
1307
+ if (trailer.exitCode !== 0) {
1308
+ return refuse(
1309
+ "FLOW-INT-18",
1310
+ `could not record ${CORRECTNESS_WEAKENING_TRAILER} on the branch: ${trailer.stderr.trim()}`,
1311
+ "commit the trailer by hand in the session worktree, then re-run",
1312
+ { branch, developBefore, rebased: entry.port === null, gate },
1313
+ );
1314
+ }
1315
+ }
1218
1316
  const merge = await git(primary, io, ["merge", "--ff-only", branch]);
1219
1317
  if (merge.exitCode !== 0) {
1220
1318
  return refuse(
@@ -1236,6 +1334,7 @@ async function integrateFlowBranchAttempt(
1236
1334
  ...(dirty.toleratedState.length > 0 ? { toleratedState: dirty.toleratedState } : {}),
1237
1335
  ...(toleratedDirt.length > 0 ? { toleratedDirt } : {}),
1238
1336
  ...(autoResolved.length > 0 ? { autoResolved } : {}),
1337
+ ...(postRebaseRegen !== undefined ? { postRebaseRegen } : {}),
1239
1338
  ...(reattachedTo !== undefined ? { reattachedTo } : {}),
1240
1339
  ...(autoCleaned !== undefined && autoCleaned.length > 0 ? { autoCleaned } : {}),
1241
1340
  ...(autocommitSha !== undefined ? { autocommitSha } : {}),
@@ -1244,6 +1343,11 @@ async function integrateFlowBranchAttempt(
1244
1343
  : {}),
1245
1344
  ...(staleImporterCommitSha !== undefined ? { staleImporterCommitSha } : {}),
1246
1345
  gateEngine: engine.source,
1346
+ correctnessGate: {
1347
+ status: correctness.status,
1348
+ bundlePath: correctness.bundlePath,
1349
+ acceptedWeakening: correctness.acceptedWeakening,
1350
+ },
1247
1351
  diagnostics: warnings,
1248
1352
  };
1249
1353
  };
@@ -1332,7 +1436,11 @@ async function integrateFlowBranchAttempt(
1332
1436
  gate: inner.gate,
1333
1437
  teardown: cleanup.gate,
1334
1438
  cleanedUp: cleanup.cleanedUp,
1335
- diagnostics: cleanup.diagnostics,
1439
+ // Integration warnings (FLOW-INT-16, FLOW-INT-18) survive the cleanup report.
1440
+ diagnostics: [
1441
+ ...inner.diagnostics.filter((d) => d.severity !== "error"),
1442
+ ...cleanup.diagnostics,
1443
+ ],
1336
1444
  };
1337
1445
  }
1338
1446
 
@@ -1359,6 +1467,10 @@ export async function runFlowIntegrate(
1359
1467
  reattach: input.flags["reattach"] === true,
1360
1468
  autoClean: input.flags["auto-clean"] === true,
1361
1469
  autocommit: input.flags["autocommit"] === true,
1470
+ ...(typeof input.flags["accept-weakening"] === "string" &&
1471
+ input.flags["accept-weakening"].trim()
1472
+ ? { acceptWeakening: input.flags["accept-weakening"] }
1473
+ : {}),
1362
1474
  waitForeignSeconds:
1363
1475
  typeof input.flags["wait-foreign"] === "string" ||
1364
1476
  typeof input.flags["wait-foreign"] === "number"