@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
@@ -1890,45 +1890,6 @@ var DERIVED_STATUSES = [
1890
1890
  "incoherent"
1891
1891
  ];
1892
1892
  var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
1893
- // ../../packages/aeg-core/src/parse-ledger.ts
1894
- function rowFromCells(cells) {
1895
- if (cells.length < 7)
1896
- return null;
1897
- const phase = (cells[0] ?? "").trim();
1898
- if (!phase)
1899
- return null;
1900
- return {
1901
- phase,
1902
- role: (cells[1] ?? "").trim(),
1903
- agentModel: (cells[2] ?? "").trim(),
1904
- tokensIn: parseIntCell(cells[3] ?? ""),
1905
- tokensOut: parseIntCell(cells[4] ?? ""),
1906
- cost: parseCostCell(cells[5] ?? ""),
1907
- date: (cells[6] ?? "").trim()
1908
- };
1909
- }
1910
- function parseIntCell(cell) {
1911
- const trimmed = cell.replace(/`/g, "").trim();
1912
- if (!trimmed || isEmDashOrDash(trimmed))
1913
- return null;
1914
- const normalized = trimmed.replace(/[,_\s]/g, "");
1915
- if (!/^-?\d+$/.test(normalized))
1916
- return null;
1917
- return Number(normalized);
1918
- }
1919
- function parseCostCell(cell) {
1920
- const trimmed = cell.replace(/`/g, "").trim();
1921
- if (!trimmed || isEmDashOrDash(trimmed))
1922
- return null;
1923
- const normalized = trimmed.replace(/^\$/, "").replace(/[,_\s]/g, "");
1924
- if (!/^-?\d+(\.\d+)?$/.test(normalized))
1925
- return null;
1926
- return Number(normalized);
1927
- }
1928
- function isEmDashOrDash(s) {
1929
- const t = s.trim();
1930
- return t === "—" || t === "-" || t === "–";
1931
- }
1932
1893
  // ../../packages/aeg-core/src/waiver-label.ts
1933
1894
  var WAIVER_LABEL = label("waiver-docs");
1934
1895
  var WAIVER_LABEL_REVIEW = label("waiver-review");
@@ -1944,61 +1905,6 @@ function isWaiverLabelActorVerified(opts) {
1944
1905
  return false;
1945
1906
  return isPrincipal(opts.labelActor, opts.principalAllowlist);
1946
1907
  }
1947
-
1948
- // ../../packages/aeg-core/src/parse-token-report.ts
1949
- var TOKEN_REPORT_HEADING = /^\s*(?:#{1,6}\s*Token report\s*|\*\*Token report\*\*)\s*$/i;
1950
- 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;
1951
- function parseTokenReportEntries(body) {
1952
- const lines = body.split(/\r?\n/);
1953
- const headingIdxs = [];
1954
- lines.forEach((line, i) => {
1955
- if (TOKEN_REPORT_HEADING.test(line))
1956
- headingIdxs.push(i);
1957
- });
1958
- const out = [];
1959
- for (let h = 0;h < headingIdxs.length; h++) {
1960
- const start = headingIdxs[h] + 1;
1961
- const end = h + 1 < headingIdxs.length ? headingIdxs[h + 1] : lines.length;
1962
- const section = lines.slice(start, end).join(`
1963
- `);
1964
- const tableRows = parseTableSection(section);
1965
- if (tableRows.length > 0) {
1966
- out.push(...tableRows);
1967
- continue;
1968
- }
1969
- const inlineRow = parseInlineFieldList(section);
1970
- if (inlineRow)
1971
- out.push(inlineRow);
1972
- }
1973
- return out;
1974
- }
1975
- function parseTableSection(section) {
1976
- const lines = section.split(/\r?\n/);
1977
- let i = 0;
1978
- for (;i < lines.length; i++) {
1979
- if ((lines[i] ?? "").trim().startsWith("|"))
1980
- break;
1981
- }
1982
- if (i + 1 >= lines.length)
1983
- return [];
1984
- i += 2;
1985
- const out = [];
1986
- for (;i < lines.length; i++) {
1987
- const trimmed = (lines[i] ?? "").trim();
1988
- if (!trimmed.startsWith("|"))
1989
- break;
1990
- const row = rowFromCells(splitTableRow(trimmed));
1991
- if (row)
1992
- out.push(row);
1993
- }
1994
- return out;
1995
- }
1996
- function parseInlineFieldList(section) {
1997
- const m = section.match(INLINE_FIELD_LIST);
1998
- if (!m)
1999
- return null;
2000
- return rowFromCells([m[1], m[2], m[3], m[4], m[5], m[6], m[7]]);
2001
- }
2002
1908
  // ../../packages/aeg-core/src/verdict-extraction.ts
2003
1909
  var HEAD_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged head:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
2004
1910
  var OBJECTIVES_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Objectives version:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
@@ -2447,10 +2353,12 @@ function evaluateC5(changed, docOwnersContent, prBody, fileExists, waiverActive,
2447
2353
  var CODE_REVIEW_SEVERITY_ORDER = ["BLOCKER", "MAJOR", "MINOR"];
2448
2354
  var SECURITY_SEVERITY_ORDER = ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
2449
2355
  var DEFAULT_MAX_ROUNDS = 3;
2356
+ var DEFAULT_MAX_TASK_MINUTES = 180;
2450
2357
  var DEFAULT_REVIEW_POLICY = {
2451
2358
  codeReviewThreshold: "BLOCKER",
2452
2359
  securityThreshold: "HIGH",
2453
- maxRounds: DEFAULT_MAX_ROUNDS
2360
+ maxRounds: DEFAULT_MAX_ROUNDS,
2361
+ maxTaskMinutes: DEFAULT_MAX_TASK_MINUTES
2454
2362
  };
2455
2363
  var FILE_SHAPED_LOCATION = /\.[a-zA-Z0-9]{1,10}(:\d+)?\s*$/;
2456
2364
  var PROSE_LOCATION_PATTERNS = [/\bpr\s*body\b/i, /\bcomment\b/i];
@@ -2470,16 +2378,42 @@ function blockingSeverities(scale, threshold) {
2470
2378
  }
2471
2379
  return scale.slice(0, idx + 1);
2472
2380
  }
2473
- function evaluateReviewFindings(findings, scale, threshold) {
2474
- const blocking = new Set(blockingSeverities(scale, threshold));
2475
- const blockingFindings = findings.filter((f) => {
2476
- if (!scale.includes(f.severity)) {
2477
- throw new Error(`evaluateReviewFindings: severity "${f.severity}" is not one of ${scale.join(" > ")}`);
2478
- }
2479
- const effectiveSeverity = f.location !== undefined && isProseLocation(f.location) ? PROSE_CAP_SEVERITY : f.severity;
2480
- return blocking.has(effectiveSeverity);
2481
- });
2482
- return { outcome: blockingFindings.length > 0 ? "blocked" : "clean", blockingFindings };
2381
+ var DEFERRAL_REASON_TEXT = {
2382
+ "unchanged-line": "unchanged line",
2383
+ "outside-surface": "outside the Surface"
2384
+ };
2385
+ var SECURITY_HIGH_AND_ABOVE = blockingSeverities(SECURITY_SEVERITY_ORDER, "HIGH");
2386
+ function classifyFinding(finding, scale, threshold, context = {}) {
2387
+ if (!scale.includes(finding.severity)) {
2388
+ throw new Error(`classifyFinding: severity "${finding.severity}" is not one of ${scale.join(" > ")}`);
2389
+ }
2390
+ const location = finding.location;
2391
+ const effectiveSeverity = location !== undefined && isProseLocation(location) ? PROSE_CAP_SEVERITY : finding.severity;
2392
+ const wouldBlock = blockingSeverities(scale, threshold).includes(effectiveSeverity);
2393
+ if (!wouldBlock)
2394
+ return { outcome: "non_blocking", deferralReason: null };
2395
+ const hasLocation = location !== undefined && location.length > 0;
2396
+ if (hasLocation && context.inSurface && !context.inSurface(location)) {
2397
+ return { outcome: "deferred", deferralReason: "outside-surface" };
2398
+ }
2399
+ if (hasLocation && context.changedLine && !SECURITY_HIGH_AND_ABOVE.includes(effectiveSeverity)) {
2400
+ if (!context.changedLine(location)) {
2401
+ return { outcome: "deferred", deferralReason: "unchanged-line" };
2402
+ }
2403
+ }
2404
+ return { outcome: "blocking", deferralReason: null };
2405
+ }
2406
+ function evaluateReviewFindings(findings, scale, threshold, context = {}) {
2407
+ const blockingFindings = [];
2408
+ const deferredFindings = [];
2409
+ for (const f of findings) {
2410
+ const c = classifyFinding(f, scale, threshold, context);
2411
+ if (c.outcome === "blocking")
2412
+ blockingFindings.push(f);
2413
+ else if (c.outcome === "deferred")
2414
+ deferredFindings.push({ finding: f, reason: c.deferralReason });
2415
+ }
2416
+ return { outcome: blockingFindings.length > 0 ? "blocked" : "clean", blockingFindings, deferredFindings };
2483
2417
  }
2484
2418
  function isConsequentialFinding(finding) {
2485
2419
  return finding.state !== "resolved";
@@ -2487,11 +2421,11 @@ function isConsequentialFinding(finding) {
2487
2421
  function consequentialFindings(findings) {
2488
2422
  return findings.filter((f) => isConsequentialFinding(f));
2489
2423
  }
2490
- function evaluateCodeReview(findings, policy) {
2491
- return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold);
2424
+ function evaluateCodeReview(findings, policy, context = {}) {
2425
+ return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold, context);
2492
2426
  }
2493
- function evaluateSecurityReview(findings, policy) {
2494
- return evaluateReviewFindings(findings, SECURITY_SEVERITY_ORDER, policy.securityThreshold);
2427
+ function evaluateSecurityReview(findings, policy, context = {}) {
2428
+ return evaluateReviewFindings(findings, SECURITY_SEVERITY_ORDER, policy.securityThreshold, context);
2495
2429
  }
2496
2430
  function isKnownSeverity(scale, value) {
2497
2431
  return scale.includes(value);
@@ -2825,11 +2759,13 @@ function checkDocUpdateList(prBody) {
2825
2759
  return headingCheck(prBody, "(?:documentation|doc)[- ]update(?:\\s+list)?", "Documentation-update list");
2826
2760
  }
2827
2761
  function checkWorktreeStep0(prBody) {
2828
- if (/git worktree add/.test(prBody))
2762
+ if (/git worktree add/.test(prBody) || /cd \.worktrees\//.test(prBody) || /bun install --frozen-lockfile/.test(prBody))
2829
2763
  return { status: "pass", errors: [] };
2830
2764
  return {
2831
2765
  status: "fail",
2832
- errors: ["brief-validation worktree Step 0: no `git worktree add` command found in the PR body."]
2766
+ errors: [
2767
+ "brief-validation worktree Step 0: no `git worktree add`, `cd .worktrees/`, or `bun install --frozen-lockfile` command found in the PR body."
2768
+ ]
2833
2769
  };
2834
2770
  }
2835
2771
  function checkStopConditions(prBody) {
@@ -3019,7 +2955,8 @@ function isCommandBlock(content) {
3019
2955
  return COMMAND_WORDS.includes(commandWordOf(firstNonBlankLine(content)));
3020
2956
  }
3021
2957
  function isStep0Block(content) {
3022
- return firstNonBlankLine(content).startsWith("git worktree add");
2958
+ const first = firstNonBlankLine(content);
2959
+ return first.startsWith("git worktree add") || first.startsWith("cd .worktrees/") || first.startsWith("bun install --frozen-lockfile");
3023
2960
  }
3024
2961
  function checkCommandsCarryOutput(prBody) {
3025
2962
  const errors = [];
@@ -3405,161 +3342,592 @@ function checkPrReportDensity(prBody) {
3405
3342
  const results = [checkDecisionsDensity(prBody), checkScopeDensity(prBody)];
3406
3343
  return { errors: results.flatMap((r) => r.errors) };
3407
3344
  }
3408
- // ../../packages/aeg-core/src/issue-validation.ts
3409
- function hasRationaleField(body, labelPattern) {
3410
- const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})`, "im");
3411
- return re.test(body);
3412
- }
3413
- var RATIONALE_FIELDS = [
3414
- { name: "Boundary", pattern: "Boundary" },
3415
- { name: "Sizing", pattern: "Sizing" },
3416
- { name: "Project(s) + blast radius", pattern: "Project\\(s\\)|Project(?:s)?\\s*\\+|blast radius" },
3417
- { name: "Dependency rationale", pattern: "Dependency rationale|Depends[- ]on" },
3418
- { name: "Traps to avoid", pattern: "Traps" },
3419
- { name: "Suggested agent-class", pattern: "(?:Suggested\\s+)?agent-class" },
3420
- { name: "Stop-and-escalate", pattern: "Stop-and-escalate" },
3421
- { name: "Docs to keep coherent", pattern: "Docs to keep coherent|§7" }
3345
+ // ../../packages/aeg-core/src/reader-resolvable-prose.ts
3346
+ var PRODUCT_SLUG_SCOPE = [
3347
+ "apps/cli/src",
3348
+ ".github/workflows",
3349
+ ".vinaya",
3350
+ "apps/cli/README.md",
3351
+ "packages/sources/README.md"
3422
3352
  ];
3423
- var DEPENDENCY_RATIONALE_FIELD_NAME = "Dependency rationale";
3424
- function checkIssueRationale(body) {
3425
- const errors = [];
3426
- for (const f of RATIONALE_FIELDS) {
3427
- if (!hasRationaleField(body, f.pattern)) {
3428
- 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).`);
3429
- continue;
3430
- }
3431
- if (f.name === DEPENDENCY_RATIONALE_FIELD_NAME && !SECTION_HEADER.test(body)) {
3432
- 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.");
3433
- }
3434
- }
3435
- return { status: errors.length > 0 ? "fail" : "pass", errors };
3436
- }
3437
- var OBJECTIVES_SINCE_ISSUE = 404;
3438
- function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
3439
- if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
3440
- return { status: "pass", errors: [] };
3441
- const result = objectivesOf(body);
3442
- if (result.ok)
3443
- return { status: "pass", errors: [] };
3444
- return { status: "fail", errors: result.errors.map((e) => `issue-validation objectives: ${e}`) };
3353
+ function isUnderOrEqual(path, prefix) {
3354
+ return path === prefix || path.startsWith(`${prefix}/`);
3445
3355
  }
3446
- function topLevelSectionText(body, headingName) {
3447
- const headingRe = new RegExp(`^##[ \\t]*${headingName}[ \\t]*$`, "im");
3448
- const heading = headingRe.exec(body);
3449
- if (!heading)
3450
- return null;
3451
- const afterHeading = body.slice(heading.index + heading[0].length);
3452
- const next = /^##[ \t]/m.exec(afterHeading);
3453
- return next ? afterHeading.slice(0, next.index) : afterHeading;
3356
+ function isProductScopeFile(path) {
3357
+ return PRODUCT_SLUG_SCOPE.some((prefix) => isUnderOrEqual(path, prefix));
3454
3358
  }
3455
- function partHasBacktickedPath(text) {
3456
- let i = 0;
3457
- while (i < text.length) {
3458
- const start = text.indexOf("`", i);
3459
- if (start === -1)
3460
- return false;
3461
- const end = text.indexOf("`", start + 1);
3462
- if (end === -1)
3463
- return false;
3464
- if (text.slice(start + 1, end).includes("/"))
3465
- return true;
3466
- i = end + 1;
3467
- }
3468
- return false;
3359
+ var SHIPS_PREFIX = "aeg-root/";
3360
+ function shipsArchivePrefix(shipsPrefix) {
3361
+ return `${shipsPrefix}tranches/completed/`;
3469
3362
  }
3470
- var PART_MIN_WORDS_OUTSIDE_BACKTICKS = 3;
3471
- function stripPartBackticks(text) {
3472
- return text.replace(/`[^`\n]*`/g, " ");
3363
+ var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
3364
+ function normalizeSpecPath(entry) {
3365
+ let out = entry.replace(/\\/g, "/");
3366
+ while (out.startsWith("./"))
3367
+ out = out.slice(2);
3368
+ out = out.replace(/\/{2,}/g, "/");
3369
+ while (out.endsWith("/"))
3370
+ out = out.slice(0, -1);
3371
+ return out;
3473
3372
  }
3474
- function partWordCount(text) {
3475
- return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
3373
+ function isSpecFile2(path, specPaths) {
3374
+ if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
3375
+ return true;
3376
+ if (!path.endsWith(".md"))
3377
+ return false;
3378
+ return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
3476
3379
  }
3477
- function looksLikeFilePath(entry) {
3478
- const stripped = entry.replace(/\/\*\*?$/, "");
3479
- const lastSegment = stripped.split("/").pop() ?? stripped;
3480
- const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
3481
- return extMatch !== null && extMatch.index > 0;
3380
+ function isClaudeMdFile(path) {
3381
+ return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
3482
3382
  }
3483
- function splitGlobList(raw) {
3484
- return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
3383
+ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
3384
+ if (path.startsWith(shipsPrefix)) {
3385
+ return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
3386
+ }
3387
+ if (path.startsWith(readerFacingPrefix) && path.endsWith(readerFacingSuffix)) {
3388
+ return "reader-facing";
3389
+ }
3390
+ if (isClaudeMdFile(path))
3391
+ return "internal";
3392
+ if (isSpecFile2(path, specPaths))
3393
+ return "spec";
3394
+ if (isProductScopeFile(path))
3395
+ return "product";
3396
+ return null;
3485
3397
  }
3486
- function parseIssueSurface(body) {
3487
- const section = topLevelSectionText(body, "Surface");
3488
- if (section === null)
3489
- return { ok: false, errors: ["no `## Surface` heading found in the body."] };
3490
- const inLine = /^in:\s*(.+)$/im.exec(section);
3491
- const outLine = /^out:\s*(.+)$/im.exec(section);
3492
- const errors = [];
3493
- if (!inLine)
3494
- errors.push("`## Surface` has no `in:` line.");
3495
- if (!outLine)
3496
- errors.push("`## Surface` has no `out:` line.");
3497
- if (errors.length > 0)
3498
- return { ok: false, errors };
3499
- const inGlobs = splitGlobList(inLine[1]);
3500
- const outGlobs = splitGlobList(outLine[1]);
3501
- for (const g of [...inGlobs, ...outGlobs]) {
3502
- if (looksLikeFilePath(g)) {
3503
- errors.push(`\`${g}\` in \`## Surface\` looks like a file path — Surface entries are directory-level globs, never file paths.`);
3504
- }
3398
+ var SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
3399
+ function stripNonProse(path, content) {
3400
+ if (path.endsWith(".md")) {
3401
+ return content.replace(/```.*?```/gs, (m) => m.replace(/[^\n]/g, "")).replace(/`[^`\n]*`/g, (m) => m.replace(/[^\n]/g, ""));
3505
3402
  }
3506
- if (inGlobs.length === 0)
3507
- errors.push("`## Surface`'s `in:` line resolved to zero globs.");
3508
- if (errors.length > 0)
3509
- return { ok: false, errors };
3510
- return { ok: true, value: { in: inGlobs, out: outGlobs } };
3403
+ if (path.endsWith(".tsx") || path.endsWith(".ts")) {
3404
+ return content.replace(/\/\*.*?\*\//gs, (m) => m.replace(/[^\n]/g, "")).replace(/(^|[^:])\/\/[^\n]*/g, (m) => m.replace(/[^\n]/g, ""));
3405
+ }
3406
+ return content;
3511
3407
  }
3512
- function globCoversPath(glob, path) {
3513
- const g = glob.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
3514
- const p = path.replace(/\/+$/, "");
3515
- if (g === "*")
3516
- return !p.includes("/");
3517
- return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
3408
+ function stripNonProseForProduct(path, content) {
3409
+ return path.endsWith(".md") ? stripNonProse(path, content) : content;
3518
3410
  }
3519
- function checkSurfaceGlobsResolve(body, resolvesToFile) {
3520
- const surface = parseIssueSurface(body);
3521
- if (!surface.ok)
3522
- return { status: "pass", errors: [] };
3523
- const errors = [];
3524
- for (const glob of surface.value.in) {
3525
- if (!resolvesToFile(glob)) {
3526
- 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.`);
3527
- }
3411
+ function lineAt(content, index) {
3412
+ let line = 1;
3413
+ for (let i = 0;i < index; i++) {
3414
+ if (content.charCodeAt(i) === 10)
3415
+ line++;
3528
3416
  }
3529
- return { status: errors.length > 0 ? "fail" : "pass", errors };
3417
+ return line;
3530
3418
  }
3531
- function checkSurfaceScope(changedFiles, outGlobs) {
3532
- if (outGlobs.length === 0)
3533
- return { ok: true };
3534
- const violations = [];
3535
- for (const file of changedFiles) {
3536
- const glob = outGlobs.find((g) => globCoversPath(g, file));
3537
- if (glob)
3538
- violations.push({ file, glob });
3539
- }
3540
- return violations.length > 0 ? { ok: false, violations } : { ok: true };
3419
+ var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
3420
+ var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
3421
+ var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
3422
+ function legacySlugPattern(legacySlugs) {
3423
+ if (legacySlugs.length === 0)
3424
+ return null;
3425
+ const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
3426
+ return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
3541
3427
  }
3542
- var ISSUE_PART_LINE_RE = /^Part\s+(\d+)\s*\(([^)]*)\)\s*[-—–]\s*(.*)$/i;
3543
- function parseIssueParts(body) {
3544
- const section = topLevelSectionText(body, "Parts");
3545
- if (section === null)
3546
- return { ok: false, errors: ["no `## Parts` heading found in the body."] };
3547
- const lines = section.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0);
3548
- const parts = [];
3549
- const errors = [];
3550
- for (const line of lines) {
3551
- const m = ISSUE_PART_LINE_RE.exec(line);
3552
- if (!m) {
3553
- errors.push(`"${line}" is not a well-formed Parts line — expected \`Part <n> (<refs>) — <outcome>\`.`);
3554
- continue;
3555
- }
3556
- const n = Number.parseInt(m[1], 10);
3557
- const refs = m[2];
3558
- const text = m[3].trim();
3559
- if (text.length === 0) {
3560
- errors.push(`Part ${n} has no outcome text after the dash — every Part states one observable outcome.`);
3561
- continue;
3562
- }
3428
+ function specGrandfatherPaths(specGrandfather) {
3429
+ return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
3430
+ }
3431
+ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
3432
+ const findings = [];
3433
+ const legacyPattern = legacySlugPattern(legacySlugs);
3434
+ const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
3435
+ const limits = new Map(Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather));
3436
+ const patterns = [
3437
+ { pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
3438
+ { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
3439
+ ...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
3440
+ ];
3441
+ const productPatterns = [
3442
+ { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
3443
+ ];
3444
+ const specPatterns = [
3445
+ ...patterns,
3446
+ { pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
3447
+ ];
3448
+ for (const file of files) {
3449
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
3450
+ if (!cls || cls === "internal")
3451
+ continue;
3452
+ if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
3453
+ continue;
3454
+ if (cls === "spec" && grandfatheredWhole.has(file.path))
3455
+ continue;
3456
+ const blocking = cls === "product" || cls === "spec";
3457
+ const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
3458
+ const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
3459
+ const fileFindings = [];
3460
+ for (const { pattern, what, group } of patternsToRun) {
3461
+ pattern.lastIndex = 0;
3462
+ let match = pattern.exec(scrubbed);
3463
+ while (match !== null) {
3464
+ const cited = group !== undefined ? match[group] ?? match[0] : match[0];
3465
+ const citedIndex = match.index + match[0].indexOf(cited);
3466
+ fileFindings.push({
3467
+ file: file.path,
3468
+ line: lineAt(scrubbed, citedIndex),
3469
+ message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
3470
+ blocking
3471
+ });
3472
+ match = pattern.exec(scrubbed);
3473
+ }
3474
+ }
3475
+ const limit = cls === "spec" ? limits.get(file.path) : undefined;
3476
+ if (limit !== undefined) {
3477
+ if (fileFindings.length <= limit)
3478
+ continue;
3479
+ for (const f of fileFindings) {
3480
+ f.message += `; ${file.path} carries ${fileFindings.length} such findings, over its proseGates.specGrandfather limit of ${limit}`;
3481
+ }
3482
+ }
3483
+ findings.push(...fileFindings);
3484
+ }
3485
+ return findings;
3486
+ }
3487
+ function escapeTerm(term) {
3488
+ return term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3489
+ }
3490
+ function containsWholeWord(text, term) {
3491
+ const escaped = escapeTerm(term);
3492
+ const re = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)`, "i");
3493
+ return re.test(text);
3494
+ }
3495
+ function findWholeWordLine(content, term) {
3496
+ const lines = content.split(`
3497
+ `);
3498
+ let lineNo = 0;
3499
+ for (const line of lines) {
3500
+ lineNo++;
3501
+ if (containsWholeWord(line, term))
3502
+ return lineNo;
3503
+ }
3504
+ return null;
3505
+ }
3506
+ function definesOrLinksGlossary(content, term) {
3507
+ const escaped = escapeTerm(term);
3508
+ const definesInline = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)[^\\n]{0,3}—`, "i").test(content);
3509
+ if (definesInline)
3510
+ return true;
3511
+ return /docs\/glossary|glossary\.md/i.test(content);
3512
+ }
3513
+ function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
3514
+ const findings = [];
3515
+ for (const file of files) {
3516
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
3517
+ if (!cls || !SWEPT_CLASSES.has(cls))
3518
+ continue;
3519
+ const scrubbed = stripNonProse(file.path, file.content);
3520
+ for (const term of glossaryTerms) {
3521
+ const line = findWholeWordLine(scrubbed, term);
3522
+ if (line === null)
3523
+ continue;
3524
+ if (definesOrLinksGlossary(scrubbed, term))
3525
+ continue;
3526
+ findings.push({
3527
+ file: file.path,
3528
+ line,
3529
+ message: `uses coined term "${term}" without defining it inline or linking the glossary`,
3530
+ blocking: false
3531
+ });
3532
+ }
3533
+ }
3534
+ return findings;
3535
+ }
3536
+ var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g;
3537
+ var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = /#[0-9]{2,}/g;
3538
+ function extractComments(path, content) {
3539
+ if (!path.endsWith(".ts") && !path.endsWith(".tsx"))
3540
+ return content.replace(/[^\n]/g, "");
3541
+ let state = "code";
3542
+ let out = "";
3543
+ const n = content.length;
3544
+ let i = 0;
3545
+ const blank = (ch) => ch === `
3546
+ ` ? `
3547
+ ` : " ";
3548
+ while (i < n) {
3549
+ const c = content[i];
3550
+ const next = i + 1 < n ? content[i + 1] : "";
3551
+ if (state === "code") {
3552
+ if (c === "/" && next === "/") {
3553
+ state = "line-comment";
3554
+ out += c;
3555
+ i++;
3556
+ continue;
3557
+ }
3558
+ if (c === "/" && next === "*") {
3559
+ state = "block-comment";
3560
+ out += c;
3561
+ i++;
3562
+ continue;
3563
+ }
3564
+ if (c === "'") {
3565
+ state = "single-quote";
3566
+ out += blank(c);
3567
+ i++;
3568
+ continue;
3569
+ }
3570
+ if (c === '"') {
3571
+ state = "double-quote";
3572
+ out += blank(c);
3573
+ i++;
3574
+ continue;
3575
+ }
3576
+ if (c === "`") {
3577
+ state = "template";
3578
+ out += blank(c);
3579
+ i++;
3580
+ continue;
3581
+ }
3582
+ out += blank(c);
3583
+ i++;
3584
+ continue;
3585
+ }
3586
+ if (state === "line-comment") {
3587
+ if (c === `
3588
+ `) {
3589
+ state = "code";
3590
+ out += `
3591
+ `;
3592
+ i++;
3593
+ continue;
3594
+ }
3595
+ out += c;
3596
+ i++;
3597
+ continue;
3598
+ }
3599
+ if (state === "block-comment") {
3600
+ if (c === "*" && next === "/") {
3601
+ out += c;
3602
+ out += next;
3603
+ state = "code";
3604
+ i += 2;
3605
+ continue;
3606
+ }
3607
+ out += c === `
3608
+ ` ? `
3609
+ ` : c;
3610
+ i++;
3611
+ continue;
3612
+ }
3613
+ const closer = state === "single-quote" ? "'" : state === "double-quote" ? '"' : "`";
3614
+ if (c === "\\") {
3615
+ out += blank(c);
3616
+ i++;
3617
+ if (i < n) {
3618
+ out += blank(content[i]);
3619
+ i++;
3620
+ }
3621
+ continue;
3622
+ }
3623
+ if (c === closer) {
3624
+ state = "code";
3625
+ out += blank(c);
3626
+ i++;
3627
+ continue;
3628
+ }
3629
+ out += blank(c);
3630
+ i++;
3631
+ }
3632
+ return out;
3633
+ }
3634
+ function checkSourceComments(files, allowlist = []) {
3635
+ const findings = [];
3636
+ const allowed = new Set(allowlist);
3637
+ const patterns = [
3638
+ { pattern: SOURCE_COMMENT_TRANCHE_SLUG_PATTERN, what: "a tranche-slug citation" },
3639
+ { pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
3640
+ ];
3641
+ for (const file of files) {
3642
+ if (!file.path.endsWith(".ts"))
3643
+ continue;
3644
+ if (allowed.has(file.path))
3645
+ continue;
3646
+ const comments = extractComments(file.path, file.content);
3647
+ for (const { pattern, what } of patterns) {
3648
+ pattern.lastIndex = 0;
3649
+ let match = pattern.exec(comments);
3650
+ while (match !== null) {
3651
+ findings.push({
3652
+ file: file.path,
3653
+ line: lineAt(comments, match.index),
3654
+ message: `comment cites ${what} ("${match[0]}") a reader outside this repo's tracker cannot resolve`,
3655
+ blocking: false
3656
+ });
3657
+ match = pattern.exec(comments);
3658
+ }
3659
+ }
3660
+ }
3661
+ return findings;
3662
+ }
3663
+ function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
3664
+ return [
3665
+ ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
3666
+ ...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
3667
+ ];
3668
+ }
3669
+ function parseGlossaryTerms(glossaryContent) {
3670
+ const terms = [];
3671
+ const re = /^\*\*(.+?)\*\* —/gm;
3672
+ let match = re.exec(glossaryContent);
3673
+ while (match !== null) {
3674
+ if (match[1] !== undefined)
3675
+ terms.push(match[1]);
3676
+ match = re.exec(glossaryContent);
3677
+ }
3678
+ return terms;
3679
+ }
3680
+
3681
+ // ../../packages/aeg-core/src/quoted-command.ts
3682
+ var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
3683
+ var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
3684
+ var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
3685
+ var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
3686
+ function isValidCitedFilePath(path) {
3687
+ if (path.length === 0)
3688
+ return false;
3689
+ if (path.startsWith("/") || path.startsWith("\\"))
3690
+ return false;
3691
+ if (/^[A-Za-z]:[\\/]/.test(path))
3692
+ return false;
3693
+ return !path.split(/[\\/]+/).includes("..");
3694
+ }
3695
+ function quotedCommandLineAt(content, index) {
3696
+ let line = 1;
3697
+ for (let i = 0;i < index; i++) {
3698
+ if (content.charCodeAt(i) === 10)
3699
+ line++;
3700
+ }
3701
+ return line;
3702
+ }
3703
+ function extractQuotedText(raw) {
3704
+ const trimmed = raw.trim();
3705
+ const fenced = /^(?:`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?(?:`{3,}|~{3,})$/.exec(trimmed);
3706
+ if (fenced)
3707
+ return (fenced[1] ?? "").trim();
3708
+ const inline = /^`([^`]+)`$/.exec(trimmed);
3709
+ if (inline)
3710
+ return (inline[1] ?? "").trim();
3711
+ return trimmed;
3712
+ }
3713
+ function findQuotesInFile(path, content) {
3714
+ const masked = maskCode(content);
3715
+ const quotes = [];
3716
+ START_PATTERN.lastIndex = 0;
3717
+ let start = START_PATTERN.exec(masked);
3718
+ while (start !== null) {
3719
+ const citedFile = start[1];
3720
+ const innerStart = start.index + start[0].length;
3721
+ const end = END_PATTERN.exec(masked.slice(innerStart));
3722
+ if (end === null) {
3723
+ START_PATTERN.lastIndex = innerStart;
3724
+ start = START_PATTERN.exec(masked);
3725
+ continue;
3726
+ }
3727
+ const innerEnd = innerStart + end.index;
3728
+ if (isValidCitedFilePath(citedFile)) {
3729
+ const quotedText = extractQuotedText(content.slice(innerStart, innerEnd));
3730
+ if (quotedText.length > 0) {
3731
+ quotes.push({ file: path, line: quotedCommandLineAt(content, innerStart), quotedText, citedFile });
3732
+ }
3733
+ }
3734
+ START_PATTERN.lastIndex = innerEnd + end[0].length;
3735
+ start = START_PATTERN.exec(masked);
3736
+ }
3737
+ return quotes;
3738
+ }
3739
+ function findCitedQuotes(files, readerFacingPrefix, readerFacingSuffix, shipsPrefix = QUOTED_COMMAND_SHIPS_PREFIX) {
3740
+ const quotes = [];
3741
+ for (const file of files) {
3742
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
3743
+ if (!cls || !QUOTED_COMMAND_SWEPT_CLASSES.has(cls))
3744
+ continue;
3745
+ quotes.push(...findQuotesInFile(file.path, file.content));
3746
+ }
3747
+ return quotes;
3748
+ }
3749
+ function evaluateCitedQuotes(citedQuotes, citedFileContents) {
3750
+ const findings = [];
3751
+ for (const quote of citedQuotes) {
3752
+ const content = citedFileContents.get(quote.citedFile);
3753
+ if (content === undefined) {
3754
+ findings.push({
3755
+ file: quote.file,
3756
+ line: quote.line,
3757
+ citedFile: quote.citedFile,
3758
+ quotedText: quote.quotedText,
3759
+ message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
3760
+ });
3761
+ continue;
3762
+ }
3763
+ if (!content.includes(quote.quotedText)) {
3764
+ findings.push({
3765
+ file: quote.file,
3766
+ line: quote.line,
3767
+ citedFile: quote.citedFile,
3768
+ quotedText: quote.quotedText,
3769
+ message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
3770
+ });
3771
+ }
3772
+ }
3773
+ return findings;
3774
+ }
3775
+
3776
+ // ../../packages/aeg-core/src/issue-validation.ts
3777
+ function hasRationaleField(body, labelPattern) {
3778
+ const re = new RegExp(`(?:\\*\\*|^#{1,4}\\s+)\\s*(?:${labelPattern})`, "im");
3779
+ return re.test(body);
3780
+ }
3781
+ var RATIONALE_FIELDS = [
3782
+ { name: "Boundary", pattern: "Boundary" },
3783
+ { name: "Sizing", pattern: "Sizing" },
3784
+ { name: "Project(s) + blast radius", pattern: "Project\\(s\\)|Project(?:s)?\\s*\\+|blast radius" },
3785
+ { name: "Dependency rationale", pattern: "Dependency rationale|Depends[- ]on" },
3786
+ { name: "Traps to avoid", pattern: "Traps" },
3787
+ { name: "Suggested agent-class", pattern: "(?:Suggested\\s+)?agent-class" },
3788
+ { name: "Stop-and-escalate", pattern: "Stop-and-escalate" },
3789
+ { name: "Docs to keep coherent", pattern: "Docs to keep coherent|§7" }
3790
+ ];
3791
+ var DEPENDENCY_RATIONALE_FIELD_NAME = "Dependency rationale";
3792
+ function checkIssueRationale(body) {
3793
+ const errors = [];
3794
+ for (const f of RATIONALE_FIELDS) {
3795
+ if (!hasRationaleField(body, f.pattern)) {
3796
+ 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).`);
3797
+ continue;
3798
+ }
3799
+ if (f.name === DEPENDENCY_RATIONALE_FIELD_NAME && !SECTION_HEADER.test(body)) {
3800
+ 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.");
3801
+ }
3802
+ }
3803
+ return { status: errors.length > 0 ? "fail" : "pass", errors };
3804
+ }
3805
+ var OBJECTIVES_SINCE_ISSUE = 404;
3806
+ function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
3807
+ if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
3808
+ return { status: "pass", errors: [] };
3809
+ const result = objectivesOf(body);
3810
+ if (result.ok)
3811
+ return { status: "pass", errors: [] };
3812
+ return { status: "fail", errors: result.errors.map((e) => `issue-validation objectives: ${e}`) };
3813
+ }
3814
+ function topLevelSectionText(body, headingName) {
3815
+ const headingRe = new RegExp(`^##[ \\t]*${headingName}[ \\t]*$`, "im");
3816
+ const heading = headingRe.exec(body);
3817
+ if (!heading)
3818
+ return null;
3819
+ const afterHeading = body.slice(heading.index + heading[0].length);
3820
+ const next = /^##[ \t]/m.exec(afterHeading);
3821
+ return next ? afterHeading.slice(0, next.index) : afterHeading;
3822
+ }
3823
+ function partHasBacktickedPath(text) {
3824
+ let i = 0;
3825
+ while (i < text.length) {
3826
+ const start = text.indexOf("`", i);
3827
+ if (start === -1)
3828
+ return false;
3829
+ const end = text.indexOf("`", start + 1);
3830
+ if (end === -1)
3831
+ return false;
3832
+ if (text.slice(start + 1, end).includes("/"))
3833
+ return true;
3834
+ i = end + 1;
3835
+ }
3836
+ return false;
3837
+ }
3838
+ var PART_MIN_WORDS_OUTSIDE_BACKTICKS = 3;
3839
+ function stripPartBackticks(text) {
3840
+ return text.replace(/`[^`\n]*`/g, " ");
3841
+ }
3842
+ function partWordCount(text) {
3843
+ return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
3844
+ }
3845
+ function looksLikeFilePath(entry) {
3846
+ const stripped = entry.replace(/\/\*\*?$/, "");
3847
+ const lastSegment = stripped.split("/").pop() ?? stripped;
3848
+ const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
3849
+ return extMatch !== null && extMatch.index > 0;
3850
+ }
3851
+ function splitGlobList(raw) {
3852
+ return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
3853
+ }
3854
+ function parseIssueSurface(body) {
3855
+ const section = topLevelSectionText(body, "Surface");
3856
+ if (section === null)
3857
+ return { ok: false, errors: ["no `## Surface` heading found in the body."] };
3858
+ const inLine = /^in:\s*(.+)$/im.exec(section);
3859
+ const outLine = /^out:\s*(.+)$/im.exec(section);
3860
+ const errors = [];
3861
+ if (!inLine)
3862
+ errors.push("`## Surface` has no `in:` line.");
3863
+ if (!outLine)
3864
+ errors.push("`## Surface` has no `out:` line.");
3865
+ if (errors.length > 0)
3866
+ return { ok: false, errors };
3867
+ const inGlobs = splitGlobList(inLine[1]);
3868
+ const outGlobs = splitGlobList(outLine[1]);
3869
+ for (const g of [...inGlobs, ...outGlobs]) {
3870
+ if (looksLikeFilePath(g)) {
3871
+ errors.push(`\`${g}\` in \`## Surface\` looks like a file path — Surface entries are directory-level globs, never file paths.`);
3872
+ }
3873
+ }
3874
+ if (inGlobs.length === 0)
3875
+ errors.push("`## Surface`'s `in:` line resolved to zero globs.");
3876
+ if (errors.length > 0)
3877
+ return { ok: false, errors };
3878
+ return { ok: true, value: { in: inGlobs, out: outGlobs } };
3879
+ }
3880
+ function globCoversPath(glob, path) {
3881
+ const g = glob.replace(/\/\*\*?$/, "").replace(/\/+$/, "");
3882
+ const p = path.replace(/\/+$/, "");
3883
+ if (g === "*")
3884
+ return !p.includes("/");
3885
+ return g === p || g.startsWith(`${p}/`) || p.startsWith(`${g}/`);
3886
+ }
3887
+ function checkSurfaceGlobsResolve(body, resolvesToFile) {
3888
+ const surface = parseIssueSurface(body);
3889
+ if (!surface.ok)
3890
+ return { status: "pass", errors: [] };
3891
+ const errors = [];
3892
+ for (const glob of surface.value.in) {
3893
+ if (!resolvesToFile(glob)) {
3894
+ 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.`);
3895
+ }
3896
+ }
3897
+ return { status: errors.length > 0 ? "fail" : "pass", errors };
3898
+ }
3899
+ function checkSurfaceScope(changedFiles, outGlobs) {
3900
+ if (outGlobs.length === 0)
3901
+ return { ok: true };
3902
+ const violations = [];
3903
+ for (const file of changedFiles) {
3904
+ const glob = outGlobs.find((g) => globCoversPath(g, file));
3905
+ if (glob)
3906
+ violations.push({ file, glob });
3907
+ }
3908
+ return violations.length > 0 ? { ok: false, violations } : { ok: true };
3909
+ }
3910
+ var ISSUE_PART_LINE_RE = /^Part\s+(\d+)\s*\(([^)]*)\)\s*[-—–]\s*(.*)$/i;
3911
+ function parseIssueParts(body) {
3912
+ const section = topLevelSectionText(body, "Parts");
3913
+ if (section === null)
3914
+ return { ok: false, errors: ["no `## Parts` heading found in the body."] };
3915
+ const lines = section.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.length > 0);
3916
+ const parts = [];
3917
+ const errors = [];
3918
+ for (const line of lines) {
3919
+ const m = ISSUE_PART_LINE_RE.exec(line);
3920
+ if (!m) {
3921
+ errors.push(`"${line}" is not a well-formed Parts line — expected \`Part <n> (<refs>) — <outcome>\`.`);
3922
+ continue;
3923
+ }
3924
+ const n = Number.parseInt(m[1], 10);
3925
+ const refs = m[2];
3926
+ const text = m[3].trim();
3927
+ if (text.length === 0) {
3928
+ errors.push(`Part ${n} has no outcome text after the dash — every Part states one observable outcome.`);
3929
+ continue;
3930
+ }
3563
3931
  if (partHasBacktickedPath(text) && partWordCount(stripPartBackticks(text)) < PART_MIN_WORDS_OUTSIDE_BACKTICKS) {
3564
3932
  errors.push(`Part ${n} is little more than a file path — a Part names an outcome and symbols, never a bare path.`);
3565
3933
  continue;
@@ -3673,6 +4041,27 @@ function checkProjectsRegistered(body, _labels, registeredNames) {
3673
4041
  }
3674
4042
  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;
3675
4043
  var DOC_PATH_RE_GLOBAL = new RegExp(DOC_PATH_RE.source, "gi");
4044
+ var FILE_EXTENSIONS = new Set([
4045
+ "ts",
4046
+ "tsx",
4047
+ "js",
4048
+ "jsx",
4049
+ "mjs",
4050
+ "cjs",
4051
+ "json",
4052
+ "jsonc",
4053
+ "md",
4054
+ "mdx",
4055
+ "yml",
4056
+ "yaml",
4057
+ "txt",
4058
+ "sh",
4059
+ "lock",
4060
+ "toml",
4061
+ "ndjson",
4062
+ "html",
4063
+ "css"
4064
+ ]);
3676
4065
 
3677
4066
  // ../../packages/aeg-core/src/task-branch-identity.ts
3678
4067
  var ISSUE_BRANCH_PATTERN = /^task\/issue-(\d+)$/;
@@ -4051,8 +4440,7 @@ function briefHash(brief) {
4051
4440
  function policyDigest(policy) {
4052
4441
  return createHash4("sha256").update(JSON.stringify({
4053
4442
  codeReviewThreshold: policy.codeReviewThreshold,
4054
- securityThreshold: policy.securityThreshold,
4055
- maxRounds: policy.maxRounds
4443
+ securityThreshold: policy.securityThreshold
4056
4444
  })).digest("hex");
4057
4445
  }
4058
4446
  function isBoundToHead(echoed, headSha) {
@@ -4118,6 +4506,15 @@ function compareManifest(echoed, current, patchIdOf) {
4118
4506
  }
4119
4507
 
4120
4508
  // ../../packages/aeg-core/src/review-gate.ts
4509
+ function renderGateDeferred(deferred) {
4510
+ if (deferred.length === 0)
4511
+ return "";
4512
+ const items = deferred.map((d) => {
4513
+ const where = d.finding.location && d.finding.location.length > 0 ? d.finding.location : "(no location)";
4514
+ return `${d.finding.severity} ${where} (${DEFERRAL_REASON_TEXT[d.reason]})`;
4515
+ }).join("; ");
4516
+ return ` ${deferred.length} finding(s) deferred, not blocking this round: ${items}.`;
4517
+ }
4121
4518
  function checkReviewGate(input) {
4122
4519
  const principalAllowlist = input.principalAllowlist ?? PRINCIPAL_ALLOWLIST;
4123
4520
  const waived = isWaiverLabelActorVerified({
@@ -4142,8 +4539,8 @@ function checkReviewGate(input) {
4142
4539
  let codeReviewPolicyEvaluation;
4143
4540
  let securityPolicyEvaluation;
4144
4541
  try {
4145
- codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy);
4146
- securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy);
4542
+ codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy, input.deferralContext);
4543
+ securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy, input.deferralContext);
4147
4544
  } catch (err) {
4148
4545
  return {
4149
4546
  verdict: "fail",
@@ -4189,10 +4586,14 @@ function checkReviewGate(input) {
4189
4586
  const securityObjectivesBound = securityBinding.objectivesVersion;
4190
4587
  const codeReviewRulingsBound = codeReviewBinding.rulingOrdinal;
4191
4588
  const securityRulingsBound = securityBinding.rulingOrdinal;
4589
+ const deferredNote = renderGateDeferred([
4590
+ ...codeReviewPolicyEvaluation.deferredFindings,
4591
+ ...securityPolicyEvaluation.deferredFindings
4592
+ ]);
4192
4593
  if (codeReviewClean && codeReviewBinding.bound && securityClean && securityBinding.bound) {
4193
4594
  return {
4194
4595
  verdict: "pass",
4195
- reason: `code-reviewer verdict is a clean APPROVE and security-review verdict is a clean PASS, both covering head ${input.headSha}.`,
4596
+ reason: `code-reviewer verdict is a clean APPROVE and security-review verdict is a clean PASS, both covering head ${input.headSha}.${deferredNote}`,
4196
4597
  waived: false
4197
4598
  };
4198
4599
  }
@@ -4234,7 +4635,7 @@ function checkReviewGate(input) {
4234
4635
  const ignoredNote = ignoredCount > 0 ? ` ${ignoredCount} verdict-shaped comment(s) from authors outside the principal allowlist were ignored.` : "";
4235
4636
  return {
4236
4637
  verdict: "fail",
4237
- 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}`,
4638
+ 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}`,
4238
4639
  waived: false
4239
4640
  };
4240
4641
  }
@@ -4349,569 +4750,194 @@ function parseEnforcementRegistry(content) {
4349
4750
  result.push({ ring, action, summary, category, description, spec, implementation, audience, line: row.line });
4350
4751
  }
4351
4752
  }
4352
- return result;
4353
- }
4354
- // ../../packages/aeg-core/src/registry-checks.ts
4355
- function checkG1(rows, existsFn) {
4356
- const findings = [];
4357
- for (const row of rows) {
4358
- if (row.implementation === "")
4359
- continue;
4360
- if (!existsFn(row.implementation)) {
4361
- findings.push({
4362
- row: row.action,
4363
- path: row.implementation,
4364
- reason: `${row.ring} row "${row.action}" names implementation "${row.implementation}", which does not exist on disk`
4365
- });
4366
- }
4367
- }
4368
- return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
4369
- }
4370
- var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
4371
- var NON_GATE_BIN_NAMES = NON_GATE_BINS;
4372
- var TWIN_CANDIDATE_EXCEPTIONS = {
4373
- "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)',
4374
- "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)`,
4375
- "apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
4376
- };
4377
- var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
4378
- function checkG2(rows, candidateFiles) {
4379
- const implementations = new Set(rows.map((r) => r.implementation).filter((p) => p !== ""));
4380
- const claimedNames = new Set(rows.flatMap((r) => claimedCheckNames(r.implementation)));
4381
- const findings = [];
4382
- for (const path of candidateFiles) {
4383
- if (implementations.has(path))
4384
- continue;
4385
- if (path.startsWith(AEG_CORE_BIN_PATH_PREFIX) && NON_GATE_BIN_NAMES.includes(basenameNoExt(path)))
4386
- continue;
4387
- if (NON_GATE_HOOK_SCRIPTS.includes(path))
4388
- continue;
4389
- if (path in TWIN_CANDIDATE_EXCEPTIONS)
4390
- continue;
4391
- const candidateNames = claimedCheckNames(path);
4392
- if (candidateNames.length > 0 && candidateNames.some((n) => claimedNames.has(n)))
4393
- continue;
4394
- findings.push({
4395
- path,
4396
- reason: `"${path}" is not named as the implementation of any row in enforcement.md's ring tables`
4397
- });
4398
- }
4399
- for (const row of rows) {
4400
- const carriesPlaceholder = [row.summary, row.description, row.spec].some((cell) => cell === SCAFFOLD_PLACEHOLDER);
4401
- if (carriesPlaceholder) {
4402
- findings.push({
4403
- row: row.action,
4404
- path: row.implementation,
4405
- reason: `${row.ring} row "${row.action}" still carries the scaffold placeholder marker — the why is owed`
4406
- });
4407
- }
4408
- }
4409
- return { check: "G2", status: findings.length > 0 ? "fail" : "pass", findings };
4410
- }
4411
- function checkG3(ring0Rows, crossingFiles) {
4412
- const ring0Implementations = new Set(ring0Rows.map((r) => r.implementation));
4413
- const findings = [];
4414
- for (const path of crossingFiles) {
4415
- if (!ring0Implementations.has(path)) {
4416
- findings.push({
4417
- path,
4418
- reason: `"${path}" makes a GitHub-crossing call but is not named by any Ring-0 row's implementation — a seventh, unlisted way into GitHub`
4419
- });
4420
- }
4421
- }
4422
- return { check: "G3", status: findings.length > 0 ? "fail" : "pass", findings };
4423
- }
4424
- function checkG4(content, resolveFn) {
4425
- const cited = new Set;
4426
- for (const hit of content.matchAll(/#(\d{3,})\b/g)) {
4427
- cited.add(Number(hit[1]));
4428
- }
4429
- const findings = [];
4430
- for (const n of cited) {
4431
- if (!resolveFn(n)) {
4432
- findings.push({
4433
- reason: `#${n} is cited in enforcement.md but does not resolve to a real Issue or PR in the forge`
4434
- });
4435
- }
4436
- }
4437
- return { check: "G4", status: findings.length > 0 ? "fail" : "pass", findings };
4438
- }
4439
- function checkG5(roles, contracts) {
4440
- const roleIds = new Set(roles.map((r) => r.role_id));
4441
- const findings = [];
4442
- for (const contract of contracts) {
4443
- if (!roleIds.has(contract.producer)) {
4444
- findings.push({
4445
- path: contract.file,
4446
- reason: `contract "${contract.file}" names producer "${contract.producer}", which is not a real role_id`
4447
- });
4448
- }
4449
- if (!roleIds.has(contract.consumer)) {
4450
- findings.push({
4451
- path: contract.file,
4452
- reason: `contract "${contract.file}" names consumer "${contract.consumer}", which is not a real role_id`
4453
- });
4454
- }
4455
- }
4456
- for (const role of roles) {
4457
- if (role.performs.length === 0) {
4458
- findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty performs array` });
4459
- }
4460
- if (role.refuses_when.trim() === "") {
4461
- findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty refuses_when` });
4462
- }
4463
- }
4464
- return { check: "G5", status: findings.length > 0 ? "fail" : "pass", findings };
4465
- }
4466
- var SHIPPED_BIN_PATH_PREFIX = "apps/cli/src/checks/bin/check-";
4467
- var AEG_CORE_BIN_PATH_PREFIX = "packages/aeg-core/bin/";
4468
- function basenameNoExt(path) {
4469
- const base = path.slice(path.lastIndexOf("/") + 1);
4470
- return base.replace(/\.ts$/, "");
4471
- }
4472
- function claimedCheckNames(implementation) {
4473
- if (implementation.startsWith(SHIPPED_BIN_PATH_PREFIX) && implementation.endsWith(".ts")) {
4474
- return [implementation.slice(SHIPPED_BIN_PATH_PREFIX.length, -".ts".length)];
4475
- }
4476
- if (implementation.startsWith(AEG_CORE_BIN_PATH_PREFIX)) {
4477
- const audience = GATE_AUDIENCE[basenameNoExt(implementation)];
4478
- if (audience && isShipped(audience)) {
4479
- return Array.isArray(audience.shippedAs) ? audience.shippedAs : [audience.shippedAs];
4480
- }
4481
- }
4482
- return [];
4483
- }
4484
- function checkG6(rows, registeredCheckNames) {
4485
- const findings = [];
4486
- for (const row of rows) {
4487
- if (row.audience !== "product")
4488
- continue;
4489
- const candidates = claimedCheckNames(row.implementation);
4490
- if (!candidates.some((name) => registeredCheckNames.has(name))) {
4491
- findings.push({
4492
- row: row.action,
4493
- path: row.implementation,
4494
- reason: `${row.ring} row "${row.action}" is marked \`product\` but its implementation "${row.implementation}" does not resolve to a coreCheckRegistry() entry`
4495
- });
4496
- }
4497
- }
4498
- return { check: "G6", status: findings.length > 0 ? "fail" : "pass", findings };
4499
- }
4500
- // ../../packages/aeg-core/src/reader-resolvable-prose.ts
4501
- var PRODUCT_SLUG_SCOPE = [
4502
- "apps/cli/src",
4503
- ".github/workflows",
4504
- ".vinaya",
4505
- "apps/cli/README.md",
4506
- "packages/sources/README.md"
4507
- ];
4508
- function isUnderOrEqual(path, prefix) {
4509
- return path === prefix || path.startsWith(`${prefix}/`);
4510
- }
4511
- function isProductScopeFile(path) {
4512
- return PRODUCT_SLUG_SCOPE.some((prefix) => isUnderOrEqual(path, prefix));
4513
- }
4514
- var SHIPS_PREFIX = "aeg-root/";
4515
- function shipsArchivePrefix(shipsPrefix) {
4516
- return `${shipsPrefix}tranches/completed/`;
4517
- }
4518
- var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
4519
- function normalizeSpecPath(entry) {
4520
- let out = entry.replace(/\\/g, "/");
4521
- while (out.startsWith("./"))
4522
- out = out.slice(2);
4523
- out = out.replace(/\/{2,}/g, "/");
4524
- while (out.endsWith("/"))
4525
- out = out.slice(0, -1);
4526
- return out;
4527
- }
4528
- function isSpecFile2(path, specPaths) {
4529
- if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
4530
- return true;
4531
- if (!path.endsWith(".md"))
4532
- return false;
4533
- return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
4534
- }
4535
- function isClaudeMdFile(path) {
4536
- return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
4537
- }
4538
- function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
4539
- if (path.startsWith(shipsPrefix)) {
4540
- return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
4541
- }
4542
- if (path.startsWith(readerFacingPrefix) && path.endsWith(readerFacingSuffix)) {
4543
- return "reader-facing";
4544
- }
4545
- if (isClaudeMdFile(path))
4546
- return "internal";
4547
- if (isSpecFile2(path, specPaths))
4548
- return "spec";
4549
- if (isProductScopeFile(path))
4550
- return "product";
4551
- return null;
4552
- }
4553
- var SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
4554
- function stripNonProse(path, content) {
4555
- if (path.endsWith(".md")) {
4556
- return content.replace(/```.*?```/gs, (m) => m.replace(/[^\n]/g, "")).replace(/`[^`\n]*`/g, (m) => m.replace(/[^\n]/g, ""));
4557
- }
4558
- if (path.endsWith(".tsx") || path.endsWith(".ts")) {
4559
- return content.replace(/\/\*.*?\*\//gs, (m) => m.replace(/[^\n]/g, "")).replace(/(^|[^:])\/\/[^\n]*/g, (m) => m.replace(/[^\n]/g, ""));
4560
- }
4561
- return content;
4753
+ return result;
4562
4754
  }
4563
- function stripNonProseForProduct(path, content) {
4564
- return path.endsWith(".md") ? stripNonProse(path, content) : content;
4755
+ // ../../packages/aeg-core/src/registry-checks.ts
4756
+ var HOOK_DIR_PREFIXES = [".claude/hooks/", ".vinaya/hooks/", ".husky/", ".git/hooks/"];
4757
+ var BARE_HOOK_NAME = /^check-[A-Za-z0-9_.-]*\.sh$/;
4758
+ function basename(path) {
4759
+ return path.slice(path.lastIndexOf("/") + 1);
4565
4760
  }
4566
- function lineAt(content, index) {
4761
+ function lineOf(content, index) {
4567
4762
  let line = 1;
4568
- for (let i = 0;i < index; i++) {
4763
+ for (let i = 0;i < index; i++)
4569
4764
  if (content.charCodeAt(i) === 10)
4570
4765
  line++;
4571
- }
4572
4766
  return line;
4573
4767
  }
4574
- var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
4575
- var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
4576
- var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
4577
- function legacySlugPattern(legacySlugs) {
4578
- if (legacySlugs.length === 0)
4579
- return null;
4580
- const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
4581
- return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
4582
- }
4583
- function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4768
+ function findUnshippedHookRefs(docs, shipped) {
4769
+ const shippedNames = new Set([...shipped].map(basename));
4584
4770
  const findings = [];
4585
- const legacyPattern = legacySlugPattern(legacySlugs);
4586
- const grandfathered = new Set(specGrandfather);
4587
- const patterns = [
4588
- { pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
4589
- { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
4590
- ...legacyPattern ? [{ pattern: legacyPattern, what: "an internal tranche slug", group: 2 }] : []
4591
- ];
4592
- const productPatterns = [
4593
- { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
4594
- ];
4595
- const specPatterns = [
4596
- ...patterns,
4597
- { pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
4598
- ];
4599
- for (const file of files) {
4600
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
4601
- if (!cls || cls === "internal")
4602
- continue;
4603
- if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
4604
- continue;
4605
- if (cls === "spec" && grandfathered.has(file.path))
4606
- continue;
4607
- const blocking = cls === "product" || cls === "spec";
4608
- const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
4609
- const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
4610
- for (const { pattern, what, group } of patternsToRun) {
4611
- pattern.lastIndex = 0;
4612
- let match = pattern.exec(scrubbed);
4613
- while (match !== null) {
4614
- const cited = group !== undefined ? match[group] ?? match[0] : match[0];
4615
- const citedIndex = match.index + match[0].indexOf(cited);
4616
- findings.push({
4617
- file: file.path,
4618
- line: lineAt(scrubbed, citedIndex),
4619
- message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
4620
- blocking
4621
- });
4622
- match = pattern.exec(scrubbed);
4623
- }
4771
+ const flag = (doc, token, index) => {
4772
+ findings.push({
4773
+ path: doc.path,
4774
+ reason: `${doc.path}:${lineOf(doc.content, index)} names hook "${token}", which is neither tracked in git nor emitted by \`vinaya init\``
4775
+ });
4776
+ };
4777
+ for (const doc of docs) {
4778
+ for (const { cited, index } of extractCitedPaths(doc.content)) {
4779
+ if (cited.endsWith("/") || !HOOK_DIR_PREFIXES.some((p) => cited.startsWith(p)))
4780
+ continue;
4781
+ if (!shipped.has(cited))
4782
+ flag(doc, cited, index);
4783
+ }
4784
+ const spanPattern = /`([^`\n]+)`/g;
4785
+ let match = spanPattern.exec(doc.content);
4786
+ while (match !== null) {
4787
+ const token = match[1] ?? "";
4788
+ if (BARE_HOOK_NAME.test(token) && !shippedNames.has(token))
4789
+ flag(doc, token, match.index);
4790
+ match = spanPattern.exec(doc.content);
4624
4791
  }
4625
4792
  }
4626
4793
  return findings;
4627
4794
  }
4628
- function escapeTerm(term) {
4629
- return term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4630
- }
4631
- function containsWholeWord(text, term) {
4632
- const escaped = escapeTerm(term);
4633
- const re = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)`, "i");
4634
- return re.test(text);
4635
- }
4636
- function findWholeWordLine(content, term) {
4637
- const lines = content.split(`
4638
- `);
4639
- let lineNo = 0;
4640
- for (const line of lines) {
4641
- lineNo++;
4642
- if (containsWholeWord(line, term))
4643
- return lineNo;
4644
- }
4645
- return null;
4646
- }
4647
- function definesOrLinksGlossary(content, term) {
4648
- const escaped = escapeTerm(term);
4649
- const definesInline = new RegExp(`(^|[^a-zA-Z])${escaped}([^a-zA-Z]|$)[^\\n]{0,3}—`, "i").test(content);
4650
- if (definesInline)
4651
- return true;
4652
- return /docs\/glossary|glossary\.md/i.test(content);
4653
- }
4654
- function checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
4795
+ function checkG1(rows, existsFn, hookRefs) {
4655
4796
  const findings = [];
4656
- for (const file of files) {
4657
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
4658
- if (!cls || !SWEPT_CLASSES.has(cls))
4797
+ for (const row of rows) {
4798
+ if (row.implementation === "")
4659
4799
  continue;
4660
- const scrubbed = stripNonProse(file.path, file.content);
4661
- for (const term of glossaryTerms) {
4662
- const line = findWholeWordLine(scrubbed, term);
4663
- if (line === null)
4664
- continue;
4665
- if (definesOrLinksGlossary(scrubbed, term))
4666
- continue;
4800
+ if (!existsFn(row.implementation)) {
4667
4801
  findings.push({
4668
- file: file.path,
4669
- line,
4670
- message: `uses coined term "${term}" without defining it inline or linking the glossary`,
4671
- blocking: false
4802
+ row: row.action,
4803
+ path: row.implementation,
4804
+ reason: `${row.ring} row "${row.action}" names implementation "${row.implementation}", which does not exist on disk`
4672
4805
  });
4673
4806
  }
4674
4807
  }
4675
- return findings;
4808
+ if (hookRefs)
4809
+ findings.push(...findUnshippedHookRefs(hookRefs.docs, hookRefs.shipped));
4810
+ return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
4676
4811
  }
4677
- var SOURCE_COMMENT_TRANCHE_SLUG_PATTERN = /[a-z0-9]+(?:-[a-z0-9]+)*-v[0-9]+/g;
4678
- var SOURCE_COMMENT_FORGE_NUMBER_PATTERN = /#[0-9]{2,}/g;
4679
- function extractComments(path, content) {
4680
- if (!path.endsWith(".ts") && !path.endsWith(".tsx"))
4681
- return content.replace(/[^\n]/g, "");
4682
- let state = "code";
4683
- let out = "";
4684
- const n = content.length;
4685
- let i = 0;
4686
- const blank = (ch) => ch === `
4687
- ` ? `
4688
- ` : " ";
4689
- while (i < n) {
4690
- const c = content[i];
4691
- const next = i + 1 < n ? content[i + 1] : "";
4692
- if (state === "code") {
4693
- if (c === "/" && next === "/") {
4694
- state = "line-comment";
4695
- out += c;
4696
- i++;
4697
- continue;
4698
- }
4699
- if (c === "/" && next === "*") {
4700
- state = "block-comment";
4701
- out += c;
4702
- i++;
4703
- continue;
4704
- }
4705
- if (c === "'") {
4706
- state = "single-quote";
4707
- out += blank(c);
4708
- i++;
4709
- continue;
4710
- }
4711
- if (c === '"') {
4712
- state = "double-quote";
4713
- out += blank(c);
4714
- i++;
4715
- continue;
4716
- }
4717
- if (c === "`") {
4718
- state = "template";
4719
- out += blank(c);
4720
- i++;
4721
- continue;
4722
- }
4723
- out += blank(c);
4724
- i++;
4812
+ var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
4813
+ var NON_GATE_BIN_NAMES = NON_GATE_BINS;
4814
+ var TWIN_CANDIDATE_EXCEPTIONS = {
4815
+ "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)',
4816
+ "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)`,
4817
+ "apps/cli/src/checks/bin/check-closes-n.ts": 'Ring 1 "Closes linkage" (implementation: verify-coherence.ts)'
4818
+ };
4819
+ var NON_GATE_HOOK_SCRIPTS = [".claude/hooks/track-transcript.sh"];
4820
+ function checkG2(rows, candidateFiles) {
4821
+ const implementations = new Set(rows.map((r) => r.implementation).filter((p) => p !== ""));
4822
+ const claimedNames = new Set(rows.flatMap((r) => claimedCheckNames(r.implementation)));
4823
+ const findings = [];
4824
+ for (const path of candidateFiles) {
4825
+ if (implementations.has(path))
4725
4826
  continue;
4726
- }
4727
- if (state === "line-comment") {
4728
- if (c === `
4729
- `) {
4730
- state = "code";
4731
- out += `
4732
- `;
4733
- i++;
4734
- continue;
4735
- }
4736
- out += c;
4737
- i++;
4827
+ if (path.startsWith(AEG_CORE_BIN_PATH_PREFIX) && NON_GATE_BIN_NAMES.includes(basenameNoExt(path)))
4738
4828
  continue;
4739
- }
4740
- if (state === "block-comment") {
4741
- if (c === "*" && next === "/") {
4742
- out += c;
4743
- out += next;
4744
- state = "code";
4745
- i += 2;
4746
- continue;
4747
- }
4748
- out += c === `
4749
- ` ? `
4750
- ` : c;
4751
- i++;
4829
+ if (NON_GATE_HOOK_SCRIPTS.includes(path))
4752
4830
  continue;
4753
- }
4754
- const closer = state === "single-quote" ? "'" : state === "double-quote" ? '"' : "`";
4755
- if (c === "\\") {
4756
- out += blank(c);
4757
- i++;
4758
- if (i < n) {
4759
- out += blank(content[i]);
4760
- i++;
4761
- }
4831
+ if (path in TWIN_CANDIDATE_EXCEPTIONS)
4762
4832
  continue;
4763
- }
4764
- if (c === closer) {
4765
- state = "code";
4766
- out += blank(c);
4767
- i++;
4833
+ const candidateNames = claimedCheckNames(path);
4834
+ if (candidateNames.length > 0 && candidateNames.some((n) => claimedNames.has(n)))
4768
4835
  continue;
4769
- }
4770
- out += blank(c);
4771
- i++;
4836
+ findings.push({
4837
+ path,
4838
+ reason: `"${path}" is not named as the implementation of any row in enforcement.md's ring tables`
4839
+ });
4772
4840
  }
4773
- return out;
4774
- }
4775
- function checkSourceComments(files, allowlist = []) {
4776
- const findings = [];
4777
- const allowed = new Set(allowlist);
4778
- const patterns = [
4779
- { pattern: SOURCE_COMMENT_TRANCHE_SLUG_PATTERN, what: "a tranche-slug citation" },
4780
- { pattern: SOURCE_COMMENT_FORGE_NUMBER_PATTERN, what: "a forge-number citation" }
4781
- ];
4782
- for (const file of files) {
4783
- if (!file.path.endsWith(".ts"))
4784
- continue;
4785
- if (allowed.has(file.path))
4786
- continue;
4787
- const comments = extractComments(file.path, file.content);
4788
- for (const { pattern, what } of patterns) {
4789
- pattern.lastIndex = 0;
4790
- let match = pattern.exec(comments);
4791
- while (match !== null) {
4792
- findings.push({
4793
- file: file.path,
4794
- line: lineAt(comments, match.index),
4795
- message: `comment cites ${what} ("${match[0]}") a reader outside this repo's tracker cannot resolve`,
4796
- blocking: false
4797
- });
4798
- match = pattern.exec(comments);
4799
- }
4841
+ for (const row of rows) {
4842
+ const carriesPlaceholder = [row.summary, row.description, row.spec].some((cell) => cell === SCAFFOLD_PLACEHOLDER);
4843
+ if (carriesPlaceholder) {
4844
+ findings.push({
4845
+ row: row.action,
4846
+ path: row.implementation,
4847
+ reason: `${row.ring} row "${row.action}" still carries the scaffold placeholder marker — the why is owed`
4848
+ });
4800
4849
  }
4801
4850
  }
4802
- return findings;
4803
- }
4804
- function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4805
- return [
4806
- ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
4807
- ...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
4808
- ];
4851
+ return { check: "G2", status: findings.length > 0 ? "fail" : "pass", findings };
4809
4852
  }
4810
- function parseGlossaryTerms(glossaryContent) {
4811
- const terms = [];
4812
- const re = /^\*\*(.+?)\*\* —/gm;
4813
- let match = re.exec(glossaryContent);
4814
- while (match !== null) {
4815
- if (match[1] !== undefined)
4816
- terms.push(match[1]);
4817
- match = re.exec(glossaryContent);
4853
+ function checkG3(ring0Rows, crossingFiles) {
4854
+ const ring0Implementations = new Set(ring0Rows.map((r) => r.implementation));
4855
+ const findings = [];
4856
+ for (const path of crossingFiles) {
4857
+ if (!ring0Implementations.has(path)) {
4858
+ findings.push({
4859
+ path,
4860
+ reason: `"${path}" makes a GitHub-crossing call but is not named by any Ring-0 row's implementation — a seventh, unlisted way into GitHub`
4861
+ });
4862
+ }
4818
4863
  }
4819
- return terms;
4820
- }
4821
-
4822
- // ../../packages/aeg-core/src/quoted-command.ts
4823
- var QUOTED_COMMAND_SHIPS_PREFIX = "aeg-root/";
4824
- var QUOTED_COMMAND_SWEPT_CLASSES = new Set(["ships", "reader-facing"]);
4825
- var START_PATTERN = /<!--\s*AEG:QUOTES-FILE:START:(\S+?)\s*-->/g;
4826
- var END_PATTERN = /<!--\s*AEG:QUOTES-FILE:END\s*-->/;
4827
- function isValidCitedFilePath(path) {
4828
- if (path.length === 0)
4829
- return false;
4830
- if (path.startsWith("/") || path.startsWith("\\"))
4831
- return false;
4832
- if (/^[A-Za-z]:[\\/]/.test(path))
4833
- return false;
4834
- return !path.split(/[\\/]+/).includes("..");
4864
+ return { check: "G3", status: findings.length > 0 ? "fail" : "pass", findings };
4835
4865
  }
4836
- function quotedCommandLineAt(content, index) {
4837
- let line = 1;
4838
- for (let i = 0;i < index; i++) {
4839
- if (content.charCodeAt(i) === 10)
4840
- line++;
4866
+ function checkG4(content, resolveFn) {
4867
+ const cited = new Set;
4868
+ for (const hit of content.matchAll(/#(\d{3,})\b/g)) {
4869
+ cited.add(Number(hit[1]));
4841
4870
  }
4842
- return line;
4843
- }
4844
- function extractQuotedText(raw) {
4845
- const trimmed = raw.trim();
4846
- const fenced = /^(?:`{3,}|~{3,})[^\n]*\n([\s\S]*?)\n?(?:`{3,}|~{3,})$/.exec(trimmed);
4847
- if (fenced)
4848
- return (fenced[1] ?? "").trim();
4849
- const inline = /^`([^`]+)`$/.exec(trimmed);
4850
- if (inline)
4851
- return (inline[1] ?? "").trim();
4852
- return trimmed;
4871
+ const findings = [];
4872
+ for (const n of cited) {
4873
+ if (!resolveFn(n)) {
4874
+ findings.push({
4875
+ reason: `#${n} is cited in enforcement.md but does not resolve to a real Issue or PR in the forge`
4876
+ });
4877
+ }
4878
+ }
4879
+ return { check: "G4", status: findings.length > 0 ? "fail" : "pass", findings };
4853
4880
  }
4854
- function findQuotesInFile(path, content) {
4855
- const masked = maskCode(content);
4856
- const quotes = [];
4857
- START_PATTERN.lastIndex = 0;
4858
- let start = START_PATTERN.exec(masked);
4859
- while (start !== null) {
4860
- const citedFile = start[1];
4861
- const innerStart = start.index + start[0].length;
4862
- const end = END_PATTERN.exec(masked.slice(innerStart));
4863
- if (end === null) {
4864
- START_PATTERN.lastIndex = innerStart;
4865
- start = START_PATTERN.exec(masked);
4866
- continue;
4881
+ function checkG5(roles, contracts) {
4882
+ const roleIds = new Set(roles.map((r) => r.role_id));
4883
+ const findings = [];
4884
+ for (const contract of contracts) {
4885
+ if (!roleIds.has(contract.producer)) {
4886
+ findings.push({
4887
+ path: contract.file,
4888
+ reason: `contract "${contract.file}" names producer "${contract.producer}", which is not a real role_id`
4889
+ });
4867
4890
  }
4868
- const innerEnd = innerStart + end.index;
4869
- if (isValidCitedFilePath(citedFile)) {
4870
- const quotedText = extractQuotedText(content.slice(innerStart, innerEnd));
4871
- if (quotedText.length > 0) {
4872
- quotes.push({ file: path, line: quotedCommandLineAt(content, innerStart), quotedText, citedFile });
4873
- }
4891
+ if (!roleIds.has(contract.consumer)) {
4892
+ findings.push({
4893
+ path: contract.file,
4894
+ reason: `contract "${contract.file}" names consumer "${contract.consumer}", which is not a real role_id`
4895
+ });
4874
4896
  }
4875
- START_PATTERN.lastIndex = innerEnd + end[0].length;
4876
- start = START_PATTERN.exec(masked);
4877
4897
  }
4878
- return quotes;
4898
+ for (const role of roles) {
4899
+ if (role.performs.length === 0) {
4900
+ findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty performs array` });
4901
+ }
4902
+ if (role.refuses_when.trim() === "") {
4903
+ findings.push({ path: role.file, reason: `role "${role.role_id}" has an empty refuses_when` });
4904
+ }
4905
+ }
4906
+ return { check: "G5", status: findings.length > 0 ? "fail" : "pass", findings };
4879
4907
  }
4880
- function findCitedQuotes(files, readerFacingPrefix, readerFacingSuffix, shipsPrefix = QUOTED_COMMAND_SHIPS_PREFIX) {
4881
- const quotes = [];
4882
- for (const file of files) {
4883
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
4884
- if (!cls || !QUOTED_COMMAND_SWEPT_CLASSES.has(cls))
4885
- continue;
4886
- quotes.push(...findQuotesInFile(file.path, file.content));
4908
+ var SHIPPED_BIN_PATH_PREFIX = "apps/cli/src/checks/bin/check-";
4909
+ var AEG_CORE_BIN_PATH_PREFIX = "packages/aeg-core/bin/";
4910
+ function basenameNoExt(path) {
4911
+ const base = path.slice(path.lastIndexOf("/") + 1);
4912
+ return base.replace(/\.ts$/, "");
4913
+ }
4914
+ function claimedCheckNames(implementation) {
4915
+ if (implementation.startsWith(SHIPPED_BIN_PATH_PREFIX) && implementation.endsWith(".ts")) {
4916
+ return [implementation.slice(SHIPPED_BIN_PATH_PREFIX.length, -".ts".length)];
4887
4917
  }
4888
- return quotes;
4918
+ if (implementation.startsWith(AEG_CORE_BIN_PATH_PREFIX)) {
4919
+ const audience = GATE_AUDIENCE[basenameNoExt(implementation)];
4920
+ if (audience && isShipped(audience)) {
4921
+ return Array.isArray(audience.shippedAs) ? audience.shippedAs : [audience.shippedAs];
4922
+ }
4923
+ }
4924
+ return [];
4889
4925
  }
4890
- function evaluateCitedQuotes(citedQuotes, citedFileContents) {
4926
+ function checkG6(rows, registeredCheckNames) {
4891
4927
  const findings = [];
4892
- for (const quote of citedQuotes) {
4893
- const content = citedFileContents.get(quote.citedFile);
4894
- if (content === undefined) {
4895
- findings.push({
4896
- file: quote.file,
4897
- line: quote.line,
4898
- citedFile: quote.citedFile,
4899
- quotedText: quote.quotedText,
4900
- message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but that file could not be read`
4901
- });
4928
+ for (const row of rows) {
4929
+ if (row.audience !== "product")
4902
4930
  continue;
4903
- }
4904
- if (!content.includes(quote.quotedText)) {
4931
+ const candidates = claimedCheckNames(row.implementation);
4932
+ if (!candidates.some((name) => registeredCheckNames.has(name))) {
4905
4933
  findings.push({
4906
- file: quote.file,
4907
- line: quote.line,
4908
- citedFile: quote.citedFile,
4909
- quotedText: quote.quotedText,
4910
- message: `${quote.file}:${quote.line} quotes "${quote.quotedText}" as citing \`${quote.citedFile}\`, but \`${quote.citedFile}\` no longer contains that text verbatim`
4934
+ row: row.action,
4935
+ path: row.implementation,
4936
+ reason: `${row.ring} row "${row.action}" is marked \`product\` but its implementation "${row.implementation}" does not resolve to a coreCheckRegistry() entry`
4911
4937
  });
4912
4938
  }
4913
4939
  }
4914
- return findings;
4940
+ return { check: "G6", status: findings.length > 0 ? "fail" : "pass", findings };
4915
4941
  }
4916
4942
  // ../../packages/aeg-core/src/dead-branch-push-guard.ts
4917
4943
  function checkDeadBranchPush(input) {
@@ -5334,7 +5360,6 @@ var TaskPrPauseSchema = z.object({
5334
5360
  var TaskPrReviewRecordSchema = z.object({
5335
5361
  verdicts: z.array(TaskPrVerdictSchema),
5336
5362
  roundMarkers: z.array(z.number().int().nonnegative()),
5337
- summaryTable: z.string().nullable(),
5338
5363
  pause: TaskPrPauseSchema.nullable()
5339
5364
  });
5340
5365
  var TaskPrReadInputSchema = z.object({
@@ -5381,16 +5406,6 @@ var TaskCancelResultSchema = z.object({
5381
5406
  authenticatedFrom: z.string().min(1),
5382
5407
  fencedEffectKeys: z.array(z.string())
5383
5408
  });
5384
- var TASK_TOOL_NAMES = [
5385
- "task_start",
5386
- "task_status",
5387
- "task_escalation_read",
5388
- "task_pr_read",
5389
- "task_resume",
5390
- "task_cancel"
5391
- ];
5392
- var OPERATOR_STATUS_FOLLOW = "task_status_follow";
5393
- var OPERATOR_TOOL_GRANT = [...TASK_TOOL_NAMES, OPERATOR_STATUS_FOLLOW];
5394
5409
  // ../../packages/aeg-core/src/first-push-dispatch-gate.ts
5395
5410
  function parseTaskBranch(branch) {
5396
5411
  const m = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
@@ -5621,15 +5636,69 @@ var NO_GATE_CUTOVERS = {
5621
5636
  briefRulesSincePr: null,
5622
5637
  agentBoxesRefusedSincePr: null
5623
5638
  };
5624
- // ../../packages/aeg-core/src/dev-review-loop/types.ts
5625
- var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5626
- // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
5627
- var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
5628
- // ../../packages/aeg-core/src/log/envelope.ts
5629
- import { createHash as createHash5 } from "node:crypto";
5630
-
5631
5639
  // ../../packages/aeg-core/src/log/schema.ts
5640
+ import { z as z3 } from "zod";
5641
+
5642
+ // ../../packages/aeg-core/src/log/custom.ts
5632
5643
  import { z as z2 } from "zod";
5644
+ var CUSTOM_EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]*\.[a-z][a-z0-9_.]*$/;
5645
+ var CUSTOM_EVENT_NAME_MAX_LENGTH = 64;
5646
+ var CUSTOM_EVENT_RESERVED_NAMESPACE = "vinaya";
5647
+ var CUSTOM_EVENT_MAX_FIELDS = 20;
5648
+ var CUSTOM_FIELD_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
5649
+ var CUSTOM_FIELD_NAME_MAX_LENGTH = 64;
5650
+ var CUSTOM_TEXT_MAX_LENGTH = 500;
5651
+ var CUSTOM_WORD_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
5652
+ var CUSTOM_WORD_MAX_LENGTH = 64;
5653
+ var CUSTOM_FIELD_MAX_WORDS = 50;
5654
+ var CustomFieldTypeSchema = z2.union([z2.enum(["text", "number", "boolean"]), z2.array(z2.string())]);
5655
+ var CustomEventDeclarationsSchema = z2.record(z2.string(), z2.object({
5656
+ fields: z2.record(z2.string(), CustomFieldTypeSchema)
5657
+ }).strict()).superRefine((events, ctx) => {
5658
+ for (const [name, declaration] of Object.entries(events)) {
5659
+ const refuse = (message, path = []) => {
5660
+ ctx.addIssue({
5661
+ code: z2.ZodIssueCode.custom,
5662
+ path: [name, ...path],
5663
+ message: `logs.events "${name}": ${message}`
5664
+ });
5665
+ };
5666
+ if (name.length > CUSTOM_EVENT_NAME_MAX_LENGTH) {
5667
+ refuse(`the name must be at most ${CUSTOM_EVENT_NAME_MAX_LENGTH} characters`);
5668
+ }
5669
+ if (!CUSTOM_EVENT_NAME_PATTERN.test(name)) {
5670
+ refuse("the name must be `<namespace>.<event>` — lowercase letters, digits and `_`, a dot between them");
5671
+ } else if (name.split(".")[0] === CUSTOM_EVENT_RESERVED_NAMESPACE) {
5672
+ refuse(`the \`${CUSTOM_EVENT_RESERVED_NAMESPACE}.\` namespace is reserved for Vinaya's own events`);
5673
+ }
5674
+ const fieldEntries = Object.entries(declaration.fields);
5675
+ if (fieldEntries.length > CUSTOM_EVENT_MAX_FIELDS) {
5676
+ refuse(`at most ${CUSTOM_EVENT_MAX_FIELDS} fields may be declared (found ${fieldEntries.length})`, ["fields"]);
5677
+ }
5678
+ for (const [field, type] of fieldEntries) {
5679
+ if (field.length > CUSTOM_FIELD_NAME_MAX_LENGTH || !CUSTOM_FIELD_NAME_PATTERN.test(field)) {
5680
+ 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]);
5681
+ }
5682
+ if (typeof type === "string")
5683
+ continue;
5684
+ if (type.length === 0) {
5685
+ refuse(`field "${field}": a list of words must name at least one word`, ["fields", field]);
5686
+ }
5687
+ if (type.length > CUSTOM_FIELD_MAX_WORDS) {
5688
+ refuse(`field "${field}": a list of words may name at most ${CUSTOM_FIELD_MAX_WORDS}`, ["fields", field]);
5689
+ }
5690
+ const bad = type.filter((w) => w.length > CUSTOM_WORD_MAX_LENGTH || !CUSTOM_WORD_PATTERN.test(w));
5691
+ if (bad.length > 0) {
5692
+ refuse(`field "${field}": a listed word is lowercase letters, digits, \`_\` and \`-\`, at most ${CUSTOM_WORD_MAX_LENGTH} characters`, ["fields", field]);
5693
+ }
5694
+ if (new Set(type).size !== type.length) {
5695
+ refuse(`field "${field}": a list of words names a word twice`, ["fields", field]);
5696
+ }
5697
+ }
5698
+ }
5699
+ });
5700
+
5701
+ // ../../packages/aeg-core/src/log/schema.ts
5633
5702
  var CONFIDENCE_REASON_MAX_LENGTH = 280;
5634
5703
  var ROLE_VALUES = [
5635
5704
  "planner",
@@ -5640,244 +5709,297 @@ var ROLE_VALUES = [
5640
5709
  "archivist",
5641
5710
  "architect"
5642
5711
  ];
5643
- var RoleSchema = z2.enum(ROLE_VALUES);
5712
+ var RoleSchema = z3.enum(ROLE_VALUES);
5644
5713
  var HOST_VALUES = ["hook", "ci", "cli", "loop"];
5645
- var HostSchema = z2.enum(HOST_VALUES);
5714
+ var HostSchema = z3.enum(HOST_VALUES);
5646
5715
  var RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
5647
5716
  var headerMetaCore = {
5648
- ts: z2.string(),
5649
- run_id: z2.string().regex(RUN_ID_PATTERN),
5650
- seq: z2.number().int().nonnegative(),
5651
- repo: z2.string().nullable(),
5652
- vinaya: z2.string(),
5653
- doctrine: z2.string(),
5717
+ ts: z3.string(),
5718
+ run_id: z3.string().regex(RUN_ID_PATTERN),
5719
+ seq: z3.number().int().nonnegative(),
5720
+ repo: z3.string().nullable(),
5721
+ vinaya: z3.string(),
5722
+ doctrine: z3.string(),
5654
5723
  host: HostSchema,
5655
- machine: z2.string()
5724
+ machine: z3.string()
5656
5725
  };
5657
- var HeaderMetaV1Schema = z2.object({
5658
- schema: z2.literal(1),
5726
+ var HeaderMetaV1Schema = z3.object({
5727
+ schema: z3.literal(1),
5659
5728
  ...headerMetaCore
5660
5729
  }).strict();
5661
- var LineageSchema = z2.object({
5662
- run: z2.string().nullable(),
5663
- attempt: z2.number().int().nullable(),
5664
- parent: z2.string().nullable()
5730
+ var LineageSchema = z3.object({
5731
+ run: z3.string().nullable(),
5732
+ attempt: z3.number().int().nullable(),
5733
+ parent: z3.string().nullable()
5665
5734
  }).strict();
5666
- var InputVersionsSchema = z2.object({
5667
- objectives_version: z2.string().nullable(),
5668
- brief_hash: z2.string().nullable(),
5669
- ruling_ordinal: z2.number().int().nullable(),
5670
- policy_digest: z2.string().nullable()
5735
+ var InputVersionsSchema = z3.object({
5736
+ objectives_version: z3.string().nullable(),
5737
+ brief_hash: z3.string().nullable(),
5738
+ ruling_ordinal: z3.number().int().nullable(),
5739
+ policy_digest: z3.string().nullable()
5671
5740
  }).strict();
5672
- var ProvenanceSchema = z2.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
5673
- var HeaderMetaV2Schema = z2.object({
5674
- schema: z2.literal(2),
5741
+ var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
5742
+ var HeaderMetaV2Schema = z3.object({
5743
+ schema: z3.literal(2),
5675
5744
  ...headerMetaCore,
5676
- event_id: z2.string().min(1),
5677
- process_id: z2.string().min(1),
5678
- actor_id: z2.string().nullable(),
5745
+ event_id: z3.string().min(1),
5746
+ process_id: z3.string().min(1),
5747
+ actor_id: z3.string().nullable(),
5679
5748
  lineage: LineageSchema,
5680
5749
  input_versions: InputVersionsSchema,
5681
5750
  provenance: ProvenanceSchema
5682
5751
  }).strict();
5683
- var HeaderMetaSchema = z2.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema]);
5684
- var SubjectSchema = z2.object({
5685
- issue: z2.number().int().nullable(),
5686
- pr: z2.number().int().optional(),
5687
- sha: z2.string().optional(),
5688
- role: z2.union([RoleSchema, z2.literal("unattributed")]),
5689
- round: z2.number().int().optional(),
5690
- objectives_version: z2.string().optional()
5752
+ var WorkSchema = z3.object({
5753
+ ref: z3.string().nullable(),
5754
+ repo: z3.string().nullable(),
5755
+ change: z3.string().nullable(),
5756
+ revision: z3.string().nullable()
5757
+ }).strict();
5758
+ var FlowSchema = z3.object({
5759
+ id: z3.string().nullable(),
5760
+ version: z3.string().nullable()
5761
+ }).strict();
5762
+ var HeaderMetaV3Schema = z3.object({
5763
+ schema: z3.literal(3),
5764
+ ...headerMetaCore,
5765
+ event_id: z3.string().min(1),
5766
+ process_id: z3.string().min(1),
5767
+ actor_id: z3.string().nullable(),
5768
+ lineage: LineageSchema,
5769
+ input_versions: InputVersionsSchema,
5770
+ provenance: ProvenanceSchema,
5771
+ work: WorkSchema,
5772
+ flow: FlowSchema,
5773
+ runtime: z3.string().nullable(),
5774
+ source: z3.string().nullable()
5775
+ }).strict();
5776
+ var HeaderMetaSchema = z3.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema, HeaderMetaV3Schema]);
5777
+ var SubjectSchema = z3.object({
5778
+ issue: z3.number().int().nullable(),
5779
+ pr: z3.number().int().optional(),
5780
+ sha: z3.string().optional(),
5781
+ role: z3.union([RoleSchema, z3.literal("unattributed")]),
5782
+ round: z3.number().int().optional(),
5783
+ objectives_version: z3.string().optional()
5691
5784
  }).strict();
5692
- var HeaderSchema = z2.object({
5785
+ var HeaderSchema = z3.object({
5693
5786
  meta: HeaderMetaSchema,
5694
5787
  subject: SubjectSchema
5695
5788
  }).strict();
5696
5789
  var envelopeTail = {
5697
- duration_ms: z2.number().nonnegative().optional(),
5698
- payload: z2.object({}).strict()
5790
+ duration_ms: z3.number().nonnegative().optional(),
5791
+ payload: z3.object({}).strict()
5699
5792
  };
5700
- var ReviewFindingSchema = z2.object({
5701
- id: z2.string(),
5702
- severity: z2.string(),
5703
- state: z2.string().optional(),
5704
- severity_scale: z2.string().optional(),
5705
- policy_treatment: z2.enum(["blocking", "non_blocking", "unavailable"]).optional(),
5706
- confidence: z2.number().min(0).max(1).optional(),
5707
- confidence_scale: z2.string().optional(),
5708
- confidence_source: z2.string().optional()
5793
+ var ReviewFindingSchema = z3.object({
5794
+ id: z3.string(),
5795
+ severity: z3.string(),
5796
+ state: z3.string().optional(),
5797
+ severity_scale: z3.string().optional(),
5798
+ policy_treatment: z3.enum(["blocking", "non_blocking", "unavailable"]).optional(),
5799
+ confidence: z3.number().min(0).max(1).optional(),
5800
+ confidence_scale: z3.string().optional(),
5801
+ confidence_source: z3.string().optional()
5709
5802
  }).strict();
5710
- var DispatchOutcomeSchema = z2.discriminatedUnion("type", [
5711
- z2.object({ type: z2.literal("pr_opened"), pr: z2.number().int(), head: z2.string() }).strict(),
5712
- z2.object({
5713
- type: z2.literal("round_pushed"),
5714
- pr: z2.number().int(),
5715
- head: z2.string(),
5716
- comment_id: z2.number().int()
5803
+ var DispatchOutcomeSchema = z3.discriminatedUnion("type", [
5804
+ z3.object({ type: z3.literal("pr_opened"), pr: z3.number().int(), head: z3.string() }).strict(),
5805
+ z3.object({
5806
+ type: z3.literal("round_pushed"),
5807
+ pr: z3.number().int(),
5808
+ head: z3.string(),
5809
+ comment_id: z3.number().int()
5717
5810
  }).strict(),
5718
- z2.object({
5719
- type: z2.literal("verdict"),
5720
- verdict: z2.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
5721
- head: z2.string(),
5722
- comment_id: z2.number().int(),
5723
- objectives: z2.array(z2.object({ id: z2.string(), met: z2.boolean() }).strict()),
5724
- findings: z2.array(ReviewFindingSchema)
5811
+ z3.object({
5812
+ type: z3.literal("verdict"),
5813
+ verdict: z3.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
5814
+ head: z3.string(),
5815
+ comment_id: z3.number().int(),
5816
+ objectives: z3.array(z3.object({ id: z3.string(), met: z3.boolean() }).strict()),
5817
+ findings: z3.array(ReviewFindingSchema)
5725
5818
  }).strict(),
5726
- z2.object({
5727
- type: z2.literal("escalation"),
5728
- class: z2.enum(["authority", "strategy", "product"]),
5729
- comment_id: z2.number().int()
5819
+ z3.object({
5820
+ type: z3.literal("escalation"),
5821
+ class: z3.enum(["authority", "strategy", "product"]),
5822
+ comment_id: z3.number().int()
5730
5823
  }).strict(),
5731
- z2.object({ type: z2.literal("brief"), comment_id: z2.number().int(), hash: z2.string() }).strict(),
5732
- z2.object({ type: z2.literal("plan"), issues: z2.array(z2.number().int()) }).strict(),
5733
- z2.object({ type: z2.literal("archive"), provenance_comment_id: z2.number().int() }).strict(),
5734
- z2.object({ type: z2.literal("completed") }).strict()
5824
+ z3.object({ type: z3.literal("brief"), comment_id: z3.number().int(), hash: z3.string() }).strict(),
5825
+ z3.object({ type: z3.literal("plan"), issues: z3.array(z3.number().int()) }).strict(),
5826
+ z3.object({ type: z3.literal("archive"), provenance_comment_id: z3.number().int() }).strict(),
5827
+ z3.object({ type: z3.literal("completed") }).strict()
5735
5828
  ]);
5736
5829
  var dispatchShared = {
5737
5830
  meta: HeaderMetaSchema,
5738
5831
  subject: SubjectSchema,
5739
- kind: z2.literal("dispatch"),
5832
+ kind: z3.literal("dispatch"),
5740
5833
  ...envelopeTail,
5741
5834
  target_role: RoleSchema,
5742
- model: z2.string(),
5743
- round: z2.number().int().optional(),
5744
- effect_id: z2.string()
5835
+ model: z3.string(),
5836
+ round: z3.number().int().optional(),
5837
+ effect_id: z3.string()
5745
5838
  };
5746
- var dispatchUsageField = z2.object({ input: z2.number().nonnegative(), output: z2.number().nonnegative() }).strict().nullable();
5747
- var DispatchEventSchema = z2.discriminatedUnion("event", [
5748
- z2.object({ ...dispatchShared, event: z2.literal("dispatched"), prompt_hash: z2.string() }).strict(),
5749
- z2.object({
5839
+ var dispatchUsageField = z3.object({ input: z3.number().nonnegative(), output: z3.number().nonnegative() }).strict().nullable();
5840
+ var DispatchEventSchema = z3.discriminatedUnion("event", [
5841
+ z3.object({ ...dispatchShared, event: z3.literal("dispatched"), prompt_hash: z3.string() }).strict(),
5842
+ z3.object({
5750
5843
  ...dispatchShared,
5751
- event: z2.literal("outcome_received"),
5844
+ event: z3.literal("outcome_received"),
5752
5845
  outcome: DispatchOutcomeSchema,
5753
5846
  usage: dispatchUsageField
5754
5847
  }).strict(),
5755
- z2.object({
5848
+ z3.object({
5756
5849
  ...dispatchShared,
5757
- event: z2.literal("dispatch_failed"),
5758
- reason: z2.enum(["timeout", "crash", "refused", "unattributed_write"]),
5850
+ event: z3.literal("dispatch_failed"),
5851
+ reason: z3.enum(["timeout", "crash", "refused", "unattributed_write"]),
5759
5852
  usage: dispatchUsageField
5760
5853
  }).strict()
5761
5854
  ]);
5855
+ var CODE_TOKEN_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
5856
+ var CodeTokenSchema = z3.string().regex(CODE_TOKEN_PATTERN);
5857
+ var ReviewerVerdictSchema = z3.object({
5858
+ role: RoleSchema,
5859
+ outcome: z3.enum(["approve", "changes_requested", "not_reviewed"]),
5860
+ blockers: z3.number().int().nonnegative()
5861
+ }).strict();
5762
5862
  var loopShared = {
5763
5863
  meta: HeaderMetaSchema,
5764
5864
  subject: SubjectSchema,
5765
- kind: z2.literal("dev_review_loop"),
5865
+ kind: z3.literal("dev_review_loop"),
5766
5866
  ...envelopeTail,
5767
- loop_id: z2.string()
5867
+ loop_id: z3.string()
5768
5868
  };
5769
- var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
5770
- z2.object({
5869
+ var DevReviewLoopEventSchema = z3.discriminatedUnion("event", [
5870
+ z3.object({
5771
5871
  ...loopShared,
5772
- event: z2.literal("loop_started"),
5773
- task: z2.number().int(),
5774
- policy: z2.object({
5775
- max_rounds: z2.number().int().nonnegative(),
5776
- reviewers: z2.array(RoleSchema),
5777
- models: z2.record(RoleSchema, z2.string())
5872
+ event: z3.literal("loop_started"),
5873
+ task: z3.number().int(),
5874
+ policy: z3.object({
5875
+ max_rounds: z3.number().int().nonnegative(),
5876
+ reviewers: z3.array(RoleSchema),
5877
+ models: z3.record(RoleSchema, z3.string())
5778
5878
  }).strict()
5779
5879
  }).strict(),
5780
- z2.object({ ...loopShared, event: z2.literal("round_started"), round: z2.number().int(), base_head: z2.string() }).strict(),
5781
- z2.object({
5880
+ z3.object({ ...loopShared, event: z3.literal("round_started"), round: z3.number().int(), base_head: z3.string() }).strict(),
5881
+ z3.object({
5782
5882
  ...loopShared,
5783
- event: z2.literal("gate_result_read"),
5784
- round: z2.number().int(),
5785
- head: z2.string(),
5786
- green: z2.boolean(),
5787
- confidence_value: z2.number().int().min(0).max(100).optional(),
5788
- confidence_reason: z2.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
5789
- confidence_unavailable: z2.boolean().optional(),
5790
- extra_turn_spent: z2.boolean().optional()
5883
+ event: z3.literal("gate_result_read"),
5884
+ round: z3.number().int(),
5885
+ head: z3.string(),
5886
+ green: z3.boolean(),
5887
+ confidence_value: z3.number().int().min(0).max(100).optional(),
5888
+ confidence_reason: z3.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
5889
+ confidence_unavailable: z3.boolean().optional(),
5890
+ extra_turn_spent: z3.boolean().optional()
5791
5891
  }).strict(),
5792
- z2.object({
5892
+ z3.object({
5793
5893
  ...loopShared,
5794
- event: z2.literal("verdicts_read"),
5795
- round: z2.number().int(),
5796
- head: z2.string(),
5797
- all_approve: z2.boolean(),
5798
- blockers: z2.number().int().nonnegative(),
5799
- findings: z2.array(ReviewFindingSchema).optional()
5894
+ event: z3.literal("verdicts_read"),
5895
+ round: z3.number().int(),
5896
+ head: z3.string(),
5897
+ all_approve: z3.boolean(),
5898
+ blockers: z3.number().int().nonnegative(),
5899
+ findings: z3.array(ReviewFindingSchema).optional(),
5900
+ reviewers: z3.array(ReviewerVerdictSchema).optional()
5800
5901
  }).strict(),
5801
- z2.object({
5902
+ z3.object({
5802
5903
  ...loopShared,
5803
- event: z2.literal("findings_compared"),
5804
- round: z2.number().int(),
5805
- open: z2.array(z2.string()),
5806
- resolved: z2.array(z2.string()),
5807
- new: z2.array(z2.string()),
5808
- recurring: z2.array(z2.string())
5904
+ event: z3.literal("findings_compared"),
5905
+ round: z3.number().int(),
5906
+ open: z3.array(z3.string()),
5907
+ resolved: z3.array(z3.string()),
5908
+ new: z3.array(z3.string()),
5909
+ recurring: z3.array(z3.string())
5809
5910
  }).strict(),
5810
- z2.object({
5911
+ z3.object({
5811
5912
  ...loopShared,
5812
- event: z2.literal("stop_condition_met"),
5813
- round: z2.number().int(),
5814
- condition: z2.enum([
5913
+ event: z3.literal("stop_condition_met"),
5914
+ round: z3.number().int(),
5915
+ condition: z3.enum([
5815
5916
  "green",
5816
5917
  "max_rounds",
5817
5918
  "no_progress",
5818
5919
  "escalated",
5819
5920
  "principal_stop",
5820
5921
  "confidence",
5821
- "reappearance"
5922
+ "reappearance",
5923
+ "repeat_finding",
5924
+ "repeat_failure",
5925
+ "time_budget"
5822
5926
  ])
5823
5927
  }).strict(),
5824
- z2.object({
5928
+ z3.object({
5929
+ ...loopShared,
5930
+ event: z3.literal("paused"),
5931
+ round: z3.number().int(),
5932
+ reason: z3.enum(["escalation", "principal_item", "refreeze_needed"]),
5933
+ reason_code: CodeTokenSchema.optional()
5934
+ }).strict(),
5935
+ z3.object({
5936
+ ...loopShared,
5937
+ event: z3.literal("resumed"),
5938
+ round: z3.number().int(),
5939
+ by: z3.enum(["principal", "driver"])
5940
+ }).strict(),
5941
+ z3.object({
5825
5942
  ...loopShared,
5826
- event: z2.literal("paused"),
5827
- round: z2.number().int(),
5828
- reason: z2.enum(["escalation", "principal_item", "refreeze_needed"])
5943
+ event: z3.literal("cancelled"),
5944
+ round: z3.number().int(),
5945
+ by: z3.literal("principal")
5829
5946
  }).strict(),
5830
- z2.object({
5947
+ z3.object({
5831
5948
  ...loopShared,
5832
- event: z2.literal("resumed"),
5833
- round: z2.number().int(),
5834
- by: z2.enum(["principal", "driver"])
5949
+ event: z3.literal("unpushed_work_resume"),
5950
+ round: z3.number().int(),
5951
+ branch: z3.string(),
5952
+ detail: z3.string()
5835
5953
  }).strict(),
5836
- z2.object({
5954
+ z3.object({
5837
5955
  ...loopShared,
5838
- event: z2.literal("cancelled"),
5839
- round: z2.number().int(),
5840
- by: z2.literal("principal")
5956
+ event: z3.literal("round_ended"),
5957
+ round: z3.number().int(),
5958
+ base_head: z3.string(),
5959
+ head: z3.string(),
5960
+ files_changed: z3.number().int().nonnegative(),
5961
+ insertions: z3.number().int().nonnegative(),
5962
+ deletions: z3.number().int().nonnegative(),
5963
+ wall_ms: z3.number().nonnegative(),
5964
+ outcome: z3.enum(["green", "changes_requested", "escalated"])
5841
5965
  }).strict(),
5842
- z2.object({
5966
+ z3.object({
5843
5967
  ...loopShared,
5844
- event: z2.literal("unpushed_work_resume"),
5845
- round: z2.number().int(),
5846
- branch: z2.string(),
5847
- detail: z2.string()
5968
+ event: z3.literal("journal_finalized"),
5969
+ rounds: z3.number().int().nonnegative(),
5970
+ total_wall_ms: z3.number().nonnegative(),
5971
+ time_to_green_ms: z3.number().nonnegative().nullable(),
5972
+ files_changed_total: z3.number().int().nonnegative(),
5973
+ final_head: z3.string(),
5974
+ result: z3.enum(["merged_ready", "stopped"])
5848
5975
  }).strict(),
5849
- z2.object({
5976
+ z3.object({
5850
5977
  ...loopShared,
5851
- event: z2.literal("round_ended"),
5852
- round: z2.number().int(),
5853
- base_head: z2.string(),
5854
- head: z2.string(),
5855
- files_changed: z2.number().int().nonnegative(),
5856
- insertions: z2.number().int().nonnegative(),
5857
- deletions: z2.number().int().nonnegative(),
5858
- wall_ms: z2.number().nonnegative(),
5859
- outcome: z2.enum(["green", "changes_requested", "escalated"])
5978
+ event: z3.literal("infrastructure_retry"),
5979
+ round: z3.number().int(),
5980
+ failure_kind: z3.enum(["pause_comment_post", "developer_connection"]),
5981
+ attempts: z3.number().int().positive(),
5982
+ outcome: z3.enum(["recovered", "exhausted"])
5860
5983
  }).strict(),
5861
- z2.object({
5984
+ z3.object({
5862
5985
  ...loopShared,
5863
- event: z2.literal("journal_finalized"),
5864
- rounds: z2.number().int().nonnegative(),
5865
- total_wall_ms: z2.number().nonnegative(),
5866
- time_to_green_ms: z2.number().nonnegative().nullable(),
5867
- files_changed_total: z2.number().int().nonnegative(),
5868
- final_head: z2.string(),
5869
- result: z2.enum(["merged_ready", "stopped"])
5986
+ event: z3.literal("driver_heartbeat"),
5987
+ task: z3.number().int(),
5988
+ pr: z3.number().int().positive().optional(),
5989
+ round: z3.number().int(),
5990
+ phase: z3.string()
5870
5991
  }).strict(),
5871
- z2.object({
5992
+ z3.object({
5872
5993
  ...loopShared,
5873
- event: z2.literal("infrastructure_retry"),
5874
- round: z2.number().int(),
5875
- failure_kind: z2.enum(["pause_comment_post", "developer_connection"]),
5876
- attempts: z2.number().int().positive(),
5877
- outcome: z2.enum(["recovered", "exhausted"])
5994
+ event: z3.literal("driver_exited"),
5995
+ task: z3.number().int(),
5996
+ reason: z3.enum(["finished", "paused", "reexec", "error", "signal"]),
5997
+ last_decision: z3.string(),
5998
+ exit_code: z3.number().int().optional(),
5999
+ error_class: CodeTokenSchema.optional()
5878
6000
  }).strict()
5879
6001
  ]);
5880
- var ForgeOpSchema = z2.enum([
6002
+ var ForgeOpSchema = z3.enum([
5881
6003
  "pr.create",
5882
6004
  "pr.comment",
5883
6005
  "pr.body.replace",
@@ -5891,24 +6013,24 @@ var ForgeOpSchema = z2.enum([
5891
6013
  "label.add",
5892
6014
  "label.remove"
5893
6015
  ]);
5894
- var ForgeWriteTargetSchema = z2.object({
5895
- issue: z2.number().int().optional(),
5896
- pr: z2.number().int().optional()
6016
+ var ForgeWriteTargetSchema = z3.object({
6017
+ issue: z3.number().int().optional(),
6018
+ pr: z3.number().int().optional()
5897
6019
  }).strict();
5898
6020
  var forgeWriteShared = {
5899
6021
  meta: HeaderMetaSchema,
5900
6022
  subject: SubjectSchema,
5901
- kind: z2.literal("forge_write"),
6023
+ kind: z3.literal("forge_write"),
5902
6024
  ...envelopeTail,
5903
6025
  op: ForgeOpSchema,
5904
6026
  target: ForgeWriteTargetSchema
5905
6027
  };
5906
- var ForgeWriteEventSchema = z2.discriminatedUnion("event", [
5907
- z2.object({ ...forgeWriteShared, event: z2.literal("validated") }).strict(),
5908
- z2.object({ ...forgeWriteShared, event: z2.literal("refused"), reason: z2.string() }).strict(),
5909
- z2.object({ ...forgeWriteShared, event: z2.literal("written"), comment_ids: z2.array(z2.string()) }).strict()
6028
+ var ForgeWriteEventSchema = z3.discriminatedUnion("event", [
6029
+ z3.object({ ...forgeWriteShared, event: z3.literal("validated") }).strict(),
6030
+ z3.object({ ...forgeWriteShared, event: z3.literal("refused"), reason: z3.string() }).strict(),
6031
+ z3.object({ ...forgeWriteShared, event: z3.literal("written"), comment_ids: z3.array(z3.string()) }).strict()
5910
6032
  ]);
5911
- var GateOutcomeSchema = z2.enum([
6033
+ var GateOutcomeSchema = z3.enum([
5912
6034
  "pass",
5913
6035
  "fail",
5914
6036
  "wait",
@@ -5921,61 +6043,74 @@ var GateOutcomeSchema = z2.enum([
5921
6043
  var gateShared = {
5922
6044
  meta: HeaderMetaSchema,
5923
6045
  subject: SubjectSchema,
5924
- kind: z2.literal("gate"),
6046
+ kind: z3.literal("gate"),
5925
6047
  ...envelopeTail,
5926
- check: z2.string(),
5927
- check_version: z2.string().nullable(),
5928
- policy_version: z2.string().nullable(),
5929
- input_fingerprint: z2.string().nullable()
6048
+ check: z3.string(),
6049
+ check_version: z3.string().nullable(),
6050
+ policy_version: z3.string().nullable(),
6051
+ input_fingerprint: z3.string().nullable()
5930
6052
  };
5931
- var GateEventSchema = z2.discriminatedUnion("event", [
5932
- z2.object({
6053
+ var GateEventSchema = z3.discriminatedUnion("event", [
6054
+ z3.object({
5933
6055
  ...gateShared,
5934
- event: z2.literal("checked"),
6056
+ event: z3.literal("checked"),
5935
6057
  outcome: GateOutcomeSchema,
5936
- reason: z2.string().optional()
6058
+ reason: z3.string().optional()
6059
+ }).strict(),
6060
+ z3.object({
6061
+ meta: HeaderMetaSchema,
6062
+ subject: SubjectSchema,
6063
+ kind: z3.literal("gate"),
6064
+ ...envelopeTail,
6065
+ event: z3.literal("summary"),
6066
+ ran: z3.number().int().nonnegative(),
6067
+ passed: z3.number().int().nonnegative(),
6068
+ failed: z3.number().int().nonnegative(),
6069
+ skipped: z3.number().int().nonnegative(),
6070
+ failed_checks: z3.array(z3.string())
5937
6071
  }).strict()
5938
6072
  ]);
5939
- var OperationResultSchema = z2.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
6073
+ var OperationResultSchema = z3.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
5940
6074
  var operationShared = {
5941
6075
  meta: HeaderMetaSchema,
5942
6076
  subject: SubjectSchema,
5943
- kind: z2.literal("operation"),
6077
+ kind: z3.literal("operation"),
5944
6078
  ...envelopeTail,
5945
- operation: z2.string(),
5946
- target: z2.string().nullable()
6079
+ operation: z3.string(),
6080
+ target: z3.string().nullable()
5947
6081
  };
5948
- var OperationEventSchema = z2.discriminatedUnion("event", [
5949
- z2.object({
6082
+ var OperationEventSchema = z3.discriminatedUnion("event", [
6083
+ z3.object({
5950
6084
  ...operationShared,
5951
- event: z2.literal("completed"),
6085
+ event: z3.literal("completed"),
5952
6086
  result: OperationResultSchema,
5953
- error_class: z2.string().nullable()
6087
+ error_class: z3.string().nullable(),
6088
+ field_names: z3.array(z3.string().max(CUSTOM_FIELD_NAME_MAX_LENGTH)).max(CUSTOM_EVENT_MAX_FIELDS).optional()
5954
6089
  }).strict()
5955
6090
  ]);
5956
- var UsageUnitsSchema = z2.object({
5957
- input: z2.number().nonnegative().nullable(),
5958
- output: z2.number().nonnegative().nullable(),
5959
- cache: z2.number().nonnegative().nullable()
6091
+ var UsageUnitsSchema = z3.object({
6092
+ input: z3.number().nonnegative().nullable(),
6093
+ output: z3.number().nonnegative().nullable(),
6094
+ cache: z3.number().nonnegative().nullable()
5960
6095
  }).strict();
5961
6096
  var usageShared = {
5962
6097
  meta: HeaderMetaSchema,
5963
6098
  subject: SubjectSchema,
5964
- kind: z2.literal("usage"),
6099
+ kind: z3.literal("usage"),
5965
6100
  ...envelopeTail,
5966
- model: z2.string().nullable(),
5967
- source: z2.string(),
5968
- semantics: z2.enum(["cumulative", "delta"])
6101
+ model: z3.string().nullable(),
6102
+ source: z3.string(),
6103
+ semantics: z3.enum(["cumulative", "delta"])
5969
6104
  };
5970
- var UsageEventSchema = z2.discriminatedUnion("event", [
5971
- z2.object({
6105
+ var UsageEventSchema = z3.discriminatedUnion("event", [
6106
+ z3.object({
5972
6107
  ...usageShared,
5973
- event: z2.literal("observed"),
6108
+ event: z3.literal("observed"),
5974
6109
  units: UsageUnitsSchema,
5975
- unknown_reason: z2.string().nullable()
6110
+ unknown_reason: z3.string().nullable()
5976
6111
  }).strict()
5977
6112
  ]);
5978
- var RoleAttemptOutcomeSchema = z2.enum([
6113
+ var RoleAttemptOutcomeSchema = z3.enum([
5979
6114
  "completed",
5980
6115
  "incomplete",
5981
6116
  "infrastructure_failed",
@@ -5986,17 +6121,17 @@ var RoleAttemptOutcomeSchema = z2.enum([
5986
6121
  var roleAttemptShared = {
5987
6122
  meta: HeaderMetaSchema,
5988
6123
  subject: SubjectSchema,
5989
- kind: z2.literal("role_attempt"),
6124
+ kind: z3.literal("role_attempt"),
5990
6125
  ...envelopeTail,
5991
- actor: z2.string().nullable(),
5992
- attempt: z2.number().int().nullable(),
5993
- effect_id: z2.string(),
5994
- model: z2.string().nullable()
6126
+ actor: z3.string().nullable(),
6127
+ attempt: z3.number().int().nullable(),
6128
+ effect_id: z3.string(),
6129
+ model: z3.string().nullable()
5995
6130
  };
5996
- var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
5997
- z2.object({
6131
+ var RoleAttemptEventSchema = z3.discriminatedUnion("event", [
6132
+ z3.object({
5998
6133
  ...roleAttemptShared,
5999
- event: z2.literal("attempted"),
6134
+ event: z3.literal("attempted"),
6000
6135
  outcome: RoleAttemptOutcomeSchema,
6001
6136
  usage: dispatchUsageField
6002
6137
  }).strict()
@@ -6004,42 +6139,59 @@ var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
6004
6139
  var handoffShared = {
6005
6140
  meta: HeaderMetaSchema,
6006
6141
  subject: SubjectSchema,
6007
- kind: z2.literal("handoff"),
6142
+ kind: z3.literal("handoff"),
6008
6143
  ...envelopeTail,
6009
- class: z2.enum(["authority", "strategy", "product"]),
6010
- reason: z2.string()
6144
+ class: z3.enum(["authority", "strategy", "product"]),
6145
+ reason: z3.string()
6011
6146
  };
6012
- var HandoffEventSchema = z2.discriminatedUnion("event", [
6013
- z2.object({
6147
+ var HandoffEventSchema = z3.discriminatedUnion("event", [
6148
+ z3.object({
6014
6149
  ...handoffShared,
6015
- event: z2.literal("raised"),
6016
- requested_decision: z2.string().nullable()
6150
+ event: z3.literal("raised"),
6151
+ requested_decision: z3.string().nullable()
6017
6152
  }).strict(),
6018
- z2.object({
6153
+ z3.object({
6019
6154
  ...handoffShared,
6020
- event: z2.literal("resolved"),
6021
- resolution: z2.string().nullable(),
6022
- resolved_by: z2.string().nullable()
6155
+ event: z3.literal("resolved"),
6156
+ resolution: z3.string().nullable(),
6157
+ resolved_by: z3.string().nullable()
6023
6158
  }).strict()
6024
6159
  ]);
6025
- var EffectTargetSchema = z2.object({
6026
- kind: z2.string(),
6027
- ref: z2.string()
6160
+ var EffectTargetSchema = z3.object({
6161
+ kind: z3.string(),
6162
+ ref: z3.string()
6028
6163
  }).strict();
6029
6164
  var effectShared = {
6030
6165
  meta: HeaderMetaSchema,
6031
6166
  subject: SubjectSchema,
6032
- kind: z2.literal("effect"),
6167
+ kind: z3.literal("effect"),
6033
6168
  ...envelopeTail,
6034
- effect_id: z2.string(),
6169
+ effect_id: z3.string(),
6035
6170
  target: EffectTargetSchema
6036
6171
  };
6037
- var EffectEventSchema = z2.discriminatedUnion("event", [
6038
- z2.object({ ...effectShared, event: z2.literal("attempted") }).strict(),
6039
- z2.object({ ...effectShared, event: z2.literal("observed"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict(),
6040
- z2.object({ ...effectShared, event: z2.literal("verified"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict()
6172
+ var EffectEventSchema = z3.discriminatedUnion("event", [
6173
+ z3.object({ ...effectShared, event: z3.literal("attempted") }).strict(),
6174
+ z3.object({ ...effectShared, event: z3.literal("observed"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict(),
6175
+ z3.object({ ...effectShared, event: z3.literal("verified"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict()
6176
+ ]);
6177
+ var CustomFieldValueSchema = z3.union([z3.string().max(CUSTOM_TEXT_MAX_LENGTH), z3.number().finite(), z3.boolean()]);
6178
+ var customShared = {
6179
+ meta: HeaderMetaV3Schema,
6180
+ subject: SubjectSchema,
6181
+ kind: z3.literal("custom"),
6182
+ ...envelopeTail
6183
+ };
6184
+ var CustomEventSchema = z3.discriminatedUnion("event", [
6185
+ z3.object({
6186
+ ...customShared,
6187
+ event: z3.literal("recorded"),
6188
+ name: z3.string().max(CUSTOM_EVENT_NAME_MAX_LENGTH).regex(CUSTOM_EVENT_NAME_PATTERN),
6189
+ 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, {
6190
+ message: `custom: at most ${CUSTOM_EVENT_MAX_FIELDS} fields`
6191
+ })
6192
+ }).strict()
6041
6193
  ]);
6042
- var LogEventSchema = z2.union([
6194
+ var LogEventSchema = z3.union([
6043
6195
  DispatchEventSchema,
6044
6196
  DevReviewLoopEventSchema,
6045
6197
  ForgeWriteEventSchema,
@@ -6048,10 +6200,11 @@ var LogEventSchema = z2.union([
6048
6200
  UsageEventSchema,
6049
6201
  RoleAttemptEventSchema,
6050
6202
  HandoffEventSchema,
6051
- EffectEventSchema
6203
+ EffectEventSchema,
6204
+ CustomEventSchema
6052
6205
  ]);
6053
-
6054
6206
  // ../../packages/aeg-core/src/log/envelope.ts
6207
+ import { createHash as createHash5 } from "node:crypto";
6055
6208
  function isRole(value) {
6056
6209
  return value !== undefined && ROLE_VALUES.includes(value);
6057
6210
  }
@@ -6088,18 +6241,27 @@ function roundFromEnv(round) {
6088
6241
  const n = Number(round);
6089
6242
  return Number.isInteger(n) ? n : undefined;
6090
6243
  }
6244
+ function prFromEnv(pr) {
6245
+ if (pr === undefined || pr === "")
6246
+ return;
6247
+ const n = Number(pr);
6248
+ return Number.isInteger(n) && n > 0 ? n : undefined;
6249
+ }
6091
6250
  function buildHeader(input) {
6092
6251
  const role = isRole(input.env.role) ? input.env.role : "unattributed";
6093
6252
  const round = roundFromEnv(input.env.round);
6253
+ const pr = prFromEnv(input.env.pr);
6094
6254
  const subject = {
6095
6255
  issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
6096
6256
  role,
6097
6257
  ...round !== undefined ? { round } : {},
6258
+ ...pr !== undefined ? { pr } : {},
6098
6259
  ...input.subject ?? {}
6099
6260
  };
6261
+ const issue = subject.issue;
6100
6262
  return {
6101
6263
  meta: {
6102
- schema: 2,
6264
+ schema: 3,
6103
6265
  ts: input.now.toISOString(),
6104
6266
  run_id: input.runId,
6105
6267
  seq: input.seq,
@@ -6122,7 +6284,19 @@ function buildHeader(input) {
6122
6284
  ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
6123
6285
  policy_digest: input.inputVersions?.policyDigest ?? null
6124
6286
  },
6125
- provenance: provenanceFor(input)
6287
+ provenance: provenanceFor(input),
6288
+ work: {
6289
+ ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
6290
+ repo: input.repo,
6291
+ change: null,
6292
+ revision: null
6293
+ },
6294
+ flow: {
6295
+ id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
6296
+ version: lineageFieldFromEnv(input.env.flowVersion)
6297
+ },
6298
+ runtime: lineageFieldFromEnv(input.env.runtime),
6299
+ source: lineageFieldFromEnv(input.env.source)
6126
6300
  },
6127
6301
  subject
6128
6302
  };
@@ -6165,7 +6339,7 @@ function redact(value, home) {
6165
6339
  return value;
6166
6340
  }
6167
6341
  // ../../packages/aeg-core/src/log/store.ts
6168
- var KNOWN_SCHEMA_VERSIONS = [1, 2];
6342
+ var KNOWN_SCHEMA_VERSIONS = [1, 2, 3];
6169
6343
  function metaOf(obj) {
6170
6344
  if (obj === null || typeof obj !== "object")
6171
6345
  return null;
@@ -6231,7 +6405,7 @@ function classifyStoredLine(raw, home) {
6231
6405
  return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
6232
6406
  }
6233
6407
  const redacted = redact(event, home);
6234
- const provenance = version === 2 ? event.meta.provenance ?? null : null;
6408
+ const provenance = version >= 2 ? event.meta.provenance ?? null : null;
6235
6409
  return {
6236
6410
  status: "ok",
6237
6411
  identity,
@@ -6244,134 +6418,143 @@ function classifyStoredLine(raw, home) {
6244
6418
  };
6245
6419
  }
6246
6420
  // ../../packages/aeg-core/src/control-store/records.ts
6247
- import { z as z3 } from "zod";
6248
- var isoTimestamp = z3.string().min(1);
6249
- var taskId = z3.number().int().positive();
6250
- var epochNumber = z3.number().int().nonnegative();
6251
- var RunRecordSchema = z3.object({
6252
- version: z3.literal(1),
6253
- kind: z3.literal("run"),
6421
+ import { z as z4 } from "zod";
6422
+ var isoTimestamp = z4.string().min(1);
6423
+ var taskId = z4.number().int().positive();
6424
+ var epochNumber = z4.number().int().nonnegative();
6425
+ var RunRecordSchema = z4.object({
6426
+ version: z4.literal(1),
6427
+ kind: z4.literal("run"),
6254
6428
  task: taskId,
6255
- runId: z3.string().min(1),
6256
- pid: z3.number().int().positive(),
6257
- host: z3.string().min(1),
6429
+ runId: z4.string().min(1),
6430
+ pid: z4.number().int().positive(),
6431
+ host: z4.string().min(1),
6258
6432
  startedAt: isoTimestamp,
6259
- childStartedAt: z3.string().min(1).nullable().optional(),
6260
- childCommand: z3.string().min(1).nullable().optional()
6433
+ childStartedAt: z4.string().min(1).nullable().optional(),
6434
+ childCommand: z4.string().min(1).nullable().optional()
6261
6435
  }).strict();
6262
- var InputRecordSchema = z3.object({
6263
- version: z3.literal(1),
6264
- kind: z3.literal("input"),
6436
+ var InputRecordSchema = z4.object({
6437
+ version: z4.literal(1),
6438
+ kind: z4.literal("input"),
6265
6439
  task: taskId,
6266
- runId: z3.string().min(1),
6267
- source: z3.union([z3.literal("fresh"), z3.literal("resume")]),
6268
- pr: z3.number().int().positive().nullable(),
6269
- round: z3.number().int().nonnegative(),
6440
+ runId: z4.string().min(1),
6441
+ source: z4.union([z4.literal("fresh"), z4.literal("resume")]),
6442
+ pr: z4.number().int().positive().nullable(),
6443
+ round: z4.number().int().nonnegative(),
6270
6444
  recordedAt: isoTimestamp
6271
6445
  }).strict();
6272
- var OwnershipRecordSchema = z3.object({
6273
- version: z3.literal(1),
6274
- kind: z3.literal("ownership"),
6446
+ var OwnershipRecordSchema = z4.object({
6447
+ version: z4.literal(1),
6448
+ kind: z4.literal("ownership"),
6275
6449
  task: taskId,
6276
6450
  epoch: epochNumber,
6277
- ownerId: z3.string().min(1),
6278
- pid: z3.number().int().positive(),
6279
- host: z3.string().min(1),
6451
+ ownerId: z4.string().min(1),
6452
+ pid: z4.number().int().positive(),
6453
+ host: z4.string().min(1),
6280
6454
  acquiredAt: isoTimestamp
6281
6455
  }).strict();
6282
- var TransitionRecordSchema = z3.object({
6283
- version: z3.literal(1),
6284
- kind: z3.literal("transition"),
6456
+ var TransitionRecordSchema = z4.object({
6457
+ version: z4.literal(1),
6458
+ kind: z4.literal("transition"),
6285
6459
  task: taskId,
6286
6460
  epoch: epochNumber,
6287
- seq: z3.number().int().nonnegative(),
6288
- from: z3.string().min(1),
6289
- to: z3.string().min(1),
6290
- detail: z3.string().optional(),
6461
+ seq: z4.number().int().nonnegative(),
6462
+ from: z4.string().min(1),
6463
+ to: z4.string().min(1),
6464
+ detail: z4.string().optional(),
6291
6465
  at: isoTimestamp
6292
6466
  }).strict();
6293
- var ManifestRecordSchema = z3.object({
6294
- version: z3.literal(1),
6295
- kind: z3.literal("manifest"),
6467
+ var ManifestRecordSchema = z4.object({
6468
+ version: z4.literal(1),
6469
+ kind: z4.literal("manifest"),
6296
6470
  task: taskId,
6297
6471
  round: epochNumber,
6298
- repository: z3.string().min(1),
6299
- pr: z3.number().int().positive(),
6300
- branch: z3.string().min(1),
6301
- baseSha: z3.string().min(1).nullable(),
6302
- headSha: z3.string().min(1),
6303
- briefHash: z3.string().min(1).nullable(),
6304
- objectivesVersion: z3.string().min(1).nullable(),
6472
+ repository: z4.string().min(1),
6473
+ pr: z4.number().int().positive(),
6474
+ branch: z4.string().min(1),
6475
+ baseSha: z4.string().min(1).nullable(),
6476
+ headSha: z4.string().min(1),
6477
+ briefHash: z4.string().min(1).nullable(),
6478
+ objectivesVersion: z4.string().min(1).nullable(),
6305
6479
  rulingOrdinal: epochNumber,
6306
- policyDigest: z3.string().min(1),
6480
+ policyDigest: z4.string().min(1),
6307
6481
  recordedAt: isoTimestamp
6308
6482
  }).strict();
6309
- var roundHeadIdentity = z3.object({ round: z3.number().int().positive(), head: z3.string().min(1) }).strict();
6310
- var LoopBudgetsSchema = z3.object({
6311
- mechanicalRetries: z3.number().int().nonnegative(),
6312
- reviewRounds: z3.number().int().nonnegative(),
6313
- infrastructureRetries: z3.number().int().nonnegative()
6483
+ var roundHeadIdentity = z4.object({ round: z4.number().int().positive(), head: z4.string().min(1) }).strict();
6484
+ var LoopBudgetsSchema = z4.object({
6485
+ mechanicalRetries: z4.number().int().nonnegative(),
6486
+ reviewRounds: z4.number().int().nonnegative(),
6487
+ infrastructureRetries: z4.number().int().nonnegative()
6314
6488
  }).strict();
6315
- var LoopStateRecordSchema = z3.object({
6316
- version: z3.literal(1),
6317
- kind: z3.literal("loop_state"),
6489
+ var LoopStateRecordSchema = z4.object({
6490
+ version: z4.literal(1),
6491
+ kind: z4.literal("loop_state"),
6318
6492
  task: taskId,
6319
- round: z3.number().int().positive(),
6320
- phase: z3.string().min(1),
6321
- pauseReason: z3.string().min(1).nullable(),
6493
+ round: z4.number().int().positive(),
6494
+ phase: z4.string().min(1),
6495
+ pauseReason: z4.string().min(1).nullable(),
6322
6496
  budgets: LoopBudgetsSchema,
6323
6497
  heldResult: roundHeadIdentity.nullable(),
6324
6498
  deliveredFindings: roundHeadIdentity.nullable(),
6499
+ repeatMemory: z4.object({
6500
+ blockingFindings: z4.array(z4.string()),
6501
+ lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
6502
+ }).strict().optional(),
6503
+ publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
6504
+ taskStartedAt: isoTimestamp.optional(),
6505
+ phaseMs: z4.record(z4.string(), z4.number().nonnegative()).optional(),
6325
6506
  recordedAt: isoTimestamp
6326
6507
  }).strict();
6327
- var EffectRecordSchema = z3.object({
6328
- version: z3.literal(1),
6329
- kind: z3.literal("effect"),
6508
+ var EffectRecordSchema = z4.object({
6509
+ version: z4.literal(1),
6510
+ kind: z4.literal("effect"),
6330
6511
  task: taskId,
6331
- key: z3.string().min(1),
6332
- operation: z3.string().min(1),
6333
- target: z3.string().min(1),
6334
- inputVersion: z3.number().int().nonnegative(),
6335
- payloadDigest: z3.string().min(1),
6336
- status: z3.union([z3.literal("started"), z3.literal("verified"), z3.literal("uncertain")]),
6337
- url: z3.string().optional(),
6512
+ key: z4.string().min(1),
6513
+ operation: z4.string().min(1),
6514
+ target: z4.string().min(1),
6515
+ inputVersion: z4.number().int().nonnegative(),
6516
+ payloadDigest: z4.string().min(1),
6517
+ status: z4.union([z4.literal("started"), z4.literal("verified"), z4.literal("uncertain")]),
6518
+ url: z4.string().optional(),
6338
6519
  recordedAt: isoTimestamp
6339
6520
  }).strict();
6340
- var EscalationRecordSchema = z3.object({
6341
- version: z3.literal(1),
6342
- kind: z3.literal("escalation"),
6521
+ var EscalationRecordSchema = z4.object({
6522
+ version: z4.literal(1),
6523
+ kind: z4.literal("escalation"),
6343
6524
  task: taskId,
6344
- escalationId: z3.string().min(1),
6525
+ escalationId: z4.string().min(1),
6345
6526
  round: epochNumber,
6346
- head: z3.string().min(1),
6347
- branch: z3.string().min(1),
6348
- pr: z3.number().int().positive().nullable(),
6349
- runId: z3.string().min(1),
6350
- pid: z3.number().int().positive(),
6351
- host: z3.string().min(1),
6352
- agent: z3.string().min(1).optional(),
6353
- reason: z3.string().min(1),
6354
- detail: z3.string().optional(),
6355
- evidence: z3.string().optional(),
6356
- attemptedRecovery: z3.string().min(1),
6357
- requestedDecision: z3.string().min(1),
6358
- recipient: z3.string().min(1),
6359
- briefHash: z3.string().min(1).nullable(),
6360
- objectivesVersion: z3.string().min(1).nullable(),
6527
+ head: z4.string().min(1),
6528
+ branch: z4.string().min(1),
6529
+ pr: z4.number().int().positive().nullable(),
6530
+ runId: z4.string().min(1),
6531
+ pid: z4.number().int().positive(),
6532
+ host: z4.string().min(1),
6533
+ agent: z4.string().min(1).optional(),
6534
+ reason: z4.string().min(1),
6535
+ detail: z4.string().optional(),
6536
+ evidence: z4.string().optional(),
6537
+ attemptedRecovery: z4.string().min(1),
6538
+ requestedDecision: z4.string().min(1),
6539
+ recipient: z4.string().min(1),
6540
+ briefHash: z4.string().min(1).nullable(),
6541
+ objectivesVersion: z4.string().min(1).nullable(),
6361
6542
  rulingOrdinal: epochNumber,
6362
- policyDigest: z3.string().min(1),
6543
+ policyDigest: z4.string().min(1),
6363
6544
  recordedAt: isoTimestamp
6364
6545
  }).strict();
6365
- var ResolutionRecordSchema = z3.object({
6366
- version: z3.literal(1),
6367
- kind: z3.literal("resolution"),
6546
+ var ResolutionRecordSchema = z4.object({
6547
+ version: z4.literal(1),
6548
+ kind: z4.literal("resolution"),
6368
6549
  task: taskId,
6369
- escalationId: z3.string().min(1),
6370
- decision: z3.union([z3.literal("resume"), z3.literal("cancel")]),
6371
- authenticatedBy: z3.string().min(1),
6372
- authenticatedFrom: z3.string().min(1),
6550
+ escalationId: z4.string().min(1),
6551
+ decision: z4.union([z4.literal("resume"), z4.literal("cancel")]),
6552
+ authenticatedBy: z4.string().min(1),
6553
+ authenticatedFrom: z4.string().min(1),
6373
6554
  consumedAt: isoTimestamp
6374
6555
  }).strict();
6556
+ // ../../packages/aeg-core/src/control-store/local.ts
6557
+ var CONTROL_AREA_DIRNAME = "control";
6375
6558
  // ../../packages/sources/src/commands.ts
6376
6559
  var COMMANDS = [
6377
6560
  {
@@ -6526,7 +6709,7 @@ var COMMANDS = [
6526
6709
  "Composes `task brief`'s own preparation (`prepareTask`) with the watching driver (`runDriverLoop`, `dev-review-loop.ts`) — nothing else. Preparation starts no agent; the loop's own round 1 reads the frozen brief off the Issue and is the only place a developer is ever dispatched from a fresh task, so exactly one developer is started by construction.",
6527
6710
  "A brief already frozen on the Issue is reused, never re-posted — the second `task dispatch`/`task brief` call this composes around does not fail the whole run, it just skips straight to running the loop. A task whose Issue refuses preparation (a missing brief section, an unmet dispatch gate) is refused before any agent starts, with nothing posted.",
6528
6711
  "Refuses when the frozen brief's developer branch already has an open pull request AND a driver is still live for it — a driver that crashed or was killed leaves its PR behind, and this command is the one that revives it, in any state, pause held or not.",
6529
- "issue-711 O4: a pause never ends this process — it keeps running and watches the pull request, continuing on its own once a newer Principal ruling appears (or, for an `'infrastructure'`/`'stale_driver'` pause, after a bounded backoff), with no `--resume` command needed for the ordinary case. Exit and printed summary distinguish a published pull request OR a watched pause's own genuine end — merged, closed, or an operator's own `--cancel` (exit `0` either way, the PR URL) — from the one pause this process can never watch (no pull request exists yet — exit `1`, with the exact `vinaya task run <tranche> <n>` command to continue by hand), a usage/argv error (exit `2`), and any other failure (exit `3`)."
6712
+ "issue-711 O4: a pause never ends this process — it keeps running and watches the pull request, continuing on its own once a newer Principal ruling appears (or, for an `'infrastructure'`/`'stale_driver'` pause, after a bounded backoff), with no `--resume` command needed for the ordinary case. Exit and printed summary distinguish a published pull request OR a watched pause's own genuine end — merged, closed, or an operator's own `--cancel` (exit `0` either way, the PR URL) — from the one pause this process can never watch (no pull request exists yet — exit `1`, with the working `vinaya task run` command for this task's own branch to continue by hand — `<tranche> <n>` for a tranche task, `--issue <n>` for a backlog one — never a `dev-review-loop --resume` line naming a pull-request number this pause does not have), a usage/argv error (exit `2`), and any other failure (exit `3`)."
6530
6713
  ],
6531
6714
  status: "shipped"
6532
6715
  },
@@ -6611,13 +6794,14 @@ var COMMANDS = [
6611
6794
  },
6612
6795
  {
6613
6796
  flag: "--push",
6614
- description: "PR number; splices the same content into that PR's LIVE body (fetched from the forge) and pushes it via `gh pr edit`, self-verifying nothing outside the AEG:EVIDENCE/AEG:TOKENS regions changed. Mutually exclusive with --write."
6797
+ description: "PR number; splices the same content into that PR's LIVE body (fetched from the forge) and pushes it via `gh pr edit`, self-verifying nothing outside the AEG:EVIDENCE region changed. Mutually exclusive with --write."
6615
6798
  }
6616
6799
  ],
6617
6800
  details: [
6618
6801
  "Two groups: Group A (recomputable) is the head sha and a width-invariant `git diff --numstat` against the merge-base with `BASE_SHA` (else `origin/main`, then `main`) — `check-evidence-fresh` recomputes and byte-compares this exactly. Group B (attested) is the result of `vinaya check --all --diff-only`, this CLI's own portable gate suite — `check-evidence-fresh` can only check it for staleness (the block's recorded head still matches the PR's real head), never re-run it.",
6619
6802
  "With no `--write`/`--push`, prints the block to stdout instead of writing a file. Exits non-zero whenever the gate run failed, whether or not `--write`/`--push` was given — the block records a failing result rather than hiding one, and a non-zero exit stops a scripted `--write && open-pr` (or `--push`) from carrying a failing suite onto the forge.",
6620
- "`--push` refuses before writing anything when the live body carries no real `AEG:EVIDENCE` pair (it never appends one, unlike `--write`), when the anchor resolves differently before and after normalisation, or when `<pr>` isn't a bare number. When the live body has no real `AEG:TOKENS` pair, the token splice is skipped (same reasoning, softer outcome) rather than creating one. After pushing, it re-reads the live body and restores the pre-edit body — exiting non-zero — if anything outside the two anchored regions changed."
6803
+ "`--push` refuses before writing anything when the live body carries no real `AEG:EVIDENCE` pair (it never appends one, unlike `--write`), when the anchor resolves differently before and after normalisation, or when `<pr>` isn't a bare number. After pushing, it re-reads the live body and restores the pre-edit body — exiting non-zero — if anything outside that one anchored region changed.",
6804
+ "A pull-request body carries no token table, and this command writes none: a dispatched turn's token use is recorded as the Vinaya log's own `usage` event instead. A body that still carries an older run's table keeps it byte for byte — it is prose this command does not own, and a change inside it reads as real drift."
6621
6805
  ],
6622
6806
  status: "shipped"
6623
6807
  },
@@ -6642,7 +6826,7 @@ var COMMANDS = [
6642
6826
  "Deliberately a command, not a check: `evidence-fresh` runs inside `vinaya check --all`, and `pr report` runs `vinaya check --all --diff-only`, so a check that regenerated the block would run the suite containing itself. That recursion is why `evidence-fresh` verifies Group A only and leaves Group B attested.",
6643
6827
  "Must be run from the repository ROOT of a CLEAN checkout at the pull request's head, and refuses otherwise. The regeneration inherits the working directory and several gates resolve their scan root from it, so a subdirectory silently narrows what the fresh run inspects. On cleanliness: Group B is regenerated by diff-scoped checks, so uncommitted or untracked files change which files are scanned and can produce a MATCH a clean checkout would not. Ignored paths are deliberately NOT inspected — `git diff` never reports one, so they cannot change the scope, and including them would refuse in every real checkout since `node_modules` is ignored and always present. The head is read from the forge and both a mismatch AND an unreadable head refuse — the verdict is bound to a commit, never merely attested. `BASE_SHA` is refused as well, since it steers the regeneration's merge-base.",
6644
6828
  "Exits 0 on MATCH; 1 on DIFFERS, HIDDEN, or no block; 2 on a refusal (dirty worktree, wrong head, usage error). HIDDEN means the anchor pair sits inside a collapsed `<details>` block, where `body-bare-digits` blanks every digit and nothing can verify what it claims.",
6645
- "Comparison is a multiset of repo-relative, control-stripped lines: absolute paths (local AND foreign, so a block generated in CI compares against one generated on a laptop) and line order are ignored — a reorder is not a fabrication. Only the AEG:EVIDENCE region is read, since AEG:TOKENS appends by design. A moved merge-base is reported ALONGSIDE the differing lines, never instead of them."
6829
+ "Comparison is a multiset of repo-relative, control-stripped lines: absolute paths (local AND foreign, so a block generated in CI compares against one generated on a laptop) and line order are ignored — a reorder is not a fabrication. Only the AEG:EVIDENCE region is read: every other section of the body is prose no regeneration reproduces. A moved merge-base is reported ALONGSIDE the differing lines, never instead of them."
6646
6830
  ],
6647
6831
  status: "shipped"
6648
6832
  },
@@ -6813,7 +6997,7 @@ var COMMANDS = [
6813
6997
  { flag: "--secrets", description: "security only: the SECRETS line" },
6814
6998
  {
6815
6999
  flag: "--secrets-evidence-file",
6816
- description: 'security only: required whenever `--secrets` claims "none found" — the pasted scanner output backing that claim'
7000
+ description: 'security only: required whenever `--secrets` claims "none found" — the passing `atta-labs/secret-scan` check result on the judged head that backs it; never run or paste the scanner'
6817
7001
  },
6818
7002
  { flag: "--task-id", description: "the closing `Tokens:` line's task id" },
6819
7003
  { flag: "--model", description: "the closing `Tokens:` line's model name" },
@@ -6921,7 +7105,20 @@ var COMMANDS = [
6921
7105
  flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
6922
7106
  details: [
6923
7107
  "Refuses if any task Issue attached to the named tranche is still open, naming each one — closing a tranche with unresolved work is never silently allowed.",
6924
- "Once every task Issue is closed, prompts for confirmation (unless `--yes`) and closes the GitHub Milestone."
7108
+ "Once every task Issue is closed, prompts for confirmation (unless `--yes`), records the tranche's retrospective in the Milestone its task Issues are attached to, and closes that Milestone once nothing else in it is still open.",
7109
+ "A tranche none of whose task Issues carry a Milestone gets one: a Milestone titled with the tranche's slug is created, the tranche's closed task Issues are attached to it, the retrospective is recorded, and it is closed — so the tranche reads as archived. An Issue already on a Milestone is never moved.",
7110
+ "Idempotent: on a tranche whose Milestone is already closed and carries its retrospective, changes nothing and says it is already archived.",
7111
+ "The generated `vinaya-archivist.yml` workflow runs it after a task pull request merges, and again when an Issue labeled with the tranche closes without a merge (dropped, replaced or closed by hand) — the tranche's slug read from that Issue's own label."
7112
+ ],
7113
+ status: "shipped"
7114
+ },
7115
+ {
7116
+ name: "archive tranches",
7117
+ description: "Archive every finished tranche that has no closed Milestone carrying its retrospective",
7118
+ flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
7119
+ details: [
7120
+ "Walks every `vinaya/tranche:<slug>` label, skips each tranche that still has an open task Issue, and runs `archive tranche` for each finished one whose Milestone is not already closed with its retrospective. One tranche failing does not stop the others; the exit code reports it.",
7121
+ "The generated `vinaya-archivist.yml` workflow calls it on its daily scheduled run, so a tranche that finished before the workflow could see it is archived within a day. Running it again when every finished tranche is archived changes nothing and says so."
6925
7122
  ],
6926
7123
  status: "shipped"
6927
7124
  },
@@ -7065,6 +7262,29 @@ var COMMANDS = [
7065
7262
  ],
7066
7263
  status: "shipped"
7067
7264
  },
7265
+ {
7266
+ name: "log selftest",
7267
+ description: "Prove log delivery works end to end: send one marked test event and read it back — PASS (exit 0) or FAIL with the one reason (exit 1)",
7268
+ details: [
7269
+ "Resolves the destination exactly as an UNATTENDED review-loop run does in this repository — the same trust-anchor read and credential lookup, forced unattended so running it by hand proves the launch path's own resolution, not a human's. It sends one test event to the configured `logs.url` server, then reads it back from the server by the event's own id through the server's cursor read.",
7270
+ "PASS (exit 0) only when the event round-trips. Otherwise FAIL (exit 1) with the ONE reason that stopped it: no server is configured, the default branch's config could not be read to confirm the url (and why), this host holds no ingest or read credential, the server refused with its status, or the event could not be read back. It never prints a credential value.",
7271
+ "The read-back needs a READ credential distinct from the write-only ingest one the server refuses on a read route: set `logs.readHeaders` in vinaya.config.json to the server's read token (referenced by variable name, resolved from the environment exactly as `logs.headers` is). The test event is marked `operation: 'log.selftest'` so a reader can exclude it from real telemetry."
7272
+ ],
7273
+ status: "shipped"
7274
+ },
7275
+ {
7276
+ name: "log emit",
7277
+ description: "Record a consumer-declared event (`logs.events` in vinaya.config.json) from a script or agent outside Vinaya",
7278
+ flags: [
7279
+ { flag: "--json '<json>'", description: "The field values as one JSON object (else read from standard input)" }
7280
+ ],
7281
+ details: [
7282
+ "Reads the field values as ONE JSON object — `--json '<json>'` or piped on standard input, never positional arguments — and records them through `emitCustomEvent`, the same chokepoint every custom event goes through, so the refusal event and the redaction stay in one place.",
7283
+ "A declared event with every field present and of its declared type exits 0 and prints the event name and the kind of destination it was recorded toward (`folder`, `server`, or `none`) — never a field value. A refused event (an undeclared name, or a missing, extra, wrong-typed or too-long field) exits 1 and prints the reason class and the field names — never a value, since a rejected value may be the secret. A missing event name, unreadable JSON, or JSON that is not a flat object is a usage error: exit 2, before anything is recorded.",
7284
+ "A process with only `VINAYA_WORK_REF` and `VINAYA_FLOW` set, and no Vinaya role or task, still gets a header carrying that work reference and way-of-working id — the same environment read every event already honours (`apps/cli/specs/log.md` § Attribution)."
7285
+ ],
7286
+ status: "shipped"
7287
+ },
7068
7288
  {
7069
7289
  name: "log send",
7070
7290
  description: "Deliver this repository's locally-held log events to the configured `logs.url` server, once",
@@ -7075,6 +7295,23 @@ var COMMANDS = [
7075
7295
  "Safe to run more than once: the server stores events by `event_id` and ignores one it already holds, so a re-sent chunk creates no duplicate, and a second run finds the folder emptied and the queue drained."
7076
7296
  ],
7077
7297
  status: "shipped"
7298
+ },
7299
+ {
7300
+ name: "sync",
7301
+ description: "Fill, resume and rebuild the local log cache from this repository's configured destination (read-only)",
7302
+ flags: [
7303
+ {
7304
+ flag: "--rebuild",
7305
+ description: "Delete the cache file and sync from the beginning of what the destination still retains"
7306
+ },
7307
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
7308
+ ],
7309
+ details: [
7310
+ "Resolves the destination exactly the way a normal event does — the sink's own decision over `vinaya.config.json`'s `logs` setting, trust-anchor-gated for an unattended caller — then reads a folder destination through the folder source or a server destination through the server source (with the configured `logs.readHeaders`, substituted from the environment), and runs the bounded sync engine against the durable cache this repository holds under its runtime directory. Prints pages read, rows stored, duplicates, edits, deletions, gaps, quarantined lines and, for a server destination, its lost-event diagnostic. Reads the destination and writes only its own cache directory — never the folder, the server, or the forge.",
7311
+ "Exits 0 when the run completed or stopped cleanly on its page bound (and says more is available), 1 when it failed part way (the progress made is kept — a second run resumes from the stored cursor), and 2 for a usage or configuration problem: no destination is configured, or a server destination is configured with no usable read credential. A missing credential names the environment variable to set and never prints its value.",
7312
+ "`--rebuild` deletes the cache file ALONE — never anything else under the cache directory — and syncs again from the beginning of what the destination still retains; an event already rotated out of a folder's single backup slot, or no longer retained by the destination, cannot be recovered and shows up as a gap, never silently."
7313
+ ],
7314
+ status: "shipped"
7078
7315
  }
7079
7316
  ];
7080
7317
  // ../../packages/sources/src/forge-adapter.ts
@@ -7086,10 +7323,10 @@ function createForgeSource(config) {
7086
7323
  };
7087
7324
  }
7088
7325
  // ../../packages/sources/src/select-source.ts
7089
- import { z as z4 } from "zod";
7090
- var StateSourceConfigSchema = z4.discriminatedUnion("kind", [
7091
- z4.object({ kind: z4.literal("forge"), owner: z4.string(), repo: z4.string() }),
7092
- z4.object({ kind: z4.literal("file"), root: z4.string().optional() })
7326
+ import { z as z5 } from "zod";
7327
+ var StateSourceConfigSchema = z5.discriminatedUnion("kind", [
7328
+ z5.object({ kind: z5.literal("forge"), owner: z5.string(), repo: z5.string() }),
7329
+ z5.object({ kind: z5.literal("file"), root: z5.string().optional() })
7093
7330
  ]);
7094
7331
  // src/checks/contract.ts
7095
7332
  var CHECK_SCHEMA_VERSION = 1;
@@ -7104,29 +7341,29 @@ import { promisify as promisify4 } from "node:util";
7104
7341
  import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
7105
7342
  import { homedir } from "node:os";
7106
7343
  import { dirname, isAbsolute, join, resolve } from "node:path";
7107
- import { z as z5 } from "zod";
7344
+ import { z as z6 } from "zod";
7108
7345
 
7109
7346
  // src/lib/agent-vendors.ts
7110
7347
  var AGENT_VENDORS = ["skills", "claude", "gemini"];
7111
7348
 
7112
7349
  // src/lib/config.ts
7113
- var EnvEntrySchema = z5.union([
7114
- z5.literal(true),
7115
- z5.object({ optional: z5.literal(true) }),
7116
- z5.object({ anyOf: z5.array(z5.string()).min(2) }),
7117
- z5.string()
7350
+ var EnvEntrySchema = z6.union([
7351
+ z6.literal(true),
7352
+ z6.object({ optional: z6.literal(true) }),
7353
+ z6.object({ anyOf: z6.array(z6.string()).min(2) }),
7354
+ z6.string()
7118
7355
  ]);
7119
- var CheckEntrySchema = z5.object({
7120
- run: z5.string(),
7121
- scope: z5.enum(["diff", "full"]),
7122
- include: z5.array(z5.string()).optional(),
7123
- args: z5.array(z5.string()).optional(),
7124
- timeoutMs: z5.number().optional(),
7125
- env: z5.record(z5.string(), EnvEntrySchema).optional(),
7126
- requiresOpenPr: z5.boolean().optional(),
7127
- ownWorkflow: z5.boolean().optional(),
7128
- principalOwed: z5.literal(true).optional(),
7129
- validates: z5.enum(["body", "issue"]).optional()
7356
+ var CheckEntrySchema = z6.object({
7357
+ run: z6.string(),
7358
+ scope: z6.enum(["diff", "full"]),
7359
+ include: z6.array(z6.string()).optional(),
7360
+ args: z6.array(z6.string()).optional(),
7361
+ timeoutMs: z6.number().optional(),
7362
+ env: z6.record(z6.string(), EnvEntrySchema).optional(),
7363
+ requiresOpenPr: z6.boolean().optional(),
7364
+ ownWorkflow: z6.boolean().optional(),
7365
+ principalOwed: z6.literal(true).optional(),
7366
+ validates: z6.enum(["body", "issue"]).optional()
7130
7367
  }).superRefine((entry, ctx) => {
7131
7368
  if (!entry.env)
7132
7369
  return;
@@ -7136,22 +7373,22 @@ var CheckEntrySchema = z5.object({
7136
7373
  const members = value.anyOf;
7137
7374
  if (new Set(members).size !== members.length) {
7138
7375
  ctx.addIssue({
7139
- code: z5.ZodIssueCode.custom,
7376
+ code: z6.ZodIssueCode.custom,
7140
7377
  message: `env.${key}.anyOf has duplicate members`,
7141
7378
  path: ["env", key, "anyOf"]
7142
7379
  });
7143
7380
  }
7144
7381
  if (!members.includes(key)) {
7145
7382
  ctx.addIssue({
7146
- code: z5.ZodIssueCode.custom,
7383
+ code: z6.ZodIssueCode.custom,
7147
7384
  message: `env.${key}.anyOf must include "${key}" itself as a member`,
7148
7385
  path: ["env", key, "anyOf"]
7149
7386
  });
7150
7387
  }
7151
7388
  }
7152
7389
  });
7153
- var RoleEntrySchema = z5.object({
7154
- contract: z5.string().refine((p) => p.includes("/"), {
7390
+ var RoleEntrySchema = z6.object({
7391
+ contract: z6.string().refine((p) => p.includes("/"), {
7155
7392
  message: 'must be a path (contain at least one "/"), not a bare filename'
7156
7393
  })
7157
7394
  });
@@ -7175,17 +7412,17 @@ var BRIEF_BUILTINS = [
7175
7412
  "briefSections",
7176
7413
  "milestoneShape"
7177
7414
  ];
7178
- var BriefSectionSchema = z5.union([
7179
- z5.object({ builtin: z5.enum(BRIEF_BUILTINS) }),
7180
- z5.object({ heading: z5.string().min(1), name: z5.string().optional() }),
7181
- z5.object({ field: z5.string().min(1), name: z5.string().optional() }),
7182
- z5.object({ phrase: z5.string().min(1), name: z5.string().optional() })
7415
+ var BriefSectionSchema = z6.union([
7416
+ z6.object({ builtin: z6.enum(BRIEF_BUILTINS) }),
7417
+ z6.object({ heading: z6.string().min(1), name: z6.string().optional() }),
7418
+ z6.object({ field: z6.string().min(1), name: z6.string().optional() }),
7419
+ z6.object({ phrase: z6.string().min(1), name: z6.string().optional() })
7183
7420
  ]);
7184
- var BriefSchemaSchema = z5.object({
7185
- pr: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
7186
- issue: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
7187
- milestone: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
7188
- ack: z5.array(z5.enum(BRIEF_BUILTINS)).optional()
7421
+ var BriefSchemaSchema = z6.object({
7422
+ pr: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
7423
+ issue: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
7424
+ milestone: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
7425
+ ack: z6.array(z6.enum(BRIEF_BUILTINS)).optional()
7189
7426
  });
7190
7427
  function isSafeRepoRelPath(p) {
7191
7428
  if (p.length === 0)
@@ -7194,7 +7431,7 @@ function isSafeRepoRelPath(p) {
7194
7431
  return false;
7195
7432
  return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
7196
7433
  }
7197
- var SafeRepoRelPath = z5.string().refine(isSafeRepoRelPath, {
7434
+ var SafeRepoRelPath = z6.string().refine(isSafeRepoRelPath, {
7198
7435
  message: "must be a repo-root-relative path with no `..` segment or absolute root"
7199
7436
  });
7200
7437
  var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
@@ -7204,22 +7441,22 @@ function isCanonicalHookBlockPath(p) {
7204
7441
  var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
7205
7442
  message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
7206
7443
  });
7207
- var ManagedBlockRecordSchema = z5.object({
7444
+ var ManagedBlockRecordSchema = z6.object({
7208
7445
  path: ManagedHookBlockPath,
7209
- marker: z5.string(),
7210
- comment: z5.enum(["hash", "html"])
7446
+ marker: z6.string(),
7447
+ comment: z6.enum(["hash", "html"])
7211
7448
  });
7212
- var ManagedManifestSchema = z5.object({
7213
- version: z5.number().int().positive(),
7214
- files: z5.array(SafeRepoRelPath),
7215
- blocks: z5.array(ManagedBlockRecordSchema),
7216
- labels: z5.array(z5.string()),
7217
- agents: z5.array(z5.enum(AGENT_VENDORS)).optional()
7449
+ var ManagedManifestSchema = z6.object({
7450
+ version: z6.number().int().positive(),
7451
+ files: z6.array(SafeRepoRelPath),
7452
+ blocks: z6.array(ManagedBlockRecordSchema),
7453
+ labels: z6.array(z6.string()),
7454
+ agents: z6.array(z6.enum(AGENT_VENDORS)).optional()
7218
7455
  });
7219
- var ProjectEntrySchema = z5.object({
7220
- name: z5.string().min(1),
7221
- description: z5.string().min(1).optional(),
7222
- path: z5.string().min(1).optional()
7456
+ var ProjectEntrySchema = z6.object({
7457
+ name: z6.string().min(1),
7458
+ description: z6.string().min(1).optional(),
7459
+ path: z6.string().min(1).optional()
7223
7460
  });
7224
7461
  function parseTokensCollectDeclaration(value) {
7225
7462
  const m = value.trim().match(/^(\S+)\s+(\S+)$/);
@@ -7230,87 +7467,97 @@ function parseTokensCollectDeclaration(value) {
7230
7467
  return null;
7231
7468
  return { interpreter, script };
7232
7469
  }
7233
- var VinayaConfigSchema = z5.object({
7234
- rings: z5.object({
7235
- ring1_forgeWriteInterception: z5.boolean(),
7236
- ring2_asyncAudits: z5.boolean()
7470
+ var VinayaConfigSchema = z6.object({
7471
+ rings: z6.object({
7472
+ ring1_forgeWriteInterception: z6.boolean(),
7473
+ ring2_asyncAudits: z6.boolean()
7237
7474
  }).optional(),
7238
- checks: z5.record(z5.string(), CheckEntrySchema).optional(),
7239
- roles: z5.record(z5.string(), RoleEntrySchema).optional(),
7475
+ checks: z6.record(z6.string(), CheckEntrySchema).optional(),
7476
+ roles: z6.record(z6.string(), RoleEntrySchema).optional(),
7240
7477
  briefSchema: BriefSchemaSchema.optional(),
7241
7478
  managed: ManagedManifestSchema.optional(),
7242
- principals: z5.array(z5.string()).min(1).optional(),
7243
- releaseActor: z5.string().min(1).optional(),
7244
- ci: z5.object({ setup: z5.string().min(1) }).optional(),
7245
- tokens: z5.object({
7246
- collect: z5.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
7479
+ principals: z6.array(z6.string()).min(1).optional(),
7480
+ releaseActor: z6.string().min(1).optional(),
7481
+ ci: z6.object({ setup: z6.string().min(1) }).optional(),
7482
+ tokens: z6.object({
7483
+ collect: z6.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
7247
7484
  message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
7248
7485
  })
7249
7486
  }).optional(),
7250
- blastRadius: z5.object({ extraDomains: z5.array(z5.string()).optional() }).optional(),
7251
- proseGates: z5.object({
7252
- doctrineRoot: z5.string().min(1).optional(),
7253
- readerFacingPrefix: z5.string().min(1).optional(),
7254
- readerFacingSuffix: z5.string().min(1).optional(),
7255
- legacySlugDir: z5.string().min(1).optional(),
7256
- sourceComments: z5.object({
7257
- globs: z5.array(z5.string().min(1)).optional(),
7258
- allowlist: z5.array(z5.string().min(1)).optional(),
7259
- severity: z5.enum(["warning", "error"]).optional()
7487
+ blastRadius: z6.object({ extraDomains: z6.array(z6.string()).optional() }).optional(),
7488
+ proseGates: z6.object({
7489
+ doctrineRoot: z6.string().min(1).optional(),
7490
+ readerFacingPrefix: z6.string().min(1).optional(),
7491
+ readerFacingSuffix: z6.string().min(1).optional(),
7492
+ legacySlugDir: z6.string().min(1).optional(),
7493
+ sourceComments: z6.object({
7494
+ globs: z6.array(z6.string().min(1)).optional(),
7495
+ allowlist: z6.array(z6.string().min(1)).optional(),
7496
+ severity: z6.enum(["warning", "error"]).optional()
7260
7497
  }).optional(),
7261
- specGrandfather: z5.array(z5.string().min(1)).optional(),
7262
- specPaths: z5.array(z5.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
7498
+ specGrandfather: z6.union([z6.array(z6.string().min(1)), z6.record(z6.string().min(1), z6.number().int().min(0))]).optional(),
7499
+ specPaths: z6.array(z6.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
7263
7500
  message: "must be a repository-relative path, not an absolute one"
7264
7501
  }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
7265
7502
  message: "must stay inside the repository — no `..` segment"
7266
7503
  })).optional()
7267
7504
  }).optional(),
7268
- projects: z5.array(ProjectEntrySchema).optional(),
7269
- dispatch: z5.object({
7270
- timeoutMs: z5.number().int().positive().optional(),
7271
- killGraceMs: z5.number().int().positive().optional(),
7272
- agent: z5.enum(["claude", "codex", "gemini"]).optional(),
7273
- requireWorkerIsolation: z5.boolean().optional()
7505
+ projects: z6.array(ProjectEntrySchema).optional(),
7506
+ dispatch: z6.object({
7507
+ timeoutMs: z6.number().int().positive().optional(),
7508
+ killGraceMs: z6.number().int().positive().optional(),
7509
+ agent: z6.enum(["claude", "codex", "gemini"]).optional()
7510
+ }).optional(),
7511
+ reviewPolicy: z6.object({
7512
+ codeReviewThreshold: z6.string().min(1).optional(),
7513
+ securityThreshold: z6.string().min(1).optional(),
7514
+ maxRounds: z6.number().optional(),
7515
+ maxTaskMinutes: z6.number().optional()
7274
7516
  }).optional(),
7275
- reviewPolicy: z5.object({
7276
- codeReviewThreshold: z5.string().min(1).optional(),
7277
- securityThreshold: z5.string().min(1).optional(),
7278
- maxRounds: z5.number().optional()
7517
+ securityScan: z6.object({
7518
+ command: z6.array(z6.string().min(1)).min(1)
7279
7519
  }).optional(),
7280
- gateCutovers: z5.object({
7281
- objectivesSinceIssue: z5.number().int().nonnegative().optional(),
7282
- briefSectionsSinceIssue: z5.number().int().nonnegative().optional(),
7283
- documentationSinceIssue: z5.number().int().nonnegative().optional(),
7284
- briefRulesSincePr: z5.number().int().nonnegative().optional(),
7285
- agentBoxesRefusedSincePr: z5.number().int().nonnegative().optional()
7520
+ gateCutovers: z6.object({
7521
+ objectivesSinceIssue: z6.number().int().nonnegative().optional(),
7522
+ briefSectionsSinceIssue: z6.number().int().nonnegative().optional(),
7523
+ documentationSinceIssue: z6.number().int().nonnegative().optional(),
7524
+ briefRulesSincePr: z6.number().int().nonnegative().optional(),
7525
+ agentBoxesRefusedSincePr: z6.number().int().nonnegative().optional()
7286
7526
  }).optional(),
7287
- prePush: z5.object({
7288
- alwaysRun: z5.array(z5.string()).optional()
7527
+ planning: z6.object({
7528
+ collisionThreshold: z6.number().int().nonnegative().optional()
7289
7529
  }).optional(),
7290
- report: z5.object({
7291
- commandTimeoutMs: z5.number().int().positive().optional()
7530
+ prePush: z6.object({
7531
+ alwaysRun: z6.array(z6.string()).optional()
7532
+ }).optional(),
7533
+ report: z6.object({
7534
+ commandTimeoutMs: z6.number().int().positive().optional()
7292
7535
  }).superRefine((report, ctx) => {
7293
7536
  const commandTimeoutMs = report.commandTimeoutMs;
7294
7537
  if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
7295
7538
  ctx.addIssue({
7296
- code: z5.ZodIssueCode.custom,
7539
+ code: z6.ZodIssueCode.custom,
7297
7540
  path: ["commandTimeoutMs"],
7298
7541
  message: "must be at most 3600000 (1 hour)"
7299
7542
  });
7300
7543
  }
7301
7544
  }).optional(),
7302
- logPublish: z5.unknown().refine((v) => v === undefined, {
7545
+ logPublish: z6.unknown().refine((v) => v === undefined, {
7303
7546
  message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
7304
7547
  }),
7305
- runtimeDir: z5.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
7306
- logs: z5.object({
7307
- folder: z5.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
7308
- url: z5.string().url().optional(),
7309
- headers: z5.record(z5.string()).optional()
7548
+ runtimeDir: z6.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
7549
+ logs: z6.object({
7550
+ folder: z6.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
7551
+ url: z6.string().url().optional(),
7552
+ headers: z6.record(z6.string()).optional(),
7553
+ readHeaders: z6.record(z6.string()).optional(),
7554
+ events: CustomEventDeclarationsSchema.optional()
7310
7555
  }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
7311
7556
  message: "logs: set at most one of folder/url"
7312
7557
  }).refine((v) => v.headers === undefined || v.url !== undefined, {
7313
7558
  message: "logs: headers requires url"
7559
+ }).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
7560
+ message: "logs: readHeaders requires url"
7314
7561
  }).optional()
7315
7562
  });
7316
7563
  var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
@@ -7415,10 +7662,15 @@ function resolveReviewPolicy(config) {
7415
7662
  if (!Number.isInteger(maxRounds) || maxRounds < 1) {
7416
7663
  throw new Error(`vinaya.config.json: reviewPolicy.maxRounds "${maxRounds}" is not a positive integer — fix the config, this never falls back to a default.`);
7417
7664
  }
7665
+ const maxTaskMinutes = raw.maxTaskMinutes ?? DEFAULT_REVIEW_POLICY.maxTaskMinutes;
7666
+ if (!Number.isInteger(maxTaskMinutes) || maxTaskMinutes < 0) {
7667
+ throw new Error(`vinaya.config.json: reviewPolicy.maxTaskMinutes "${maxTaskMinutes}" is not a non-negative integer (0 turns the budget off) — fix the config, this never falls back to a default.`);
7668
+ }
7418
7669
  return {
7419
7670
  codeReviewThreshold,
7420
7671
  securityThreshold,
7421
- maxRounds
7672
+ maxRounds,
7673
+ maxTaskMinutes
7422
7674
  };
7423
7675
  }
7424
7676
  function resolveGateCutovers(config) {