@attalabs/vinaya 0.35.0 → 0.37.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 (246) hide show
  1. package/README.md +6 -6
  2. package/aeg-root/contracts/developer-reviewer.md +1 -1
  3. package/aeg-root/contracts/planner-operator.md +1 -1
  4. package/aeg-root/contracts/principal-operator.md +6 -6
  5. package/aeg-root/contracts/security-archivist.md +1 -1
  6. package/aeg-root/enforcement.md +9 -10
  7. package/aeg-root/process.md +3 -1
  8. package/aeg-root/roles/archivist.md +2 -2
  9. package/aeg-root/roles/developer/reference.md +13 -16
  10. package/aeg-root/roles/developer.md +7 -3
  11. package/aeg-root/roles/operator.md +18 -18
  12. package/aeg-root/roles/planner/reference.md +23 -8
  13. package/aeg-root/roles/planner.md +2 -0
  14. package/aeg-root/roles/principal.md +6 -1
  15. package/aeg-root/roles/reviewer.md +11 -3
  16. package/aeg-root/roles/security.md +19 -9
  17. package/aeg-root/roles/tranche-archivist.md +14 -2
  18. package/aeg-root/state-machine.md +11 -10
  19. package/aeg-root/templates/brief-template.md +10 -4
  20. package/aeg-root/templates/pr-report-template.md +1 -9
  21. package/aeg-root/tranche-model.md +4 -4
  22. package/dist/checks/bin/check-body-bare-digits.js +2081 -1883
  23. package/dist/checks/bin/check-branch-topology.js +1376 -1139
  24. package/dist/checks/bin/check-brief-shape.js +2081 -1883
  25. package/dist/checks/bin/check-changeset-coverage.js +2564 -2025
  26. package/dist/checks/bin/check-closes-n.js +1376 -1139
  27. package/dist/checks/bin/check-coherence.js +1480 -1228
  28. package/dist/checks/bin/check-dead-branch-push.js +1339 -1156
  29. package/dist/checks/bin/check-dispatch-readiness.js +1480 -1228
  30. package/dist/checks/bin/check-doc-coverage-push.js +2563 -2024
  31. package/dist/checks/bin/check-doc-coverage.js +2565 -2026
  32. package/dist/checks/bin/check-doctrine-no-procedures.js +2081 -1883
  33. package/dist/checks/bin/check-doctrine-portability.js +2563 -2024
  34. package/dist/checks/bin/check-evidence-fresh.js +1906 -1536
  35. package/dist/checks/bin/check-exec-bits.js +2136 -1597
  36. package/dist/checks/bin/check-first-push-dispatch.js +1480 -1228
  37. package/dist/checks/bin/check-issue-assignment.js +1376 -1139
  38. package/dist/checks/bin/check-issue-milestone-attach.js +1339 -1156
  39. package/dist/checks/bin/check-issue-objectives-numbering.js +2081 -1883
  40. package/dist/checks/bin/check-issue-parts-coverage.js +1339 -1156
  41. package/dist/checks/bin/check-issue-surface-globs.js +1488 -1227
  42. package/dist/checks/bin/check-issue-title-grammar.js +1339 -1156
  43. package/dist/checks/bin/check-issue-tranche-label.js +1339 -1156
  44. package/dist/checks/bin/check-main-branch-refusal.js +1342 -1159
  45. package/dist/checks/bin/check-no-disk-state.js +1342 -1159
  46. package/dist/checks/bin/check-pr-premise-reassert.js +2081 -1883
  47. package/dist/checks/bin/check-pr-report-density.js +1342 -1159
  48. package/dist/checks/bin/check-principal-test-plan-wait.js +1342 -1159
  49. package/dist/checks/bin/check-quoted-command.js +4063 -3526
  50. package/dist/checks/bin/check-reader-resolvable-prose.js +4082 -3533
  51. package/dist/checks/bin/check-registry-gates.js +1363 -1167
  52. package/dist/checks/bin/check-retired-vocabulary.js +4057 -3520
  53. package/dist/checks/bin/check-review-gate.js +2081 -1883
  54. package/dist/checks/bin/check-single-plan-pr.js +1339 -1156
  55. package/dist/checks/bin/check-surface-scope.js +1376 -1139
  56. package/dist/checks/bin/check-test-plan.js +1339 -1156
  57. package/dist/checks/bin/check-token-collection-wired.js +1342 -1159
  58. package/dist/checks/bin/check-token-report.js +1409 -1342
  59. package/dist/checks/bin/check-workspace-escape.js +2562 -2023
  60. package/dist/index.js +14171 -6490
  61. package/dist/lib/pre-push-cache-test-run.js +1044 -641
  62. package/dist/lib/pre-push-select-tests.js +641 -444
  63. package/package.json +2 -2
  64. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +38 -0
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +19 -0
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +257 -10
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +7 -2
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +2 -0
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +69 -11
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +139 -2
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-claim.ts +32 -6
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +27 -1
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +757 -0
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +8 -1
  75. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +52 -4
  76. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +163 -21
  77. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  78. package/studio-standalone/apps/vinaya-studio/web/.next/app-path-routes-manifest.json +0 -1
  79. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  80. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  81. package/studio-standalone/apps/vinaya-studio/web/.next/required-server-files.json +0 -5
  82. package/studio-standalone/apps/vinaya-studio/web/.next/routes-manifest.json +0 -6
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error/page.js +1 -1
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error/page.js.nft.json +1 -1
  85. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  87. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  89. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  90. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  91. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  92. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  95. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js +1 -1
  98. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +3 -3
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  105. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +3 -3
  106. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  107. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  108. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  109. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +3 -3
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  113. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +5 -5
  114. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +3 -3
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +3 -3
  122. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  123. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  124. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  125. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +3 -3
  126. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  127. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  128. package/studio-standalone/apps/vinaya-studio/web/.next/server/app-paths-manifest.json +0 -1
  129. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/044u_vinaya-studio_web_src_app_studio_backlog__components_BacklogTable_tsx_0oha0bt._.js +3 -0
  130. 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
  131. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1bh2awk._.js → [root-of-the-server]__038scsm._.js} +2 -2
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1widio3._.js → [root-of-the-server]__03__s45._.js} +2 -2
  133. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{_15gdg48._.js → [root-of-the-server]__04adkz-._.js} +3 -3
  134. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__05zwn98._.js +14 -0
  135. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +3 -0
  136. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  137. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__10riywf._.js +3 -0
  138. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__13znegp._.js → [root-of-the-server]__134x-65._.js} +2 -2
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__0zc_0gx._.js → [root-of-the-server]__14ui9sz._.js} +2 -2
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__13eeix2._.js → [root-of-the-server]__1_l_l1u._.js} +2 -2
  141. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1f4bb3_._.js +3 -0
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  143. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1dky4g0._.js → [root-of-the-server]__1my83lt._.js} +2 -2
  144. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1ng2x88._.js +3 -0
  145. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__040smoa._.js → [root-of-the-server]__1qpc6at._.js} +2 -2
  146. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1snpgaw._.js +56 -0
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +2 -2
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_06h3wbl._.js +3 -0
  149. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
  150. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  151. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  152. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  153. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0gs4gvl._.js +3 -0
  154. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  155. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  156. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  157. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_121lrn5._.js +3 -0
  158. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  159. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1o4v6lb._.js +3 -0
  160. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1q7h5mz._.js +1 -1
  161. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1ztd4i3._.js +3 -0
  162. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_209-ugd._.js +3 -0
  163. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_214d71c._.js +3 -0
  164. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/apps_vinaya-studio_web_src_app_studio_projects_[name]_tranches_[slug]_17dho0f._.js +3 -0
  165. 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
  166. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_next_dist_1lzmr5o._.js +1 -1
  167. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_animate_components_index_ts_186fje1._.js +1 -1
  168. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_basic_components_index_ts_0xk1vda._.js +1 -1
  169. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  170. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  171. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  172. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  173. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/09fcolor69bun.js +1 -0
  174. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0lcwmwzxacdie.js +1 -0
  175. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ojry7lrbzkfd.css +1 -0
  176. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0vtfb0g813gki.js +1 -0
  177. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1giu47hrbhroj.js +1 -0
  178. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1shz6lwruld25.js +1 -0
  179. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1ytvuy1mmnc6j.js +1 -0
  180. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3oxhhhm_psozq.js → 21a6_5cr956wj.js} +1 -1
  181. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2g8mwnydod96u.js +1 -0
  182. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3li0ueedy-ozv.js → 2nrnuawd5fwpv.js} +1 -1
  183. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2nw47832_uvfe.js +1 -0
  184. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2qdxnj8wk2h0s.js +1 -0
  185. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3b9q75p-z5ma5.js +1 -0
  186. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3cv-oe7153242.js +1 -0
  187. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3ip5z3cf43bgo.js → 3l56x8wjdzvaw.js} +5 -5
  188. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3m310lbjj4p5u.js +1 -0
  189. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3goaig_rysc6p.js → 3qtt1v3ya-ofe.js} +1 -1
  190. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  191. package/studio-standalone/apps/vinaya-studio/web/server.js +1 -1
  192. 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/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/aeg-core/bin/verify-coherence.ts +0 -1089
  193. package/studio-standalone/_node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js +0 -6
  194. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route/app-paths-manifest.json +0 -3
  195. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route/build-manifest.json +0 -9
  196. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route/server-reference-manifest.json +0 -4
  197. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js +0 -6
  198. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.map +0 -5
  199. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +0 -1
  200. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route_client-reference-manifest.js +0 -3
  201. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/044u_vinaya-studio_web__next-internal_server_app_api_coherence_route_actions_1rnzea1.js +0 -3
  202. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[externals]__0cki-x_._.js +0 -3
  203. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +0 -15
  204. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[turbopack]_runtime.js +0 -903
  205. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +0 -3
  206. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ln09ua._.js +0 -3
  207. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0oegopp._.js +0 -3
  208. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__13yxbjd._.js +0 -51
  209. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1duqmtm._.js +0 -3
  210. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1z7dml9._.js +0 -9
  211. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0bfs_u4._.js +0 -3
  212. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0g8_eot._.js +0 -3
  213. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0hrh_v-._.js +0 -181
  214. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0i4-dea._.js +0 -3
  215. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0o54suy._.js +0 -3
  216. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0rxd7s0._.js +0 -3
  217. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0y1jv16._.js +0 -3
  218. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_151m4rz._.js +0 -3
  219. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1a9dieq._.js +0 -3
  220. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1sxsf5q._.js +0 -3
  221. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1sy_yfr._.js +0 -3
  222. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_219v2an._.js +0 -3
  223. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/apps_vinaya-studio_web_src_app_studio_projects_[name]_tranches_[slug]_05ufo8i._.js +0 -3
  224. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_basic_components_form_input_tsx_0es8d8b._.js +0 -3
  225. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_brutal_components_index_ts_0n_lcc4._.js +0 -3
  226. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_retro_components_index_ts_0wvpm_z._.js +0 -3
  227. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bjnj-5fy4e7l.js +0 -1
  228. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0c8uwz_-m8s99.js +0 -165
  229. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ct0c-xj0baf6.js +0 -1
  230. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ko698wh8xx2g.css +0 -1
  231. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0t5n_r4xm__t-.js +0 -1
  232. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0vc2u252q5q6o.js +0 -1
  233. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/16r_o07lw0vm0.js +0 -1
  234. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1cah7_e5a1zvu.js +0 -1
  235. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1gjo9-6dz7nup.js +0 -1
  236. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/24tz8aro1uto4.js +0 -1
  237. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2ef2g5fozszw7.js +0 -1
  238. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2ka8dg687auhj.js +0 -1
  239. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2pf3f50gbrkyv.js +0 -1
  240. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2qq49pct3q51-.js +0 -1
  241. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3et66z7glk65w.js +0 -1
  242. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3u9emqjwpd0t9.js +0 -1
  243. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3y6u3prmrkea-.js +0 -1
  244. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{ca66rAHI_w9D7S7ceXDvR → yR5RsCxb1OGnYggiaO09S}/_buildManifest.js +0 -0
  245. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{ca66rAHI_w9D7S7ceXDvR → yR5RsCxb1OGnYggiaO09S}/_clientMiddlewareManifest.js +0 -0
  246. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{ca66rAHI_w9D7S7ceXDvR → yR5RsCxb1OGnYggiaO09S}/_ssgManifest.js +0 -0
@@ -2,7 +2,8 @@
2
2
 
3
3
  // src/checks/bin/check-registry-gates.ts
4
4
  import { execSync, execFileSync as execFileSync2 } from "node:child_process";
5
- import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync2, statSync } from "node:fs";
5
+ import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2, statSync } from "node:fs";
6
+ import { join as join3 } from "node:path";
6
7
  import matter2 from "gray-matter";
7
8
  // ../../packages/aeg-core/src/gate-audience.ts
8
9
  var GATE_AUDIENCE = {
@@ -1887,45 +1888,6 @@ var DERIVED_STATUSES = [
1887
1888
  "incoherent"
1888
1889
  ];
1889
1890
  var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
1890
- // ../../packages/aeg-core/src/parse-ledger.ts
1891
- function rowFromCells(cells) {
1892
- if (cells.length < 7)
1893
- return null;
1894
- const phase = (cells[0] ?? "").trim();
1895
- if (!phase)
1896
- return null;
1897
- return {
1898
- phase,
1899
- role: (cells[1] ?? "").trim(),
1900
- agentModel: (cells[2] ?? "").trim(),
1901
- tokensIn: parseIntCell(cells[3] ?? ""),
1902
- tokensOut: parseIntCell(cells[4] ?? ""),
1903
- cost: parseCostCell(cells[5] ?? ""),
1904
- date: (cells[6] ?? "").trim()
1905
- };
1906
- }
1907
- function parseIntCell(cell) {
1908
- const trimmed = cell.replace(/`/g, "").trim();
1909
- if (!trimmed || isEmDashOrDash(trimmed))
1910
- return null;
1911
- const normalized = trimmed.replace(/[,_\s]/g, "");
1912
- if (!/^-?\d+$/.test(normalized))
1913
- return null;
1914
- return Number(normalized);
1915
- }
1916
- function parseCostCell(cell) {
1917
- const trimmed = cell.replace(/`/g, "").trim();
1918
- if (!trimmed || isEmDashOrDash(trimmed))
1919
- return null;
1920
- const normalized = trimmed.replace(/^\$/, "").replace(/[,_\s]/g, "");
1921
- if (!/^-?\d+(\.\d+)?$/.test(normalized))
1922
- return null;
1923
- return Number(normalized);
1924
- }
1925
- function isEmDashOrDash(s) {
1926
- const t = s.trim();
1927
- return t === "—" || t === "-" || t === "–";
1928
- }
1929
1891
  // ../../packages/aeg-core/src/waiver-label.ts
1930
1892
  var WAIVER_LABEL = label("waiver-docs");
1931
1893
  var WAIVER_LABEL_REVIEW = label("waiver-review");
@@ -1941,61 +1903,6 @@ function isWaiverLabelActorVerified(opts) {
1941
1903
  return false;
1942
1904
  return isPrincipal(opts.labelActor, opts.principalAllowlist);
1943
1905
  }
1944
-
1945
- // ../../packages/aeg-core/src/parse-token-report.ts
1946
- var TOKEN_REPORT_HEADING = /^\s*(?:#{1,6}\s*Token report\s*|\*\*Token report\*\*)\s*$/i;
1947
- var INLINE_FIELD_LIST = /Phase:\s*([^|]+?)\s*\|\s*Role:\s*([^|]+?)\s*\|\s*Agent\/Model:\s*([^|]+?)\s*\|\s*Tokens in:\s*([^|]+?)\s*\|\s*Tokens out:\s*([^|]+?)\s*\|\s*Cost:\s*([^|]+?)\s*\|\s*Date:\s*(.+?)\s*$/im;
1948
- function parseTokenReportEntries(body) {
1949
- const lines = body.split(/\r?\n/);
1950
- const headingIdxs = [];
1951
- lines.forEach((line, i) => {
1952
- if (TOKEN_REPORT_HEADING.test(line))
1953
- headingIdxs.push(i);
1954
- });
1955
- const out = [];
1956
- for (let h = 0;h < headingIdxs.length; h++) {
1957
- const start = headingIdxs[h] + 1;
1958
- const end = h + 1 < headingIdxs.length ? headingIdxs[h + 1] : lines.length;
1959
- const section = lines.slice(start, end).join(`
1960
- `);
1961
- const tableRows = parseTableSection(section);
1962
- if (tableRows.length > 0) {
1963
- out.push(...tableRows);
1964
- continue;
1965
- }
1966
- const inlineRow = parseInlineFieldList(section);
1967
- if (inlineRow)
1968
- out.push(inlineRow);
1969
- }
1970
- return out;
1971
- }
1972
- function parseTableSection(section) {
1973
- const lines = section.split(/\r?\n/);
1974
- let i = 0;
1975
- for (;i < lines.length; i++) {
1976
- if ((lines[i] ?? "").trim().startsWith("|"))
1977
- break;
1978
- }
1979
- if (i + 1 >= lines.length)
1980
- return [];
1981
- i += 2;
1982
- const out = [];
1983
- for (;i < lines.length; i++) {
1984
- const trimmed = (lines[i] ?? "").trim();
1985
- if (!trimmed.startsWith("|"))
1986
- break;
1987
- const row = rowFromCells(splitTableRow(trimmed));
1988
- if (row)
1989
- out.push(row);
1990
- }
1991
- return out;
1992
- }
1993
- function parseInlineFieldList(section) {
1994
- const m = section.match(INLINE_FIELD_LIST);
1995
- if (!m)
1996
- return null;
1997
- return rowFromCells([m[1], m[2], m[3], m[4], m[5], m[6], m[7]]);
1998
- }
1999
1906
  // ../../packages/aeg-core/src/verdict-extraction.ts
2000
1907
  var HEAD_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged head:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
2001
1908
  var OBJECTIVES_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Objectives version:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
@@ -2444,10 +2351,12 @@ function evaluateC5(changed, docOwnersContent, prBody, fileExists, waiverActive,
2444
2351
  var CODE_REVIEW_SEVERITY_ORDER = ["BLOCKER", "MAJOR", "MINOR"];
2445
2352
  var SECURITY_SEVERITY_ORDER = ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
2446
2353
  var DEFAULT_MAX_ROUNDS = 3;
2354
+ var DEFAULT_MAX_TASK_MINUTES = 180;
2447
2355
  var DEFAULT_REVIEW_POLICY = {
2448
2356
  codeReviewThreshold: "BLOCKER",
2449
2357
  securityThreshold: "HIGH",
2450
- maxRounds: DEFAULT_MAX_ROUNDS
2358
+ maxRounds: DEFAULT_MAX_ROUNDS,
2359
+ maxTaskMinutes: DEFAULT_MAX_TASK_MINUTES
2451
2360
  };
2452
2361
  var FILE_SHAPED_LOCATION = /\.[a-zA-Z0-9]{1,10}(:\d+)?\s*$/;
2453
2362
  var PROSE_LOCATION_PATTERNS = [/\bpr\s*body\b/i, /\bcomment\b/i];
@@ -2467,16 +2376,42 @@ function blockingSeverities(scale, threshold) {
2467
2376
  }
2468
2377
  return scale.slice(0, idx + 1);
2469
2378
  }
2470
- function evaluateReviewFindings(findings, scale, threshold) {
2471
- const blocking = new Set(blockingSeverities(scale, threshold));
2472
- const blockingFindings = findings.filter((f) => {
2473
- if (!scale.includes(f.severity)) {
2474
- throw new Error(`evaluateReviewFindings: severity "${f.severity}" is not one of ${scale.join(" > ")}`);
2475
- }
2476
- const effectiveSeverity = f.location !== undefined && isProseLocation(f.location) ? PROSE_CAP_SEVERITY : f.severity;
2477
- return blocking.has(effectiveSeverity);
2478
- });
2479
- return { outcome: blockingFindings.length > 0 ? "blocked" : "clean", blockingFindings };
2379
+ var DEFERRAL_REASON_TEXT = {
2380
+ "unchanged-line": "unchanged line",
2381
+ "outside-surface": "outside the Surface"
2382
+ };
2383
+ var SECURITY_HIGH_AND_ABOVE = blockingSeverities(SECURITY_SEVERITY_ORDER, "HIGH");
2384
+ function classifyFinding(finding, scale, threshold, context = {}) {
2385
+ if (!scale.includes(finding.severity)) {
2386
+ throw new Error(`classifyFinding: severity "${finding.severity}" is not one of ${scale.join(" > ")}`);
2387
+ }
2388
+ const location = finding.location;
2389
+ const effectiveSeverity = location !== undefined && isProseLocation(location) ? PROSE_CAP_SEVERITY : finding.severity;
2390
+ const wouldBlock = blockingSeverities(scale, threshold).includes(effectiveSeverity);
2391
+ if (!wouldBlock)
2392
+ return { outcome: "non_blocking", deferralReason: null };
2393
+ const hasLocation = location !== undefined && location.length > 0;
2394
+ if (hasLocation && context.inSurface && !context.inSurface(location)) {
2395
+ return { outcome: "deferred", deferralReason: "outside-surface" };
2396
+ }
2397
+ if (hasLocation && context.changedLine && !SECURITY_HIGH_AND_ABOVE.includes(effectiveSeverity)) {
2398
+ if (!context.changedLine(location)) {
2399
+ return { outcome: "deferred", deferralReason: "unchanged-line" };
2400
+ }
2401
+ }
2402
+ return { outcome: "blocking", deferralReason: null };
2403
+ }
2404
+ function evaluateReviewFindings(findings, scale, threshold, context = {}) {
2405
+ const blockingFindings = [];
2406
+ const deferredFindings = [];
2407
+ for (const f of findings) {
2408
+ const c = classifyFinding(f, scale, threshold, context);
2409
+ if (c.outcome === "blocking")
2410
+ blockingFindings.push(f);
2411
+ else if (c.outcome === "deferred")
2412
+ deferredFindings.push({ finding: f, reason: c.deferralReason });
2413
+ }
2414
+ return { outcome: blockingFindings.length > 0 ? "blocked" : "clean", blockingFindings, deferredFindings };
2480
2415
  }
2481
2416
  function isConsequentialFinding(finding) {
2482
2417
  return finding.state !== "resolved";
@@ -2484,11 +2419,11 @@ function isConsequentialFinding(finding) {
2484
2419
  function consequentialFindings(findings) {
2485
2420
  return findings.filter((f) => isConsequentialFinding(f));
2486
2421
  }
2487
- function evaluateCodeReview(findings, policy) {
2488
- return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold);
2422
+ function evaluateCodeReview(findings, policy, context = {}) {
2423
+ return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold, context);
2489
2424
  }
2490
- function evaluateSecurityReview(findings, policy) {
2491
- return evaluateReviewFindings(findings, SECURITY_SEVERITY_ORDER, policy.securityThreshold);
2425
+ function evaluateSecurityReview(findings, policy, context = {}) {
2426
+ return evaluateReviewFindings(findings, SECURITY_SEVERITY_ORDER, policy.securityThreshold, context);
2492
2427
  }
2493
2428
  function isKnownSeverity(scale, value) {
2494
2429
  return scale.includes(value);
@@ -2822,11 +2757,13 @@ function checkDocUpdateList(prBody) {
2822
2757
  return headingCheck(prBody, "(?:documentation|doc)[- ]update(?:\\s+list)?", "Documentation-update list");
2823
2758
  }
2824
2759
  function checkWorktreeStep0(prBody) {
2825
- if (/git worktree add/.test(prBody))
2760
+ if (/git worktree add/.test(prBody) || /cd \.worktrees\//.test(prBody) || /bun install --frozen-lockfile/.test(prBody))
2826
2761
  return { status: "pass", errors: [] };
2827
2762
  return {
2828
2763
  status: "fail",
2829
- errors: ["brief-validation worktree Step 0: no `git worktree add` command found in the PR body."]
2764
+ errors: [
2765
+ "brief-validation worktree Step 0: no `git worktree add`, `cd .worktrees/`, or `bun install --frozen-lockfile` command found in the PR body."
2766
+ ]
2830
2767
  };
2831
2768
  }
2832
2769
  function checkStopConditions(prBody) {
@@ -3016,7 +2953,8 @@ function isCommandBlock(content) {
3016
2953
  return COMMAND_WORDS.includes(commandWordOf(firstNonBlankLine(content)));
3017
2954
  }
3018
2955
  function isStep0Block(content) {
3019
- return firstNonBlankLine(content).startsWith("git worktree add");
2956
+ const first = firstNonBlankLine(content);
2957
+ return first.startsWith("git worktree add") || first.startsWith("cd .worktrees/") || first.startsWith("bun install --frozen-lockfile");
3020
2958
  }
3021
2959
  function checkCommandsCarryOutput(prBody) {
3022
2960
  const errors = [];
@@ -3402,161 +3340,592 @@ function checkPrReportDensity(prBody) {
3402
3340
  const results = [checkDecisionsDensity(prBody), checkScopeDensity(prBody)];
3403
3341
  return { errors: results.flatMap((r) => r.errors) };
3404
3342
  }
3405
- // ../../packages/aeg-core/src/issue-validation.ts
3406
- function hasRationaleField(body, labelPattern) {
3407
- const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})`, "im");
3408
- return re.test(body);
3409
- }
3410
- var RATIONALE_FIELDS = [
3411
- { name: "Boundary", pattern: "Boundary" },
3412
- { name: "Sizing", pattern: "Sizing" },
3413
- { name: "Project(s) + blast radius", pattern: "Project\\(s\\)|Project(?:s)?\\s*\\+|blast radius" },
3414
- { name: "Dependency rationale", pattern: "Dependency rationale|Depends[- ]on" },
3415
- { name: "Traps to avoid", pattern: "Traps" },
3416
- { name: "Suggested agent-class", pattern: "(?:Suggested\\s+)?agent-class" },
3417
- { name: "Stop-and-escalate", pattern: "Stop-and-escalate" },
3418
- { name: "Docs to keep coherent", pattern: "Docs to keep coherent|§7" }
3343
+ // ../../packages/aeg-core/src/reader-resolvable-prose.ts
3344
+ var PRODUCT_SLUG_SCOPE = [
3345
+ "apps/cli/src",
3346
+ ".github/workflows",
3347
+ ".vinaya",
3348
+ "apps/cli/README.md",
3349
+ "packages/sources/README.md"
3419
3350
  ];
3420
- var DEPENDENCY_RATIONALE_FIELD_NAME = "Dependency rationale";
3421
- function checkIssueRationale(body) {
3422
- const errors = [];
3423
- for (const f of RATIONALE_FIELDS) {
3424
- if (!hasRationaleField(body, f.pattern)) {
3425
- errors.push(`issue-validation ${f.name}: rationale field not found in the Issue body — every task Issue carries the full Planner's rationale (aeg-root/contracts/planner-brief.md).`);
3426
- continue;
3427
- }
3428
- if (f.name === DEPENDENCY_RATIONALE_FIELD_NAME && !SECTION_HEADER.test(body)) {
3429
- errors.push(`issue-validation ${f.name}: rationale field found, but not in the form amend-deps requires — ` + "write `**Dependency rationale** — …`, not `**Dependency rationale:** …`. " + "`amendRationaleDeps` (the only sanctioned way to edit Depends-on/Conflicts-with) locates this " + "section by the exact anchor `**Dependency rationale**`; a colon inside the bold breaks that match " + "and the Issue becomes unamendable.");
3430
- }
3431
- }
3432
- return { status: errors.length > 0 ? "fail" : "pass", errors };
3433
- }
3434
- var OBJECTIVES_SINCE_ISSUE = 404;
3435
- function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
3436
- if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
3437
- return { status: "pass", errors: [] };
3438
- const result = objectivesOf(body);
3439
- if (result.ok)
3440
- return { status: "pass", errors: [] };
3441
- return { status: "fail", errors: result.errors.map((e) => `issue-validation objectives: ${e}`) };
3351
+ function isUnderOrEqual(path, prefix) {
3352
+ return path === prefix || path.startsWith(`${prefix}/`);
3442
3353
  }
3443
- function topLevelSectionText(body, headingName) {
3444
- const headingRe = new RegExp(`^##[ \\t]*${headingName}[ \\t]*$`, "im");
3445
- const heading = headingRe.exec(body);
3446
- if (!heading)
3447
- return null;
3448
- const afterHeading = body.slice(heading.index + heading[0].length);
3449
- const next = /^##[ \t]/m.exec(afterHeading);
3450
- return next ? afterHeading.slice(0, next.index) : afterHeading;
3354
+ function isProductScopeFile(path) {
3355
+ return PRODUCT_SLUG_SCOPE.some((prefix) => isUnderOrEqual(path, prefix));
3451
3356
  }
3452
- function partHasBacktickedPath(text) {
3453
- let i = 0;
3454
- while (i < text.length) {
3455
- const start = text.indexOf("`", i);
3456
- if (start === -1)
3457
- return false;
3458
- const end = text.indexOf("`", start + 1);
3459
- if (end === -1)
3460
- return false;
3461
- if (text.slice(start + 1, end).includes("/"))
3462
- return true;
3463
- i = end + 1;
3464
- }
3465
- return false;
3357
+ var SHIPS_PREFIX = "aeg-root/";
3358
+ function shipsArchivePrefix(shipsPrefix) {
3359
+ return `${shipsPrefix}tranches/completed/`;
3466
3360
  }
3467
- var PART_MIN_WORDS_OUTSIDE_BACKTICKS = 3;
3468
- function stripPartBackticks(text) {
3469
- return text.replace(/`[^`\n]*`/g, " ");
3361
+ var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
3362
+ function normalizeSpecPath(entry) {
3363
+ let out = entry.replace(/\\/g, "/");
3364
+ while (out.startsWith("./"))
3365
+ out = out.slice(2);
3366
+ out = out.replace(/\/{2,}/g, "/");
3367
+ while (out.endsWith("/"))
3368
+ out = out.slice(0, -1);
3369
+ return out;
3470
3370
  }
3471
- function partWordCount(text) {
3472
- return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
3371
+ function isSpecFile2(path, specPaths) {
3372
+ if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
3373
+ return true;
3374
+ if (!path.endsWith(".md"))
3375
+ return false;
3376
+ return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
3473
3377
  }
3474
- function looksLikeFilePath(entry) {
3475
- const stripped = entry.replace(/\/\*\*?$/, "");
3476
- const lastSegment = stripped.split("/").pop() ?? stripped;
3477
- const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
3478
- return extMatch !== null && extMatch.index > 0;
3378
+ function isClaudeMdFile(path) {
3379
+ return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
3479
3380
  }
3480
- function splitGlobList(raw) {
3481
- return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
3381
+ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
3382
+ if (path.startsWith(shipsPrefix)) {
3383
+ return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
3384
+ }
3385
+ if (path.startsWith(readerFacingPrefix) && path.endsWith(readerFacingSuffix)) {
3386
+ return "reader-facing";
3387
+ }
3388
+ if (isClaudeMdFile(path))
3389
+ return "internal";
3390
+ if (isSpecFile2(path, specPaths))
3391
+ return "spec";
3392
+ if (isProductScopeFile(path))
3393
+ return "product";
3394
+ return null;
3482
3395
  }
3483
- function parseIssueSurface(body) {
3484
- const section = topLevelSectionText(body, "Surface");
3485
- if (section === null)
3486
- return { ok: false, errors: ["no `## Surface` heading found in the body."] };
3487
- const inLine = /^in:\s*(.+)$/im.exec(section);
3488
- const outLine = /^out:\s*(.+)$/im.exec(section);
3489
- const errors = [];
3490
- if (!inLine)
3491
- errors.push("`## Surface` has no `in:` line.");
3492
- if (!outLine)
3493
- errors.push("`## Surface` has no `out:` line.");
3494
- if (errors.length > 0)
3495
- return { ok: false, errors };
3496
- const inGlobs = splitGlobList(inLine[1]);
3497
- const outGlobs = splitGlobList(outLine[1]);
3498
- for (const g of [...inGlobs, ...outGlobs]) {
3499
- if (looksLikeFilePath(g)) {
3500
- errors.push(`\`${g}\` in \`## Surface\` looks like a file path — Surface entries are directory-level globs, never file paths.`);
3501
- }
3396
+ var SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
3397
+ function stripNonProse(path, content) {
3398
+ if (path.endsWith(".md")) {
3399
+ return content.replace(/```.*?```/gs, (m) => m.replace(/[^\n]/g, "")).replace(/`[^`\n]*`/g, (m) => m.replace(/[^\n]/g, ""));
3502
3400
  }
3503
- if (inGlobs.length === 0)
3504
- errors.push("`## Surface`'s `in:` line resolved to zero globs.");
3505
- if (errors.length > 0)
3506
- return { ok: false, errors };
3507
- return { ok: true, value: { in: inGlobs, out: outGlobs } };
3401
+ if (path.endsWith(".tsx") || path.endsWith(".ts")) {
3402
+ return content.replace(/\/\*.*?\*\//gs, (m) => m.replace(/[^\n]/g, "")).replace(/(^|[^:])\/\/[^\n]*/g, (m) => m.replace(/[^\n]/g, ""));
3403
+ }
3404
+ return content;
3508
3405
  }
3509
- function globCoversPath(glob, path) {
3510
- const g = glob.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
3511
- const p = path.replace(/\/+$/, "");
3512
- if (g === "*")
3513
- return !p.includes("/");
3514
- return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
3406
+ function stripNonProseForProduct(path, content) {
3407
+ return path.endsWith(".md") ? stripNonProse(path, content) : content;
3515
3408
  }
3516
- function checkSurfaceGlobsResolve(body, resolvesToFile) {
3517
- const surface = parseIssueSurface(body);
3518
- if (!surface.ok)
3519
- return { status: "pass", errors: [] };
3520
- const errors = [];
3521
- for (const glob of surface.value.in) {
3522
- if (!resolvesToFile(glob)) {
3523
- errors.push(`issue-validation Surface: \`${glob}\` in \`## Surface\`'s \`in:\` list matches no tracked file — a Surface that cannot resolve cannot render a brief's file list.`);
3524
- }
3409
+ function lineAt(content, index) {
3410
+ let line = 1;
3411
+ for (let i = 0;i < index; i++) {
3412
+ if (content.charCodeAt(i) === 10)
3413
+ line++;
3525
3414
  }
3526
- return { status: errors.length > 0 ? "fail" : "pass", errors };
3415
+ return line;
3527
3416
  }
3528
- function checkSurfaceScope(changedFiles, outGlobs) {
3529
- if (outGlobs.length === 0)
3530
- return { ok: true };
3531
- const violations = [];
3532
- for (const file of changedFiles) {
3533
- const glob = outGlobs.find((g) => globCoversPath(g, file));
3534
- if (glob)
3535
- violations.push({ file, glob });
3536
- }
3537
- return violations.length > 0 ? { ok: false, violations } : { ok: true };
3417
+ var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
3418
+ var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
3419
+ var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
3420
+ function legacySlugPattern(legacySlugs) {
3421
+ if (legacySlugs.length === 0)
3422
+ return null;
3423
+ const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
3424
+ return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
3538
3425
  }
3539
- var ISSUE_PART_LINE_RE = /^Part\s+(\d+)\s*\(([^)]*)\)\s*[-—–]\s*(.*)$/i;
3540
- function parseIssueParts(body) {
3541
- const section = topLevelSectionText(body, "Parts");
3542
- if (section === null)
3543
- return { ok: false, errors: ["no `## Parts` heading found in the body."] };
3544
- const lines = section.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0);
3545
- const parts = [];
3546
- const errors = [];
3547
- for (const line of lines) {
3548
- const m = ISSUE_PART_LINE_RE.exec(line);
3549
- if (!m) {
3550
- errors.push(`"${line}" is not a well-formed Parts line — expected \`Part <n> (<refs>) — <outcome>\`.`);
3551
- continue;
3552
- }
3553
- const n = Number.parseInt(m[1], 10);
3554
- const refs = m[2];
3555
- const text = m[3].trim();
3556
- if (text.length === 0) {
3557
- errors.push(`Part ${n} has no outcome text after the dash — every Part states one observable outcome.`);
3558
- continue;
3559
- }
3426
+ function specGrandfatherPaths(specGrandfather) {
3427
+ return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
3428
+ }
3429
+ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
3430
+ const findings = [];
3431
+ const legacyPattern = legacySlugPattern(legacySlugs);
3432
+ const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
3433
+ const limits = new Map(Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather));
3434
+ const patterns = [
3435
+ { pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
3436
+ { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
3437
+ ...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
3438
+ ];
3439
+ const productPatterns = [
3440
+ { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
3441
+ ];
3442
+ const specPatterns = [
3443
+ ...patterns,
3444
+ { pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
3445
+ ];
3446
+ for (const file of files) {
3447
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
3448
+ if (!cls || cls === "internal")
3449
+ continue;
3450
+ if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
3451
+ continue;
3452
+ if (cls === "spec" && grandfatheredWhole.has(file.path))
3453
+ continue;
3454
+ const blocking = cls === "product" || cls === "spec";
3455
+ const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
3456
+ const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
3457
+ const fileFindings = [];
3458
+ for (const { pattern, what, group } of patternsToRun) {
3459
+ pattern.lastIndex = 0;
3460
+ let match = pattern.exec(scrubbed);
3461
+ while (match !== null) {
3462
+ const cited = group !== undefined ? match[group] ?? match[0] : match[0];
3463
+ const citedIndex = match.index + match[0].indexOf(cited);
3464
+ fileFindings.push({
3465
+ file: file.path,
3466
+ line: lineAt(scrubbed, citedIndex),
3467
+ message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
3468
+ blocking
3469
+ });
3470
+ match = pattern.exec(scrubbed);
3471
+ }
3472
+ }
3473
+ const limit = cls === "spec" ? limits.get(file.path) : undefined;
3474
+ if (limit !== undefined) {
3475
+ if (fileFindings.length <= limit)
3476
+ continue;
3477
+ for (const f of fileFindings) {
3478
+ f.message += `; ${file.path} carries ${fileFindings.length} such findings, over its proseGates.specGrandfather limit of ${limit}`;
3479
+ }
3480
+ }
3481
+ findings.push(...fileFindings);
3482
+ }
3483
+ return findings;
3484
+ }
3485
+ function escapeTerm(term) {
3486
+ return term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3487
+ }
3488
+ function containsWholeWord(text, term) {
3489
+ const escaped = escapeTerm(term);
3490
+ const re = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)`, "i");
3491
+ return re.test(text);
3492
+ }
3493
+ function findWholeWordLine(content, term) {
3494
+ const lines = content.split(`
3495
+ `);
3496
+ let lineNo = 0;
3497
+ for (const line of lines) {
3498
+ lineNo++;
3499
+ if (containsWholeWord(line, term))
3500
+ return lineNo;
3501
+ }
3502
+ return null;
3503
+ }
3504
+ function definesOrLinksGlossary(content, term) {
3505
+ const escaped = escapeTerm(term);
3506
+ const definesInline = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)[^\\n]{0,3}—`, "i").test(content);
3507
+ if (definesInline)
3508
+ return true;
3509
+ return /docs\/glossary|glossary\.md/i.test(content);
3510
+ }
3511
+ function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
3512
+ const findings = [];
3513
+ for (const file of files) {
3514
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
3515
+ if (!cls || !SWEPT_CLASSES.has(cls))
3516
+ continue;
3517
+ const scrubbed = stripNonProse(file.path, file.content);
3518
+ for (const term of glossaryTerms) {
3519
+ const line = findWholeWordLine(scrubbed, term);
3520
+ if (line === null)
3521
+ continue;
3522
+ if (definesOrLinksGlossary(scrubbed, term))
3523
+ continue;
3524
+ findings.push({
3525
+ file: file.path,
3526
+ line,
3527
+ message: `uses coined term "${term}" without defining it inline or linking the glossary`,
3528
+ blocking: false
3529
+ });
3530
+ }
3531
+ }
3532
+ return findings;
3533
+ }
3534
+ var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g;
3535
+ var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = /#[0-9]{2,}/g;
3536
+ function extractComments(path, content) {
3537
+ if (!path.endsWith(".ts") && !path.endsWith(".tsx"))
3538
+ return content.replace(/[^\n]/g, "");
3539
+ let state = "code";
3540
+ let out = "";
3541
+ const n = content.length;
3542
+ let i = 0;
3543
+ const blank = (ch) => ch === `
3544
+ ` ? `
3545
+ ` : " ";
3546
+ while (i < n) {
3547
+ const c = content[i];
3548
+ const next = i + 1 < n ? content[i + 1] : "";
3549
+ if (state === "code") {
3550
+ if (c === "/" && next === "/") {
3551
+ state = "line-comment";
3552
+ out += c;
3553
+ i++;
3554
+ continue;
3555
+ }
3556
+ if (c === "/" && next === "*") {
3557
+ state = "block-comment";
3558
+ out += c;
3559
+ i++;
3560
+ continue;
3561
+ }
3562
+ if (c === "'") {
3563
+ state = "single-quote";
3564
+ out += blank(c);
3565
+ i++;
3566
+ continue;
3567
+ }
3568
+ if (c === '"') {
3569
+ state = "double-quote";
3570
+ out += blank(c);
3571
+ i++;
3572
+ continue;
3573
+ }
3574
+ if (c === "`") {
3575
+ state = "template";
3576
+ out += blank(c);
3577
+ i++;
3578
+ continue;
3579
+ }
3580
+ out += blank(c);
3581
+ i++;
3582
+ continue;
3583
+ }
3584
+ if (state === "line-comment") {
3585
+ if (c === `
3586
+ `) {
3587
+ state = "code";
3588
+ out += `
3589
+ `;
3590
+ i++;
3591
+ continue;
3592
+ }
3593
+ out += c;
3594
+ i++;
3595
+ continue;
3596
+ }
3597
+ if (state === "block-comment") {
3598
+ if (c === "*" && next === "/") {
3599
+ out += c;
3600
+ out += next;
3601
+ state = "code";
3602
+ i += 2;
3603
+ continue;
3604
+ }
3605
+ out += c === `
3606
+ ` ? `
3607
+ ` : c;
3608
+ i++;
3609
+ continue;
3610
+ }
3611
+ const closer = state === "single-quote" ? "'" : state === "double-quote" ? '"' : "`";
3612
+ if (c === "\\") {
3613
+ out += blank(c);
3614
+ i++;
3615
+ if (i < n) {
3616
+ out += blank(content[i]);
3617
+ i++;
3618
+ }
3619
+ continue;
3620
+ }
3621
+ if (c === closer) {
3622
+ state = "code";
3623
+ out += blank(c);
3624
+ i++;
3625
+ continue;
3626
+ }
3627
+ out += blank(c);
3628
+ i++;
3629
+ }
3630
+ return out;
3631
+ }
3632
+ function checkSourceComments(files, allowlist = []) {
3633
+ const findings = [];
3634
+ const allowed = new Set(allowlist);
3635
+ const patterns = [
3636
+ { pattern: SOURCE_COMMENT_TRANCHE_SLUG_PATTERN, what: "a tranche-slug citation" },
3637
+ { pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
3638
+ ];
3639
+ for (const file of files) {
3640
+ if (!file.path.endsWith(".ts"))
3641
+ continue;
3642
+ if (allowed.has(file.path))
3643
+ continue;
3644
+ const comments = extractComments(file.path, file.content);
3645
+ for (const { pattern, what } of patterns) {
3646
+ pattern.lastIndex = 0;
3647
+ let match = pattern.exec(comments);
3648
+ while (match !== null) {
3649
+ findings.push({
3650
+ file: file.path,
3651
+ line: lineAt(comments, match.index),
3652
+ message: `comment cites ${what} ("${match[0]}") a reader outside this repo's tracker cannot resolve`,
3653
+ blocking: false
3654
+ });
3655
+ match = pattern.exec(comments);
3656
+ }
3657
+ }
3658
+ }
3659
+ return findings;
3660
+ }
3661
+ function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
3662
+ return [
3663
+ ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
3664
+ ...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
3665
+ ];
3666
+ }
3667
+ function parseGlossaryTerms(glossaryContent) {
3668
+ const terms = [];
3669
+ const re = /^\*\*(.+?)\*\* —/gm;
3670
+ let match = re.exec(glossaryContent);
3671
+ while (match !== null) {
3672
+ if (match[1] !== undefined)
3673
+ terms.push(match[1]);
3674
+ match = re.exec(glossaryContent);
3675
+ }
3676
+ return terms;
3677
+ }
3678
+
3679
+ // ../../packages/aeg-core/src/quoted-command.ts
3680
+ var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
3681
+ var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
3682
+ var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
3683
+ var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
3684
+ function isValidCitedFilePath(path) {
3685
+ if (path.length === 0)
3686
+ return false;
3687
+ if (path.startsWith("/") || path.startsWith("\\"))
3688
+ return false;
3689
+ if (/^[A-Za-z]:[\\/]/.test(path))
3690
+ return false;
3691
+ return !path.split(/[\\/]+/).includes("..");
3692
+ }
3693
+ function quotedCommandLineAt(content, index) {
3694
+ let line = 1;
3695
+ for (let i = 0;i < index; i++) {
3696
+ if (content.charCodeAt(i) === 10)
3697
+ line++;
3698
+ }
3699
+ return line;
3700
+ }
3701
+ function extractQuotedText(raw) {
3702
+ const trimmed = raw.trim();
3703
+ const fenced = /^(?:`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?(?:`{3,}|~{3,})$/.exec(trimmed);
3704
+ if (fenced)
3705
+ return (fenced[1] ?? "").trim();
3706
+ const inline = /^`([^`]+)`$/.exec(trimmed);
3707
+ if (inline)
3708
+ return (inline[1] ?? "").trim();
3709
+ return trimmed;
3710
+ }
3711
+ function findQuotesInFile(path, content) {
3712
+ const masked = maskCode(content);
3713
+ const quotes = [];
3714
+ START_PATTERN.lastIndex = 0;
3715
+ let start = START_PATTERN.exec(masked);
3716
+ while (start !== null) {
3717
+ const citedFile = start[1];
3718
+ const innerStart = start.index + start[0].length;
3719
+ const end = END_PATTERN.exec(masked.slice(innerStart));
3720
+ if (end === null) {
3721
+ START_PATTERN.lastIndex = innerStart;
3722
+ start = START_PATTERN.exec(masked);
3723
+ continue;
3724
+ }
3725
+ const innerEnd = innerStart + end.index;
3726
+ if (isValidCitedFilePath(citedFile)) {
3727
+ const quotedText = extractQuotedText(content.slice(innerStart, innerEnd));
3728
+ if (quotedText.length > 0) {
3729
+ quotes.push({ file: path, line: quotedCommandLineAt(content, innerStart), quotedText, citedFile });
3730
+ }
3731
+ }
3732
+ START_PATTERN.lastIndex = innerEnd + end[0].length;
3733
+ start = START_PATTERN.exec(masked);
3734
+ }
3735
+ return quotes;
3736
+ }
3737
+ function findCitedQuotes(files, readerFacingPrefix, readerFacingSuffix, shipsPrefix = QUOTED_COMMAND_SHIPS_PREFIX) {
3738
+ const quotes = [];
3739
+ for (const file of files) {
3740
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
3741
+ if (!cls || !QUOTED_COMMAND_SWEPT_CLASSES.has(cls))
3742
+ continue;
3743
+ quotes.push(...findQuotesInFile(file.path, file.content));
3744
+ }
3745
+ return quotes;
3746
+ }
3747
+ function evaluateCitedQuotes(citedQuotes, citedFileContents) {
3748
+ const findings = [];
3749
+ for (const quote of citedQuotes) {
3750
+ const content = citedFileContents.get(quote.citedFile);
3751
+ if (content === undefined) {
3752
+ findings.push({
3753
+ file: quote.file,
3754
+ line: quote.line,
3755
+ citedFile: quote.citedFile,
3756
+ quotedText: quote.quotedText,
3757
+ message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
3758
+ });
3759
+ continue;
3760
+ }
3761
+ if (!content.includes(quote.quotedText)) {
3762
+ findings.push({
3763
+ file: quote.file,
3764
+ line: quote.line,
3765
+ citedFile: quote.citedFile,
3766
+ quotedText: quote.quotedText,
3767
+ message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
3768
+ });
3769
+ }
3770
+ }
3771
+ return findings;
3772
+ }
3773
+
3774
+ // ../../packages/aeg-core/src/issue-validation.ts
3775
+ function hasRationaleField(body, labelPattern) {
3776
+ const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})`, "im");
3777
+ return re.test(body);
3778
+ }
3779
+ var RATIONALE_FIELDS = [
3780
+ { name: "Boundary", pattern: "Boundary" },
3781
+ { name: "Sizing", pattern: "Sizing" },
3782
+ { name: "Project(s) + blast radius", pattern: "Project\\(s\\)|Project(?:s)?\\s*\\+|blast radius" },
3783
+ { name: "Dependency rationale", pattern: "Dependency rationale|Depends[- ]on" },
3784
+ { name: "Traps to avoid", pattern: "Traps" },
3785
+ { name: "Suggested agent-class", pattern: "(?:Suggested\\s+)?agent-class" },
3786
+ { name: "Stop-and-escalate", pattern: "Stop-and-escalate" },
3787
+ { name: "Docs to keep coherent", pattern: "Docs to keep coherent|§7" }
3788
+ ];
3789
+ var DEPENDENCY_RATIONALE_FIELD_NAME = "Dependency rationale";
3790
+ function checkIssueRationale(body) {
3791
+ const errors = [];
3792
+ for (const f of RATIONALE_FIELDS) {
3793
+ if (!hasRationaleField(body, f.pattern)) {
3794
+ errors.push(`issue-validation ${f.name}: rationale field not found in the Issue body — every task Issue carries the full Planner's rationale (aeg-root/contracts/planner-brief.md).`);
3795
+ continue;
3796
+ }
3797
+ if (f.name === DEPENDENCY_RATIONALE_FIELD_NAME && !SECTION_HEADER.test(body)) {
3798
+ errors.push(`issue-validation ${f.name}: rationale field found, but not in the form amend-deps requires — ` + "write `**Dependency rationale** — …`, not `**Dependency rationale:** …`. " + "`amendRationaleDeps` (the only sanctioned way to edit Depends-on/Conflicts-with) locates this " + "section by the exact anchor `**Dependency rationale**`; a colon inside the bold breaks that match " + "and the Issue becomes unamendable.");
3799
+ }
3800
+ }
3801
+ return { status: errors.length > 0 ? "fail" : "pass", errors };
3802
+ }
3803
+ var OBJECTIVES_SINCE_ISSUE = 404;
3804
+ function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
3805
+ if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
3806
+ return { status: "pass", errors: [] };
3807
+ const result = objectivesOf(body);
3808
+ if (result.ok)
3809
+ return { status: "pass", errors: [] };
3810
+ return { status: "fail", errors: result.errors.map((e) => `issue-validation objectives: ${e}`) };
3811
+ }
3812
+ function topLevelSectionText(body, headingName) {
3813
+ const headingRe = new RegExp(`^##[ \\t]*${headingName}[ \\t]*$`, "im");
3814
+ const heading = headingRe.exec(body);
3815
+ if (!heading)
3816
+ return null;
3817
+ const afterHeading = body.slice(heading.index + heading[0].length);
3818
+ const next = /^##[ \t]/m.exec(afterHeading);
3819
+ return next ? afterHeading.slice(0, next.index) : afterHeading;
3820
+ }
3821
+ function partHasBacktickedPath(text) {
3822
+ let i = 0;
3823
+ while (i < text.length) {
3824
+ const start = text.indexOf("`", i);
3825
+ if (start === -1)
3826
+ return false;
3827
+ const end = text.indexOf("`", start + 1);
3828
+ if (end === -1)
3829
+ return false;
3830
+ if (text.slice(start + 1, end).includes("/"))
3831
+ return true;
3832
+ i = end + 1;
3833
+ }
3834
+ return false;
3835
+ }
3836
+ var PART_MIN_WORDS_OUTSIDE_BACKTICKS = 3;
3837
+ function stripPartBackticks(text) {
3838
+ return text.replace(/`[^`\n]*`/g, " ");
3839
+ }
3840
+ function partWordCount(text) {
3841
+ return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
3842
+ }
3843
+ function looksLikeFilePath(entry) {
3844
+ const stripped = entry.replace(/\/\*\*?$/, "");
3845
+ const lastSegment = stripped.split("/").pop() ?? stripped;
3846
+ const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
3847
+ return extMatch !== null && extMatch.index > 0;
3848
+ }
3849
+ function splitGlobList(raw) {
3850
+ return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
3851
+ }
3852
+ function parseIssueSurface(body) {
3853
+ const section = topLevelSectionText(body, "Surface");
3854
+ if (section === null)
3855
+ return { ok: false, errors: ["no `## Surface` heading found in the body."] };
3856
+ const inLine = /^in:\s*(.+)$/im.exec(section);
3857
+ const outLine = /^out:\s*(.+)$/im.exec(section);
3858
+ const errors = [];
3859
+ if (!inLine)
3860
+ errors.push("`## Surface` has no `in:` line.");
3861
+ if (!outLine)
3862
+ errors.push("`## Surface` has no `out:` line.");
3863
+ if (errors.length > 0)
3864
+ return { ok: false, errors };
3865
+ const inGlobs = splitGlobList(inLine[1]);
3866
+ const outGlobs = splitGlobList(outLine[1]);
3867
+ for (const g of [...inGlobs, ...outGlobs]) {
3868
+ if (looksLikeFilePath(g)) {
3869
+ errors.push(`\`${g}\` in \`## Surface\` looks like a file path — Surface entries are directory-level globs, never file paths.`);
3870
+ }
3871
+ }
3872
+ if (inGlobs.length === 0)
3873
+ errors.push("`## Surface`'s `in:` line resolved to zero globs.");
3874
+ if (errors.length > 0)
3875
+ return { ok: false, errors };
3876
+ return { ok: true, value: { in: inGlobs, out: outGlobs } };
3877
+ }
3878
+ function globCoversPath(glob, path) {
3879
+ const g = glob.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
3880
+ const p = path.replace(/\/+$/, "");
3881
+ if (g === "*")
3882
+ return !p.includes("/");
3883
+ return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
3884
+ }
3885
+ function checkSurfaceGlobsResolve(body, resolvesToFile) {
3886
+ const surface = parseIssueSurface(body);
3887
+ if (!surface.ok)
3888
+ return { status: "pass", errors: [] };
3889
+ const errors = [];
3890
+ for (const glob of surface.value.in) {
3891
+ if (!resolvesToFile(glob)) {
3892
+ errors.push(`issue-validation Surface: \`${glob}\` in \`## Surface\`'s \`in:\` list matches no tracked file — a Surface that cannot resolve cannot render a brief's file list.`);
3893
+ }
3894
+ }
3895
+ return { status: errors.length > 0 ? "fail" : "pass", errors };
3896
+ }
3897
+ function checkSurfaceScope(changedFiles, outGlobs) {
3898
+ if (outGlobs.length === 0)
3899
+ return { ok: true };
3900
+ const violations = [];
3901
+ for (const file of changedFiles) {
3902
+ const glob = outGlobs.find((g) => globCoversPath(g, file));
3903
+ if (glob)
3904
+ violations.push({ file, glob });
3905
+ }
3906
+ return violations.length > 0 ? { ok: false, violations } : { ok: true };
3907
+ }
3908
+ var ISSUE_PART_LINE_RE = /^Part\s+(\d+)\s*\(([^)]*)\)\s*[-—–]\s*(.*)$/i;
3909
+ function parseIssueParts(body) {
3910
+ const section = topLevelSectionText(body, "Parts");
3911
+ if (section === null)
3912
+ return { ok: false, errors: ["no `## Parts` heading found in the body."] };
3913
+ const lines = section.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0);
3914
+ const parts = [];
3915
+ const errors = [];
3916
+ for (const line of lines) {
3917
+ const m = ISSUE_PART_LINE_RE.exec(line);
3918
+ if (!m) {
3919
+ errors.push(`"${line}" is not a well-formed Parts line — expected \`Part <n> (<refs>) — <outcome>\`.`);
3920
+ continue;
3921
+ }
3922
+ const n = Number.parseInt(m[1], 10);
3923
+ const refs = m[2];
3924
+ const text = m[3].trim();
3925
+ if (text.length === 0) {
3926
+ errors.push(`Part ${n} has no outcome text after the dash — every Part states one observable outcome.`);
3927
+ continue;
3928
+ }
3560
3929
  if (partHasBacktickedPath(text) && partWordCount(stripPartBackticks(text)) < PART_MIN_WORDS_OUTSIDE_BACKTICKS) {
3561
3930
  errors.push(`Part ${n} is little more than a file path — a Part names an outcome and symbols, never a bare path.`);
3562
3931
  continue;
@@ -3670,6 +4039,27 @@ function checkProjectsRegistered(body, _labels, registeredNames) {
3670
4039
  }
3671
4040
  var DOC_PATH_RE = /(?:(?:aeg-root|apps|packages|specs|docs|tools|\.claude|\.github)\/[\w./@-]*\.(?:md|mdx)|\.claude\/(?:skills|rules)\/[\w./-]+|\b(?:docs-index|decisions|projects|state-machine|enforcement|process|README|CLAUDE)\.md\b|\b[\w-]+-(?:spec|decisions|backlog)\.md\b)/i;
3672
4041
  var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
4042
+ var FILE_EXTENSIONS = new Set([
4043
+ "ts",
4044
+ "tsx",
4045
+ "js",
4046
+ "jsx",
4047
+ "mjs",
4048
+ "cjs",
4049
+ "json",
4050
+ "jsonc",
4051
+ "md",
4052
+ "mdx",
4053
+ "yml",
4054
+ "yaml",
4055
+ "txt",
4056
+ "sh",
4057
+ "lock",
4058
+ "toml",
4059
+ "ndjson",
4060
+ "html",
4061
+ "css"
4062
+ ]);
3673
4063
 
3674
4064
  // ../../packages/aeg-core/src/task-branch-identity.ts
3675
4065
  var ISSUE_BRANCH_PATTERN = /^task\/issue-(\d+)$/;
@@ -4048,8 +4438,7 @@ function briefHash(brief) {
4048
4438
  function policyDigest(policy) {
4049
4439
  return createHash4("sha256").update(JSON.stringify({
4050
4440
  codeReviewThreshold: policy.codeReviewThreshold,
4051
- securityThreshold: policy.securityThreshold,
4052
- maxRounds: policy.maxRounds
4441
+ securityThreshold: policy.securityThreshold
4053
4442
  })).digest("hex");
4054
4443
  }
4055
4444
  function isBoundToHead(echoed, headSha) {
@@ -4115,6 +4504,15 @@ function compareManifest(echoed, current, patchIdOf) {
4115
4504
  }
4116
4505
 
4117
4506
  // ../../packages/aeg-core/src/review-gate.ts
4507
+ function renderGateDeferred(deferred) {
4508
+ if (deferred.length === 0)
4509
+ return "";
4510
+ const items = deferred.map((d) => {
4511
+ const where = d.finding.location && d.finding.location.length > 0 ? d.finding.location : "(no location)";
4512
+ return `${d.finding.severity} ${where} (${DEFERRAL_REASON_TEXT[d.reason]})`;
4513
+ }).join("; ");
4514
+ return ` ${deferred.length} finding(s) deferred, not blocking this round: ${items}.`;
4515
+ }
4118
4516
  function checkReviewGate(input) {
4119
4517
  const principalAllowlist = input.principalAllowlist ?? PRINCIPAL_ALLOWLIST;
4120
4518
  const waived = isWaiverLabelActorVerified({
@@ -4139,8 +4537,8 @@ function checkReviewGate(input) {
4139
4537
  let codeReviewPolicyEvaluation;
4140
4538
  let securityPolicyEvaluation;
4141
4539
  try {
4142
- codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy);
4143
- securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy);
4540
+ codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy, input.deferralContext);
4541
+ securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy, input.deferralContext);
4144
4542
  } catch (err) {
4145
4543
  return {
4146
4544
  verdict: "fail",
@@ -4186,10 +4584,14 @@ function checkReviewGate(input) {
4186
4584
  const securityObjectivesBound = securityBinding.objectivesVersion;
4187
4585
  const codeReviewRulingsBound = codeReviewBinding.rulingOrdinal;
4188
4586
  const securityRulingsBound = securityBinding.rulingOrdinal;
4587
+ const deferredNote = renderGateDeferred([
4588
+ ...codeReviewPolicyEvaluation.deferredFindings,
4589
+ ...securityPolicyEvaluation.deferredFindings
4590
+ ]);
4189
4591
  if (codeReviewClean && codeReviewBinding.bound && securityClean && securityBinding.bound) {
4190
4592
  return {
4191
4593
  verdict: "pass",
4192
- reason: `code-reviewer verdict is a clean APPROVE and security-review verdict is a clean PASS, both covering head ${input.headSha}.`,
4594
+ reason: `code-reviewer verdict is a clean APPROVE and security-review verdict is a clean PASS, both covering head ${input.headSha}.${deferredNote}`,
4193
4595
  waived: false
4194
4596
  };
4195
4597
  }
@@ -4231,7 +4633,7 @@ function checkReviewGate(input) {
4231
4633
  const ignoredNote = ignoredCount > 0 ? ` ${ignoredCount} verdict-shaped comment(s) from authors outside the principal allowlist were ignored.` : "";
4232
4634
  return {
4233
4635
  verdict: "fail",
4234
- reason: `${problems.join("; ")}. A principal can apply an actor-verified \`${WAIVER_LABEL_REVIEW}\` label to skip this requirement, or post the missing/clean verdict comment(s).${ignoredNote}`,
4636
+ reason: `${problems.join("; ")}. A principal can apply an actor-verified \`${WAIVER_LABEL_REVIEW}\` label to skip this requirement, or post the missing/clean verdict comment(s).${ignoredNote}${deferredNote}`,
4235
4637
  waived: false
4236
4638
  };
4237
4639
  }
@@ -4330,585 +4732,210 @@ function parseEnforcementRegistry(content) {
4330
4732
  continue;
4331
4733
  const descriptionIndex = table.headers.findIndex((h) => h.trim().toLowerCase() === "description");
4332
4734
  const implementationIndex = table.headers.findIndex((h) => h.trim().toLowerCase() === "implementation");
4333
- const audienceIndex = table.headers.findIndex((h) => h.trim().toLowerCase() === "audience");
4334
- for (const row of table.rows) {
4335
- const cells = row.cells;
4336
- if (cells.length < 3)
4337
- continue;
4338
- const action = stripBold(cells[0] ?? "");
4339
- const summary = stripBackticks2(cells[1] ?? "");
4340
- const category = stripBackticks2(cells[2] ?? "");
4341
- const implementation = stripBackticks2((implementationIndex === -1 ? cells[cells.length - 1] : cells[implementationIndex]) ?? "");
4342
- const description = descriptionIndex === -1 ? undefined : stripBackticks2(cells[descriptionIndex] ?? "") || undefined;
4343
- const specIndex = (audienceIndex === -1 ? cells.length - 1 : audienceIndex) - 1;
4344
- const spec = specIndex >= 3 ? stripBackticks2(cells[specIndex] ?? "") || undefined : undefined;
4345
- const audience = audienceIndex === -1 ? "repo-own" : stripBackticks2(cells[audienceIndex] ?? "") === "product" ? "product" : "repo-own";
4346
- result.push({ ring, action, summary, category, description, spec, implementation, audience, line: row.line });
4347
- }
4348
- }
4349
- return result;
4350
- }
4351
- // ../../packages/aeg-core/src/registry-checks.ts
4352
- function checkG1(rows, existsFn) {
4353
- const findings = [];
4354
- for (const row of rows) {
4355
- if (row.implementation === "")
4356
- continue;
4357
- if (!existsFn(row.implementation)) {
4358
- findings.push({
4359
- row: row.action,
4360
- path: row.implementation,
4361
- reason: `${row.ring} row "${row.action}" names implementation "${row.implementation}", which does not exist on disk`
4362
- });
4363
- }
4364
- }
4365
- return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
4366
- }
4367
- var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
4368
- var NON_GATE_BIN_NAMES = NON_GATE_BINS;
4369
- var TWIN_CANDIDATE_EXCEPTIONS = {
4370
- "apps/cli/src/checks/bin/check-dead-branch-push.ts": 'Ring 0 "Pushing to a branch whose pull request already resolved" (implementation: check-push-target.ts)',
4371
- "apps/cli/src/checks/bin/check-issue-assignment.ts": `Ring 0 "A task branch's first push (Issue self-assignment)" (implementation: assign-task-issue.ts)`,
4372
- "apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
4373
- };
4374
- var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
4375
- function checkG2(rows, candidateFiles) {
4376
- const implementations = new Set(rows.map((r) => r.implementation).filter((p) => p !== ""));
4377
- const claimedNames = new Set(rows.flatMap((r) => claimedCheckNames(r.implementation)));
4378
- const findings = [];
4379
- for (const path of candidateFiles) {
4380
- if (implementations.has(path))
4381
- continue;
4382
- if (path.startsWith(AEG_CORE_BIN_PATH_PREFIX) && NON_GATE_BIN_NAMES.includes(basenameNoExt(path)))
4383
- continue;
4384
- if (NON_GATE_HOOK_SCRIPTS.includes(path))
4385
- continue;
4386
- if (path in TWIN_CANDIDATE_EXCEPTIONS)
4387
- continue;
4388
- const candidateNames = claimedCheckNames(path);
4389
- if (candidateNames.length > 0 && candidateNames.some((n) => claimedNames.has(n)))
4390
- continue;
4391
- findings.push({
4392
- path,
4393
- reason: `"${path}" is not named as the implementation of any row in enforcement.md's ring tables`
4394
- });
4395
- }
4396
- for (const row of rows) {
4397
- const carriesPlaceholder = [row.summary, row.description, row.spec].some((cell) => cell === SCAFFOLD_PLACEHOLDER);
4398
- if (carriesPlaceholder) {
4399
- findings.push({
4400
- row: row.action,
4401
- path: row.implementation,
4402
- reason: `${row.ring} row "${row.action}" still carries the scaffold placeholder marker — the why is owed`
4403
- });
4404
- }
4405
- }
4406
- return { check: "G2", status: findings.length > 0 ? "fail" : "pass", findings };
4407
- }
4408
- function checkG3(ring0Rows, crossingFiles) {
4409
- const ring0Implementations = new Set(ring0Rows.map((r) => r.implementation));
4410
- const findings = [];
4411
- for (const path of crossingFiles) {
4412
- if (!ring0Implementations.has(path)) {
4413
- findings.push({
4414
- path,
4415
- reason: `"${path}" makes a GitHub-crossing call but is not named by any Ring-0 row's implementation — a seventh, unlisted way into GitHub`
4416
- });
4417
- }
4418
- }
4419
- return { check: "G3", status: findings.length > 0 ? "fail" : "pass", findings };
4420
- }
4421
- function checkG4(content, resolveFn) {
4422
- const cited = new Set;
4423
- for (const hit of content.matchAll(/#(\d{3,})\b/g)) {
4424
- cited.add(Number(hit[1]));
4425
- }
4426
- const findings = [];
4427
- for (const n of cited) {
4428
- if (!resolveFn(n)) {
4429
- findings.push({
4430
- reason: `#${n} is cited in enforcement.md but does not resolve to a real Issue or PR in the forge`
4431
- });
4432
- }
4433
- }
4434
- return { check: "G4", status: findings.length > 0 ? "fail" : "pass", findings };
4435
- }
4436
- function checkG5(roles, contracts) {
4437
- const roleIds = new Set(roles.map((r) => r.role_id));
4438
- const findings = [];
4439
- for (const contract of contracts) {
4440
- if (!roleIds.has(contract.producer)) {
4441
- findings.push({
4442
- path: contract.file,
4443
- reason: `contract "${contract.file}" names producer "${contract.producer}", which is not a real role_id`
4444
- });
4445
- }
4446
- if (!roleIds.has(contract.consumer)) {
4447
- findings.push({
4448
- path: contract.file,
4449
- reason: `contract "${contract.file}" names consumer "${contract.consumer}", which is not a real role_id`
4450
- });
4451
- }
4452
- }
4453
- for (const role of roles) {
4454
- if (role.performs.length === 0) {
4455
- findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty performs array` });
4456
- }
4457
- if (role.refuses_when.trim() === "") {
4458
- findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty refuses_when` });
4459
- }
4460
- }
4461
- return { check: "G5", status: findings.length > 0 ? "fail" : "pass", findings };
4462
- }
4463
- var SHIPPED_BIN_PATH_PREFIX = "apps/cli/src/checks/bin/check-";
4464
- var AEG_CORE_BIN_PATH_PREFIX = "packages/aeg-core/bin/";
4465
- function basenameNoExt(path) {
4466
- const base = path.slice(path.lastIndexOf("/") + 1);
4467
- return base.replace(/\.ts$/, "");
4468
- }
4469
- function claimedCheckNames(implementation) {
4470
- if (implementation.startsWith(SHIPPED_BIN_PATH_PREFIX) && implementation.endsWith(".ts")) {
4471
- return [implementation.slice(SHIPPED_BIN_PATH_PREFIX.length, -".ts".length)];
4472
- }
4473
- if (implementation.startsWith(AEG_CORE_BIN_PATH_PREFIX)) {
4474
- const audience = GATE_AUDIENCE[basenameNoExt(implementation)];
4475
- if (audience && isShipped(audience)) {
4476
- return Array.isArray(audience.shippedAs) ? audience.shippedAs : [audience.shippedAs];
4477
- }
4478
- }
4479
- return [];
4480
- }
4481
- function checkG6(rows, registeredCheckNames) {
4482
- const findings = [];
4483
- for (const row of rows) {
4484
- if (row.audience !== "product")
4485
- continue;
4486
- const candidates = claimedCheckNames(row.implementation);
4487
- if (!candidates.some((name) => registeredCheckNames.has(name))) {
4488
- findings.push({
4489
- row: row.action,
4490
- path: row.implementation,
4491
- reason: `${row.ring} row "${row.action}" is marked \`product\` but its implementation "${row.implementation}" does not resolve to a coreCheckRegistry() entry`
4492
- });
4493
- }
4494
- }
4495
- return { check: "G6", status: findings.length > 0 ? "fail" : "pass", findings };
4496
- }
4497
- // ../../packages/aeg-core/src/reader-resolvable-prose.ts
4498
- var PRODUCT_SLUG_SCOPE = [
4499
- "apps/cli/src",
4500
- ".github/workflows",
4501
- ".vinaya",
4502
- "apps/cli/README.md",
4503
- "packages/sources/README.md"
4504
- ];
4505
- function isUnderOrEqual(path, prefix) {
4506
- return path === prefix || path.startsWith(`${prefix}/`);
4507
- }
4508
- function isProductScopeFile(path) {
4509
- return PRODUCT_SLUG_SCOPE.some((prefix) => isUnderOrEqual(path, prefix));
4510
- }
4511
- var SHIPS_PREFIX = "aeg-root/";
4512
- function shipsArchivePrefix(shipsPrefix) {
4513
- return `${shipsPrefix}tranches/completed/`;
4514
- }
4515
- var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
4516
- function normalizeSpecPath(entry) {
4517
- let out = entry.replace(/\\/g, "/");
4518
- while (out.startsWith("./"))
4519
- out = out.slice(2);
4520
- out = out.replace(/\/{2,}/g, "/");
4521
- while (out.endsWith("/"))
4522
- out = out.slice(0, -1);
4523
- return out;
4524
- }
4525
- function isSpecFile2(path, specPaths) {
4526
- if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
4527
- return true;
4528
- if (!path.endsWith(".md"))
4529
- return false;
4530
- return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
4531
- }
4532
- function isClaudeMdFile(path) {
4533
- return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
4534
- }
4535
- function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
4536
- if (path.startsWith(shipsPrefix)) {
4537
- return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
4538
- }
4539
- if (path.startsWith(readerFacingPrefix) && path.endsWith(readerFacingSuffix)) {
4540
- return "reader-facing";
4541
- }
4542
- if (isClaudeMdFile(path))
4543
- return "internal";
4544
- if (isSpecFile2(path, specPaths))
4545
- return "spec";
4546
- if (isProductScopeFile(path))
4547
- return "product";
4548
- return null;
4549
- }
4550
- var SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
4551
- function stripNonProse(path, content) {
4552
- if (path.endsWith(".md")) {
4553
- return content.replace(/```.*?```/gs, (m) => m.replace(/[^\n]/g, "")).replace(/`[^`\n]*`/g, (m) => m.replace(/[^\n]/g, ""));
4554
- }
4555
- if (path.endsWith(".tsx") || path.endsWith(".ts")) {
4556
- return content.replace(/\/\*.*?\*\//gs, (m) => m.replace(/[^\n]/g, "")).replace(/(^|[^:])\/\/[^\n]*/g, (m) => m.replace(/[^\n]/g, ""));
4735
+ const audienceIndex = table.headers.findIndex((h) => h.trim().toLowerCase() === "audience");
4736
+ for (const row of table.rows) {
4737
+ const cells = row.cells;
4738
+ if (cells.length < 3)
4739
+ continue;
4740
+ const action = stripBold(cells[0] ?? "");
4741
+ const summary = stripBackticks2(cells[1] ?? "");
4742
+ const category = stripBackticks2(cells[2] ?? "");
4743
+ const implementation = stripBackticks2((implementationIndex === -1 ? cells[cells.length - 1] : cells[implementationIndex]) ?? "");
4744
+ const description = descriptionIndex === -1 ? undefined : stripBackticks2(cells[descriptionIndex] ?? "") || undefined;
4745
+ const specIndex = (audienceIndex === -1 ? cells.length - 1 : audienceIndex) - 1;
4746
+ const spec = specIndex >= 3 ? stripBackticks2(cells[specIndex] ?? "") || undefined : undefined;
4747
+ const audience = audienceIndex === -1 ? "repo-own" : stripBackticks2(cells[audienceIndex] ?? "") === "product" ? "product" : "repo-own";
4748
+ result.push({ ring, action, summary, category, description, spec, implementation, audience, line: row.line });
4749
+ }
4557
4750
  }
4558
- return content;
4751
+ return result;
4559
4752
  }
4560
- function stripNonProseForProduct(path, content) {
4561
- return path.endsWith(".md") ? stripNonProse(path, content) : content;
4753
+ // ../../packages/aeg-core/src/registry-checks.ts
4754
+ var HOOK_DIR_PREFIXES = [".claude/hooks/", ".vinaya/hooks/", ".husky/", ".git/hooks/"];
4755
+ var BARE_HOOK_NAME = /^check-[A-Za-z0-9_.-]*\.sh$/;
4756
+ function basename(path) {
4757
+ return path.slice(path.lastIndexOf("/") + 1);
4562
4758
  }
4563
- function lineAt(content, index) {
4759
+ function lineOf(content, index) {
4564
4760
  let line = 1;
4565
- for (let i = 0;i < index; i++) {
4761
+ for (let i = 0;i < index; i++)
4566
4762
  if (content.charCodeAt(i) === 10)
4567
4763
  line++;
4568
- }
4569
4764
  return line;
4570
4765
  }
4571
- var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
4572
- var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
4573
- var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
4574
- function legacySlugPattern(legacySlugs) {
4575
- if (legacySlugs.length === 0)
4576
- return null;
4577
- const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
4578
- return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
4579
- }
4580
- function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4766
+ function findUnshippedHookRefs(docs, shipped) {
4767
+ const shippedNames = new Set([...shipped].map(basename));
4581
4768
  const findings = [];
4582
- const legacyPattern = legacySlugPattern(legacySlugs);
4583
- const grandfathered = new Set(specGrandfather);
4584
- const patterns = [
4585
- { pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
4586
- { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
4587
- ...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
4588
- ];
4589
- const productPatterns = [
4590
- { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
4591
- ];
4592
- const specPatterns = [
4593
- ...patterns,
4594
- { pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
4595
- ];
4596
- for (const file of files) {
4597
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
4598
- if (!cls || cls === "internal")
4599
- continue;
4600
- if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
4601
- continue;
4602
- if (cls === "spec" && grandfathered.has(file.path))
4603
- continue;
4604
- const blocking = cls === "product" || cls === "spec";
4605
- const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
4606
- const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
4607
- for (const { pattern, what, group } of patternsToRun) {
4608
- pattern.lastIndex = 0;
4609
- let match = pattern.exec(scrubbed);
4610
- while (match !== null) {
4611
- const cited = group !== undefined ? match[group] ?? match[0] : match[0];
4612
- const citedIndex = match.index + match[0].indexOf(cited);
4613
- findings.push({
4614
- file: file.path,
4615
- line: lineAt(scrubbed, citedIndex),
4616
- message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
4617
- blocking
4618
- });
4619
- match = pattern.exec(scrubbed);
4620
- }
4769
+ const flag = (doc, token, index) => {
4770
+ findings.push({
4771
+ path: doc.path,
4772
+ reason: `${doc.path}:${lineOf(doc.content, index)} names hook "${token}", which is neither tracked in git nor emitted by \`vinaya init\``
4773
+ });
4774
+ };
4775
+ for (const doc of docs) {
4776
+ for (const { cited, index } of extractCitedPaths(doc.content)) {
4777
+ if (cited.endsWith("/") || !HOOK_DIR_PREFIXES.some((p) => cited.startsWith(p)))
4778
+ continue;
4779
+ if (!shipped.has(cited))
4780
+ flag(doc, cited, index);
4781
+ }
4782
+ const spanPattern = /`([^`\n]+)`/g;
4783
+ let match = spanPattern.exec(doc.content);
4784
+ while (match !== null) {
4785
+ const token = match[1] ?? "";
4786
+ if (BARE_HOOK_NAME.test(token) && !shippedNames.has(token))
4787
+ flag(doc, token, match.index);
4788
+ match = spanPattern.exec(doc.content);
4621
4789
  }
4622
4790
  }
4623
4791
  return findings;
4624
4792
  }
4625
- function escapeTerm(term) {
4626
- return term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4627
- }
4628
- function containsWholeWord(text, term) {
4629
- const escaped = escapeTerm(term);
4630
- const re = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)`, "i");
4631
- return re.test(text);
4632
- }
4633
- function findWholeWordLine(content, term) {
4634
- const lines = content.split(`
4635
- `);
4636
- let lineNo = 0;
4637
- for (const line of lines) {
4638
- lineNo++;
4639
- if (containsWholeWord(line, term))
4640
- return lineNo;
4641
- }
4642
- return null;
4643
- }
4644
- function definesOrLinksGlossary(content, term) {
4645
- const escaped = escapeTerm(term);
4646
- const definesInline = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)[^\\n]{0,3}—`, "i").test(content);
4647
- if (definesInline)
4648
- return true;
4649
- return /docs\/glossary|glossary\.md/i.test(content);
4650
- }
4651
- function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
4793
+ function checkG1(rows, existsFn, hookRefs) {
4652
4794
  const findings = [];
4653
- for (const file of files) {
4654
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
4655
- if (!cls || !SWEPT_CLASSES.has(cls))
4795
+ for (const row of rows) {
4796
+ if (row.implementation === "")
4656
4797
  continue;
4657
- const scrubbed = stripNonProse(file.path, file.content);
4658
- for (const term of glossaryTerms) {
4659
- const line = findWholeWordLine(scrubbed, term);
4660
- if (line === null)
4661
- continue;
4662
- if (definesOrLinksGlossary(scrubbed, term))
4663
- continue;
4798
+ if (!existsFn(row.implementation)) {
4664
4799
  findings.push({
4665
- file: file.path,
4666
- line,
4667
- message: `uses coined term "${term}" without defining it inline or linking the glossary`,
4668
- blocking: false
4800
+ row: row.action,
4801
+ path: row.implementation,
4802
+ reason: `${row.ring} row "${row.action}" names implementation "${row.implementation}", which does not exist on disk`
4669
4803
  });
4670
4804
  }
4671
4805
  }
4672
- return findings;
4806
+ if (hookRefs)
4807
+ findings.push(...findUnshippedHookRefs(hookRefs.docs, hookRefs.shipped));
4808
+ return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
4673
4809
  }
4674
- var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g;
4675
- var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = /#[0-9]{2,}/g;
4676
- function extractComments(path, content) {
4677
- if (!path.endsWith(".ts") && !path.endsWith(".tsx"))
4678
- return content.replace(/[^\n]/g, "");
4679
- let state = "code";
4680
- let out = "";
4681
- const n = content.length;
4682
- let i = 0;
4683
- const blank = (ch) => ch === `
4684
- ` ? `
4685
- ` : " ";
4686
- while (i < n) {
4687
- const c = content[i];
4688
- const next = i + 1 < n ? content[i + 1] : "";
4689
- if (state === "code") {
4690
- if (c === "/" && next === "/") {
4691
- state = "line-comment";
4692
- out += c;
4693
- i++;
4694
- continue;
4695
- }
4696
- if (c === "/" && next === "*") {
4697
- state = "block-comment";
4698
- out += c;
4699
- i++;
4700
- continue;
4701
- }
4702
- if (c === "'") {
4703
- state = "single-quote";
4704
- out += blank(c);
4705
- i++;
4706
- continue;
4707
- }
4708
- if (c === '"') {
4709
- state = "double-quote";
4710
- out += blank(c);
4711
- i++;
4712
- continue;
4713
- }
4714
- if (c === "`") {
4715
- state = "template";
4716
- out += blank(c);
4717
- i++;
4718
- continue;
4719
- }
4720
- out += blank(c);
4721
- i++;
4810
+ var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
4811
+ var NON_GATE_BIN_NAMES = NON_GATE_BINS;
4812
+ var TWIN_CANDIDATE_EXCEPTIONS = {
4813
+ "apps/cli/src/checks/bin/check-dead-branch-push.ts": 'Ring 0 "Pushing to a branch whose pull request already resolved" (implementation: check-push-target.ts)',
4814
+ "apps/cli/src/checks/bin/check-issue-assignment.ts": `Ring 0 "A task branch's first push (Issue self-assignment)" (implementation: assign-task-issue.ts)`,
4815
+ "apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
4816
+ };
4817
+ var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
4818
+ function checkG2(rows, candidateFiles) {
4819
+ const implementations = new Set(rows.map((r) => r.implementation).filter((p) => p !== ""));
4820
+ const claimedNames = new Set(rows.flatMap((r) => claimedCheckNames(r.implementation)));
4821
+ const findings = [];
4822
+ for (const path of candidateFiles) {
4823
+ if (implementations.has(path))
4722
4824
  continue;
4723
- }
4724
- if (state === "line-comment") {
4725
- if (c === `
4726
- `) {
4727
- state = "code";
4728
- out += `
4729
- `;
4730
- i++;
4731
- continue;
4732
- }
4733
- out += c;
4734
- i++;
4825
+ if (path.startsWith(AEG_CORE_BIN_PATH_PREFIX) && NON_GATE_BIN_NAMES.includes(basenameNoExt(path)))
4735
4826
  continue;
4736
- }
4737
- if (state === "block-comment") {
4738
- if (c === "*" && next === "/") {
4739
- out += c;
4740
- out += next;
4741
- state = "code";
4742
- i += 2;
4743
- continue;
4744
- }
4745
- out += c === `
4746
- ` ? `
4747
- ` : c;
4748
- i++;
4827
+ if (NON_GATE_HOOK_SCRIPTS.includes(path))
4749
4828
  continue;
4750
- }
4751
- const closer = state === "single-quote" ? "'" : state === "double-quote" ? '"' : "`";
4752
- if (c === "\\") {
4753
- out += blank(c);
4754
- i++;
4755
- if (i < n) {
4756
- out += blank(content[i]);
4757
- i++;
4758
- }
4829
+ if (path in TWIN_CANDIDATE_EXCEPTIONS)
4759
4830
  continue;
4760
- }
4761
- if (c === closer) {
4762
- state = "code";
4763
- out += blank(c);
4764
- i++;
4831
+ const candidateNames = claimedCheckNames(path);
4832
+ if (candidateNames.length > 0 && candidateNames.some((n) => claimedNames.has(n)))
4765
4833
  continue;
4834
+ findings.push({
4835
+ path,
4836
+ reason: `"${path}" is not named as the implementation of any row in enforcement.md's ring tables`
4837
+ });
4838
+ }
4839
+ for (const row of rows) {
4840
+ const carriesPlaceholder = [row.summary, row.description, row.spec].some((cell) => cell === SCAFFOLD_PLACEHOLDER);
4841
+ if (carriesPlaceholder) {
4842
+ findings.push({
4843
+ row: row.action,
4844
+ path: row.implementation,
4845
+ reason: `${row.ring} row "${row.action}" still carries the scaffold placeholder marker — the why is owed`
4846
+ });
4847
+ }
4848
+ }
4849
+ return { check: "G2", status: findings.length > 0 ? "fail" : "pass", findings };
4850
+ }
4851
+ function checkG3(ring0Rows, crossingFiles) {
4852
+ const ring0Implementations = new Set(ring0Rows.map((r) => r.implementation));
4853
+ const findings = [];
4854
+ for (const path of crossingFiles) {
4855
+ if (!ring0Implementations.has(path)) {
4856
+ findings.push({
4857
+ path,
4858
+ reason: `"${path}" makes a GitHub-crossing call but is not named by any Ring-0 row's implementation — a seventh, unlisted way into GitHub`
4859
+ });
4766
4860
  }
4767
- out += blank(c);
4768
- i++;
4769
4861
  }
4770
- return out;
4862
+ return { check: "G3", status: findings.length > 0 ? "fail" : "pass", findings };
4771
4863
  }
4772
- function checkSourceComments(files, allowlist = []) {
4864
+ function checkG4(content, resolveFn) {
4865
+ const cited = new Set;
4866
+ for (const hit of content.matchAll(/#(\d{3,})\b/g)) {
4867
+ cited.add(Number(hit[1]));
4868
+ }
4773
4869
  const findings = [];
4774
- const allowed = new Set(allowlist);
4775
- const patterns = [
4776
- { pattern: SOURCE_COMMENT_TRANCHE_SLUG_PATTERN, what: "a tranche-slug citation" },
4777
- { pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
4778
- ];
4779
- for (const file of files) {
4780
- if (!file.path.endsWith(".ts"))
4781
- continue;
4782
- if (allowed.has(file.path))
4783
- continue;
4784
- const comments = extractComments(file.path, file.content);
4785
- for (const { pattern, what } of patterns) {
4786
- pattern.lastIndex = 0;
4787
- let match = pattern.exec(comments);
4788
- while (match !== null) {
4789
- findings.push({
4790
- file: file.path,
4791
- line: lineAt(comments, match.index),
4792
- message: `comment cites ${what} ("${match[0]}") a reader outside this repo's tracker cannot resolve`,
4793
- blocking: false
4794
- });
4795
- match = pattern.exec(comments);
4796
- }
4870
+ for (const n of cited) {
4871
+ if (!resolveFn(n)) {
4872
+ findings.push({
4873
+ reason: `#${n} is cited in enforcement.md but does not resolve to a real Issue or PR in the forge`
4874
+ });
4797
4875
  }
4798
4876
  }
4799
- return findings;
4800
- }
4801
- function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4802
- return [
4803
- ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
4804
- ...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
4805
- ];
4806
- }
4807
- function parseGlossaryTerms(glossaryContent) {
4808
- const terms = [];
4809
- const re = /^\*\*(.+?)\*\* —/gm;
4810
- let match = re.exec(glossaryContent);
4811
- while (match !== null) {
4812
- if (match[1] !== undefined)
4813
- terms.push(match[1]);
4814
- match = re.exec(glossaryContent);
4815
- }
4816
- return terms;
4817
- }
4818
-
4819
- // ../../packages/aeg-core/src/quoted-command.ts
4820
- var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
4821
- var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
4822
- var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
4823
- var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
4824
- function isValidCitedFilePath(path) {
4825
- if (path.length === 0)
4826
- return false;
4827
- if (path.startsWith("/") || path.startsWith("\\"))
4828
- return false;
4829
- if (/^[A-Za-z]:[\\/]/.test(path))
4830
- return false;
4831
- return !path.split(/[\\/]+/).includes("..");
4877
+ return { check: "G4", status: findings.length > 0 ? "fail" : "pass", findings };
4832
4878
  }
4833
- function quotedCommandLineAt(content, index) {
4834
- let line = 1;
4835
- for (let i = 0;i < index; i++) {
4836
- if (content.charCodeAt(i) === 10)
4837
- line++;
4879
+ function checkG5(roles, contracts) {
4880
+ const roleIds = new Set(roles.map((r) => r.role_id));
4881
+ const findings = [];
4882
+ for (const contract of contracts) {
4883
+ if (!roleIds.has(contract.producer)) {
4884
+ findings.push({
4885
+ path: contract.file,
4886
+ reason: `contract "${contract.file}" names producer "${contract.producer}", which is not a real role_id`
4887
+ });
4888
+ }
4889
+ if (!roleIds.has(contract.consumer)) {
4890
+ findings.push({
4891
+ path: contract.file,
4892
+ reason: `contract "${contract.file}" names consumer "${contract.consumer}", which is not a real role_id`
4893
+ });
4894
+ }
4838
4895
  }
4839
- return line;
4840
- }
4841
- function extractQuotedText(raw) {
4842
- const trimmed = raw.trim();
4843
- const fenced = /^(?:`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?(?:`{3,}|~{3,})$/.exec(trimmed);
4844
- if (fenced)
4845
- return (fenced[1] ?? "").trim();
4846
- const inline = /^`([^`]+)`$/.exec(trimmed);
4847
- if (inline)
4848
- return (inline[1] ?? "").trim();
4849
- return trimmed;
4850
- }
4851
- function findQuotesInFile(path, content) {
4852
- const masked = maskCode(content);
4853
- const quotes = [];
4854
- START_PATTERN.lastIndex = 0;
4855
- let start = START_PATTERN.exec(masked);
4856
- while (start !== null) {
4857
- const citedFile = start[1];
4858
- const innerStart = start.index + start[0].length;
4859
- const end = END_PATTERN.exec(masked.slice(innerStart));
4860
- if (end === null) {
4861
- START_PATTERN.lastIndex = innerStart;
4862
- start = START_PATTERN.exec(masked);
4863
- continue;
4896
+ for (const role of roles) {
4897
+ if (role.performs.length === 0) {
4898
+ findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty performs array` });
4864
4899
  }
4865
- const innerEnd = innerStart + end.index;
4866
- if (isValidCitedFilePath(citedFile)) {
4867
- const quotedText = extractQuotedText(content.slice(innerStart, innerEnd));
4868
- if (quotedText.length > 0) {
4869
- quotes.push({ file: path, line: quotedCommandLineAt(content, innerStart), quotedText, citedFile });
4870
- }
4900
+ if (role.refuses_when.trim() === "") {
4901
+ findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty refuses_when` });
4871
4902
  }
4872
- START_PATTERN.lastIndex = innerEnd + end[0].length;
4873
- start = START_PATTERN.exec(masked);
4874
4903
  }
4875
- return quotes;
4904
+ return { check: "G5", status: findings.length > 0 ? "fail" : "pass", findings };
4876
4905
  }
4877
- function findCitedQuotes(files, readerFacingPrefix, readerFacingSuffix, shipsPrefix = QUOTED_COMMAND_SHIPS_PREFIX) {
4878
- const quotes = [];
4879
- for (const file of files) {
4880
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
4881
- if (!cls || !QUOTED_COMMAND_SWEPT_CLASSES.has(cls))
4882
- continue;
4883
- quotes.push(...findQuotesInFile(file.path, file.content));
4906
+ var SHIPPED_BIN_PATH_PREFIX = "apps/cli/src/checks/bin/check-";
4907
+ var AEG_CORE_BIN_PATH_PREFIX = "packages/aeg-core/bin/";
4908
+ function basenameNoExt(path) {
4909
+ const base = path.slice(path.lastIndexOf("/") + 1);
4910
+ return base.replace(/\.ts$/, "");
4911
+ }
4912
+ function claimedCheckNames(implementation) {
4913
+ if (implementation.startsWith(SHIPPED_BIN_PATH_PREFIX) && implementation.endsWith(".ts")) {
4914
+ return [implementation.slice(SHIPPED_BIN_PATH_PREFIX.length, -".ts".length)];
4884
4915
  }
4885
- return quotes;
4916
+ if (implementation.startsWith(AEG_CORE_BIN_PATH_PREFIX)) {
4917
+ const audience = GATE_AUDIENCE[basenameNoExt(implementation)];
4918
+ if (audience && isShipped(audience)) {
4919
+ return Array.isArray(audience.shippedAs) ? audience.shippedAs : [audience.shippedAs];
4920
+ }
4921
+ }
4922
+ return [];
4886
4923
  }
4887
- function evaluateCitedQuotes(citedQuotes, citedFileContents) {
4924
+ function checkG6(rows, registeredCheckNames) {
4888
4925
  const findings = [];
4889
- for (const quote of citedQuotes) {
4890
- const content = citedFileContents.get(quote.citedFile);
4891
- if (content === undefined) {
4892
- findings.push({
4893
- file: quote.file,
4894
- line: quote.line,
4895
- citedFile: quote.citedFile,
4896
- quotedText: quote.quotedText,
4897
- message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
4898
- });
4926
+ for (const row of rows) {
4927
+ if (row.audience !== "product")
4899
4928
  continue;
4900
- }
4901
- if (!content.includes(quote.quotedText)) {
4929
+ const candidates = claimedCheckNames(row.implementation);
4930
+ if (!candidates.some((name) => registeredCheckNames.has(name))) {
4902
4931
  findings.push({
4903
- file: quote.file,
4904
- line: quote.line,
4905
- citedFile: quote.citedFile,
4906
- quotedText: quote.quotedText,
4907
- message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
4932
+ row: row.action,
4933
+ path: row.implementation,
4934
+ reason: `${row.ring} row "${row.action}" is marked \`product\` but its implementation "${row.implementation}" does not resolve to a coreCheckRegistry() entry`
4908
4935
  });
4909
4936
  }
4910
4937
  }
4911
- return findings;
4938
+ return { check: "G6", status: findings.length > 0 ? "fail" : "pass", findings };
4912
4939
  }
4913
4940
  // ../../packages/aeg-core/src/dead-branch-push-guard.ts
4914
4941
  function checkDeadBranchPush(input) {
@@ -5331,7 +5358,6 @@ var TaskPrPauseSchema = z.object({
5331
5358
  var TaskPrReviewRecordSchema = z.object({
5332
5359
  verdicts: z.array(TaskPrVerdictSchema),
5333
5360
  roundMarkers: z.array(z.number().int().nonnegative()),
5334
- summaryTable: z.string().nullable(),
5335
5361
  pause: TaskPrPauseSchema.nullable()
5336
5362
  });
5337
5363
  var TaskPrReadInputSchema = z.object({
@@ -5378,16 +5404,6 @@ var TaskCancelResultSchema = z.object({
5378
5404
  authenticatedFrom: z.string().min(1),
5379
5405
  fencedEffectKeys: z.array(z.string())
5380
5406
  });
5381
- var TASK_TOOL_NAMES = [
5382
- "task_start",
5383
- "task_status",
5384
- "task_escalation_read",
5385
- "task_pr_read",
5386
- "task_resume",
5387
- "task_cancel"
5388
- ];
5389
- var OPERATOR_STATUS_FOLLOW = "task_status_follow";
5390
- var OPERATOR_TOOL_GRANT = [...TASK_TOOL_NAMES, OPERATOR_STATUS_FOLLOW];
5391
5407
  // ../../packages/aeg-core/src/first-push-dispatch-gate.ts
5392
5408
  function parseTaskBranch(branch) {
5393
5409
  const m = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
@@ -5618,15 +5634,69 @@ var NO_GATE_CUTOVERS = {
5618
5634
  briefRulesSincePr: null,
5619
5635
  agentBoxesRefusedSincePr: null
5620
5636
  };
5621
- // ../../packages/aeg-core/src/dev-review-loop/types.ts
5622
- var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5623
- // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
5624
- var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
5625
- // ../../packages/aeg-core/src/log/envelope.ts
5626
- import { createHash as createHash5 } from "node:crypto";
5627
-
5628
5637
  // ../../packages/aeg-core/src/log/schema.ts
5638
+ import { z as z3 } from "zod";
5639
+
5640
+ // ../../packages/aeg-core/src/log/custom.ts
5629
5641
  import { z as z2 } from "zod";
5642
+ var CUSTOM_EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]*\.[a-z][a-z0-9_.]*$/;
5643
+ var CUSTOM_EVENT_NAME_MAX_LENGTH = 64;
5644
+ var CUSTOM_EVENT_RESERVED_NAMESPACE = "vinaya";
5645
+ var CUSTOM_EVENT_MAX_FIELDS = 20;
5646
+ var CUSTOM_FIELD_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
5647
+ var CUSTOM_FIELD_NAME_MAX_LENGTH = 64;
5648
+ var CUSTOM_TEXT_MAX_LENGTH = 500;
5649
+ var CUSTOM_WORD_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
5650
+ var CUSTOM_WORD_MAX_LENGTH = 64;
5651
+ var CUSTOM_FIELD_MAX_WORDS = 50;
5652
+ var CustomFieldTypeSchema = z2.union([z2.enum(["text", "number", "boolean"]), z2.array(z2.string())]);
5653
+ var CustomEventDeclarationsSchema = z2.record(z2.string(), z2.object({
5654
+ fields: z2.record(z2.string(), CustomFieldTypeSchema)
5655
+ }).strict()).superRefine((events, ctx) => {
5656
+ for (const [name, declaration] of Object.entries(events)) {
5657
+ const refuse = (message, path = []) => {
5658
+ ctx.addIssue({
5659
+ code: z2.ZodIssueCode.custom,
5660
+ path: [name, ...path],
5661
+ message: `logs.events "${name}": ${message}`
5662
+ });
5663
+ };
5664
+ if (name.length > CUSTOM_EVENT_NAME_MAX_LENGTH) {
5665
+ refuse(`the name must be at most ${CUSTOM_EVENT_NAME_MAX_LENGTH} characters`);
5666
+ }
5667
+ if (!CUSTOM_EVENT_NAME_PATTERN.test(name)) {
5668
+ refuse("the name must be `<namespace>.<event>` — lowercase letters, digits and `_`, a dot between them");
5669
+ } else if (name.split(".")[0] === CUSTOM_EVENT_RESERVED_NAMESPACE) {
5670
+ refuse(`the \`${CUSTOM_EVENT_RESERVED_NAMESPACE}.\` namespace is reserved for Vinaya's own events`);
5671
+ }
5672
+ const fieldEntries = Object.entries(declaration.fields);
5673
+ if (fieldEntries.length > CUSTOM_EVENT_MAX_FIELDS) {
5674
+ refuse(`at most ${CUSTOM_EVENT_MAX_FIELDS} fields may be declared (found ${fieldEntries.length})`, ["fields"]);
5675
+ }
5676
+ for (const [field, type] of fieldEntries) {
5677
+ if (field.length > CUSTOM_FIELD_NAME_MAX_LENGTH || !CUSTOM_FIELD_NAME_PATTERN.test(field)) {
5678
+ refuse(`field "${field}": a field name is lowercase letters, digits and \`_\`, starting with a letter, at most ${CUSTOM_FIELD_NAME_MAX_LENGTH} characters`, ["fields", field]);
5679
+ }
5680
+ if (typeof type === "string")
5681
+ continue;
5682
+ if (type.length === 0) {
5683
+ refuse(`field "${field}": a list of words must name at least one word`, ["fields", field]);
5684
+ }
5685
+ if (type.length > CUSTOM_FIELD_MAX_WORDS) {
5686
+ refuse(`field "${field}": a list of words may name at most ${CUSTOM_FIELD_MAX_WORDS}`, ["fields", field]);
5687
+ }
5688
+ const bad = type.filter((w) => w.length > CUSTOM_WORD_MAX_LENGTH || !CUSTOM_WORD_PATTERN.test(w));
5689
+ if (bad.length > 0) {
5690
+ refuse(`field "${field}": a listed word is lowercase letters, digits, \`_\` and \`-\`, at most ${CUSTOM_WORD_MAX_LENGTH} characters`, ["fields", field]);
5691
+ }
5692
+ if (new Set(type).size !== type.length) {
5693
+ refuse(`field "${field}": a list of words names a word twice`, ["fields", field]);
5694
+ }
5695
+ }
5696
+ }
5697
+ });
5698
+
5699
+ // ../../packages/aeg-core/src/log/schema.ts
5630
5700
  var CONFIDENCE_REASON_MAX_LENGTH = 280;
5631
5701
  var ROLE_VALUES = [
5632
5702
  "planner",
@@ -5637,244 +5707,297 @@ var ROLE_VALUES = [
5637
5707
  "archivist",
5638
5708
  "architect"
5639
5709
  ];
5640
- var RoleSchema = z2.enum(ROLE_VALUES);
5710
+ var RoleSchema = z3.enum(ROLE_VALUES);
5641
5711
  var HOST_VALUES = ["hook", "ci", "cli", "loop"];
5642
- var HostSchema = z2.enum(HOST_VALUES);
5712
+ var HostSchema = z3.enum(HOST_VALUES);
5643
5713
  var RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
5644
5714
  var headerMetaCore = {
5645
- ts: z2.string(),
5646
- run_id: z2.string().regex(RUN_ID_PATTERN),
5647
- seq: z2.number().int().nonnegative(),
5648
- repo: z2.string().nullable(),
5649
- vinaya: z2.string(),
5650
- doctrine: z2.string(),
5715
+ ts: z3.string(),
5716
+ run_id: z3.string().regex(RUN_ID_PATTERN),
5717
+ seq: z3.number().int().nonnegative(),
5718
+ repo: z3.string().nullable(),
5719
+ vinaya: z3.string(),
5720
+ doctrine: z3.string(),
5651
5721
  host: HostSchema,
5652
- machine: z2.string()
5722
+ machine: z3.string()
5653
5723
  };
5654
- var HeaderMetaV1Schema = z2.object({
5655
- schema: z2.literal(1),
5724
+ var HeaderMetaV1Schema = z3.object({
5725
+ schema: z3.literal(1),
5656
5726
  ...headerMetaCore
5657
5727
  }).strict();
5658
- var LineageSchema = z2.object({
5659
- run: z2.string().nullable(),
5660
- attempt: z2.number().int().nullable(),
5661
- parent: z2.string().nullable()
5728
+ var LineageSchema = z3.object({
5729
+ run: z3.string().nullable(),
5730
+ attempt: z3.number().int().nullable(),
5731
+ parent: z3.string().nullable()
5662
5732
  }).strict();
5663
- var InputVersionsSchema = z2.object({
5664
- objectives_version: z2.string().nullable(),
5665
- brief_hash: z2.string().nullable(),
5666
- ruling_ordinal: z2.number().int().nullable(),
5667
- policy_digest: z2.string().nullable()
5733
+ var InputVersionsSchema = z3.object({
5734
+ objectives_version: z3.string().nullable(),
5735
+ brief_hash: z3.string().nullable(),
5736
+ ruling_ordinal: z3.number().int().nullable(),
5737
+ policy_digest: z3.string().nullable()
5668
5738
  }).strict();
5669
- var ProvenanceSchema = z2.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
5670
- var HeaderMetaV2Schema = z2.object({
5671
- schema: z2.literal(2),
5739
+ var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
5740
+ var HeaderMetaV2Schema = z3.object({
5741
+ schema: z3.literal(2),
5672
5742
  ...headerMetaCore,
5673
- event_id: z2.string().min(1),
5674
- process_id: z2.string().min(1),
5675
- actor_id: z2.string().nullable(),
5743
+ event_id: z3.string().min(1),
5744
+ process_id: z3.string().min(1),
5745
+ actor_id: z3.string().nullable(),
5676
5746
  lineage: LineageSchema,
5677
5747
  input_versions: InputVersionsSchema,
5678
5748
  provenance: ProvenanceSchema
5679
5749
  }).strict();
5680
- var HeaderMetaSchema = z2.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema]);
5681
- var SubjectSchema = z2.object({
5682
- issue: z2.number().int().nullable(),
5683
- pr: z2.number().int().optional(),
5684
- sha: z2.string().optional(),
5685
- role: z2.union([RoleSchema, z2.literal("unattributed")]),
5686
- round: z2.number().int().optional(),
5687
- objectives_version: z2.string().optional()
5750
+ var WorkSchema = z3.object({
5751
+ ref: z3.string().nullable(),
5752
+ repo: z3.string().nullable(),
5753
+ change: z3.string().nullable(),
5754
+ revision: z3.string().nullable()
5688
5755
  }).strict();
5689
- var HeaderSchema = z2.object({
5756
+ var FlowSchema = z3.object({
5757
+ id: z3.string().nullable(),
5758
+ version: z3.string().nullable()
5759
+ }).strict();
5760
+ var HeaderMetaV3Schema = z3.object({
5761
+ schema: z3.literal(3),
5762
+ ...headerMetaCore,
5763
+ event_id: z3.string().min(1),
5764
+ process_id: z3.string().min(1),
5765
+ actor_id: z3.string().nullable(),
5766
+ lineage: LineageSchema,
5767
+ input_versions: InputVersionsSchema,
5768
+ provenance: ProvenanceSchema,
5769
+ work: WorkSchema,
5770
+ flow: FlowSchema,
5771
+ runtime: z3.string().nullable(),
5772
+ source: z3.string().nullable()
5773
+ }).strict();
5774
+ var HeaderMetaSchema = z3.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema, HeaderMetaV3Schema]);
5775
+ var SubjectSchema = z3.object({
5776
+ issue: z3.number().int().nullable(),
5777
+ pr: z3.number().int().optional(),
5778
+ sha: z3.string().optional(),
5779
+ role: z3.union([RoleSchema, z3.literal("unattributed")]),
5780
+ round: z3.number().int().optional(),
5781
+ objectives_version: z3.string().optional()
5782
+ }).strict();
5783
+ var HeaderSchema = z3.object({
5690
5784
  meta: HeaderMetaSchema,
5691
5785
  subject: SubjectSchema
5692
5786
  }).strict();
5693
5787
  var envelopeTail = {
5694
- duration_ms: z2.number().nonnegative().optional(),
5695
- payload: z2.object({}).strict()
5788
+ duration_ms: z3.number().nonnegative().optional(),
5789
+ payload: z3.object({}).strict()
5696
5790
  };
5697
- var ReviewFindingSchema = z2.object({
5698
- id: z2.string(),
5699
- severity: z2.string(),
5700
- state: z2.string().optional(),
5701
- severity_scale: z2.string().optional(),
5702
- policy_treatment: z2.enum(["blocking", "non_blocking", "unavailable"]).optional(),
5703
- confidence: z2.number().min(0).max(1).optional(),
5704
- confidence_scale: z2.string().optional(),
5705
- confidence_source: z2.string().optional()
5791
+ var ReviewFindingSchema = z3.object({
5792
+ id: z3.string(),
5793
+ severity: z3.string(),
5794
+ state: z3.string().optional(),
5795
+ severity_scale: z3.string().optional(),
5796
+ policy_treatment: z3.enum(["blocking", "non_blocking", "unavailable"]).optional(),
5797
+ confidence: z3.number().min(0).max(1).optional(),
5798
+ confidence_scale: z3.string().optional(),
5799
+ confidence_source: z3.string().optional()
5706
5800
  }).strict();
5707
- var DispatchOutcomeSchema = z2.discriminatedUnion("type", [
5708
- z2.object({ type: z2.literal("pr_opened"), pr: z2.number().int(), head: z2.string() }).strict(),
5709
- z2.object({
5710
- type: z2.literal("round_pushed"),
5711
- pr: z2.number().int(),
5712
- head: z2.string(),
5713
- comment_id: z2.number().int()
5801
+ var DispatchOutcomeSchema = z3.discriminatedUnion("type", [
5802
+ z3.object({ type: z3.literal("pr_opened"), pr: z3.number().int(), head: z3.string() }).strict(),
5803
+ z3.object({
5804
+ type: z3.literal("round_pushed"),
5805
+ pr: z3.number().int(),
5806
+ head: z3.string(),
5807
+ comment_id: z3.number().int()
5714
5808
  }).strict(),
5715
- z2.object({
5716
- type: z2.literal("verdict"),
5717
- verdict: z2.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
5718
- head: z2.string(),
5719
- comment_id: z2.number().int(),
5720
- objectives: z2.array(z2.object({ id: z2.string(), met: z2.boolean() }).strict()),
5721
- findings: z2.array(ReviewFindingSchema)
5809
+ z3.object({
5810
+ type: z3.literal("verdict"),
5811
+ verdict: z3.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
5812
+ head: z3.string(),
5813
+ comment_id: z3.number().int(),
5814
+ objectives: z3.array(z3.object({ id: z3.string(), met: z3.boolean() }).strict()),
5815
+ findings: z3.array(ReviewFindingSchema)
5722
5816
  }).strict(),
5723
- z2.object({
5724
- type: z2.literal("escalation"),
5725
- class: z2.enum(["authority", "strategy", "product"]),
5726
- comment_id: z2.number().int()
5817
+ z3.object({
5818
+ type: z3.literal("escalation"),
5819
+ class: z3.enum(["authority", "strategy", "product"]),
5820
+ comment_id: z3.number().int()
5727
5821
  }).strict(),
5728
- z2.object({ type: z2.literal("brief"), comment_id: z2.number().int(), hash: z2.string() }).strict(),
5729
- z2.object({ type: z2.literal("plan"), issues: z2.array(z2.number().int()) }).strict(),
5730
- z2.object({ type: z2.literal("archive"), provenance_comment_id: z2.number().int() }).strict(),
5731
- z2.object({ type: z2.literal("completed") }).strict()
5822
+ z3.object({ type: z3.literal("brief"), comment_id: z3.number().int(), hash: z3.string() }).strict(),
5823
+ z3.object({ type: z3.literal("plan"), issues: z3.array(z3.number().int()) }).strict(),
5824
+ z3.object({ type: z3.literal("archive"), provenance_comment_id: z3.number().int() }).strict(),
5825
+ z3.object({ type: z3.literal("completed") }).strict()
5732
5826
  ]);
5733
5827
  var dispatchShared = {
5734
5828
  meta: HeaderMetaSchema,
5735
5829
  subject: SubjectSchema,
5736
- kind: z2.literal("dispatch"),
5830
+ kind: z3.literal("dispatch"),
5737
5831
  ...envelopeTail,
5738
5832
  target_role: RoleSchema,
5739
- model: z2.string(),
5740
- round: z2.number().int().optional(),
5741
- effect_id: z2.string()
5833
+ model: z3.string(),
5834
+ round: z3.number().int().optional(),
5835
+ effect_id: z3.string()
5742
5836
  };
5743
- var dispatchUsageField = z2.object({ input: z2.number().nonnegative(), output: z2.number().nonnegative() }).strict().nullable();
5744
- var DispatchEventSchema = z2.discriminatedUnion("event", [
5745
- z2.object({ ...dispatchShared, event: z2.literal("dispatched"), prompt_hash: z2.string() }).strict(),
5746
- z2.object({
5837
+ var dispatchUsageField = z3.object({ input: z3.number().nonnegative(), output: z3.number().nonnegative() }).strict().nullable();
5838
+ var DispatchEventSchema = z3.discriminatedUnion("event", [
5839
+ z3.object({ ...dispatchShared, event: z3.literal("dispatched"), prompt_hash: z3.string() }).strict(),
5840
+ z3.object({
5747
5841
  ...dispatchShared,
5748
- event: z2.literal("outcome_received"),
5842
+ event: z3.literal("outcome_received"),
5749
5843
  outcome: DispatchOutcomeSchema,
5750
5844
  usage: dispatchUsageField
5751
5845
  }).strict(),
5752
- z2.object({
5846
+ z3.object({
5753
5847
  ...dispatchShared,
5754
- event: z2.literal("dispatch_failed"),
5755
- reason: z2.enum(["timeout", "crash", "refused", "unattributed_write"]),
5848
+ event: z3.literal("dispatch_failed"),
5849
+ reason: z3.enum(["timeout", "crash", "refused", "unattributed_write"]),
5756
5850
  usage: dispatchUsageField
5757
5851
  }).strict()
5758
5852
  ]);
5853
+ var CODE_TOKEN_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
5854
+ var CodeTokenSchema = z3.string().regex(CODE_TOKEN_PATTERN);
5855
+ var ReviewerVerdictSchema = z3.object({
5856
+ role: RoleSchema,
5857
+ outcome: z3.enum(["approve", "changes_requested", "not_reviewed"]),
5858
+ blockers: z3.number().int().nonnegative()
5859
+ }).strict();
5759
5860
  var loopShared = {
5760
5861
  meta: HeaderMetaSchema,
5761
5862
  subject: SubjectSchema,
5762
- kind: z2.literal("dev_review_loop"),
5863
+ kind: z3.literal("dev_review_loop"),
5763
5864
  ...envelopeTail,
5764
- loop_id: z2.string()
5865
+ loop_id: z3.string()
5765
5866
  };
5766
- var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
5767
- z2.object({
5867
+ var DevReviewLoopEventSchema = z3.discriminatedUnion("event", [
5868
+ z3.object({
5768
5869
  ...loopShared,
5769
- event: z2.literal("loop_started"),
5770
- task: z2.number().int(),
5771
- policy: z2.object({
5772
- max_rounds: z2.number().int().nonnegative(),
5773
- reviewers: z2.array(RoleSchema),
5774
- models: z2.record(RoleSchema, z2.string())
5870
+ event: z3.literal("loop_started"),
5871
+ task: z3.number().int(),
5872
+ policy: z3.object({
5873
+ max_rounds: z3.number().int().nonnegative(),
5874
+ reviewers: z3.array(RoleSchema),
5875
+ models: z3.record(RoleSchema, z3.string())
5775
5876
  }).strict()
5776
5877
  }).strict(),
5777
- z2.object({ ...loopShared, event: z2.literal("round_started"), round: z2.number().int(), base_head: z2.string() }).strict(),
5778
- z2.object({
5878
+ z3.object({ ...loopShared, event: z3.literal("round_started"), round: z3.number().int(), base_head: z3.string() }).strict(),
5879
+ z3.object({
5779
5880
  ...loopShared,
5780
- event: z2.literal("gate_result_read"),
5781
- round: z2.number().int(),
5782
- head: z2.string(),
5783
- green: z2.boolean(),
5784
- confidence_value: z2.number().int().min(0).max(100).optional(),
5785
- confidence_reason: z2.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
5786
- confidence_unavailable: z2.boolean().optional(),
5787
- extra_turn_spent: z2.boolean().optional()
5881
+ event: z3.literal("gate_result_read"),
5882
+ round: z3.number().int(),
5883
+ head: z3.string(),
5884
+ green: z3.boolean(),
5885
+ confidence_value: z3.number().int().min(0).max(100).optional(),
5886
+ confidence_reason: z3.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
5887
+ confidence_unavailable: z3.boolean().optional(),
5888
+ extra_turn_spent: z3.boolean().optional()
5788
5889
  }).strict(),
5789
- z2.object({
5890
+ z3.object({
5790
5891
  ...loopShared,
5791
- event: z2.literal("verdicts_read"),
5792
- round: z2.number().int(),
5793
- head: z2.string(),
5794
- all_approve: z2.boolean(),
5795
- blockers: z2.number().int().nonnegative(),
5796
- findings: z2.array(ReviewFindingSchema).optional()
5892
+ event: z3.literal("verdicts_read"),
5893
+ round: z3.number().int(),
5894
+ head: z3.string(),
5895
+ all_approve: z3.boolean(),
5896
+ blockers: z3.number().int().nonnegative(),
5897
+ findings: z3.array(ReviewFindingSchema).optional(),
5898
+ reviewers: z3.array(ReviewerVerdictSchema).optional()
5797
5899
  }).strict(),
5798
- z2.object({
5900
+ z3.object({
5799
5901
  ...loopShared,
5800
- event: z2.literal("findings_compared"),
5801
- round: z2.number().int(),
5802
- open: z2.array(z2.string()),
5803
- resolved: z2.array(z2.string()),
5804
- new: z2.array(z2.string()),
5805
- recurring: z2.array(z2.string())
5902
+ event: z3.literal("findings_compared"),
5903
+ round: z3.number().int(),
5904
+ open: z3.array(z3.string()),
5905
+ resolved: z3.array(z3.string()),
5906
+ new: z3.array(z3.string()),
5907
+ recurring: z3.array(z3.string())
5806
5908
  }).strict(),
5807
- z2.object({
5909
+ z3.object({
5808
5910
  ...loopShared,
5809
- event: z2.literal("stop_condition_met"),
5810
- round: z2.number().int(),
5811
- condition: z2.enum([
5911
+ event: z3.literal("stop_condition_met"),
5912
+ round: z3.number().int(),
5913
+ condition: z3.enum([
5812
5914
  "green",
5813
5915
  "max_rounds",
5814
5916
  "no_progress",
5815
5917
  "escalated",
5816
5918
  "principal_stop",
5817
5919
  "confidence",
5818
- "reappearance"
5920
+ "reappearance",
5921
+ "repeat_finding",
5922
+ "repeat_failure",
5923
+ "time_budget"
5819
5924
  ])
5820
5925
  }).strict(),
5821
- z2.object({
5926
+ z3.object({
5927
+ ...loopShared,
5928
+ event: z3.literal("paused"),
5929
+ round: z3.number().int(),
5930
+ reason: z3.enum(["escalation", "principal_item", "refreeze_needed"]),
5931
+ reason_code: CodeTokenSchema.optional()
5932
+ }).strict(),
5933
+ z3.object({
5934
+ ...loopShared,
5935
+ event: z3.literal("resumed"),
5936
+ round: z3.number().int(),
5937
+ by: z3.enum(["principal", "driver"])
5938
+ }).strict(),
5939
+ z3.object({
5822
5940
  ...loopShared,
5823
- event: z2.literal("paused"),
5824
- round: z2.number().int(),
5825
- reason: z2.enum(["escalation", "principal_item", "refreeze_needed"])
5941
+ event: z3.literal("cancelled"),
5942
+ round: z3.number().int(),
5943
+ by: z3.literal("principal")
5826
5944
  }).strict(),
5827
- z2.object({
5945
+ z3.object({
5828
5946
  ...loopShared,
5829
- event: z2.literal("resumed"),
5830
- round: z2.number().int(),
5831
- by: z2.enum(["principal", "driver"])
5947
+ event: z3.literal("unpushed_work_resume"),
5948
+ round: z3.number().int(),
5949
+ branch: z3.string(),
5950
+ detail: z3.string()
5832
5951
  }).strict(),
5833
- z2.object({
5952
+ z3.object({
5834
5953
  ...loopShared,
5835
- event: z2.literal("cancelled"),
5836
- round: z2.number().int(),
5837
- by: z2.literal("principal")
5954
+ event: z3.literal("round_ended"),
5955
+ round: z3.number().int(),
5956
+ base_head: z3.string(),
5957
+ head: z3.string(),
5958
+ files_changed: z3.number().int().nonnegative(),
5959
+ insertions: z3.number().int().nonnegative(),
5960
+ deletions: z3.number().int().nonnegative(),
5961
+ wall_ms: z3.number().nonnegative(),
5962
+ outcome: z3.enum(["green", "changes_requested", "escalated"])
5838
5963
  }).strict(),
5839
- z2.object({
5964
+ z3.object({
5840
5965
  ...loopShared,
5841
- event: z2.literal("unpushed_work_resume"),
5842
- round: z2.number().int(),
5843
- branch: z2.string(),
5844
- detail: z2.string()
5966
+ event: z3.literal("journal_finalized"),
5967
+ rounds: z3.number().int().nonnegative(),
5968
+ total_wall_ms: z3.number().nonnegative(),
5969
+ time_to_green_ms: z3.number().nonnegative().nullable(),
5970
+ files_changed_total: z3.number().int().nonnegative(),
5971
+ final_head: z3.string(),
5972
+ result: z3.enum(["merged_ready", "stopped"])
5845
5973
  }).strict(),
5846
- z2.object({
5974
+ z3.object({
5847
5975
  ...loopShared,
5848
- event: z2.literal("round_ended"),
5849
- round: z2.number().int(),
5850
- base_head: z2.string(),
5851
- head: z2.string(),
5852
- files_changed: z2.number().int().nonnegative(),
5853
- insertions: z2.number().int().nonnegative(),
5854
- deletions: z2.number().int().nonnegative(),
5855
- wall_ms: z2.number().nonnegative(),
5856
- outcome: z2.enum(["green", "changes_requested", "escalated"])
5976
+ event: z3.literal("infrastructure_retry"),
5977
+ round: z3.number().int(),
5978
+ failure_kind: z3.enum(["pause_comment_post", "developer_connection"]),
5979
+ attempts: z3.number().int().positive(),
5980
+ outcome: z3.enum(["recovered", "exhausted"])
5857
5981
  }).strict(),
5858
- z2.object({
5982
+ z3.object({
5859
5983
  ...loopShared,
5860
- event: z2.literal("journal_finalized"),
5861
- rounds: z2.number().int().nonnegative(),
5862
- total_wall_ms: z2.number().nonnegative(),
5863
- time_to_green_ms: z2.number().nonnegative().nullable(),
5864
- files_changed_total: z2.number().int().nonnegative(),
5865
- final_head: z2.string(),
5866
- result: z2.enum(["merged_ready", "stopped"])
5984
+ event: z3.literal("driver_heartbeat"),
5985
+ task: z3.number().int(),
5986
+ pr: z3.number().int().positive().optional(),
5987
+ round: z3.number().int(),
5988
+ phase: z3.string()
5867
5989
  }).strict(),
5868
- z2.object({
5990
+ z3.object({
5869
5991
  ...loopShared,
5870
- event: z2.literal("infrastructure_retry"),
5871
- round: z2.number().int(),
5872
- failure_kind: z2.enum(["pause_comment_post", "developer_connection"]),
5873
- attempts: z2.number().int().positive(),
5874
- outcome: z2.enum(["recovered", "exhausted"])
5992
+ event: z3.literal("driver_exited"),
5993
+ task: z3.number().int(),
5994
+ reason: z3.enum(["finished", "paused", "reexec", "error", "signal"]),
5995
+ last_decision: z3.string(),
5996
+ exit_code: z3.number().int().optional(),
5997
+ error_class: CodeTokenSchema.optional()
5875
5998
  }).strict()
5876
5999
  ]);
5877
- var ForgeOpSchema = z2.enum([
6000
+ var ForgeOpSchema = z3.enum([
5878
6001
  "pr.create",
5879
6002
  "pr.comment",
5880
6003
  "pr.body.replace",
@@ -5888,24 +6011,24 @@ var ForgeOpSchema = z2.enum([
5888
6011
  "label.add",
5889
6012
  "label.remove"
5890
6013
  ]);
5891
- var ForgeWriteTargetSchema = z2.object({
5892
- issue: z2.number().int().optional(),
5893
- pr: z2.number().int().optional()
6014
+ var ForgeWriteTargetSchema = z3.object({
6015
+ issue: z3.number().int().optional(),
6016
+ pr: z3.number().int().optional()
5894
6017
  }).strict();
5895
6018
  var forgeWriteShared = {
5896
6019
  meta: HeaderMetaSchema,
5897
6020
  subject: SubjectSchema,
5898
- kind: z2.literal("forge_write"),
6021
+ kind: z3.literal("forge_write"),
5899
6022
  ...envelopeTail,
5900
6023
  op: ForgeOpSchema,
5901
6024
  target: ForgeWriteTargetSchema
5902
6025
  };
5903
- var ForgeWriteEventSchema = z2.discriminatedUnion("event", [
5904
- z2.object({ ...forgeWriteShared, event: z2.literal("validated") }).strict(),
5905
- z2.object({ ...forgeWriteShared, event: z2.literal("refused"), reason: z2.string() }).strict(),
5906
- z2.object({ ...forgeWriteShared, event: z2.literal("written"), comment_ids: z2.array(z2.string()) }).strict()
6026
+ var ForgeWriteEventSchema = z3.discriminatedUnion("event", [
6027
+ z3.object({ ...forgeWriteShared, event: z3.literal("validated") }).strict(),
6028
+ z3.object({ ...forgeWriteShared, event: z3.literal("refused"), reason: z3.string() }).strict(),
6029
+ z3.object({ ...forgeWriteShared, event: z3.literal("written"), comment_ids: z3.array(z3.string()) }).strict()
5907
6030
  ]);
5908
- var GateOutcomeSchema = z2.enum([
6031
+ var GateOutcomeSchema = z3.enum([
5909
6032
  "pass",
5910
6033
  "fail",
5911
6034
  "wait",
@@ -5918,61 +6041,74 @@ var GateOutcomeSchema = z2.enum([
5918
6041
  var gateShared = {
5919
6042
  meta: HeaderMetaSchema,
5920
6043
  subject: SubjectSchema,
5921
- kind: z2.literal("gate"),
6044
+ kind: z3.literal("gate"),
5922
6045
  ...envelopeTail,
5923
- check: z2.string(),
5924
- check_version: z2.string().nullable(),
5925
- policy_version: z2.string().nullable(),
5926
- input_fingerprint: z2.string().nullable()
6046
+ check: z3.string(),
6047
+ check_version: z3.string().nullable(),
6048
+ policy_version: z3.string().nullable(),
6049
+ input_fingerprint: z3.string().nullable()
5927
6050
  };
5928
- var GateEventSchema = z2.discriminatedUnion("event", [
5929
- z2.object({
6051
+ var GateEventSchema = z3.discriminatedUnion("event", [
6052
+ z3.object({
5930
6053
  ...gateShared,
5931
- event: z2.literal("checked"),
6054
+ event: z3.literal("checked"),
5932
6055
  outcome: GateOutcomeSchema,
5933
- reason: z2.string().optional()
6056
+ reason: z3.string().optional()
6057
+ }).strict(),
6058
+ z3.object({
6059
+ meta: HeaderMetaSchema,
6060
+ subject: SubjectSchema,
6061
+ kind: z3.literal("gate"),
6062
+ ...envelopeTail,
6063
+ event: z3.literal("summary"),
6064
+ ran: z3.number().int().nonnegative(),
6065
+ passed: z3.number().int().nonnegative(),
6066
+ failed: z3.number().int().nonnegative(),
6067
+ skipped: z3.number().int().nonnegative(),
6068
+ failed_checks: z3.array(z3.string())
5934
6069
  }).strict()
5935
6070
  ]);
5936
- var OperationResultSchema = z2.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
6071
+ var OperationResultSchema = z3.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
5937
6072
  var operationShared = {
5938
6073
  meta: HeaderMetaSchema,
5939
6074
  subject: SubjectSchema,
5940
- kind: z2.literal("operation"),
6075
+ kind: z3.literal("operation"),
5941
6076
  ...envelopeTail,
5942
- operation: z2.string(),
5943
- target: z2.string().nullable()
6077
+ operation: z3.string(),
6078
+ target: z3.string().nullable()
5944
6079
  };
5945
- var OperationEventSchema = z2.discriminatedUnion("event", [
5946
- z2.object({
6080
+ var OperationEventSchema = z3.discriminatedUnion("event", [
6081
+ z3.object({
5947
6082
  ...operationShared,
5948
- event: z2.literal("completed"),
6083
+ event: z3.literal("completed"),
5949
6084
  result: OperationResultSchema,
5950
- error_class: z2.string().nullable()
6085
+ error_class: z3.string().nullable(),
6086
+ field_names: z3.array(z3.string().max(CUSTOM_FIELD_NAME_MAX_LENGTH)).max(CUSTOM_EVENT_MAX_FIELDS).optional()
5951
6087
  }).strict()
5952
6088
  ]);
5953
- var UsageUnitsSchema = z2.object({
5954
- input: z2.number().nonnegative().nullable(),
5955
- output: z2.number().nonnegative().nullable(),
5956
- cache: z2.number().nonnegative().nullable()
6089
+ var UsageUnitsSchema = z3.object({
6090
+ input: z3.number().nonnegative().nullable(),
6091
+ output: z3.number().nonnegative().nullable(),
6092
+ cache: z3.number().nonnegative().nullable()
5957
6093
  }).strict();
5958
6094
  var usageShared = {
5959
6095
  meta: HeaderMetaSchema,
5960
6096
  subject: SubjectSchema,
5961
- kind: z2.literal("usage"),
6097
+ kind: z3.literal("usage"),
5962
6098
  ...envelopeTail,
5963
- model: z2.string().nullable(),
5964
- source: z2.string(),
5965
- semantics: z2.enum(["cumulative", "delta"])
6099
+ model: z3.string().nullable(),
6100
+ source: z3.string(),
6101
+ semantics: z3.enum(["cumulative", "delta"])
5966
6102
  };
5967
- var UsageEventSchema = z2.discriminatedUnion("event", [
5968
- z2.object({
6103
+ var UsageEventSchema = z3.discriminatedUnion("event", [
6104
+ z3.object({
5969
6105
  ...usageShared,
5970
- event: z2.literal("observed"),
6106
+ event: z3.literal("observed"),
5971
6107
  units: UsageUnitsSchema,
5972
- unknown_reason: z2.string().nullable()
6108
+ unknown_reason: z3.string().nullable()
5973
6109
  }).strict()
5974
6110
  ]);
5975
- var RoleAttemptOutcomeSchema = z2.enum([
6111
+ var RoleAttemptOutcomeSchema = z3.enum([
5976
6112
  "completed",
5977
6113
  "incomplete",
5978
6114
  "infrastructure_failed",
@@ -5983,17 +6119,17 @@ var RoleAttemptOutcomeSchema = z2.enum([
5983
6119
  var roleAttemptShared = {
5984
6120
  meta: HeaderMetaSchema,
5985
6121
  subject: SubjectSchema,
5986
- kind: z2.literal("role_attempt"),
6122
+ kind: z3.literal("role_attempt"),
5987
6123
  ...envelopeTail,
5988
- actor: z2.string().nullable(),
5989
- attempt: z2.number().int().nullable(),
5990
- effect_id: z2.string(),
5991
- model: z2.string().nullable()
6124
+ actor: z3.string().nullable(),
6125
+ attempt: z3.number().int().nullable(),
6126
+ effect_id: z3.string(),
6127
+ model: z3.string().nullable()
5992
6128
  };
5993
- var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
5994
- z2.object({
6129
+ var RoleAttemptEventSchema = z3.discriminatedUnion("event", [
6130
+ z3.object({
5995
6131
  ...roleAttemptShared,
5996
- event: z2.literal("attempted"),
6132
+ event: z3.literal("attempted"),
5997
6133
  outcome: RoleAttemptOutcomeSchema,
5998
6134
  usage: dispatchUsageField
5999
6135
  }).strict()
@@ -6001,42 +6137,59 @@ var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
6001
6137
  var handoffShared = {
6002
6138
  meta: HeaderMetaSchema,
6003
6139
  subject: SubjectSchema,
6004
- kind: z2.literal("handoff"),
6140
+ kind: z3.literal("handoff"),
6005
6141
  ...envelopeTail,
6006
- class: z2.enum(["authority", "strategy", "product"]),
6007
- reason: z2.string()
6142
+ class: z3.enum(["authority", "strategy", "product"]),
6143
+ reason: z3.string()
6008
6144
  };
6009
- var HandoffEventSchema = z2.discriminatedUnion("event", [
6010
- z2.object({
6145
+ var HandoffEventSchema = z3.discriminatedUnion("event", [
6146
+ z3.object({
6011
6147
  ...handoffShared,
6012
- event: z2.literal("raised"),
6013
- requested_decision: z2.string().nullable()
6148
+ event: z3.literal("raised"),
6149
+ requested_decision: z3.string().nullable()
6014
6150
  }).strict(),
6015
- z2.object({
6151
+ z3.object({
6016
6152
  ...handoffShared,
6017
- event: z2.literal("resolved"),
6018
- resolution: z2.string().nullable(),
6019
- resolved_by: z2.string().nullable()
6153
+ event: z3.literal("resolved"),
6154
+ resolution: z3.string().nullable(),
6155
+ resolved_by: z3.string().nullable()
6020
6156
  }).strict()
6021
6157
  ]);
6022
- var EffectTargetSchema = z2.object({
6023
- kind: z2.string(),
6024
- ref: z2.string()
6158
+ var EffectTargetSchema = z3.object({
6159
+ kind: z3.string(),
6160
+ ref: z3.string()
6025
6161
  }).strict();
6026
6162
  var effectShared = {
6027
6163
  meta: HeaderMetaSchema,
6028
6164
  subject: SubjectSchema,
6029
- kind: z2.literal("effect"),
6165
+ kind: z3.literal("effect"),
6030
6166
  ...envelopeTail,
6031
- effect_id: z2.string(),
6167
+ effect_id: z3.string(),
6032
6168
  target: EffectTargetSchema
6033
6169
  };
6034
- var EffectEventSchema = z2.discriminatedUnion("event", [
6035
- z2.object({ ...effectShared, event: z2.literal("attempted") }).strict(),
6036
- z2.object({ ...effectShared, event: z2.literal("observed"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict(),
6037
- z2.object({ ...effectShared, event: z2.literal("verified"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict()
6170
+ var EffectEventSchema = z3.discriminatedUnion("event", [
6171
+ z3.object({ ...effectShared, event: z3.literal("attempted") }).strict(),
6172
+ z3.object({ ...effectShared, event: z3.literal("observed"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict(),
6173
+ z3.object({ ...effectShared, event: z3.literal("verified"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict()
6174
+ ]);
6175
+ var CustomFieldValueSchema = z3.union([z3.string().max(CUSTOM_TEXT_MAX_LENGTH), z3.number().finite(), z3.boolean()]);
6176
+ var customShared = {
6177
+ meta: HeaderMetaV3Schema,
6178
+ subject: SubjectSchema,
6179
+ kind: z3.literal("custom"),
6180
+ ...envelopeTail
6181
+ };
6182
+ var CustomEventSchema = z3.discriminatedUnion("event", [
6183
+ z3.object({
6184
+ ...customShared,
6185
+ event: z3.literal("recorded"),
6186
+ name: z3.string().max(CUSTOM_EVENT_NAME_MAX_LENGTH).regex(CUSTOM_EVENT_NAME_PATTERN),
6187
+ fields: z3.record(z3.string().max(CUSTOM_FIELD_NAME_MAX_LENGTH).regex(CUSTOM_FIELD_NAME_PATTERN), CustomFieldValueSchema).refine((f) => Object.keys(f).length <= CUSTOM_EVENT_MAX_FIELDS, {
6188
+ message: `custom: at most ${CUSTOM_EVENT_MAX_FIELDS} fields`
6189
+ })
6190
+ }).strict()
6038
6191
  ]);
6039
- var LogEventSchema = z2.union([
6192
+ var LogEventSchema = z3.union([
6040
6193
  DispatchEventSchema,
6041
6194
  DevReviewLoopEventSchema,
6042
6195
  ForgeWriteEventSchema,
@@ -6045,10 +6198,11 @@ var LogEventSchema = z2.union([
6045
6198
  UsageEventSchema,
6046
6199
  RoleAttemptEventSchema,
6047
6200
  HandoffEventSchema,
6048
- EffectEventSchema
6201
+ EffectEventSchema,
6202
+ CustomEventSchema
6049
6203
  ]);
6050
-
6051
6204
  // ../../packages/aeg-core/src/log/envelope.ts
6205
+ import { createHash as createHash5 } from "node:crypto";
6052
6206
  function isRole(value) {
6053
6207
  return value !== undefined && ROLE_VALUES.includes(value);
6054
6208
  }
@@ -6085,18 +6239,27 @@ function roundFromEnv(round) {
6085
6239
  const n = Number(round);
6086
6240
  return Number.isInteger(n) ? n : undefined;
6087
6241
  }
6242
+ function prFromEnv(pr) {
6243
+ if (pr === undefined || pr === "")
6244
+ return;
6245
+ const n = Number(pr);
6246
+ return Number.isInteger(n) && n > 0 ? n : undefined;
6247
+ }
6088
6248
  function buildHeader(input) {
6089
6249
  const role = isRole(input.env.role) ? input.env.role : "unattributed";
6090
6250
  const round = roundFromEnv(input.env.round);
6251
+ const pr = prFromEnv(input.env.pr);
6091
6252
  const subject = {
6092
6253
  issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
6093
6254
  role,
6094
6255
  ...round !== undefined ? { round } : {},
6256
+ ...pr !== undefined ? { pr } : {},
6095
6257
  ...input.subject ?? {}
6096
6258
  };
6259
+ const issue = subject.issue;
6097
6260
  return {
6098
6261
  meta: {
6099
- schema: 2,
6262
+ schema: 3,
6100
6263
  ts: input.now.toISOString(),
6101
6264
  run_id: input.runId,
6102
6265
  seq: input.seq,
@@ -6119,7 +6282,19 @@ function buildHeader(input) {
6119
6282
  ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
6120
6283
  policy_digest: input.inputVersions?.policyDigest ?? null
6121
6284
  },
6122
- provenance: provenanceFor(input)
6285
+ provenance: provenanceFor(input),
6286
+ work: {
6287
+ ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
6288
+ repo: input.repo,
6289
+ change: null,
6290
+ revision: null
6291
+ },
6292
+ flow: {
6293
+ id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
6294
+ version: lineageFieldFromEnv(input.env.flowVersion)
6295
+ },
6296
+ runtime: lineageFieldFromEnv(input.env.runtime),
6297
+ source: lineageFieldFromEnv(input.env.source)
6123
6298
  },
6124
6299
  subject
6125
6300
  };
@@ -6162,7 +6337,7 @@ function redact(value, home) {
6162
6337
  return value;
6163
6338
  }
6164
6339
  // ../../packages/aeg-core/src/log/store.ts
6165
- var KNOWN_SCHEMA_VERSIONS = [1, 2];
6340
+ var KNOWN_SCHEMA_VERSIONS = [1, 2, 3];
6166
6341
  function metaOf(obj) {
6167
6342
  if (obj === null || typeof obj !== "object")
6168
6343
  return null;
@@ -6228,7 +6403,7 @@ function classifyStoredLine(raw, home) {
6228
6403
  return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
6229
6404
  }
6230
6405
  const redacted = redact(event, home);
6231
- const provenance = version === 2 ? event.meta.provenance ?? null : null;
6406
+ const provenance = version >= 2 ? event.meta.provenance ?? null : null;
6232
6407
  return {
6233
6408
  status: "ok",
6234
6409
  identity,
@@ -6241,134 +6416,151 @@ function classifyStoredLine(raw, home) {
6241
6416
  };
6242
6417
  }
6243
6418
  // ../../packages/aeg-core/src/control-store/records.ts
6244
- import { z as z3 } from "zod";
6245
- var isoTimestamp = z3.string().min(1);
6246
- var taskId = z3.number().int().positive();
6247
- var epochNumber = z3.number().int().nonnegative();
6248
- var RunRecordSchema = z3.object({
6249
- version: z3.literal(1),
6250
- kind: z3.literal("run"),
6419
+ import { z as z4 } from "zod";
6420
+ var isoTimestamp = z4.string().min(1);
6421
+ var taskId = z4.number().int().positive();
6422
+ var epochNumber = z4.number().int().nonnegative();
6423
+ var RunRecordSchema = z4.object({
6424
+ version: z4.literal(1),
6425
+ kind: z4.literal("run"),
6251
6426
  task: taskId,
6252
- runId: z3.string().min(1),
6253
- pid: z3.number().int().positive(),
6254
- host: z3.string().min(1),
6427
+ runId: z4.string().min(1),
6428
+ pid: z4.number().int().positive(),
6429
+ host: z4.string().min(1),
6255
6430
  startedAt: isoTimestamp,
6256
- childStartedAt: z3.string().min(1).nullable().optional(),
6257
- childCommand: z3.string().min(1).nullable().optional()
6431
+ childStartedAt: z4.string().min(1).nullable().optional(),
6432
+ childCommand: z4.string().min(1).nullable().optional()
6258
6433
  }).strict();
6259
- var InputRecordSchema = z3.object({
6260
- version: z3.literal(1),
6261
- kind: z3.literal("input"),
6434
+ var InputRecordSchema = z4.object({
6435
+ version: z4.literal(1),
6436
+ kind: z4.literal("input"),
6262
6437
  task: taskId,
6263
- runId: z3.string().min(1),
6264
- source: z3.union([z3.literal("fresh"), z3.literal("resume")]),
6265
- pr: z3.number().int().positive().nullable(),
6266
- round: z3.number().int().nonnegative(),
6438
+ runId: z4.string().min(1),
6439
+ source: z4.union([z4.literal("fresh"), z4.literal("resume")]),
6440
+ pr: z4.number().int().positive().nullable(),
6441
+ round: z4.number().int().nonnegative(),
6267
6442
  recordedAt: isoTimestamp
6268
6443
  }).strict();
6269
- var OwnershipRecordSchema = z3.object({
6270
- version: z3.literal(1),
6271
- kind: z3.literal("ownership"),
6444
+ var OwnershipRecordSchema = z4.object({
6445
+ version: z4.literal(1),
6446
+ kind: z4.literal("ownership"),
6272
6447
  task: taskId,
6273
6448
  epoch: epochNumber,
6274
- ownerId: z3.string().min(1),
6275
- pid: z3.number().int().positive(),
6276
- host: z3.string().min(1),
6449
+ ownerId: z4.string().min(1),
6450
+ pid: z4.number().int().positive(),
6451
+ host: z4.string().min(1),
6277
6452
  acquiredAt: isoTimestamp
6278
6453
  }).strict();
6279
- var TransitionRecordSchema = z3.object({
6280
- version: z3.literal(1),
6281
- kind: z3.literal("transition"),
6454
+ var TransitionRecordSchema = z4.object({
6455
+ version: z4.literal(1),
6456
+ kind: z4.literal("transition"),
6282
6457
  task: taskId,
6283
6458
  epoch: epochNumber,
6284
- seq: z3.number().int().nonnegative(),
6285
- from: z3.string().min(1),
6286
- to: z3.string().min(1),
6287
- detail: z3.string().optional(),
6459
+ seq: z4.number().int().nonnegative(),
6460
+ from: z4.string().min(1),
6461
+ to: z4.string().min(1),
6462
+ detail: z4.string().optional(),
6288
6463
  at: isoTimestamp
6289
6464
  }).strict();
6290
- var ManifestRecordSchema = z3.object({
6291
- version: z3.literal(1),
6292
- kind: z3.literal("manifest"),
6465
+ var ManifestRecordSchema = z4.object({
6466
+ version: z4.literal(1),
6467
+ kind: z4.literal("manifest"),
6293
6468
  task: taskId,
6294
6469
  round: epochNumber,
6295
- repository: z3.string().min(1),
6296
- pr: z3.number().int().positive(),
6297
- branch: z3.string().min(1),
6298
- baseSha: z3.string().min(1).nullable(),
6299
- headSha: z3.string().min(1),
6300
- briefHash: z3.string().min(1).nullable(),
6301
- objectivesVersion: z3.string().min(1).nullable(),
6470
+ repository: z4.string().min(1),
6471
+ pr: z4.number().int().positive(),
6472
+ branch: z4.string().min(1),
6473
+ baseSha: z4.string().min(1).nullable(),
6474
+ headSha: z4.string().min(1),
6475
+ briefHash: z4.string().min(1).nullable(),
6476
+ objectivesVersion: z4.string().min(1).nullable(),
6302
6477
  rulingOrdinal: epochNumber,
6303
- policyDigest: z3.string().min(1),
6478
+ policyDigest: z4.string().min(1),
6304
6479
  recordedAt: isoTimestamp
6305
6480
  }).strict();
6306
- var roundHeadIdentity = z3.object({ round: z3.number().int().positive(), head: z3.string().min(1) }).strict();
6307
- var LoopBudgetsSchema = z3.object({
6308
- mechanicalRetries: z3.number().int().nonnegative(),
6309
- reviewRounds: z3.number().int().nonnegative(),
6310
- infrastructureRetries: z3.number().int().nonnegative()
6481
+ var roundHeadIdentity = z4.object({ round: z4.number().int().positive(), head: z4.string().min(1) }).strict();
6482
+ var LoopBudgetsSchema = z4.object({
6483
+ mechanicalRetries: z4.number().int().nonnegative(),
6484
+ reviewRounds: z4.number().int().nonnegative(),
6485
+ infrastructureRetries: z4.number().int().nonnegative()
6311
6486
  }).strict();
6312
- var LoopStateRecordSchema = z3.object({
6313
- version: z3.literal(1),
6314
- kind: z3.literal("loop_state"),
6487
+ var LoopStateRecordSchema = z4.object({
6488
+ version: z4.literal(1),
6489
+ kind: z4.literal("loop_state"),
6315
6490
  task: taskId,
6316
- round: z3.number().int().positive(),
6317
- phase: z3.string().min(1),
6318
- pauseReason: z3.string().min(1).nullable(),
6491
+ round: z4.number().int().positive(),
6492
+ phase: z4.string().min(1),
6493
+ pauseReason: z4.string().min(1).nullable(),
6319
6494
  budgets: LoopBudgetsSchema,
6320
6495
  heldResult: roundHeadIdentity.nullable(),
6321
6496
  deliveredFindings: roundHeadIdentity.nullable(),
6497
+ repeatMemory: z4.object({
6498
+ blockingFindings: z4.array(z4.string()),
6499
+ lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
6500
+ }).strict().optional(),
6501
+ publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
6502
+ taskStartedAt: isoTimestamp.optional(),
6503
+ phaseMs: z4.record(z4.string(), z4.number().nonnegative()).optional(),
6322
6504
  recordedAt: isoTimestamp
6323
6505
  }).strict();
6324
- var EffectRecordSchema = z3.object({
6325
- version: z3.literal(1),
6326
- kind: z3.literal("effect"),
6506
+ var EffectRecordSchema = z4.object({
6507
+ version: z4.literal(1),
6508
+ kind: z4.literal("effect"),
6327
6509
  task: taskId,
6328
- key: z3.string().min(1),
6329
- operation: z3.string().min(1),
6330
- target: z3.string().min(1),
6331
- inputVersion: z3.number().int().nonnegative(),
6332
- payloadDigest: z3.string().min(1),
6333
- status: z3.union([z3.literal("started"), z3.literal("verified"), z3.literal("uncertain")]),
6334
- url: z3.string().optional(),
6510
+ key: z4.string().min(1),
6511
+ operation: z4.string().min(1),
6512
+ target: z4.string().min(1),
6513
+ inputVersion: z4.number().int().nonnegative(),
6514
+ payloadDigest: z4.string().min(1),
6515
+ status: z4.union([z4.literal("started"), z4.literal("verified"), z4.literal("uncertain")]),
6516
+ url: z4.string().optional(),
6335
6517
  recordedAt: isoTimestamp
6336
6518
  }).strict();
6337
- var EscalationRecordSchema = z3.object({
6338
- version: z3.literal(1),
6339
- kind: z3.literal("escalation"),
6519
+ var EscalationRecordSchema = z4.object({
6520
+ version: z4.literal(1),
6521
+ kind: z4.literal("escalation"),
6340
6522
  task: taskId,
6341
- escalationId: z3.string().min(1),
6523
+ escalationId: z4.string().min(1),
6342
6524
  round: epochNumber,
6343
- head: z3.string().min(1),
6344
- branch: z3.string().min(1),
6345
- pr: z3.number().int().positive().nullable(),
6346
- runId: z3.string().min(1),
6347
- pid: z3.number().int().positive(),
6348
- host: z3.string().min(1),
6349
- agent: z3.string().min(1).optional(),
6350
- reason: z3.string().min(1),
6351
- detail: z3.string().optional(),
6352
- evidence: z3.string().optional(),
6353
- attemptedRecovery: z3.string().min(1),
6354
- requestedDecision: z3.string().min(1),
6355
- recipient: z3.string().min(1),
6356
- briefHash: z3.string().min(1).nullable(),
6357
- objectivesVersion: z3.string().min(1).nullable(),
6525
+ head: z4.string().min(1),
6526
+ branch: z4.string().min(1),
6527
+ pr: z4.number().int().positive().nullable(),
6528
+ runId: z4.string().min(1),
6529
+ pid: z4.number().int().positive(),
6530
+ host: z4.string().min(1),
6531
+ agent: z4.string().min(1).optional(),
6532
+ reason: z4.string().min(1),
6533
+ detail: z4.string().optional(),
6534
+ evidence: z4.string().optional(),
6535
+ attemptedRecovery: z4.string().min(1),
6536
+ requestedDecision: z4.string().min(1),
6537
+ recipient: z4.string().min(1),
6538
+ briefHash: z4.string().min(1).nullable(),
6539
+ objectivesVersion: z4.string().min(1).nullable(),
6358
6540
  rulingOrdinal: epochNumber,
6359
- policyDigest: z3.string().min(1),
6541
+ policyDigest: z4.string().min(1),
6360
6542
  recordedAt: isoTimestamp
6361
6543
  }).strict();
6362
- var ResolutionRecordSchema = z3.object({
6363
- version: z3.literal(1),
6364
- kind: z3.literal("resolution"),
6544
+ var ResolutionRecordSchema = z4.object({
6545
+ version: z4.literal(1),
6546
+ kind: z4.literal("resolution"),
6365
6547
  task: taskId,
6366
- escalationId: z3.string().min(1),
6367
- decision: z3.union([z3.literal("resume"), z3.literal("cancel")]),
6368
- authenticatedBy: z3.string().min(1),
6369
- authenticatedFrom: z3.string().min(1),
6548
+ escalationId: z4.string().min(1),
6549
+ decision: z4.union([z4.literal("resume"), z4.literal("cancel")]),
6550
+ authenticatedBy: z4.string().min(1),
6551
+ authenticatedFrom: z4.string().min(1),
6370
6552
  consumedAt: isoTimestamp
6371
6553
  }).strict();
6554
+ // ../../packages/aeg-core/src/control-store/local.ts
6555
+ var CONTROL_AREA_DIRNAME = "control";
6556
+ // src/lib/init-hook-paths.ts
6557
+ var TRACKED_HOOK_DIR = ".vinaya/hooks";
6558
+ var HOOK_DIRS = [".husky", ".git/hooks", TRACKED_HOOK_DIR];
6559
+ var INIT_HOOK_NAMES = ["pre-commit", "pre-push", "commit-msg"];
6560
+ function initHookPaths() {
6561
+ return HOOK_DIRS.flatMap((dir) => INIT_HOOK_NAMES.map((name) => `${dir}/${name}`));
6562
+ }
6563
+
6372
6564
  // src/checks/contract.ts
6373
6565
  var CHECK_SCHEMA_VERSION = 1;
6374
6566
  function emitCheckError(error) {
@@ -6377,8 +6569,8 @@ function emitCheckError(error) {
6377
6569
  }
6378
6570
 
6379
6571
  // src/checks/registry.ts
6380
- import { existsSync as existsSync2 } from "node:fs";
6381
- import { join as join2 } from "node:path";
6572
+ import { join as join2, relative, sep } from "node:path";
6573
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
6382
6574
 
6383
6575
  // src/lib/package-root.ts
6384
6576
  import { existsSync } from "node:fs";
@@ -6398,10 +6590,14 @@ function packageRoot(moduleUrl) {
6398
6590
  }
6399
6591
 
6400
6592
  // src/checks/registry.ts
6401
- var DIST_BIN_DIR = join2(packageRoot(import.meta.url), "dist", "checks", "bin");
6402
- var SRC_BIN_DIR = join2(packageRoot(import.meta.url), "src", "checks", "bin");
6403
- var BIN_DIR = existsSync2(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
6404
- var BIN_EXT = BIN_DIR === DIST_BIN_DIR ? ".js" : ".ts";
6593
+ function resolveCheckBin(packageDir, moduleUrl) {
6594
+ const fromPackage = relative(packageDir, fileURLToPath2(moduleUrl));
6595
+ const bundled = fromPackage === "dist" || fromPackage.startsWith(`dist${sep}`);
6596
+ return bundled ? { dir: join2(packageDir, "dist", "checks", "bin"), ext: ".js" } : { dir: join2(packageDir, "src", "checks", "bin"), ext: ".ts" };
6597
+ }
6598
+ var CHECK_BIN = resolveCheckBin(packageRoot(import.meta.url), import.meta.url);
6599
+ var BIN_DIR = CHECK_BIN.dir;
6600
+ var BIN_EXT = CHECK_BIN.ext;
6405
6601
  function bin(name) {
6406
6602
  return join2(BIN_DIR, `${name}${BIN_EXT}`);
6407
6603
  }
@@ -6599,23 +6795,6 @@ var REGISTRY = [
6599
6795
  },
6600
6796
  1
6601
6797
  ],
6602
- [
6603
- {
6604
- name: "token-report",
6605
- validates: "body",
6606
- run: bin("check-token-report"),
6607
- scope: "diff",
6608
- timeoutMs: 15000,
6609
- requiresOpenPr: true,
6610
- env: {
6611
- PR_BODY: { optional: true },
6612
- BRANCH: { optional: true },
6613
- CLAUDE_PROJECT_DIR: { optional: true },
6614
- CLAUDE_CODE_SESSION_ID: { optional: true }
6615
- }
6616
- },
6617
- 1
6618
- ],
6619
6798
  [
6620
6799
  {
6621
6800
  name: "no-disk-state",
@@ -6966,6 +7145,7 @@ var CHECK_NAME = "registry-gates";
6966
7145
  var ENFORCEMENT_PATH = "aeg-root/enforcement.md";
6967
7146
  var ROLES_DIR = "aeg-root/roles";
6968
7147
  var CONTRACTS_DIR = "aeg-root/contracts";
7148
+ var DOCTRINE_DIR = "aeg-root";
6969
7149
  function isGithubCrossingLine(line) {
6970
7150
  const createMatch = /\bgh\s+(pr|issue)\s+create\b/.test(line);
6971
7151
  const editWithBodyOrTitle = /\bgh\s+(pr|issue)\s+edit\b/.test(line) && /--body\b|--body-file\b|--title\b|(?:^|\s)-b(?:\s|$)|(?:^|\s)-F(?:\s|$)|(?:^|\s)-t(?:\s|$)/.test(line);
@@ -6976,7 +7156,7 @@ function isGithubCrossingLine(line) {
6976
7156
  }
6977
7157
  function globCandidateFiles() {
6978
7158
  const out = [];
6979
- if (existsSync3(".husky")) {
7159
+ if (existsSync2(".husky")) {
6980
7160
  for (const name of readdirSync(".husky")) {
6981
7161
  if (name === "_")
6982
7162
  continue;
@@ -6985,7 +7165,7 @@ function globCandidateFiles() {
6985
7165
  out.push(rel);
6986
7166
  }
6987
7167
  }
6988
- if (existsSync3(".claude/hooks")) {
7168
+ if (existsSync2(".claude/hooks")) {
6989
7169
  for (const name of readdirSync(".claude/hooks")) {
6990
7170
  if (name.endsWith(".sh"))
6991
7171
  out.push(`.claude/hooks/${name}`);
@@ -6997,8 +7177,24 @@ function findCrossingFiles(candidateFiles) {
6997
7177
  return candidateFiles.filter((path) => readFileSync2(path, "utf8").split(`
6998
7178
  `).some((line) => isGithubCrossingLine(line)));
6999
7179
  }
7180
+ function readHookScanFiles(dir) {
7181
+ const out = [];
7182
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
7183
+ const rel = join3(dir, entry.name);
7184
+ if (entry.isDirectory())
7185
+ out.push(...readHookScanFiles(rel));
7186
+ else if (entry.name.endsWith(".md"))
7187
+ out.push({ path: rel, content: readFileSync2(rel, "utf8") });
7188
+ }
7189
+ return out;
7190
+ }
7191
+ function shippedHookPaths() {
7192
+ const tracked = sh("git ls-files").split(`
7193
+ `).filter(Boolean);
7194
+ return new Set([...tracked, ...initHookPaths()]);
7195
+ }
7000
7196
  function readRoles() {
7001
- if (!existsSync3(ROLES_DIR))
7197
+ if (!existsSync2(ROLES_DIR))
7002
7198
  return [];
7003
7199
  return readdirSync(ROLES_DIR).filter((name) => name.endsWith(".md")).map((name) => {
7004
7200
  const rel = `${ROLES_DIR}/${name}`;
@@ -7012,7 +7208,7 @@ function readRoles() {
7012
7208
  });
7013
7209
  }
7014
7210
  function readContracts() {
7015
- if (!existsSync3(CONTRACTS_DIR))
7211
+ if (!existsSync2(CONTRACTS_DIR))
7016
7212
  return [];
7017
7213
  return readdirSync(CONTRACTS_DIR).filter((name) => name.endsWith(".md")).map((name) => {
7018
7214
  const rel = `${CONTRACTS_DIR}/${name}`;
@@ -7087,7 +7283,7 @@ function emitResult(result, blocking) {
7087
7283
  }
7088
7284
  }
7089
7285
  async function main() {
7090
- if (!existsSync3(ENFORCEMENT_PATH)) {
7286
+ if (!existsSync2(ENFORCEMENT_PATH)) {
7091
7287
  emitCheckError({
7092
7288
  schema: CHECK_SCHEMA_VERSION,
7093
7289
  check: `${CHECK_NAME}.dormant`,
@@ -7115,7 +7311,7 @@ async function main() {
7115
7311
  }
7116
7312
  ]
7117
7313
  };
7118
- const g1 = checkG1(rows, existsSync3);
7314
+ const g1 = checkG1(rows, existsSync2, { docs: readHookScanFiles(DOCTRINE_DIR), shipped: shippedHookPaths() });
7119
7315
  const g2 = checkG2(rows, candidateFiles);
7120
7316
  const g3 = checkG3(ring0Rows, crossingFiles);
7121
7317
  const g5 = checkG5(roles, contracts);