@warpgogol/forge 9.1.0 → 9.2.3

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 (380) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +15 -8
  3. package/README.uk.md +15 -8
  4. package/bin/cli.ts +3 -2
  5. package/dist/bin/cli.js +3 -2
  6. package/dist/bin/cli.js.map +1 -1
  7. package/dist/os/core/core.module.d.ts.map +1 -1
  8. package/dist/os/core/core.module.js +6 -4
  9. package/dist/os/core/core.module.js.map +1 -1
  10. package/dist/os/flow/branch-name.d.ts +56 -0
  11. package/dist/os/flow/branch-name.d.ts.map +1 -0
  12. package/dist/os/flow/branch-name.js +108 -0
  13. package/dist/os/flow/branch-name.js.map +1 -0
  14. package/dist/os/flow/digest.d.ts +73 -0
  15. package/dist/os/flow/digest.d.ts.map +1 -0
  16. package/dist/os/flow/digest.js +634 -0
  17. package/dist/os/flow/digest.js.map +1 -0
  18. package/dist/os/flow/flow.module.d.ts +3 -0
  19. package/dist/os/flow/flow.module.d.ts.map +1 -0
  20. package/dist/os/flow/flow.module.js +716 -0
  21. package/dist/os/flow/flow.module.js.map +1 -0
  22. package/dist/os/flow/git.d.ts +68 -0
  23. package/dist/os/flow/git.d.ts.map +1 -0
  24. package/dist/os/flow/git.js +257 -0
  25. package/dist/os/flow/git.js.map +1 -0
  26. package/dist/os/flow/guard-files.d.ts +50 -0
  27. package/dist/os/flow/guard-files.d.ts.map +1 -0
  28. package/dist/os/flow/guard-files.js +147 -0
  29. package/dist/os/flow/guard-files.js.map +1 -0
  30. package/dist/os/flow/handlers/flow-backmerge.d.ts +27 -0
  31. package/dist/os/flow/handlers/flow-backmerge.d.ts.map +1 -0
  32. package/dist/os/flow/handlers/flow-backmerge.js +332 -0
  33. package/dist/os/flow/handlers/flow-backmerge.js.map +1 -0
  34. package/dist/os/flow/handlers/flow-check.d.ts +42 -0
  35. package/dist/os/flow/handlers/flow-check.d.ts.map +1 -0
  36. package/dist/os/flow/handlers/flow-check.js +347 -0
  37. package/dist/os/flow/handlers/flow-check.js.map +1 -0
  38. package/dist/os/flow/handlers/flow-cut.d.ts +63 -0
  39. package/dist/os/flow/handlers/flow-cut.d.ts.map +1 -0
  40. package/dist/os/flow/handlers/flow-cut.js +636 -0
  41. package/dist/os/flow/handlers/flow-cut.js.map +1 -0
  42. package/dist/os/flow/handlers/flow-digest.d.ts +5 -0
  43. package/dist/os/flow/handlers/flow-digest.d.ts.map +1 -0
  44. package/dist/os/flow/handlers/flow-digest.js +110 -0
  45. package/dist/os/flow/handlers/flow-digest.js.map +1 -0
  46. package/dist/os/flow/handlers/flow-discard.d.ts +22 -0
  47. package/dist/os/flow/handlers/flow-discard.d.ts.map +1 -0
  48. package/dist/os/flow/handlers/flow-discard.js +200 -0
  49. package/dist/os/flow/handlers/flow-discard.js.map +1 -0
  50. package/dist/os/flow/handlers/flow-fix.d.ts +47 -0
  51. package/dist/os/flow/handlers/flow-fix.d.ts.map +1 -0
  52. package/dist/os/flow/handlers/flow-fix.js +443 -0
  53. package/dist/os/flow/handlers/flow-fix.js.map +1 -0
  54. package/dist/os/flow/handlers/flow-hold.d.ts +32 -0
  55. package/dist/os/flow/handlers/flow-hold.d.ts.map +1 -0
  56. package/dist/os/flow/handlers/flow-hold.js +359 -0
  57. package/dist/os/flow/handlers/flow-hold.js.map +1 -0
  58. package/dist/os/flow/handlers/flow-install.d.ts +92 -0
  59. package/dist/os/flow/handlers/flow-install.d.ts.map +1 -0
  60. package/dist/os/flow/handlers/flow-install.js +883 -0
  61. package/dist/os/flow/handlers/flow-install.js.map +1 -0
  62. package/dist/os/flow/handlers/flow-integrate.d.ts +35 -0
  63. package/dist/os/flow/handlers/flow-integrate.d.ts.map +1 -0
  64. package/dist/os/flow/handlers/flow-integrate.js +419 -0
  65. package/dist/os/flow/handlers/flow-integrate.js.map +1 -0
  66. package/dist/os/flow/handlers/flow-open.d.ts +63 -0
  67. package/dist/os/flow/handlers/flow-open.d.ts.map +1 -0
  68. package/dist/os/flow/handlers/flow-open.js +294 -0
  69. package/dist/os/flow/handlers/flow-open.js.map +1 -0
  70. package/dist/os/flow/handlers/flow-push.d.ts +22 -0
  71. package/dist/os/flow/handlers/flow-push.d.ts.map +1 -0
  72. package/dist/os/flow/handlers/flow-push.js +306 -0
  73. package/dist/os/flow/handlers/flow-push.js.map +1 -0
  74. package/dist/os/flow/handlers/flow-status.d.ts +65 -0
  75. package/dist/os/flow/handlers/flow-status.d.ts.map +1 -0
  76. package/dist/os/flow/handlers/flow-status.js +193 -0
  77. package/dist/os/flow/handlers/flow-status.js.map +1 -0
  78. package/dist/os/flow/handlers/flow-unhold.d.ts +20 -0
  79. package/dist/os/flow/handlers/flow-unhold.d.ts.map +1 -0
  80. package/dist/os/flow/handlers/flow-unhold.js +158 -0
  81. package/dist/os/flow/handlers/flow-unhold.js.map +1 -0
  82. package/dist/os/flow/handlers/flow-version.d.ts +39 -0
  83. package/dist/os/flow/handlers/flow-version.d.ts.map +1 -0
  84. package/dist/os/flow/handlers/flow-version.js +122 -0
  85. package/dist/os/flow/handlers/flow-version.js.map +1 -0
  86. package/dist/os/flow/index.d.ts +30 -0
  87. package/dist/os/flow/index.d.ts.map +1 -0
  88. package/dist/os/flow/index.js +83 -0
  89. package/dist/os/flow/index.js.map +1 -0
  90. package/dist/os/flow/line-version.d.ts +23 -0
  91. package/dist/os/flow/line-version.d.ts.map +1 -0
  92. package/dist/os/flow/line-version.js +83 -0
  93. package/dist/os/flow/line-version.js.map +1 -0
  94. package/dist/os/flow/locks.d.ts +34 -0
  95. package/dist/os/flow/locks.d.ts.map +1 -0
  96. package/dist/os/flow/locks.js +147 -0
  97. package/dist/os/flow/locks.js.map +1 -0
  98. package/dist/os/flow/markers.d.ts +49 -0
  99. package/dist/os/flow/markers.d.ts.map +1 -0
  100. package/dist/os/flow/markers.js +112 -0
  101. package/dist/os/flow/markers.js.map +1 -0
  102. package/dist/os/flow/publish.d.ts +28 -0
  103. package/dist/os/flow/publish.d.ts.map +1 -0
  104. package/dist/os/flow/publish.js +153 -0
  105. package/dist/os/flow/publish.js.map +1 -0
  106. package/dist/os/flow/registry.d.ts +142 -0
  107. package/dist/os/flow/registry.d.ts.map +1 -0
  108. package/dist/os/flow/registry.js +198 -0
  109. package/dist/os/flow/registry.js.map +1 -0
  110. package/dist/os/flow/release-level.d.ts +23 -0
  111. package/dist/os/flow/release-level.d.ts.map +1 -0
  112. package/dist/os/flow/release-level.js +102 -0
  113. package/dist/os/flow/release-level.js.map +1 -0
  114. package/dist/os/flow/release-lines.d.ts +25 -0
  115. package/dist/os/flow/release-lines.d.ts.map +1 -0
  116. package/dist/os/flow/release-lines.js +172 -0
  117. package/dist/os/flow/release-lines.js.map +1 -0
  118. package/dist/os/flow/release-tags.d.ts +72 -0
  119. package/dist/os/flow/release-tags.d.ts.map +1 -0
  120. package/dist/os/flow/release-tags.js +166 -0
  121. package/dist/os/flow/release-tags.js.map +1 -0
  122. package/dist/os/flow/repo-kind.d.ts +41 -0
  123. package/dist/os/flow/repo-kind.d.ts.map +1 -0
  124. package/dist/os/flow/repo-kind.js +92 -0
  125. package/dist/os/flow/repo-kind.js.map +1 -0
  126. package/dist/os/flow/scripts.d.ts +20 -0
  127. package/dist/os/flow/scripts.d.ts.map +1 -0
  128. package/dist/os/flow/scripts.js +49 -0
  129. package/dist/os/flow/scripts.js.map +1 -0
  130. package/dist/os/flow/semver.d.ts +21 -0
  131. package/dist/os/flow/semver.d.ts.map +1 -0
  132. package/dist/os/flow/semver.js +73 -0
  133. package/dist/os/flow/semver.js.map +1 -0
  134. package/dist/os/flow/tests/helpers.d.ts +52 -0
  135. package/dist/os/flow/tests/helpers.d.ts.map +1 -0
  136. package/dist/os/flow/tests/helpers.js +189 -0
  137. package/dist/os/flow/tests/helpers.js.map +1 -0
  138. package/dist/os/flow/version-files.d.ts +21 -0
  139. package/dist/os/flow/version-files.d.ts.map +1 -0
  140. package/dist/os/flow/version-files.js +94 -0
  141. package/dist/os/flow/version-files.js.map +1 -0
  142. package/dist/os/flow/worktree-path.d.ts +31 -0
  143. package/dist/os/flow/worktree-path.d.ts.map +1 -0
  144. package/dist/os/flow/worktree-path.js +80 -0
  145. package/dist/os/flow/worktree-path.js.map +1 -0
  146. package/dist/os/mission/handlers/archive.d.ts.map +1 -1
  147. package/dist/os/mission/handlers/archive.js +43 -6
  148. package/dist/os/mission/handlers/archive.js.map +1 -1
  149. package/dist/os/program/handlers/seal.d.ts.map +1 -1
  150. package/dist/os/program/handlers/seal.js +1 -1
  151. package/dist/os/program/handlers/seal.js.map +1 -1
  152. package/dist/os/program/handlers/validate.d.ts.map +1 -1
  153. package/dist/os/program/handlers/validate.js +1 -1
  154. package/dist/os/program/handlers/validate.js.map +1 -1
  155. package/dist/os/program/program.module.d.ts.map +1 -1
  156. package/dist/os/program/program.module.js +2 -1
  157. package/dist/os/program/program.module.js.map +1 -1
  158. package/dist/os/program/schemas.d.ts +4 -6
  159. package/dist/os/program/schemas.d.ts.map +1 -1
  160. package/dist/os/program/schemas.js +16 -6
  161. package/dist/os/program/schemas.js.map +1 -1
  162. package/dist/os/program/state.d.ts +0 -1
  163. package/dist/os/program/state.d.ts.map +1 -1
  164. package/dist/os/program/state.js +1 -7
  165. package/dist/os/program/state.js.map +1 -1
  166. package/dist/os/rfc/acceptance.d.ts +21 -0
  167. package/dist/os/rfc/acceptance.d.ts.map +1 -1
  168. package/dist/os/rfc/acceptance.js +62 -13
  169. package/dist/os/rfc/acceptance.js.map +1 -1
  170. package/dist/os/rfc/frontmatter-io.d.ts +19 -0
  171. package/dist/os/rfc/frontmatter-io.d.ts.map +1 -1
  172. package/dist/os/rfc/frontmatter-io.js +65 -12
  173. package/dist/os/rfc/frontmatter-io.js.map +1 -1
  174. package/dist/os/rfc/handlers/validate-rules.d.ts +2 -5
  175. package/dist/os/rfc/handlers/validate-rules.d.ts.map +1 -1
  176. package/dist/os/rfc/handlers/validate-rules.js +10 -8
  177. package/dist/os/rfc/handlers/validate-rules.js.map +1 -1
  178. package/dist/os/rfc/handlers/validate.d.ts.map +1 -1
  179. package/dist/os/rfc/handlers/validate.js +15 -5
  180. package/dist/os/rfc/handlers/validate.js.map +1 -1
  181. package/dist/os/rfc/index.d.ts +2 -2
  182. package/dist/os/rfc/index.d.ts.map +1 -1
  183. package/dist/os/rfc/index.js +5 -2
  184. package/dist/os/rfc/index.js.map +1 -1
  185. package/dist/os/rfc/probe-batch.d.ts +71 -0
  186. package/dist/os/rfc/probe-batch.d.ts.map +1 -0
  187. package/dist/os/rfc/probe-batch.js +251 -0
  188. package/dist/os/rfc/probe-batch.js.map +1 -0
  189. package/dist/os/rfc/rfc.module.d.ts.map +1 -1
  190. package/dist/os/rfc/rfc.module.js +16 -2
  191. package/dist/os/rfc/rfc.module.js.map +1 -1
  192. package/dist/os/rfc/verification-evidence.d.ts.map +1 -1
  193. package/dist/os/rfc/verification-evidence.js +21 -10
  194. package/dist/os/rfc/verification-evidence.js.map +1 -1
  195. package/dist/os/rfc/verification-refresh.d.ts.map +1 -1
  196. package/dist/os/rfc/verification-refresh.js +20 -13
  197. package/dist/os/rfc/verification-refresh.js.map +1 -1
  198. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts.map +1 -1
  199. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js +21 -7
  200. package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js.map +1 -1
  201. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts.map +1 -1
  202. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js +1 -1
  203. package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js.map +1 -1
  204. package/dist/os/werkstatt/werkstatt.module.d.ts.map +1 -1
  205. package/dist/os/werkstatt/werkstatt.module.js +2 -82
  206. package/dist/os/werkstatt/werkstatt.module.js.map +1 -1
  207. package/dist/src/config/forge-config.d.ts +0 -3
  208. package/dist/src/config/forge-config.d.ts.map +1 -1
  209. package/dist/src/config/forge-config.js +2 -4
  210. package/dist/src/config/forge-config.js.map +1 -1
  211. package/dist/src/index.d.ts +3 -0
  212. package/dist/src/index.d.ts.map +1 -1
  213. package/dist/src/index.js +2 -0
  214. package/dist/src/index.js.map +1 -1
  215. package/dist/src/onboarding/agents-generate.d.ts.map +1 -1
  216. package/dist/src/onboarding/agents-generate.js +49 -4
  217. package/dist/src/onboarding/agents-generate.js.map +1 -1
  218. package/dist/src/onboarding/create.d.ts +13 -0
  219. package/dist/src/onboarding/create.d.ts.map +1 -1
  220. package/dist/src/onboarding/create.js +95 -9
  221. package/dist/src/onboarding/create.js.map +1 -1
  222. package/dist/src/onboarding/doctor.d.ts.map +1 -1
  223. package/dist/src/onboarding/doctor.js +2 -47
  224. package/dist/src/onboarding/doctor.js.map +1 -1
  225. package/dist/src/onboarding/upgrade.d.ts +5 -0
  226. package/dist/src/onboarding/upgrade.d.ts.map +1 -1
  227. package/dist/src/onboarding/upgrade.js +70 -1
  228. package/dist/src/onboarding/upgrade.js.map +1 -1
  229. package/dist/src/types.d.ts +9 -0
  230. package/dist/src/types.d.ts.map +1 -1
  231. package/dist/src/types.js +2 -2
  232. package/docs/branch-model.md +98 -0
  233. package/docs/maintainers/publishing.md +14 -6
  234. package/docs/reference/cli.md +125 -0
  235. package/docs/reference/profiles.md +1 -0
  236. package/os/core/core.module.ts +7 -4
  237. package/os/flow/assets/flow-guard.sh +176 -0
  238. package/os/flow/branch-name.ts +139 -0
  239. package/os/flow/digest.ts +761 -0
  240. package/os/flow/flow.module.ts +740 -0
  241. package/os/flow/git.ts +342 -0
  242. package/os/flow/guard-files.ts +172 -0
  243. package/os/flow/handlers/flow-backmerge.ts +488 -0
  244. package/os/flow/handlers/flow-check.ts +450 -0
  245. package/os/flow/handlers/flow-cut.ts +912 -0
  246. package/os/flow/handlers/flow-digest.ts +124 -0
  247. package/os/flow/handlers/flow-discard.ts +301 -0
  248. package/os/flow/handlers/flow-fix.ts +597 -0
  249. package/os/flow/handlers/flow-hold.ts +500 -0
  250. package/os/flow/handlers/flow-install.ts +1185 -0
  251. package/os/flow/handlers/flow-integrate.ts +607 -0
  252. package/os/flow/handlers/flow-open.ts +447 -0
  253. package/os/flow/handlers/flow-push.ts +373 -0
  254. package/os/flow/handlers/flow-status.ts +283 -0
  255. package/os/flow/handlers/flow-unhold.ts +220 -0
  256. package/os/flow/handlers/flow-version.ts +196 -0
  257. package/os/flow/index.ts +102 -0
  258. package/os/flow/line-version.ts +113 -0
  259. package/os/flow/locks.ts +177 -0
  260. package/os/flow/markers.ts +135 -0
  261. package/os/flow/publish.ts +201 -0
  262. package/os/flow/registry.ts +266 -0
  263. package/os/flow/release-level.ts +139 -0
  264. package/os/flow/release-lines.ts +208 -0
  265. package/os/flow/release-tags.ts +231 -0
  266. package/os/flow/repo-kind.ts +117 -0
  267. package/os/flow/scripts.ts +73 -0
  268. package/os/flow/semver.ts +82 -0
  269. package/os/flow/tests/branch-name.test.ts +136 -0
  270. package/os/flow/tests/fixtures/branch-names.yaml +56 -0
  271. package/os/flow/tests/flow-backmerge.test.ts +267 -0
  272. package/os/flow/tests/flow-check-version.test.ts +138 -0
  273. package/os/flow/tests/flow-check.test.ts +213 -0
  274. package/os/flow/tests/flow-cut.rerun.test.ts +95 -0
  275. package/os/flow/tests/flow-cut.test.ts +319 -0
  276. package/os/flow/tests/flow-digest.test.ts +313 -0
  277. package/os/flow/tests/flow-discard.test.ts +220 -0
  278. package/os/flow/tests/flow-fix.test.ts +359 -0
  279. package/os/flow/tests/flow-guard-merge.test.ts +100 -0
  280. package/os/flow/tests/flow-guard-parity.test.ts +115 -0
  281. package/os/flow/tests/flow-guard-push.test.ts +100 -0
  282. package/os/flow/tests/flow-guard.test.ts +135 -0
  283. package/os/flow/tests/flow-hold.test.ts +465 -0
  284. package/os/flow/tests/flow-install-baseline.rerun.test.ts +73 -0
  285. package/os/flow/tests/flow-install-baseline.test.ts +164 -0
  286. package/os/flow/tests/flow-install-markers.test.ts +161 -0
  287. package/os/flow/tests/flow-install.rerun.test.ts +212 -0
  288. package/os/flow/tests/flow-install.test.ts +330 -0
  289. package/os/flow/tests/flow-integrate.rerun.test.ts +92 -0
  290. package/os/flow/tests/flow-integrate.test.ts +229 -0
  291. package/os/flow/tests/flow-open.test.ts +200 -0
  292. package/os/flow/tests/flow-push-publish.test.ts +282 -0
  293. package/os/flow/tests/flow-push.test.ts +160 -0
  294. package/os/flow/tests/flow-stale.test.ts +136 -0
  295. package/os/flow/tests/flow-status.test.ts +93 -0
  296. package/os/flow/tests/flow-version-level.test.ts +116 -0
  297. package/os/flow/tests/flow-version.test.ts +169 -0
  298. package/os/flow/tests/helpers.ts +235 -0
  299. package/os/flow/tests/is-flow-adopted.test.ts +71 -0
  300. package/os/flow/tests/registry.test.ts +150 -0
  301. package/os/flow/tests/repository-line-version.test.ts +100 -0
  302. package/os/flow/tests/scripts.test.ts +97 -0
  303. package/os/flow/tests/state-roots.test.ts +127 -0
  304. package/os/flow/tests/version-files.test.ts +145 -0
  305. package/os/flow/version-files.ts +115 -0
  306. package/os/flow/worktree-path.ts +107 -0
  307. package/os/mission/handlers/archive.test.ts +27 -0
  308. package/os/mission/handlers/archive.ts +46 -6
  309. package/os/program/handlers/seal.ts +1 -1
  310. package/os/program/handlers/validate.ts +1 -1
  311. package/os/program/program.module.ts +2 -1
  312. package/os/program/schemas.ts +51 -34
  313. package/os/program/state.ts +1 -9
  314. package/os/rfc/acceptance.ts +84 -19
  315. package/os/rfc/frontmatter-io.ts +78 -12
  316. package/os/rfc/handlers/implement-stamp-stale.test.ts +22 -0
  317. package/os/rfc/handlers/validate-rules.test.ts +9 -6
  318. package/os/rfc/handlers/validate-rules.ts +12 -10
  319. package/os/rfc/handlers/validate.ts +17 -5
  320. package/os/rfc/index.ts +13 -1
  321. package/os/rfc/probe-batch.ts +329 -0
  322. package/os/rfc/rfc.module.ts +19 -2
  323. package/os/rfc/verification-emit-check.test.ts +22 -0
  324. package/os/rfc/verification-emit-freshness.test.ts +22 -0
  325. package/os/rfc/verification-emit.test.ts +22 -0
  326. package/os/rfc/verification-evidence.ts +21 -16
  327. package/os/rfc/verification-refresh.test.ts +22 -0
  328. package/os/rfc/verification-refresh.ts +20 -18
  329. package/os/rfc/verifier/rfc-1333/imp12-binding.acceptance.test.ts +9 -0
  330. package/os/werkstatt/handlers/werkstatt-lock-recover.ts +22 -5
  331. package/os/werkstatt/handlers/werkstatt-operation-validate.ts +1 -1
  332. package/os/werkstatt/werkstatt.module.ts +2 -85
  333. package/package.json +17 -1
  334. package/profiles/forge-shell.yaml +22 -10
  335. package/profiles/godot-game.yaml +24 -13
  336. package/profiles/knowledge.yaml +19 -0
  337. package/profiles/phaser-game.yaml +25 -13
  338. package/profiles/site-workshop.yaml +27 -10
  339. package/profiles/typescript.yaml +26 -9
  340. package/skills/fo/fo-session-retro/SKILL.md +18 -7
  341. package/skills/fo/fo-step-commit/SKILL.md +2 -1
  342. package/src/config/forge-config.ts +2 -6
  343. package/src/index.ts +8 -0
  344. package/src/onboarding/agents-generate.ts +49 -5
  345. package/src/onboarding/create.ts +101 -9
  346. package/src/onboarding/doctor.ts +2 -51
  347. package/src/onboarding/upgrade.ts +86 -1
  348. package/src/tests/agents-generate-flow.test.ts +132 -0
  349. package/src/tests/create-flow.test.ts +114 -0
  350. package/src/tests/create.test.ts +22 -21
  351. package/src/tests/doctor-autonomy.test.ts +2 -1
  352. package/src/tests/implement-stamp.test.ts +26 -3
  353. package/src/tests/profile-flow-hooks.test.ts +77 -0
  354. package/src/tests/program-schemas.test.ts +66 -6
  355. package/src/tests/program-spec-node.test.ts +1 -5
  356. package/src/tests/rfc-evidence-sync.test.ts +22 -0
  357. package/src/tests/rfc-implement-stamp-governance.test.ts +25 -1
  358. package/src/tests/rfc-verification-verdict-ingest.test.ts +22 -0
  359. package/src/tests/upgrade-flow.test.ts +174 -0
  360. package/src/types.ts +11 -2
  361. package/dist/os/werkstatt/handlers/session-close.d.ts +0 -13
  362. package/dist/os/werkstatt/handlers/session-close.d.ts.map +0 -1
  363. package/dist/os/werkstatt/handlers/session-close.js +0 -56
  364. package/dist/os/werkstatt/handlers/session-close.js.map +0 -1
  365. package/dist/os/werkstatt/handlers/session-engine.d.ts +0 -3
  366. package/dist/os/werkstatt/handlers/session-engine.d.ts.map +0 -1
  367. package/dist/os/werkstatt/handlers/session-engine.js +0 -28
  368. package/dist/os/werkstatt/handlers/session-engine.js.map +0 -1
  369. package/dist/os/werkstatt/handlers/session-open.d.ts +0 -10
  370. package/dist/os/werkstatt/handlers/session-open.d.ts.map +0 -1
  371. package/dist/os/werkstatt/handlers/session-open.js +0 -46
  372. package/dist/os/werkstatt/handlers/session-open.js.map +0 -1
  373. package/dist/os/werkstatt/handlers/session-status.d.ts +0 -9
  374. package/dist/os/werkstatt/handlers/session-status.d.ts.map +0 -1
  375. package/dist/os/werkstatt/handlers/session-status.js +0 -34
  376. package/dist/os/werkstatt/handlers/session-status.js.map +0 -1
  377. package/os/werkstatt/handlers/session-close.ts +0 -82
  378. package/os/werkstatt/handlers/session-engine.ts +0 -34
  379. package/os/werkstatt/handlers/session-open.ts +0 -68
  380. package/os/werkstatt/handlers/session-status.ts +0 -55
@@ -0,0 +1,634 @@
1
+ /*
2
+ <MODULE_CONTRACT>
3
+ <purpose>Risk digest of the unpushed outbound state (RFC-1491): the unpushed
4
+ develop tail segmented into journal-attributed items, risk categories from
5
+ each item's diff, new release tags versus origin, held registry branches and
6
+ journal-scoped pending publications — fingerprinted into a digestId that
7
+ flow.push must quote.</purpose>
8
+ <non-goals>
9
+ <item>No mutation — the only write is the optional git fetch of remote-tracking refs.</item>
10
+ <item>No push or publish policy — handlers/flow-push.ts owns outbound execution.</item>
11
+ </non-goals>
12
+ </MODULE_CONTRACT>
13
+ <KEY_DECISIONS>
14
+ <item>The unpushed tail's anchor (origin tip, or the oldest unpushed commit's parent) counts as a valid record base — the RFC's "base and tip on the tail" reads the tail including its anchor, else every first item above a push would be unattributed.</item>
15
+ <item>Overlapping journal records are resolved newest-tail-first: records claim tail commits from the highest tip downward, so a stale record can never cover commits a newer record owns.</item>
16
+ <item>The remote tag set comes from `git ls-remote --tags origin` whenever origin exists (read-only, allowed under --no-fetch); when it fails, a tag is remote-known iff its commit is an ancestor of a remote-tracking tip — a tag on an already-pushed commit is then indistinguishable from a pushed one.</item>
17
+ <item>RFC frontmatter is read only via listRfcFiles/readRfcFrontmatter (RFC-1465 door) — never re-parsed locally.</item>
18
+ <item>tagTriggers (RFC-1498) is part of digestId input: a workflow-file change between digest and push must invalidate the quoted id. Unparseable workflows and ununderstood patterns warn FLOW-11 and match nothing — never block the digest.</item>
19
+ </KEY_DECISIONS>
20
+ <CHANGE_SUMMARY>
21
+ <item>RFC-1491: step 3 — flow.digest risk digest with journal-attributed items, categories, digestId</item>
22
+ <item>RFC-1491: step 5 — flow.push atomic outbound path + extract publication</item>
23
+ <item>RFC-1491: independent-review pass — shared lock constants, publishable pending filter, declared rules, hold ordering, sha-pinned refspecs</item>
24
+ <item>RFC-1491: digest segments develop by first-parent chain; hold of the topmost item skips the empty replay
25
+
26
+ Steering-session verification of wave 2 found two outbound defects:
27
+ - flow.digest attributed items by index spans over the date-ordered tail; after a fix release and its back-merge, the fix cut record (whose range lives on main) claimed the develop integration that shared its base, so the operator saw 'feat: dev work' labelled as the fix release. Segments now follow develop's first-parent chain and item commit counts come from the base..tip range.
28
+ - flow.hold on the item at the tip of develop ran cherry-pick on an empty range and refused FLOW-HOLD-07. An empty tail now resets develop to the item's base.</item>
29
+ <item>RFC-1498: step 4 — CI tag triggers and FLOW-11 in flow.digest
30
+
31
+ flow.digest now reads .github/workflows on the primary checkout and reports tagTriggers: for every digest tag the workflows whose on.push.tags filter matches its name. Matching evaluates the GitHub glob subset — star inside a segment, double-star across, question for one char; character classes and leading negations report FLOW-11 as pattern not understood and match nothing. A workflow that cannot be parsed reports FLOW-11 and contributes nothing, never blocking the digest. tagTriggers feeds digestId so a workflow change invalidates a quoted id, the pretty output prints one line per triggered tag, and flow.module declares FLOW-11 warning plus the workflows read glob. Tests AC-7 (a v1.0.1 tag maps to the v-star workflow only) and AC-8 (broken YAML and a bracket pattern warn while the digest still returns). Compass metadata updated.</item>
32
+ <history>RFC-1491</history>
33
+ </CHANGE_SUMMARY>
34
+ */
35
+ import { createHash } from "node:crypto";
36
+ import { join } from "node:path";
37
+ import { parse as parseYaml } from "yaml";
38
+ import { listRfcFiles, readRfcFrontmatter, rfcFileMatchesId } from "../rfc/frontmatter-io.js";
39
+ import { git } from "./git.js";
40
+ import { commonGitDir, readJournal, readRegistry, RISK_CATEGORIES, } from "./registry.js";
41
+ import { tagAnnotationLevel } from "./publish.js";
42
+ import { discoverReleaseLines } from "./release-lines.js";
43
+ import { listLineTags } from "./release-tags.js";
44
+ import { primaryWorktree } from "./worktree-path.js";
45
+ const RFC_DIR = "docs/rfcs";
46
+ const DEFAULT_SPECS_DIR = "docs/specs";
47
+ const DEFAULT_INVARIANTS_FILE = "docs/architecture-dna.md";
48
+ async function revParse(repoRoot, io, ref) {
49
+ const result = await git(repoRoot, io, ["rev-parse", "--verify", "--quiet", ref]);
50
+ return result.exitCode === 0 ? result.stdout.trim() || null : null;
51
+ }
52
+ /** Oldest→newest commits of `branch` not reachable from any origin/* ref (or from `remoteTip` when given). */
53
+ async function unpushedCommits(repoRoot, io, branch, remoteTip, firstParent = false) {
54
+ const order = firstParent ? ["--reverse", "--first-parent"] : ["--reverse"];
55
+ const args = remoteTip !== null
56
+ ? ["rev-list", ...order, `${remoteTip}..${branch}`]
57
+ : ["rev-list", ...order, branch, "--not", "--remotes=origin"];
58
+ const result = await git(repoRoot, io, args);
59
+ if (result.exitCode !== 0)
60
+ return [];
61
+ return result.stdout.split("\n").map((l) => l.trim()).filter((l) => l.length > 0);
62
+ }
63
+ /** forge.yaml `paths.specsDir` and `bindings.paths.invariantsFile` with the RFC-1491 defaults. */
64
+ async function readPathConfig(repoRoot, io) {
65
+ const file = join(repoRoot, "forge.yaml");
66
+ if (!(await io.exists(file))) {
67
+ return { specsDir: DEFAULT_SPECS_DIR, invariantsFile: DEFAULT_INVARIANTS_FILE };
68
+ }
69
+ try {
70
+ const parsed = parseYaml(await io.readFile(file));
71
+ return {
72
+ specsDir: typeof parsed?.paths?.specsDir === "string" && parsed.paths.specsDir.length > 0
73
+ ? parsed.paths.specsDir
74
+ : DEFAULT_SPECS_DIR,
75
+ invariantsFile: typeof parsed?.bindings?.paths?.invariantsFile === "string" &&
76
+ parsed.bindings.paths.invariantsFile.length > 0
77
+ ? parsed.bindings.paths.invariantsFile
78
+ : DEFAULT_INVARIANTS_FILE,
79
+ };
80
+ }
81
+ catch {
82
+ return { specsDir: DEFAULT_SPECS_DIR, invariantsFile: DEFAULT_INVARIANTS_FILE };
83
+ }
84
+ }
85
+ /** X-RFC trailer ids + subjects of the commits in (base, tip], oldest first. */
86
+ async function commitMeta(repoRoot, io, base, tip) {
87
+ const result = await git(repoRoot, io, [
88
+ "log",
89
+ "--reverse",
90
+ "--format=%s%x00%(trailers:key=X-RFC,valueonly,separator=%x20)",
91
+ `${base}..${tip}`,
92
+ ]);
93
+ if (result.exitCode !== 0)
94
+ return { subjects: [], rfcs: [] };
95
+ const subjects = [];
96
+ const rfcs = new Set();
97
+ for (const line of result.stdout.split("\n")) {
98
+ const [subject, trailers] = line.split("\0");
99
+ if (subject !== undefined && subject.length > 0)
100
+ subjects.push(subject);
101
+ for (const token of (trailers ?? "").split(/\s+/)) {
102
+ if (/^RFC-\d+$/i.test(token))
103
+ rfcs.add(token.toUpperCase());
104
+ }
105
+ }
106
+ return { subjects, rfcs: [...rfcs].sort() };
107
+ }
108
+ /** Frontmatter of every RFC named by id — `{versionBump, commandsRemoved}` per id. */
109
+ async function rfcFacts(repoRoot, ids) {
110
+ const facts = new Map();
111
+ if (ids.length === 0)
112
+ return facts;
113
+ const rfcDirPath = join(repoRoot, RFC_DIR);
114
+ const files = await listRfcFiles(rfcDirPath);
115
+ for (const id of ids) {
116
+ const fileName = files.find((f) => rfcFileMatchesId(f, id));
117
+ if (fileName === undefined) {
118
+ facts.set(id, { versionBump: null, commandsRemoved: false });
119
+ continue;
120
+ }
121
+ const parsed = await readRfcFrontmatter(rfcDirPath, fileName);
122
+ const fm = parsed && "parsed" in parsed
123
+ ? parsed.parsed.frontmatter
124
+ : {};
125
+ const idExact = String(fm["id"] ?? "").trim().toUpperCase() === id;
126
+ const bump = typeof fm["versionBump"] === "string" ? fm["versionBump"] : null;
127
+ const commands = fm["commands"];
128
+ const removed = idExact &&
129
+ typeof commands === "object" &&
130
+ commands !== null &&
131
+ Array.isArray(commands.removed) &&
132
+ (commands.removed.length > 0);
133
+ facts.set(id, {
134
+ versionBump: idExact ? bump : null,
135
+ commandsRemoved: removed,
136
+ });
137
+ }
138
+ return facts;
139
+ }
140
+ /** `git show <ref>:<path>` → parsed JSON, null when absent/unparseable. */
141
+ async function jsonAtRef(repoRoot, io, ref, path) {
142
+ const result = await git(repoRoot, io, ["show", `${ref}:${path}`]);
143
+ if (result.exitCode !== 0)
144
+ return null;
145
+ try {
146
+ const parsed = JSON.parse(result.stdout);
147
+ return typeof parsed === "object" && parsed !== null ? parsed : null;
148
+ }
149
+ catch {
150
+ return null;
151
+ }
152
+ }
153
+ const DEP_SECTIONS = ["dependencies", "devDependencies", "peerDependencies"];
154
+ /** Major number of a semver spec, ignoring ^ ~ >= and whitespace; null for non-semver. */
155
+ function specMajor(spec) {
156
+ if (typeof spec !== "string")
157
+ return null;
158
+ const cleaned = spec.trim().replace(/^(\^|~|>=?)\s*/, "");
159
+ const match = cleaned.match(/^(\d+)\.\d+\.\d+/);
160
+ return match === null ? null : Number.parseInt(match[1], 10);
161
+ }
162
+ /**
163
+ * Package-json risk signals of an item touching `path`: a removed `exports`
164
+ * key (capability-removal) or a raised dependency major (major-dependency).
165
+ */
166
+ async function packageJsonSignals(repoRoot, io, base, tip, path) {
167
+ const before = await jsonAtRef(repoRoot, io, base, path);
168
+ const after = await jsonAtRef(repoRoot, io, tip, path);
169
+ if (before === null || after === null)
170
+ return { exportsRemoved: false, majorRaised: false };
171
+ const beforeExports = before["exports"];
172
+ const afterExports = after["exports"];
173
+ const exportsRemoved = typeof beforeExports === "object" &&
174
+ beforeExports !== null &&
175
+ typeof afterExports === "object" &&
176
+ afterExports !== null &&
177
+ Object.keys(beforeExports).some((key) => !Object.prototype.hasOwnProperty.call(afterExports, key));
178
+ let majorRaised = false;
179
+ for (const section of DEP_SECTIONS) {
180
+ const b = before[section];
181
+ const a = after[section];
182
+ if (typeof b !== "object" || b === null || typeof a !== "object" || a === null)
183
+ continue;
184
+ for (const [dep, spec] of Object.entries(a)) {
185
+ const oldMajor = specMajor(b[dep]);
186
+ const newMajor = specMajor(spec);
187
+ if (oldMajor !== null && newMajor !== null && newMajor > oldMajor) {
188
+ majorRaised = true;
189
+ }
190
+ }
191
+ }
192
+ return { exportsRemoved: exportsRemoved === true, majorRaised };
193
+ }
194
+ /** Risk classification of the diff `base..tip` — first match wins; flags hold all matches. */
195
+ async function classifyItem(repoRoot, io, base, tip, rfcs, specsDir, invariantsFile) {
196
+ const flags = new Set();
197
+ const names = await git(repoRoot, io, ["diff", "--name-only", base, tip]);
198
+ const files = names.exitCode === 0
199
+ ? names.stdout.split("\n").map((l) => l.trim()).filter((l) => l.length > 0)
200
+ : [];
201
+ const specsPrefix = `${specsDir.replace(/\/+$/, "")}/`;
202
+ if (files.some((f) => f.startsWith(specsPrefix) || f.endsWith(".schema.json") || f.split("/").includes("schemas"))) {
203
+ flags.add("contract");
204
+ }
205
+ if (files.some((f) => f === invariantsFile || f.endsWith(".proof.yaml"))) {
206
+ flags.add("invariant");
207
+ }
208
+ const facts = await rfcFacts(repoRoot, rfcs);
209
+ for (const fact of facts.values()) {
210
+ if (fact.versionBump === "minor" || fact.versionBump === "major")
211
+ flags.add("migration");
212
+ if (fact.commandsRemoved)
213
+ flags.add("capability-removal");
214
+ }
215
+ // @ai-invariant lines in the added/removed set — zero-context diff keeps the scan tight.
216
+ const diff = await git(repoRoot, io, ["diff", "--unified=0", "--no-color", base, tip]);
217
+ if (diff.exitCode === 0) {
218
+ for (const line of diff.stdout.split("\n")) {
219
+ if ((line.startsWith("+") || line.startsWith("-")) && line.includes("@ai-invariant")) {
220
+ flags.add("invariant");
221
+ break;
222
+ }
223
+ }
224
+ }
225
+ for (const file of files) {
226
+ if (file !== "package.json" && !file.endsWith("/package.json"))
227
+ continue;
228
+ const signals = await packageJsonSignals(repoRoot, io, base, tip, file);
229
+ if (signals.exportsRemoved)
230
+ flags.add("capability-removal");
231
+ if (signals.majorRaised)
232
+ flags.add("major-dependency");
233
+ }
234
+ const ordered = RISK_CATEGORIES.filter((c) => c !== "other" && flags.has(c));
235
+ return { category: ordered[0] ?? "other", flags: ordered };
236
+ }
237
+ /**
238
+ * The newest journal record per branch among integrate/backmerge/cut and
239
+ * hold.rewrites (later journal lines win — the journal is append-only).
240
+ */
241
+ function attributedRecords(journal) {
242
+ const byBranch = new Map();
243
+ for (const event of journal) {
244
+ if (event.event === "integrate" || event.event === "backmerge") {
245
+ const kind = event.event === "backmerge" || event.branch.startsWith("auto/port-")
246
+ ? "backmerge"
247
+ : "integration";
248
+ byBranch.set(event.branch, {
249
+ branch: event.branch,
250
+ kind,
251
+ base: event.base ?? "",
252
+ tip: event.sha,
253
+ });
254
+ }
255
+ else if (event.event === "cut") {
256
+ byBranch.set(event.branch, {
257
+ branch: event.branch,
258
+ kind: "release",
259
+ base: event.base ?? "",
260
+ tip: event.sha,
261
+ });
262
+ }
263
+ else if (event.event === "hold" && Array.isArray(event.rewrites)) {
264
+ for (const rewrite of event.rewrites) {
265
+ byBranch.set(rewrite.branch, {
266
+ branch: rewrite.branch,
267
+ kind: rewrite.kind,
268
+ base: rewrite.base,
269
+ tip: rewrite.sha,
270
+ });
271
+ }
272
+ }
273
+ }
274
+ return [...byBranch.values()];
275
+ }
276
+ /** Remote tag names via ls-remote; null when the remote cannot be queried. */
277
+ async function remoteTagNames(repoRoot, io) {
278
+ const result = await git(repoRoot, io, ["ls-remote", "--tags", "origin"]);
279
+ if (result.exitCode !== 0)
280
+ return null;
281
+ const names = new Set();
282
+ for (const line of result.stdout.split("\n")) {
283
+ const match = line.match(/refs\/tags\/([^\s^]+)$/);
284
+ if (match?.[1] !== undefined)
285
+ names.add(match[1]);
286
+ }
287
+ return names;
288
+ }
289
+ /** Tag is treated as remote-known when its commit is an ancestor of an origin/* tip. */
290
+ async function tagReachableFromRemote(repoRoot, io, tag) {
291
+ const tips = await git(repoRoot, io, [
292
+ "for-each-ref",
293
+ "--format=%(refname)",
294
+ "refs/remotes/origin",
295
+ ]);
296
+ if (tips.exitCode !== 0)
297
+ return false;
298
+ for (const tip of tips.stdout.split("\n").map((l) => l.trim()).filter((l) => l.length > 0)) {
299
+ const ancestor = await git(repoRoot, io, ["merge-base", "--is-ancestor", tag, tip]);
300
+ if (ancestor.exitCode === 0)
301
+ return true;
302
+ }
303
+ return false;
304
+ }
305
+ const WORKFLOWS_DIR = join(".github", "workflows");
306
+ /**
307
+ * The `on.push.tags` patterns of one parsed workflow document (RFC-1498).
308
+ * Only a mapping `on:` with `push.tags` yields patterns — `on: push`,
309
+ * `on: [push, …]` and `push:` without `tags` trigger on branches, not
310
+ * tags. `on` may arrive as the boolean `true` when the file was authored
311
+ * for YAML 1.1 semantics.
312
+ */
313
+ function pushTagPatterns(parsed) {
314
+ if (typeof parsed !== "object" || parsed === null)
315
+ return [];
316
+ const rec = parsed;
317
+ const on = rec["on"] ?? rec["true"];
318
+ if (typeof on !== "object" || on === null || Array.isArray(on))
319
+ return [];
320
+ const push = on["push"];
321
+ if (typeof push !== "object" || push === null || Array.isArray(push))
322
+ return [];
323
+ const tags = push["tags"];
324
+ if (typeof tags === "string")
325
+ return [tags];
326
+ if (Array.isArray(tags))
327
+ return tags.filter((t) => typeof t === "string");
328
+ return [];
329
+ }
330
+ /**
331
+ * GitHub glob → regex for the tag-name subset Forge evaluates (RFC-1498):
332
+ * `*` within a segment, `**` across segments, `?` one char. Returns null
333
+ * for patterns we do not understand — `[` character classes and leading
334
+ * `!` negations — so the caller can report them instead of guessing.
335
+ */
336
+ export function tagPatternRegex(pattern) {
337
+ if (pattern.startsWith("!") || pattern.includes("["))
338
+ return null;
339
+ let out = "^";
340
+ for (let i = 0; i < pattern.length; i++) {
341
+ const c = pattern[i];
342
+ if (c === "*") {
343
+ if (pattern[i + 1] === "*") {
344
+ out += ".*";
345
+ i++;
346
+ }
347
+ else {
348
+ out += "[^/]*";
349
+ }
350
+ }
351
+ else if (c === "?") {
352
+ out += ".";
353
+ }
354
+ else {
355
+ out += c.replace(/[.+^${}()|\\]/g, "\\$&");
356
+ }
357
+ }
358
+ return new RegExp(`${out}$`);
359
+ }
360
+ /**
361
+ * Tag-trigger patterns of every `.github/workflows/*.y{ml,aml}` file under
362
+ * `dir` (RFC-1498), repo-relative file paths. A file that cannot be read
363
+ * or parsed reports FLOW-11 and contributes nothing; a pattern the glob
364
+ * subset does not cover reports FLOW-11 and matches nothing.
365
+ */
366
+ async function workflowTagPatterns(dir, io, diagnostics) {
367
+ const workflows = [];
368
+ if (!(await io.exists(dir)))
369
+ return workflows;
370
+ const entries = await io.readdir(dir).catch(() => []);
371
+ const names = entries
372
+ .filter((e) => e.isFile && /\.ya?ml$/.test(e.name))
373
+ .map((e) => e.name)
374
+ .sort();
375
+ for (const name of names) {
376
+ const file = `${WORKFLOWS_DIR}/${name}`;
377
+ const text = await io.readFile(join(dir, name)).catch(() => null);
378
+ let parsed = null;
379
+ let ok = text !== null;
380
+ if (text !== null) {
381
+ try {
382
+ parsed = parseYaml(text);
383
+ }
384
+ catch {
385
+ ok = false;
386
+ }
387
+ }
388
+ if (!ok) {
389
+ diagnostics.push({
390
+ ruleId: "FLOW-11",
391
+ severity: "warning",
392
+ file,
393
+ message: `workflow ${file} cannot be parsed — its tag triggers are not evaluated`,
394
+ fixHint: "fix the workflow YAML — the digest treats it as matching nothing",
395
+ });
396
+ continue;
397
+ }
398
+ const patterns = pushTagPatterns(parsed);
399
+ for (const p of patterns) {
400
+ if (tagPatternRegex(p) === null) {
401
+ diagnostics.push({
402
+ ruleId: "FLOW-11",
403
+ severity: "warning",
404
+ file,
405
+ message: `workflow ${file}: tag pattern '${p}' not understood — it matches nothing`,
406
+ fixHint: "use plain globs (*, **, ?) — character classes and negations are not evaluated",
407
+ });
408
+ }
409
+ }
410
+ if (patterns.length > 0)
411
+ workflows.push({ file, patterns });
412
+ }
413
+ return workflows;
414
+ }
415
+ /** The release line a tag belongs to — longest prefix wins. */
416
+ export function lineForTag(lines, tag) {
417
+ let best = null;
418
+ for (const line of lines) {
419
+ if (!tag.startsWith(line.tagPrefix))
420
+ continue;
421
+ if (best === null || line.tagPrefix.length > best.tagPrefix.length)
422
+ best = line;
423
+ }
424
+ return best;
425
+ }
426
+ /** Recursively key-sorted JSON.stringify — the digestId's canonical form. */
427
+ function canonicalJson(value) {
428
+ if (Array.isArray(value))
429
+ return `[${value.map(canonicalJson).join(",")}]`;
430
+ if (typeof value === "object" && value !== null) {
431
+ const entries = Object.entries(value)
432
+ .sort(([a], [b]) => a.localeCompare(b))
433
+ .map(([k, v]) => `${JSON.stringify(k)}:${canonicalJson(v)}`);
434
+ return `{${entries.join(",")}}`;
435
+ }
436
+ return JSON.stringify(value);
437
+ }
438
+ /**
439
+ * Collect the outbound digest of repoRoot. `opts.fetch === false` skips the
440
+ * `git fetch origin --prune`; a failed fetch yields `fetched: false` plus a
441
+ * warning — never an error.
442
+ */
443
+ export async function collectDigest(repoRoot, io, opts) {
444
+ const diagnostics = [];
445
+ const hasOrigin = (await git(repoRoot, io, ["remote", "get-url", "origin"])).exitCode === 0;
446
+ if (!hasOrigin) {
447
+ diagnostics.push({
448
+ ruleId: "FLOW-PUSH-01",
449
+ severity: "error",
450
+ message: "no 'origin' remote — flow.push has nothing to push to",
451
+ });
452
+ }
453
+ let fetched = false;
454
+ if (hasOrigin && opts.fetch) {
455
+ const fetch = await git(repoRoot, io, ["fetch", "origin", "--prune"]);
456
+ fetched = fetch.exitCode === 0;
457
+ if (!fetched) {
458
+ diagnostics.push({
459
+ ruleId: "FLOW-DIGEST-01",
460
+ severity: "warning",
461
+ message: `git fetch origin --prune failed — the digest is computed on stale remote-tracking refs: ${fetch.stderr.trim().split("\n").slice(-1)[0] ?? "unknown error"}`,
462
+ });
463
+ }
464
+ }
465
+ const developLocal = await revParse(repoRoot, io, "develop");
466
+ const mainLocal = await revParse(repoRoot, io, "main");
467
+ const developRemote = await revParse(repoRoot, io, "refs/remotes/origin/develop");
468
+ const mainRemote = await revParse(repoRoot, io, "refs/remotes/origin/main");
469
+ const developTail = developLocal === null ? [] : await unpushedCommits(repoRoot, io, "develop", developRemote);
470
+ const mainTail = mainLocal === null ? [] : await unpushedCommits(repoRoot, io, "main", mainRemote);
471
+ // --- items: journal-attributed segments of the develop tail ---------------
472
+ // Segments follow develop's first-parent chain: a back-merge brings main's
473
+ // commits in through its second parent, and a fix cut's range lives on
474
+ // main — index spans over the full (date-ordered) list would misattribute.
475
+ const developChain = developLocal === null ? [] : await unpushedCommits(repoRoot, io, "develop", developRemote, true);
476
+ const common = await commonGitDir(io, repoRoot);
477
+ const journal = await readJournal(io, common);
478
+ const tailIndex = new Map(developChain.map((sha, i) => [sha, i]));
479
+ const boundary = developRemote ??
480
+ (developChain.length > 0 ? await revParse(repoRoot, io, `${developChain[0]}^`) : null);
481
+ const claimed = new Set();
482
+ const records = attributedRecords(journal)
483
+ .filter((r) => tailIndex.has(r.tip) && (tailIndex.has(r.base) || r.base === boundary))
484
+ .sort((a, b) => (tailIndex.get(b.tip) ?? 0) - (tailIndex.get(a.tip) ?? 0));
485
+ const segments = [];
486
+ for (const record of records) {
487
+ const from = record.base === boundary ? 0 : (tailIndex.get(record.base) ?? -1) + 1;
488
+ const to = tailIndex.get(record.tip);
489
+ const span = [];
490
+ for (let i = from; i <= to; i++) {
491
+ if (!claimed.has(i))
492
+ span.push(i);
493
+ }
494
+ for (const i of span)
495
+ claimed.add(i);
496
+ if (span.length > 0)
497
+ segments.push({ record, from: span[0], to: span[span.length - 1] });
498
+ }
499
+ // Maximal unclaimed runs → unattributed items.
500
+ let runStart = null;
501
+ for (let i = 0; i <= developChain.length; i++) {
502
+ if (i < developChain.length && !claimed.has(i)) {
503
+ if (runStart === null)
504
+ runStart = i;
505
+ }
506
+ else if (runStart !== null) {
507
+ segments.push({ record: null, from: runStart, to: i - 1 });
508
+ runStart = null;
509
+ }
510
+ }
511
+ segments.sort((a, b) => a.from - b.from);
512
+ const { specsDir, invariantsFile } = await readPathConfig(repoRoot, io);
513
+ const items = [];
514
+ for (const segment of segments) {
515
+ const base = segment.from === 0 ? (boundary ?? "4b825dc642cb6eb9a060e54bf8d69288fbee4904") : developChain[segment.from - 1];
516
+ const tip = developChain[segment.to];
517
+ const meta = await commitMeta(repoRoot, io, base, tip);
518
+ const cls = await classifyItem(repoRoot, io, base, tip, meta.rfcs, specsDir, invariantsFile);
519
+ items.push({
520
+ id: `I-${tip.slice(0, 9)}`,
521
+ kind: segment.record?.kind ?? "unattributed",
522
+ branch: segment.record?.branch ?? null,
523
+ base,
524
+ tip,
525
+ commits: meta.subjects.length,
526
+ subjects: meta.subjects,
527
+ rfcs: meta.rfcs,
528
+ category: cls.category,
529
+ flags: cls.flags,
530
+ });
531
+ }
532
+ // --- new release tags ------------------------------------------------------
533
+ const { lines } = await discoverReleaseLines(repoRoot, io);
534
+ // The RFC names `git ls-remote --tags origin` — a read-only query, run
535
+ // whenever origin exists (--no-fetch still allows it). A failed query
536
+ // degrades to the reachability approximation.
537
+ const remoteTags = hasOrigin ? await remoteTagNames(repoRoot, io) : null;
538
+ const tags = [];
539
+ const allLocalTags = new Set();
540
+ for (const line of lines) {
541
+ const { reachable } = await listLineTags(repoRoot, line, io);
542
+ for (const tag of reachable) {
543
+ allLocalTags.add(tag);
544
+ const remoteKnown = remoteTags !== null ? remoteTags.has(tag) : await tagReachableFromRemote(repoRoot, io, tag);
545
+ if (!remoteKnown)
546
+ tags.push(tag);
547
+ }
548
+ }
549
+ tags.sort((a, b) => a.localeCompare(b));
550
+ // --- held + pending publications -------------------------------------------
551
+ const registry = await readRegistry(io, common);
552
+ const held = registry.branches
553
+ .filter((b) => b.held !== null)
554
+ .map((b) => ({
555
+ branch: b.name,
556
+ tip: b.held.tip,
557
+ reason: b.held.reason,
558
+ riskCategory: b.held.riskCategory,
559
+ heldAt: b.held.heldAt,
560
+ }));
561
+ const pendingPublications = [];
562
+ const pushedTags = new Set();
563
+ const publishedTags = new Set();
564
+ for (const event of journal) {
565
+ if (event.event === "push") {
566
+ for (const token of event.detail.split(/[^A-Za-z0-9._/@-]+/)) {
567
+ if (token.length > 0)
568
+ pushedTags.add(token);
569
+ }
570
+ }
571
+ else if (event.event === "publish") {
572
+ publishedTags.add(event.branch);
573
+ }
574
+ }
575
+ for (const tag of [...pushedTags].sort((a, b) => a.localeCompare(b))) {
576
+ if (!allLocalTags.has(tag) || publishedTags.has(tag))
577
+ continue;
578
+ const line = lineForTag(lines, tag);
579
+ // Repo-line tags are never extracted, and baseline annotations are
580
+ // skipped at push time — neither ever gains a publish record.
581
+ if (line === null || line.id === "repo")
582
+ continue;
583
+ if ((await tagAnnotationLevel(repoRoot, io, tag)) === "baseline")
584
+ continue;
585
+ pendingPublications.push({ tag, line: line.id });
586
+ }
587
+ // --- CI workflows a tag push would trigger (RFC-1498) --------------------
588
+ // Read on the primary checkout — that is the working copy the operator
589
+ // sees; a bare or primary-less repo degrades to no workflows.
590
+ let primary = repoRoot;
591
+ try {
592
+ primary = await primaryWorktree(io, repoRoot);
593
+ }
594
+ catch {
595
+ primary = repoRoot;
596
+ }
597
+ const tagPatterns = await workflowTagPatterns(join(primary, WORKFLOWS_DIR), io, diagnostics);
598
+ const tagTriggers = [];
599
+ for (const tag of tags) {
600
+ const workflows = tagPatterns
601
+ .filter((w) => w.patterns.some((p) => tagPatternRegex(p)?.test(tag) === true))
602
+ .map((w) => w.file);
603
+ if (workflows.length > 0)
604
+ tagTriggers.push({ tag, workflows });
605
+ }
606
+ const byCategory = Object.fromEntries(RISK_CATEGORIES.map((c) => [c, []]));
607
+ for (const item of items)
608
+ byCategory[item.category].push(item.id);
609
+ const digestId = createHash("sha256")
610
+ .update(canonicalJson({
611
+ develop: { local: developLocal, remote: developRemote, ahead: developTail.length },
612
+ main: { local: mainLocal, remote: mainRemote, ahead: mainTail.length },
613
+ tags,
614
+ tagTriggers,
615
+ items: items.map((i) => ({ id: i.id, tip: i.tip })),
616
+ }))
617
+ .digest("hex")
618
+ .slice(0, 12);
619
+ return {
620
+ digestId,
621
+ remote: "origin",
622
+ fetched,
623
+ develop: { local: developLocal ?? "", remote: developRemote, ahead: developTail.length },
624
+ main: { local: mainLocal ?? "", remote: mainRemote, ahead: mainTail.length },
625
+ tags,
626
+ items,
627
+ byCategory,
628
+ held,
629
+ pendingPublications,
630
+ tagTriggers,
631
+ diagnostics,
632
+ };
633
+ }
634
+ //# sourceMappingURL=digest.js.map