@warpgogol/forge 9.7.0 → 10.0.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 (327) hide show
  1. package/AGENTS.md +50 -27
  2. package/CHANGELOG.md +52 -0
  3. package/bin/cli.js +0 -0
  4. package/dist/os/adr/handlers/archive.d.ts.map +1 -1
  5. package/dist/os/adr/handlers/archive.js +3 -7
  6. package/dist/os/adr/handlers/archive.js.map +1 -1
  7. package/dist/os/adr/handlers/list-create.d.ts.map +1 -1
  8. package/dist/os/adr/handlers/list-create.js +8 -6
  9. package/dist/os/adr/handlers/list-create.js.map +1 -1
  10. package/dist/os/audit/handlers/archive.d.ts.map +1 -1
  11. package/dist/os/audit/handlers/archive.js +3 -7
  12. package/dist/os/audit/handlers/archive.js.map +1 -1
  13. package/dist/os/codebase/handlers/codebase-measure-symbols.d.ts.map +1 -1
  14. package/dist/os/codebase/handlers/codebase-measure-symbols.js +35 -4
  15. package/dist/os/codebase/handlers/codebase-measure-symbols.js.map +1 -1
  16. package/dist/os/core/archive-regen.d.ts +1 -0
  17. package/dist/os/core/archive-regen.d.ts.map +1 -1
  18. package/dist/os/core/archive-regen.js +31 -6
  19. package/dist/os/core/archive-regen.js.map +1 -1
  20. package/dist/os/core/core.module.d.ts.map +1 -1
  21. package/dist/os/core/core.module.js +6 -69
  22. package/dist/os/core/core.module.js.map +1 -1
  23. package/dist/os/core/handlers/assets-helpers.d.ts.map +1 -1
  24. package/dist/os/core/handlers/assets-helpers.js +2 -3
  25. package/dist/os/core/handlers/assets-helpers.js.map +1 -1
  26. package/dist/os/core/handlers/determinism-check.d.ts.map +1 -1
  27. package/dist/os/core/handlers/determinism-check.js +2 -3
  28. package/dist/os/core/handlers/determinism-check.js.map +1 -1
  29. package/dist/os/core/handlers/pinned-check.d.ts +13 -0
  30. package/dist/os/core/handlers/pinned-check.d.ts.map +1 -1
  31. package/dist/os/core/handlers/pinned-check.js +25 -0
  32. package/dist/os/core/handlers/pinned-check.js.map +1 -1
  33. package/dist/os/core/handlers/pinned-types.d.ts +7 -0
  34. package/dist/os/core/handlers/pinned-types.d.ts.map +1 -1
  35. package/dist/os/core/handlers/pinned-validate.d.ts.map +1 -1
  36. package/dist/os/core/handlers/pinned-validate.js +24 -1
  37. package/dist/os/core/handlers/pinned-validate.js.map +1 -1
  38. package/dist/os/core/handlers/release-prepare.d.ts.map +1 -1
  39. package/dist/os/core/handlers/release-prepare.js +2 -4
  40. package/dist/os/core/handlers/release-prepare.js.map +1 -1
  41. package/dist/os/flow/digest.d.ts +73 -1
  42. package/dist/os/flow/digest.d.ts.map +1 -1
  43. package/dist/os/flow/digest.js +344 -92
  44. package/dist/os/flow/digest.js.map +1 -1
  45. package/dist/os/flow/evidence-lock.d.ts +36 -0
  46. package/dist/os/flow/evidence-lock.d.ts.map +1 -0
  47. package/dist/os/flow/evidence-lock.js +156 -0
  48. package/dist/os/flow/evidence-lock.js.map +1 -0
  49. package/dist/os/flow/flow.module.d.ts.map +1 -1
  50. package/dist/os/flow/flow.module.js +36 -14
  51. package/dist/os/flow/flow.module.js.map +1 -1
  52. package/dist/os/flow/git.d.ts +50 -3
  53. package/dist/os/flow/git.d.ts.map +1 -1
  54. package/dist/os/flow/git.js +144 -12
  55. package/dist/os/flow/git.js.map +1 -1
  56. package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -1
  57. package/dist/os/flow/handlers/flow-digest.js +3 -5
  58. package/dist/os/flow/handlers/flow-digest.js.map +1 -1
  59. package/dist/os/flow/handlers/flow-peers.js +1 -1
  60. package/dist/os/flow/handlers/flow-peers.js.map +1 -1
  61. package/dist/os/flow/handlers/flow-push.d.ts +81 -0
  62. package/dist/os/flow/handlers/flow-push.d.ts.map +1 -1
  63. package/dist/os/flow/handlers/flow-push.js +642 -138
  64. package/dist/os/flow/handlers/flow-push.js.map +1 -1
  65. package/dist/os/flow/locks.d.ts +8 -0
  66. package/dist/os/flow/locks.d.ts.map +1 -1
  67. package/dist/os/flow/locks.js +6 -3
  68. package/dist/os/flow/locks.js.map +1 -1
  69. package/dist/os/{mission → flow}/open-missions.d.ts +1 -2
  70. package/dist/os/flow/open-missions.d.ts.map +1 -0
  71. package/dist/os/flow/open-missions.js +37 -0
  72. package/dist/os/flow/open-missions.js.map +1 -0
  73. package/dist/os/flow/preflight.d.ts.map +1 -1
  74. package/dist/os/flow/preflight.js +5 -3
  75. package/dist/os/flow/preflight.js.map +1 -1
  76. package/dist/os/flow/registry.d.ts +9 -5
  77. package/dist/os/flow/registry.d.ts.map +1 -1
  78. package/dist/os/flow/registry.js +2 -2
  79. package/dist/os/flow/registry.js.map +1 -1
  80. package/dist/os/friction/friction.module.d.ts.map +1 -1
  81. package/dist/os/friction/friction.module.js +30 -5
  82. package/dist/os/friction/friction.module.js.map +1 -1
  83. package/dist/os/friction/handlers/friction-add.d.ts.map +1 -1
  84. package/dist/os/friction/handlers/friction-add.js +10 -17
  85. package/dist/os/friction/handlers/friction-add.js.map +1 -1
  86. package/dist/os/friction/handlers/friction-migrate.d.ts.map +1 -1
  87. package/dist/os/friction/handlers/friction-migrate.js +188 -2
  88. package/dist/os/friction/handlers/friction-migrate.js.map +1 -1
  89. package/dist/os/friction/store.d.ts +4 -0
  90. package/dist/os/friction/store.d.ts.map +1 -1
  91. package/dist/os/friction/store.js +20 -0
  92. package/dist/os/friction/store.js.map +1 -1
  93. package/dist/os/friction/types.d.ts +12 -0
  94. package/dist/os/friction/types.d.ts.map +1 -1
  95. package/dist/os/friction/types.js +8 -0
  96. package/dist/os/friction/types.js.map +1 -1
  97. package/dist/os/gate/handlers/gate-probe-catalog.d.ts.map +1 -1
  98. package/dist/os/gate/handlers/gate-probe-catalog.js +38 -5
  99. package/dist/os/gate/handlers/gate-probe-catalog.js.map +1 -1
  100. package/dist/os/plan/handlers/archive.d.ts.map +1 -1
  101. package/dist/os/plan/handlers/archive.js +3 -7
  102. package/dist/os/plan/handlers/archive.js.map +1 -1
  103. package/dist/os/rfc/handlers/archive.d.ts.map +1 -1
  104. package/dist/os/rfc/handlers/archive.js +3 -7
  105. package/dist/os/rfc/handlers/archive.js.map +1 -1
  106. package/dist/os/rfc/handlers/list-create.d.ts.map +1 -1
  107. package/dist/os/rfc/handlers/list-create.js +15 -7
  108. package/dist/os/rfc/handlers/list-create.js.map +1 -1
  109. package/dist/os/session/handlers/archive.d.ts.map +1 -1
  110. package/dist/os/session/handlers/archive.js +3 -7
  111. package/dist/os/session/handlers/archive.js.map +1 -1
  112. package/dist/os/system/handlers/system-product-register.d.ts +24 -0
  113. package/dist/os/system/handlers/system-product-register.d.ts.map +1 -0
  114. package/dist/os/system/handlers/system-product-register.js +322 -0
  115. package/dist/os/system/handlers/system-product-register.js.map +1 -0
  116. package/dist/os/system/handlers/system-products-status.d.ts +23 -0
  117. package/dist/os/system/handlers/system-products-status.d.ts.map +1 -0
  118. package/dist/os/system/handlers/system-products-status.js +235 -0
  119. package/dist/os/system/handlers/system-products-status.js.map +1 -0
  120. package/dist/os/system/schemas.d.ts +13 -0
  121. package/dist/os/system/schemas.d.ts.map +1 -1
  122. package/dist/os/system/schemas.js +15 -0
  123. package/dist/os/system/schemas.js.map +1 -1
  124. package/dist/os/system/system.module.d.ts.map +1 -1
  125. package/dist/os/system/system.module.js +113 -3
  126. package/dist/os/system/system.module.js.map +1 -1
  127. package/dist/src/command-modules.d.ts.map +1 -1
  128. package/dist/src/command-modules.js +0 -2
  129. package/dist/src/command-modules.js.map +1 -1
  130. package/dist/src/config/forge-config.d.ts +2 -0
  131. package/dist/src/config/forge-config.d.ts.map +1 -1
  132. package/dist/src/config/forge-config.js +11 -10
  133. package/dist/src/config/forge-config.js.map +1 -1
  134. package/dist/src/index.d.ts +0 -2
  135. package/dist/src/index.d.ts.map +1 -1
  136. package/dist/src/index.js +0 -2
  137. package/dist/src/index.js.map +1 -1
  138. package/dist/src/onboarding/create.d.ts.map +1 -1
  139. package/dist/src/onboarding/create.js +27 -2
  140. package/dist/src/onboarding/create.js.map +1 -1
  141. package/dist/src/onboarding/doctor.d.ts +0 -5
  142. package/dist/src/onboarding/doctor.d.ts.map +1 -1
  143. package/dist/src/onboarding/doctor.js +6 -79
  144. package/dist/src/onboarding/doctor.js.map +1 -1
  145. package/dist/src/onboarding/npm-token-check.d.ts +1 -1
  146. package/dist/src/onboarding/npm-token-check.d.ts.map +1 -1
  147. package/dist/src/onboarding/npm-token-check.js +2 -2
  148. package/dist/src/onboarding/npm-token-check.js.map +1 -1
  149. package/dist/src/profiles/stack-profile.js +2 -2
  150. package/dist/src/types.js +2 -2
  151. package/dist/src/utils/hash.d.ts +1 -0
  152. package/dist/src/utils/hash.d.ts.map +1 -1
  153. package/dist/src/utils/hash.js +4 -0
  154. package/dist/src/utils/hash.js.map +1 -1
  155. package/dist/{os/mission → src/utils}/lockfile.d.ts +1 -18
  156. package/dist/src/utils/lockfile.d.ts.map +1 -0
  157. package/dist/src/utils/lockfile.js +70 -0
  158. package/dist/src/utils/lockfile.js.map +1 -0
  159. package/dist/src/utils/verifier-git.d.ts +27 -1
  160. package/dist/src/utils/verifier-git.d.ts.map +1 -1
  161. package/dist/src/utils/verifier-git.js +36 -6
  162. package/dist/src/utils/verifier-git.js.map +1 -1
  163. package/docs/reference/system-hub.md +104 -0
  164. package/os/adr/handlers/archive.ts +3 -11
  165. package/os/adr/handlers/list-create.test.ts +174 -0
  166. package/os/adr/handlers/list-create.ts +16 -8
  167. package/os/audit/handlers/archive.ts +3 -11
  168. package/os/codebase/handlers/codebase-measure-symbols.ts +32 -4
  169. package/os/core/archive-regen.ts +33 -7
  170. package/os/core/core.module.ts +10 -76
  171. package/os/core/docs-archive.test.ts +25 -0
  172. package/os/core/handlers/assets-helpers.ts +2 -4
  173. package/os/core/handlers/determinism-check.ts +2 -3
  174. package/os/core/handlers/lifecycle-handlers.test.ts +529 -0
  175. package/os/core/handlers/pinned-check.ts +30 -0
  176. package/os/core/handlers/pinned-types.ts +7 -0
  177. package/os/core/handlers/pinned-validate.ts +28 -3
  178. package/os/core/handlers/release-prepare.ts +2 -4
  179. package/os/correctness/gate/trust-boundary-cx18.test.ts +1 -1
  180. package/os/flow/digest.ts +436 -95
  181. package/os/flow/evidence-lock.ts +184 -0
  182. package/os/flow/flow.module.ts +37 -14
  183. package/os/flow/git.ts +206 -11
  184. package/os/flow/handlers/flow-digest.ts +12 -8
  185. package/os/flow/handlers/flow-peers.ts +1 -1
  186. package/os/flow/handlers/flow-push.ts +725 -137
  187. package/os/flow/locks.ts +24 -7
  188. package/os/flow/open-missions.ts +45 -0
  189. package/os/flow/preflight.ts +5 -3
  190. package/os/flow/registry.ts +7 -3
  191. package/os/flow/tests/digest-id-inputs.test.ts +106 -0
  192. package/os/flow/tests/digest-persist.test.ts +243 -0
  193. package/os/flow/tests/evidence-preflight-surface-skip.test.ts +218 -0
  194. package/os/flow/tests/flow-push-attest.test.ts +137 -0
  195. package/os/flow/tests/flow-push-review-baseline.test.ts +339 -0
  196. package/os/flow/tests/flow-push-verifier-batch.test.ts +134 -0
  197. package/os/flow/tests/release-lines.test.ts +136 -0
  198. package/os/flow/tests/state-roots.test.ts +1 -48
  199. package/os/friction/friction-add.test.ts +42 -0
  200. package/os/friction/friction-migrate.test.ts +67 -2
  201. package/os/friction/friction.module.ts +33 -5
  202. package/os/friction/handlers/friction-add.ts +10 -15
  203. package/os/friction/handlers/friction-migrate.ts +220 -1
  204. package/os/friction/store.ts +19 -0
  205. package/os/friction/types.ts +8 -0
  206. package/os/gate/handlers/gate-probe-catalog.ts +39 -7
  207. package/os/gate/handlers/gate-probe-ratchet.test.ts +57 -22
  208. package/os/plan/handlers/archive.ts +3 -11
  209. package/os/rfc/handlers/archive.ts +3 -11
  210. package/os/rfc/handlers/list-create.ts +22 -17
  211. package/os/rfc/handlers/validate-corpus.test.ts +149 -0
  212. package/os/rfc/probe-batch.test.ts +253 -0
  213. package/os/rfc/verifier/rfc-1391/ac10-operating-model-policy.acceptance.test.ts +63 -0
  214. package/os/session/handlers/archive.ts +3 -11
  215. package/os/system/handlers/system-product-register.ts +492 -0
  216. package/os/system/handlers/system-products-status.ts +395 -0
  217. package/os/system/schemas.ts +17 -0
  218. package/os/system/system.module.ts +117 -3
  219. package/os/system/tests/system-product-register.test.ts +304 -0
  220. package/os/system/tests/system-products-status.test.ts +154 -0
  221. package/package.json +161 -506
  222. package/profiles/root-agents-system.md +82 -0
  223. package/profiles/system.yaml +1 -0
  224. package/src/command-modules.ts +0 -2
  225. package/src/config/forge-config.ts +16 -11
  226. package/src/index.ts +0 -2
  227. package/src/onboarding/create-superfolder-guard.test.ts +73 -0
  228. package/src/onboarding/create.ts +28 -2
  229. package/src/onboarding/doctor.ts +9 -96
  230. package/src/onboarding/npm-token-check.ts +3 -3
  231. package/src/profiles/stack-profile.ts +2 -2
  232. package/src/tests/evidence-consult-serialization.test.ts +202 -0
  233. package/src/tests/pinned-validate.test.ts +194 -0
  234. package/src/tests/pkg-health-self-scan.test.ts +29 -0
  235. package/src/tests/profile-flow-hooks.test.ts +1 -0
  236. package/src/tests/profile-schema.test.ts +1 -0
  237. package/src/tests/rfc-evidence-sync.test.ts +369 -0
  238. package/src/tests/skill-agents-sync.test.ts +192 -0
  239. package/src/tests/stack-profile.test.ts +1 -0
  240. package/src/types.ts +2 -2
  241. package/src/utils/hash.ts +5 -0
  242. package/src/utils/lockfile.ts +78 -0
  243. package/src/utils/verifier-git.ts +53 -5
  244. package/dist/os/core/handlers/forge-autonomy-validate.d.ts +0 -25
  245. package/dist/os/core/handlers/forge-autonomy-validate.d.ts.map +0 -1
  246. package/dist/os/core/handlers/forge-autonomy-validate.js +0 -208
  247. package/dist/os/core/handlers/forge-autonomy-validate.js.map +0 -1
  248. package/dist/os/mission/handlers/archive.d.ts +0 -4
  249. package/dist/os/mission/handlers/archive.d.ts.map +0 -1
  250. package/dist/os/mission/handlers/archive.js +0 -587
  251. package/dist/os/mission/handlers/archive.js.map +0 -1
  252. package/dist/os/mission/importer-block.d.ts +0 -19
  253. package/dist/os/mission/importer-block.d.ts.map +0 -1
  254. package/dist/os/mission/importer-block.js +0 -124
  255. package/dist/os/mission/importer-block.js.map +0 -1
  256. package/dist/os/mission/index.d.ts +0 -2
  257. package/dist/os/mission/index.d.ts.map +0 -1
  258. package/dist/os/mission/index.js +0 -15
  259. package/dist/os/mission/index.js.map +0 -1
  260. package/dist/os/mission/lockfile.d.ts.map +0 -1
  261. package/dist/os/mission/lockfile.js +0 -138
  262. package/dist/os/mission/lockfile.js.map +0 -1
  263. package/dist/os/mission/mission.module.d.ts +0 -3
  264. package/dist/os/mission/mission.module.d.ts.map +0 -1
  265. package/dist/os/mission/mission.module.js +0 -63
  266. package/dist/os/mission/mission.module.js.map +0 -1
  267. package/dist/os/mission/open-missions.d.ts.map +0 -1
  268. package/dist/os/mission/open-missions.js +0 -42
  269. package/dist/os/mission/open-missions.js.map +0 -1
  270. package/dist/os/mission/types.d.ts +0 -23
  271. package/dist/os/mission/types.d.ts.map +0 -1
  272. package/dist/os/mission/types.js +0 -19
  273. package/dist/os/mission/types.js.map +0 -1
  274. package/dist/os/werkstatt/handlers/lock.d.ts +0 -10
  275. package/dist/os/werkstatt/handlers/lock.d.ts.map +0 -1
  276. package/dist/os/werkstatt/handlers/lock.js +0 -153
  277. package/dist/os/werkstatt/handlers/lock.js.map +0 -1
  278. package/dist/os/werkstatt/handlers/schema.d.ts +0 -33
  279. package/dist/os/werkstatt/handlers/schema.d.ts.map +0 -1
  280. package/dist/os/werkstatt/handlers/schema.js +0 -42
  281. package/dist/os/werkstatt/handlers/schema.js.map +0 -1
  282. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts +0 -15
  283. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts.map +0 -1
  284. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js +0 -171
  285. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js.map +0 -1
  286. package/dist/os/werkstatt/handlers/werkstatt-lock-status.d.ts +0 -18
  287. package/dist/os/werkstatt/handlers/werkstatt-lock-status.d.ts.map +0 -1
  288. package/dist/os/werkstatt/handlers/werkstatt-lock-status.js +0 -51
  289. package/dist/os/werkstatt/handlers/werkstatt-lock-status.js.map +0 -1
  290. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts +0 -11
  291. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts.map +0 -1
  292. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js +0 -86
  293. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js.map +0 -1
  294. package/dist/os/werkstatt/handlers/workspace-deps.d.ts +0 -12
  295. package/dist/os/werkstatt/handlers/workspace-deps.d.ts.map +0 -1
  296. package/dist/os/werkstatt/handlers/workspace-deps.js +0 -42
  297. package/dist/os/werkstatt/handlers/workspace-deps.js.map +0 -1
  298. package/dist/os/werkstatt/index.d.ts +0 -7
  299. package/dist/os/werkstatt/index.d.ts.map +0 -1
  300. package/dist/os/werkstatt/index.js +0 -18
  301. package/dist/os/werkstatt/index.js.map +0 -1
  302. package/dist/os/werkstatt/werkstatt.module.d.ts +0 -3
  303. package/dist/os/werkstatt/werkstatt.module.d.ts.map +0 -1
  304. package/dist/os/werkstatt/werkstatt.module.js +0 -91
  305. package/dist/os/werkstatt/werkstatt.module.js.map +0 -1
  306. package/os/core/handlers/forge-autonomy-validate.ts +0 -276
  307. package/os/correctness/gate/trust-boundary-cx19.test.ts +0 -514
  308. package/os/mission/handlers/archive.test.ts +0 -764
  309. package/os/mission/handlers/archive.ts +0 -719
  310. package/os/mission/handlers/ship-inflight-degraded.test.ts +0 -105
  311. package/os/mission/importer-block.ts +0 -119
  312. package/os/mission/index.ts +0 -15
  313. package/os/mission/lockfile.ts +0 -152
  314. package/os/mission/mission.module.ts +0 -68
  315. package/os/mission/open-missions.ts +0 -50
  316. package/os/mission/types.ts +0 -42
  317. package/os/werkstatt/handlers/lock.ts +0 -168
  318. package/os/werkstatt/handlers/schema.ts +0 -47
  319. package/os/werkstatt/handlers/werkstatt-lock-recover.ts +0 -206
  320. package/os/werkstatt/handlers/werkstatt-lock-status.ts +0 -82
  321. package/os/werkstatt/handlers/werkstatt-operation-validate.ts +0 -112
  322. package/os/werkstatt/handlers/workspace-deps.ts +0 -56
  323. package/os/werkstatt/index.ts +0 -39
  324. package/os/werkstatt/werkstatt.module.ts +0 -95
  325. package/src/tests/doctor-autonomy.test.ts +0 -246
  326. package/src/tests/forge-autonomy-validate.test.ts +0 -159
  327. package/src/tests/werkstatt-lock.test.ts +0 -357
@@ -0,0 +1,339 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>RFC-1643: flow.push honors a committed review baseline —
4
+ `push.verifierReviewedThrough: <full sha>` read from forge.yaml at the
5
+ digest-reviewed `refs/heads/develop` tip. Trailer commits that are
6
+ ancestors of a usable baseline (and the integrate-generated weakening
7
+ record of a baseline-only bump) stop triggering FLOW-PUSH-08 but stay
8
+ listed; FLOW-PUSH-17 makes every exemption visible. Worktree, session-HEAD
9
+ and shadow-ref declarations, malformed/unknown/tag/non-ancestor values,
10
+ pseudo-hits and planted tracking refs (CX-82) exempt nothing.</purpose>
11
+ <non-goals>
12
+ <item>Never touches the enclosing repository — all fixtures are mkdtemp repos.</item>
13
+ <item>No publication coverage — the scan runs before the extract path.</item>
14
+ </non-goals>
15
+ </MODULE_CONTRACT>
16
+ */
17
+
18
+ import { rm, writeFile } from "node:fs/promises";
19
+ import { join } from "node:path";
20
+
21
+ import { afterEach, describe, expect, it } from "vitest";
22
+
23
+ import { ambientIo } from "../../../src/utils/io.ts";
24
+ import { collectDigest } from "../digest.ts";
25
+ import { pushFlow, type FlowPushData } from "../handlers/flow-push.ts";
26
+ import { gitExec, initRepoWithOrigin } from "./helpers.ts";
27
+
28
+ const dirs: string[] = [];
29
+ afterEach(async () => {
30
+ for (const dir of dirs.splice(0)) {
31
+ await rm(dir, { recursive: true, force: true });
32
+ }
33
+ }, 20_000);
34
+
35
+ async function head(repo: string, rev = "HEAD"): Promise<string> {
36
+ return (await gitExec(repo, ["rev-parse", rev])).stdout.trim();
37
+ }
38
+
39
+ async function trailerCommit(repo: string, file: string, trailer: string): Promise<string> {
40
+ await writeFile(join(repo, file), `${file}\n`);
41
+ await gitExec(repo, ["add", file]);
42
+ await gitExec(repo, ["commit", "-qm", `session work\n\n${trailer}: yes`]);
43
+ return head(repo);
44
+ }
45
+
46
+ function forgeYaml(originUrl: string, extra: string): string {
47
+ return `schema: "forge/workspace@1"\npush:\n expectedRemote: ${JSON.stringify(originUrl)}\n${extra}`;
48
+ }
49
+
50
+ /** Write (and by default commit) forge.yaml declaring `line` under push. */
51
+ async function declare(
52
+ repo: string,
53
+ originUrl: string,
54
+ line: string,
55
+ commit = true,
56
+ ): Promise<string> {
57
+ await writeFile(join(repo, "forge.yaml"), forgeYaml(originUrl, line ? ` ${line}\n` : ""));
58
+ if (!commit) return "";
59
+ await gitExec(repo, ["add", "forge.yaml"]);
60
+ await gitExec(repo, ["commit", "-qm", "chore: move review baseline"]);
61
+ return head(repo);
62
+ }
63
+
64
+ async function dryPush(repo: string): Promise<FlowPushData> {
65
+ const digest = await collectDigest(repo, ambientIo, { fetch: false });
66
+ return pushFlow(repo, ambientIo, { digest: digest.digestId, dryRun: true });
67
+ }
68
+
69
+ const ids = (d: FlowPushData) => d.diagnostics.map((x) => x.ruleId);
70
+
71
+ describe("flow.push committed review baseline (RFC-1643)", () => {
72
+ it("AC-1/AC-2/AC-3: ancestors of the baseline stop no push, stay listed, and FLOW-PUSH-17 names the bump", async () => {
73
+ const { repo, originUrl } = await initRepoWithOrigin(dirs, { prefix: "rfc1643-" });
74
+ const t1 = await trailerCommit(repo, "a.txt", "X-Verifier-Report");
75
+ const bump = await declare(repo, originUrl, `verifierReviewedThrough: "${t1}"`);
76
+ const data = await dryPush(repo);
77
+ expect(ids(data)).not.toContain("FLOW-PUSH-08");
78
+ expect(data.verifierTrailerCommits?.map((h) => h.sha)).toEqual([t1]);
79
+ expect(data.verifierReviewBaseline).toMatchObject({
80
+ status: "applied",
81
+ declared: t1,
82
+ exempted: [t1],
83
+ newlyExempted: [t1],
84
+ bumpedBy: bump,
85
+ });
86
+ expect(data.verifierReviewBaseline?.changes).toEqual([
87
+ { commit: bump, from: "(absent)", to: t1 },
88
+ ]);
89
+ const w = data.diagnostics.find((x) => x.ruleId === "FLOW-PUSH-17");
90
+ expect(w?.severity).toBe("warning");
91
+ expect(w?.message).toContain(t1.slice(0, 9));
92
+ expect(w?.message).toContain(bump.slice(0, 9));
93
+ }, 90_000);
94
+
95
+ it("AC-4: a trailer commit after the baseline still stops, naming only it", async () => {
96
+ const { repo, originUrl } = await initRepoWithOrigin(dirs, { prefix: "rfc1643-" });
97
+ const t1 = await trailerCommit(repo, "a.txt", "X-Verifier-Report");
98
+ await declare(repo, originUrl, `verifierReviewedThrough: "${t1}"`);
99
+ const t2 = await trailerCommit(repo, "b.txt", "X-Policy-Digest");
100
+ const data = await dryPush(repo);
101
+ const stop = data.diagnostics.find((x) => x.ruleId === "FLOW-PUSH-08");
102
+ expect(stop?.message).toContain(t2.slice(0, 9));
103
+ expect(stop?.message).not.toContain(t1.slice(0, 9));
104
+ expect(data.verifierTrailerCommits?.map((h) => h.sha).sort()).toEqual([t1, t2].sort());
105
+ }, 90_000);
106
+
107
+ it("AC-4: an unverifiable pseudo-hit inside the baseline's ancestry still stops", async () => {
108
+ const { repo, originUrl } = await initRepoWithOrigin(dirs, { prefix: "rfc1643-" });
109
+ await writeFile(join(repo, "enc.txt"), "x\n");
110
+ await gitExec(repo, ["add", "enc.txt"]);
111
+ await gitExec(repo, ["-c", "i18n.commitEncoding=ISO-8859-1", "commit", "-qm", "encoded"]);
112
+ const enc = await head(repo);
113
+ await declare(repo, originUrl, `verifierReviewedThrough: "${enc}"`);
114
+ const data = await dryPush(repo);
115
+ expect(data.verifierTrailerCommits?.find((h) => h.sha === enc)?.trailers.join()).toContain(
116
+ "x-unverifiable-encoding",
117
+ );
118
+ expect(data.diagnostics.find((x) => x.ruleId === "FLOW-PUSH-08")?.message).toContain(
119
+ enc.slice(0, 9),
120
+ );
121
+ }, 90_000);
122
+
123
+ it("AC-5: a worktree-only baseline exempts nothing (CX-34)", async () => {
124
+ const { repo, originUrl } = await initRepoWithOrigin(dirs, { prefix: "rfc1643-" });
125
+ const t1 = await trailerCommit(repo, "a.txt", "X-Verifier-Report");
126
+ await declare(repo, originUrl, `verifierReviewedThrough: "${t1}"`, false);
127
+ const data = await dryPush(repo);
128
+ expect(ids(data)).toContain("FLOW-PUSH-08");
129
+ }, 90_000);
130
+
131
+ it("AC-5: a baseline or opt-out on an unintegrated session HEAD exempts nothing", async () => {
132
+ const { repo, originUrl } = await initRepoWithOrigin(dirs, { prefix: "rfc1643-" });
133
+ const t1 = await trailerCommit(repo, "a.txt", "X-Verifier-Report");
134
+ await gitExec(repo, ["switch", "-qc", "auto/session-x"]);
135
+ await declare(
136
+ repo,
137
+ originUrl,
138
+ `verifierReviewedThrough: "${t1}"\n requireVerifierReview: false`,
139
+ );
140
+ const data = await dryPush(repo);
141
+ expect(ids(data)).toContain("FLOW-PUSH-08");
142
+ expect(data.verifierReviewBaseline?.status).toBe("absent");
143
+ }, 90_000);
144
+
145
+ it("AC-5: a shadow refs/tags/develop carrying a baseline exempts nothing", async () => {
146
+ const { repo, originUrl } = await initRepoWithOrigin(dirs, { prefix: "rfc1643-" });
147
+ const t1 = await trailerCommit(repo, "a.txt", "X-Verifier-Report");
148
+ await gitExec(repo, ["switch", "-qc", "side"]);
149
+ const shadow = await declare(repo, originUrl, `verifierReviewedThrough: "${t1}"`);
150
+ await gitExec(repo, ["tag", "develop", shadow]);
151
+ await gitExec(repo, ["switch", "-q", "refs/heads/develop"]);
152
+ const digest = await collectDigest(repo, ambientIo, { fetch: false });
153
+ expect(digest.develop.local).toBe(t1);
154
+ const data = await pushFlow(repo, ambientIo, { digest: digest.digestId, dryRun: true });
155
+ expect(ids(data)).toContain("FLOW-PUSH-08");
156
+ }, 90_000);
157
+
158
+ describe("AC-6/AC-7: unusable baselines exempt nothing and FLOW-PUSH-16 names the reason", () => {
159
+ const cases: Array<{
160
+ name: string;
161
+ value: (r: { repo: string; t1: string }) => Promise<string>;
162
+ reason: string;
163
+ }> = [
164
+ {
165
+ name: "abbreviated sha",
166
+ value: async ({ t1 }) => `"${t1.slice(0, 12)}"`,
167
+ reason: "malformed",
168
+ },
169
+ { name: "ref name", value: async () => `"develop"`, reason: "malformed" },
170
+ {
171
+ name: "upper-case sha",
172
+ value: async ({ t1 }) => `"${t1.toUpperCase()}"`,
173
+ reason: "malformed",
174
+ },
175
+ { name: "unquoted numeric", value: async () => "1234567", reason: "malformed" },
176
+ { name: "unknown sha", value: async () => `"${"ab".repeat(20)}"`, reason: "unknown" },
177
+ {
178
+ name: "tag-object sha",
179
+ value: async ({ repo, t1 }) => {
180
+ await gitExec(repo, ["tag", "-a", "reviewed", "-m", "r", t1]);
181
+ return `"${await head(repo, "refs/tags/reviewed")}"`;
182
+ },
183
+ reason: "not-a-commit",
184
+ },
185
+ {
186
+ name: "non-ancestor commit",
187
+ value: async ({ repo }) => {
188
+ await gitExec(repo, ["switch", "-qc", "side"]);
189
+ await writeFile(join(repo, "side.txt"), "s\n");
190
+ await gitExec(repo, ["add", "side.txt"]);
191
+ await gitExec(repo, ["commit", "-qm", "side"]);
192
+ const side = await head(repo);
193
+ await gitExec(repo, ["switch", "-q", "develop"]);
194
+ return `"${side}"`;
195
+ },
196
+ reason: "not-ancestor",
197
+ },
198
+ ];
199
+ it.each(cases)(
200
+ "$name",
201
+ async ({ value, reason }) => {
202
+ const { repo, originUrl } = await initRepoWithOrigin(dirs, { prefix: "rfc1643-" });
203
+ const t1 = await trailerCommit(repo, "a.txt", "X-Verifier-Report");
204
+ await declare(repo, originUrl, `verifierReviewedThrough: ${await value({ repo, t1 })}`);
205
+ const data = await dryPush(repo);
206
+ expect(ids(data)).toContain("FLOW-PUSH-08");
207
+ expect(data.verifierReviewBaseline?.exempted).toEqual([]);
208
+ const w = data.diagnostics.find((x) => x.ruleId === "FLOW-PUSH-16");
209
+ expect(w?.severity).toBe("warning");
210
+ expect(w?.message).toContain(`(${reason})`);
211
+ },
212
+ 90_000,
213
+ );
214
+ });
215
+
216
+ it("AC-8: a planted origin/develop past the baseline cannot hide a trailer commit (CX-82)", async () => {
217
+ const { repo, originUrl } = await initRepoWithOrigin(dirs, { prefix: "rfc1643-" });
218
+ const t1 = await trailerCommit(repo, "a.txt", "X-Verifier-Report");
219
+ await declare(repo, originUrl, `verifierReviewedThrough: "${t1}"`);
220
+ const t2 = await trailerCommit(repo, "b.txt", "X-Expectation-Origin");
221
+ await gitExec(repo, ["update-ref", "refs/remotes/origin/develop", t2]);
222
+ const data = await dryPush(repo);
223
+ expect(data.diagnostics.find((x) => x.ruleId === "FLOW-PUSH-08")?.message).toContain(
224
+ t2.slice(0, 9),
225
+ );
226
+ }, 90_000);
227
+
228
+ it("AC-9: the empty weakening record of a baseline-only bump is exempt", async () => {
229
+ const { repo, originUrl } = await initRepoWithOrigin(dirs, { prefix: "rfc1643-" });
230
+ const t1 = await trailerCommit(repo, "a.txt", "X-Verifier-Report");
231
+ await declare(repo, originUrl, `verifierReviewedThrough: "${t1}"`);
232
+ await gitExec(repo, [
233
+ "commit",
234
+ "-q",
235
+ "--allow-empty",
236
+ "-m",
237
+ "flow: accept correctness weakening\n\nX-Correctness-Weakening: policy-key push",
238
+ ]);
239
+ const w = await head(repo);
240
+ const data = await dryPush(repo);
241
+ expect(ids(data)).not.toContain("FLOW-PUSH-08");
242
+ expect(data.verifierReviewBaseline?.exempted.sort()).toEqual([t1, w].sort());
243
+ expect(data.verifierReviewBaseline?.newlyExempted.sort()).toEqual([t1, w].sort());
244
+ }, 90_000);
245
+
246
+ it("AC-9: a weakening record over a bump that also changes other files still stops", async () => {
247
+ const { repo, originUrl } = await initRepoWithOrigin(dirs, { prefix: "rfc1643-" });
248
+ const t1 = await trailerCommit(repo, "a.txt", "X-Verifier-Report");
249
+ await writeFile(join(repo, "smuggled.txt"), "payload\n");
250
+ await gitExec(repo, ["add", "smuggled.txt"]);
251
+ await declare(repo, originUrl, `verifierReviewedThrough: "${t1}"`);
252
+ await gitExec(repo, [
253
+ "commit",
254
+ "-q",
255
+ "--allow-empty",
256
+ "-m",
257
+ "flow: accept correctness weakening\n\nX-Correctness-Weakening: policy-key push",
258
+ ]);
259
+ const w = await head(repo);
260
+ const data = await dryPush(repo);
261
+ expect(data.diagnostics.find((x) => x.ruleId === "FLOW-PUSH-08")?.message).toContain(
262
+ w.slice(0, 9),
263
+ );
264
+ }, 90_000);
265
+
266
+ it("FLOW-PUSH-17: a decoy comment or a re-quote is not a baseline change (review E1/E3)", async () => {
267
+ const { repo, originUrl } = await initRepoWithOrigin(dirs, { prefix: "rfc1643-" });
268
+ const t1 = await trailerCommit(repo, "a.txt", "X-Verifier-Report");
269
+ const bump = await declare(repo, originUrl, `verifierReviewedThrough: "${t1}"`);
270
+ await declare(repo, originUrl, `verifierReviewedThrough: '${t1}'`);
271
+ await declare(
272
+ repo,
273
+ originUrl,
274
+ `verifierReviewedThrough: '${t1}'\n # verifierReviewedThrough: operator-reviewed`,
275
+ );
276
+ const data = await dryPush(repo);
277
+ expect(data.verifierReviewBaseline?.bumpedBy).toBe(bump);
278
+ expect(data.verifierReviewBaseline?.changes.map((c) => c.commit)).toEqual([bump]);
279
+ expect(data.verifierReviewBaseline?.newlyExempted).toEqual([t1]);
280
+ }, 90_000);
281
+
282
+ it("FLOW-PUSH-17: a chain of bumps lists every change and cannot hide newly exempted hits (review E4)", async () => {
283
+ const { repo, originUrl } = await initRepoWithOrigin(dirs, { prefix: "rfc1643-" });
284
+ const t1 = await trailerCommit(repo, "a.txt", "X-Verifier-Report");
285
+ const p1 = await declare(repo, originUrl, `verifierReviewedThrough: "${t1}"`);
286
+ const p2 = await declare(repo, originUrl, `verifierReviewedThrough: "${p1}"`);
287
+ const data = await dryPush(repo);
288
+ expect(ids(data)).not.toContain("FLOW-PUSH-08");
289
+ expect(data.verifierReviewBaseline?.changes).toEqual([
290
+ { commit: p2, from: t1, to: p1 },
291
+ { commit: p1, from: "(absent)", to: t1 },
292
+ ]);
293
+ expect(data.verifierReviewBaseline?.newlyExempted).toEqual([t1]);
294
+ const w = data.diagnostics.find((x) => x.ruleId === "FLOW-PUSH-17")?.message ?? "";
295
+ expect(w).toContain(p1.slice(0, 9));
296
+ expect(w).toContain(p2.slice(0, 9));
297
+ }, 90_000);
298
+
299
+ it("AC-5: a shadow refs/develop carrying a baseline exempts nothing", async () => {
300
+ const { repo, originUrl } = await initRepoWithOrigin(dirs, { prefix: "rfc1643-" });
301
+ const t1 = await trailerCommit(repo, "a.txt", "X-Verifier-Report");
302
+ await gitExec(repo, ["switch", "-qc", "side"]);
303
+ const shadow = await declare(repo, originUrl, `verifierReviewedThrough: "${t1}"`);
304
+ await gitExec(repo, ["update-ref", "refs/develop", shadow]);
305
+ await gitExec(repo, ["switch", "-q", "refs/heads/develop"]);
306
+ const digest = await collectDigest(repo, ambientIo, { fetch: false });
307
+ expect(digest.develop.local).toBe(t1);
308
+ const data = await pushFlow(repo, ambientIo, { digest: digest.digestId, dryRun: true });
309
+ expect(ids(data)).toContain("FLOW-PUSH-08");
310
+ }, 90_000);
311
+
312
+ it("T9 residual: a develop moved past integrate still surfaces the bump in FLOW-PUSH-17 (review E2)", async () => {
313
+ const { repo, originUrl } = await initRepoWithOrigin(dirs, { prefix: "rfc1643-" });
314
+ await declare(repo, originUrl, "");
315
+ await writeFile(
316
+ join(repo, "forge.yaml"),
317
+ forgeYaml(originUrl, "") + "policy:\n mutable: []\n",
318
+ );
319
+ await gitExec(repo, ["commit", "-qam", "declare policy"]);
320
+ await gitExec(repo, ["switch", "-qc", "auto/session-x"]);
321
+ const t1 = await trailerCommit(repo, "a.txt", "X-Verifier-Report");
322
+ await writeFile(
323
+ join(repo, "forge.yaml"),
324
+ forgeYaml(originUrl, ` verifierReviewedThrough: "${t1}"\n`) + "policy:\n mutable: []\n",
325
+ );
326
+ await gitExec(repo, ["commit", "-qam", "self-exempt"]);
327
+ const bump = await head(repo);
328
+ await gitExec(repo, ["update-ref", "refs/heads/develop", bump]);
329
+ await gitExec(repo, ["switch", "-q", "develop"]);
330
+ const data = await dryPush(repo);
331
+ // Accepted residual (RFC-1643 T9, option a): no stop, but never silent.
332
+ expect(ids(data)).not.toContain("FLOW-PUSH-08");
333
+ expect(data.verifierReviewBaseline?.bumpedBy).toBe(bump);
334
+ expect(data.verifierReviewBaseline?.newlyExempted).toEqual([t1]);
335
+ expect(data.diagnostics.find((x) => x.ruleId === "FLOW-PUSH-17")?.message).toContain(
336
+ bump.slice(0, 9),
337
+ );
338
+ }, 90_000);
339
+ });
@@ -0,0 +1,134 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>F-0394: flow.push's verifier-trailer scan reads the whole local
4
+ branch in batched judged consults instead of two judged consults per
5
+ commit — and the batch never narrows the scan: a framing it cannot prove
6
+ (\x1e inside a subject or trailer value) falls back to the exact
7
+ per-commit reads, and a planted tracking ref still cannot hide a trailer
8
+ commit (CX-82).</purpose>
9
+ <non-goals>
10
+ <item>Never touches the enclosing repository — all fixtures are mkdtemp repos.</item>
11
+ </non-goals>
12
+ </MODULE_CONTRACT>
13
+ */
14
+
15
+ import { rm, writeFile } from "node:fs/promises";
16
+ import { join } from "node:path";
17
+
18
+ import { afterEach, describe, expect, it } from "vitest";
19
+
20
+ import { ambientIo } from "../../../src/utils/io.ts";
21
+ import { collectDigest } from "../digest.ts";
22
+ import { consultProbe } from "../git.ts";
23
+ import { batchedCommitReads, pushFlow } from "../handlers/flow-push.ts";
24
+ import { gitExec, initRepoWithOrigin } from "./helpers.ts";
25
+
26
+ const dirs: string[] = [];
27
+ afterEach(async () => {
28
+ consultProbe.current = null;
29
+ for (const dir of dirs.splice(0)) {
30
+ await rm(dir, { recursive: true, force: true });
31
+ }
32
+ }, 20_000);
33
+
34
+ async function commit(repo: string, file: string, message: string): Promise<string> {
35
+ await writeFile(join(repo, file), `${file}\n`);
36
+ await gitExec(repo, ["add", file]);
37
+ const r = await gitExec(repo, ["commit", "-qm", message]);
38
+ if (r.exitCode !== 0) throw new Error(`commit failed: ${r.stderr}`);
39
+ return (await gitExec(repo, ["rev-parse", "HEAD"])).stdout.trim();
40
+ }
41
+
42
+ async function revList(repo: string, range: string): Promise<string[]> {
43
+ return (await gitExec(repo, ["rev-list", range])).stdout.split("\n").filter(Boolean);
44
+ }
45
+
46
+ describe("flow.push batched verifier-trailer scan (F-0394)", () => {
47
+ it("batched reads are byte-identical to the per-commit reads, merges included", async () => {
48
+ const { repo } = await initRepoWithOrigin(dirs, { prefix: "flow-push-vb-" });
49
+ await commit(repo, "a.txt", "plain work");
50
+ await commit(repo, "b.txt", "session work\n\nX-Verifier-Report: r.yaml\nX-RFC: RFC-1");
51
+ await commit(repo, "c.txt", "X-Policy-Digest: subject-shaped");
52
+ await gitExec(repo, ["checkout", "-q", "-b", "side", "HEAD~2"]);
53
+ await commit(repo, "d.txt", "side work\n\nX-Expectation-Origin: independent-verifier");
54
+ await gitExec(repo, ["checkout", "-q", "main"]);
55
+ const m = await gitExec(repo, ["merge", "-q", "--no-ff", "-m", "merge side", "side"]);
56
+ expect(m.exitCode).toBe(0);
57
+ const shas = await revList(repo, "main");
58
+ const batched = await batchedCommitReads(repo, "main", shas);
59
+ expect(batched).not.toBeNull();
60
+ expect(batched!.size).toBe(shas.length);
61
+ for (const sha of shas) {
62
+ const trailers = await gitExec(repo, [
63
+ "log",
64
+ "-1",
65
+ "--format=%(trailers:only,separator=%x00)%x00%e",
66
+ sha,
67
+ ]);
68
+ const subject = await gitExec(repo, ["log", "-1", "--format=%s", sha]);
69
+ expect(batched!.get(sha)!.trailers).toBe(trailers.stdout);
70
+ expect(batched!.get(sha)!.subject).toBe(subject.stdout);
71
+ }
72
+ }, 60_000);
73
+
74
+ it.each([
75
+ ["a \\x1e inside the subject", "work\x1e0000000000000000000000000000000000000000"],
76
+ ["a \\x1e inside a trailer value", "work\n\nX-Note: a\x1eb"],
77
+ ])(
78
+ "refuses the batch on %s (CX-33 framing) instead of trusting it",
79
+ async (_label, message) => {
80
+ const { repo } = await initRepoWithOrigin(dirs, { prefix: "flow-push-vb-" });
81
+ await commit(repo, "a.txt", message);
82
+ const shas = await revList(repo, "HEAD");
83
+ expect(await batchedCommitReads(repo, "HEAD", shas)).toBeNull();
84
+ },
85
+ 60_000,
86
+ );
87
+
88
+ it("a \\x1e-framed commit still refuses FLOW-PUSH-08 through the per-commit fallback", async () => {
89
+ const { repo } = await initRepoWithOrigin(dirs, { prefix: "flow-push-vb-" });
90
+ const sha = await commit(repo, "a.txt", "session work\x1e\n\nX-Verifier-Report: r.yaml");
91
+ const digest = await collectDigest(repo, ambientIo, { fetch: false });
92
+ const data = await pushFlow(repo, ambientIo, { digest: digest.digestId, dryRun: true });
93
+ expect(data.diagnostics[0]?.ruleId).toBe("FLOW-PUSH-08");
94
+ expect(data.verifierTrailerCommits?.map((h) => h.sha)).toContain(sha);
95
+ }, 60_000);
96
+
97
+ it("CX-82: a tracking ref planted at the trailer commit does not hide it", async () => {
98
+ const { repo } = await initRepoWithOrigin(dirs, { prefix: "flow-push-vb-" });
99
+ const sha = await commit(repo, "a.txt", "session work\n\nX-Expectation-Origin: verifier");
100
+ await commit(repo, "b.txt", "later plain work");
101
+ // The session plants origin/* at (and past) the trailer commit — a
102
+ // `remote..local` range would exclude it.
103
+ await gitExec(repo, ["update-ref", "refs/remotes/origin/main", "HEAD"]);
104
+ await gitExec(repo, ["update-ref", "refs/remotes/origin/develop", "HEAD"]);
105
+ await gitExec(repo, ["update-ref", "refs/heads/develop", "HEAD"]);
106
+ const digest = await collectDigest(repo, ambientIo, { fetch: false });
107
+ const data = await pushFlow(repo, ambientIo, { digest: digest.digestId, dryRun: true });
108
+ expect(data.pushed).toBe(false);
109
+ expect(data.diagnostics[0]?.ruleId).toBe("FLOW-PUSH-08");
110
+ expect(data.verifierTrailerCommits?.map((h) => h.sha)).toContain(sha);
111
+ }, 60_000);
112
+
113
+ it("scans N commits without per-commit consults", async () => {
114
+ const { repo } = await initRepoWithOrigin(dirs, { prefix: "flow-push-vb-" });
115
+ for (let i = 0; i < 25; i++) await commit(repo, `f${i}.txt`, `plain work ${i}`);
116
+ const digest = await collectDigest(repo, ambientIo, { fetch: false });
117
+ const perCommit: string[][] = [];
118
+ const batched: string[][] = [];
119
+ consultProbe.current = (argv, channel) => {
120
+ if (channel !== "evidence" || argv[0] !== "log") return;
121
+ if (argv[1] === "-1") perCommit.push([...argv]);
122
+ else if (argv[1]?.startsWith("--format=%x1e%H%x00")) batched.push([...argv]);
123
+ };
124
+ const data = await pushFlow(repo, ambientIo, { digest: digest.digestId, dryRun: true });
125
+ consultProbe.current = null;
126
+ expect(data.diagnostics).toEqual([]);
127
+ expect(data.verifierTrailerCommits).toEqual([]);
128
+ expect(perCommit.filter((a) => a.some((t) => t.includes("trailers:only")))).toEqual([]);
129
+ expect(perCommit.filter((a) => a.includes("--format=%s"))).toEqual([]);
130
+ // Two batched reads per distinct range — develop (25 commits ahead)
131
+ // and main (the seed) — the consult count no longer scales with N.
132
+ expect(batched.length).toBe(4);
133
+ }, 60_000);
134
+ });
@@ -0,0 +1,136 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>Release-line discovery tests (RFC-1488, AC-2 foundation): temp
4
+ workspaces exercise the pnpm-workspace glob expansion, the
5
+ `extract.config.yaml` publishability marker, negated globs and the
6
+ FLOW-VER-02 basename collision; a read-only pass over the real werkstatt
7
+ root pins the expected line set.</purpose>
8
+ <non-goals>
9
+ <item>No tag or version math — release-tags/release-level tests own those.</item>
10
+ </non-goals>
11
+ </MODULE_CONTRACT>
12
+ <CHANGE_SUMMARY>
13
+ <item>RFC-1488: step 1 — release-lines discovery tests</item>
14
+ <item>RFC-1488: step 1 — semver helper + release-line discovery (extract.config.yaml workspace globs)</item>
15
+ <item>RFC-1540: count the intake-validator release line in the werkstatt root discovery test</item>
16
+ </CHANGE_SUMMARY>
17
+ */
18
+
19
+ import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
20
+ import { tmpdir } from "node:os";
21
+ import { dirname, join } from "node:path";
22
+ import { fileURLToPath } from "node:url";
23
+
24
+ import { afterEach, describe, expect, it } from "vitest";
25
+
26
+ import { ambientIo } from "../../../src/utils/io.ts";
27
+ import { discoverReleaseLines } from "../release-lines.ts";
28
+
29
+ const dirs: string[] = [];
30
+
31
+ afterEach(async () => {
32
+ for (const dir of dirs.splice(0)) {
33
+ await rm(dir, { recursive: true, force: true });
34
+ }
35
+ });
36
+
37
+ async function tempRepo(): Promise<string> {
38
+ const dir = await mkdtemp(join(tmpdir(), "flow-lines-"));
39
+ dirs.push(dir);
40
+ return dir;
41
+ }
42
+
43
+ async function touch(repo: string, rel: string, content = ""): Promise<void> {
44
+ await mkdir(join(repo, rel.split("/").slice(0, -1).join("/")), { recursive: true });
45
+ await writeFile(join(repo, rel), content);
46
+ }
47
+
48
+ describe("discoverReleaseLines", () => {
49
+ it("reports the repo line plus every extract.config.yaml workspace dir", async () => {
50
+ const repo = await tempRepo();
51
+ await touch(repo, "package.json", '{ "version": "1.0.0" }\n');
52
+ await touch(
53
+ repo,
54
+ "pnpm-workspace.yaml",
55
+ "packages:\n - 'packages/*'\n - 'missions/*/workpiece'\n",
56
+ );
57
+ await touch(repo, "packages/forge/package.json", '{ "version": "9.0.0" }\n');
58
+ await touch(repo, "packages/forge/extract.config.yaml", "forgePlugin: true\n");
59
+ await touch(repo, "packages/pbp/package.json", '{ "version": "2.1.0" }\n');
60
+ await touch(repo, "packages/pbp/extract.config.yaml", "forgePlugin: false\n");
61
+ await touch(repo, "packages/no-extract/package.json", '{ "version": "0.0.1" }\n');
62
+ await touch(repo, "missions/m1/workpiece/src/index.ts", "// workpiece\n");
63
+
64
+ const { lines, diagnostics } = await discoverReleaseLines(repo, ambientIo);
65
+ expect(diagnostics).toEqual([]);
66
+ expect(lines.map((l) => l.id).sort()).toEqual(["forge", "pbp", "repo"]);
67
+ const forge = lines.find((l) => l.id === "forge");
68
+ expect(forge).toMatchObject({
69
+ tagPrefix: "forge@",
70
+ versionFile: "packages/forge/package.json",
71
+ paths: ["packages/forge"],
72
+ });
73
+ const repoLine = lines.find((l) => l.id === "repo");
74
+ expect(repoLine).toMatchObject({ tagPrefix: "v", versionFile: "package.json", paths: [] });
75
+ });
76
+
77
+ it("reports a null versionFile when the repo has no root package.json", async () => {
78
+ const repo = await tempRepo();
79
+ const { lines } = await discoverReleaseLines(repo, ambientIo);
80
+ expect(lines).toEqual([
81
+ { id: "repo", tagPrefix: "v", versionFile: null, paths: [] },
82
+ ]);
83
+ });
84
+
85
+ it("skips negated glob matches and node_modules", async () => {
86
+ const repo = await tempRepo();
87
+ await touch(repo, "package.json", '{ "version": "1.0.0" }\n');
88
+ await touch(
89
+ repo,
90
+ "pnpm-workspace.yaml",
91
+ "packages:\n - 'packages/*'\n - '!packages/internal'\n",
92
+ );
93
+ await touch(repo, "packages/internal/extract.config.yaml", "forgePlugin: false\n");
94
+ await touch(repo, "packages/forge/extract.config.yaml", "forgePlugin: true\n");
95
+ await touch(repo, "packages/node_modules/x/extract.config.yaml", "x: 1\n");
96
+
97
+ const { lines, diagnostics } = await discoverReleaseLines(repo, ambientIo);
98
+ expect(diagnostics).toEqual([]);
99
+ expect(lines.map((l) => l.id).sort()).toEqual(["forge", "repo"]);
100
+ });
101
+
102
+ it("refuses colliding basenames with FLOW-VER-02 naming both dirs", async () => {
103
+ const repo = await tempRepo();
104
+ await touch(repo, "package.json", '{ "version": "1.0.0" }\n');
105
+ await touch(
106
+ repo,
107
+ "pnpm-workspace.yaml",
108
+ "packages:\n - 'packages/*/x'\n - 'services/*'\n",
109
+ );
110
+ await touch(repo, "packages/a/x/extract.config.yaml", "forgePlugin: false\n");
111
+ await touch(repo, "services/x/extract.config.yaml", "forgePlugin: false\n");
112
+ await touch(repo, "services/keep/extract.config.yaml", "forgePlugin: false\n");
113
+
114
+ const { lines, diagnostics } = await discoverReleaseLines(repo, ambientIo);
115
+ const collision = diagnostics.filter((d) => d.ruleId === "FLOW-VER-02");
116
+ expect(collision).toHaveLength(1);
117
+ expect(collision[0]?.severity).toBe("error");
118
+ expect(collision[0]?.message).toContain("x");
119
+ expect(collision[0]?.message).toContain("packages/a/x");
120
+ expect(collision[0]?.message).toContain("services/x");
121
+ // The non-colliding line still lands; the collided id is absent.
122
+ expect(lines.map((l) => l.id).sort()).toEqual(["keep", "repo"]);
123
+ });
124
+
125
+ it("the real monorepo root discovers repo plus its published package lines", async () => {
126
+ const root = join(dirname(fileURLToPath(import.meta.url)), "../../../../..");
127
+ const { lines, diagnostics } = await discoverReleaseLines(root, ambientIo);
128
+ expect(diagnostics.filter((d) => d.ruleId === "FLOW-VER-02")).toEqual([]);
129
+ // v10 authoring monorepo (RFC-1649): a directory joins the release-line set
130
+ // when it carries extract.config.yaml — the publishability fact. Today that
131
+ // is packages/forge + packages/forge-typescript plus the repo line itself;
132
+ // the first-party plugin scaffolds (forge-astro, forge-repo-extract,
133
+ // forge-system) join when WP-5 makes them publishable.
134
+ expect(lines.map((l) => l.id).sort()).toEqual(["forge", "forge-typescript", "repo"]);
135
+ });
136
+ });