@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
@@ -8,7 +8,7 @@ Journal records are suppressor-only (R13-C): they can hide a tag from
8
8
  digest.tags but never mint pending/superseded publication entries, which
9
9
  stay empty by construction.</purpose>
10
10
  <non-goals>
11
- <item>No mutation — the only write is the optional git fetch of remote-tracking refs.</item>
11
+ <item>No git mutation — the only write is the RFC-1638 persisted digest record under .git/forge/digests/.</item>
12
12
  <item>No push or publish policy — handlers/flow-push.ts owns outbound execution.</item>
13
13
  </non-goals>
14
14
  </MODULE_CONTRACT>
@@ -20,55 +20,11 @@ stay empty by construction.</purpose>
20
20
  <item>tagTriggers feeds digestId — a workflow change between digest and push invalidates the quoted id; unparseable patterns warn never block.</item>
21
21
  </KEY_DECISIONS>
22
22
  <CHANGE_SUMMARY>
23
- <item>RFC-1616: close RFC-1616 r7 trust-boundary counterexamples
24
-
25
- Independent clean-context verification (round 7, candidate d2f270ad6)
26
- returned REFUTED with eleven live counterexamples against the
27
- r6-hardened evidence channel — this commit closes all nine root causes.
28
-
29
- - remote.<name>.fetch is value-judged: only the clone-default
30
- +?refs/heads/*:refs/remotes/<name>/* shape stays KEEP, because git
31
- UNIONs configured refspecs with the pinned fetch argv and a session
32
- spec writes arbitrary local refs inside the trusted fetch (CX-94).
33
- remote.<name>.tagopt|promirror|followremotehead|prunetags|
34
- skipfetchall|mirror move to REFUSE for the same reason.
35
- - Alternates/shape comment lexing is col-0 `#` only — git's parser does
36
- not treat whitespace-led `#` as a comment, so ` # forged` is a real
37
- alternates path the shape check must count (CX-95).
38
- - config reads forbid the alternate-source selectors --file/-f, --blob,
39
- --worktree (reaches config.worktree even under the disabled-extension
40
- pin), --system/--global, --default and --includes, plus the
41
- write-action spellings, on both the evidence and shared read-only
42
- tables (CX-96).
43
- - verifierGit judges fabrication argv on the runner/policy channel:
44
- @{...}, -g, --reflog, --walk-reflogs and --fork-point return
45
- EVIDENCE-REFUSED before the spawn — policy.digest --base 'HEAD@{0}'
46
- can no longer verify an unattested advance (CX-97).
47
- - --use-bitmap-index/--test-bitmap are forbidden on rev-list/log in
48
- both tables — the flag opts the trusted walk into the session-
49
- writable pack bitmap cache the commitGraph/MIDX pins closed (CX-98).
50
- - for-each-ref/show-ref/ls-remote forbid --stdin and --exclude-existing
51
- on both tables — they block on input the no-stdin spawn never
52
- supplies (CX-101).
53
- - The workflow-adoption heredoc lexer is bash-faithful: openers are
54
- scanned on the raw line before the # comment strip (quoted-#
55
- delimiters, CX-99a), bare delimiters accept digits/./- (CX-99b), and
56
- the terminator match is strict — << wants the delimiter alone, <<-/
57
- <<~ skip leading tabs only (CX-100).
58
- - Trailer scans read %e beside %(trailers): a commit declaring a
59
- non-UTF-8 encoding header recodes every trusted message read, so the
60
- digest trail and the push-time scan flag it as unverifiable and the
61
- policy attestation scan skips it (CX-102).
62
-
63
- Probe premise updates for the tightened contract: CX-61's decoy
64
- remote.origin.fetch (cx4 and cx5 R5-R1) now asserts the wholesale
65
- EVIDENCE-REFUSED plus FLOW-PUSH-13 refuse — strictly stronger than the
66
- decoy-namespace guard it replaces. The independent r7 probe file and
67
- acceptance report land in the follow-up port commit.</item>
68
- <item>RFC-1616: close RFC-1616 r12 trust-boundary counterexamples</item>
69
- <item>RFC-1616: close RFC-1616 r13 trust-boundary counterexamples</item>
70
- <item>RFC-1616: close RFC-1616 r16 trust-boundary counterexamples</item>
71
- <item>RFC-1616: close r20 counterexamples CX-173 through CX-177</item>
23
+ <item>RFC-1633: serialize evidence consults + bestEffort reader mode (RFC-1633)</item>
24
+ <item>RFC-1633: review round 1 — digest envInputs, package-wide bestEffort scan, holder command, serialized standalone preflight</item>
25
+ <item>RFC-1638: persist reviewed digests + attest pushed state by input hash</item>
26
+ <item>RFC-1638: review round 1 — payload preimage binding, fail-closed coverage scan, FLOW-PUSH-15</item>
27
+ <item>RFC-1643: committed verifier-review baseline for flow.push</item>
72
28
  <history>RFC-1491, RFC-1498, RFC-1503, RFC-1580, RFC-1616</history>
73
29
  </CHANGE_SUMMARY>
74
30
  */
@@ -78,7 +34,9 @@ import { parse as parseYaml } from "yaml";
78
34
  import { listRfcFiles, readRfcFrontmatter, rfcFileMatchesId } from "../rfc/frontmatter-io.js";
79
35
  import { EVIDENCE_REFUSED_PREFIX } from "../../src/utils/verifier-git.js";
80
36
  import { git, gitEvidence, evidencePreflight, parseGitTrailers } from "./git.js";
81
- import { commonGitDir, readJournal, readRegistry, RISK_CATEGORIES, } from "./registry.js";
37
+ import { describeEvidenceLockError, withEvidenceConsultLock } from "./evidence-lock.js";
38
+ import { LockTimeoutError } from "./locks.js";
39
+ import { commonGitDir, JOURNAL_RELATIVE_PATH, readJournal, readRegistry, RISK_CATEGORIES, } from "./registry.js";
82
40
  import { discoverReleaseLines } from "./release-lines.js";
83
41
  import { parseVersion } from "./semver.js";
84
42
  import { listLineTags } from "./release-tags.js";
@@ -320,7 +278,9 @@ async function rfcFacts(repoRoot, ids) {
320
278
  }
321
279
  /** `git show <ref>:<path>` → parsed JSON, null when absent/unparseable. */
322
280
  async function jsonAtRef(repoRoot, io, ref, path) {
323
- const result = await gitEvidence(repoRoot, ["show", `${ref}:${path}`]);
281
+ const result = await gitEvidence(repoRoot, ["show", `${ref}:${path}`], {
282
+ mode: "bestEffort",
283
+ });
324
284
  if (result.exitCode !== 0)
325
285
  return null;
326
286
  try {
@@ -383,7 +343,9 @@ async function classifyItem(repoRoot, io, base, tip, rfcs, specsDir, invariantsF
383
343
  // files a later commit reverted). A refused names read must never
384
344
  // degrade to files=[] — that silently narrows the classification
385
345
  // (CX-155: a contract-touching item labelled "other").
386
- const names = await gitEvidence(repoRoot, ["diff", "--name-only", base, tip]);
346
+ const names = await gitEvidence(repoRoot, ["diff", "--name-only", base, tip], {
347
+ mode: "bestEffort",
348
+ });
387
349
  const splitNames = (stdout) => stdout
388
350
  .split("\n")
389
351
  .map((l) => l.trim())
@@ -431,15 +393,9 @@ async function classifyItem(repoRoot, io, base, tip, rfcs, specsDir, invariantsF
431
393
  // the scan tight. --no-textconv/--no-ext-diff: a repo-config filter must
432
394
  // not rewrite what the diff reports (CX-50 class — config channels are
433
395
  // scrubbed, this closes the repo-config half too).
434
- const diff = await gitEvidence(repoRoot, [
435
- "diff",
436
- "--unified=0",
437
- "--no-color",
438
- "--no-textconv",
439
- "--no-ext-diff",
440
- base,
441
- tip,
442
- ]);
396
+ const diff = await gitEvidence(repoRoot, ["diff", "--unified=0", "--no-color", "--no-textconv", "--no-ext-diff", base, tip], {
397
+ mode: "bestEffort",
398
+ });
443
399
  let diffOut = diff.exitCode === 0 ? diff.stdout : null;
444
400
  if (diffOut === null) {
445
401
  // Same refused-diff fallback as the names read — per-commit patches
@@ -666,13 +622,252 @@ function canonicalJson(value) {
666
622
  }
667
623
  return JSON.stringify(value);
668
624
  }
625
+ // --- persisted digests (RFC-1638) -------------------------------------------
626
+ export const PERSISTED_DIGEST_SCHEMA = "forge/persisted-digest@1";
627
+ /** `.git/forge/` subdir carrying one persisted digest per file. */
628
+ export const PERSISTED_DIGESTS_DIR = "forge/digests";
629
+ /** gate-runs precedent (RFC-1568): the newest 50 persisted digests survive. */
630
+ const PERSISTED_DIGEST_RETENTION = 50;
631
+ /** sha256 over canonicalJson(DigestInputs) — full hex, internal attestation. */
632
+ export function digestInputHash(inputs) {
633
+ return createHash("sha256").update(canonicalJson(inputs)).digest("hex");
634
+ }
635
+ function computeDigestId(preimage) {
636
+ return createHash("sha256")
637
+ .update(canonicalJson({
638
+ develop: { local: preimage.developLocal },
639
+ main: { local: preimage.mainLocal },
640
+ releaseTags: preimage.releaseTags,
641
+ tagTriggers: preimage.tagTriggers,
642
+ correctnessTrail: preimage.correctnessTrail,
643
+ items: preimage.items.map((i) => ({ id: i.id, tip: i.tip })),
644
+ }))
645
+ .digest("hex")
646
+ .slice(0, 12);
647
+ }
648
+ /**
649
+ * Recompute the digestId a persisted record's own payload preimages —
650
+ * `null` when the record's fields cannot re-derive the preimage. A forged
651
+ * `.git/forge/digests/*.json` (session-writable) then needs a 48-bit
652
+ * sha256 preimage to move a push, not just a plausible-looking file.
653
+ */
654
+ export function recomputePersistedDigestId(persisted) {
655
+ const d = persisted.digest;
656
+ if (typeof d.develop?.local !== "string" ||
657
+ typeof d.main?.local !== "string" ||
658
+ !Array.isArray(d.tagTriggers) ||
659
+ !Array.isArray(d.items) ||
660
+ !Array.isArray(persisted.releaseTags)) {
661
+ return null;
662
+ }
663
+ return computeDigestId({
664
+ developLocal: d.develop.local,
665
+ mainLocal: d.main.local,
666
+ releaseTags: persisted.releaseTags,
667
+ tagTriggers: d.tagTriggers,
668
+ correctnessTrail: d.correctnessTrail,
669
+ items: d.items.map((i) => ({ id: i.id, tip: i.tip })),
670
+ });
671
+ }
672
+ /** Every reachable release-line tag (unsuppressed), sorted — the set both
673
+ * digestId and DigestInputs cover; the journal `push` suppression applies
674
+ * only to the display/push-planning view (RFC-1638 decision 2). */
675
+ async function releaseTagSet(repoRoot, io, lines) {
676
+ const set = new Set();
677
+ for (const line of lines) {
678
+ const { reachable } = await listLineTags(repoRoot, line, io);
679
+ for (const tag of reachable)
680
+ set.add(tag);
681
+ }
682
+ return [...set].sort((a, b) => a.localeCompare(b));
683
+ }
684
+ /** sha256 over every `.github/workflows/*.y{ml,aml}` name + content on `dir` —
685
+ * the same file set workflowTagPatterns parses (RFC-1498 read surface). */
686
+ async function workflowFilesSha256(dir, io) {
687
+ const hash = createHash("sha256");
688
+ if (!(await io.exists(dir)))
689
+ return hash.digest("hex");
690
+ const entries = await io
691
+ .readdir(dir)
692
+ .catch(() => []);
693
+ const names = entries
694
+ .filter((e) => e.isFile && /\.ya?ml$/.test(e.name))
695
+ .map((e) => e.name)
696
+ .sort();
697
+ for (const name of names) {
698
+ const text = await io.readFile(join(dir, name)).catch(() => null);
699
+ hash.update(name);
700
+ hash.update("\0");
701
+ hash.update(text ?? "<unreadable>");
702
+ hash.update("\0");
703
+ }
704
+ return hash.digest("hex");
705
+ }
706
+ /**
707
+ * Re-observe every cheap digest input through the judged channel (RFC-1638:
708
+ * attestation feeds a refusal decision — a verdict input, never bestEffort).
709
+ * `null` means some input is unprovable — the caller falls back to recount.
710
+ */
711
+ export async function observeDigestInputs(repoRoot, io) {
712
+ try {
713
+ const urlSet = async (args) => {
714
+ const r = await gitEvidence(repoRoot, args);
715
+ if (r.exitCode === -1)
716
+ throw new Error(r.stderr);
717
+ return r.exitCode === 0 ? r.stdout : "";
718
+ };
719
+ const [head, developLocal, mainLocal, developRemote, mainRemote] = await Promise.all([
720
+ revParse(repoRoot, io, "HEAD"),
721
+ // RFC-1643: fully qualified — a shadow `refs/tags/develop` or
722
+ // `refs/develop` wins a bare-name lookup and would plant the tip.
723
+ revParse(repoRoot, io, "refs/heads/develop"),
724
+ revParse(repoRoot, io, "refs/heads/main"),
725
+ revParse(repoRoot, io, "refs/remotes/origin/develop"),
726
+ revParse(repoRoot, io, "refs/remotes/origin/main"),
727
+ ]);
728
+ const remoteConfigSha256 = createHash("sha256")
729
+ .update(canonicalJson({
730
+ configured: await urlSet(["config", "--get-all", "remote.origin.url"]),
731
+ fetch: await urlSet(["remote", "get-url", "--all", "origin"]),
732
+ push: await urlSet(["remote", "get-url", "--push", "--all", "origin"]),
733
+ }))
734
+ .digest("hex");
735
+ const { lines } = await discoverReleaseLines(repoRoot, io);
736
+ const releaseTags = await releaseTagSet(repoRoot, io, lines);
737
+ const common = await commonGitDir(io, repoRoot);
738
+ let primary = repoRoot;
739
+ try {
740
+ primary = await primaryWorktree(io, repoRoot);
741
+ }
742
+ catch {
743
+ primary = repoRoot;
744
+ }
745
+ const journalBytes = (await io.exists(join(common, JOURNAL_RELATIVE_PATH)))
746
+ ? await io.readFile(join(common, JOURNAL_RELATIVE_PATH))
747
+ : "";
748
+ const journalTailSha256 = createHash("sha256").update(journalBytes).digest("hex");
749
+ const sessions = (await readRegistry(io, common)).branches
750
+ .map((b) => b.name)
751
+ .sort((a, b) => a.localeCompare(b));
752
+ const repoStatus = await gitEvidence(repoRoot, ["status", "--porcelain=v1", "-z"]);
753
+ const primaryStatus = primary === repoRoot
754
+ ? repoStatus
755
+ : await gitEvidence(primary, ["status", "--porcelain=v1", "-z"]);
756
+ // A refused status consult cannot prove worktree state — attestation is
757
+ // a verdict input, so the observation itself is unprovable (CX-174).
758
+ if (repoStatus.exitCode !== 0 || primaryStatus.exitCode !== 0)
759
+ return null;
760
+ return {
761
+ head,
762
+ developLocal,
763
+ mainLocal,
764
+ developRemote,
765
+ mainRemote,
766
+ remoteConfigSha256,
767
+ releaseTags,
768
+ tagTriggerFilesSha256: await workflowFilesSha256(join(primary, WORKFLOWS_DIR), io),
769
+ journalTailSha256,
770
+ sessions,
771
+ statusPorcelainSha256: createHash("sha256")
772
+ .update(canonicalJson({ repo: repoStatus.stdout, primary: primaryStatus.stdout }))
773
+ .digest("hex"),
774
+ };
775
+ }
776
+ catch {
777
+ return null;
778
+ }
779
+ }
780
+ /**
781
+ * Load `.git/forge/digests/<digestId>.json`. "missing" names an absent file;
782
+ * "unknown" names an unreadable or wrong-schema record — both refuse
783
+ * FLOW-PUSH-15 upstream, never silently downgrade (RFC-1638).
784
+ */
785
+ export async function loadPersistedDigest(io, common, digestId) {
786
+ // The id becomes a path segment — a crafted `--digest ../…` must not walk
787
+ // out of the digests dir.
788
+ if (!/^[a-z0-9-]{1,80}$/.test(digestId))
789
+ return "unknown";
790
+ const file = join(common, PERSISTED_DIGESTS_DIR, `${digestId}.json`);
791
+ if (!(await io.exists(file)))
792
+ return "missing";
793
+ let raw;
794
+ try {
795
+ raw = JSON.parse(await io.readFile(file));
796
+ }
797
+ catch {
798
+ return "unknown";
799
+ }
800
+ const rec = raw;
801
+ const d = rec?.digest;
802
+ if (rec === null ||
803
+ rec.schema !== PERSISTED_DIGEST_SCHEMA ||
804
+ rec.digestId !== digestId ||
805
+ typeof rec.inputHash !== "string" ||
806
+ typeof rec.computedAt !== "string" ||
807
+ !Array.isArray(rec.releaseTags) ||
808
+ !rec.releaseTags.every((t) => typeof t === "string") ||
809
+ typeof d !== "object" ||
810
+ d === null ||
811
+ typeof d.digestId !== "string" ||
812
+ !Array.isArray(d.diagnostics) ||
813
+ typeof d.develop?.local !== "string" ||
814
+ typeof d.main?.local !== "string" ||
815
+ !Array.isArray(d.items) ||
816
+ !Array.isArray(d.tagTriggers)) {
817
+ return "unknown";
818
+ }
819
+ return rec;
820
+ }
821
+ /** Write the persisted digest atomically (tmp + rename) and sweep to the
822
+ * 50-newest retention (RFC-1568 precedent); `.tmp-<pid>` orphans of a dead
823
+ * writer older than a minute are reclaimed in the same pass. */
824
+ async function persistDigest(io, common, persisted) {
825
+ const dir = join(common, PERSISTED_DIGESTS_DIR);
826
+ await io.mkdir(dir);
827
+ const file = join(dir, `${persisted.digestId}.json`);
828
+ const tmp = `${file}.tmp-${process.pid}`;
829
+ await io.writeFile(tmp, `${JSON.stringify(persisted, null, 2)}\n`);
830
+ await io.rename(tmp, file);
831
+ const entries = await io
832
+ .readdir(dir)
833
+ .catch(() => []);
834
+ const names = entries.filter((e) => e.isFile).map((e) => e.name);
835
+ const orphans = names.filter((n) => n.endsWith(".json") === false && n.includes(".tmp-"));
836
+ const digests = names.filter((n) => n.endsWith(".json") && !n.includes(".tmp-"));
837
+ const now = Date.now();
838
+ for (const n of orphans) {
839
+ const t = await io
840
+ .stat(join(dir, n))
841
+ .then((s) => s.mtimeMs)
842
+ .catch(() => 0);
843
+ if (now - t > 60_000)
844
+ await io.rm(join(dir, n)).catch(() => { });
845
+ }
846
+ if (digests.length <= PERSISTED_DIGEST_RETENTION)
847
+ return;
848
+ const aged = await Promise.all(digests.map(async (n) => ({
849
+ n,
850
+ t: await io
851
+ .stat(join(dir, n))
852
+ .then((s) => s.mtimeMs)
853
+ .catch(() => 0),
854
+ })));
855
+ const keep = new Set(aged
856
+ .sort((a, b) => b.t - a.t)
857
+ .slice(0, PERSISTED_DIGEST_RETENTION)
858
+ .map((e) => e.n));
859
+ for (const n of digests) {
860
+ if (!keep.has(n))
861
+ await io.rm(join(dir, n)).catch(() => { });
862
+ }
863
+ }
669
864
  /**
670
865
  * Collect the outbound digest of repoRoot. The `fetch` flag is retained for
671
866
  * call-site compatibility but is inert — the trusted channel refuses every
672
867
  * transport (CX-132), so a digest never contacts a remote and `fetched` is
673
868
  * structurally false.
674
869
  */
675
- export async function collectDigest(repoRoot, io, _opts) {
870
+ export async function collectDigest(repoRoot, io, opts) {
676
871
  const diagnostics = [];
677
872
  // --- trust-boundary preflight ------------------------------------------
678
873
  // The evidence channel refuses when the session-writable repo surface
@@ -681,8 +876,32 @@ export async function collectDigest(repoRoot, io, _opts) {
681
876
  // read resolves (CX-79). Emitting the reasons here keeps the digest's
682
877
  // diagnostics honest instead of cascading "no origin"/"fetch failed"
683
878
  // secondaries on top of the refused channel.
684
- const preflight = await evidencePreflight(repoRoot);
685
- if (preflight === null) {
879
+ // RFC-1633 (review DEV-4): the standalone surface preflight is itself a
880
+ // heavy judged reader (~47k openat on this repo) — it serializes on the
881
+ // consult lock like every other judged read, so a parallel digest's
882
+ // fingerprint capture cannot interleave mid-sweep.
883
+ let preflight;
884
+ try {
885
+ preflight = await withEvidenceConsultLock(repoRoot, { command: "flow.digest preflight" }, () =>
886
+ // RFC-1644: diagnostic-only — read for refusedKeys/shapeViolations,
887
+ // never armed against, so the worktree baseline is skipped.
888
+ evidencePreflight(repoRoot, undefined, { worktreeSurface: "skip" }));
889
+ }
890
+ catch (error) {
891
+ if (error instanceof LockTimeoutError) {
892
+ diagnostics.push({
893
+ ruleId: "FLOW-PUSH-13",
894
+ severity: "error",
895
+ message: await describeEvidenceLockError(repoRoot, error),
896
+ fixHint: `a parallel judged consult held the evidence lock past the wait budget — re-run flow.digest`,
897
+ });
898
+ preflight = null;
899
+ }
900
+ else {
901
+ throw error;
902
+ }
903
+ }
904
+ if (preflight === null && !diagnostics.some((d) => d.ruleId === "FLOW-PUSH-13")) {
686
905
  diagnostics.push({
687
906
  ruleId: "FLOW-PUSH-13",
688
907
  severity: "error",
@@ -849,8 +1068,11 @@ export async function collectDigest(repoRoot, io, _opts) {
849
1068
  // false and the verifier-trailer scan always covers the full local
850
1069
  // branch — the strictly stronger judgment.
851
1070
  const fetched = false;
852
- const developLocal = await revParse(repoRoot, io, "develop");
853
- const mainLocal = await revParse(repoRoot, io, "main");
1071
+ // RFC-1643: branch tips resolve fully qualified — git's bare-name order
1072
+ // (`refs/<name>`, `refs/tags/<name>`, then `refs/heads/<name>`) lets a
1073
+ // shadow ref plant an unintegrated commit as the reviewed tip.
1074
+ const developLocal = await revParse(repoRoot, io, "refs/heads/develop");
1075
+ const mainLocal = await revParse(repoRoot, io, "refs/heads/main");
854
1076
  // The "remote" tips are always the session-mutable tracking refs —
855
1077
  // verified remote tips cannot exist (CX-132). A planted
856
1078
  // `refs/remotes/origin/*` can hide commits from the tail exactly like
@@ -864,15 +1086,17 @@ export async function collectDigest(repoRoot, io, _opts) {
864
1086
  // keeps the tracking-ref-relative view.
865
1087
  const developTailRead = developLocal === null
866
1088
  ? []
867
- : await unpushedCommits(repoRoot, io, "develop", developRemote, false, null);
868
- const mainTailRead = mainLocal === null ? [] : await unpushedCommits(repoRoot, io, "main", mainRemote, false, null);
1089
+ : await unpushedCommits(repoRoot, io, developLocal, developRemote, false, null);
1090
+ const mainTailRead = mainLocal === null
1091
+ ? []
1092
+ : await unpushedCommits(repoRoot, io, mainLocal, mainRemote, false, null);
869
1093
  // --- items: journal-attributed segments of the develop tail ---------------
870
1094
  // Segments follow develop's first-parent chain: a back-merge brings main's
871
1095
  // commits in through its second parent, and a fix cut's range lives on
872
1096
  // main — index spans over the full (date-ordered) list would misattribute.
873
1097
  const developChainRead = developLocal === null
874
1098
  ? []
875
- : await unpushedCommits(repoRoot, io, "develop", developRemote, true, null);
1099
+ : await unpushedCommits(repoRoot, io, developLocal, developRemote, true, null);
876
1100
  // A null tail/chain means the enumeration itself is unverifiable —
877
1101
  // degrading to [] would run the verifier trailer scan over NOTHING
878
1102
  // (CX-174). Fail the digest as unverifiable; the lists stay empty so
@@ -989,15 +1213,13 @@ export async function collectDigest(repoRoot, io, _opts) {
989
1213
  // corroborated into one (R13-C) — flow.push publishes only what this
990
1214
  // run itself pushes.
991
1215
  const { lines } = await discoverReleaseLines(repoRoot, io);
992
- const tags = [];
993
- for (const line of lines) {
994
- const { reachable } = await listLineTags(repoRoot, line, io);
995
- for (const tag of reachable) {
996
- if (!pushedTags.has(tag))
997
- tags.push(tag);
998
- }
999
- }
1000
- tags.sort((a, b) => a.localeCompare(b));
1216
+ // RFC-1638 decision 2: the hashed set is the UNSUPPRESSED reachable set —
1217
+ // `pushedTags` suppression derives from journal `push` records, and a
1218
+ // foreign push record must not move digestId. The display/push view keeps
1219
+ // the suppression; flow.push re-applies it from the journal at planning
1220
+ // time so records appended after the digest still hide their tags.
1221
+ const releaseTags = await releaseTagSet(repoRoot, io, lines);
1222
+ const tags = releaseTags.filter((t) => !pushedTags.has(t));
1001
1223
  const pendingPublications = [];
1002
1224
  const supersededPublications = [];
1003
1225
  // --- CI workflows a tag push would trigger (RFC-1498) --------------------
@@ -1012,7 +1234,9 @@ export async function collectDigest(repoRoot, io, _opts) {
1012
1234
  }
1013
1235
  const tagPatterns = await workflowTagPatterns(join(primary, WORKFLOWS_DIR), io, diagnostics);
1014
1236
  const tagTriggers = [];
1015
- for (const tag of tags) {
1237
+ // Triggers compute over the unsuppressed set — a journal `push` record
1238
+ // hiding a tag must not shrink the hashed trigger surface (RFC-1638).
1239
+ for (const tag of releaseTags) {
1016
1240
  const workflows = tagPatterns
1017
1241
  .filter((w) => w.patterns.some((p) => tagPatternRegex(p)?.test(tag) === true))
1018
1242
  .map((w) => w.file);
@@ -1023,20 +1247,22 @@ export async function collectDigest(repoRoot, io, _opts) {
1023
1247
  const byCategory = Object.fromEntries(RISK_CATEGORIES.map((c) => [c, []]));
1024
1248
  for (const item of items)
1025
1249
  byCategory[item.category].push(item.id);
1026
- const digestId = createHash("sha256")
1027
- .update(canonicalJson({
1028
- develop: { local: developLocal, remote: developRemote, ahead: developTail.length },
1029
- main: { local: mainLocal, remote: mainRemote, ahead: mainTail.length },
1030
- tags,
1250
+ // RFC-1638 decision 2: the hashed contract covers judgment inputs only —
1251
+ // local branch tips, the unsuppressed release-tag set, triggers, the
1252
+ // correctness trail and the item tips. `*.remote` (session-mutable
1253
+ // tracking refs), the derived `ahead` counts and the display-only
1254
+ // publication fields stay in the returned object as preview data but
1255
+ // leave the hash: a foreign push or journal `push` record can no longer
1256
+ // move a digest the operator already reviewed.
1257
+ const digestId = computeDigestId({
1258
+ developLocal,
1259
+ mainLocal,
1260
+ releaseTags,
1031
1261
  tagTriggers,
1032
1262
  correctnessTrail,
1033
- pendingPublications,
1034
- supersededPublications,
1035
- items: items.map((i) => ({ id: i.id, tip: i.tip })),
1036
- }))
1037
- .digest("hex")
1038
- .slice(0, 12);
1039
- return {
1263
+ items,
1264
+ });
1265
+ const data = {
1040
1266
  digestId,
1041
1267
  remote: "origin",
1042
1268
  fetched,
@@ -1053,5 +1279,31 @@ export async function collectDigest(repoRoot, io, _opts) {
1053
1279
  correctnessTrail,
1054
1280
  diagnostics,
1055
1281
  };
1282
+ // RFC-1638 persist — the reviewed digest + its input hash, so flow.push
1283
+ // attests staleness in seconds instead of recounting. Best-effort: a
1284
+ // failed persist degrades to the recount path (FLOW-PUSH-15 upstream),
1285
+ // never blocks the digest itself. `persist:false` (dry-run callers)
1286
+ // leaves the digests dir untouched.
1287
+ try {
1288
+ const inputs = opts?.persist === false ? null : await observeDigestInputs(repoRoot, io);
1289
+ if (inputs !== null) {
1290
+ await persistDigest(io, common, {
1291
+ schema: PERSISTED_DIGEST_SCHEMA,
1292
+ digestId,
1293
+ inputHash: digestInputHash(inputs),
1294
+ computedAt: new Date().toISOString(),
1295
+ releaseTags,
1296
+ digest: data,
1297
+ });
1298
+ }
1299
+ }
1300
+ catch (error) {
1301
+ diagnostics.push({
1302
+ ruleId: "FLOW-DIGEST-01",
1303
+ severity: "warning",
1304
+ message: `the persisted digest could not be written — flow.push will recount instead of attesting: ${error instanceof Error ? error.message : String(error)}`,
1305
+ });
1306
+ }
1307
+ return data;
1056
1308
  }
1057
1309
  //# sourceMappingURL=digest.js.map