@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
@@ -19,6 +19,30 @@ export declare function classifyLockfileDiff(diffText: string): LockfileClassifi
19
19
  * null otherwise — any removal or foreign addition is ambiguous.
20
20
  */
21
21
  export declare function classifyLockfileMaterialize(diffText: string): string[] | null;
22
+ /**
23
+ * Snapshot keys reachable from `missionIds` in the working lockfile — BFS
24
+ * from each `missions/<id>/workpiece` importer through `dependencies`,
25
+ * `devDependencies` and `optionalDependencies` version specifiers, then
26
+ * through each reached snapshot's own dependency maps. Specifiers that are
27
+ * not registry resolutions (`link:`, `workspace:`, `file:`) have no snapshot
28
+ * entry and are ignored.
29
+ */
30
+ export declare function reachableSnapshotKeys(lockText: string, missionIds: string[]): Set<string>;
31
+ /**
32
+ * ADR-0130 criterion (b)+(c): materialize shape extended with induced
33
+ * changes. Removed lines must be `optional: true` on snapshots reachable
34
+ * from the added mission importers, or `key:` lines paired with an added
35
+ * `key: {}` collapse. Added lines outside mission importer blocks must
36
+ * anchor under `packages:` or `snapshots:` in the HEAD file.
37
+ */
38
+ export declare function classifyLockfileMaterializeExtended(diffText: string, headText: string, workText: string): string[] | null;
39
+ /**
40
+ * ADR-0130 prune direction: removed lines must still be importer-block
41
+ * members (strict rule); added lines are tolerated only when they anchor
42
+ * inside `packages:`/`snapshots:` — the inverse induced write (`optional:
43
+ * true` re-additions, `transitivePeerDependencies`, snapshot entries).
44
+ */
45
+ export declare function classifyLockfilePruneIdsExtended(diffText: string, headText: string): string[] | null;
22
46
  export type { DirtyClass } from "./dirty-classify.ts";
23
47
  export interface ToleratedEntry {
24
48
  path: string;
@@ -1 +1 @@
1
- {"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../../os/flow/preflight.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAC1B,WAAW,EACZ,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,UAAU,EAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,aAAa,EAAgB,MAAM,UAAU,CAAC;AAE3E,OAAO,EAA+B,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE9E,MAAM,MAAM,sBAAsB,GAAG,qBAAqB,GAAG,OAAO,CAAC;AAErE;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CA2C1E;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,sBAAsB,CAE7E;AAED;;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MAAM,EAAE,CAAC;CACxB;AAED,0EAA0E;AAC1E,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAG5D,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,WAAW,EACf,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,GAAE;IAAE,MAAM,EAAE,OAAO,GAAG,CAAA;CAAoB,GAC7C,OAAO,CAAC,qBAAqB,CAAC,CA2ChC"}
@@ -14,19 +14,22 @@ closed by the RFC: adding a check requires an amendment.</purpose>
14
14
  </non-goals>
15
15
  </MODULE_CONTRACT>
16
16
  <CHANGE_SUMMARY>
17
- <item>RFC-1531: shared DirtyClass enum via dirty-classify.ts (Q-4), classified FLOW-INT-01/03 data.entries, classifyDirtyEntries for the remediation flags</item>
18
- <item>RFC-1546: derive-and-repair recoverable state across flow surfaces (AC-1..AC-5)</item>
19
- <item>RFC-1545: standalone generated-conflict regeneration in flow.integrate</item>
20
- <item>RFC-1543: attribute shared-checkout dirt to live ops and expose peers (RFC-1543)</item>
21
17
  <item>RFC-1544: attribute mission lockfile churn to owning checkout and auto-resolve foreign importer diffs (RFC-1544)</item>
22
- <history>RFC-1528, RFC-1537, RFC-1538</history>
18
+ <item>ADR-0130: induced-change lockfile classifiers — BFS reachability for optional-flag removals, collapse pairs, induced packages/snapshots additions</item>
19
+ <item>ADR-0129: F-0186/F-0187 — FLOW-INT-03 names paths + three-way remedy, FLOW-OPEN-01 same hint, forge CLI kernel-command hint</item>
20
+ <item>RFC-0000: skip rfc-0000 template in integrate preflight id extraction; regen ecosystem manifest; file F-0207</item>
21
+ <item>RFC-1574: regenerate derived manifests after the integrate rebase and commit them
22
+
23
+ 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>
24
+ <history>RFC-1528, RFC-1531, RFC-1537, RFC-1538, RFC-1543, RFC-1545, RFC-1546</history>
23
25
  </CHANGE_SUMMARY>
24
26
  */
25
27
  import { basename, dirname, join } from "node:path";
28
+ import { parse as parseYaml } from "yaml";
26
29
  import { loadLiveCommandInventory } from "../../src/utils/command-inventory.js";
27
30
  import { isGeneratedContent, isGeneratedPathName, REGEN_FLAGS } from "../core/archive-regen.js";
28
31
  import { openMissionsIn } from "../mission/open-missions.js";
29
- import { classifyDirtyPath, summarizeClasses, } from "./dirty-classify.js";
32
+ import { classifyDirtyPath, FOREIGN_PRIMARY_DIRT_HINT, summarizeClasses, } from "./dirty-classify.js";
30
33
  import { currentBranch, git, statusTracked, worktreeList } from "./git.js";
31
34
  import { canonicalRepoDir } from "../../src/utils/repo-path.js";
32
35
  import { claimCoversPath, liveClaims } from "./ops-registry.js";
@@ -140,6 +143,303 @@ export function classifyLockfileMaterialize(diffText) {
140
143
  }
141
144
  return sawImporterKey ? [...ids].sort() : null;
142
145
  }
146
+ // ---------------------------------------------------------------------------
147
+ // ADR-0130 (F-0201): induced-change lockfile shapes
148
+ //
149
+ // A `pnpm install` against a lockfile whose `importers:` list includes open
150
+ // mission workpieces produces diffs that are never pure block additions or
151
+ // removals — the dependency-graph write also adds/drops `optional: true`
152
+ // flags, collapses `key:\n optional: true` pairs to `key: {}`, and adds or
153
+ // removes `packages:`/`snapshots:` members. The strict one-shape classifiers
154
+ // above see the extra hunks and degrade to `work`, which is the ping-pong the
155
+ // ADR stops. These extended classifiers accept the strict shape first and
156
+ // then the induced shape, bounded by where each hunk anchors in the HEAD
157
+ // lockfile.
158
+ // ---------------------------------------------------------------------------
159
+ const DIFF_HEADER = /^(diff |index |--- |\+\+\+ |@@ )/;
160
+ const TOP_LEVEL_KEY = /^(\S[^:]*):\s*$/;
161
+ const IMPORTER_KEY = /^\s*missions\/([^\s/]+)\/workpiece:\s*$/;
162
+ const OPTIONAL_TRUE = /^\s*optional: true\s*$/;
163
+ /** Parse `git diff` output into positioned lines (single-file diffs only). */
164
+ function parseDiffLines(diffText) {
165
+ const lines = [];
166
+ let oldCursor = 0;
167
+ for (const raw of diffText.split("\n")) {
168
+ const hunk = /^@@ -(\d+)(?:,\d+)? \+\d+(?:,\d+)? @@/.exec(raw);
169
+ if (hunk) {
170
+ oldCursor = Number(hunk[1]);
171
+ lines.push({ kind: "hunk", text: raw, oldLine: oldCursor });
172
+ continue;
173
+ }
174
+ if (DIFF_HEADER.test(raw) || raw === "")
175
+ continue;
176
+ if (raw.startsWith("+")) {
177
+ lines.push({ kind: "add", text: raw.slice(1), oldLine: oldCursor });
178
+ continue;
179
+ }
180
+ if (raw.startsWith("-")) {
181
+ lines.push({ kind: "del", text: raw.slice(1), oldLine: oldCursor });
182
+ oldCursor += 1;
183
+ continue;
184
+ }
185
+ lines.push({ kind: "ctx", text: raw.slice(1), oldLine: oldCursor });
186
+ oldCursor += 1;
187
+ }
188
+ return lines;
189
+ }
190
+ /** Top-level (`key:`) section containing old-file line `n` (1-based). */
191
+ function topLevelSectionAt(headLines, n) {
192
+ let section = null;
193
+ for (let i = 0; i < Math.min(n, headLines.length); i++) {
194
+ const m = TOP_LEVEL_KEY.exec(headLines[i]);
195
+ if (m)
196
+ section = m[1];
197
+ }
198
+ return section;
199
+ }
200
+ /** Second-level `key:` (one-indent) enclosing old-file line `n` inside `section`. */
201
+ function secondLevelKeyAt(headLines, n, section) {
202
+ let inSection = false;
203
+ let key = null;
204
+ for (let i = 0; i < Math.min(n, headLines.length); i++) {
205
+ const line = headLines[i];
206
+ const top = TOP_LEVEL_KEY.exec(line);
207
+ if (top) {
208
+ inSection = top[1] === section;
209
+ key = null;
210
+ continue;
211
+ }
212
+ if (!inSection || line.trim() === "")
213
+ continue;
214
+ const m = /^ {2}('?[^:]*'?):\s*(?:\{\})?\s*$/.exec(line);
215
+ if (m)
216
+ key = m[1].replace(/^'|'$/g, "");
217
+ }
218
+ return key;
219
+ }
220
+ /**
221
+ * Snapshot keys reachable from `missionIds` in the working lockfile — BFS
222
+ * from each `missions/<id>/workpiece` importer through `dependencies`,
223
+ * `devDependencies` and `optionalDependencies` version specifiers, then
224
+ * through each reached snapshot's own dependency maps. Specifiers that are
225
+ * not registry resolutions (`link:`, `workspace:`, `file:`) have no snapshot
226
+ * entry and are ignored.
227
+ */
228
+ export function reachableSnapshotKeys(lockText, missionIds) {
229
+ const reachable = new Set();
230
+ let parsed;
231
+ try {
232
+ parsed = parseYaml(lockText);
233
+ }
234
+ catch {
235
+ return reachable;
236
+ }
237
+ const root = parsed;
238
+ const importers = (root?.importers ?? {});
239
+ const snapshots = (root?.snapshots ?? {});
240
+ const depMaps = (entry) => {
241
+ const out = [];
242
+ for (const field of ["dependencies", "devDependencies", "optionalDependencies"]) {
243
+ const deps = entry[field];
244
+ if (!deps)
245
+ continue;
246
+ for (const [name, spec] of Object.entries(deps)) {
247
+ const version = typeof spec === "string" ? spec : spec?.version;
248
+ if (typeof version !== "string")
249
+ continue;
250
+ if (/^(link|workspace|file):/.test(version))
251
+ continue;
252
+ // pnpm strips the name for plain resolutions inside importers
253
+ // (version only) but snapshot keys carry `name@version`.
254
+ out.push(version.startsWith(`${name}@`) ? version : `${name}@${version}`);
255
+ }
256
+ }
257
+ return out;
258
+ };
259
+ const queue = [];
260
+ for (const id of missionIds) {
261
+ const entry = importers[`missions/${id}/workpiece`];
262
+ if (entry)
263
+ queue.push(...depMaps(entry));
264
+ }
265
+ while (queue.length > 0) {
266
+ const key = queue.shift();
267
+ if (reachable.has(key))
268
+ continue;
269
+ reachable.add(key);
270
+ const snap = snapshots[key];
271
+ if (snap)
272
+ queue.push(...depMaps(snap));
273
+ }
274
+ return reachable;
275
+ }
276
+ /**
277
+ * ADR-0130 criterion (b)+(c): materialize shape extended with induced
278
+ * changes. Removed lines must be `optional: true` on snapshots reachable
279
+ * from the added mission importers, or `key:` lines paired with an added
280
+ * `key: {}` collapse. Added lines outside mission importer blocks must
281
+ * anchor under `packages:` or `snapshots:` in the HEAD file.
282
+ */
283
+ export function classifyLockfileMaterializeExtended(diffText, headText, workText) {
284
+ const strict = classifyLockfileMaterialize(diffText);
285
+ if (strict !== null)
286
+ return strict;
287
+ const headLines = headText.split("\n");
288
+ const lines = parseDiffLines(diffText);
289
+ const missionIds = new Set();
290
+ const collapsedKeys = new Set();
291
+ const optionalRemovedOn = new Set();
292
+ let importerBlockIndent = null;
293
+ let sawDiff = false;
294
+ for (const line of lines) {
295
+ if (line.kind === "hunk") {
296
+ importerBlockIndent = null;
297
+ continue;
298
+ }
299
+ if (line.kind === "ctx") {
300
+ const indent = line.text.length - line.text.trimStart().length;
301
+ if (line.text.trim().length > 0 &&
302
+ importerBlockIndent !== null &&
303
+ indent <= importerBlockIndent) {
304
+ importerBlockIndent = null;
305
+ }
306
+ continue;
307
+ }
308
+ sawDiff = true;
309
+ if (line.kind === "add") {
310
+ const text = line.text;
311
+ const indent = text.length - text.trimStart().length;
312
+ const key = IMPORTER_KEY.exec(text);
313
+ if (key) {
314
+ missionIds.add(key[1]);
315
+ importerBlockIndent = indent;
316
+ continue;
317
+ }
318
+ if (importerBlockIndent !== null && (indent > importerBlockIndent || text.trim() === "")) {
319
+ continue; // member of an open importer block
320
+ }
321
+ if (indent <= (importerBlockIndent ?? indent))
322
+ importerBlockIndent = null;
323
+ // Non-importer additions must anchor inside the dependency-graph
324
+ // sections — the induced write never touches anything else.
325
+ const section = topLevelSectionAt(headLines, line.oldLine);
326
+ if (section === "packages" || section === "snapshots")
327
+ continue;
328
+ return null;
329
+ }
330
+ // removed line
331
+ const text = line.text;
332
+ if (OPTIONAL_TRUE.test(text)) {
333
+ const owner = secondLevelKeyAt(headLines, line.oldLine, "snapshots");
334
+ if (owner === null)
335
+ return null;
336
+ optionalRemovedOn.add(owner);
337
+ continue;
338
+ }
339
+ const removedKey = /^(\s*'?[^:]*'?):\s*$/.exec(text);
340
+ if (removedKey) {
341
+ // allowed only as the `key:` → `key: {}` collapse — an added
342
+ // `key: {}` must appear somewhere in the diff.
343
+ collapsedKeys.add(removedKey[1].trim());
344
+ const owner = removedKey[1].trim().replace(/^'|'$/g, "");
345
+ const section = topLevelSectionAt(headLines, line.oldLine);
346
+ if (section !== "snapshots")
347
+ return null;
348
+ optionalRemovedOn.add(owner);
349
+ continue;
350
+ }
351
+ return null;
352
+ }
353
+ if (!sawDiff || missionIds.size === 0)
354
+ return null;
355
+ // every removed `key:` must be matched by an added `key: {}` — an
356
+ // unmatched one is a real snapshot removal, not a collapse.
357
+ for (const key of collapsedKeys) {
358
+ const hasPair = lines.some((l) => l.kind === "add" && l.text.trim() === `${key}: {}`);
359
+ if (!hasPair)
360
+ return null;
361
+ }
362
+ const reachable = reachableSnapshotKeys(workText, [...missionIds]);
363
+ for (const owner of optionalRemovedOn) {
364
+ if (!reachable.has(owner))
365
+ return null;
366
+ }
367
+ return [...missionIds].sort();
368
+ }
369
+ /**
370
+ * ADR-0130 prune direction: removed lines must still be importer-block
371
+ * members (strict rule); added lines are tolerated only when they anchor
372
+ * inside `packages:`/`snapshots:` — the inverse induced write (`optional:
373
+ * true` re-additions, `transitivePeerDependencies`, snapshot entries).
374
+ */
375
+ export function classifyLockfilePruneIdsExtended(diffText, headText) {
376
+ const strict = classifyLockfilePruneIds(diffText);
377
+ if (strict !== null)
378
+ return strict;
379
+ const headLines = headText.split("\n");
380
+ const lines = parseDiffLines(diffText);
381
+ const ids = new Set();
382
+ const expandedKeys = new Set();
383
+ let sawImporterKey = false;
384
+ let openBlockIndent = null;
385
+ for (const line of lines) {
386
+ if (line.kind === "hunk") {
387
+ openBlockIndent = null;
388
+ continue;
389
+ }
390
+ if (line.kind === "ctx") {
391
+ const indent = line.text.length - line.text.trimStart().length;
392
+ if (line.text.trim().length > 0 && openBlockIndent !== null && indent <= openBlockIndent) {
393
+ openBlockIndent = null;
394
+ }
395
+ continue;
396
+ }
397
+ if (line.kind === "add") {
398
+ const section = topLevelSectionAt(headLines, line.oldLine);
399
+ if (section === "packages" || section === "snapshots")
400
+ continue;
401
+ return null;
402
+ }
403
+ const text = line.text;
404
+ if (text.trim().length === 0) {
405
+ if (openBlockIndent === null)
406
+ return null;
407
+ continue;
408
+ }
409
+ // inverse of the materialize collapse — the prune re-expands
410
+ // `key: {}` into `key:` + `optional: true` children.
411
+ const emptyEntry = /^(\s*'?[^:]*'?):\s*\{\}\s*$/.exec(text);
412
+ if (emptyEntry) {
413
+ const section = topLevelSectionAt(headLines, line.oldLine);
414
+ if (section === "snapshots" || section === "packages") {
415
+ expandedKeys.add(emptyEntry[1].trim());
416
+ continue;
417
+ }
418
+ return null;
419
+ }
420
+ const indent = text.length - text.trimStart().length;
421
+ const key = IMPORTER_KEY.exec(text);
422
+ if (key) {
423
+ sawImporterKey = true;
424
+ ids.add(key[1]);
425
+ openBlockIndent = indent;
426
+ continue;
427
+ }
428
+ if (openBlockIndent !== null && indent > openBlockIndent)
429
+ continue;
430
+ return null;
431
+ }
432
+ if (!sawImporterKey)
433
+ return null;
434
+ // every removed `key: {}` must pair with an added `key:` — an unmatched
435
+ // one is a real snapshot removal, not a re-expansion.
436
+ for (const key of expandedKeys) {
437
+ const hasPair = lines.some((l) => l.kind === "add" && l.text.trim() === `${key}:`);
438
+ if (!hasPair)
439
+ return null;
440
+ }
441
+ return [...ids].sort();
442
+ }
143
443
  /** Classify the pnpm-lock.yaml diff of `repo` when the lockfile is dirty. */
144
444
  async function classifyDirtyLockfile(repo, io, dirtyEntries, runGit) {
145
445
  const lockfileDirty = dirtyEntries.some((entry) => entry.slice(3).trim() === "pnpm-lock.yaml");
@@ -255,7 +555,34 @@ export async function classifyDirt(repo, io, entries, deps = { runGit: git }, cl
255
555
  outer: for (const [path, lines] of byPath) {
256
556
  if (path === "pnpm-lock.yaml") {
257
557
  const diff = await deps.runGit(repo, io, ["diff", "HEAD", "--", "pnpm-lock.yaml"]);
258
- const pruneIds = classifyLockfilePruneIds(diff.stdout);
558
+ // ADR-0130: the induced-change shapes need the HEAD and working
559
+ // contents — fetched lazily, only when the strict shapes miss.
560
+ let headLock = null;
561
+ let workLock = null;
562
+ const lockContents = async () => {
563
+ if (headLock === null || workLock === null) {
564
+ const head = await deps.runGit(repo, io, ["show", "HEAD:pnpm-lock.yaml"]);
565
+ if (head.exitCode !== 0)
566
+ return null;
567
+ let work;
568
+ try {
569
+ work = await io.readFile(join(repo, "pnpm-lock.yaml"));
570
+ }
571
+ catch {
572
+ return null; // reduced io — degrade to the strict-shape verdict
573
+ }
574
+ headLock = head.stdout;
575
+ workLock = work;
576
+ }
577
+ return { head: headLock, work: workLock };
578
+ };
579
+ let pruneIds = classifyLockfilePruneIds(diff.stdout);
580
+ if (pruneIds === null) {
581
+ const contents = await lockContents();
582
+ if (contents !== null) {
583
+ pruneIds = classifyLockfilePruneIdsExtended(diff.stdout, contents.head);
584
+ }
585
+ }
259
586
  if (pruneIds !== null) {
260
587
  // RFC-1544: the pruned importer's referent decides the class — a
261
588
  // foreign checkout's open mission (foreign-open-mission, auto-
@@ -286,7 +613,13 @@ export async function classifyDirt(repo, io, entries, deps = { runGit: git }, cl
286
613
  }
287
614
  continue;
288
615
  }
289
- const ids = classifyLockfileMaterialize(diff.stdout);
616
+ let ids = classifyLockfileMaterialize(diff.stdout);
617
+ if (ids === null) {
618
+ const contents = await lockContents();
619
+ if (contents !== null) {
620
+ ids = classifyLockfileMaterializeExtended(diff.stdout, contents.head, contents.work);
621
+ }
622
+ }
290
623
  if (ids !== null) {
291
624
  const open = await openMissionIds();
292
625
  if (ids.every((id) => open.has(id))) {
@@ -549,15 +882,26 @@ export async function runIntegratePreflight(opts, deps = { runGit: git, runStatu
549
882
  message: (primaryBranch !== "develop"
550
883
  ? `primary worktree is on ${primaryBranch ?? "detached HEAD"}, not develop`
551
884
  : verdict.unattributed.length > 0
552
- ? `primary worktree has ${verdict.unattributed.length} uncommitted change(s)`
885
+ ? // ADR-0129 (F-0186): name the paths — the remedy differs by
886
+ // whose work each one is.
887
+ `primary worktree has ${verdict.unattributed.length} uncommitted change(s): ${verdict.unattributed
888
+ .slice(0, 20)
889
+ .map((line) => line.slice(3).trim())
890
+ .join(", ")}` +
891
+ (verdict.unattributed.length > 20
892
+ ? ` (+${verdict.unattributed.length - 20} more)`
893
+ : "")
553
894
  : `primary worktree held by ${verdict.foreignInFlight.length} in-flight foreign op(s)`) +
554
895
  holderNote +
555
896
  (verdict.tolerated.length > 0
556
897
  ? ` — tolerated regenerable state: ${verdict.tolerated.map((t) => `${t.path} (${t.class})`).join(", ")}`
557
898
  : "") +
558
899
  (lockfile === "importer-prune-only" ? ` — pnpm-lock.yaml${LOCKFILE_PRUNE_HINT}` : ""),
559
- fixHint: "switch the primary to develop and commit or revert its tracked changes, then re-run — the branch stays rebased",
900
+ fixHint: primaryBranch !== "develop"
901
+ ? "switch the primary to develop and commit or revert its tracked changes, then re-run — the branch stays rebased"
902
+ : `${FOREIGN_PRIMARY_DIRT_HINT}, then re-run`,
560
903
  data: {
904
+ unattributed: verdict.unattributed.map((line) => line.slice(3).trim()),
561
905
  entries: verdict.unattributed.map((line) => {
562
906
  const path = line.slice(3).trim();
563
907
  return { path, class: classifyDirtyPath(path) };
@@ -623,7 +967,9 @@ export async function runIntegratePreflight(opts, deps = { runGit: git, runStatu
623
967
  ...new Set(diff.stdout
624
968
  .split("\n")
625
969
  .map((l) => /^docs\/rfcs\/(?:archive\/(?:implemented|rejected|superseded)\/)?rfc-(\d+)-[^/]*\.md$/.exec(l.trim())?.[1])
626
- .filter((m) => m !== undefined)
970
+ // rfc-0000-template.md is corpus-excluded (listRfcFiles) — it is a
971
+ // template, not a validateable RFC.
972
+ .filter((m) => m !== undefined && m !== "0000")
627
973
  .map((n) => `RFC-${n.padStart(4, "0")}`)),
628
974
  ];
629
975
  if (changedRfcIds.length > 0) {
@@ -679,22 +1025,16 @@ export async function runIntegratePreflight(opts, deps = { runGit: git, runStatu
679
1025
  reason: opts.invoke === undefined ? "no-invoke" : "unresolvable",
680
1026
  });
681
1027
  }
682
- // RFC-1546: every other check passed — the manifest drift is the sole
683
- // violation, so the owner command regenerates in place and the validator
684
- // re-runs. A coexisting violation already refused above without ever
685
- // reaching the regeneration.
1028
+ // RFC-1574 (amends RFC-1546): every other check passed — the manifest
1029
+ // drift is the sole violation. The preflight writes nothing: a resolvable
1030
+ // owner defers the regeneration to flow.integrate step (3b), which runs on
1031
+ // the rebased tree and commits the result. Without an owner the drift
1032
+ // still refuses here.
686
1033
  if (manifestDrift !== undefined) {
687
1034
  if (resolvable("ecosystem.manifest.generate")) {
688
- const regen = await opts.invoke("ecosystem.manifest.generate", REGEN_FLAGS["ecosystem.manifest.generate"] ?? {});
689
- if (regen.ok !== false && (regen.exitCode === undefined || regen.exitCode === 0)) {
690
- checked.push("ecosystem.manifest.generate", "ecosystem.manifest.validate");
691
- const result = await opts.invoke("ecosystem.manifest.validate", {});
692
- if (result.ok !== false && (result.exitCode === undefined || result.exitCode === 0)) {
693
- manifestDrift = undefined;
694
- }
695
- }
1035
+ opts.onProgress?.("preflight: ecosystem manifest drift — regenerating after the rebase");
696
1036
  }
697
- if (manifestDrift !== undefined) {
1037
+ else {
698
1038
  return {
699
1039
  ok: false,
700
1040
  checked,