@attalabs/vinaya 0.31.0 → 0.33.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 (212) hide show
  1. package/README.md +2 -3
  2. package/aeg-root/contracts/principal-operator.md +18 -5
  3. package/aeg-root/roles/developer/reference.md +3 -3
  4. package/aeg-root/roles/operator.md +69 -16
  5. package/aeg-root/roles/planner/reference.md +1 -1
  6. package/aeg-root/roles/tranche-archivist.md +1 -0
  7. package/aeg-root/skills/aeg-context-packets/SKILL.md +1 -1
  8. package/aeg-root/skills/aeg-context-packets/examples/operator-start.md +1 -1
  9. package/aeg-root/templates/pr-report-template.md +7 -2
  10. package/dist/checks/bin/check-body-bare-digits.js +340 -101
  11. package/dist/checks/bin/check-branch-topology.js +184 -105
  12. package/dist/checks/bin/check-brief-shape.js +333 -94
  13. package/dist/checks/bin/check-changeset-coverage.js +1028 -248
  14. package/dist/checks/bin/check-ci-shard-coverage.js +82 -0
  15. package/dist/checks/bin/check-closes-n.js +184 -105
  16. package/dist/checks/bin/check-coherence.js +345 -145
  17. package/dist/checks/bin/check-dead-branch-push.js +179 -59
  18. package/dist/checks/bin/check-dispatch-readiness.js +350 -150
  19. package/dist/checks/bin/check-doc-coverage-push.js +1011 -231
  20. package/dist/checks/bin/check-doc-coverage.js +1015 -235
  21. package/dist/checks/bin/check-doctrine-no-procedures.js +333 -94
  22. package/dist/checks/bin/check-doctrine-portability.js +1013 -233
  23. package/dist/checks/bin/check-evidence-fresh.js +1010 -222
  24. package/dist/checks/bin/check-exec-bits.js +1009 -229
  25. package/dist/checks/bin/check-first-push-dispatch.js +343 -145
  26. package/dist/checks/bin/check-issue-assignment.js +186 -107
  27. package/dist/checks/bin/check-issue-milestone-attach.js +176 -56
  28. package/dist/checks/bin/check-issue-objectives-numbering.js +176 -56
  29. package/dist/checks/bin/check-issue-parts-coverage.js +176 -56
  30. package/dist/checks/bin/check-issue-surface-globs.js +363 -143
  31. package/dist/checks/bin/check-issue-title-grammar.js +176 -56
  32. package/dist/checks/bin/check-issue-tranche-label.js +176 -56
  33. package/dist/checks/bin/check-main-branch-refusal.js +176 -56
  34. package/dist/checks/bin/check-no-disk-state.js +176 -56
  35. package/dist/checks/bin/check-pr-premise-reassert.js +333 -92
  36. package/dist/checks/bin/check-pr-report-density.js +176 -56
  37. package/dist/checks/bin/check-principal-test-plan-wait.js +176 -54
  38. package/dist/checks/bin/check-quoted-command.js +999 -217
  39. package/dist/checks/bin/check-reader-resolvable-prose.js +1011 -229
  40. package/dist/checks/bin/check-registry-gates.js +186 -56
  41. package/dist/checks/bin/check-retired-vocabulary.js +997 -215
  42. package/dist/checks/bin/check-review-gate.js +403 -203
  43. package/dist/checks/bin/check-single-plan-pr.js +176 -56
  44. package/dist/checks/bin/check-surface-scope.js +184 -105
  45. package/dist/checks/bin/check-test-plan.js +176 -54
  46. package/dist/checks/bin/check-token-collection-wired.js +182 -57
  47. package/dist/checks/bin/check-token-report.js +178 -58
  48. package/dist/checks/bin/check-workspace-escape.js +1011 -229
  49. package/dist/index.js +5971 -3489
  50. package/dist/lib/pre-push-cache-test-run.js +4431 -0
  51. package/dist/lib/pre-push-select-tests.js +799 -110
  52. package/package.json +3 -2
  53. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/actions.ts +10 -12
  54. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +5 -5
  55. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/archive-task.ts +42 -17
  56. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/baseline-capture.ts +1 -2
  57. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/branch-topology-gate.ts +3 -3
  58. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +554 -95
  59. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +264 -44
  60. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/claude-code-transcript.ts +9 -9
  61. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +211 -30
  62. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/consumer-enumeration.ts +2 -2
  63. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/index.ts +75 -0
  64. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +961 -0
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/migration.ts +212 -0
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/outcomes.ts +135 -0
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +394 -0
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dead-branch-push-audit.ts +1 -2
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dead-branch-push-guard.ts +1 -1
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/derive-section7.ts +2 -2
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +514 -0
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +110 -0
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +27 -0
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +123 -0
  75. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +27 -0
  76. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +240 -0
  77. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/diagram-model.ts +1 -1
  78. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/direct-main-push.ts +1 -2
  79. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +65 -22
  80. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-claim.ts +238 -0
  81. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-owners.ts +14 -1
  82. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/docs-coherence.ts +1 -1
  83. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/legacy-anchors.ts +1 -1
  84. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/node-route.ts +1 -1
  85. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/surfaced-manifest.ts +1 -1
  86. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-no-procedures.ts +1 -1
  87. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +5 -5
  88. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ensure-label.ts +1 -1
  89. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/first-push-dispatch-gate.ts +1 -1
  90. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +14 -3
  91. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +379 -11
  92. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-assignment.ts +3 -4
  93. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +1450 -33
  94. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/leftover-detection.ts +1 -2
  95. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/local-anchor-coverage.ts +2 -2
  96. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +119 -0
  97. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +75 -0
  98. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/redact.ts +87 -0
  99. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +801 -0
  100. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/store.ts +373 -0
  101. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +2 -2
  102. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/metering-io-guard.ts +1 -1
  103. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/milestone-validation.ts +2 -3
  104. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/no-disk-state.ts +2 -2
  105. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives.ts +288 -0
  106. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/parse-token-report.ts +3 -3
  107. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/parse-tranche.ts +1 -1
  108. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-report-density.ts +30 -16
  109. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-tier.ts +17 -1
  110. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/premise-check.ts +1 -1
  111. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/quoted-command.ts +1 -1
  112. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +267 -19
  113. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +91 -24
  114. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-scaffold.ts +6 -6
  115. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/report-tokens.ts +4 -4
  116. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +239 -110
  117. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +384 -0
  118. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +184 -0
  119. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +65 -18
  120. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +76 -0
  121. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/single-plan-pr.ts +4 -4
  122. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/state-machine-model.ts +40 -27
  123. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/symbol-collisions.ts +2 -2
  124. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-branch-identity.ts +38 -0
  125. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +488 -0
  126. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-gate.ts +7 -9
  127. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-section.ts +5 -5
  128. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/types.ts +4 -4
  129. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +314 -56
  130. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/waiver-label.ts +2 -3
  131. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/workspace-escape.ts +3 -3
  132. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  133. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  134. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  135. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  136. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  137. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  138. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  141. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  143. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  144. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  145. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js +1 -1
  146. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  149. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  150. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  151. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +1 -1
  152. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  153. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  154. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  155. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +1 -1
  156. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  157. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  158. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  159. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +1 -1
  160. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  161. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  162. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  163. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +2 -2
  164. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  165. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  166. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  167. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +1 -1
  168. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  169. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  170. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  171. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +1 -1
  172. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  173. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  174. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  175. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +1 -1
  176. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  177. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  178. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/{[externals]__1agj1ww._.js → [externals]__0cki-x_._.js} +2 -2
  179. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +6 -6
  180. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/1q96_modules_@clerk_nextjs_dist_esm_app-router_client_keyless-creator-reader_0lom2js.js +1 -1
  181. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +3 -0
  182. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  183. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__0r7e54g._.js → [root-of-the-server]__18paley._.js} +1 -1
  184. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  185. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  186. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1r47dr7._.js → _08onyya._.js} +3 -3
  187. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  188. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  189. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  190. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  191. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0y1jv16._.js +1 -1
  192. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  193. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  194. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_15gdg48._.js +5 -5
  195. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  196. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_@clerk_nextjs_dist_esm_app-router_server-actions_1x7vfhn.js +2 -2
  197. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  198. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  199. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  200. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  201. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bjnj-5fy4e7l.js +1 -0
  202. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1dc2_-c_gavj1.js → 1ce2dj27_cgbj.js} +4 -4
  203. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3xg6-flovrcx-.js → 22s44f5k3ecmj.js} +1 -1
  204. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/34hhdtbp20krb.js +1 -0
  205. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  206. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0hstap0._.js +0 -3
  207. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2t_rfsztmwu6y.js +0 -1
  208. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3ua4rm5f-a9k6.js +0 -1
  209. /package/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/{aeg-core → vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
  210. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_buildManifest.js +0 -0
  211. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_clientMiddlewareManifest.js +0 -0
  212. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_ssgManifest.js +0 -0
@@ -0,0 +1,123 @@
1
+ /**
2
+ * The round journal is the task's, not the driver's — and it is rebuilt from
3
+ * the control store and the forge's own principal-authored markers, NEVER
4
+ * from a log event. The Vinaya Log is fail-open telemetry: it "is never the
5
+ * authority for dispatch, approval, publication or recovery" (Log tech spec,
6
+ * §1), so no reconstruction here reads a `dev_review_loop` event, a flushed
7
+ * log comment, or the telemetry outbox. This closes the dependency the Log
8
+ * spec forbade before the log destination moves off the tracker — a rebuild
9
+ * that replayed the loop's own flushed log events would break the moment
10
+ * those events stopped going to the tracker.
11
+ *
12
+ * This module is the PURE half of the rebuild: given the round numbers the
13
+ * forge's own principal-authored developer round markers carry, and whether a
14
+ * ready-for-merge summary was actually published to the forge, hand back one
15
+ * `RoundRecord` per round plus where the next round should start numbering.
16
+ * The impure caller (`journal-history.ts`, `@attalabs/vinaya`) gathers those
17
+ * two facts: it reads the pull request's principal-authored comments and the
18
+ * control store, never a log line. The control store's own authoritative
19
+ * round is recovered separately by the driver (`recoverLoopState`), and is
20
+ * deliberately NOT folded into the numbering here — see `reconstructRounds`.
21
+ *
22
+ * Honest about what the forge markers carry: a developer round marker
23
+ * (`<!-- aeg:developer:round-<n> -->`) names only the round's own number and
24
+ * head — never a per-severity finding breakdown, a confidence value, or the
25
+ * round's wall time / files changed. Those had a source only in the log
26
+ * events this rebuild no longer reads, so a reconstructed round carries an
27
+ * empty `countsBySeverity`, a `null` confidence, and the totals read `0`
28
+ * (O3: "the summary says it is unavailable for that round" rather than a
29
+ * fabricated number). What the markers DO carry — the round's own existence
30
+ * and number, and whether the run reached a published summary — is exactly
31
+ * what the numbering and the "already published?" decision need.
32
+ */
33
+
34
+ import { SEVERITY_COLUMNS, type RoundRecord } from './types'
35
+
36
+ /**
37
+ * The published summary's own header row, byte-for-byte as `render-summary.ts`
38
+ * emits it — both derived from `SEVERITY_COLUMNS`, so the detector here and
39
+ * the renderer there can never drift about what a summary comment looks like.
40
+ * A principal-authored comment carrying this line is the ready-for-merge
41
+ * summary itself: the one honest "the summary was actually published" signal,
42
+ * distinct from a round merely deciding `publish` (the control store's own
43
+ * `loop_state.phase === 'publish'` is written before `publishRound` runs, so
44
+ * it can never stand in for this).
45
+ */
46
+ export const SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(' | ')} | confidence | outcome |`
47
+
48
+ /** True when `body` is (or contains, verbatim on its own line) the published summary's header — the caller has already confirmed the comment is principal-authored. */
49
+ export function isPublishedSummaryComment(body: string): boolean {
50
+ return body.split('\n').some((line) => line.trim() === SUMMARY_TABLE_HEADER)
51
+ }
52
+
53
+ /**
54
+ * The two forge-derived facts a rebuild is handed. `roundMarkers` are the
55
+ * round numbers read off every principal-authored developer round marker on
56
+ * the pull request (order and duplicates irrelevant — deduplicated here).
57
+ * `summaryPublished` is whether a principal-authored summary comment exists.
58
+ */
59
+ export type ReconstructionInput = {
60
+ roundMarkers: readonly number[]
61
+ summaryPublished: boolean
62
+ }
63
+
64
+ export type ReconstructedJournal = {
65
+ rounds: RoundRecord[]
66
+ /** Deliberately `0`: per-round wall time has no control-record or forge source, so it is reported unavailable rather than a fabricated sum (O3). */
67
+ totalWallMs: number
68
+ /** Deliberately `0`: per-round files-changed has no control-record or forge source, so it is reported unavailable rather than a fabricated sum (O3). */
69
+ totalFilesChanged: number
70
+ /**
71
+ * `{ result: 'merged_ready' }` ONLY when a principal-authored ready-for-
72
+ * merge summary comment is actually on the forge — the one honest signal a
73
+ * run reached publication. A round that decided `publish` but crashed before
74
+ * the summary landed (a `gh` failure mid-publish) leaves NO summary comment,
75
+ * so this reads `null` and the caller never mistakes that crash for a
76
+ * completion — the exact distinction the old log-derived `journal_finalized`
77
+ * deferral drew, now drawn from the forge instead. Consumers only ever test
78
+ * `=== 'merged_ready'`; `'stopped'` is retained in the type for parity with
79
+ * the shape this replaces but is never produced here.
80
+ */
81
+ journalFinalized: { result: 'merged_ready' | 'stopped' } | null
82
+ }
83
+
84
+ /**
85
+ * One `RoundRecord` per distinct developer round marker found on the forge,
86
+ * sorted ascending. Deliberately marker-derived ONLY: the control store's own
87
+ * `loop_state.round` is the driver's authoritative current round and is
88
+ * clamped in separately by `recoverLoopState` (`dev-review-loop.ts`'s round
89
+ * bump), NEVER folded into the numbering here. Were it folded in, an attach
90
+ * whose control store records an in-flight round `k` (its markers not yet on
91
+ * the forge) would reconstruct `k` rounds and bump the next round to `k+1`,
92
+ * skipping the very round the control store says is still running — the
93
+ * "recovers from the control store alone" fixture proves round `k` must be
94
+ * kept, so this function must not carry it past `nextRoundNumber`.
95
+ *
96
+ * `countsBySeverity`/`confidence` are unavailable from a marker (O3): empty and
97
+ * `null`, never a guessed count. `outcome` is `'changes_requested'` — the
98
+ * loop only posts a later round's marker after the prior round concluded
99
+ * changes-requested and re-dispatched the developer, so every reconstructed
100
+ * round is one the loop moved past; the published/green round is the live
101
+ * run's own computed record, never one rebuilt here.
102
+ */
103
+ export function reconstructRounds(input: ReconstructionInput): ReconstructedJournal {
104
+ const distinct = [...new Set(input.roundMarkers)].sort((a, b) => a - b)
105
+ const rounds: RoundRecord[] = distinct.map((round) => ({
106
+ round,
107
+ countsBySeverity: {},
108
+ confidence: null,
109
+ outcome: 'changes_requested'
110
+ }))
111
+ return {
112
+ rounds,
113
+ totalWallMs: 0,
114
+ totalFilesChanged: 0,
115
+ journalFinalized: input.summaryPublished ? { result: 'merged_ready' } : null
116
+ }
117
+ }
118
+
119
+ /** Where a fresh round should start numbering after reconstruction — `1` when there is no prior history at all. */
120
+ export function nextRoundNumber(rounds: readonly RoundRecord[]): number {
121
+ if (rounds.length === 0) return 1
122
+ return Math.max(...rounds.map((r) => r.round)) + 1
123
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * `renderSummary(journal)` — the publication comment. One markdown table, rows per round, counts and the
3
+ * outcome only — no finding prose, and no line either verdict extractor
4
+ * (`../verdict-extraction`) would read as a real verdict: no `VERDICT:`,
5
+ * `Judged head:`, or `Objectives version:` label anywhere in the output.
6
+ */
7
+
8
+ import { SUMMARY_TABLE_HEADER } from './journal-reconstruction'
9
+ import { SEVERITY_COLUMNS, type Confidence, type Journal, type RoundRecord } from './types'
10
+
11
+ function confidenceCell(confidence: Confidence | null): string {
12
+ if (confidence === null) return '—'
13
+ if (confidence === 'absent') return 'absent'
14
+ return `${confidence.value}%`
15
+ }
16
+
17
+ function row(record: RoundRecord): string {
18
+ const counts = SEVERITY_COLUMNS.map((key) => String(record.countsBySeverity[key] ?? 0))
19
+ return `| ${record.round} | ${counts.join(' | ')} | ${confidenceCell(record.confidence)} | ${record.outcome} |`
20
+ }
21
+
22
+ export function renderSummary(journal: Journal): string {
23
+ const header = SUMMARY_TABLE_HEADER
24
+ const divider = `| --- | ${SEVERITY_COLUMNS.map(() => '---').join(' | ')} | --- | --- |`
25
+ const rows = journal.rounds.map(row)
26
+ return [header, divider, ...rows].join('\n')
27
+ }
@@ -0,0 +1,240 @@
1
+ /**
2
+ * The dev-review-loop's own types — the
3
+ * policy half of the loop spec (Linear "Tech spec — Developer Review Loop",
4
+ * rev 4, §16). Pure — no `fs`, no `fetch`, no `process.env`, no vendor name,
5
+ * no prompt anywhere in this directory.
6
+ */
7
+
8
+ import type { DevReviewLoopEvent } from '../log'
9
+
10
+ type Envelope = { meta: unknown; subject: unknown }
11
+ /**
12
+ * The same shape `apps/cli/src/lib/log-sink.ts`'s `LogEventInput` derives
13
+ * from `LogEvent` — mirrored here, scoped to `DevReviewLoopEvent` only,
14
+ * because this package can never import from `apps/cli` (the surface runs
15
+ * one way). `assessRound`'s caller (the driver) passes each returned event
16
+ * straight to the injected `log()`, which fills `meta`/`subject` itself.
17
+ */
18
+ type StripEnvelope<T> = T extends Envelope ? Omit<T, 'meta' | 'subject'> : never
19
+ export type DevReviewLoopEventInput = StripEnvelope<DevReviewLoopEvent>
20
+
21
+ /** O4's fixed column order — shared by `assess-round.ts` (counting) and `render-summary.ts` (rendering) so the two never drift apart. */
22
+ export const SEVERITY_COLUMNS = ['blocker', 'major', 'minor', 'critical', 'high', 'medium', 'low'] as const
23
+
24
+ /** The built form's finding identity (spec §0 item 1) — no fingerprint hashing. */
25
+ export type FindingState = 'open' | 'fix-claimed' | 'reproduced' | 'resolved' | null
26
+
27
+ /**
28
+ * The optional fields mirror
29
+ * `ReviewFindingSchema` (`log/schema.ts`) field-for-field — `severityScale`
30
+ * names which scale `severity` is read against (a free string: this
31
+ * doctrine already has a code-review scale and a security scale, and a
32
+ * third reviewer type should never need a schema change to name its own);
33
+ * `policyTreatment` is a SEPARATE fact from `severity` — the same reported
34
+ * severity can bind or not bind a verdict depending on the effective policy
35
+ * threshold and the body-located-prose cap, so the two are never conflated
36
+ * here either; `confidence`/`confidenceScale`/`confidenceSource` are
37
+ * optional and self-reported, left unset rather than fabricated wherever no
38
+ * reviewer grammar produces one yet.
39
+ */
40
+ export type FindingObservation = {
41
+ id: string
42
+ severity: string
43
+ state: FindingState
44
+ severityScale?: string
45
+ policyTreatment?: 'blocking' | 'non_blocking' | 'unavailable'
46
+ confidence?: number
47
+ confidenceScale?: string
48
+ confidenceSource?: string
49
+ }
50
+
51
+ export type VerdictObservation = {
52
+ role: 'reviewer' | 'security'
53
+ verdict: 'APPROVE' | 'REQUEST CHANGES' | 'PASS' | 'FAIL' | 'ESCALATE'
54
+ objectives: { id: string; met: boolean }[]
55
+ findings: FindingObservation[]
56
+ }
57
+
58
+ /** `spec §6.7`: required, but only ever recorded — never branches except by this task's Principal ruling (§2). */
59
+ export type Confidence = { value: number; reason?: string } | 'absent'
60
+
61
+ /** The round's own diff stats — computed by the driver (git, time), never by this pure module. */
62
+ export type RoundStats = {
63
+ baseHead: string
64
+ head: string
65
+ filesChanged: number
66
+ insertions: number
67
+ deletions: number
68
+ wallMs: number
69
+ }
70
+
71
+ /**
72
+ * One round is up to two `assessRound` calls: a `gate` observation (the
73
+ * mechanical check result for the round's new head, carrying the
74
+ * developer's confidence when round ≥ 2 requires one), then, only once the
75
+ * gate passes and confidence clears, a `verdicts` observation. A `gate`
76
+ * observation with `confidence: 'absent'` may repeat once, for the same
77
+ * round, before the loop pauses (spec §6.7's bounded re-ask).
78
+ */
79
+ export type Observations =
80
+ | ({ kind: 'gate' } & { round: number; green: boolean; confidence?: Confidence; stats: RoundStats })
81
+ | ({ kind: 'verdicts' } & {
82
+ round: number
83
+ verdicts: VerdictObservation[]
84
+ })
85
+
86
+ /**
87
+ * `'infrastructure'`: a review
88
+ * role's work directory carried no `findings.txt`/`report.txt` (or, on a
89
+ * task with objectives, no `objectives.txt`) on two consecutive fresh
90
+ * dispatches — never a verdict, a mechanical-gate stall, or an escalation.
91
+ * The driver detects and retries this itself (it reads no verdict here at
92
+ * all); this member exists so the pause it falls back to on a second
93
+ * failure shares the same vocabulary and rendering path every other pause
94
+ * reason already uses, rather than a second, parallel pause shape.
95
+ *
96
+ * `'objectives_changed'`: the
97
+ * objectives version the driver resolved when it dispatched this round's
98
+ * reviewers no longer matches the version it resolves once their verdicts
99
+ * are back — a principal posted an objectives edit mid-round. Like
100
+ * `'infrastructure'`, the driver detects and decides this itself (comparing
101
+ * two resolutions it fetched is not something `assessRound` can do from an
102
+ * `Observations` value); this member exists so that pause shares the same
103
+ * vocabulary and rendering path every other pause reason already uses.
104
+ *
105
+ * `'ruling_posted'`: the newest
106
+ * principal ruling ordinal the driver resolved when it dispatched this
107
+ * round's reviewers no longer matches the ordinal it resolves once their
108
+ * verdicts are back — a principal posted a ruling mid-round. Same shape as
109
+ * `'objectives_changed'` in every respect: the driver detects and decides
110
+ * it itself, and this member exists only so the pause shares the same
111
+ * vocabulary and rendering path every other pause reason already uses.
112
+ *
113
+ * `'stale_driver'`: the base branch
114
+ * moved past a commit touching the driver's own code
115
+ * (`apps/cli/src/lib/dev-review-loop.ts`, `apps/cli/src/commands/
116
+ * review-post.ts`, or this package) since the loop started — same shape
117
+ * again: the driver compares its recorded start-of-loop base head against a
118
+ * freshly re-read one and decides this itself, so a running driver never
119
+ * publishes verdicts an updated gate would refuse.
120
+ *
121
+ * `'brief_superseded'`: the
122
+ * frozen brief's own hash the driver resolved when it dispatched this
123
+ * round's reviewers no longer matches the hash it resolves once their
124
+ * verdicts are back — a Planner superseded the frozen brief mid-round.
125
+ * Same shape as `'objectives_changed'`/`'ruling_posted'`: the driver
126
+ * detects and decides it itself (via the shared `compareManifest`, not a
127
+ * hand-rolled inequality), and this member exists only so the pause shares
128
+ * the same vocabulary and rendering path every other pause reason uses.
129
+ *
130
+ * `'policy_changed'`: the effective review policy's
131
+ * digest the driver resolved at dispatch time no longer matches the one it
132
+ * resolves once verdicts are back — same shape again. In practice a single
133
+ * loop run resolves its policy once and never re-reads it, so this branch
134
+ * is reachable only if a future change makes that re-read live; it exists
135
+ * now so the manifest's comparison is symmetric on every field, matching
136
+ * what the merge gate (which DOES re-resolve policy fresh on every run)
137
+ * already checks.
138
+ *
139
+ * `'no_push'`: a developer turn
140
+ * ended with a dirty worktree or local commits ahead of the remote, and no
141
+ * new head appeared on the branch even after one foreground resume asking
142
+ * it to commit and push. Same shape as the driver-decided reasons above:
143
+ * `devReviewLoop` detects and decides this itself (reading the worktree's
144
+ * own git status, not something `assessRound` can see from an
145
+ * `Observations` value) — it exists only so this pause shares the same
146
+ * vocabulary and rendering path every other pause reason already uses.
147
+ * `detail` is set for this reason too, naming the branch and the dirty
148
+ * file(s) observed.
149
+ */
150
+ export type PauseReason =
151
+ | 'escalation'
152
+ | 'max_rounds'
153
+ | 'no_progress'
154
+ | 'confidence'
155
+ | 'reappearance'
156
+ | 'infrastructure'
157
+ | 'no_push'
158
+ | 'objectives_changed'
159
+ | 'ruling_posted'
160
+ | 'stale_driver'
161
+ | 'brief_superseded'
162
+ | 'policy_changed'
163
+
164
+ export type Decision =
165
+ | { type: 'dispatch_developer'; reason?: 'confidence' }
166
+ | { type: 'dispatch_reviewers' }
167
+ | { type: 'ask_confidence' }
168
+ | { type: 'publish' }
169
+ | {
170
+ type: 'pause'
171
+ reason: PauseReason
172
+ /** Set only for `'infrastructure'` — the role and missing artifact(s) the driver observed; every other reason omits it. */
173
+ detail?: string
174
+ }
175
+
176
+ /**
177
+ * The summary's own outcome vocabulary — wider than `round_ended`'s
178
+ * schema-constrained `green | changes_requested | escalated`: a round whose
179
+ * processing triggered one of the assessment exits (max_rounds, confidence,
180
+ * reappearance) records `'stopped'` here, even though the log
181
+ * event for that same round still reports `changes_requested` (the schema
182
+ * has no fifth value) — the journal, not the per-event log line, is where
183
+ * the loop's own verdict on that round belongs.
184
+ */
185
+ export type RoundOutcome = 'green' | 'changes_requested' | 'escalated' | 'stopped'
186
+
187
+ /** One row of the published summary (`renderSummary`, O4) — counts only, no finding prose. */
188
+ export type RoundRecord = {
189
+ round: number
190
+ countsBySeverity: Record<string, number>
191
+ confidence: Confidence | null
192
+ outcome: RoundOutcome
193
+ }
194
+
195
+ export type Journal = { rounds: RoundRecord[] }
196
+
197
+ export type LoopConfig = {
198
+ /** Set once by the driver at loop start (`startLoop`, spec §16) — never generated here; this module has no random source. */
199
+ loopId: string
200
+ task: number
201
+ reviewers: string[]
202
+ models: Record<string, string>
203
+ /** The round cap — resolved by the driver from `ReviewPolicy.maxRounds` (repository config), never read here: this module has no config read of its own. */
204
+ maxRounds: number
205
+ }
206
+
207
+ /** A round awaiting its `verdicts` observation, or awaiting a confidence re-ask — never both logged twice. */
208
+ export type PendingRound = {
209
+ round: number
210
+ stats: RoundStats
211
+ confidenceAskCount: number
212
+ confidence: Confidence | null
213
+ /** The id → state map of every prior round combined, for the reappearance check. */
214
+ priorIds: Map<string, string | null>
215
+ }
216
+
217
+ export type LoopState = {
218
+ config: LoopConfig
219
+ rounds: RoundRecord[]
220
+ pending: PendingRound | null
221
+ /** The one extra developer turn the confidence rule (§2) grants after a below-50 round — spent once, ever. */
222
+ extraTurnUsed: boolean
223
+ /** The most recent round's combined id → state map, carried forward for the next round's comparison. */
224
+ lastIds: Map<string, string | null>
225
+ /** Running sums for `journal_finalized` — updated once per concluded round, never recomputed from `rounds` (which carries counts only, not diff stats). */
226
+ totalWallMs: number
227
+ totalFilesChanged: number
228
+ }
229
+
230
+ export function initialLoopState(config: LoopConfig): LoopState {
231
+ return {
232
+ config,
233
+ rounds: [],
234
+ pending: null,
235
+ extraTurnUsed: false,
236
+ lastIds: new Map(),
237
+ totalWallMs: 0,
238
+ totalFilesChanged: 0
239
+ }
240
+ }
@@ -57,7 +57,7 @@ export type DiagramNode = {
57
57
  crosses?: 'into-github' | 'none'
58
58
  /** The node's name **for a reader**, when its `label` is an identifier rather
59
59
  * than words. `role`/`contract` nodes label themselves with their doctrine id
60
- * (`brief-author`, `archivist-tranche-archivist`) because that id is the
60
+ * (`planner`, `archivist-tranche-archivist`) because that id is the
61
61
  * node's identity — routes, doc paths and edge endpoints all key off it, so
62
62
  * it cannot be prettified in place. This carries the doc's own `title:`
63
63
  * frontmatter instead, and every renderer showing a name to a person prefers
@@ -1,6 +1,5 @@
1
1
  /**
2
- * Direct-main-push detection (aeg-governance-hardening task 24, #364,
3
- * Part 3 — item 1). Pure — no `fs`, no `gh`/`git` shell-outs. The CLI shim
2
+ * Direct-main-push detection. Pure — no `fs`, no `gh`/`git` shell-outs. The CLI shim
4
3
  * (`bin/check-direct-main-push.ts`) makes the one forge call (the
5
4
  * commits→pulls association API: `GET /repos/{owner}/{repo}/commits/{sha}/pulls`,
6
5
  * which GitHub documents as returning "the merged Pull Request that
@@ -1,6 +1,5 @@
1
1
  /**
2
- * Dispatch-readiness composition (aeg-governance-hardening task 11, #324).
3
- * Pure — no `fs`, no `fetch`. Composes the forge/rationale/provenance/
2
+ * Dispatch-readiness composition. Pure — no `fs`, no `fetch`. Composes the forge/rationale/provenance/
4
3
  * archival facts the CLI shim (`bin/verify-dispatch.ts`) gathers (reusing
5
4
  * `parseTranche`, `hasProvenance`, `taskRefFromBranch`,
6
5
  * `checkIssueRationale`, `fetchProvenance` — never re-implementing any of
@@ -37,9 +36,9 @@ export type DispatchDependsOnFact = DispatchEdgeFact & {
37
36
  * `false` when the resolver could not find any tranche/task/Issue matching
38
37
  * this edge at all — a fact distinct from `merged: false`, which means the
39
38
  * edge resolved to a real target that just hasn't merged yet. Conflating
40
- * the two produced a false "not merged yet" claim for #193's
41
- * `vinaya-milestone-model-v1 2` edge, which had genuinely already merged
42
- * (#196) — the message this distinction exists to correct. Absent or
39
+ * the two produced a false "not merged yet" claim for a real dependency
40
+ * edge, which had genuinely already merged
41
+ * — the message this distinction exists to correct. Absent or
43
42
  * `true` for every edge the resolver actually matched to a target,
44
43
  * including one whose target lookup itself then failed (an outage), which
45
44
  * stays under the existing conservative `merged: false` default rather
@@ -47,7 +46,7 @@ export type DispatchDependsOnFact = DispatchEdgeFact & {
47
46
  */
48
47
  resolved?: boolean
49
48
  /**
50
- * Hand-close recognition facts (task `vinaya-engine-v1` 21, #99) — a
49
+ * Hand-close recognition facts — a
51
50
  * second, narrower path alongside `merged` for a dependency Issue closed
52
51
  * directly by a recognized Principal, with a stated `COMPLETED` reason,
53
52
  * rather than via a merged PR. All three are `null`/absent when the edge
@@ -143,7 +142,40 @@ export type DispatchGateInput = {
143
142
  principalAllowlist?: string[]
144
143
  }
145
144
 
146
- export type DispatchResult = { ready: boolean; blockers: string[] }
145
+ /**
146
+ * Every distinct dispatch-readiness blocker shape `checkDispatchReadiness`
147
+ * can produce, named apart from its human `message` string —
148
+ * the recovery-prompt switch in `check-dispatch-readiness.ts` matches on
149
+ * THIS, never on parsing `message`'s text. Closed deliberately: a new
150
+ * blocker kind that reuses an existing member here silently inherits that
151
+ * member's (possibly wrong) recovery prompt, while adding a genuinely new
152
+ * member without a matching `case` in the consumer's switch fails typecheck
153
+ * via that switch's exhaustiveness check — the trap a real regression fell into (a new
154
+ * self-dependency class read as depends-on, whose stock prompt said "close
155
+ * the dependency" for a dependency that can never close) is now a compile
156
+ * error, not a live incident.
157
+ */
158
+ export type DispatchBlockerClass =
159
+ | 'internal-self-dependency'
160
+ | 'issue-existence'
161
+ | 'rationale'
162
+ | 'depends-on-unresolvable'
163
+ | 'depends-on-not-merged'
164
+ | 'conflicts-with'
165
+ | 'prior-tranche-archival'
166
+
167
+ /** A blocker's machine-readable class, beside the human string it always also carries. */
168
+ export type DispatchBlocker = { class: DispatchBlockerClass; message: string }
169
+
170
+ /**
171
+ * `blockers` stays the plain message list existing callers (`brief-render.ts`
172
+ * via `brief-assembly.ts`, `bin/verify-dispatch.ts`) already depend on —
173
+ * unchanged, byte-identical to before this task. `blockerDetails` is the new,
174
+ * additive field: the same blockers, each now paired with its
175
+ * `DispatchBlockerClass`, for a consumer (`check-dispatch-readiness.ts`) that
176
+ * needs to route on the class rather than re-parse the string.
177
+ */
178
+ export type DispatchResult = { ready: boolean; blockers: string[]; blockerDetails: DispatchBlocker[] }
147
179
 
148
180
  /**
149
181
  * True when a parsed `depends-on` edge points back at its own host task.
@@ -152,10 +184,10 @@ export type DispatchResult = { ready: boolean; blockers: string[] }
152
184
  * gate state — its presence is proof of a defect in the edge text or in its
153
185
  * resolution. `parseRationaleDeps` (`@attalabs/aeg-forge-state`) reads only
154
186
  * a labeled `Depends-on:`/`Conflicts-with:` field's own comma-separated,
155
- * id-shaped tokens; since Issue #347 an unlabeled/bare span elsewhere in the
187
+ * id-shaped tokens; an unlabeled/bare span elsewhere in the
156
188
  * "Dependency rationale" section is never read as an edge, whatever its
157
189
  * shape (`parse-rationale-deps.ts`'s own module comment states the rule). A
158
- * slug-qualified token in that list (`aeg-governance-hardening #368`) still
190
+ * slug-qualified token in that list (`aeg-governance-hardening #NNN`) still
159
191
  * resolves its trailing bare number against the NAMED tranche, not the host
160
192
  * — a resolver bug there is what would land a task depending on itself, on
161
193
  * that tranche's own task `1`.
@@ -182,29 +214,35 @@ export function checkDispatchReadiness(input: DispatchGateInput): DispatchResult
182
214
  const { trancheSlug, task } = input
183
215
  const taskLabel = `task ${task.id} (tranche ${trancheSlug})`
184
216
  const principalAllowlist = input.principalAllowlist ?? PRINCIPAL_ALLOWLIST
185
- const blockers: string[] = []
217
+ const blockerDetails: DispatchBlocker[] = []
218
+ const push = (blockerClass: DispatchBlockerClass, message: string): void => {
219
+ blockerDetails.push({ class: blockerClass, message })
220
+ }
186
221
 
187
222
  // Issue-existence — the topology row itself has no Issue number.
188
223
  if (task.issue === null) {
189
- blockers.push(
224
+ push(
225
+ 'issue-existence',
190
226
  `dispatch-gate issue-existence: ${taskLabel} has no Issue (#TBD or blank) in the topology — not dispatchable until the Planner cuts the Issue.`
191
227
  )
192
228
  } else if (input.issue === null) {
193
229
  // Row names an Issue number, but it doesn't resolve on the forge — phantom ref (T1's fail class).
194
- blockers.push(
230
+ push(
231
+ 'issue-existence',
195
232
  `dispatch-gate issue-existence: ${taskLabel} names Issue #${task.issue}, but it does not resolve to a real GitHub Issue (phantom reference).`
196
233
  )
197
234
  }
198
235
 
199
236
  // Planner-rationale completeness — only evaluable when the Issue itself resolved.
200
237
  if (input.issue !== null && !input.issueRationalePass) {
201
- blockers.push(
238
+ push(
239
+ 'rationale',
202
240
  `dispatch-gate rationale: Issue #${input.issue.number} for ${taskLabel} fails the rationale gate (checkIssueRationale) — the Planner must complete the eight-field rationale before this task is dispatchable.`
203
241
  )
204
242
  }
205
243
 
206
- // Depends-on merged — OR hand-closed by a recognized Principal (task
207
- // `vinaya-engine-v1` 21, #99): a second, narrower path for a dependency
244
+ // Depends-on merged — OR hand-closed by a recognized Principal: a
245
+ // second, narrower path for a dependency
208
246
  // Issue closed directly rather than via a merged PR.
209
247
  for (const dep of input.dependsOn) {
210
248
  // Evaluated BEFORE the unresolvable branch: a self-reference that also
@@ -213,25 +251,28 @@ export function checkDispatchReadiness(input: DispatchGateInput): DispatchResult
213
251
  // not actually the fault.
214
252
  if (isSelfDependency(dep, task, input.issue)) {
215
253
  const issueStr = input.issue !== null ? `#${input.issue.number}` : '?'
216
- blockers.push(
254
+ push(
255
+ 'internal-self-dependency',
217
256
  `dispatch-gate INTERNAL: parsed a self-dependency for task ${task.id} (${issueStr}) — this is a parser bug in parseRationaleDeps, not a real dependency. Please report it upstream. Re-run once the rationale is corrected or the fix ships.`
218
257
  )
219
258
  continue
220
259
  }
221
260
  if (dep.resolved === false) {
222
- // Distinct from the "not merged yet" branch below (#196): this edge
261
+ // Distinct from the "not merged yet" branch below: this edge
223
262
  // never resolved to any tranche/task/Issue at all, so a "not merged"
224
263
  // claim would misattribute the failure to the forge rather than to
225
264
  // the edge text. Still blocks — the conservative default is correct
226
265
  // for a genuinely unresolvable edge — but says so honestly.
227
- blockers.push(
266
+ push(
267
+ 'depends-on-unresolvable',
228
268
  `dispatch-gate depends-on: ${taskLabel} depends on "${dep.id}", which is UNRESOLVABLE — the resolver could not find a matching tranche/task/Issue for this edge (not a claim about merge status). Not dispatchable until the edge is corrected.`
229
269
  )
230
270
  continue
231
271
  }
232
272
  if (!dep.merged && !isHandClosedByRecognizedPrincipal(dep, principalAllowlist)) {
233
273
  const issueStr = dep.issue !== null ? ` (#${dep.issue})` : ''
234
- blockers.push(
274
+ push(
275
+ 'depends-on-not-merged',
235
276
  `dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, whose PR is not merged yet — not dispatchable, it serializes behind it.`
236
277
  )
237
278
  }
@@ -241,7 +282,8 @@ export function checkDispatchReadiness(input: DispatchGateInput): DispatchResult
241
282
  for (const c of input.conflictsWith) {
242
283
  if (c.openOrInFlight) {
243
284
  const issueStr = c.issue !== null ? ` (#${c.issue})` : ''
244
- blockers.push(
285
+ push(
286
+ 'conflicts-with',
245
287
  `dispatch-gate conflicts-with: ${taskLabel} conflicts with ${c.id}${issueStr}, whose PR is open or in-flight — not dispatchable until it merges.`
246
288
  )
247
289
  }
@@ -258,11 +300,12 @@ export function checkDispatchReadiness(input: DispatchGateInput): DispatchResult
258
300
  // Prior-tranche archival, per project named in Project(s).
259
301
  for (const proj of input.priorTrancheArchival) {
260
302
  if (proj.priorTrancheSlug !== null && !proj.archived) {
261
- blockers.push(
303
+ push(
304
+ 'prior-tranche-archival',
262
305
  `dispatch-gate prior-tranche-archival: project \`${proj.project}\`'s previous tranche \`${proj.priorTrancheSlug}\` is not archived — the Tranche Archivist must run before new work on this product.`
263
306
  )
264
307
  }
265
308
  }
266
309
 
267
- return { ready: blockers.length === 0, blockers }
310
+ return { ready: blockerDetails.length === 0, blockers: blockerDetails.map((b) => b.message), blockerDetails }
268
311
  }