@attalabs/vinaya 0.32.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 (209) hide show
  1. package/README.md +1 -1
  2. package/aeg-root/contracts/principal-operator.md +18 -5
  3. package/aeg-root/roles/operator.md +69 -16
  4. package/aeg-root/roles/planner/reference.md +1 -1
  5. package/aeg-root/roles/tranche-archivist.md +1 -0
  6. package/aeg-root/skills/aeg-context-packets/SKILL.md +1 -1
  7. package/aeg-root/skills/aeg-context-packets/examples/operator-start.md +1 -1
  8. package/dist/checks/bin/check-body-bare-digits.js +111 -15
  9. package/dist/checks/bin/check-branch-topology.js +83 -16
  10. package/dist/checks/bin/check-brief-shape.js +111 -15
  11. package/dist/checks/bin/check-changeset-coverage.js +342 -69
  12. package/dist/checks/bin/check-closes-n.js +83 -16
  13. package/dist/checks/bin/check-coherence.js +112 -16
  14. package/dist/checks/bin/check-dead-branch-push.js +82 -15
  15. package/dist/checks/bin/check-dispatch-readiness.js +112 -16
  16. package/dist/checks/bin/check-doc-coverage-push.js +342 -69
  17. package/dist/checks/bin/check-doc-coverage.js +342 -69
  18. package/dist/checks/bin/check-doctrine-no-procedures.js +111 -15
  19. package/dist/checks/bin/check-doctrine-portability.js +342 -69
  20. package/dist/checks/bin/check-evidence-fresh.js +343 -69
  21. package/dist/checks/bin/check-exec-bits.js +342 -69
  22. package/dist/checks/bin/check-first-push-dispatch.js +112 -16
  23. package/dist/checks/bin/check-issue-assignment.js +83 -16
  24. package/dist/checks/bin/check-issue-milestone-attach.js +82 -15
  25. package/dist/checks/bin/check-issue-objectives-numbering.js +82 -15
  26. package/dist/checks/bin/check-issue-parts-coverage.js +82 -15
  27. package/dist/checks/bin/check-issue-surface-globs.js +112 -16
  28. package/dist/checks/bin/check-issue-title-grammar.js +82 -15
  29. package/dist/checks/bin/check-issue-tranche-label.js +82 -15
  30. package/dist/checks/bin/check-main-branch-refusal.js +82 -15
  31. package/dist/checks/bin/check-no-disk-state.js +82 -15
  32. package/dist/checks/bin/check-pr-premise-reassert.js +111 -15
  33. package/dist/checks/bin/check-pr-report-density.js +82 -15
  34. package/dist/checks/bin/check-principal-test-plan-wait.js +82 -15
  35. package/dist/checks/bin/check-quoted-command.js +342 -69
  36. package/dist/checks/bin/check-reader-resolvable-prose.js +342 -69
  37. package/dist/checks/bin/check-registry-gates.js +82 -15
  38. package/dist/checks/bin/check-retired-vocabulary.js +342 -69
  39. package/dist/checks/bin/check-review-gate.js +179 -124
  40. package/dist/checks/bin/check-single-plan-pr.js +82 -15
  41. package/dist/checks/bin/check-surface-scope.js +83 -16
  42. package/dist/checks/bin/check-test-plan.js +82 -15
  43. package/dist/checks/bin/check-token-collection-wired.js +82 -15
  44. package/dist/checks/bin/check-token-report.js +82 -15
  45. package/dist/checks/bin/check-workspace-escape.js +342 -69
  46. package/dist/index.js +2495 -590
  47. package/dist/lib/pre-push-cache-test-run.js +317 -61
  48. package/dist/lib/pre-push-select-tests.js +91 -10
  49. package/package.json +1 -1
  50. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/actions.ts +10 -12
  51. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +5 -5
  52. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/archive-task.ts +42 -17
  53. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/baseline-capture.ts +1 -2
  54. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/branch-topology-gate.ts +3 -3
  55. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +554 -95
  56. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +264 -44
  57. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/claude-code-transcript.ts +9 -9
  58. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +211 -30
  59. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/consumer-enumeration.ts +2 -2
  60. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/index.ts +75 -0
  61. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +961 -0
  62. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/migration.ts +212 -0
  63. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/outcomes.ts +135 -0
  64. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +394 -0
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dead-branch-push-audit.ts +1 -2
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dead-branch-push-guard.ts +1 -1
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/derive-section7.ts +2 -2
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +514 -0
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +110 -0
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +27 -0
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +123 -0
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +27 -0
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +240 -0
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/diagram-model.ts +1 -1
  75. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/direct-main-push.ts +1 -2
  76. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +65 -22
  77. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-claim.ts +238 -0
  78. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-owners.ts +14 -1
  79. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/docs-coherence.ts +1 -1
  80. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/legacy-anchors.ts +1 -1
  81. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/node-route.ts +1 -1
  82. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/surfaced-manifest.ts +1 -1
  83. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-no-procedures.ts +1 -1
  84. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +5 -5
  85. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ensure-label.ts +1 -1
  86. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/first-push-dispatch-gate.ts +1 -1
  87. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +14 -3
  88. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +379 -11
  89. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-assignment.ts +3 -4
  90. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +1450 -33
  91. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/leftover-detection.ts +1 -2
  92. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/local-anchor-coverage.ts +2 -2
  93. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +119 -0
  94. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +75 -0
  95. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/redact.ts +87 -0
  96. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +801 -0
  97. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/store.ts +373 -0
  98. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +2 -2
  99. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/metering-io-guard.ts +1 -1
  100. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/milestone-validation.ts +2 -3
  101. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/no-disk-state.ts +2 -2
  102. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives.ts +288 -0
  103. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/parse-token-report.ts +3 -3
  104. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/parse-tranche.ts +1 -1
  105. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-report-density.ts +30 -16
  106. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-tier.ts +17 -1
  107. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/premise-check.ts +1 -1
  108. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/quoted-command.ts +1 -1
  109. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +267 -19
  110. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +91 -24
  111. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-scaffold.ts +6 -6
  112. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/report-tokens.ts +4 -4
  113. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +239 -110
  114. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +384 -0
  115. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +184 -0
  116. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +65 -18
  117. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +76 -0
  118. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/single-plan-pr.ts +4 -4
  119. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/state-machine-model.ts +40 -27
  120. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/symbol-collisions.ts +2 -2
  121. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-branch-identity.ts +38 -0
  122. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +488 -0
  123. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-gate.ts +7 -9
  124. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-section.ts +5 -5
  125. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/types.ts +4 -4
  126. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +314 -56
  127. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/waiver-label.ts +2 -3
  128. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/workspace-escape.ts +3 -3
  129. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  130. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  131. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  133. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  134. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  135. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  136. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  137. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  138. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  141. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js +1 -1
  143. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
  144. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  145. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  146. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +1 -1
  149. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  150. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  151. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  152. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +1 -1
  153. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  154. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  155. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  156. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +1 -1
  157. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  158. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  159. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  160. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +2 -2
  161. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  162. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  163. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  164. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +1 -1
  165. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  166. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  167. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  168. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +1 -1
  169. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  170. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  171. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  172. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +1 -1
  173. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  174. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  175. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/{[externals]__1agj1ww._.js → [externals]__0cki-x_._.js} +2 -2
  176. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +6 -6
  177. 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
  178. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +3 -0
  179. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  180. 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
  181. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  182. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  183. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1r47dr7._.js → _08onyya._.js} +3 -3
  184. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  185. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  186. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  187. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  188. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0y1jv16._.js +1 -1
  189. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  190. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  191. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_15gdg48._.js +5 -5
  192. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  193. 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
  194. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  195. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  196. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  197. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  198. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bjnj-5fy4e7l.js +1 -0
  199. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1dc2_-c_gavj1.js → 1ce2dj27_cgbj.js} +4 -4
  200. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3xg6-flovrcx-.js → 22s44f5k3ecmj.js} +1 -1
  201. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/34hhdtbp20krb.js +1 -0
  202. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  203. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0hstap0._.js +0 -3
  204. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2t_rfsztmwu6y.js +0 -1
  205. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3ua4rm5f-a9k6.js +0 -1
  206. /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
  207. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_buildManifest.js +0 -0
  208. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_clientMiddlewareManifest.js +0 -0
  209. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_ssgManifest.js +0 -0
@@ -6,11 +6,23 @@
6
6
  * topology are injected by the caller (`bin/verify-coherence.ts`, the I/O shim).
7
7
  */
8
8
 
9
- import { trancheLabel, label } from '@attalabs/aeg-forge-state'
9
+ import { parseRationaleDeps, trancheLabel, label } from '@attalabs/aeg-forge-state'
10
10
  import { anchoredRegion, stripCode } from './anchored-region'
11
- import { checkIssueRationale, checkProjectsRegistered, isTaskIssueLabelSet } from './issue-validation'
11
+ import {
12
+ checkIssueObjectives,
13
+ checkIssueRationale,
14
+ checkPartsCiteDefinedObjectives,
15
+ checkProjectsRegistered,
16
+ checkSurfaceExcludesBoundDoc,
17
+ checkSurfaceOverlap,
18
+ isTaskIssueLabelSet,
19
+ parseIssueSurface,
20
+ type TaskSurfaceFacts
21
+ } from './issue-validation'
22
+ import { parseTaskBranchIdentity } from './task-branch-identity'
12
23
  import { isPrincipal, PRINCIPAL_ALLOWLIST } from './waiver-label'
13
24
  import type { ForgeIssue, TaskIssueRef } from '@attalabs/aeg-types'
25
+ import type { GhIssue } from '@attalabs/aeg-forge-state'
14
26
  import type { ForgeFacts, Tranche, Task } from './types'
15
27
 
16
28
  // ---------- grandfather cutoff -----------------------------------------------
@@ -51,7 +63,43 @@ export const R1_GRANDFATHERED_ISSUES: ReadonlySet<number> = new Set([279, 280, 2
51
63
 
52
64
  // ---------- types -------------------------------------------------------------
53
65
 
66
+ /**
67
+ * Every distinct coherence-failure shape this module's checks can produce,
68
+ * named apart from `CheckFailure.reason`'s human string — the
69
+ * recovery-prompt switch in `check-coherence.ts` matches on THIS, never on
70
+ * parsing `reason`'s text or `CheckResult.check`'s code alone. Closed
71
+ * deliberately, and split finer than the `check` code where one check code
72
+ * hides two failures needing opposite advice: `checkD1` produces both
73
+ * `d1-self-dependency` (unsatisfiable by construction, escalate) and
74
+ * `dispatched-on-unmet-deps` (an ordinary unmet dependency, close it) under
75
+ * the same `D1` check code — keying recovery on `check` alone told an agent
76
+ * to close an uncloseable dependency (the live incident this task fixes).
77
+ * Adding a member here without a matching `case` in the consumer's switch
78
+ * fails typecheck via that switch's exhaustiveness check.
79
+ */
80
+ export type CoherenceFailureCode =
81
+ | 'closed-without-merge'
82
+ | 'archived-without-provenance'
83
+ | 'auto-close-misfire'
84
+ | 'phantom-issue-ref'
85
+ | 'orphan-task'
86
+ | 'tbd-in-active-tranche'
87
+ | 'd1-self-dependency'
88
+ | 'dispatched-on-unmet-deps'
89
+ | 'missing-rationale-field'
90
+ | 'surface-excludes-bound-doc'
91
+ | 'surface-overlap'
92
+ | 'archive-recommended'
93
+ | 'premature-archive'
94
+ | 'milestone-drift'
95
+ | 'tranche-not-archived'
96
+ | 'doc-owners-dangling-pointer'
97
+ | 'doc-owners-duplicate-glob'
98
+ | 'forge-read-unavailable'
99
+
54
100
  export type CheckFailure = {
101
+ /** The failure's machine-readable class, beside `reason`'s human string. */
102
+ code: CoherenceFailureCode
55
103
  issue?: number | null
56
104
  tranche: string
57
105
  task?: string
@@ -85,7 +133,7 @@ export type TrancheFile = {
85
133
 
86
134
  /**
87
135
  * A1: Every closed task-Issue has a merged closing PR — OR was hand-closed
88
- * directly by a recognized Principal (task `vinaya-engine-v1` 21, #99): a
136
+ * directly by a recognized Principal: a
89
137
  * second, narrower "done" path for a dependency Issue whose technical
90
138
  * premise dissolved, closed with a stated `COMPLETED` reason rather than via
91
139
  * a merge. Every condition is a real forge fact (who performed the
@@ -111,6 +159,7 @@ export function checkA1(entries: TaskEntry[], principalAllowlist: string[] = PRI
111
159
  const handClosed = e.facts.stateReason === 'completed' && isPrincipal(e.facts.closedByActor, principalAllowlist)
112
160
  if (handClosed) continue
113
161
  failures.push({
162
+ code: 'closed-without-merge',
114
163
  issue: e.task.issue,
115
164
  tranche: e.trancheSlug,
116
165
  task: e.task.id,
@@ -149,6 +198,7 @@ export function checkA2(entries: TaskEntry[], hasProvenanceByKey: Map<string, bo
149
198
  if (hasProvenance === undefined) continue
150
199
  if (!hasProvenance) {
151
200
  failures.push({
201
+ code: 'archived-without-provenance',
152
202
  issue: e.task.issue,
153
203
  tranche: e.trancheSlug,
154
204
  task: e.task.id,
@@ -169,7 +219,7 @@ export function checkA2(entries: TaskEntry[], hasProvenanceByKey: Map<string, bo
169
219
 
170
220
  /**
171
221
  * A3: Every Issue whose closing PR merged is itself closed.
172
- * Fail class: `auto-close-misfire` — the headline check (#174 class).
222
+ * Fail class: `auto-close-misfire` — the headline check.
173
223
  * Terminal event date: `prMergedAt` — grandfathered when before `COHERENCE_ENFORCED_FROM`.
174
224
  */
175
225
  export function checkA3(entries: TaskEntry[]): CheckResult {
@@ -178,6 +228,7 @@ export function checkA3(entries: TaskEntry[]): CheckResult {
178
228
  if (!e.facts) continue
179
229
  if (e.facts.prState === 'merged' && e.facts.issueState !== 'closed') {
180
230
  failures.push({
231
+ code: 'auto-close-misfire',
181
232
  issue: e.task.issue,
182
233
  tranche: e.trancheSlug,
183
234
  task: e.task.id,
@@ -211,6 +262,7 @@ export function checkT1(entries: TaskEntry[]): CheckResult {
211
262
  // facts === undefined and issue !== null → forge query returned nothing for this issue
212
263
  if (e.facts === undefined) {
213
264
  failures.push({
265
+ code: 'phantom-issue-ref',
214
266
  issue: e.task.issue,
215
267
  tranche: e.trancheSlug,
216
268
  task: e.task.id,
@@ -248,6 +300,7 @@ export function checkT2(
248
300
  for (const num of openNums) {
249
301
  if (!topologySet.has(num)) {
250
302
  failures.push({
303
+ code: 'orphan-task',
251
304
  issue: num,
252
305
  tranche: slug,
253
306
  reason: `Issue #${num} is open and labeled ${trancheLabel(slug)} but does not appear in the topology file`
@@ -259,11 +312,10 @@ export function checkT2(
259
312
  }
260
313
 
261
314
  /**
262
- * T2 point-of-power relocation (aeg-governance-hardening task 24, #364,
263
- * Part 2; supersedes half of task 19's T2-in-task-PR-CI placement).
315
+ * T2 point-of-power relocation (supersedes half of an earlier task's T2-in-task-PR-CI placement).
264
316
  * A gate may only red a PR that could cause or cure the violation it
265
- * reports — live incident #363 (2026-07-04): registering Issues #364/#365
266
- * correctly reddened same-tranche task PR #363's CI, which could neither
317
+ * reports — a live incident (2026-07-04): registering sibling Issues
318
+ * correctly reddened a same-tranche task PR's CI, which could neither
267
319
  * have caused nor fixed the topology gap. `checkT2`'s own assertion logic
268
320
  * (above) is untouched; this only demotes its CI-blocking status when the
269
321
  * current PR is NOT a plan PR (i.e. its diff doesn't touch a tranche
@@ -329,6 +381,7 @@ export function checkT3(
329
381
 
330
382
  if (forgeUnavailableSlugs?.has(e.trancheSlug)) {
331
383
  failures.push({
384
+ code: 'tbd-in-active-tranche',
332
385
  issue: null,
333
386
  tranche: e.trancheSlug,
334
387
  task: e.task.id,
@@ -339,6 +392,7 @@ export function checkT3(
339
392
  }
340
393
 
341
394
  failures.push({
395
+ code: 'tbd-in-active-tranche',
342
396
  issue: null,
343
397
  tranche: e.trancheSlug,
344
398
  task: e.task.id,
@@ -390,6 +444,7 @@ export function checkD1(
390
444
  const sameIssue = depEntry.task.issue !== null && e.task.issue !== null && depEntry.task.issue === e.task.issue
391
445
  if (sameTask || sameIssue) {
392
446
  failures.push({
447
+ code: 'd1-self-dependency',
393
448
  issue: e.task.issue,
394
449
  tranche: e.trancheSlug,
395
450
  task: e.task.id,
@@ -402,6 +457,7 @@ export function checkD1(
402
457
  const depClosed = depFacts?.issueState === 'closed'
403
458
  if (!depClosed) {
404
459
  failures.push({
460
+ code: 'dispatched-on-unmet-deps',
405
461
  issue: e.task.issue,
406
462
  tranche: e.trancheSlug,
407
463
  task: e.task.id,
@@ -427,7 +483,7 @@ function resolveDepEntry(
427
483
  }
428
484
 
429
485
  /**
430
- * `ForgeIssue` lives in `@attalabs/aeg-types` (aeg-core-purity fix, #521) —
486
+ * `ForgeIssue` lives in `@attalabs/aeg-types` (an aeg-core-purity fix) —
431
487
  * re-exported here since every existing call site imports it from
432
488
  * `@attalabs/aeg-core`.
433
489
  */
@@ -467,10 +523,15 @@ export function checkR1(
467
523
  if (!isTaskIssueLabelSet(issue.labels)) continue
468
524
  const errors = [
469
525
  ...checkIssueRationale(issue.body).errors,
470
- ...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors
526
+ ...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
527
+ ...checkIssueObjectives(issue.body, issue.number).errors,
528
+ // task 17, O2 — Parts coverage joins the sweep here: same
529
+ // dormant-when-absent posture as the other two, zero new inputs.
530
+ ...checkPartsCiteDefinedObjectives(issue.body).errors
471
531
  ]
472
532
  if (errors.length === 0) continue
473
533
  failures.push({
534
+ code: 'missing-rationale-field',
474
535
  issue: issue.number,
475
536
  tranche: slug,
476
537
  reason: `Issue #${issue.number} fails the rationale gate: ${errors.join(' | ')}`,
@@ -491,11 +552,113 @@ export function checkR1(
491
552
  }
492
553
  }
493
554
 
555
+ /**
556
+ * R2: The same `checkSurfaceExcludesBoundDoc` predicate,
557
+ * run over every open task Issue in an active tranche. This is a related
558
+ * obligation: a task Issue whose `## Surface` `out:` list excludes a
559
+ * `.vinaya/doc-owners`-bound document its `in:` list otherwise covers must be
560
+ * reported, not silently left to fail at the Developer's first commit — the
561
+ * ring-0 gate in `forge-write.ts` catches this at create/edit time going
562
+ * forward, but an Issue written before this gate shipped, or edited outside
563
+ * the validated path, needs the ring-1/2 half the way R1 does.
564
+ * Fail class: `surface-excludes-bound-doc`
565
+ *
566
+ * `docOwnersContent`: the caller's own tree read of `.vinaya/doc-owners` — a
567
+ * repo with no manifest, or one with no binding, leaves this dormant for
568
+ * every Issue (the predicate itself already returns `pass` in both cases).
569
+ * One grammar, one parser, same discipline as R1: this function never
570
+ * re-implements `checkSurfaceExcludesBoundDoc`'s matching.
571
+ */
572
+ export function checkR2(issuesBySlug: Map<string, ForgeIssue[]>, docOwnersContent: string | null): CheckResult {
573
+ const failures: CheckFailure[] = []
574
+ for (const [slug, issues] of issuesBySlug) {
575
+ for (const issue of issues) {
576
+ if (!isTaskIssueLabelSet(issue.labels)) continue
577
+ const errors = checkSurfaceExcludesBoundDoc(issue.body, docOwnersContent).errors
578
+ if (errors.length === 0) continue
579
+ failures.push({
580
+ code: 'surface-excludes-bound-doc',
581
+ issue: issue.number,
582
+ tranche: slug,
583
+ reason: `Issue #${issue.number} fails the surface/doc-owners gate: ${errors.join(' | ')}`
584
+ })
585
+ }
586
+ }
587
+ return { check: 'R2', status: failures.length > 0 ? 'fail' : 'pass', failures }
588
+ }
589
+
590
+ /**
591
+ * R3: The same `checkSurfaceOverlap` predicate run
592
+ * pairwise over every open task Issue sharing a Milestone — the coherence
593
+ * half of O5's own obligation ("the same predicate runs in the coherence
594
+ * check over open task Issues"). The write-time gate
595
+ * (`apps/cli/src/lib/forge-write.ts`) only ever compares the ONE Issue being
596
+ * created/edited against its siblings at that moment; this is the sweep that
597
+ * re-checks the whole open set afterward — a sibling's Surface widened
598
+ * later, or an Issue edited outside the validated path, still surfaces here.
599
+ *
600
+ * Takes the RAW `GhIssue` list (not the derived `ForgeIssue`/`Tranche`
601
+ * shapes R1/R2 consume) because only the raw shape carries the GitHub-native
602
+ * `milestone` field — see this module's own header note on why the raw
603
+ * per-slug Issue lists are threaded through the sweep for exactly this
604
+ * reason. An Issue with no Milestone, or whose `## Surface` doesn't parse,
605
+ * is excluded from every group: O5 only binds tasks that share a real
606
+ * Milestone, and a Surface this function cannot read is `checkIssueBriefSections`'s
607
+ * finding to report, not this one's.
608
+ *
609
+ * Fail class: `surface-overlap`
610
+ */
611
+ export function checkR3(issuesBySlug: Map<string, GhIssue[]>): CheckResult {
612
+ type Entry = { slug: string; issue: GhIssue; facts: TaskSurfaceFacts }
613
+ const byMilestone = new Map<string, Entry[]>()
614
+
615
+ for (const [slug, issues] of issuesBySlug) {
616
+ for (const issue of issues) {
617
+ if (issue.state !== 'OPEN') continue
618
+ const milestoneTitle = issue.milestone?.title
619
+ if (!milestoneTitle) continue
620
+ const labels = issue.labels.map((l) => l.name)
621
+ if (!isTaskIssueLabelSet(labels)) continue
622
+ const body = issue.body ?? ''
623
+ const surface = parseIssueSurface(body)
624
+ if (!surface.ok) continue
625
+
626
+ const deps = parseRationaleDeps(body)
627
+ const facts: TaskSurfaceFacts = {
628
+ ref: String(issue.number),
629
+ surfaceIn: surface.value.in,
630
+ conflictsWith: deps.conflictsWith,
631
+ dependsOn: deps.dependsOn
632
+ }
633
+ const group = byMilestone.get(milestoneTitle) ?? []
634
+ group.push({ slug, issue, facts })
635
+ byMilestone.set(milestoneTitle, group)
636
+ }
637
+ }
638
+
639
+ const failures: CheckFailure[] = []
640
+ for (const group of byMilestone.values()) {
641
+ if (group.length < 2) continue
642
+ for (const entry of group) {
643
+ const siblings = group.filter((g) => g.facts.ref !== entry.facts.ref).map((g) => g.facts)
644
+ const errors = checkSurfaceOverlap(entry.facts, siblings).errors
645
+ if (errors.length === 0) continue
646
+ failures.push({
647
+ code: 'surface-overlap',
648
+ issue: entry.issue.number,
649
+ tranche: entry.slug,
650
+ reason: `Issue #${entry.issue.number} fails the cross-task surface-overlap gate: ${errors.join(' | ')}`
651
+ })
652
+ }
653
+ }
654
+ return { check: 'R3', status: failures.length > 0 ? 'fail' : 'pass', failures }
655
+ }
656
+
494
657
  /**
495
658
  * L1: Active tranche with zero open task-Issues → should be archived.
496
659
  * **Advisory (info-only)** per `state-machine.md` §12 (L1/L2 are lifecycle-hygiene
497
660
  * signals, not the done-lifecycle gate). Findings are surfaced for a human to
498
- * investigate; they never fail CI. Only A1/A2/A3/M1/M3/L5 block (L5 promoted, vinaya-milestone-model-v1 task 1).
661
+ * investigate; they never fail CI. Only A1/A2/A3/M1/M3/L5 block (L5 later promoted from advisory).
499
662
  *
500
663
  * An active tranche (file not in completed/) where every task with a
501
664
  * known issue has `issueState === 'closed'`.
@@ -510,6 +673,7 @@ export function checkL1(files: TrancheFile[], entriesBySlug: Map<string, TaskEnt
510
673
  const allClosed = withFacts.every((e) => e.facts?.issueState === 'closed')
511
674
  if (allClosed) {
512
675
  failures.push({
676
+ code: 'archive-recommended',
513
677
  tranche: f.slug,
514
678
  reason: 'Active tranche has no open task-Issues — consider archiving to completed/'
515
679
  })
@@ -530,7 +694,7 @@ export function checkL1(files: TrancheFile[], entriesBySlug: Map<string, TaskEnt
530
694
  * L2: Archived tranche with any open task-Issue → premature archive.
531
695
  * **Advisory (info-only)** per `state-machine.md` §12 (L1/L2 are lifecycle-hygiene
532
696
  * signals, not the done-lifecycle gate). Findings are surfaced for a human to
533
- * investigate; they never fail CI. Only A1/A2/A3/M1/M3/L5 block (L5 promoted, vinaya-milestone-model-v1 task 1).
697
+ * investigate; they never fail CI. Only A1/A2/A3/M1/M3/L5 block (L5 later promoted from advisory).
534
698
  */
535
699
  export function checkL2(files: TrancheFile[], entriesBySlug: Map<string, TaskEntry[]>): CheckResult {
536
700
  const failures: CheckFailure[] = []
@@ -541,6 +705,7 @@ export function checkL2(files: TrancheFile[], entriesBySlug: Map<string, TaskEnt
541
705
  if (!e.facts) continue
542
706
  if (e.facts.issueState === 'open') {
543
707
  failures.push({
708
+ code: 'premature-archive',
544
709
  issue: e.task.issue,
545
710
  tranche: f.slug,
546
711
  task: e.task.id,
@@ -574,12 +739,11 @@ export function checkL3(files: TrancheFile[]): CheckResult {
574
739
  }
575
740
 
576
741
  /**
577
- * L4: Issue-level Milestone-attachment drift (aeg-review-gate-v1 task 1
578
- * follow-up). An open task-Issue carrying `vinaya/tranche:<slug>` for an ACTIVE
742
+ * L4: Issue-level Milestone-attachment drift. An open task-Issue carrying `vinaya/tranche:<slug>` for an ACTIVE
579
743
  * tranche (open Milestone titled the slug) whose GitHub-native
580
744
  * `milestone` field doesn't match that same Milestone.
581
745
  *
582
- * **Scope changed (vinaya-milestone-model-v1 task 1): the exact-title-match
746
+ * **Scope changed: the exact-title-match
583
747
  * invariant this check evaluates is only meaningful for LEGACY tranches** —
584
748
  * a Milestone titled exactly the tranche slug, the 1:1 regime that predates
585
749
  * the label model. Once one Milestone can legitimately hold several
@@ -612,6 +776,7 @@ export function checkL4(
612
776
  if (!activeSet.has(f.tranche)) continue
613
777
  if (f.milestoneTitle === f.tranche) continue
614
778
  failures.push({
779
+ code: 'milestone-drift',
615
780
  issue: f.issue,
616
781
  tranche: f.tranche,
617
782
  reason:
@@ -633,8 +798,8 @@ export function checkL4(
633
798
 
634
799
  /**
635
800
  * L5: an active tranche whose every task Issue is closed → the tranche is
636
- * effectively complete but was never archived (Issue #481, drift class #2;
637
- * 1 live incident this session — `aeg-forge-state-v1`'s Milestone left open
801
+ * effectively complete but was never archived (a real drift class;
802
+ * confirmed live — a real tranche's Milestone left open
638
803
  * after full archive).
639
804
  *
640
805
  * This is the FORGE-NATIVE analogue of file-based L1: L1 reads `TrancheFile[]`
@@ -643,8 +808,8 @@ export function checkL4(
643
808
  * L5 keys off `activeTrancheSlugs` (the derived-active population — the
644
809
  * authority) instead, so it sees exactly the tranches L1 no longer can.
645
810
  *
646
- * **Promoted from advisory to authoritative (vinaya-milestone-model-v1 task
647
- * 1): `status` is now `'fail'`, joining A1/A2/A3/M1/M3 as CI-blocking.**
811
+ * **Promoted from advisory to authoritative: `status` is now `'fail'`,
812
+ * joining A1/A2/A3/M1/M3 as CI-blocking.**
648
813
  * Before this task, "the tranche is complete" meant "its Milestone is
649
814
  * closed" — a fact a Milestone shared by several tranches can no longer
650
815
  * carry reliably (closing it would close every tranche it holds, not just
@@ -669,6 +834,7 @@ export function checkL5(activeTrancheSlugs: string[], entriesBySlug: Map<string,
669
834
  const allClosed = withFacts.every((e) => e.facts?.issueState === 'closed')
670
835
  if (allClosed) {
671
836
  failures.push({
837
+ code: 'tranche-not-archived',
672
838
  tranche: slug,
673
839
  reason: 'Every task Issue is closed but the tranche is not recorded as complete — archive it'
674
840
  })
@@ -686,9 +852,9 @@ export function checkL5(activeTrancheSlugs: string[], entriesBySlug: Map<string,
686
852
  }
687
853
 
688
854
  /** Extracts the set of Issue numbers a PR body's `Closes #N` (and Fixes/
689
- * Resolves synonyms) references. Shared by `checkClosesN`'s forward and
855
+ * Resolves synonyms) references. Shared by `checkClosesNTopology`'s forward and
690
856
  * reverse directions, and by the CI wiring script that must resolve each
691
- * referenced Issue's task identity *before* calling `checkClosesN` — one
857
+ * referenced Issue's task identity *before* calling `checkClosesNTopology` — one
692
858
  * grammar, not a second copy of the pattern (discipline). Honors the
693
859
  * AEG:CLOSES anchor pair (`anchored-region.ts`, task 30) when present: only
694
860
  * references inside the pair count, so a Closes-shaped line in a pasted
@@ -696,10 +862,10 @@ export function checkL5(activeTrancheSlugs: string[], entriesBySlug: Map<string,
696
862
  * is additionally `stripCode`d before matching, for parity with GitHub's
697
863
  * auto-close parser (which ignores `Closes #N` inside code) — a backticked-only
698
864
  * reference resolves to no Issue here exactly as it does on merge, so this
699
- * repo-wide check and the pre-merge `checkClosesN` agree with GitHub.
865
+ * repo-wide check and the pre-merge `checkClosesNTopology` agree with GitHub.
700
866
  *
701
867
  * The separator groups are bounded (`\s{0,8}`) for the same reason, and to the
702
- * same width, as `checkClosesN`'s — see the ReDoS note there. The two patterns
868
+ * same width, as `checkClosesNTopology`'s — see the ReDoS note there. The two patterns
703
869
  * must stay byte-identical apart from the capture group; a divergence here is
704
870
  * a gate-disagreement bug, not a style difference. */
705
871
  export function extractClosesReferences(prBody: string): Set<number> {
@@ -709,7 +875,7 @@ export function extractClosesReferences(prBody: string): Set<number> {
709
875
  // the strip's rules read (list vs indented-code, fence pairing), so an
710
876
  // anchor indented inside a list item was blanked as if it were code, and
711
877
  // this parser silently disagreed with the whole-body path in the same call
712
- // (PR #617 review MAJOR). See `archive-task.ts`'s `extractIssue`.
878
+ // (a MAJOR review finding). See `archive-task.ts`'s `extractIssue`.
713
879
  const stripped = stripCode(prBody)
714
880
  const searchIn = anchoredRegion(stripped, 'CLOSES') ?? stripped
715
881
  const referenced = new Set<number>()
@@ -728,7 +894,7 @@ export function extractClosesReferences(prBody: string): Set<number> {
728
894
  *
729
895
  * Reverse direction (added: a branch NOT named `task/<tranche>/<n>` that
730
896
  * nonetheless closes a real AEG task Issue must be named after that task —
731
- * the gap that let `feat/vinaya-landing-v3` implement Issue #509 with zero
897
+ * the gap that let a real feature branch implement a real Issue with zero
732
898
  * forge-visible status. Runs for ANY branch, gated on `taskIssueRefs` being
733
899
  * supplied: each `Closes #N` the body references is looked up in the map;
734
900
  * an entry resolving to a task's `{trancheSlug, taskId}` requires
@@ -742,7 +908,7 @@ export function extractClosesReferences(prBody: string): Set<number> {
742
908
  * in BRANCH + PR_BODY env vars (forward) and a batched forge lookup
743
909
  * (reverse, see `@attalabs/aeg-forge-state`'s `fetchTaskIssueRefs`).
744
910
  */
745
- export function checkClosesN(
911
+ export function checkClosesNTopology(
746
912
  branch: string,
747
913
  prBody: string,
748
914
  trancheFiles: TrancheFile[],
@@ -764,11 +930,26 @@ export function checkClosesN(
764
930
  }
765
931
  }
766
932
 
767
- const m = branch.match(/^task\/([^/]+)\/([^/]+)$/)
768
- if (!m) return { ok: true } // non-task branch — forward direction bypass
933
+ const ref = parseTaskBranchIdentity(branch)
934
+ if (!ref) return { ok: true } // non-task branch — forward direction bypass
935
+
936
+ // A backlog Issue's task IS its Issue — the
937
+ // expected `Closes #N` is the branch's own issue number, no topology
938
+ // lookup needed at all.
939
+ if (ref.kind === 'issue') {
940
+ const expectedIssue = ref.issueNumber
941
+ if (!referenced.has(expectedIssue)) {
942
+ return {
943
+ ok: false,
944
+ expectedIssue,
945
+ message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
946
+ }
947
+ }
948
+ return { ok: true, expectedIssue }
949
+ }
769
950
 
770
- const trancheSlug = m[1] as string
771
- const taskId = m[2] as string
951
+ const trancheSlug = ref.tranche
952
+ const taskId = ref.taskId
772
953
 
773
954
  const trancheFile = trancheFiles.find((f) => f.slug === trancheSlug)
774
955
  if (!trancheFile) {
@@ -1,6 +1,6 @@
1
1
  /**
2
- * `checkConsumerTests`'s consumer enumeration (`brief-validation.ts`, task 10,
3
- * Issue #385; corrected by the round-2 ruling item 3) — every workspace
2
+ * `checkConsumerTests`'s consumer enumeration (`brief-validation.ts`,
3
+ * corrected by a later ruling) — every workspace
4
4
  * member whose own `package.json` depends on `@attalabs/<pkg>`, for "every
5
5
  * workspace package depending on `@attalabs/<pkg>`" to mean what it says.
6
6
  *
@@ -0,0 +1,75 @@
1
+ export {
2
+ CONTROL_RECORD_VERSION,
3
+ parseEffectRecord,
4
+ parseEscalationRecord,
5
+ parseInputRecord,
6
+ parseLoopStateRecord,
7
+ parseManifestRecord,
8
+ parseOwnershipRecord,
9
+ parseResolutionRecord,
10
+ parseRunRecord,
11
+ parseTransitionRecord
12
+ } from './records'
13
+ export type {
14
+ ControlRecord,
15
+ EffectRecord,
16
+ EffectStatus,
17
+ EscalationRecord,
18
+ InputRecord,
19
+ LoopBudgets,
20
+ LoopStateRecord,
21
+ ManifestRecord,
22
+ OwnershipRecord,
23
+ ParsedRecord,
24
+ ResolutionRecord,
25
+ RoundHeadIdentity,
26
+ RunRecord,
27
+ TransitionRecord
28
+ } from './records'
29
+ export {
30
+ acquireOwnership,
31
+ appendTransition,
32
+ attemptEpochClaim,
33
+ consumeResolutionOnce,
34
+ CONTROL_AREA_DIRNAME,
35
+ defaultControlStoreDeps,
36
+ InvalidEffectKeyError,
37
+ InvalidEscalationIdError,
38
+ InvalidRunIdError,
39
+ listStartedEffectKeys,
40
+ markEffectUncertain,
41
+ mkdirNoSymlinks,
42
+ readCurrentOwnership,
43
+ readEffect,
44
+ readEscalation,
45
+ readInput,
46
+ readLoopState,
47
+ readManifest,
48
+ readResolution,
49
+ readRun,
50
+ readTransitions,
51
+ StaleEpochWriteError,
52
+ writeEffect,
53
+ writeEscalation,
54
+ writeInput,
55
+ writeLoopState,
56
+ writeManifest,
57
+ writeRun
58
+ } from './local'
59
+ export type {
60
+ AcquireResult,
61
+ ConsumeResolutionResult,
62
+ ControlStoreDeps,
63
+ EffectInput,
64
+ EscalationInput,
65
+ InputInput,
66
+ LoopStateInput,
67
+ ManifestInput,
68
+ ResolutionInput,
69
+ RunInput,
70
+ TransitionInput
71
+ } from './local'
72
+ export { defaultIsPidAlive, migrateLegacyTask } from './migration'
73
+ export type { MigrationResult } from './migration'
74
+ export { normalizeOutcome } from './outcomes'
75
+ export type { NormalizedOutcome, OutcomeSignals, TaskOutcomeStatus } from './outcomes'