@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,488 @@
1
+ /**
2
+ * The task-tool catalog — the one place a task-operator tool's name, input
3
+ * shape, result shape, error shape and purpose are written. Five tools:
4
+ * `task_status` and `task_escalation_read` are bound to a real read
5
+ * interface (`apps/cli/src/lib/task-tools/read.ts` and `handlers.ts` —
6
+ * `apps/cli` reads the outbox and the forge, `aeg-core` stays pure); `task_start`,
7
+ * `task_resume` and `task_cancel` are declared here but refuse with
8
+ * `capability_unavailable` until a control store exists to act on (Traps to
9
+ * avoid: an internal helper is not automatically an agent tool, and this
10
+ * catalog exposes no raw shell or forge access — every field below is
11
+ * either a schema or prose, never a live handle to a process or a write).
12
+ *
13
+ * `handlerBinding` names where each tool's behaviour actually lives; it is
14
+ * data (a module/export pointer), not an import — `aeg-core` has no
15
+ * dependency on `apps/cli`, so the binding is documentation the CLI-side
16
+ * registry is expected to satisfy, not a call this file can make itself.
17
+ *
18
+ * A caller-supplied `role` field is never part of any input schema below —
19
+ * an agent's own claim about who it is authenticates nothing (Traps to
20
+ * avoid); authority is a property of the transport that invokes a tool, not
21
+ * a value that transport lets the caller set.
22
+ */
23
+
24
+ import { createHash } from 'node:crypto'
25
+ import { z } from 'zod'
26
+
27
+ // --- error taxonomy ---------------------------------------------------------
28
+
29
+ /**
30
+ * Eight kinds, each naming a distinct reason a tool call did not produce its
31
+ * result: `validation` (the input itself is malformed), `authority` (the
32
+ * caller may not do this), `precondition` (the input is well-formed but the
33
+ * task is not in a state this call accepts — e.g. resuming a task with no
34
+ * paused run), `capability` (the tool exists in the catalog but its handler
35
+ * is not yet implemented — the fixed refusal `task_start`/`task_resume`/
36
+ * `task_cancel` return today), `infrastructure` (a read or write the tool
37
+ * depends on failed for reasons outside the caller's input — a file the
38
+ * outbox should carry could not be read), `cancellation` (a cancel request
39
+ * could not be honored, e.g. nothing running to cancel), `timeout` (a read
40
+ * exceeded its own bound), and `uncertain_effect` (a mutation was attempted
41
+ * and its outcome could not be confirmed — reserved for `task_start`/
42
+ * `task_resume`/`task_cancel` once they have a real effect to be uncertain
43
+ * about; no handler below returns it yet).
44
+ */
45
+ export const TASK_TOOL_ERROR_KINDS = [
46
+ 'validation',
47
+ 'authority',
48
+ 'precondition',
49
+ 'capability',
50
+ 'infrastructure',
51
+ 'cancellation',
52
+ 'timeout',
53
+ 'uncertain_effect'
54
+ ] as const
55
+
56
+ export type TaskToolErrorKind = (typeof TASK_TOOL_ERROR_KINDS)[number]
57
+
58
+ export const TaskToolErrorSchema = z.object({
59
+ kind: z.enum(TASK_TOOL_ERROR_KINDS),
60
+ message: z.string().min(1),
61
+ detail: z.string().optional()
62
+ })
63
+
64
+ export type TaskToolError = z.infer<typeof TaskToolErrorSchema>
65
+
66
+ export function taskToolError(kind: TaskToolErrorKind, message: string, detail?: string): TaskToolError {
67
+ return detail === undefined ? { kind, message } : { kind, message, detail }
68
+ }
69
+
70
+ /** The one error every not-yet-landed mutating tool returns — same kind, same message shape, so a caller routing on `kind` never has to special-case which of the three it called. */
71
+ export function capabilityUnavailable(tool: TaskToolName, becauseOf: string): TaskToolError {
72
+ return taskToolError('capability', `${tool} is not available yet — ${becauseOf}.`)
73
+ }
74
+
75
+ // --- shared primitives -------------------------------------------------------
76
+
77
+ /**
78
+ * The two identity shapes every task-referencing tool accepts — a
79
+ * tranche-labeled task (`{ tranche, id }`, matching `task/<tranche>/<n>`) or
80
+ * a backlog task (`{ issue }`, matching `task/issue-<n>`) — the same two
81
+ * shapes `apps/cli/src/lib/task-status.ts`'s own `TaskRef` already
82
+ * distinguishes, mirrored here as the catalog's public vocabulary rather
83
+ * than importing that CLI-internal type (`aeg-core` takes no dependency on
84
+ * `apps/cli`).
85
+ */
86
+ export const TaskToolRefSchema = z.union([
87
+ z.object({ tranche: z.string().min(1), id: z.string().min(1) }).strict(),
88
+ z.object({ issue: z.number().int().positive() }).strict()
89
+ ])
90
+
91
+ export type TaskToolRef = z.infer<typeof TaskToolRefSchema>
92
+
93
+ /** Bounded pagination — every list-shaped result caps at `limit` (default and ceiling both declared here, so no caller and no handler picks its own). */
94
+ export const DEFAULT_PAGE_LIMIT = 20
95
+ export const MAX_PAGE_LIMIT = 100
96
+
97
+ export const PageRequestSchema = z.object({
98
+ cursor: z.string().optional(),
99
+ limit: z.number().int().positive().max(MAX_PAGE_LIMIT).optional()
100
+ })
101
+
102
+ export type PageRequest = z.infer<typeof PageRequestSchema>
103
+
104
+ /**
105
+ * `fresh`: the record was read and is current as of the run's last known
106
+ * transition. `stale`: the record was read but predates that transition
107
+ * (e.g. a pause record for a round the loop has since published past).
108
+ * `unknown`: no record exists to read at all, or it could not be parsed.
109
+ * Every observation the read interface (O2) returns carries one of these
110
+ * alongside its own `observedAt` timestamp — never a bare value with no way
111
+ * to tell a fresh read from a guess.
112
+ */
113
+ export const FreshnessSchema = z.enum(['fresh', 'stale', 'unknown'])
114
+ export type Freshness = z.infer<typeof FreshnessSchema>
115
+
116
+ export const ObservedSchema = z.object({
117
+ observedAt: z.string(),
118
+ freshness: FreshnessSchema
119
+ })
120
+
121
+ // --- task_status -------------------------------------------------------------
122
+
123
+ export const TaskStatusInputSchema = z
124
+ .object({
125
+ task: TaskToolRefSchema.optional()
126
+ })
127
+ .merge(PageRequestSchema)
128
+ .strict()
129
+
130
+ export type TaskStatusInput = z.infer<typeof TaskStatusInputSchema>
131
+
132
+ export const TaskStatusItemSchema = z
133
+ .object({
134
+ task: TaskToolRefSchema,
135
+ issue: z.number().int().positive(),
136
+ pr: z.number().int().positive().nullable(),
137
+ state: z.string()
138
+ })
139
+ .merge(ObservedSchema)
140
+
141
+ export const TaskStatusResultSchema = z.object({
142
+ items: z.array(TaskStatusItemSchema),
143
+ nextCursor: z.string().nullable()
144
+ })
145
+
146
+ export type TaskStatusResult = z.infer<typeof TaskStatusResultSchema>
147
+
148
+ // --- task_escalation_read ------------------------------------------------
149
+
150
+ /** Who this pause reason is addressed to — the same routing the loop's own doctrine already gives each `PauseReason`, named here so the tool's result carries it as data rather than requiring the caller to know the doctrine. */
151
+ export const RequestedAuthoritySchema = z.enum(['planner', 'principal', 'operator', 'self'])
152
+ export type RequestedAuthority = z.infer<typeof RequestedAuthoritySchema>
153
+
154
+ export const EscalationInputsSchema = z.object({
155
+ task: z.number().int().positive(),
156
+ round: z.number().int().nonnegative(),
157
+ head: z.string(),
158
+ branch: z.string(),
159
+ prNumber: z.number().int().positive()
160
+ })
161
+
162
+ export const EscalationEvidenceSchema = z.object({
163
+ round: z.number().int().nonnegative(),
164
+ reviewer: z.string().nullable(),
165
+ security: z.string().nullable()
166
+ })
167
+
168
+ /** The escalation's run identity — `null` when no durable `EscalationRecord` exists yet for this pause (a `PauseState` written before that control-store adoption, or a best-effort write that itself failed). */
169
+ export const EscalationRunIdentitySchema = z.object({
170
+ runId: z.string(),
171
+ pid: z.number().int().positive(),
172
+ host: z.string()
173
+ })
174
+
175
+ /** The input versions the pause's round was judged against — `null` under the identical condition `EscalationRunIdentitySchema` is. */
176
+ export const EscalationInputVersionsSchema = z.object({
177
+ briefHash: z.string().nullable(),
178
+ objectivesVersion: z.string().nullable(),
179
+ rulingOrdinal: z.number().int().nonnegative(),
180
+ policyDigest: z.string()
181
+ })
182
+
183
+ export const TaskEscalationReadInputSchema = z
184
+ .object({
185
+ task: TaskToolRefSchema
186
+ })
187
+ .merge(PageRequestSchema)
188
+ .strict()
189
+
190
+ export type TaskEscalationReadInput = z.infer<typeof TaskEscalationReadInputSchema>
191
+
192
+ export const TaskEscalationPacketSchema = z
193
+ .object({
194
+ reason: z.string(),
195
+ detail: z.string().nullable(),
196
+ inputs: EscalationInputsSchema.nullable(),
197
+ evidence: EscalationEvidenceSchema.nullable(),
198
+ attemptedRecovery: z.string(),
199
+ requestedAuthority: RequestedAuthoritySchema,
200
+ permittedNextActions: z.array(z.string()),
201
+ /** From the durable `EscalationRecord` — `null` when none exists for this pause (see the field's own schema doc). */
202
+ runIdentity: EscalationRunIdentitySchema.nullable(),
203
+ /** From the durable `EscalationRecord` — `null` under the identical condition. */
204
+ inputVersions: EscalationInputVersionsSchema.nullable()
205
+ })
206
+ .merge(ObservedSchema)
207
+
208
+ export type TaskEscalationPacket = z.infer<typeof TaskEscalationPacketSchema>
209
+
210
+ export const TaskEscalationReadResultSchema = z
211
+ .object({
212
+ items: z.array(TaskEscalationPacketSchema),
213
+ nextCursor: z.string().nullable()
214
+ })
215
+ .merge(ObservedSchema)
216
+
217
+ export type TaskEscalationReadResult = z.infer<typeof TaskEscalationReadResultSchema>
218
+
219
+ // --- task_start / task_resume / task_cancel (stubs — O3) ------------------
220
+
221
+ export const TaskStartInputSchema = z
222
+ .object({
223
+ tranche: z.string().min(1),
224
+ id: z.string().min(1)
225
+ })
226
+ .strict()
227
+ export type TaskStartInput = z.infer<typeof TaskStartInputSchema>
228
+
229
+ /**
230
+ * `task_start`'s durable result (O2): the request identity this start was
231
+ * scoped to, the durable run identity a caller can address it by (the task's
232
+ * tranche/id — its `task/<tranche>/<n>` branch is the addressing scheme every
233
+ * other tool and role already resolves through), whether THIS call started the
234
+ * run or replayed an already-started one (`started`), when it was first
235
+ * started, and the mode it ran in. `mode` is a literal `'attended'`: there is
236
+ * no unattended start until the worker-isolation boundary and a capability flag
237
+ * exist, so the field never carries any other value today.
238
+ */
239
+ export const TaskStartResultSchema = z.object({
240
+ requestId: z.string().min(1),
241
+ run: z.object({ tranche: z.string().min(1), id: z.string().min(1) }),
242
+ started: z.boolean(),
243
+ startedAt: z.string(),
244
+ mode: z.literal('attended')
245
+ })
246
+ export type TaskStartResult = z.infer<typeof TaskStartResultSchema>
247
+
248
+ /**
249
+ * The stable request identity a `task_start` call is idempotent on (O2) —
250
+ * scoped to the caller, the repo, the target task, and a digest of the call's
251
+ * own payload, so the same caller asking to start the same task twice collapses
252
+ * to one run, while a different caller, repo, target, or payload is a distinct
253
+ * request. Pure and deterministic: the same input always yields the same id,
254
+ * across processes and machines, which is what lets a durable store recognise a
255
+ * duplicate start after a disconnect. It authenticates nothing on its own — the
256
+ * `caller` value must come from the transport's invocation context, never a
257
+ * tool argument (this module's own header).
258
+ */
259
+ export type TaskStartRequestInput = {
260
+ caller: string
261
+ repo: string | null
262
+ tranche: string
263
+ id: string
264
+ payloadDigest: string
265
+ }
266
+
267
+ export function taskStartRequestIdentity(input: TaskStartRequestInput): string {
268
+ const canonical = JSON.stringify({
269
+ caller: input.caller,
270
+ repo: input.repo,
271
+ tranche: input.tranche,
272
+ id: input.id,
273
+ payloadDigest: input.payloadDigest
274
+ })
275
+ return `req_${createHash('sha256').update(canonical).digest('hex').slice(0, 32)}`
276
+ }
277
+
278
+ export const TaskResumeInputSchema = z
279
+ .object({
280
+ task: TaskToolRefSchema
281
+ })
282
+ .strict()
283
+ export type TaskResumeInput = z.infer<typeof TaskResumeInputSchema>
284
+
285
+ export const TaskCancelInputSchema = z
286
+ .object({
287
+ task: TaskToolRefSchema,
288
+ reason: z.string().min(1)
289
+ })
290
+ .strict()
291
+ export type TaskCancelInput = z.infer<typeof TaskCancelInputSchema>
292
+
293
+ /**
294
+ * `task_resume`'s durable result: the run this call
295
+ * addressed (`task`/`pr`), the escalation it resolved (`escalationId`), and
296
+ * the authenticated decision reference it consumed — `authenticatedBy`/
297
+ * `authenticatedFrom` mirror `ResolutionRecord`'s own fields exactly, never a
298
+ * caller-supplied claim (Traps to avoid: no free-text approved boolean).
299
+ * `outcome: 'started'` — this call is the one that triggered the existing
300
+ * `dev-review-loop --resume` continuation. `outcome: 'already_resumed'` — a
301
+ * prior call (or a race this call lost) already did, and this call is a
302
+ * truthful idempotent replay: nothing new was started.
303
+ */
304
+ export const TaskResumeResultSchema = z.object({
305
+ task: z.number().int().positive(),
306
+ pr: z.number().int().positive(),
307
+ escalationId: z.string().min(1),
308
+ outcome: z.enum(['started', 'already_resumed']),
309
+ authenticatedBy: z.string().min(1),
310
+ authenticatedFrom: z.string().min(1)
311
+ })
312
+ export type TaskResumeResult = z.infer<typeof TaskResumeResultSchema>
313
+
314
+ /**
315
+ * `task_cancel`'s three truthful outcomes:
316
+ * `'confirmed'` — the cancellation is durably resolved and, where a local
317
+ * in-flight process existed, it was signaled on this host. `'pending'` — the
318
+ * cancellation is durably resolved, but the run's own driver was dispatched
319
+ * on a DIFFERENT host, so this call cannot itself confirm the process
320
+ * stopped (the driver's own next control-store write is fenced regardless —
321
+ * see `fencedEffectKeys`). `'uncertain'` — one or more in-flight external
322
+ * effects could not be confirmed complete and were fenced instead; a late
323
+ * result cannot land under the superseded epoch, but whether it had already
324
+ * landed before the fence is not knowable from here.
325
+ */
326
+ export const TaskCancelOutcomeSchema = z.enum(['confirmed', 'pending', 'uncertain'])
327
+ export type TaskCancelOutcome = z.infer<typeof TaskCancelOutcomeSchema>
328
+
329
+ export const TaskCancelResultSchema = z.object({
330
+ task: z.number().int().positive(),
331
+ pr: z.number().int().positive(),
332
+ escalationId: z.string().min(1),
333
+ outcome: TaskCancelOutcomeSchema,
334
+ authenticatedBy: z.string().min(1),
335
+ authenticatedFrom: z.string().min(1),
336
+ /** Effect keys fenced from `'started'` to `'uncertain'` by this cancel — empty on an idempotent replay, which fences nothing new. */
337
+ fencedEffectKeys: z.array(z.string())
338
+ })
339
+ export type TaskCancelResult = z.infer<typeof TaskCancelResultSchema>
340
+
341
+ // --- catalog -----------------------------------------------------------------
342
+
343
+ export const TASK_TOOL_NAMES = [
344
+ 'task_start',
345
+ 'task_status',
346
+ 'task_escalation_read',
347
+ 'task_resume',
348
+ 'task_cancel'
349
+ ] as const
350
+
351
+ export type TaskToolName = (typeof TASK_TOOL_NAMES)[number]
352
+
353
+ export function isTaskToolName(value: string): value is TaskToolName {
354
+ return (TASK_TOOL_NAMES as readonly string[]).includes(value)
355
+ }
356
+
357
+ /** Where a tool's behaviour is actually implemented — a pointer for a CLI-side registry to satisfy, never a call this module makes. */
358
+ export type TaskToolHandlerBinding =
359
+ | { kind: 'bound'; module: string; export: string }
360
+ | { kind: 'stub'; module: string; export: string }
361
+
362
+ export type TaskToolDefinition<Input = unknown, Result = unknown> = {
363
+ name: TaskToolName
364
+ /** One sentence: what an Operator calls this tool to accomplish. */
365
+ purpose: string
366
+ /** What this tool is not — the neighbour it is easiest to confuse it with, and why the boundary sits where it does. */
367
+ boundaries: string
368
+ inputSchema: z.ZodType<Input>
369
+ resultSchema: z.ZodType<Result>
370
+ errorSchema: typeof TaskToolErrorSchema
371
+ /** At least one schema-valid input, so a catalog consumer can typecheck and smoke-test a call without inventing its own fixture. */
372
+ examples: readonly Input[]
373
+ handlerBinding: TaskToolHandlerBinding
374
+ }
375
+
376
+ export const TASK_STATUS_TOOL: TaskToolDefinition<TaskStatusInput, TaskStatusResult> = {
377
+ name: 'task_status',
378
+ purpose:
379
+ "Read a task's current loop state (running, paused, published, exited, or no driver) and its Issue/PR identity, without shelling to `ps` or re-parsing posted verdict comments.",
380
+ boundaries:
381
+ 'Terse and always-answerable: one state per task, from records that either exist or explicitly do not. It never explains WHY a paused task is paused beyond naming the reason — that full packet is `task_escalation_read`. Omitting `task` lists every open task, paginated; it never starts, resumes or cancels anything.',
382
+ inputSchema: TaskStatusInputSchema,
383
+ resultSchema: TaskStatusResultSchema,
384
+ errorSchema: TaskToolErrorSchema,
385
+ examples: [{ task: { tranche: 'task-operator-v1', id: '1' } }, { limit: 10 }, {}],
386
+ handlerBinding: { kind: 'bound', module: 'apps/cli/src/lib/task-tools/handlers.ts', export: 'taskStatusHandler' }
387
+ }
388
+
389
+ export const TASK_ESCALATION_READ_TOOL: TaskToolDefinition<TaskEscalationReadInput, TaskEscalationReadResult> = {
390
+ name: 'task_escalation_read',
391
+ purpose:
392
+ "Read the full escalation packet for a paused task — the reason, the round's inputs, the held verdict evidence, what recovery the driver already attempted, who the pause is addressed to, and the actions permitted next.",
393
+ boundaries:
394
+ 'Only meaningful once `task_status` reports `paused` (or a prior pause the run has since moved past, returned as `stale`); calling it on a task with no pause record ever written answers with an empty, `unknown`-freshness page rather than an error — a caller unsure whether a task ever paused can call this directly. It never resumes or cancels; those stay `task_resume`/`task_cancel`.',
395
+ inputSchema: TaskEscalationReadInputSchema,
396
+ resultSchema: TaskEscalationReadResultSchema,
397
+ errorSchema: TaskToolErrorSchema,
398
+ examples: [{ task: { tranche: 'task-operator-v1', id: '1' } }, { task: { issue: 558 }, limit: 5 }],
399
+ handlerBinding: {
400
+ kind: 'bound',
401
+ module: 'apps/cli/src/lib/task-tools/handlers.ts',
402
+ export: 'taskEscalationReadHandler'
403
+ }
404
+ }
405
+
406
+ export const TASK_START_TOOL: TaskToolDefinition<TaskStartInput, TaskStartResult> = {
407
+ name: 'task_start',
408
+ purpose:
409
+ 'Start the dev-review-loop for an explicitly selected, already-frozen task, in attended mode, under the caller’s own credentials — wrapping the existing `runTask` composition and returning the durable run identity.',
410
+ boundaries:
411
+ 'Distinct from `task_resume`: this tool starts a run, it does not continue a paused one. It refuses (`authority`) unless the invocation context carries an authenticated caller — MCP is a transport, not authorization, so the caller is never taken from an argument. It is idempotent per request identity (caller + repo + target + payload digest): asking twice returns the same run and starts nothing twice. ATTENDED MODE ONLY — the run it starts inherits the caller’s own environment and credentials; there is no unattended start and no attended bypass. An unattended start waits on the worker-isolation boundary and a capability flag a later tranche adds.',
412
+ inputSchema: TaskStartInputSchema,
413
+ resultSchema: TaskStartResultSchema,
414
+ errorSchema: TaskToolErrorSchema,
415
+ examples: [{ tranche: 'task-operator-v1', id: '1' }],
416
+ handlerBinding: { kind: 'bound', module: 'apps/cli/src/lib/task-tools/start.ts', export: 'defaultTaskStartHandler' }
417
+ }
418
+
419
+ export const TASK_RESUME_TOOL: TaskToolDefinition<TaskResumeInput, TaskResumeResult> = {
420
+ name: 'task_resume',
421
+ purpose: 'Continue a paused dev-review-loop run from where it left off, once a Principal ruling authenticates it.',
422
+ boundaries:
423
+ "Distinct from `task_start`: this tool only ever applies to a task that already has a paused run, never a fresh one. It never accepts a caller-supplied approval — the only decision reference it consumes is a Principal ruling comment already posted on the run's own PR, read fresh from the forge every call, never taken from a tool argument. It never resolves a decision itself: it triggers the SAME `dev-review-loop --resume` continuation the CLI has always used, guarded so the same paused escalation is never resumed by two calls.",
424
+ inputSchema: TaskResumeInputSchema,
425
+ resultSchema: TaskResumeResultSchema,
426
+ errorSchema: TaskToolErrorSchema,
427
+ examples: [{ task: { tranche: 'task-operator-v1', id: '1' } }],
428
+ handlerBinding: { kind: 'bound', module: 'apps/cli/src/lib/task-tools/resume.ts', export: 'defaultTaskResumeHandler' }
429
+ }
430
+
431
+ export const TASK_CANCEL_TOOL: TaskToolDefinition<TaskCancelInput, TaskCancelResult> = {
432
+ name: 'task_cancel',
433
+ purpose: 'Stop a paused dev-review-loop run, fencing any in-flight effect it can no longer safely complete.',
434
+ boundaries:
435
+ 'The only tool in this catalog whose job is to end a run rather than read or continue one. Like `task_resume`, it consumes a Principal ruling read fresh from the forge, never a caller-supplied approval. A repeated call against an already-cancelled escalation reports the same outcome again rather than erroring — cancelling twice is never a retry of a failed cancel.',
436
+ inputSchema: TaskCancelInputSchema,
437
+ resultSchema: TaskCancelResultSchema,
438
+ errorSchema: TaskToolErrorSchema,
439
+ examples: [{ task: { issue: 558 }, reason: 'superseded by a re-plan' }],
440
+ handlerBinding: { kind: 'bound', module: 'apps/cli/src/lib/task-tools/cancel.ts', export: 'defaultTaskCancelHandler' }
441
+ }
442
+
443
+ /** The one place every tool's name and shape can be found — in this fixed order, matching `TASK_TOOL_NAMES`. */
444
+ export const TASK_TOOL_CATALOG: readonly [
445
+ typeof TASK_START_TOOL,
446
+ typeof TASK_STATUS_TOOL,
447
+ typeof TASK_ESCALATION_READ_TOOL,
448
+ typeof TASK_RESUME_TOOL,
449
+ typeof TASK_CANCEL_TOOL
450
+ ] = [TASK_START_TOOL, TASK_STATUS_TOOL, TASK_ESCALATION_READ_TOOL, TASK_RESUME_TOOL, TASK_CANCEL_TOOL]
451
+
452
+ export function taskToolByName(name: TaskToolName): TaskToolDefinition {
453
+ const found = TASK_TOOL_CATALOG.find((tool) => tool.name === name)
454
+ if (!found) throw new Error(`no catalog entry for task tool "${name}"`)
455
+ return found as TaskToolDefinition
456
+ }
457
+
458
+ // --- the Operator's tool grant, the boundary the router enforces -----------
459
+
460
+ /**
461
+ * The one grant the task Operator holds beyond the five catalog tools: the
462
+ * append-only `task status --follow` read (`apps/cli/src/lib/task-status.ts`'s
463
+ * own `--follow` narration). Named as a grant token rather than a catalog
464
+ * tool because it is a bounded status stream the Operator follows, not one of
465
+ * the five typed task tools — but it is still part of what the router must
466
+ * recognize as granted, so it lives here beside the catalog rather than as a
467
+ * bare string a caller reinvents.
468
+ */
469
+ export const OPERATOR_STATUS_FOLLOW = 'task_status_follow' as const
470
+
471
+ /**
472
+ * The complete, closed set of tools the task Operator is granted — the
473
+ * five catalog tools plus the status-follow read, and nothing else. This is
474
+ * the machine-readable twin of `aeg-root/roles/operator.md`'s `allowed-tools`
475
+ * frontmatter and of the generated skill's `allowed-tools`; a test binds all
476
+ * three so no representation drifts from another. The router refuses every
477
+ * tool outside this set: a registered tool is a capability, but the grant is
478
+ * what says the Operator may call it — a shell, a forge write, an Issue edit,
479
+ * a review publish or a merge is never in it.
480
+ */
481
+ export const OPERATOR_TOOL_GRANT = [...TASK_TOOL_NAMES, OPERATOR_STATUS_FOLLOW] as const
482
+
483
+ export type OperatorGrantedTool = (typeof OPERATOR_TOOL_GRANT)[number]
484
+
485
+ /** True only for a tool inside the Operator's grant — the membership test the router's refusal is built on. Any name not in `OPERATOR_TOOL_GRANT` (a shell, a forge write, an Issue edit, `merge`, a review publish) is outside the grant and refused. */
486
+ export function isOperatorGranted(tool: string): tool is OperatorGrantedTool {
487
+ return (OPERATOR_TOOL_GRANT as readonly string[]).includes(tool)
488
+ }
@@ -1,7 +1,6 @@
1
1
  /**
2
- * Test Plan checkbox-state gate evaluator (aeg-governance-hardening
3
- * task 25, #365; narrowed to `[principal]` boxes only by task 12, #387 —
4
- * the `[agent]` half stopped being a checkbox at all: it is a fenced command
2
+ * Test Plan checkbox-state gate evaluator (later narrowed to `[principal]`
3
+ * boxes only — the `[agent]` half stopped being a checkbox at all: it is a fenced command
5
4
  * list `vinaya pr report` executes and writes into the `AEG:EVIDENCE` block,
6
5
  * which IS the evidence, so there is nothing left for this gate to grade on
7
6
  * that half). Pure — no `fs`, no `gh`/`git`. The CLI shim
@@ -13,17 +12,18 @@
13
12
  * This module owns the checkbox tick-state decision built on top of it:
14
13
  *
15
14
  * - No section found, task branch → `fail` (a task PR without a
16
- * Test Plan is malformed, not exempt — the exact #377 live-fire gap).
15
+ * Test Plan is malformed, not exempt — a real live-fire gap).
17
16
  * - No section found, non-task branch (or no BRANCH) → `pass` (advisory).
18
17
  * - `Test Plan: unit-tests-only` sentinel → `pass`.
19
18
  * - Any unticked `- [ ]` `[principal]` checkbox → `fail`, naming every
20
- * unticked line. A `[agent]`-tagged checkbox (a pre-#387 body, still
19
+ * unticked line. A `[agent]`-tagged checkbox (an older body, still
21
20
  * grandfathered by `brief-shape`'s own rollout) is never graded here —
22
21
  * see the module doc comment above.
23
22
  * - All `[principal]` boxes ticked (or none exist at all) → `pass`.
24
23
  */
25
24
 
26
25
  import { locateTestPlanSection } from './test-plan-section'
26
+ import { parseTaskBranchIdentity } from './task-branch-identity'
27
27
 
28
28
  export type TestPlanGateVerdict = 'pass' | 'fail'
29
29
  export type TestPlanGateResult = {
@@ -31,8 +31,6 @@ export type TestPlanGateResult = {
31
31
  messages: string[]
32
32
  }
33
33
 
34
- const TASK_BRANCH_PATTERN = /^task\/[^/]+\/[^/]+$/
35
-
36
34
  export function evaluateTestPlanGate(body: string, branch: string): TestPlanGateResult {
37
35
  if (!body) {
38
36
  return {
@@ -47,7 +45,7 @@ export function evaluateTestPlanGate(body: string, branch: string): TestPlanGate
47
45
  const located = locateTestPlanSection(body)
48
46
 
49
47
  if (!located.found) {
50
- if (TASK_BRANCH_PATTERN.test(branch)) {
48
+ if (parseTaskBranchIdentity(branch) !== null) {
51
49
  return {
52
50
  verdict: 'fail',
53
51
  messages: [
@@ -77,7 +75,7 @@ export function evaluateTestPlanGate(body: string, branch: string): TestPlanGate
77
75
  }
78
76
 
79
77
  // `[agent]` checkboxes are never graded here — see the module doc comment.
80
- // A pre-#387 body may still carry them (grandfathered by `brief-shape`'s
78
+ // An older body may still carry them (grandfathered by `brief-shape`'s
81
79
  // own rollout); this gate simply does not look at that tag at all any
82
80
  // more, ticked or not.
83
81
  const checkboxLines = section
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Test Plan section locator (aeg-governance-hardening task 25, #365). Pure —
2
+ * Test Plan section locator. Pure —
3
3
  * no `fs`, no `gh`/`git`. Extracted from `bin/verify-test-plan.ts`'s original
4
- * inline-only regex to fix the live-fire gap PR #377 exposed: its body used
4
+ * inline-only regex to fix a live-fire gap a real PR exposed: its body used
5
5
  * the `## 9. Test Plan` heading form, which the old inline-only regex never
6
6
  * matched, so `verify-test-plan` reported "no section" and advisory-PASSED a
7
7
  * PR that actually had an unticked `**[principal]**` box.
@@ -43,9 +43,9 @@ const NEXT_SECTION_RE = /\n(?:#{1,3}[ \t]|\*\*[A-Z][^*\n]*:\*\*)/
43
43
  * task 30), the pair IS the section: its whole content is returned verbatim,
44
44
  * with no heading/inline marker required inside it — requiring a second,
45
45
  * redundant in-region marker would reintroduce the unrecognized-heading
46
- * failure class (#377) the anchors exist to close. Identical-looking Test
47
- * Plan text elsewhere in the body (a pasted reference brief's own §9, the
48
- * PR #392 shape) is ignored. Bodies without the pair parse exactly as before.
46
+ * failure class the anchors exist to close. Identical-looking Test
47
+ * Plan text elsewhere in the body (a pasted reference brief's own §9)
48
+ * is ignored. Bodies without the pair parse exactly as before.
49
49
  */
50
50
  export function locateTestPlanSection(body: string): TestPlanSection {
51
51
  const region = anchoredRegion(body, 'TEST-PLAN')
@@ -30,8 +30,8 @@ export type Registry = Project[]
30
30
  // ---------- Tranche file (tranches/<name>.md) ----------
31
31
 
32
32
  /**
33
- * `Lifecycle`/`Task`/`Tranche` live in `@attalabs/aeg-types` (task
34
- * aeg-forge-state-v1 3a) — re-exported here since every existing call site
33
+ * `Lifecycle`/`Task`/`Tranche` live in `@attalabs/aeg-types` —
34
+ * re-exported here since every existing call site
35
35
  * across the repo imports them from `@attalabs/aeg-core`. Moved out so
36
36
  * `@attalabs/aeg-forge-state` can depend on these shapes without creating a
37
37
  * package cycle with `aeg-core` (which in turn depends on
@@ -42,7 +42,7 @@ export type { Lifecycle, Task, Tranche }
42
42
  // ---------- Forge facts ----------
43
43
 
44
44
  /**
45
- * `ForgeFacts` lives in `@attalabs/aeg-types` (aeg-core-purity fix, #521) —
45
+ * `ForgeFacts` lives in `@attalabs/aeg-types` (an aeg-core-purity fix) —
46
46
  * re-exported here for the same reason as `Lifecycle`/`Task`/`Tranche`:
47
47
  * every existing call site imports it from `@attalabs/aeg-core`, and it moved
48
48
  * out so the I/O-performing fetchers that produce it (now in
@@ -131,7 +131,7 @@ export type DerivedTranche = {
131
131
  * The tranche total is `sum(rows)`, derived at read time — never stored.
132
132
  *
133
133
  * The two capture sources surface here as `null` cells: a row written by a
134
- * claude.ai role (Planner / Brief Author / Reviewer / Security) before the
134
+ * claude.ai role (Planner / Reviewer / Security) before the
135
135
  * Principal has filled in its usage figure has `tokensIn`/`tokensOut`/`cost`
136
136
  * as `null`; a terminal-role row (Developer / Archivist with `/cost`) has
137
137
  * exact numbers.