@attalabs/vinaya 0.36.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 (243) 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 +4 -4
  13. package/aeg-root/roles/principal.md +6 -1
  14. package/aeg-root/roles/reviewer.md +9 -3
  15. package/aeg-root/roles/security.md +19 -9
  16. package/aeg-root/roles/tranche-archivist.md +14 -2
  17. package/aeg-root/state-machine.md +11 -10
  18. package/aeg-root/templates/brief-template.md +6 -4
  19. package/aeg-root/templates/pr-report-template.md +1 -9
  20. package/aeg-root/tranche-model.md +4 -4
  21. package/dist/checks/bin/check-body-bare-digits.js +685 -584
  22. package/dist/checks/bin/check-branch-topology.js +626 -466
  23. package/dist/checks/bin/check-brief-shape.js +686 -585
  24. package/dist/checks/bin/check-changeset-coverage.js +1161 -731
  25. package/dist/checks/bin/check-closes-n.js +626 -466
  26. package/dist/checks/bin/check-coherence.js +744 -599
  27. package/dist/checks/bin/check-dead-branch-push.js +567 -451
  28. package/dist/checks/bin/check-dispatch-readiness.js +747 -602
  29. package/dist/checks/bin/check-doc-coverage-push.js +1160 -730
  30. package/dist/checks/bin/check-doc-coverage.js +1160 -730
  31. package/dist/checks/bin/check-doctrine-no-procedures.js +683 -582
  32. package/dist/checks/bin/check-doctrine-portability.js +1160 -730
  33. package/dist/checks/bin/check-evidence-fresh.js +1167 -906
  34. package/dist/checks/bin/check-exec-bits.js +1159 -729
  35. package/dist/checks/bin/check-first-push-dispatch.js +747 -602
  36. package/dist/checks/bin/check-issue-assignment.js +626 -466
  37. package/dist/checks/bin/check-issue-milestone-attach.js +567 -451
  38. package/dist/checks/bin/check-issue-objectives-numbering.js +683 -582
  39. package/dist/checks/bin/check-issue-parts-coverage.js +567 -451
  40. package/dist/checks/bin/check-issue-surface-globs.js +755 -601
  41. package/dist/checks/bin/check-issue-title-grammar.js +567 -451
  42. package/dist/checks/bin/check-issue-tranche-label.js +567 -451
  43. package/dist/checks/bin/check-main-branch-refusal.js +567 -451
  44. package/dist/checks/bin/check-no-disk-state.js +567 -451
  45. package/dist/checks/bin/check-pr-premise-reassert.js +683 -582
  46. package/dist/checks/bin/check-pr-report-density.js +567 -451
  47. package/dist/checks/bin/check-principal-test-plan-wait.js +567 -451
  48. package/dist/checks/bin/check-quoted-command.js +1644 -1216
  49. package/dist/checks/bin/check-reader-resolvable-prose.js +1663 -1223
  50. package/dist/checks/bin/check-registry-gates.js +610 -481
  51. package/dist/checks/bin/check-retired-vocabulary.js +1638 -1210
  52. package/dist/checks/bin/check-review-gate.js +694 -593
  53. package/dist/checks/bin/check-single-plan-pr.js +567 -451
  54. package/dist/checks/bin/check-surface-scope.js +626 -466
  55. package/dist/checks/bin/check-test-plan.js +567 -451
  56. package/dist/checks/bin/check-token-collection-wired.js +567 -451
  57. package/dist/checks/bin/check-workspace-escape.js +1160 -730
  58. package/dist/index.js +13507 -7975
  59. package/dist/lib/pre-push-cache-test-run.js +1004 -681
  60. package/dist/lib/pre-push-select-tests.js +609 -480
  61. package/package.json +2 -2
  62. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +38 -0
  63. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +19 -0
  64. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +233 -8
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +7 -2
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +1 -0
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +38 -3
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +113 -4
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-claim.ts +32 -6
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +26 -1
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +747 -0
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +8 -1
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +52 -4
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +163 -21
  75. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  76. package/studio-standalone/apps/vinaya-studio/web/.next/app-path-routes-manifest.json +0 -1
  77. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  78. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  79. package/studio-standalone/apps/vinaya-studio/web/.next/required-server-files.json +0 -5
  80. package/studio-standalone/apps/vinaya-studio/web/.next/routes-manifest.json +0 -6
  81. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error/page.js +1 -1
  82. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error/page.js.nft.json +1 -1
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  85. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  87. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  89. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  90. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  91. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js +1 -1
  92. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  95. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js +1 -1
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  98. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +3 -3
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +3 -3
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  105. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  106. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  107. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +3 -3
  108. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  109. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +5 -5
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  113. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  114. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +3 -3
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +3 -3
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  122. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  123. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +3 -3
  124. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  125. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  126. package/studio-standalone/apps/vinaya-studio/web/.next/server/app-paths-manifest.json +0 -1
  127. 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
  128. 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
  129. 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
  130. 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
  131. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{_15gdg48._.js → [root-of-the-server]__04adkz-._.js} +3 -3
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__05zwn98._.js +14 -0
  133. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +3 -0
  134. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  135. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__10riywf._.js +3 -0
  136. 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
  137. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1wy7w66._.js → [root-of-the-server]__14ui9sz._.js} +2 -2
  138. 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
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1f4bb3_._.js +3 -0
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  141. 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
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1ng2x88._.js +3 -0
  143. 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
  144. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1snpgaw._.js +56 -0
  145. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +2 -2
  146. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_06h3wbl._.js +3 -0
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  149. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  150. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  151. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0gs4gvl._.js +3 -0
  152. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  153. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  154. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  155. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_121lrn5._.js +3 -0
  156. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  157. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1o4v6lb._.js +3 -0
  158. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1q7h5mz._.js +1 -1
  159. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1ztd4i3._.js +3 -0
  160. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_209-ugd._.js +3 -0
  161. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_214d71c._.js +3 -0
  162. 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
  163. 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
  164. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_next_dist_1lzmr5o._.js +1 -1
  165. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_animate_components_index_ts_186fje1._.js +1 -1
  166. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_basic_components_index_ts_0xk1vda._.js +1 -1
  167. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  168. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  169. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  170. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  171. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/09fcolor69bun.js +1 -0
  172. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0lcwmwzxacdie.js +1 -0
  173. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ojry7lrbzkfd.css +1 -0
  174. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{00z3-ljjd1gj9.js → 0vtfb0g813gki.js} +1 -1
  175. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1giu47hrbhroj.js +1 -0
  176. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1shz6lwruld25.js +1 -0
  177. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1ytvuy1mmnc6j.js +1 -0
  178. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3oxhhhm_psozq.js → 21a6_5cr956wj.js} +1 -1
  179. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2g8mwnydod96u.js +1 -0
  180. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3li0ueedy-ozv.js → 2nrnuawd5fwpv.js} +1 -1
  181. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2nw47832_uvfe.js +1 -0
  182. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2qdxnj8wk2h0s.js +1 -0
  183. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3b9q75p-z5ma5.js +1 -0
  184. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3cv-oe7153242.js +1 -0
  185. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3lqjwjrcvq481.js → 3l56x8wjdzvaw.js} +5 -5
  186. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3m310lbjj4p5u.js +1 -0
  187. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2o9l0b7eqbr57.js → 3qtt1v3ya-ofe.js} +1 -1
  188. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  189. package/studio-standalone/apps/vinaya-studio/web/server.js +1 -1
  190. 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/vinaya/studio-standalone/_node_modules/@attalabs/aeg-core/bin/verify-coherence.ts +0 -1089
  191. package/studio-standalone/_node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js +0 -6
  192. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route/app-paths-manifest.json +0 -3
  193. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route/build-manifest.json +0 -9
  194. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route/server-reference-manifest.json +0 -4
  195. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js +0 -6
  196. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.map +0 -5
  197. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +0 -1
  198. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route_client-reference-manifest.js +0 -3
  199. 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
  200. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[externals]__0cki-x_._.js +0 -3
  201. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +0 -15
  202. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[turbopack]_runtime.js +0 -903
  203. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +0 -3
  204. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ln09ua._.js +0 -3
  205. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0oegopp._.js +0 -3
  206. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__13yxbjd._.js +0 -51
  207. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1duqmtm._.js +0 -3
  208. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1z7dml9._.js +0 -9
  209. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0bfs_u4._.js +0 -3
  210. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0g8_eot._.js +0 -3
  211. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0hrh_v-._.js +0 -181
  212. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0i4-dea._.js +0 -3
  213. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0o54suy._.js +0 -3
  214. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0rxd7s0._.js +0 -3
  215. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0y1jv16._.js +0 -3
  216. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_151m4rz._.js +0 -3
  217. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1a9dieq._.js +0 -3
  218. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1sxsf5q._.js +0 -3
  219. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1sy_yfr._.js +0 -3
  220. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_219v2an._.js +0 -3
  221. 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
  222. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_basic_components_form_input_tsx_0es8d8b._.js +0 -3
  223. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_brutal_components_index_ts_0n_lcc4._.js +0 -3
  224. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_retro_components_index_ts_0wvpm_z._.js +0 -3
  225. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bjnj-5fy4e7l.js +0 -1
  226. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0c8uwz_-m8s99.js +0 -165
  227. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ct0c-xj0baf6.js +0 -1
  228. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ko698wh8xx2g.css +0 -1
  229. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0t5n_r4xm__t-.js +0 -1
  230. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0vc2u252q5q6o.js +0 -1
  231. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/16r_o07lw0vm0.js +0 -1
  232. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1cah7_e5a1zvu.js +0 -1
  233. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1gjo9-6dz7nup.js +0 -1
  234. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/24tz8aro1uto4.js +0 -1
  235. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2ef2g5fozszw7.js +0 -1
  236. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2ka8dg687auhj.js +0 -1
  237. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2pf3f50gbrkyv.js +0 -1
  238. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2qq49pct3q51-.js +0 -1
  239. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3et66z7glk65w.js +0 -1
  240. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3y6u3prmrkea-.js +0 -1
  241. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{z1fTSBP6ZlUjObzFIp-qq → yR5RsCxb1OGnYggiaO09S}/_buildManifest.js +0 -0
  242. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{z1fTSBP6ZlUjObzFIp-qq → yR5RsCxb1OGnYggiaO09S}/_clientMiddlewareManifest.js +0 -0
  243. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{z1fTSBP6ZlUjObzFIp-qq → yR5RsCxb1OGnYggiaO09S}/_ssgManifest.js +0 -0
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/checks/bin/check-evidence-fresh.ts
4
- import { execFileSync as execFileSync9 } from "node:child_process";
4
+ import { execFileSync as execFileSync8 } from "node:child_process";
5
5
  // ../../packages/aeg-core/src/gate-audience.ts
6
6
  var GATE_AUDIENCE = {
7
7
  "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
@@ -1885,45 +1885,6 @@ var DERIVED_STATUSES = [
1885
1885
  "incoherent"
1886
1886
  ];
1887
1887
  var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
1888
- // ../../packages/aeg-core/src/parse-ledger.ts
1889
- function rowFromCells(cells) {
1890
- if (cells.length < 7)
1891
- return null;
1892
- const phase = (cells[0] ?? "").trim();
1893
- if (!phase)
1894
- return null;
1895
- return {
1896
- phase,
1897
- role: (cells[1] ?? "").trim(),
1898
- agentModel: (cells[2] ?? "").trim(),
1899
- tokensIn: parseIntCell(cells[3] ?? ""),
1900
- tokensOut: parseIntCell(cells[4] ?? ""),
1901
- cost: parseCostCell(cells[5] ?? ""),
1902
- date: (cells[6] ?? "").trim()
1903
- };
1904
- }
1905
- function parseIntCell(cell) {
1906
- const trimmed = cell.replace(/`/g, "").trim();
1907
- if (!trimmed || isEmDashOrDash(trimmed))
1908
- return null;
1909
- const normalized = trimmed.replace(/[,_\s]/g, "");
1910
- if (!/^-?\d+$/.test(normalized))
1911
- return null;
1912
- return Number(normalized);
1913
- }
1914
- function parseCostCell(cell) {
1915
- const trimmed = cell.replace(/`/g, "").trim();
1916
- if (!trimmed || isEmDashOrDash(trimmed))
1917
- return null;
1918
- const normalized = trimmed.replace(/^\$/, "").replace(/[,_\s]/g, "");
1919
- if (!/^-?\d+(\.\d+)?$/.test(normalized))
1920
- return null;
1921
- return Number(normalized);
1922
- }
1923
- function isEmDashOrDash(s) {
1924
- const t = s.trim();
1925
- return t === "—" || t === "-" || t === "–";
1926
- }
1927
1888
  // ../../packages/aeg-core/src/waiver-label.ts
1928
1889
  var WAIVER_LABEL = label("waiver-docs");
1929
1890
  var WAIVER_LABEL_REVIEW = label("waiver-review");
@@ -1939,61 +1900,6 @@ function isWaiverLabelActorVerified(opts) {
1939
1900
  return false;
1940
1901
  return isPrincipal(opts.labelActor, opts.principalAllowlist);
1941
1902
  }
1942
-
1943
- // ../../packages/aeg-core/src/parse-token-report.ts
1944
- var TOKEN_REPORT_HEADING = /^\s*(?:#{1,6}\s*Token report\s*|\*\*Token report\*\*)\s*$/i;
1945
- 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;
1946
- function parseTokenReportEntries(body) {
1947
- const lines = body.split(/\r?\n/);
1948
- const headingIdxs = [];
1949
- lines.forEach((line, i) => {
1950
- if (TOKEN_REPORT_HEADING.test(line))
1951
- headingIdxs.push(i);
1952
- });
1953
- const out = [];
1954
- for (let h = 0;h < headingIdxs.length; h++) {
1955
- const start = headingIdxs[h] + 1;
1956
- const end = h + 1 < headingIdxs.length ? headingIdxs[h + 1] : lines.length;
1957
- const section = lines.slice(start, end).join(`
1958
- `);
1959
- const tableRows = parseTableSection(section);
1960
- if (tableRows.length > 0) {
1961
- out.push(...tableRows);
1962
- continue;
1963
- }
1964
- const inlineRow = parseInlineFieldList(section);
1965
- if (inlineRow)
1966
- out.push(inlineRow);
1967
- }
1968
- return out;
1969
- }
1970
- function parseTableSection(section) {
1971
- const lines = section.split(/\r?\n/);
1972
- let i = 0;
1973
- for (;i < lines.length; i++) {
1974
- if ((lines[i] ?? "").trim().startsWith("|"))
1975
- break;
1976
- }
1977
- if (i + 1 >= lines.length)
1978
- return [];
1979
- i += 2;
1980
- const out = [];
1981
- for (;i < lines.length; i++) {
1982
- const trimmed = (lines[i] ?? "").trim();
1983
- if (!trimmed.startsWith("|"))
1984
- break;
1985
- const row = rowFromCells(splitTableRow(trimmed));
1986
- if (row)
1987
- out.push(row);
1988
- }
1989
- return out;
1990
- }
1991
- function parseInlineFieldList(section) {
1992
- const m = section.match(INLINE_FIELD_LIST);
1993
- if (!m)
1994
- return null;
1995
- return rowFromCells([m[1], m[2], m[3], m[4], m[5], m[6], m[7]]);
1996
- }
1997
1903
  // ../../packages/aeg-core/src/verdict-extraction.ts
1998
1904
  var HEAD_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged head:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
1999
1905
  var OBJECTIVES_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Objectives version:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
@@ -2442,10 +2348,12 @@ function evaluateC5(changed, docOwnersContent, prBody, fileExists, waiverActive,
2442
2348
  var CODE_REVIEW_SEVERITY_ORDER = ["BLOCKER", "MAJOR", "MINOR"];
2443
2349
  var SECURITY_SEVERITY_ORDER = ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
2444
2350
  var DEFAULT_MAX_ROUNDS = 3;
2351
+ var DEFAULT_MAX_TASK_MINUTES = 180;
2445
2352
  var DEFAULT_REVIEW_POLICY = {
2446
2353
  codeReviewThreshold: "BLOCKER",
2447
2354
  securityThreshold: "HIGH",
2448
- maxRounds: DEFAULT_MAX_ROUNDS
2355
+ maxRounds: DEFAULT_MAX_ROUNDS,
2356
+ maxTaskMinutes: DEFAULT_MAX_TASK_MINUTES
2449
2357
  };
2450
2358
  var FILE_SHAPED_LOCATION = /\.[a-zA-Z0-9]{1,10}(:\d+)?\s*$/;
2451
2359
  var PROSE_LOCATION_PATTERNS = [/\bpr\s*body\b/i, /\bcomment\b/i];
@@ -2846,11 +2754,13 @@ function checkDocUpdateList(prBody) {
2846
2754
  return headingCheck(prBody, "(?:documentation|doc)[- ]update(?:\\s+list)?", "Documentation-update list");
2847
2755
  }
2848
2756
  function checkWorktreeStep0(prBody) {
2849
- if (/git worktree add/.test(prBody))
2757
+ if (/git worktree add/.test(prBody) || /cd \.worktrees\//.test(prBody) || /bun install --frozen-lockfile/.test(prBody))
2850
2758
  return { status: "pass", errors: [] };
2851
2759
  return {
2852
2760
  status: "fail",
2853
- errors: ["brief-validation worktree Step 0: no `git worktree add` command found in the PR body."]
2761
+ errors: [
2762
+ "brief-validation worktree Step 0: no `git worktree add`, `cd .worktrees/`, or `bun install --frozen-lockfile` command found in the PR body."
2763
+ ]
2854
2764
  };
2855
2765
  }
2856
2766
  function checkStopConditions(prBody) {
@@ -3040,7 +2950,8 @@ function isCommandBlock(content) {
3040
2950
  return COMMAND_WORDS.includes(commandWordOf(firstNonBlankLine(content)));
3041
2951
  }
3042
2952
  function isStep0Block(content) {
3043
- return firstNonBlankLine(content).startsWith("git worktree add");
2953
+ const first = firstNonBlankLine(content);
2954
+ return first.startsWith("git worktree add") || first.startsWith("cd .worktrees/") || first.startsWith("bun install --frozen-lockfile");
3044
2955
  }
3045
2956
  function checkCommandsCarryOutput(prBody) {
3046
2957
  const errors = [];
@@ -3509,10 +3420,14 @@ function legacySlugPattern(legacySlugs) {
3509
3420
  const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
3510
3421
  return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
3511
3422
  }
3423
+ function specGrandfatherPaths(specGrandfather) {
3424
+ return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
3425
+ }
3512
3426
  function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
3513
3427
  const findings = [];
3514
3428
  const legacyPattern = legacySlugPattern(legacySlugs);
3515
- const grandfathered = new Set(specGrandfather);
3429
+ const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
3430
+ const limits = new Map(Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather));
3516
3431
  const patterns = [
3517
3432
  { pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
3518
3433
  { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
@@ -3531,18 +3446,19 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
3531
3446
  continue;
3532
3447
  if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
3533
3448
  continue;
3534
- if (cls === "spec" && grandfathered.has(file.path))
3449
+ if (cls === "spec" && grandfatheredWhole.has(file.path))
3535
3450
  continue;
3536
3451
  const blocking = cls === "product" || cls === "spec";
3537
3452
  const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
3538
3453
  const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
3454
+ const fileFindings = [];
3539
3455
  for (const { pattern, what, group } of patternsToRun) {
3540
3456
  pattern.lastIndex = 0;
3541
3457
  let match = pattern.exec(scrubbed);
3542
3458
  while (match !== null) {
3543
3459
  const cited = group !== undefined ? match[group] ?? match[0] : match[0];
3544
3460
  const citedIndex = match.index + match[0].indexOf(cited);
3545
- findings.push({
3461
+ fileFindings.push({
3546
3462
  file: file.path,
3547
3463
  line: lineAt(scrubbed, citedIndex),
3548
3464
  message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
@@ -3551,6 +3467,15 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
3551
3467
  match = pattern.exec(scrubbed);
3552
3468
  }
3553
3469
  }
3470
+ const limit = cls === "spec" ? limits.get(file.path) : undefined;
3471
+ if (limit !== undefined) {
3472
+ if (fileFindings.length <= limit)
3473
+ continue;
3474
+ for (const f of fileFindings) {
3475
+ f.message += `; ${file.path} carries ${fileFindings.length} such findings, over its proseGates.specGrandfather limit of ${limit}`;
3476
+ }
3477
+ }
3478
+ findings.push(...fileFindings);
3554
3479
  }
3555
3480
  return findings;
3556
3481
  }
@@ -4510,8 +4435,7 @@ function briefHash(brief) {
4510
4435
  function policyDigest(policy) {
4511
4436
  return createHash4("sha256").update(JSON.stringify({
4512
4437
  codeReviewThreshold: policy.codeReviewThreshold,
4513
- securityThreshold: policy.securityThreshold,
4514
- maxRounds: policy.maxRounds
4438
+ securityThreshold: policy.securityThreshold
4515
4439
  })).digest("hex");
4516
4440
  }
4517
4441
  function isBoundToHead(echoed, headSha) {
@@ -4824,7 +4748,46 @@ function parseEnforcementRegistry(content) {
4824
4748
  return result;
4825
4749
  }
4826
4750
  // ../../packages/aeg-core/src/registry-checks.ts
4827
- function checkG1(rows, existsFn) {
4751
+ var HOOK_DIR_PREFIXES = [".claude/hooks/", ".vinaya/hooks/", ".husky/", ".git/hooks/"];
4752
+ var BARE_HOOK_NAME = /^check-[A-Za-z0-9_.-]*\.sh$/;
4753
+ function basename(path) {
4754
+ return path.slice(path.lastIndexOf("/") + 1);
4755
+ }
4756
+ function lineOf(content, index) {
4757
+ let line = 1;
4758
+ for (let i = 0;i < index; i++)
4759
+ if (content.charCodeAt(i) === 10)
4760
+ line++;
4761
+ return line;
4762
+ }
4763
+ function findUnshippedHookRefs(docs, shipped) {
4764
+ const shippedNames = new Set([...shipped].map(basename));
4765
+ const findings = [];
4766
+ const flag = (doc, token, index) => {
4767
+ findings.push({
4768
+ path: doc.path,
4769
+ reason: `${doc.path}:${lineOf(doc.content, index)} names hook "${token}", which is neither tracked in git nor emitted by \`vinaya init\``
4770
+ });
4771
+ };
4772
+ for (const doc of docs) {
4773
+ for (const { cited, index } of extractCitedPaths(doc.content)) {
4774
+ if (cited.endsWith("/") || !HOOK_DIR_PREFIXES.some((p) => cited.startsWith(p)))
4775
+ continue;
4776
+ if (!shipped.has(cited))
4777
+ flag(doc, cited, index);
4778
+ }
4779
+ const spanPattern = /`([^`\n]+)`/g;
4780
+ let match = spanPattern.exec(doc.content);
4781
+ while (match !== null) {
4782
+ const token = match[1] ?? "";
4783
+ if (BARE_HOOK_NAME.test(token) && !shippedNames.has(token))
4784
+ flag(doc, token, match.index);
4785
+ match = spanPattern.exec(doc.content);
4786
+ }
4787
+ }
4788
+ return findings;
4789
+ }
4790
+ function checkG1(rows, existsFn, hookRefs) {
4828
4791
  const findings = [];
4829
4792
  for (const row of rows) {
4830
4793
  if (row.implementation === "")
@@ -4837,6 +4800,8 @@ function checkG1(rows, existsFn) {
4837
4800
  });
4838
4801
  }
4839
4802
  }
4803
+ if (hookRefs)
4804
+ findings.push(...findUnshippedHookRefs(hookRefs.docs, hookRefs.shipped));
4840
4805
  return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
4841
4806
  }
4842
4807
  var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
@@ -5390,7 +5355,6 @@ var TaskPrPauseSchema = z.object({
5390
5355
  var TaskPrReviewRecordSchema = z.object({
5391
5356
  verdicts: z.array(TaskPrVerdictSchema),
5392
5357
  roundMarkers: z.array(z.number().int().nonnegative()),
5393
- summaryTable: z.string().nullable(),
5394
5358
  pause: TaskPrPauseSchema.nullable()
5395
5359
  });
5396
5360
  var TaskPrReadInputSchema = z.object({
@@ -5437,16 +5401,6 @@ var TaskCancelResultSchema = z.object({
5437
5401
  authenticatedFrom: z.string().min(1),
5438
5402
  fencedEffectKeys: z.array(z.string())
5439
5403
  });
5440
- var TASK_TOOL_NAMES = [
5441
- "task_start",
5442
- "task_status",
5443
- "task_escalation_read",
5444
- "task_pr_read",
5445
- "task_resume",
5446
- "task_cancel"
5447
- ];
5448
- var OPERATOR_STATUS_FOLLOW = "task_status_follow";
5449
- var OPERATOR_TOOL_GRANT = [...TASK_TOOL_NAMES, OPERATOR_STATUS_FOLLOW];
5450
5404
  // ../../packages/aeg-core/src/first-push-dispatch-gate.ts
5451
5405
  function parseTaskBranch(branch) {
5452
5406
  const m = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
@@ -5677,15 +5631,69 @@ var NO_GATE_CUTOVERS = {
5677
5631
  briefRulesSincePr: null,
5678
5632
  agentBoxesRefusedSincePr: null
5679
5633
  };
5680
- // ../../packages/aeg-core/src/dev-review-loop/types.ts
5681
- var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5682
- // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
5683
- var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
5684
- // ../../packages/aeg-core/src/log/envelope.ts
5685
- import { createHash as createHash5 } from "node:crypto";
5686
-
5687
5634
  // ../../packages/aeg-core/src/log/schema.ts
5635
+ import { z as z3 } from "zod";
5636
+
5637
+ // ../../packages/aeg-core/src/log/custom.ts
5688
5638
  import { z as z2 } from "zod";
5639
+ var CUSTOM_EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]*\.[a-z][a-z0-9_.]*$/;
5640
+ var CUSTOM_EVENT_NAME_MAX_LENGTH = 64;
5641
+ var CUSTOM_EVENT_RESERVED_NAMESPACE = "vinaya";
5642
+ var CUSTOM_EVENT_MAX_FIELDS = 20;
5643
+ var CUSTOM_FIELD_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
5644
+ var CUSTOM_FIELD_NAME_MAX_LENGTH = 64;
5645
+ var CUSTOM_TEXT_MAX_LENGTH = 500;
5646
+ var CUSTOM_WORD_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
5647
+ var CUSTOM_WORD_MAX_LENGTH = 64;
5648
+ var CUSTOM_FIELD_MAX_WORDS = 50;
5649
+ var CustomFieldTypeSchema = z2.union([z2.enum(["text", "number", "boolean"]), z2.array(z2.string())]);
5650
+ var CustomEventDeclarationsSchema = z2.record(z2.string(), z2.object({
5651
+ fields: z2.record(z2.string(), CustomFieldTypeSchema)
5652
+ }).strict()).superRefine((events, ctx) => {
5653
+ for (const [name, declaration] of Object.entries(events)) {
5654
+ const refuse = (message, path = []) => {
5655
+ ctx.addIssue({
5656
+ code: z2.ZodIssueCode.custom,
5657
+ path: [name, ...path],
5658
+ message: `logs.events "${name}": ${message}`
5659
+ });
5660
+ };
5661
+ if (name.length > CUSTOM_EVENT_NAME_MAX_LENGTH) {
5662
+ refuse(`the name must be at most ${CUSTOM_EVENT_NAME_MAX_LENGTH} characters`);
5663
+ }
5664
+ if (!CUSTOM_EVENT_NAME_PATTERN.test(name)) {
5665
+ refuse("the name must be `<namespace>.<event>` — lowercase letters, digits and `_`, a dot between them");
5666
+ } else if (name.split(".")[0] === CUSTOM_EVENT_RESERVED_NAMESPACE) {
5667
+ refuse(`the \`${CUSTOM_EVENT_RESERVED_NAMESPACE}.\` namespace is reserved for Vinaya's own events`);
5668
+ }
5669
+ const fieldEntries = Object.entries(declaration.fields);
5670
+ if (fieldEntries.length > CUSTOM_EVENT_MAX_FIELDS) {
5671
+ refuse(`at most ${CUSTOM_EVENT_MAX_FIELDS} fields may be declared (found ${fieldEntries.length})`, ["fields"]);
5672
+ }
5673
+ for (const [field, type] of fieldEntries) {
5674
+ if (field.length > CUSTOM_FIELD_NAME_MAX_LENGTH || !CUSTOM_FIELD_NAME_PATTERN.test(field)) {
5675
+ 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]);
5676
+ }
5677
+ if (typeof type === "string")
5678
+ continue;
5679
+ if (type.length === 0) {
5680
+ refuse(`field "${field}": a list of words must name at least one word`, ["fields", field]);
5681
+ }
5682
+ if (type.length > CUSTOM_FIELD_MAX_WORDS) {
5683
+ refuse(`field "${field}": a list of words may name at most ${CUSTOM_FIELD_MAX_WORDS}`, ["fields", field]);
5684
+ }
5685
+ const bad = type.filter((w) => w.length > CUSTOM_WORD_MAX_LENGTH || !CUSTOM_WORD_PATTERN.test(w));
5686
+ if (bad.length > 0) {
5687
+ refuse(`field "${field}": a listed word is lowercase letters, digits, \`_\` and \`-\`, at most ${CUSTOM_WORD_MAX_LENGTH} characters`, ["fields", field]);
5688
+ }
5689
+ if (new Set(type).size !== type.length) {
5690
+ refuse(`field "${field}": a list of words names a word twice`, ["fields", field]);
5691
+ }
5692
+ }
5693
+ }
5694
+ });
5695
+
5696
+ // ../../packages/aeg-core/src/log/schema.ts
5689
5697
  var CONFIDENCE_REASON_MAX_LENGTH = 280;
5690
5698
  var ROLE_VALUES = [
5691
5699
  "planner",
@@ -5696,178 +5704,210 @@ var ROLE_VALUES = [
5696
5704
  "archivist",
5697
5705
  "architect"
5698
5706
  ];
5699
- var RoleSchema = z2.enum(ROLE_VALUES);
5707
+ var RoleSchema = z3.enum(ROLE_VALUES);
5700
5708
  var HOST_VALUES = ["hook", "ci", "cli", "loop"];
5701
- var HostSchema = z2.enum(HOST_VALUES);
5709
+ var HostSchema = z3.enum(HOST_VALUES);
5702
5710
  var RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
5703
5711
  var headerMetaCore = {
5704
- ts: z2.string(),
5705
- run_id: z2.string().regex(RUN_ID_PATTERN),
5706
- seq: z2.number().int().nonnegative(),
5707
- repo: z2.string().nullable(),
5708
- vinaya: z2.string(),
5709
- doctrine: z2.string(),
5712
+ ts: z3.string(),
5713
+ run_id: z3.string().regex(RUN_ID_PATTERN),
5714
+ seq: z3.number().int().nonnegative(),
5715
+ repo: z3.string().nullable(),
5716
+ vinaya: z3.string(),
5717
+ doctrine: z3.string(),
5710
5718
  host: HostSchema,
5711
- machine: z2.string()
5719
+ machine: z3.string()
5712
5720
  };
5713
- var HeaderMetaV1Schema = z2.object({
5714
- schema: z2.literal(1),
5721
+ var HeaderMetaV1Schema = z3.object({
5722
+ schema: z3.literal(1),
5715
5723
  ...headerMetaCore
5716
5724
  }).strict();
5717
- var LineageSchema = z2.object({
5718
- run: z2.string().nullable(),
5719
- attempt: z2.number().int().nullable(),
5720
- parent: z2.string().nullable()
5725
+ var LineageSchema = z3.object({
5726
+ run: z3.string().nullable(),
5727
+ attempt: z3.number().int().nullable(),
5728
+ parent: z3.string().nullable()
5721
5729
  }).strict();
5722
- var InputVersionsSchema = z2.object({
5723
- objectives_version: z2.string().nullable(),
5724
- brief_hash: z2.string().nullable(),
5725
- ruling_ordinal: z2.number().int().nullable(),
5726
- policy_digest: z2.string().nullable()
5730
+ var InputVersionsSchema = z3.object({
5731
+ objectives_version: z3.string().nullable(),
5732
+ brief_hash: z3.string().nullable(),
5733
+ ruling_ordinal: z3.number().int().nullable(),
5734
+ policy_digest: z3.string().nullable()
5727
5735
  }).strict();
5728
- var ProvenanceSchema = z2.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
5729
- var HeaderMetaV2Schema = z2.object({
5730
- schema: z2.literal(2),
5736
+ var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
5737
+ var HeaderMetaV2Schema = z3.object({
5738
+ schema: z3.literal(2),
5731
5739
  ...headerMetaCore,
5732
- event_id: z2.string().min(1),
5733
- process_id: z2.string().min(1),
5734
- actor_id: z2.string().nullable(),
5740
+ event_id: z3.string().min(1),
5741
+ process_id: z3.string().min(1),
5742
+ actor_id: z3.string().nullable(),
5735
5743
  lineage: LineageSchema,
5736
5744
  input_versions: InputVersionsSchema,
5737
5745
  provenance: ProvenanceSchema
5738
5746
  }).strict();
5739
- var HeaderMetaSchema = z2.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema]);
5740
- var SubjectSchema = z2.object({
5741
- issue: z2.number().int().nullable(),
5742
- pr: z2.number().int().optional(),
5743
- sha: z2.string().optional(),
5744
- role: z2.union([RoleSchema, z2.literal("unattributed")]),
5745
- round: z2.number().int().optional(),
5746
- objectives_version: z2.string().optional()
5747
+ var WorkSchema = z3.object({
5748
+ ref: z3.string().nullable(),
5749
+ repo: z3.string().nullable(),
5750
+ change: z3.string().nullable(),
5751
+ revision: z3.string().nullable()
5752
+ }).strict();
5753
+ var FlowSchema = z3.object({
5754
+ id: z3.string().nullable(),
5755
+ version: z3.string().nullable()
5747
5756
  }).strict();
5748
- var HeaderSchema = z2.object({
5757
+ var HeaderMetaV3Schema = z3.object({
5758
+ schema: z3.literal(3),
5759
+ ...headerMetaCore,
5760
+ event_id: z3.string().min(1),
5761
+ process_id: z3.string().min(1),
5762
+ actor_id: z3.string().nullable(),
5763
+ lineage: LineageSchema,
5764
+ input_versions: InputVersionsSchema,
5765
+ provenance: ProvenanceSchema,
5766
+ work: WorkSchema,
5767
+ flow: FlowSchema,
5768
+ runtime: z3.string().nullable(),
5769
+ source: z3.string().nullable()
5770
+ }).strict();
5771
+ var HeaderMetaSchema = z3.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema, HeaderMetaV3Schema]);
5772
+ var SubjectSchema = z3.object({
5773
+ issue: z3.number().int().nullable(),
5774
+ pr: z3.number().int().optional(),
5775
+ sha: z3.string().optional(),
5776
+ role: z3.union([RoleSchema, z3.literal("unattributed")]),
5777
+ round: z3.number().int().optional(),
5778
+ objectives_version: z3.string().optional()
5779
+ }).strict();
5780
+ var HeaderSchema = z3.object({
5749
5781
  meta: HeaderMetaSchema,
5750
5782
  subject: SubjectSchema
5751
5783
  }).strict();
5752
5784
  var envelopeTail = {
5753
- duration_ms: z2.number().nonnegative().optional(),
5754
- payload: z2.object({}).strict()
5785
+ duration_ms: z3.number().nonnegative().optional(),
5786
+ payload: z3.object({}).strict()
5755
5787
  };
5756
- var ReviewFindingSchema = z2.object({
5757
- id: z2.string(),
5758
- severity: z2.string(),
5759
- state: z2.string().optional(),
5760
- severity_scale: z2.string().optional(),
5761
- policy_treatment: z2.enum(["blocking", "non_blocking", "unavailable"]).optional(),
5762
- confidence: z2.number().min(0).max(1).optional(),
5763
- confidence_scale: z2.string().optional(),
5764
- confidence_source: z2.string().optional()
5788
+ var ReviewFindingSchema = z3.object({
5789
+ id: z3.string(),
5790
+ severity: z3.string(),
5791
+ state: z3.string().optional(),
5792
+ severity_scale: z3.string().optional(),
5793
+ policy_treatment: z3.enum(["blocking", "non_blocking", "unavailable"]).optional(),
5794
+ confidence: z3.number().min(0).max(1).optional(),
5795
+ confidence_scale: z3.string().optional(),
5796
+ confidence_source: z3.string().optional()
5765
5797
  }).strict();
5766
- var DispatchOutcomeSchema = z2.discriminatedUnion("type", [
5767
- z2.object({ type: z2.literal("pr_opened"), pr: z2.number().int(), head: z2.string() }).strict(),
5768
- z2.object({
5769
- type: z2.literal("round_pushed"),
5770
- pr: z2.number().int(),
5771
- head: z2.string(),
5772
- comment_id: z2.number().int()
5798
+ var DispatchOutcomeSchema = z3.discriminatedUnion("type", [
5799
+ z3.object({ type: z3.literal("pr_opened"), pr: z3.number().int(), head: z3.string() }).strict(),
5800
+ z3.object({
5801
+ type: z3.literal("round_pushed"),
5802
+ pr: z3.number().int(),
5803
+ head: z3.string(),
5804
+ comment_id: z3.number().int()
5773
5805
  }).strict(),
5774
- z2.object({
5775
- type: z2.literal("verdict"),
5776
- verdict: z2.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
5777
- head: z2.string(),
5778
- comment_id: z2.number().int(),
5779
- objectives: z2.array(z2.object({ id: z2.string(), met: z2.boolean() }).strict()),
5780
- findings: z2.array(ReviewFindingSchema)
5806
+ z3.object({
5807
+ type: z3.literal("verdict"),
5808
+ verdict: z3.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
5809
+ head: z3.string(),
5810
+ comment_id: z3.number().int(),
5811
+ objectives: z3.array(z3.object({ id: z3.string(), met: z3.boolean() }).strict()),
5812
+ findings: z3.array(ReviewFindingSchema)
5781
5813
  }).strict(),
5782
- z2.object({
5783
- type: z2.literal("escalation"),
5784
- class: z2.enum(["authority", "strategy", "product"]),
5785
- comment_id: z2.number().int()
5814
+ z3.object({
5815
+ type: z3.literal("escalation"),
5816
+ class: z3.enum(["authority", "strategy", "product"]),
5817
+ comment_id: z3.number().int()
5786
5818
  }).strict(),
5787
- z2.object({ type: z2.literal("brief"), comment_id: z2.number().int(), hash: z2.string() }).strict(),
5788
- z2.object({ type: z2.literal("plan"), issues: z2.array(z2.number().int()) }).strict(),
5789
- z2.object({ type: z2.literal("archive"), provenance_comment_id: z2.number().int() }).strict(),
5790
- z2.object({ type: z2.literal("completed") }).strict()
5819
+ z3.object({ type: z3.literal("brief"), comment_id: z3.number().int(), hash: z3.string() }).strict(),
5820
+ z3.object({ type: z3.literal("plan"), issues: z3.array(z3.number().int()) }).strict(),
5821
+ z3.object({ type: z3.literal("archive"), provenance_comment_id: z3.number().int() }).strict(),
5822
+ z3.object({ type: z3.literal("completed") }).strict()
5791
5823
  ]);
5792
5824
  var dispatchShared = {
5793
5825
  meta: HeaderMetaSchema,
5794
5826
  subject: SubjectSchema,
5795
- kind: z2.literal("dispatch"),
5827
+ kind: z3.literal("dispatch"),
5796
5828
  ...envelopeTail,
5797
5829
  target_role: RoleSchema,
5798
- model: z2.string(),
5799
- round: z2.number().int().optional(),
5800
- effect_id: z2.string()
5830
+ model: z3.string(),
5831
+ round: z3.number().int().optional(),
5832
+ effect_id: z3.string()
5801
5833
  };
5802
- var dispatchUsageField = z2.object({ input: z2.number().nonnegative(), output: z2.number().nonnegative() }).strict().nullable();
5803
- var DispatchEventSchema = z2.discriminatedUnion("event", [
5804
- z2.object({ ...dispatchShared, event: z2.literal("dispatched"), prompt_hash: z2.string() }).strict(),
5805
- z2.object({
5834
+ var dispatchUsageField = z3.object({ input: z3.number().nonnegative(), output: z3.number().nonnegative() }).strict().nullable();
5835
+ var DispatchEventSchema = z3.discriminatedUnion("event", [
5836
+ z3.object({ ...dispatchShared, event: z3.literal("dispatched"), prompt_hash: z3.string() }).strict(),
5837
+ z3.object({
5806
5838
  ...dispatchShared,
5807
- event: z2.literal("outcome_received"),
5839
+ event: z3.literal("outcome_received"),
5808
5840
  outcome: DispatchOutcomeSchema,
5809
5841
  usage: dispatchUsageField
5810
5842
  }).strict(),
5811
- z2.object({
5843
+ z3.object({
5812
5844
  ...dispatchShared,
5813
- event: z2.literal("dispatch_failed"),
5814
- reason: z2.enum(["timeout", "crash", "refused", "unattributed_write"]),
5845
+ event: z3.literal("dispatch_failed"),
5846
+ reason: z3.enum(["timeout", "crash", "refused", "unattributed_write"]),
5815
5847
  usage: dispatchUsageField
5816
5848
  }).strict()
5817
5849
  ]);
5850
+ var CODE_TOKEN_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
5851
+ var CodeTokenSchema = z3.string().regex(CODE_TOKEN_PATTERN);
5852
+ var ReviewerVerdictSchema = z3.object({
5853
+ role: RoleSchema,
5854
+ outcome: z3.enum(["approve", "changes_requested", "not_reviewed"]),
5855
+ blockers: z3.number().int().nonnegative()
5856
+ }).strict();
5818
5857
  var loopShared = {
5819
5858
  meta: HeaderMetaSchema,
5820
5859
  subject: SubjectSchema,
5821
- kind: z2.literal("dev_review_loop"),
5860
+ kind: z3.literal("dev_review_loop"),
5822
5861
  ...envelopeTail,
5823
- loop_id: z2.string()
5862
+ loop_id: z3.string()
5824
5863
  };
5825
- var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
5826
- z2.object({
5864
+ var DevReviewLoopEventSchema = z3.discriminatedUnion("event", [
5865
+ z3.object({
5827
5866
  ...loopShared,
5828
- event: z2.literal("loop_started"),
5829
- task: z2.number().int(),
5830
- policy: z2.object({
5831
- max_rounds: z2.number().int().nonnegative(),
5832
- reviewers: z2.array(RoleSchema),
5833
- models: z2.record(RoleSchema, z2.string())
5867
+ event: z3.literal("loop_started"),
5868
+ task: z3.number().int(),
5869
+ policy: z3.object({
5870
+ max_rounds: z3.number().int().nonnegative(),
5871
+ reviewers: z3.array(RoleSchema),
5872
+ models: z3.record(RoleSchema, z3.string())
5834
5873
  }).strict()
5835
5874
  }).strict(),
5836
- z2.object({ ...loopShared, event: z2.literal("round_started"), round: z2.number().int(), base_head: z2.string() }).strict(),
5837
- z2.object({
5875
+ z3.object({ ...loopShared, event: z3.literal("round_started"), round: z3.number().int(), base_head: z3.string() }).strict(),
5876
+ z3.object({
5838
5877
  ...loopShared,
5839
- event: z2.literal("gate_result_read"),
5840
- round: z2.number().int(),
5841
- head: z2.string(),
5842
- green: z2.boolean(),
5843
- confidence_value: z2.number().int().min(0).max(100).optional(),
5844
- confidence_reason: z2.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
5845
- confidence_unavailable: z2.boolean().optional(),
5846
- extra_turn_spent: z2.boolean().optional()
5878
+ event: z3.literal("gate_result_read"),
5879
+ round: z3.number().int(),
5880
+ head: z3.string(),
5881
+ green: z3.boolean(),
5882
+ confidence_value: z3.number().int().min(0).max(100).optional(),
5883
+ confidence_reason: z3.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
5884
+ confidence_unavailable: z3.boolean().optional(),
5885
+ extra_turn_spent: z3.boolean().optional()
5847
5886
  }).strict(),
5848
- z2.object({
5887
+ z3.object({
5849
5888
  ...loopShared,
5850
- event: z2.literal("verdicts_read"),
5851
- round: z2.number().int(),
5852
- head: z2.string(),
5853
- all_approve: z2.boolean(),
5854
- blockers: z2.number().int().nonnegative(),
5855
- findings: z2.array(ReviewFindingSchema).optional()
5889
+ event: z3.literal("verdicts_read"),
5890
+ round: z3.number().int(),
5891
+ head: z3.string(),
5892
+ all_approve: z3.boolean(),
5893
+ blockers: z3.number().int().nonnegative(),
5894
+ findings: z3.array(ReviewFindingSchema).optional(),
5895
+ reviewers: z3.array(ReviewerVerdictSchema).optional()
5856
5896
  }).strict(),
5857
- z2.object({
5897
+ z3.object({
5858
5898
  ...loopShared,
5859
- event: z2.literal("findings_compared"),
5860
- round: z2.number().int(),
5861
- open: z2.array(z2.string()),
5862
- resolved: z2.array(z2.string()),
5863
- new: z2.array(z2.string()),
5864
- recurring: z2.array(z2.string())
5899
+ event: z3.literal("findings_compared"),
5900
+ round: z3.number().int(),
5901
+ open: z3.array(z3.string()),
5902
+ resolved: z3.array(z3.string()),
5903
+ new: z3.array(z3.string()),
5904
+ recurring: z3.array(z3.string())
5865
5905
  }).strict(),
5866
- z2.object({
5906
+ z3.object({
5867
5907
  ...loopShared,
5868
- event: z2.literal("stop_condition_met"),
5869
- round: z2.number().int(),
5870
- condition: z2.enum([
5908
+ event: z3.literal("stop_condition_met"),
5909
+ round: z3.number().int(),
5910
+ condition: z3.enum([
5871
5911
  "green",
5872
5912
  "max_rounds",
5873
5913
  "no_progress",
@@ -5876,66 +5916,85 @@ var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
5876
5916
  "confidence",
5877
5917
  "reappearance",
5878
5918
  "repeat_finding",
5879
- "repeat_failure"
5919
+ "repeat_failure",
5920
+ "time_budget"
5880
5921
  ])
5881
5922
  }).strict(),
5882
- z2.object({
5923
+ z3.object({
5883
5924
  ...loopShared,
5884
- event: z2.literal("paused"),
5885
- round: z2.number().int(),
5886
- reason: z2.enum(["escalation", "principal_item", "refreeze_needed"])
5925
+ event: z3.literal("paused"),
5926
+ round: z3.number().int(),
5927
+ reason: z3.enum(["escalation", "principal_item", "refreeze_needed"]),
5928
+ reason_code: CodeTokenSchema.optional()
5887
5929
  }).strict(),
5888
- z2.object({
5930
+ z3.object({
5889
5931
  ...loopShared,
5890
- event: z2.literal("resumed"),
5891
- round: z2.number().int(),
5892
- by: z2.enum(["principal", "driver"])
5932
+ event: z3.literal("resumed"),
5933
+ round: z3.number().int(),
5934
+ by: z3.enum(["principal", "driver"])
5893
5935
  }).strict(),
5894
- z2.object({
5936
+ z3.object({
5895
5937
  ...loopShared,
5896
- event: z2.literal("cancelled"),
5897
- round: z2.number().int(),
5898
- by: z2.literal("principal")
5938
+ event: z3.literal("cancelled"),
5939
+ round: z3.number().int(),
5940
+ by: z3.literal("principal")
5899
5941
  }).strict(),
5900
- z2.object({
5942
+ z3.object({
5901
5943
  ...loopShared,
5902
- event: z2.literal("unpushed_work_resume"),
5903
- round: z2.number().int(),
5904
- branch: z2.string(),
5905
- detail: z2.string()
5944
+ event: z3.literal("unpushed_work_resume"),
5945
+ round: z3.number().int(),
5946
+ branch: z3.string(),
5947
+ detail: z3.string()
5906
5948
  }).strict(),
5907
- z2.object({
5949
+ z3.object({
5908
5950
  ...loopShared,
5909
- event: z2.literal("round_ended"),
5910
- round: z2.number().int(),
5911
- base_head: z2.string(),
5912
- head: z2.string(),
5913
- files_changed: z2.number().int().nonnegative(),
5914
- insertions: z2.number().int().nonnegative(),
5915
- deletions: z2.number().int().nonnegative(),
5916
- wall_ms: z2.number().nonnegative(),
5917
- outcome: z2.enum(["green", "changes_requested", "escalated"])
5951
+ event: z3.literal("round_ended"),
5952
+ round: z3.number().int(),
5953
+ base_head: z3.string(),
5954
+ head: z3.string(),
5955
+ files_changed: z3.number().int().nonnegative(),
5956
+ insertions: z3.number().int().nonnegative(),
5957
+ deletions: z3.number().int().nonnegative(),
5958
+ wall_ms: z3.number().nonnegative(),
5959
+ outcome: z3.enum(["green", "changes_requested", "escalated"])
5918
5960
  }).strict(),
5919
- z2.object({
5961
+ z3.object({
5920
5962
  ...loopShared,
5921
- event: z2.literal("journal_finalized"),
5922
- rounds: z2.number().int().nonnegative(),
5923
- total_wall_ms: z2.number().nonnegative(),
5924
- time_to_green_ms: z2.number().nonnegative().nullable(),
5925
- files_changed_total: z2.number().int().nonnegative(),
5926
- final_head: z2.string(),
5927
- result: z2.enum(["merged_ready", "stopped"])
5963
+ event: z3.literal("journal_finalized"),
5964
+ rounds: z3.number().int().nonnegative(),
5965
+ total_wall_ms: z3.number().nonnegative(),
5966
+ time_to_green_ms: z3.number().nonnegative().nullable(),
5967
+ files_changed_total: z3.number().int().nonnegative(),
5968
+ final_head: z3.string(),
5969
+ result: z3.enum(["merged_ready", "stopped"])
5928
5970
  }).strict(),
5929
- z2.object({
5971
+ z3.object({
5930
5972
  ...loopShared,
5931
- event: z2.literal("infrastructure_retry"),
5932
- round: z2.number().int(),
5933
- failure_kind: z2.enum(["pause_comment_post", "developer_connection"]),
5934
- attempts: z2.number().int().positive(),
5935
- outcome: z2.enum(["recovered", "exhausted"])
5973
+ event: z3.literal("infrastructure_retry"),
5974
+ round: z3.number().int(),
5975
+ failure_kind: z3.enum(["pause_comment_post", "developer_connection"]),
5976
+ attempts: z3.number().int().positive(),
5977
+ outcome: z3.enum(["recovered", "exhausted"])
5978
+ }).strict(),
5979
+ z3.object({
5980
+ ...loopShared,
5981
+ event: z3.literal("driver_heartbeat"),
5982
+ task: z3.number().int(),
5983
+ pr: z3.number().int().positive().optional(),
5984
+ round: z3.number().int(),
5985
+ phase: z3.string()
5986
+ }).strict(),
5987
+ z3.object({
5988
+ ...loopShared,
5989
+ event: z3.literal("driver_exited"),
5990
+ task: z3.number().int(),
5991
+ reason: z3.enum(["finished", "paused", "reexec", "error", "signal"]),
5992
+ last_decision: z3.string(),
5993
+ exit_code: z3.number().int().optional(),
5994
+ error_class: CodeTokenSchema.optional()
5936
5995
  }).strict()
5937
5996
  ]);
5938
- var ForgeOpSchema = z2.enum([
5997
+ var ForgeOpSchema = z3.enum([
5939
5998
  "pr.create",
5940
5999
  "pr.comment",
5941
6000
  "pr.body.replace",
@@ -5949,24 +6008,24 @@ var ForgeOpSchema = z2.enum([
5949
6008
  "label.add",
5950
6009
  "label.remove"
5951
6010
  ]);
5952
- var ForgeWriteTargetSchema = z2.object({
5953
- issue: z2.number().int().optional(),
5954
- pr: z2.number().int().optional()
6011
+ var ForgeWriteTargetSchema = z3.object({
6012
+ issue: z3.number().int().optional(),
6013
+ pr: z3.number().int().optional()
5955
6014
  }).strict();
5956
6015
  var forgeWriteShared = {
5957
6016
  meta: HeaderMetaSchema,
5958
6017
  subject: SubjectSchema,
5959
- kind: z2.literal("forge_write"),
6018
+ kind: z3.literal("forge_write"),
5960
6019
  ...envelopeTail,
5961
6020
  op: ForgeOpSchema,
5962
6021
  target: ForgeWriteTargetSchema
5963
6022
  };
5964
- var ForgeWriteEventSchema = z2.discriminatedUnion("event", [
5965
- z2.object({ ...forgeWriteShared, event: z2.literal("validated") }).strict(),
5966
- z2.object({ ...forgeWriteShared, event: z2.literal("refused"), reason: z2.string() }).strict(),
5967
- z2.object({ ...forgeWriteShared, event: z2.literal("written"), comment_ids: z2.array(z2.string()) }).strict()
6023
+ var ForgeWriteEventSchema = z3.discriminatedUnion("event", [
6024
+ z3.object({ ...forgeWriteShared, event: z3.literal("validated") }).strict(),
6025
+ z3.object({ ...forgeWriteShared, event: z3.literal("refused"), reason: z3.string() }).strict(),
6026
+ z3.object({ ...forgeWriteShared, event: z3.literal("written"), comment_ids: z3.array(z3.string()) }).strict()
5968
6027
  ]);
5969
- var GateOutcomeSchema = z2.enum([
6028
+ var GateOutcomeSchema = z3.enum([
5970
6029
  "pass",
5971
6030
  "fail",
5972
6031
  "wait",
@@ -5979,61 +6038,74 @@ var GateOutcomeSchema = z2.enum([
5979
6038
  var gateShared = {
5980
6039
  meta: HeaderMetaSchema,
5981
6040
  subject: SubjectSchema,
5982
- kind: z2.literal("gate"),
6041
+ kind: z3.literal("gate"),
5983
6042
  ...envelopeTail,
5984
- check: z2.string(),
5985
- check_version: z2.string().nullable(),
5986
- policy_version: z2.string().nullable(),
5987
- input_fingerprint: z2.string().nullable()
6043
+ check: z3.string(),
6044
+ check_version: z3.string().nullable(),
6045
+ policy_version: z3.string().nullable(),
6046
+ input_fingerprint: z3.string().nullable()
5988
6047
  };
5989
- var GateEventSchema = z2.discriminatedUnion("event", [
5990
- z2.object({
6048
+ var GateEventSchema = z3.discriminatedUnion("event", [
6049
+ z3.object({
5991
6050
  ...gateShared,
5992
- event: z2.literal("checked"),
6051
+ event: z3.literal("checked"),
5993
6052
  outcome: GateOutcomeSchema,
5994
- reason: z2.string().optional()
6053
+ reason: z3.string().optional()
6054
+ }).strict(),
6055
+ z3.object({
6056
+ meta: HeaderMetaSchema,
6057
+ subject: SubjectSchema,
6058
+ kind: z3.literal("gate"),
6059
+ ...envelopeTail,
6060
+ event: z3.literal("summary"),
6061
+ ran: z3.number().int().nonnegative(),
6062
+ passed: z3.number().int().nonnegative(),
6063
+ failed: z3.number().int().nonnegative(),
6064
+ skipped: z3.number().int().nonnegative(),
6065
+ failed_checks: z3.array(z3.string())
5995
6066
  }).strict()
5996
6067
  ]);
5997
- var OperationResultSchema = z2.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
6068
+ var OperationResultSchema = z3.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
5998
6069
  var operationShared = {
5999
6070
  meta: HeaderMetaSchema,
6000
6071
  subject: SubjectSchema,
6001
- kind: z2.literal("operation"),
6072
+ kind: z3.literal("operation"),
6002
6073
  ...envelopeTail,
6003
- operation: z2.string(),
6004
- target: z2.string().nullable()
6074
+ operation: z3.string(),
6075
+ target: z3.string().nullable()
6005
6076
  };
6006
- var OperationEventSchema = z2.discriminatedUnion("event", [
6007
- z2.object({
6077
+ var OperationEventSchema = z3.discriminatedUnion("event", [
6078
+ z3.object({
6008
6079
  ...operationShared,
6009
- event: z2.literal("completed"),
6080
+ event: z3.literal("completed"),
6010
6081
  result: OperationResultSchema,
6011
- error_class: z2.string().nullable()
6082
+ error_class: z3.string().nullable(),
6083
+ field_names: z3.array(z3.string().max(CUSTOM_FIELD_NAME_MAX_LENGTH)).max(CUSTOM_EVENT_MAX_FIELDS).optional()
6012
6084
  }).strict()
6013
6085
  ]);
6014
- var UsageUnitsSchema = z2.object({
6015
- input: z2.number().nonnegative().nullable(),
6016
- output: z2.number().nonnegative().nullable(),
6017
- cache: z2.number().nonnegative().nullable()
6086
+ var UsageUnitsSchema = z3.object({
6087
+ input: z3.number().nonnegative().nullable(),
6088
+ output: z3.number().nonnegative().nullable(),
6089
+ cache: z3.number().nonnegative().nullable()
6018
6090
  }).strict();
6019
6091
  var usageShared = {
6020
6092
  meta: HeaderMetaSchema,
6021
6093
  subject: SubjectSchema,
6022
- kind: z2.literal("usage"),
6094
+ kind: z3.literal("usage"),
6023
6095
  ...envelopeTail,
6024
- model: z2.string().nullable(),
6025
- source: z2.string(),
6026
- semantics: z2.enum(["cumulative", "delta"])
6096
+ model: z3.string().nullable(),
6097
+ source: z3.string(),
6098
+ semantics: z3.enum(["cumulative", "delta"])
6027
6099
  };
6028
- var UsageEventSchema = z2.discriminatedUnion("event", [
6029
- z2.object({
6100
+ var UsageEventSchema = z3.discriminatedUnion("event", [
6101
+ z3.object({
6030
6102
  ...usageShared,
6031
- event: z2.literal("observed"),
6103
+ event: z3.literal("observed"),
6032
6104
  units: UsageUnitsSchema,
6033
- unknown_reason: z2.string().nullable()
6105
+ unknown_reason: z3.string().nullable()
6034
6106
  }).strict()
6035
6107
  ]);
6036
- var RoleAttemptOutcomeSchema = z2.enum([
6108
+ var RoleAttemptOutcomeSchema = z3.enum([
6037
6109
  "completed",
6038
6110
  "incomplete",
6039
6111
  "infrastructure_failed",
@@ -6044,17 +6116,17 @@ var RoleAttemptOutcomeSchema = z2.enum([
6044
6116
  var roleAttemptShared = {
6045
6117
  meta: HeaderMetaSchema,
6046
6118
  subject: SubjectSchema,
6047
- kind: z2.literal("role_attempt"),
6119
+ kind: z3.literal("role_attempt"),
6048
6120
  ...envelopeTail,
6049
- actor: z2.string().nullable(),
6050
- attempt: z2.number().int().nullable(),
6051
- effect_id: z2.string(),
6052
- model: z2.string().nullable()
6121
+ actor: z3.string().nullable(),
6122
+ attempt: z3.number().int().nullable(),
6123
+ effect_id: z3.string(),
6124
+ model: z3.string().nullable()
6053
6125
  };
6054
- var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
6055
- z2.object({
6126
+ var RoleAttemptEventSchema = z3.discriminatedUnion("event", [
6127
+ z3.object({
6056
6128
  ...roleAttemptShared,
6057
- event: z2.literal("attempted"),
6129
+ event: z3.literal("attempted"),
6058
6130
  outcome: RoleAttemptOutcomeSchema,
6059
6131
  usage: dispatchUsageField
6060
6132
  }).strict()
@@ -6062,42 +6134,59 @@ var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
6062
6134
  var handoffShared = {
6063
6135
  meta: HeaderMetaSchema,
6064
6136
  subject: SubjectSchema,
6065
- kind: z2.literal("handoff"),
6137
+ kind: z3.literal("handoff"),
6066
6138
  ...envelopeTail,
6067
- class: z2.enum(["authority", "strategy", "product"]),
6068
- reason: z2.string()
6139
+ class: z3.enum(["authority", "strategy", "product"]),
6140
+ reason: z3.string()
6069
6141
  };
6070
- var HandoffEventSchema = z2.discriminatedUnion("event", [
6071
- z2.object({
6142
+ var HandoffEventSchema = z3.discriminatedUnion("event", [
6143
+ z3.object({
6072
6144
  ...handoffShared,
6073
- event: z2.literal("raised"),
6074
- requested_decision: z2.string().nullable()
6145
+ event: z3.literal("raised"),
6146
+ requested_decision: z3.string().nullable()
6075
6147
  }).strict(),
6076
- z2.object({
6148
+ z3.object({
6077
6149
  ...handoffShared,
6078
- event: z2.literal("resolved"),
6079
- resolution: z2.string().nullable(),
6080
- resolved_by: z2.string().nullable()
6150
+ event: z3.literal("resolved"),
6151
+ resolution: z3.string().nullable(),
6152
+ resolved_by: z3.string().nullable()
6081
6153
  }).strict()
6082
6154
  ]);
6083
- var EffectTargetSchema = z2.object({
6084
- kind: z2.string(),
6085
- ref: z2.string()
6155
+ var EffectTargetSchema = z3.object({
6156
+ kind: z3.string(),
6157
+ ref: z3.string()
6086
6158
  }).strict();
6087
6159
  var effectShared = {
6088
6160
  meta: HeaderMetaSchema,
6089
6161
  subject: SubjectSchema,
6090
- kind: z2.literal("effect"),
6162
+ kind: z3.literal("effect"),
6091
6163
  ...envelopeTail,
6092
- effect_id: z2.string(),
6164
+ effect_id: z3.string(),
6093
6165
  target: EffectTargetSchema
6094
6166
  };
6095
- var EffectEventSchema = z2.discriminatedUnion("event", [
6096
- z2.object({ ...effectShared, event: z2.literal("attempted") }).strict(),
6097
- z2.object({ ...effectShared, event: z2.literal("observed"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict(),
6098
- z2.object({ ...effectShared, event: z2.literal("verified"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict()
6167
+ var EffectEventSchema = z3.discriminatedUnion("event", [
6168
+ z3.object({ ...effectShared, event: z3.literal("attempted") }).strict(),
6169
+ z3.object({ ...effectShared, event: z3.literal("observed"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict(),
6170
+ z3.object({ ...effectShared, event: z3.literal("verified"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict()
6099
6171
  ]);
6100
- var LogEventSchema = z2.union([
6172
+ var CustomFieldValueSchema = z3.union([z3.string().max(CUSTOM_TEXT_MAX_LENGTH), z3.number().finite(), z3.boolean()]);
6173
+ var customShared = {
6174
+ meta: HeaderMetaV3Schema,
6175
+ subject: SubjectSchema,
6176
+ kind: z3.literal("custom"),
6177
+ ...envelopeTail
6178
+ };
6179
+ var CustomEventSchema = z3.discriminatedUnion("event", [
6180
+ z3.object({
6181
+ ...customShared,
6182
+ event: z3.literal("recorded"),
6183
+ name: z3.string().max(CUSTOM_EVENT_NAME_MAX_LENGTH).regex(CUSTOM_EVENT_NAME_PATTERN),
6184
+ 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, {
6185
+ message: `custom: at most ${CUSTOM_EVENT_MAX_FIELDS} fields`
6186
+ })
6187
+ }).strict()
6188
+ ]);
6189
+ var LogEventSchema = z3.union([
6101
6190
  DispatchEventSchema,
6102
6191
  DevReviewLoopEventSchema,
6103
6192
  ForgeWriteEventSchema,
@@ -6106,10 +6195,11 @@ var LogEventSchema = z2.union([
6106
6195
  UsageEventSchema,
6107
6196
  RoleAttemptEventSchema,
6108
6197
  HandoffEventSchema,
6109
- EffectEventSchema
6198
+ EffectEventSchema,
6199
+ CustomEventSchema
6110
6200
  ]);
6111
-
6112
6201
  // ../../packages/aeg-core/src/log/envelope.ts
6202
+ import { createHash as createHash5 } from "node:crypto";
6113
6203
  function isRole(value) {
6114
6204
  return value !== undefined && ROLE_VALUES.includes(value);
6115
6205
  }
@@ -6146,18 +6236,27 @@ function roundFromEnv(round) {
6146
6236
  const n = Number(round);
6147
6237
  return Number.isInteger(n) ? n : undefined;
6148
6238
  }
6239
+ function prFromEnv(pr) {
6240
+ if (pr === undefined || pr === "")
6241
+ return;
6242
+ const n = Number(pr);
6243
+ return Number.isInteger(n) && n > 0 ? n : undefined;
6244
+ }
6149
6245
  function buildHeader(input) {
6150
6246
  const role = isRole(input.env.role) ? input.env.role : "unattributed";
6151
6247
  const round = roundFromEnv(input.env.round);
6248
+ const pr = prFromEnv(input.env.pr);
6152
6249
  const subject = {
6153
6250
  issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
6154
6251
  role,
6155
6252
  ...round !== undefined ? { round } : {},
6253
+ ...pr !== undefined ? { pr } : {},
6156
6254
  ...input.subject ?? {}
6157
6255
  };
6256
+ const issue = subject.issue;
6158
6257
  return {
6159
6258
  meta: {
6160
- schema: 2,
6259
+ schema: 3,
6161
6260
  ts: input.now.toISOString(),
6162
6261
  run_id: input.runId,
6163
6262
  seq: input.seq,
@@ -6180,7 +6279,19 @@ function buildHeader(input) {
6180
6279
  ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
6181
6280
  policy_digest: input.inputVersions?.policyDigest ?? null
6182
6281
  },
6183
- provenance: provenanceFor(input)
6282
+ provenance: provenanceFor(input),
6283
+ work: {
6284
+ ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
6285
+ repo: input.repo,
6286
+ change: null,
6287
+ revision: null
6288
+ },
6289
+ flow: {
6290
+ id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
6291
+ version: lineageFieldFromEnv(input.env.flowVersion)
6292
+ },
6293
+ runtime: lineageFieldFromEnv(input.env.runtime),
6294
+ source: lineageFieldFromEnv(input.env.source)
6184
6295
  },
6185
6296
  subject
6186
6297
  };
@@ -6223,7 +6334,7 @@ function redact(value, home) {
6223
6334
  return value;
6224
6335
  }
6225
6336
  // ../../packages/aeg-core/src/log/store.ts
6226
- var KNOWN_SCHEMA_VERSIONS = [1, 2];
6337
+ var KNOWN_SCHEMA_VERSIONS = [1, 2, 3];
6227
6338
  function metaOf(obj) {
6228
6339
  if (obj === null || typeof obj !== "object")
6229
6340
  return null;
@@ -6289,7 +6400,7 @@ function classifyStoredLine(raw, home) {
6289
6400
  return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
6290
6401
  }
6291
6402
  const redacted = redact(event, home);
6292
- const provenance = version === 2 ? event.meta.provenance ?? null : null;
6403
+ const provenance = version >= 2 ? event.meta.provenance ?? null : null;
6293
6404
  return {
6294
6405
  status: "ok",
6295
6406
  identity,
@@ -6302,145 +6413,150 @@ function classifyStoredLine(raw, home) {
6302
6413
  };
6303
6414
  }
6304
6415
  // ../../packages/aeg-core/src/control-store/records.ts
6305
- import { z as z3 } from "zod";
6306
- var isoTimestamp = z3.string().min(1);
6307
- var taskId = z3.number().int().positive();
6308
- var epochNumber = z3.number().int().nonnegative();
6309
- var RunRecordSchema = z3.object({
6310
- version: z3.literal(1),
6311
- kind: z3.literal("run"),
6416
+ import { z as z4 } from "zod";
6417
+ var isoTimestamp = z4.string().min(1);
6418
+ var taskId = z4.number().int().positive();
6419
+ var epochNumber = z4.number().int().nonnegative();
6420
+ var RunRecordSchema = z4.object({
6421
+ version: z4.literal(1),
6422
+ kind: z4.literal("run"),
6312
6423
  task: taskId,
6313
- runId: z3.string().min(1),
6314
- pid: z3.number().int().positive(),
6315
- host: z3.string().min(1),
6424
+ runId: z4.string().min(1),
6425
+ pid: z4.number().int().positive(),
6426
+ host: z4.string().min(1),
6316
6427
  startedAt: isoTimestamp,
6317
- childStartedAt: z3.string().min(1).nullable().optional(),
6318
- childCommand: z3.string().min(1).nullable().optional()
6428
+ childStartedAt: z4.string().min(1).nullable().optional(),
6429
+ childCommand: z4.string().min(1).nullable().optional()
6319
6430
  }).strict();
6320
- var InputRecordSchema = z3.object({
6321
- version: z3.literal(1),
6322
- kind: z3.literal("input"),
6431
+ var InputRecordSchema = z4.object({
6432
+ version: z4.literal(1),
6433
+ kind: z4.literal("input"),
6323
6434
  task: taskId,
6324
- runId: z3.string().min(1),
6325
- source: z3.union([z3.literal("fresh"), z3.literal("resume")]),
6326
- pr: z3.number().int().positive().nullable(),
6327
- round: z3.number().int().nonnegative(),
6435
+ runId: z4.string().min(1),
6436
+ source: z4.union([z4.literal("fresh"), z4.literal("resume")]),
6437
+ pr: z4.number().int().positive().nullable(),
6438
+ round: z4.number().int().nonnegative(),
6328
6439
  recordedAt: isoTimestamp
6329
6440
  }).strict();
6330
- var OwnershipRecordSchema = z3.object({
6331
- version: z3.literal(1),
6332
- kind: z3.literal("ownership"),
6441
+ var OwnershipRecordSchema = z4.object({
6442
+ version: z4.literal(1),
6443
+ kind: z4.literal("ownership"),
6333
6444
  task: taskId,
6334
6445
  epoch: epochNumber,
6335
- ownerId: z3.string().min(1),
6336
- pid: z3.number().int().positive(),
6337
- host: z3.string().min(1),
6446
+ ownerId: z4.string().min(1),
6447
+ pid: z4.number().int().positive(),
6448
+ host: z4.string().min(1),
6338
6449
  acquiredAt: isoTimestamp
6339
6450
  }).strict();
6340
- var TransitionRecordSchema = z3.object({
6341
- version: z3.literal(1),
6342
- kind: z3.literal("transition"),
6451
+ var TransitionRecordSchema = z4.object({
6452
+ version: z4.literal(1),
6453
+ kind: z4.literal("transition"),
6343
6454
  task: taskId,
6344
6455
  epoch: epochNumber,
6345
- seq: z3.number().int().nonnegative(),
6346
- from: z3.string().min(1),
6347
- to: z3.string().min(1),
6348
- detail: z3.string().optional(),
6456
+ seq: z4.number().int().nonnegative(),
6457
+ from: z4.string().min(1),
6458
+ to: z4.string().min(1),
6459
+ detail: z4.string().optional(),
6349
6460
  at: isoTimestamp
6350
6461
  }).strict();
6351
- var ManifestRecordSchema = z3.object({
6352
- version: z3.literal(1),
6353
- kind: z3.literal("manifest"),
6462
+ var ManifestRecordSchema = z4.object({
6463
+ version: z4.literal(1),
6464
+ kind: z4.literal("manifest"),
6354
6465
  task: taskId,
6355
6466
  round: epochNumber,
6356
- repository: z3.string().min(1),
6357
- pr: z3.number().int().positive(),
6358
- branch: z3.string().min(1),
6359
- baseSha: z3.string().min(1).nullable(),
6360
- headSha: z3.string().min(1),
6361
- briefHash: z3.string().min(1).nullable(),
6362
- objectivesVersion: z3.string().min(1).nullable(),
6467
+ repository: z4.string().min(1),
6468
+ pr: z4.number().int().positive(),
6469
+ branch: z4.string().min(1),
6470
+ baseSha: z4.string().min(1).nullable(),
6471
+ headSha: z4.string().min(1),
6472
+ briefHash: z4.string().min(1).nullable(),
6473
+ objectivesVersion: z4.string().min(1).nullable(),
6363
6474
  rulingOrdinal: epochNumber,
6364
- policyDigest: z3.string().min(1),
6475
+ policyDigest: z4.string().min(1),
6365
6476
  recordedAt: isoTimestamp
6366
6477
  }).strict();
6367
- var roundHeadIdentity = z3.object({ round: z3.number().int().positive(), head: z3.string().min(1) }).strict();
6368
- var LoopBudgetsSchema = z3.object({
6369
- mechanicalRetries: z3.number().int().nonnegative(),
6370
- reviewRounds: z3.number().int().nonnegative(),
6371
- infrastructureRetries: z3.number().int().nonnegative()
6478
+ var roundHeadIdentity = z4.object({ round: z4.number().int().positive(), head: z4.string().min(1) }).strict();
6479
+ var LoopBudgetsSchema = z4.object({
6480
+ mechanicalRetries: z4.number().int().nonnegative(),
6481
+ reviewRounds: z4.number().int().nonnegative(),
6482
+ infrastructureRetries: z4.number().int().nonnegative()
6372
6483
  }).strict();
6373
- var LoopStateRecordSchema = z3.object({
6374
- version: z3.literal(1),
6375
- kind: z3.literal("loop_state"),
6484
+ var LoopStateRecordSchema = z4.object({
6485
+ version: z4.literal(1),
6486
+ kind: z4.literal("loop_state"),
6376
6487
  task: taskId,
6377
- round: z3.number().int().positive(),
6378
- phase: z3.string().min(1),
6379
- pauseReason: z3.string().min(1).nullable(),
6488
+ round: z4.number().int().positive(),
6489
+ phase: z4.string().min(1),
6490
+ pauseReason: z4.string().min(1).nullable(),
6380
6491
  budgets: LoopBudgetsSchema,
6381
6492
  heldResult: roundHeadIdentity.nullable(),
6382
6493
  deliveredFindings: roundHeadIdentity.nullable(),
6383
- repeatMemory: z3.object({
6384
- blockingFindings: z3.array(z3.string()),
6385
- lastFailure: z3.object({ signature: z3.string(), message: z3.string() }).nullable()
6494
+ repeatMemory: z4.object({
6495
+ blockingFindings: z4.array(z4.string()),
6496
+ lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
6386
6497
  }).strict().optional(),
6498
+ publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
6499
+ taskStartedAt: isoTimestamp.optional(),
6500
+ phaseMs: z4.record(z4.string(), z4.number().nonnegative()).optional(),
6387
6501
  recordedAt: isoTimestamp
6388
6502
  }).strict();
6389
- var EffectRecordSchema = z3.object({
6390
- version: z3.literal(1),
6391
- kind: z3.literal("effect"),
6503
+ var EffectRecordSchema = z4.object({
6504
+ version: z4.literal(1),
6505
+ kind: z4.literal("effect"),
6392
6506
  task: taskId,
6393
- key: z3.string().min(1),
6394
- operation: z3.string().min(1),
6395
- target: z3.string().min(1),
6396
- inputVersion: z3.number().int().nonnegative(),
6397
- payloadDigest: z3.string().min(1),
6398
- status: z3.union([z3.literal("started"), z3.literal("verified"), z3.literal("uncertain")]),
6399
- url: z3.string().optional(),
6507
+ key: z4.string().min(1),
6508
+ operation: z4.string().min(1),
6509
+ target: z4.string().min(1),
6510
+ inputVersion: z4.number().int().nonnegative(),
6511
+ payloadDigest: z4.string().min(1),
6512
+ status: z4.union([z4.literal("started"), z4.literal("verified"), z4.literal("uncertain")]),
6513
+ url: z4.string().optional(),
6400
6514
  recordedAt: isoTimestamp
6401
6515
  }).strict();
6402
- var EscalationRecordSchema = z3.object({
6403
- version: z3.literal(1),
6404
- kind: z3.literal("escalation"),
6516
+ var EscalationRecordSchema = z4.object({
6517
+ version: z4.literal(1),
6518
+ kind: z4.literal("escalation"),
6405
6519
  task: taskId,
6406
- escalationId: z3.string().min(1),
6520
+ escalationId: z4.string().min(1),
6407
6521
  round: epochNumber,
6408
- head: z3.string().min(1),
6409
- branch: z3.string().min(1),
6410
- pr: z3.number().int().positive().nullable(),
6411
- runId: z3.string().min(1),
6412
- pid: z3.number().int().positive(),
6413
- host: z3.string().min(1),
6414
- agent: z3.string().min(1).optional(),
6415
- reason: z3.string().min(1),
6416
- detail: z3.string().optional(),
6417
- evidence: z3.string().optional(),
6418
- attemptedRecovery: z3.string().min(1),
6419
- requestedDecision: z3.string().min(1),
6420
- recipient: z3.string().min(1),
6421
- briefHash: z3.string().min(1).nullable(),
6422
- objectivesVersion: z3.string().min(1).nullable(),
6522
+ head: z4.string().min(1),
6523
+ branch: z4.string().min(1),
6524
+ pr: z4.number().int().positive().nullable(),
6525
+ runId: z4.string().min(1),
6526
+ pid: z4.number().int().positive(),
6527
+ host: z4.string().min(1),
6528
+ agent: z4.string().min(1).optional(),
6529
+ reason: z4.string().min(1),
6530
+ detail: z4.string().optional(),
6531
+ evidence: z4.string().optional(),
6532
+ attemptedRecovery: z4.string().min(1),
6533
+ requestedDecision: z4.string().min(1),
6534
+ recipient: z4.string().min(1),
6535
+ briefHash: z4.string().min(1).nullable(),
6536
+ objectivesVersion: z4.string().min(1).nullable(),
6423
6537
  rulingOrdinal: epochNumber,
6424
- policyDigest: z3.string().min(1),
6538
+ policyDigest: z4.string().min(1),
6425
6539
  recordedAt: isoTimestamp
6426
6540
  }).strict();
6427
- var ResolutionRecordSchema = z3.object({
6428
- version: z3.literal(1),
6429
- kind: z3.literal("resolution"),
6541
+ var ResolutionRecordSchema = z4.object({
6542
+ version: z4.literal(1),
6543
+ kind: z4.literal("resolution"),
6430
6544
  task: taskId,
6431
- escalationId: z3.string().min(1),
6432
- decision: z3.union([z3.literal("resume"), z3.literal("cancel")]),
6433
- authenticatedBy: z3.string().min(1),
6434
- authenticatedFrom: z3.string().min(1),
6545
+ escalationId: z4.string().min(1),
6546
+ decision: z4.union([z4.literal("resume"), z4.literal("cancel")]),
6547
+ authenticatedBy: z4.string().min(1),
6548
+ authenticatedFrom: z4.string().min(1),
6435
6549
  consumedAt: isoTimestamp
6436
6550
  }).strict();
6551
+ // ../../packages/aeg-core/src/control-store/local.ts
6552
+ var CONTROL_AREA_DIRNAME = "control";
6437
6553
  // src/lib/pr-report-engine.ts
6438
6554
  import { execFile as execFile6 } from "node:child_process";
6439
6555
  import { promisify as promisify6 } from "node:util";
6440
6556
 
6441
6557
  // src/checks/registry.ts
6442
- import { existsSync as existsSync2 } from "node:fs";
6443
- import { join as join2 } from "node:path";
6558
+ import { join as join2, relative, sep } from "node:path";
6559
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
6444
6560
 
6445
6561
  // src/lib/package-root.ts
6446
6562
  import { existsSync } from "node:fs";
@@ -6460,10 +6576,14 @@ function packageRoot(moduleUrl) {
6460
6576
  }
6461
6577
 
6462
6578
  // src/checks/registry.ts
6463
- var DIST_BIN_DIR = join2(packageRoot(import.meta.url), "dist", "checks", "bin");
6464
- var SRC_BIN_DIR = join2(packageRoot(import.meta.url), "src", "checks", "bin");
6465
- var BIN_DIR = existsSync2(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
6466
- var BIN_EXT = BIN_DIR === DIST_BIN_DIR ? ".js" : ".ts";
6579
+ function resolveCheckBin(packageDir, moduleUrl) {
6580
+ const fromPackage = relative(packageDir, fileURLToPath2(moduleUrl));
6581
+ const bundled = fromPackage === "dist" || fromPackage.startsWith(`dist${sep}`);
6582
+ return bundled ? { dir: join2(packageDir, "dist", "checks", "bin"), ext: ".js" } : { dir: join2(packageDir, "src", "checks", "bin"), ext: ".ts" };
6583
+ }
6584
+ var CHECK_BIN = resolveCheckBin(packageRoot(import.meta.url), import.meta.url);
6585
+ var BIN_DIR = CHECK_BIN.dir;
6586
+ var BIN_EXT = CHECK_BIN.ext;
6467
6587
  function bin(name) {
6468
6588
  return join2(BIN_DIR, `${name}${BIN_EXT}`);
6469
6589
  }
@@ -6661,23 +6781,6 @@ var REGISTRY = [
6661
6781
  },
6662
6782
  1
6663
6783
  ],
6664
- [
6665
- {
6666
- name: "token-report",
6667
- validates: "body",
6668
- run: bin("check-token-report"),
6669
- scope: "diff",
6670
- timeoutMs: 15000,
6671
- requiresOpenPr: true,
6672
- env: {
6673
- PR_BODY: { optional: true },
6674
- BRANCH: { optional: true },
6675
- CLAUDE_PROJECT_DIR: { optional: true },
6676
- CLAUDE_CODE_SESSION_ID: { optional: true }
6677
- }
6678
- },
6679
- 1
6680
- ],
6681
6784
  [
6682
6785
  {
6683
6786
  name: "no-disk-state",
@@ -7027,71 +7130,52 @@ var CORE_CHECK_RING = Object.fromEntries(REGISTRY.map(([spec, ring]) => [spec.na
7027
7130
  import { execFile as execFile5 } from "node:child_process";
7028
7131
  import { randomUUID as randomUUID2 } from "node:crypto";
7029
7132
  import {
7030
- closeSync as closeSync3,
7031
- constants as fsConstants3,
7133
+ appendFileSync,
7134
+ closeSync as closeSync4,
7135
+ constants as fsConstants4,
7032
7136
  existsSync as existsSync5,
7033
- fstatSync as fstatSync2,
7034
- mkdirSync as mkdirSync3,
7035
- openSync as openSync3,
7036
- readFileSync as readFileSync4,
7137
+ fstatSync as fstatSync3,
7138
+ mkdirSync as mkdirSync4,
7139
+ lstatSync as lstatSync2,
7140
+ openSync as openSync4,
7141
+ readFileSync as readFileSync5,
7037
7142
  renameSync as renameSync2,
7038
- writeSync as writeSync2
7143
+ writeFileSync as writeFileSync3,
7144
+ writeSync as writeSync3
7039
7145
  } from "node:fs";
7040
7146
  import { hostname as osHostname, homedir as homedir3 } from "node:os";
7041
- import { dirname as dirname5, join as join6 } from "node:path";
7147
+ import { dirname as dirname6, join as join6 } from "node:path";
7042
7148
  import { promisify as promisify5 } from "node:util";
7043
7149
 
7044
7150
  // src/lib/config.ts
7045
- import { execFile as execFile4, execFileSync as execFileSync3 } from "node:child_process";
7151
+ import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
7046
7152
  import { promisify as promisify4 } from "node:util";
7047
- import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
7153
+ import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
7048
7154
  import { homedir } from "node:os";
7049
7155
  import { dirname as dirname2, isAbsolute, join as join3, resolve } from "node:path";
7050
- import { z as z4 } from "zod";
7156
+ import { z as z5 } from "zod";
7051
7157
 
7052
7158
  // src/lib/agent-vendors.ts
7053
7159
  var AGENT_VENDORS = ["skills", "claude", "gemini"];
7054
7160
 
7055
- // src/lib/worker-boundary.ts
7056
- import { execFileSync as execFileSync2 } from "node:child_process";
7057
- var LOG_HEADER_KEYCHAIN_SERVICE = "Vinaya Log";
7058
- var logHeaderKeychainCache = new Map;
7059
- function readRealLogHeaderKeychainCredential(variable) {
7060
- if (process.platform !== "darwin")
7061
- return null;
7062
- try {
7063
- return execFileSync2("/usr/bin/security", ["find-generic-password", "-s", LOG_HEADER_KEYCHAIN_SERVICE, "-a", variable, "-w"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 5000, maxBuffer: 1024 * 1024 }).replace(/\n$/, "");
7064
- } catch {
7065
- return null;
7066
- }
7067
- }
7068
- function readLogHeaderKeychainCredential(variable) {
7069
- const cached = logHeaderKeychainCache.get(variable);
7070
- if (cached !== undefined)
7071
- return cached;
7072
- const value = readRealLogHeaderKeychainCredential(variable);
7073
- logHeaderKeychainCache.set(variable, value);
7074
- return value;
7075
- }
7076
-
7077
7161
  // src/lib/config.ts
7078
- var EnvEntrySchema = z4.union([
7079
- z4.literal(true),
7080
- z4.object({ optional: z4.literal(true) }),
7081
- z4.object({ anyOf: z4.array(z4.string()).min(2) }),
7082
- z4.string()
7162
+ var EnvEntrySchema = z5.union([
7163
+ z5.literal(true),
7164
+ z5.object({ optional: z5.literal(true) }),
7165
+ z5.object({ anyOf: z5.array(z5.string()).min(2) }),
7166
+ z5.string()
7083
7167
  ]);
7084
- var CheckEntrySchema = z4.object({
7085
- run: z4.string(),
7086
- scope: z4.enum(["diff", "full"]),
7087
- include: z4.array(z4.string()).optional(),
7088
- args: z4.array(z4.string()).optional(),
7089
- timeoutMs: z4.number().optional(),
7090
- env: z4.record(z4.string(), EnvEntrySchema).optional(),
7091
- requiresOpenPr: z4.boolean().optional(),
7092
- ownWorkflow: z4.boolean().optional(),
7093
- principalOwed: z4.literal(true).optional(),
7094
- validates: z4.enum(["body", "issue"]).optional()
7168
+ var CheckEntrySchema = z5.object({
7169
+ run: z5.string(),
7170
+ scope: z5.enum(["diff", "full"]),
7171
+ include: z5.array(z5.string()).optional(),
7172
+ args: z5.array(z5.string()).optional(),
7173
+ timeoutMs: z5.number().optional(),
7174
+ env: z5.record(z5.string(), EnvEntrySchema).optional(),
7175
+ requiresOpenPr: z5.boolean().optional(),
7176
+ ownWorkflow: z5.boolean().optional(),
7177
+ principalOwed: z5.literal(true).optional(),
7178
+ validates: z5.enum(["body", "issue"]).optional()
7095
7179
  }).superRefine((entry, ctx) => {
7096
7180
  if (!entry.env)
7097
7181
  return;
@@ -7101,22 +7185,22 @@ var CheckEntrySchema = z4.object({
7101
7185
  const members = value.anyOf;
7102
7186
  if (new Set(members).size !== members.length) {
7103
7187
  ctx.addIssue({
7104
- code: z4.ZodIssueCode.custom,
7188
+ code: z5.ZodIssueCode.custom,
7105
7189
  message: `env.${key}.anyOf has duplicate members`,
7106
7190
  path: ["env", key, "anyOf"]
7107
7191
  });
7108
7192
  }
7109
7193
  if (!members.includes(key)) {
7110
7194
  ctx.addIssue({
7111
- code: z4.ZodIssueCode.custom,
7195
+ code: z5.ZodIssueCode.custom,
7112
7196
  message: `env.${key}.anyOf must include "${key}" itself as a member`,
7113
7197
  path: ["env", key, "anyOf"]
7114
7198
  });
7115
7199
  }
7116
7200
  }
7117
7201
  });
7118
- var RoleEntrySchema = z4.object({
7119
- contract: z4.string().refine((p) => p.includes("/"), {
7202
+ var RoleEntrySchema = z5.object({
7203
+ contract: z5.string().refine((p) => p.includes("/"), {
7120
7204
  message: 'must be a path (contain at least one "/"), not a bare filename'
7121
7205
  })
7122
7206
  });
@@ -7140,17 +7224,17 @@ var BRIEF_BUILTINS = [
7140
7224
  "briefSections",
7141
7225
  "milestoneShape"
7142
7226
  ];
7143
- var BriefSectionSchema = z4.union([
7144
- z4.object({ builtin: z4.enum(BRIEF_BUILTINS) }),
7145
- z4.object({ heading: z4.string().min(1), name: z4.string().optional() }),
7146
- z4.object({ field: z4.string().min(1), name: z4.string().optional() }),
7147
- z4.object({ phrase: z4.string().min(1), name: z4.string().optional() })
7227
+ var BriefSectionSchema = z5.union([
7228
+ z5.object({ builtin: z5.enum(BRIEF_BUILTINS) }),
7229
+ z5.object({ heading: z5.string().min(1), name: z5.string().optional() }),
7230
+ z5.object({ field: z5.string().min(1), name: z5.string().optional() }),
7231
+ z5.object({ phrase: z5.string().min(1), name: z5.string().optional() })
7148
7232
  ]);
7149
- var BriefSchemaSchema = z4.object({
7150
- pr: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
7151
- issue: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
7152
- milestone: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
7153
- ack: z4.array(z4.enum(BRIEF_BUILTINS)).optional()
7233
+ var BriefSchemaSchema = z5.object({
7234
+ pr: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
7235
+ issue: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
7236
+ milestone: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
7237
+ ack: z5.array(z5.enum(BRIEF_BUILTINS)).optional()
7154
7238
  });
7155
7239
  function isSafeRepoRelPath(p) {
7156
7240
  if (p.length === 0)
@@ -7159,7 +7243,7 @@ function isSafeRepoRelPath(p) {
7159
7243
  return false;
7160
7244
  return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
7161
7245
  }
7162
- var SafeRepoRelPath = z4.string().refine(isSafeRepoRelPath, {
7246
+ var SafeRepoRelPath = z5.string().refine(isSafeRepoRelPath, {
7163
7247
  message: "must be a repo-root-relative path with no `..` segment or absolute root"
7164
7248
  });
7165
7249
  var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
@@ -7169,22 +7253,22 @@ function isCanonicalHookBlockPath(p) {
7169
7253
  var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
7170
7254
  message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
7171
7255
  });
7172
- var ManagedBlockRecordSchema = z4.object({
7256
+ var ManagedBlockRecordSchema = z5.object({
7173
7257
  path: ManagedHookBlockPath,
7174
- marker: z4.string(),
7175
- comment: z4.enum(["hash", "html"])
7258
+ marker: z5.string(),
7259
+ comment: z5.enum(["hash", "html"])
7176
7260
  });
7177
- var ManagedManifestSchema = z4.object({
7178
- version: z4.number().int().positive(),
7179
- files: z4.array(SafeRepoRelPath),
7180
- blocks: z4.array(ManagedBlockRecordSchema),
7181
- labels: z4.array(z4.string()),
7182
- agents: z4.array(z4.enum(AGENT_VENDORS)).optional()
7261
+ var ManagedManifestSchema = z5.object({
7262
+ version: z5.number().int().positive(),
7263
+ files: z5.array(SafeRepoRelPath),
7264
+ blocks: z5.array(ManagedBlockRecordSchema),
7265
+ labels: z5.array(z5.string()),
7266
+ agents: z5.array(z5.enum(AGENT_VENDORS)).optional()
7183
7267
  });
7184
- var ProjectEntrySchema = z4.object({
7185
- name: z4.string().min(1),
7186
- description: z4.string().min(1).optional(),
7187
- path: z4.string().min(1).optional()
7268
+ var ProjectEntrySchema = z5.object({
7269
+ name: z5.string().min(1),
7270
+ description: z5.string().min(1).optional(),
7271
+ path: z5.string().min(1).optional()
7188
7272
  });
7189
7273
  function parseTokensCollectDeclaration(value) {
7190
7274
  const m = value.trim().match(/^(\S+)\s+(\S+)$/);
@@ -7195,90 +7279,97 @@ function parseTokensCollectDeclaration(value) {
7195
7279
  return null;
7196
7280
  return { interpreter, script };
7197
7281
  }
7198
- var VinayaConfigSchema = z4.object({
7199
- rings: z4.object({
7200
- ring1_forgeWriteInterception: z4.boolean(),
7201
- ring2_asyncAudits: z4.boolean()
7282
+ var VinayaConfigSchema = z5.object({
7283
+ rings: z5.object({
7284
+ ring1_forgeWriteInterception: z5.boolean(),
7285
+ ring2_asyncAudits: z5.boolean()
7202
7286
  }).optional(),
7203
- checks: z4.record(z4.string(), CheckEntrySchema).optional(),
7204
- roles: z4.record(z4.string(), RoleEntrySchema).optional(),
7287
+ checks: z5.record(z5.string(), CheckEntrySchema).optional(),
7288
+ roles: z5.record(z5.string(), RoleEntrySchema).optional(),
7205
7289
  briefSchema: BriefSchemaSchema.optional(),
7206
7290
  managed: ManagedManifestSchema.optional(),
7207
- principals: z4.array(z4.string()).min(1).optional(),
7208
- releaseActor: z4.string().min(1).optional(),
7209
- ci: z4.object({ setup: z4.string().min(1) }).optional(),
7210
- tokens: z4.object({
7211
- collect: z4.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
7291
+ principals: z5.array(z5.string()).min(1).optional(),
7292
+ releaseActor: z5.string().min(1).optional(),
7293
+ ci: z5.object({ setup: z5.string().min(1) }).optional(),
7294
+ tokens: z5.object({
7295
+ collect: z5.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
7212
7296
  message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
7213
7297
  })
7214
7298
  }).optional(),
7215
- blastRadius: z4.object({ extraDomains: z4.array(z4.string()).optional() }).optional(),
7216
- proseGates: z4.object({
7217
- doctrineRoot: z4.string().min(1).optional(),
7218
- readerFacingPrefix: z4.string().min(1).optional(),
7219
- readerFacingSuffix: z4.string().min(1).optional(),
7220
- legacySlugDir: z4.string().min(1).optional(),
7221
- sourceComments: z4.object({
7222
- globs: z4.array(z4.string().min(1)).optional(),
7223
- allowlist: z4.array(z4.string().min(1)).optional(),
7224
- severity: z4.enum(["warning", "error"]).optional()
7299
+ blastRadius: z5.object({ extraDomains: z5.array(z5.string()).optional() }).optional(),
7300
+ proseGates: z5.object({
7301
+ doctrineRoot: z5.string().min(1).optional(),
7302
+ readerFacingPrefix: z5.string().min(1).optional(),
7303
+ readerFacingSuffix: z5.string().min(1).optional(),
7304
+ legacySlugDir: z5.string().min(1).optional(),
7305
+ sourceComments: z5.object({
7306
+ globs: z5.array(z5.string().min(1)).optional(),
7307
+ allowlist: z5.array(z5.string().min(1)).optional(),
7308
+ severity: z5.enum(["warning", "error"]).optional()
7225
7309
  }).optional(),
7226
- specGrandfather: z4.array(z4.string().min(1)).optional(),
7227
- specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
7310
+ specGrandfather: z5.union([z5.array(z5.string().min(1)), z5.record(z5.string().min(1), z5.number().int().min(0))]).optional(),
7311
+ specPaths: z5.array(z5.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
7228
7312
  message: "must be a repository-relative path, not an absolute one"
7229
7313
  }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
7230
7314
  message: "must stay inside the repository — no `..` segment"
7231
7315
  })).optional()
7232
7316
  }).optional(),
7233
- projects: z4.array(ProjectEntrySchema).optional(),
7234
- dispatch: z4.object({
7235
- timeoutMs: z4.number().int().positive().optional(),
7236
- killGraceMs: z4.number().int().positive().optional(),
7237
- agent: z4.enum(["claude", "codex", "gemini"]).optional(),
7238
- requireWorkerIsolation: z4.boolean().optional()
7317
+ projects: z5.array(ProjectEntrySchema).optional(),
7318
+ dispatch: z5.object({
7319
+ timeoutMs: z5.number().int().positive().optional(),
7320
+ killGraceMs: z5.number().int().positive().optional(),
7321
+ agent: z5.enum(["claude", "codex", "gemini"]).optional()
7322
+ }).optional(),
7323
+ reviewPolicy: z5.object({
7324
+ codeReviewThreshold: z5.string().min(1).optional(),
7325
+ securityThreshold: z5.string().min(1).optional(),
7326
+ maxRounds: z5.number().optional(),
7327
+ maxTaskMinutes: z5.number().optional()
7239
7328
  }).optional(),
7240
- reviewPolicy: z4.object({
7241
- codeReviewThreshold: z4.string().min(1).optional(),
7242
- securityThreshold: z4.string().min(1).optional(),
7243
- maxRounds: z4.number().optional()
7329
+ securityScan: z5.object({
7330
+ command: z5.array(z5.string().min(1)).min(1)
7244
7331
  }).optional(),
7245
- gateCutovers: z4.object({
7246
- objectivesSinceIssue: z4.number().int().nonnegative().optional(),
7247
- briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
7248
- documentationSinceIssue: z4.number().int().nonnegative().optional(),
7249
- briefRulesSincePr: z4.number().int().nonnegative().optional(),
7250
- agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
7332
+ gateCutovers: z5.object({
7333
+ objectivesSinceIssue: z5.number().int().nonnegative().optional(),
7334
+ briefSectionsSinceIssue: z5.number().int().nonnegative().optional(),
7335
+ documentationSinceIssue: z5.number().int().nonnegative().optional(),
7336
+ briefRulesSincePr: z5.number().int().nonnegative().optional(),
7337
+ agentBoxesRefusedSincePr: z5.number().int().nonnegative().optional()
7251
7338
  }).optional(),
7252
- planning: z4.object({
7253
- collisionThreshold: z4.number().int().nonnegative().optional()
7339
+ planning: z5.object({
7340
+ collisionThreshold: z5.number().int().nonnegative().optional()
7254
7341
  }).optional(),
7255
- prePush: z4.object({
7256
- alwaysRun: z4.array(z4.string()).optional()
7342
+ prePush: z5.object({
7343
+ alwaysRun: z5.array(z5.string()).optional()
7257
7344
  }).optional(),
7258
- report: z4.object({
7259
- commandTimeoutMs: z4.number().int().positive().optional()
7345
+ report: z5.object({
7346
+ commandTimeoutMs: z5.number().int().positive().optional()
7260
7347
  }).superRefine((report, ctx) => {
7261
7348
  const commandTimeoutMs = report.commandTimeoutMs;
7262
7349
  if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
7263
7350
  ctx.addIssue({
7264
- code: z4.ZodIssueCode.custom,
7351
+ code: z5.ZodIssueCode.custom,
7265
7352
  path: ["commandTimeoutMs"],
7266
7353
  message: "must be at most 3600000 (1 hour)"
7267
7354
  });
7268
7355
  }
7269
7356
  }).optional(),
7270
- logPublish: z4.unknown().refine((v) => v === undefined, {
7357
+ logPublish: z5.unknown().refine((v) => v === undefined, {
7271
7358
  message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
7272
7359
  }),
7273
- runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
7274
- logs: z4.object({
7275
- folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
7276
- url: z4.string().url().optional(),
7277
- headers: z4.record(z4.string()).optional()
7360
+ runtimeDir: z5.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
7361
+ logs: z5.object({
7362
+ folder: z5.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
7363
+ url: z5.string().url().optional(),
7364
+ headers: z5.record(z5.string()).optional(),
7365
+ readHeaders: z5.record(z5.string()).optional(),
7366
+ events: CustomEventDeclarationsSchema.optional()
7278
7367
  }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
7279
7368
  message: "logs: set at most one of folder/url"
7280
7369
  }).refine((v) => v.headers === undefined || v.url !== undefined, {
7281
7370
  message: "logs: headers requires url"
7371
+ }).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
7372
+ message: "logs: readHeaders requires url"
7282
7373
  }).optional()
7283
7374
  });
7284
7375
  var GLOBAL_VINAYA_HOME = join3(homedir(), ".vinaya");
@@ -7288,9 +7379,9 @@ function findLocalConfig() {
7288
7379
  let dir = process.cwd();
7289
7380
  while (true) {
7290
7381
  const candidate = join3(dir, LOCAL_CONFIG_FILENAME);
7291
- if (existsSync3(candidate))
7382
+ if (existsSync2(candidate))
7292
7383
  return candidate;
7293
- if (existsSync3(join3(dir, ".git")))
7384
+ if (existsSync2(join3(dir, ".git")))
7294
7385
  return null;
7295
7386
  const parent = dirname2(dir);
7296
7387
  if (parent === dir)
@@ -7302,7 +7393,7 @@ function configPath() {
7302
7393
  const local = findLocalConfig();
7303
7394
  if (local)
7304
7395
  return local;
7305
- if (existsSync3(GLOBAL_CONFIG_PATH))
7396
+ if (existsSync2(GLOBAL_CONFIG_PATH))
7306
7397
  return GLOBAL_CONFIG_PATH;
7307
7398
  return null;
7308
7399
  }
@@ -7383,10 +7474,15 @@ function resolveReviewPolicy(config) {
7383
7474
  if (!Number.isInteger(maxRounds) || maxRounds < 1) {
7384
7475
  throw new Error(`vinaya.config.json: reviewPolicy.maxRounds "${maxRounds}" is not a positive integer — fix the config, this never falls back to a default.`);
7385
7476
  }
7477
+ const maxTaskMinutes = raw.maxTaskMinutes ?? DEFAULT_REVIEW_POLICY.maxTaskMinutes;
7478
+ if (!Number.isInteger(maxTaskMinutes) || maxTaskMinutes < 0) {
7479
+ 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.`);
7480
+ }
7386
7481
  return {
7387
7482
  codeReviewThreshold,
7388
7483
  securityThreshold,
7389
- maxRounds
7484
+ maxRounds,
7485
+ maxTaskMinutes
7390
7486
  };
7391
7487
  }
7392
7488
  function resolveGateCutovers(config) {
@@ -7426,17 +7522,12 @@ function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
7426
7522
  return "url" in anchored && anchored.url === local.url ? anchored : null;
7427
7523
  return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
7428
7524
  }
7429
- function resolveLogsHeaderValues(headers, env, readKeychain = readLogHeaderKeychainCredential) {
7525
+ function resolveLogsHeaderValues(headers, env) {
7430
7526
  if (!headers)
7431
7527
  return;
7432
7528
  const resolved = {};
7433
7529
  for (const [key, value] of Object.entries(headers)) {
7434
- resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => {
7435
- const fromEnv = env[name];
7436
- if (fromEnv !== undefined)
7437
- return fromEnv;
7438
- return readKeychain(name) ?? "";
7439
- });
7530
+ resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
7440
7531
  }
7441
7532
  return resolved;
7442
7533
  }
@@ -7445,7 +7536,7 @@ function trustAnchorRepo() {
7445
7536
  if (fromRunner)
7446
7537
  return fromRunner;
7447
7538
  try {
7448
- const url = execFileSync3("git", ["remote", "get-url", "origin"], {
7539
+ const url = execFileSync2("git", ["remote", "get-url", "origin"], {
7449
7540
  encoding: "utf-8",
7450
7541
  stdio: ["ignore", "pipe", "pipe"]
7451
7542
  });
@@ -7492,7 +7583,7 @@ function resolveCiTrustAnchorProbeRef(env = process.env) {
7492
7583
  return ref;
7493
7584
  }
7494
7585
  function readTrustAnchorConfigAtRef(ref) {
7495
- const raw = execFileSync3("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
7586
+ const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
7496
7587
  encoding: "utf-8",
7497
7588
  stdio: ["ignore", "pipe", "pipe"],
7498
7589
  timeout: 1e4
@@ -7506,7 +7597,7 @@ function ghFetchTrustAnchorConfig() {
7506
7597
  const repo = trustAnchorRepo();
7507
7598
  if (!repo)
7508
7599
  throw new Error("could not resolve repo identity for the trust-anchor read");
7509
- return execFileSync3("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
7600
+ return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
7510
7601
  encoding: "utf-8",
7511
7602
  stdio: ["ignore", "pipe", "pipe"]
7512
7603
  });
@@ -7597,8 +7688,17 @@ function loadConfig() {
7597
7688
  var TOKENS_COLLECT_TRUST_PATH = join3(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
7598
7689
 
7599
7690
  // src/lib/run-paths.ts
7600
- import { chmodSync, existsSync as existsSync4, realpathSync as realpathSync2 } from "node:fs";
7691
+ import { execFileSync as execFileSync3 } from "node:child_process";
7692
+ import { chmodSync, existsSync as existsSync3, realpathSync as realpathSync2 } from "node:fs";
7601
7693
  import { dirname as dirname3, join as join4, resolve as resolvePath } from "node:path";
7694
+ var TASKS_EXECUTION_DIRNAME = "tasks-execution";
7695
+ var RUN_AREA_DIRNAMES = {
7696
+ control: CONTROL_AREA_DIRNAME,
7697
+ sessions: "sessions",
7698
+ hooks: "hooks",
7699
+ output: "output",
7700
+ rounds: "rounds"
7701
+ };
7602
7702
  var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
7603
7703
  function isSafeRepoSegment(segment) {
7604
7704
  return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
@@ -7629,12 +7729,52 @@ function isInsideRepo(candidate, repoRoot) {
7629
7729
  const target = resolvePath(candidate);
7630
7730
  return target === root || target.startsWith(`${root}/`);
7631
7731
  }
7732
+ function runPath(runtimeDir, scope, location) {
7733
+ const dir = join4(runtimeDir, TASKS_EXECUTION_DIRNAME, scopeSegment(scope));
7734
+ switch (location.area) {
7735
+ case "task":
7736
+ return location.file ? join4(dir, location.file) : dir;
7737
+ case "control": {
7738
+ const controlDir = join4(dir, RUN_AREA_DIRNAMES.control);
7739
+ return location.file ? join4(controlDir, location.file) : controlDir;
7740
+ }
7741
+ case "rounds":
7742
+ return join4(dir, RUN_AREA_DIRNAMES.rounds);
7743
+ case "round": {
7744
+ const roundDir = join4(dir, RUN_AREA_DIRNAMES.rounds, String(location.round));
7745
+ return location.file ? join4(roundDir, location.file) : roundDir;
7746
+ }
7747
+ case "developer": {
7748
+ const developerDir = join4(dir, RUN_AREA_DIRNAMES.rounds, String(location.round), "developer");
7749
+ return location.file ? join4(developerDir, location.file) : developerDir;
7750
+ }
7751
+ default: {
7752
+ const areaDir = join4(dir, RUN_AREA_DIRNAMES[location.area]);
7753
+ return location.file ? join4(areaDir, location.file) : areaDir;
7754
+ }
7755
+ }
7756
+ }
7757
+ function scopeSegment(scope) {
7758
+ if (scope === "unscoped")
7759
+ return "unscoped";
7760
+ if (typeof scope === "number")
7761
+ return String(scope);
7762
+ return `pr-${scope.pr}`;
7763
+ }
7632
7764
  var UNATTENDED_ENV_KEY = "VINAYA_UNATTENDED";
7633
7765
  var RUNTIME_DIR_ENV_KEY = "VINAYA_RUNTIME_DIR";
7634
7766
  function isUnattendedProcess(env = process.env) {
7635
7767
  return env[UNATTENDED_ENV_KEY] === "1" || (env.VINAYA_ROLE ?? "") !== "";
7636
7768
  }
7637
7769
  var memoized = null;
7770
+ function runtimeDirForRepo(repo) {
7771
+ const key = repoSegment(repo);
7772
+ if (memoized?.key === key)
7773
+ return memoized.value;
7774
+ const value = resolveRuntimeDirUncached(repo);
7775
+ memoized = { key, value };
7776
+ return value;
7777
+ }
7638
7778
  async function runtimeDirForRepoAsync(repo) {
7639
7779
  const key = repoSegment(repo);
7640
7780
  if (memoized?.key === key)
@@ -7650,6 +7790,16 @@ async function runtimeDirForRepoAsync(repo) {
7650
7790
  memoized = { key, value };
7651
7791
  return value;
7652
7792
  }
7793
+ function resolveRuntimeDirUncached(repo) {
7794
+ const inputs = runtimeDirInputs();
7795
+ if (typeof inputs === "string")
7796
+ return inputs;
7797
+ return resolveRuntimeDir({
7798
+ repo,
7799
+ ...inputs.base,
7800
+ trustAnchorConfig: inputs.needsAnchor ? loadTrustAnchorConfig() : null
7801
+ });
7802
+ }
7653
7803
  function runtimeDirInputs() {
7654
7804
  const handedDown = process.env[RUNTIME_DIR_ENV_KEY];
7655
7805
  if (handedDown)
@@ -7669,7 +7819,7 @@ function repoRootSync(start = process.cwd()) {
7669
7819
  return null;
7670
7820
  }
7671
7821
  for (;; ) {
7672
- if (existsSync4(join4(dir, ".git")))
7822
+ if (existsSync3(join4(dir, ".git")))
7673
7823
  return dir;
7674
7824
  const parent = dirname3(dir);
7675
7825
  if (parent === dir)
@@ -7677,26 +7827,94 @@ function repoRootSync(start = process.cwd()) {
7677
7827
  dir = parent;
7678
7828
  }
7679
7829
  }
7830
+ function resolveRepoSync() {
7831
+ const fromEnv = process.env.AEG_REPO;
7832
+ if (fromEnv) {
7833
+ const m = /^([^/]+)\/(.+)$/.exec(fromEnv);
7834
+ if (m?.[1] && m[2])
7835
+ return { owner: m[1], repo: m[2] };
7836
+ }
7837
+ let url;
7838
+ try {
7839
+ url = execFileSync3("git", ["remote", "get-url", "origin"], {
7840
+ encoding: "utf-8",
7841
+ stdio: ["ignore", "pipe", "pipe"]
7842
+ }).trim();
7843
+ } catch {
7844
+ return null;
7845
+ }
7846
+ const ssh = /^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/.exec(url);
7847
+ if (ssh?.[1] && ssh[2])
7848
+ return { owner: ssh[1], repo: ssh[2] };
7849
+ const https = /^https?:\/\/(?:[^@]+@)?github\.com\/([^/]+)\/(.+?)(?:\.git)?\/?$/.exec(url);
7850
+ if (https?.[1] && https[2])
7851
+ return { owner: https[1], repo: https[2] };
7852
+ return null;
7853
+ }
7854
+ var memoizedThisRepo = null;
7855
+ function runtimeDirForThisRepo() {
7856
+ if (memoizedThisRepo !== null)
7857
+ return memoizedThisRepo;
7858
+ memoizedThisRepo = runtimeDirForRepo(resolveRepoSync());
7859
+ return memoizedThisRepo;
7860
+ }
7680
7861
 
7681
- // src/lib/log-webhook-drain.ts
7862
+ // src/lib/loop-log.ts
7682
7863
  import {
7683
7864
  closeSync as closeSync2,
7684
7865
  constants as fsConstants2,
7685
- lstatSync,
7866
+ existsSync as existsSync4,
7867
+ fstatSync as fstatSync2,
7686
7868
  mkdirSync as mkdirSync2,
7687
7869
  openSync as openSync2,
7688
- linkSync,
7689
7870
  readFileSync as readFileSync3,
7690
- renameSync,
7871
+ readSync,
7691
7872
  statSync,
7873
+ writeSync
7874
+ } from "node:fs";
7875
+ import { dirname as dirname4 } from "node:path";
7876
+ function loopsRoot() {
7877
+ return runtimeDirForThisRepo();
7878
+ }
7879
+ function loopLogPathFor(_repo, issue, root = loopsRoot()) {
7880
+ return runPath(root, issue, { area: "output", file: "driver.log" });
7881
+ }
7882
+ var LOOP_LOG_MAX_BYTES = 8 * 1024 * 1024;
7883
+ function appendLoopLogLine(path, line) {
7884
+ try {
7885
+ mkdirSync2(dirname4(path), { recursive: true, mode: 448 });
7886
+ const fd = openSync2(path, fsConstants2.O_WRONLY | fsConstants2.O_APPEND | fsConstants2.O_CREAT | fsConstants2.O_NOFOLLOW, 384);
7887
+ try {
7888
+ const stat = fstatSync2(fd);
7889
+ if (stat.isFile() && stat.size < LOOP_LOG_MAX_BYTES) {
7890
+ writeSync(fd, `${line}
7891
+ `);
7892
+ }
7893
+ } finally {
7894
+ closeSync2(fd);
7895
+ }
7896
+ } catch {}
7897
+ }
7898
+
7899
+ // src/lib/log-webhook-drain.ts
7900
+ import {
7901
+ closeSync as closeSync3,
7902
+ constants as fsConstants3,
7903
+ lstatSync,
7904
+ mkdirSync as mkdirSync3,
7905
+ openSync as openSync3,
7906
+ linkSync,
7907
+ readFileSync as readFileSync4,
7908
+ renameSync,
7909
+ statSync as statSync2,
7692
7910
  unlinkSync,
7693
7911
  utimesSync,
7694
7912
  writeFileSync as writeFileSync2,
7695
- writeSync
7913
+ writeSync as writeSync2
7696
7914
  } from "node:fs";
7697
7915
  import { randomUUID } from "node:crypto";
7698
7916
  import { homedir as homedir2 } from "node:os";
7699
- import { dirname as dirname4, join as join5 } from "node:path";
7917
+ import { dirname as dirname5, join as join5 } from "node:path";
7700
7918
  var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
7701
7919
  var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
7702
7920
  var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
@@ -7712,13 +7930,13 @@ function isEnoent(err) {
7712
7930
  var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
7713
7931
  function tryCreateLock(lockPath, token) {
7714
7932
  try {
7715
- mkdirSync2(dirname4(lockPath), { recursive: true, mode: 448 });
7716
- const fd = openSync2(lockPath, fsConstants2.O_WRONLY | fsConstants2.O_CREAT | fsConstants2.O_EXCL, 384);
7933
+ mkdirSync3(dirname5(lockPath), { recursive: true, mode: 448 });
7934
+ const fd = openSync3(lockPath, fsConstants3.O_WRONLY | fsConstants3.O_CREAT | fsConstants3.O_EXCL, 384);
7717
7935
  try {
7718
- writeSync(fd, `${token}
7936
+ writeSync2(fd, `${token}
7719
7937
  `);
7720
7938
  } finally {
7721
- closeSync2(fd);
7939
+ closeSync3(fd);
7722
7940
  }
7723
7941
  return true;
7724
7942
  } catch (err) {
@@ -7733,7 +7951,7 @@ function acquireDrainLock(lockPath) {
7733
7951
  return token;
7734
7952
  let observedMtimeMs;
7735
7953
  try {
7736
- observedMtimeMs = statSync(lockPath).mtimeMs;
7954
+ observedMtimeMs = statSync2(lockPath).mtimeMs;
7737
7955
  } catch (err) {
7738
7956
  if (!isEnoent(err))
7739
7957
  throw err;
@@ -7751,7 +7969,7 @@ function acquireDrainLock(lockPath) {
7751
7969
  }
7752
7970
  let claimedMtimeMs = null;
7753
7971
  try {
7754
- claimedMtimeMs = statSync(claimed).mtimeMs;
7972
+ claimedMtimeMs = statSync2(claimed).mtimeMs;
7755
7973
  } catch (err) {
7756
7974
  if (!isEnoent(err))
7757
7975
  throw err;
@@ -7777,7 +7995,7 @@ function acquireDrainLock(lockPath) {
7777
7995
  function renewDrainLock(lockPath, token) {
7778
7996
  let holder;
7779
7997
  try {
7780
- holder = readFileSync3(lockPath, "utf8").trim();
7998
+ holder = readFileSync4(lockPath, "utf8").trim();
7781
7999
  } catch (err) {
7782
8000
  if (!isEnoent(err))
7783
8001
  throw err;
@@ -7797,7 +8015,7 @@ function renewDrainLock(lockPath, token) {
7797
8015
  }
7798
8016
  function releaseDrainLock(lockPath, token) {
7799
8017
  try {
7800
- const holder = readFileSync3(lockPath, "utf8").trim();
8018
+ const holder = readFileSync4(lockPath, "utf8").trim();
7801
8019
  if (holder !== token)
7802
8020
  return;
7803
8021
  unlinkSync(lockPath);
@@ -7847,7 +8065,7 @@ function queueLines(buf) {
7847
8065
  return lines;
7848
8066
  }
7849
8067
  function removeQueueHead(path, cut) {
7850
- const remaining = readFileSync3(path);
8068
+ const remaining = readFileSync4(path);
7851
8069
  writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
7852
8070
  }
7853
8071
  function queueBucketSize(path) {
@@ -7868,7 +8086,7 @@ function queueBucketSize(path) {
7868
8086
  function readQueueFile(path) {
7869
8087
  if (queueBucketSize(path) === null)
7870
8088
  return null;
7871
- return readFileSync3(path);
8089
+ return readFileSync4(path);
7872
8090
  }
7873
8091
  function rejectLine(rejectedPath, reason, status, identity, raw) {
7874
8092
  const record = JSON.stringify({
@@ -8050,13 +8268,19 @@ function logsCredentialMissing(headers, env) {
8050
8268
  const varPattern = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
8051
8269
  for (const value of Object.values(headers)) {
8052
8270
  for (const match of value.matchAll(varPattern)) {
8053
- if (!env[match[1]])
8054
- return true;
8271
+ const name = match[1];
8272
+ if (env[name])
8273
+ continue;
8274
+ return true;
8055
8275
  }
8056
8276
  }
8057
8277
  return false;
8058
8278
  }
8059
8279
  function resolveLogDestinationFrom(input) {
8280
+ const spoolDir = input.env.VINAYA_LOG_SPOOL_DIR;
8281
+ if (spoolDir !== undefined && spoolDir.trim() !== "") {
8282
+ return { kind: "folder", folder: spoolDir };
8283
+ }
8060
8284
  const local = resolveLogsSetting(input.localConfig);
8061
8285
  let effective = null;
8062
8286
  let fallbackReason;
@@ -8096,24 +8320,73 @@ function resolveLogDestinationFrom(input) {
8096
8320
  const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
8097
8321
  return fallbackReason ? { kind: "folder", folder, fallbackReason } : { kind: "folder", folder };
8098
8322
  }
8099
- var processTrustAnchorOnce;
8100
- function processTrustAnchor() {
8101
- if (processTrustAnchorOnce === undefined)
8102
- processTrustAnchorOnce = safeLoadTrustAnchorConfig();
8103
- return processTrustAnchorOnce;
8323
+ var processTrustAnchorByRepo = new Map;
8324
+ function processTrustAnchor(repoRoot) {
8325
+ const cached = processTrustAnchorByRepo.get(repoRoot);
8326
+ if (cached !== undefined)
8327
+ return cached;
8328
+ const reading = safeLoadTrustAnchorConfig();
8329
+ processTrustAnchorByRepo.set(repoRoot, reading);
8330
+ return reading;
8104
8331
  }
8105
8332
  async function defaultResolveLogDestination(repo, env) {
8106
8333
  const localConfig = loadConfig();
8107
8334
  const unattended = isUnattendedProcess(process.env);
8335
+ const repoRoot = repoRootSync();
8108
8336
  return resolveLogDestinationFrom({
8109
8337
  localConfig,
8110
- trustAnchorConfig: unattended ? await processTrustAnchor() : null,
8338
+ trustAnchorConfig: unattended ? await processTrustAnchor(repoRoot) : null,
8111
8339
  unattended,
8112
8340
  env,
8113
8341
  defaultFolder: join6(await runtimeDirForRepoAsync(repo), "logs"),
8114
- repoRoot: repoRootSync()
8342
+ repoRoot
8115
8343
  });
8116
8344
  }
8345
+ function unresolvedLogDestination(env) {
8346
+ if (hostFromEnv(env) === "ci") {
8347
+ return {
8348
+ kind: "none",
8349
+ reason: "the process ended before its log destination was resolved, and a CI job never records to a folder"
8350
+ };
8351
+ }
8352
+ const loaded = loadConfig();
8353
+ const localConfig = loaded?.logs?.url !== undefined ? { ...loaded, logs: undefined } : loaded;
8354
+ const unattended = isUnattendedProcess(process.env);
8355
+ const repoRoot = repoRootSync();
8356
+ const runtimeDir = process.env[RUNTIME_DIR_ENV_KEY] || resolveRuntimeDir({ repo: null, localConfig, trustAnchorConfig: null, unattended, repoRoot });
8357
+ const defaultFolder = join6(runtimeDir, "logs");
8358
+ const resolved = resolveLogDestinationFrom({
8359
+ localConfig,
8360
+ trustAnchorConfig: null,
8361
+ unattended,
8362
+ env,
8363
+ defaultFolder,
8364
+ repoRoot
8365
+ });
8366
+ return resolved.kind === "folder" ? resolved : { kind: "folder", folder: defaultFolder };
8367
+ }
8368
+ function folderFallbackStatePath(repo, stateRoot = GLOBAL_VINAYA_HOME) {
8369
+ const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
8370
+ return join6(stateRoot, "fallback", `${dirName}.json`);
8371
+ }
8372
+ function recordFolderFallback(repo, issue, reason, now, runtimeDir, stateRoot = GLOBAL_VINAYA_HOME) {
8373
+ const message = describeFolderFallback(reason);
8374
+ if (issue !== null) {
8375
+ appendLoopLogLine(loopLogPathFor(repo, issue, runtimeDir), `[log] ${message}`);
8376
+ }
8377
+ try {
8378
+ const record = {
8379
+ at: now.toISOString(),
8380
+ reason: message,
8381
+ intendedUrl: reason.intendedUrl,
8382
+ kind: reason.kind
8383
+ };
8384
+ const path = folderFallbackStatePath(repo, stateRoot);
8385
+ mkdirSync4(dirname6(path), { recursive: true, mode: 448 });
8386
+ writeFileSync3(path, `${JSON.stringify(record)}
8387
+ `, { mode: 384 });
8388
+ } catch {}
8389
+ }
8117
8390
  function isEnoent2(err) {
8118
8391
  return typeof err === "object" && err !== null && err.code === "ENOENT";
8119
8392
  }
@@ -8226,7 +8499,7 @@ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
8226
8499
  }
8227
8500
  function readVinayaVersion() {
8228
8501
  try {
8229
- const pkg = JSON.parse(readFileSync4(join6(packageRoot(import.meta.url), "package.json"), "utf8"));
8502
+ const pkg = JSON.parse(readFileSync5(join6(packageRoot(import.meta.url), "package.json"), "utf8"));
8230
8503
  return pkg.version ?? "unknown";
8231
8504
  } catch {
8232
8505
  return "unknown";
@@ -8264,6 +8537,7 @@ function defaultStderr(message) {
8264
8537
  }
8265
8538
  var branchIssueFallbackEnabled = true;
8266
8539
  var branchIssueByCwd = new Map;
8540
+ var branchIssueSettledByCwd = new Map;
8267
8541
  function branchIssueRead(key, read, shared) {
8268
8542
  if (!shared)
8269
8543
  return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
@@ -8272,8 +8546,30 @@ function branchIssueRead(key, read, shared) {
8272
8546
  return cached;
8273
8547
  const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
8274
8548
  branchIssueByCwd.set(key, reading);
8549
+ reading.then((value) => branchIssueSettledByCwd.set(key, value));
8550
+ return reading;
8551
+ }
8552
+ var headShaByCwd = new Map;
8553
+ var headShaSettledByCwd = new Map;
8554
+ function headShaRead(key, read, shared) {
8555
+ if (!shared)
8556
+ return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
8557
+ const cached = headShaByCwd.get(key);
8558
+ if (cached !== undefined)
8559
+ return cached;
8560
+ const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
8561
+ headShaByCwd.set(key, reading);
8562
+ reading.then((value) => headShaSettledByCwd.set(key, value));
8275
8563
  return reading;
8276
8564
  }
8565
+ async function resolveHeadSha(cwd) {
8566
+ try {
8567
+ const out = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "HEAD"], { encoding: "utf8" })).stdout.trim();
8568
+ return /^[0-9a-f]{40}$/.test(out) ? out : null;
8569
+ } catch {
8570
+ return null;
8571
+ }
8572
+ }
8277
8573
  function defaultDeps() {
8278
8574
  return {
8279
8575
  outboxRoot: () => join6(GLOBAL_VINAYA_HOME, "outbox"),
@@ -8288,29 +8584,30 @@ function defaultDeps() {
8288
8584
  inputVersions: () => {
8289
8585
  return;
8290
8586
  },
8291
- resolveLogDestination: defaultResolveLogDestination
8587
+ resolveLogDestination: defaultResolveLogDestination,
8588
+ unresolvedLogDestination
8292
8589
  };
8293
8590
  }
8294
- var APPEND_OPEN_FLAGS = fsConstants3.O_WRONLY | fsConstants3.O_APPEND | fsConstants3.O_CREAT | fsConstants3.O_NOFOLLOW | fsConstants3.O_NONBLOCK;
8591
+ var APPEND_OPEN_FLAGS = fsConstants4.O_WRONLY | fsConstants4.O_APPEND | fsConstants4.O_CREAT | fsConstants4.O_NOFOLLOW | fsConstants4.O_NONBLOCK;
8295
8592
  function guardedAppendOpen(path) {
8296
8593
  try {
8297
- return openSync3(path, APPEND_OPEN_FLAGS, 384);
8594
+ return openSync4(path, APPEND_OPEN_FLAGS, 384);
8298
8595
  } catch {
8299
8596
  return;
8300
8597
  }
8301
8598
  }
8302
8599
  function appendHardenedLine(path, line) {
8303
8600
  try {
8304
- mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
8601
+ mkdirSync4(dirname6(path), { recursive: true, mode: 448 });
8305
8602
  const fd = guardedAppendOpen(path);
8306
8603
  if (fd === undefined)
8307
8604
  return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
8308
8605
  try {
8309
- if (!fstatSync2(fd).isFile())
8606
+ if (!fstatSync3(fd).isFile())
8310
8607
  return `target is not a regular file: ${path}`;
8311
- writeSync2(fd, line);
8608
+ writeSync3(fd, line);
8312
8609
  } finally {
8313
- closeSync3(fd);
8610
+ closeSync4(fd);
8314
8611
  }
8315
8612
  return null;
8316
8613
  } catch (err) {
@@ -8320,7 +8617,7 @@ function appendHardenedLine(path, line) {
8320
8617
  function reportRotationOverflow(backupPath, warn) {
8321
8618
  let raw;
8322
8619
  try {
8323
- raw = readFileSync4(backupPath, "utf8");
8620
+ raw = readFileSync5(backupPath, "utf8");
8324
8621
  } catch {
8325
8622
  return;
8326
8623
  }
@@ -8343,7 +8640,7 @@ function reportRotationOverflow(backupPath, warn) {
8343
8640
  }
8344
8641
  function appendLine(path, line, warn) {
8345
8642
  try {
8346
- mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
8643
+ mkdirSync4(dirname6(path), { recursive: true, mode: 448 });
8347
8644
  let fd = guardedAppendOpen(path);
8348
8645
  if (fd === undefined) {
8349
8646
  warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
@@ -8352,14 +8649,14 @@ function appendLine(path, line, warn) {
8352
8649
  }
8353
8650
  let closed = false;
8354
8651
  try {
8355
- const stat = fstatSync2(fd);
8652
+ const stat = fstatSync3(fd);
8356
8653
  if (!stat.isFile()) {
8357
8654
  warn(`vinaya: log outbox target is not a regular file — refusing to write: ${path}
8358
8655
  `);
8359
8656
  return;
8360
8657
  }
8361
8658
  if (stat.size > OUTBOX_MAX_BYTES) {
8362
- closeSync3(fd);
8659
+ closeSync4(fd);
8363
8660
  closed = true;
8364
8661
  const backupPath = path.replace(/\.ndjson$/, ".1.ndjson");
8365
8662
  reportRotationOverflow(backupPath, warn);
@@ -8373,10 +8670,10 @@ function appendLine(path, line, warn) {
8373
8670
  fd = rotated;
8374
8671
  closed = false;
8375
8672
  }
8376
- writeSync2(fd, line);
8673
+ writeSync3(fd, line);
8377
8674
  } finally {
8378
8675
  if (!closed)
8379
- closeSync3(fd);
8676
+ closeSync4(fd);
8380
8677
  }
8381
8678
  } catch (err) {
8382
8679
  warn(`vinaya: log outbox write failed — ${err instanceof Error ? err.message : String(err)}
@@ -8387,12 +8684,14 @@ function createLogSink(overrides = {}) {
8387
8684
  const deps = {
8388
8685
  ...defaultDeps(),
8389
8686
  resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
8687
+ resolveHeadSha: () => resolveHeadSha(deps.cwd()),
8390
8688
  ...overrides
8391
8689
  };
8392
8690
  const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
8393
8691
  const processId = randomUUID2();
8394
8692
  let seq = 0;
8395
8693
  let warned = false;
8694
+ let folderFallbackRecorded = false;
8396
8695
  const warnOnce = (message) => {
8397
8696
  if (warned)
8398
8697
  return;
@@ -8410,6 +8709,7 @@ function createLogSink(overrides = {}) {
8410
8709
  };
8411
8710
  const readerIsReal = overrides.resolveBranchIssue === undefined;
8412
8711
  let ownBranchIssue;
8712
+ let ownBranchIssueSettled = null;
8413
8713
  const branchIssueOnce = (repo) => {
8414
8714
  if (!branchIssueFallbackEnabled)
8415
8715
  return Promise.resolve(null);
@@ -8417,10 +8717,36 @@ function createLogSink(overrides = {}) {
8417
8717
  const read = () => deps.resolveBranchIssue(slug);
8418
8718
  if (readerIsReal)
8419
8719
  return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
8420
- if (ownBranchIssue === undefined)
8720
+ if (ownBranchIssue === undefined) {
8421
8721
  ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
8722
+ ownBranchIssue.then((value) => {
8723
+ ownBranchIssueSettled = value;
8724
+ });
8725
+ }
8422
8726
  return ownBranchIssue;
8423
8727
  };
8728
+ const branchIssueIfSettled = (repo) => {
8729
+ if (!branchIssueFallbackEnabled)
8730
+ return null;
8731
+ if (!readerIsReal)
8732
+ return ownBranchIssueSettled;
8733
+ return branchIssueSettledByCwd.get(`${deps.cwd()}\x00${safeRepoSlug(repo) ?? ""}`) ?? null;
8734
+ };
8735
+ const headShaReaderIsReal = overrides.resolveHeadSha === undefined;
8736
+ let ownHeadSha;
8737
+ let ownHeadShaSettled = null;
8738
+ const headShaOnce = () => {
8739
+ if (headShaReaderIsReal)
8740
+ return headShaRead(deps.cwd(), deps.resolveHeadSha, true);
8741
+ if (ownHeadSha === undefined) {
8742
+ ownHeadSha = headShaRead(deps.cwd(), deps.resolveHeadSha, false);
8743
+ ownHeadSha.then((value) => {
8744
+ ownHeadShaSettled = value;
8745
+ });
8746
+ }
8747
+ return ownHeadSha;
8748
+ };
8749
+ const headShaIfSettled = () => headShaReaderIsReal ? headShaSettledByCwd.get(deps.cwd()) ?? null : ownHeadShaSettled;
8424
8750
  let resolveRepoCache;
8425
8751
  const resolveRepoOnce = () => {
8426
8752
  if (resolveRepoCache === undefined)
@@ -8428,6 +8754,7 @@ function createLogSink(overrides = {}) {
8428
8754
  return resolveRepoCache;
8429
8755
  };
8430
8756
  let contextCache;
8757
+ let settledContext;
8431
8758
  const context = () => {
8432
8759
  if (contextCache === undefined) {
8433
8760
  const env = deps.env();
@@ -8436,11 +8763,16 @@ function createLogSink(overrides = {}) {
8436
8763
  doctrine()
8437
8764
  ]).then(async ([resolved, doctrineValue]) => {
8438
8765
  const repo = resolved && isSafeRepoSegment3(resolved.owner) && isSafeRepoSegment3(resolved.repo) ? resolved : null;
8439
- return { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
8766
+ settledContext = { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
8767
+ return settledContext;
8440
8768
  });
8441
8769
  }
8442
8770
  return contextCache;
8443
8771
  };
8772
+ const resetContext = () => {
8773
+ contextCache = undefined;
8774
+ settledContext = undefined;
8775
+ };
8444
8776
  let drainChain = Promise.resolve();
8445
8777
  const pendingWrites = new Set;
8446
8778
  let writeChain = Promise.resolve();
@@ -8452,63 +8784,88 @@ function createLogSink(overrides = {}) {
8452
8784
  `);
8453
8785
  });
8454
8786
  };
8455
- function log(e) {
8456
- try {
8457
- const env = deps.env();
8458
- const host = hostFromEnv(env);
8459
- const now = deps.now();
8460
- const mySeq = seq++;
8461
- const envFields = {
8787
+ const snapshot = () => {
8788
+ const env = deps.env();
8789
+ return {
8790
+ host: hostFromEnv(env),
8791
+ now: deps.now(),
8792
+ seq: seq++,
8793
+ envFields: {
8462
8794
  role: env.VINAYA_ROLE,
8463
8795
  task: env.VINAYA_TASK,
8464
8796
  round: env.VINAYA_ROUND,
8797
+ pr: env.VINAYA_PR,
8465
8798
  run: env.VINAYA_RUN || runId,
8466
8799
  attempt: env.VINAYA_ATTEMPT,
8467
- parent: env.VINAYA_PARENT_EVENT
8468
- };
8469
- const write = async () => {
8470
- const { repo, doctrine: doctrineValue, destination: resolvedDestination } = await context();
8471
- if (resolvedDestination.kind === "none") {
8472
- warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
8800
+ parent: env.VINAYA_PARENT_EVENT,
8801
+ workRef: env.VINAYA_WORK_REF,
8802
+ flow: env.VINAYA_FLOW,
8803
+ flowVersion: env.VINAYA_FLOW_VERSION,
8804
+ runtime: env.VINAYA_RUNTIME,
8805
+ source: env.VINAYA_SOURCE
8806
+ }
8807
+ };
8808
+ };
8809
+ const writeEvent = (e, call, ctx, branchIssue, headSha, deliver) => {
8810
+ const { repo, doctrine: doctrineValue, destination } = ctx;
8811
+ if (destination.kind === "none") {
8812
+ warnOnce(`vinaya: not recording — ${destination.reason}
8473
8813
  `);
8474
- return;
8475
- }
8476
- if (resolvedDestination.kind === "folder" && resolvedDestination.fallbackReason) {
8477
- warnOnce(`vinaya: ${describeFolderFallback(resolvedDestination.fallbackReason)}
8814
+ return;
8815
+ }
8816
+ if (destination.kind === "folder" && destination.fallbackReason) {
8817
+ warnOnce(`vinaya: ${describeFolderFallback(destination.fallbackReason)}
8478
8818
  `);
8479
- }
8480
- const branchIssue = envFields.task ? null : await branchIssueOnce(repo);
8481
- const header = buildHeader({
8482
- now,
8483
- runId,
8484
- seq: mySeq,
8485
- repo: repo ? `${repo.owner}/${repo.repo}` : null,
8486
- vinaya: deps.vinayaVersion(),
8487
- doctrine: doctrineValue,
8488
- host,
8489
- hostname: deps.hostname(),
8490
- env: envFields,
8491
- branchIssue,
8492
- eventId: randomUUID2(),
8493
- processId,
8494
- inputVersions: deps.inputVersions()
8495
- });
8496
- const full = { ...e, ...header };
8497
- const parsed = LogEventSchema.safeParse(full);
8498
- if (!parsed.success) {
8499
- warnOnce(`vinaya: log() refused an invalid payload — ${parsed.error.issues[0]?.message ?? "schema violation"}
8819
+ }
8820
+ const built = buildHeader({
8821
+ now: call.now,
8822
+ runId,
8823
+ seq: call.seq,
8824
+ repo: repo ? `${repo.owner}/${repo.repo}` : null,
8825
+ vinaya: deps.vinayaVersion(),
8826
+ doctrine: doctrineValue,
8827
+ host: call.host,
8828
+ hostname: deps.hostname(),
8829
+ env: call.envFields,
8830
+ branchIssue,
8831
+ eventId: randomUUID2(),
8832
+ processId,
8833
+ inputVersions: deps.inputVersions()
8834
+ });
8835
+ const header = headSha === null ? built : { ...built, subject: { ...built.subject, sha: headSha } };
8836
+ if (destination.kind === "folder" && destination.fallbackReason && !folderFallbackRecorded) {
8837
+ folderFallbackRecorded = true;
8838
+ recordFolderFallback(repo, header.subject.issue, destination.fallbackReason, call.now, dirname6(destination.folder), join6(deps.home(), ".vinaya"));
8839
+ }
8840
+ const full = { ...e, ...header };
8841
+ const parsed = LogEventSchema.safeParse(full);
8842
+ if (!parsed.success) {
8843
+ warnOnce(`vinaya: log() refused an invalid payload — ${parsed.error.issues[0]?.message ?? "schema violation"}
8500
8844
  `);
8501
- return;
8502
- }
8503
- const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
8845
+ return;
8846
+ }
8847
+ const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
8504
8848
  `;
8505
- const destination = resolvedDestination;
8506
- if (destination.kind === "server") {
8507
- appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
8508
- scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
8509
- } else {
8510
- appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
8849
+ if (destination.kind === "server") {
8850
+ appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
8851
+ if (deliver)
8852
+ scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
8853
+ } else {
8854
+ appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
8855
+ }
8856
+ };
8857
+ function log(e) {
8858
+ try {
8859
+ const call = snapshot();
8860
+ const write = async () => {
8861
+ const ctx = await context();
8862
+ if (ctx.destination.kind === "none") {
8863
+ writeEvent(e, call, ctx, null, null, true);
8864
+ return;
8511
8865
  }
8866
+ const branchIssue = call.envFields.task ? null : await branchIssueOnce(ctx.repo);
8867
+ const headSha = e.kind === "gate" ? await headShaOnce() : null;
8868
+ writeEvent(e, call, ctx, branchIssue, headSha, true);
8512
8869
  };
8513
8870
  const written = writeChain.then(write).catch((err) => {
8514
8871
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
@@ -8519,6 +8876,26 @@ function createLogSink(overrides = {}) {
8519
8876
  written.finally(() => pendingWrites.delete(written));
8520
8877
  } catch (err) {
8521
8878
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
8879
+ `);
8880
+ }
8881
+ }
8882
+ function logSync(e, opts = {}) {
8883
+ try {
8884
+ const call = snapshot();
8885
+ let ctx = settledContext;
8886
+ if (ctx === undefined) {
8887
+ const destination = deps.unresolvedLogDestination(deps.env());
8888
+ if (destination.kind === "folder" && !opts.quiet) {
8889
+ warnOnce(`vinaya: the process ended before its log destination was resolved — the event is written to ${destination.folder}; \`vinaya log send\` delivers it to a configured server later
8890
+ `);
8891
+ }
8892
+ ctx = { repo: null, doctrine: "unknown", destination };
8893
+ }
8894
+ const branchIssue = ctx.destination.kind === "none" || call.envFields.task ? null : branchIssueIfSettled(ctx.repo);
8895
+ const headSha = e.kind === "gate" && ctx.destination.kind !== "none" ? headShaIfSettled() : null;
8896
+ writeEvent(e, call, ctx, branchIssue, headSha, false);
8897
+ } catch (err) {
8898
+ warnOnce(`vinaya: logSync() failed — ${err instanceof Error ? err.message : String(err)}
8522
8899
  `);
8523
8900
  }
8524
8901
  }
@@ -8539,7 +8916,7 @@ function createLogSink(overrides = {}) {
8539
8916
  return;
8540
8917
  });
8541
8918
  };
8542
- return { log, runId, warmup, drain };
8919
+ return { log, logSync, runId, warmup, drain, resetContext };
8543
8920
  }
8544
8921
  var defaultSink = createLogSink();
8545
8922
 
@@ -8628,16 +9005,9 @@ function summaryLineIndex(maskedRegion) {
8628
9005
  return index === -1 ? null : index;
8629
9006
  }
8630
9007
 
8631
- // src/lib/loop-log.ts
8632
- var LOOP_LOG_MAX_BYTES = 8 * 1024 * 1024;
8633
-
8634
- // src/lib/diff-evidence.ts
8635
- import { execFileSync as execFileSync7 } from "node:child_process";
8636
- import { join as join9, relative, resolve as resolve2 } from "node:path";
8637
-
8638
9008
  // src/lib/brief-assembly.ts
8639
9009
  import { execFileSync as execFileSync6 } from "node:child_process";
8640
- import { existsSync as existsSync7, readFileSync as readFileSync6, readdirSync as readdirSync2 } from "node:fs";
9010
+ import { existsSync as existsSync7, readFileSync as readFileSync7, readdirSync as readdirSync2 } from "node:fs";
8641
9011
  import { join as join8 } from "node:path";
8642
9012
 
8643
9013
  // ../../packages/sources/src/commands.ts
@@ -8794,7 +9164,7 @@ var COMMANDS = [
8794
9164
  "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.",
8795
9165
  "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.",
8796
9166
  "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.",
8797
- "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`)."
9167
+ "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`)."
8798
9168
  ],
8799
9169
  status: "shipped"
8800
9170
  },
@@ -8879,13 +9249,14 @@ var COMMANDS = [
8879
9249
  },
8880
9250
  {
8881
9251
  flag: "--push",
8882
- 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."
9252
+ 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."
8883
9253
  }
8884
9254
  ],
8885
9255
  details: [
8886
9256
  "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.",
8887
9257
  "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.",
8888
- "`--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."
9258
+ "`--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.",
9259
+ "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."
8889
9260
  ],
8890
9261
  status: "shipped"
8891
9262
  },
@@ -8910,7 +9281,7 @@ var COMMANDS = [
8910
9281
  "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.",
8911
9282
  "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.",
8912
9283
  "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.",
8913
- "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."
9284
+ "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."
8914
9285
  ],
8915
9286
  status: "shipped"
8916
9287
  },
@@ -9081,7 +9452,7 @@ var COMMANDS = [
9081
9452
  { flag: "--secrets", description: "security only: the SECRETS line" },
9082
9453
  {
9083
9454
  flag: "--secrets-evidence-file",
9084
- description: 'security only: required whenever `--secrets` claims "none found" — the pasted scanner output backing that claim'
9455
+ 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'
9085
9456
  },
9086
9457
  { flag: "--task-id", description: "the closing `Tokens:` line's task id" },
9087
9458
  { flag: "--model", description: "the closing `Tokens:` line's model name" },
@@ -9189,7 +9560,20 @@ var COMMANDS = [
9189
9560
  flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
9190
9561
  details: [
9191
9562
  "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.",
9192
- "Once every task Issue is closed, prompts for confirmation (unless `--yes`) and closes the GitHub Milestone."
9563
+ "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.",
9564
+ "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.",
9565
+ "Idempotent: on a tranche whose Milestone is already closed and carries its retrospective, changes nothing and says it is already archived.",
9566
+ "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."
9567
+ ],
9568
+ status: "shipped"
9569
+ },
9570
+ {
9571
+ name: "archive tranches",
9572
+ description: "Archive every finished tranche that has no closed Milestone carrying its retrospective",
9573
+ flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
9574
+ details: [
9575
+ "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.",
9576
+ "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."
9193
9577
  ],
9194
9578
  status: "shipped"
9195
9579
  },
@@ -9333,6 +9717,29 @@ var COMMANDS = [
9333
9717
  ],
9334
9718
  status: "shipped"
9335
9719
  },
9720
+ {
9721
+ name: "log selftest",
9722
+ 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)",
9723
+ details: [
9724
+ "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.",
9725
+ "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.",
9726
+ "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."
9727
+ ],
9728
+ status: "shipped"
9729
+ },
9730
+ {
9731
+ name: "log emit",
9732
+ description: "Record a consumer-declared event (`logs.events` in vinaya.config.json) from a script or agent outside Vinaya",
9733
+ flags: [
9734
+ { flag: "--json '<json>'", description: "The field values as one JSON object (else read from standard input)" }
9735
+ ],
9736
+ details: [
9737
+ "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.",
9738
+ "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.",
9739
+ "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)."
9740
+ ],
9741
+ status: "shipped"
9742
+ },
9336
9743
  {
9337
9744
  name: "log send",
9338
9745
  description: "Deliver this repository's locally-held log events to the configured `logs.url` server, once",
@@ -9345,12 +9752,19 @@ var COMMANDS = [
9345
9752
  status: "shipped"
9346
9753
  },
9347
9754
  {
9348
- name: "log set-credential",
9349
- description: "Store a `logs.headers` delivery credential in the macOS login Keychain, read from standard input",
9755
+ name: "sync",
9756
+ description: "Fill, resume and rebuild the local log cache from this repository's configured destination (read-only)",
9757
+ flags: [
9758
+ {
9759
+ flag: "--rebuild",
9760
+ description: "Delete the cache file and sync from the beginning of what the destination still retains"
9761
+ },
9762
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
9763
+ ],
9350
9764
  details: [
9351
- 'For a `logs.url` server whose `headers` reference a credential by variable name (`{ "authorization": "Bearer ${VINAYA_LOG_TOKEN}" }`) on a host where that variable is not in the process environment — the case an Operator the Claude desktop app starts on macOS hits, since the token lives in an interactive shell file the app never reads. It stores the value so header resolution finds it in the Keychain when the environment does not, with no token copied into any settings file.',
9352
- 'The value is read from STANDARD INPUT, never a command-line argument a `ps` listing could show — `printf %s "$TOKEN" | vinaya log set-credential VINAYA_LOG_TOKEN`. Only the variable NAME, which is not a secret, sits on the command line; the value is stored under the Keychain service `Vinaya Log` keyed by that name. The command prints a confirmation naming the variable and never echoes, returns, or logs the value.',
9353
- "macOS only (Linux keyrings are out of scope); it refuses with a clear message elsewhere. The environment still wins over the Keychain wherever the variable is set, so this changes nothing for a host that already exports it."
9765
+ "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.",
9766
+ "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.",
9767
+ "`--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."
9354
9768
  ],
9355
9769
  status: "shipped"
9356
9770
  }
@@ -9364,10 +9778,10 @@ function createForgeSource(config) {
9364
9778
  };
9365
9779
  }
9366
9780
  // ../../packages/sources/src/select-source.ts
9367
- import { z as z5 } from "zod";
9368
- var StateSourceConfigSchema = z5.discriminatedUnion("kind", [
9369
- z5.object({ kind: z5.literal("forge"), owner: z5.string(), repo: z5.string() }),
9370
- z5.object({ kind: z5.literal("file"), root: z5.string().optional() })
9781
+ import { z as z6 } from "zod";
9782
+ var StateSourceConfigSchema = z6.discriminatedUnion("kind", [
9783
+ z6.object({ kind: z6.literal("forge"), owner: z6.string(), repo: z6.string() }),
9784
+ z6.object({ kind: z6.literal("file"), root: z6.string().optional() })
9371
9785
  ]);
9372
9786
  // src/checks/edge-resolve.ts
9373
9787
  import { execFileSync as execFileSync4 } from "node:child_process";
@@ -9489,9 +9903,18 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
9489
9903
 
9490
9904
  // src/commands/doctrine.ts
9491
9905
  import { execFileSync as execFileSync5 } from "node:child_process";
9492
- import { existsSync as existsSync6, readdirSync, readFileSync as readFileSync5 } from "node:fs";
9493
- import { dirname as dirname6, join as join7, sep } from "node:path";
9906
+ import { existsSync as existsSync6, readdirSync, readFileSync as readFileSync6 } from "node:fs";
9907
+ import { dirname as dirname7, join as join7, sep as sep2 } from "node:path";
9908
+ import matter4 from "gray-matter";
9909
+
9910
+ // ../../packages/aeg-core/src/docs/parse-doc.ts
9494
9911
  import matter2 from "gray-matter";
9912
+ // ../../packages/aeg-core/src/docs/surfaced-manifest.ts
9913
+ var NO_MODEL_BACKED_PATHS = new Set;
9914
+ // src/roles/contract.ts
9915
+ import matter3 from "gray-matter";
9916
+
9917
+ // src/commands/doctrine.ts
9495
9918
  var ENTRY_SEGMENTS = ["skills", "aeg", "SKILL.md"];
9496
9919
  function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
9497
9920
  return resolveDoctrineRootInfo(pkg, cwd)?.root ?? null;
@@ -9513,8 +9936,8 @@ function resolveDoctrineRootInfo(pkg = packageRoot(import.meta.url), cwd = proce
9513
9936
  if (existsSync6(join7(treeRoot, "roles")))
9514
9937
  return { root: treeRoot, source: "tree" };
9515
9938
  }
9516
- const fromSource = !pkg.split(sep).includes("node_modules");
9517
- const bundleRoot = fromSource ? join7(dirname6(dirname6(pkg)), "aeg-root") : join7(pkg, "aeg-root");
9939
+ const fromSource = !pkg.split(sep2).includes("node_modules");
9940
+ const bundleRoot = fromSource ? join7(dirname7(dirname7(pkg)), "aeg-root") : join7(pkg, "aeg-root");
9518
9941
  return hasDoctrineEntry(bundleRoot) ? { root: bundleRoot, source: "bundle" } : null;
9519
9942
  }
9520
9943
  function hasDoctrineEntry(root) {
@@ -9547,150 +9970,6 @@ var INFORMATIONAL_DISPATCH_BLOCKER_CLASSES = new Set([
9547
9970
  "conflicts-with"
9548
9971
  ]);
9549
9972
 
9550
- // src/commands/review-post.ts
9551
- function parseChangedLineRanges(diffOutput) {
9552
- const result = {};
9553
- let currentFile = null;
9554
- for (const line of diffOutput.split(`
9555
- `)) {
9556
- if (line.startsWith("+++ ")) {
9557
- const path = line.slice(4).trim();
9558
- currentFile = path === "/dev/null" ? null : path.replace(/^b\//, "");
9559
- continue;
9560
- }
9561
- if (line.startsWith("@@") && currentFile) {
9562
- const m = line.match(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/);
9563
- if (m) {
9564
- const start = Number(m[1]);
9565
- const count = m[2] !== undefined ? Number(m[2]) : 1;
9566
- if (count > 0) {
9567
- if (!result[currentFile])
9568
- result[currentFile] = [];
9569
- result[currentFile].push([start, start + count - 1]);
9570
- }
9571
- }
9572
- }
9573
- }
9574
- return result;
9575
- }
9576
-
9577
- // src/lib/diff-evidence.ts
9578
- function fileDiffAgainst(ref, path) {
9579
- let out;
9580
- try {
9581
- out = execFileSync7("git", ["diff", `${ref}...HEAD`, "--", path], {
9582
- encoding: "utf8",
9583
- stdio: ["ignore", "pipe", "pipe"]
9584
- }).trim();
9585
- } catch {
9586
- return null;
9587
- }
9588
- return out === "" ? null : out;
9589
- }
9590
- function revParse(ref) {
9591
- try {
9592
- return execFileSync7("git", ["rev-parse", "--verify", ref], {
9593
- encoding: "utf8",
9594
- stdio: ["ignore", "pipe", "pipe"]
9595
- }).trim();
9596
- } catch {
9597
- return null;
9598
- }
9599
- }
9600
- function repoRoot() {
9601
- try {
9602
- return execFileSync7("git", ["rev-parse", "--show-toplevel"], {
9603
- encoding: "utf8",
9604
- stdio: ["ignore", "pipe", "pipe"]
9605
- }).trim();
9606
- } catch {
9607
- return null;
9608
- }
9609
- }
9610
- function changedFiles(base) {
9611
- let out;
9612
- try {
9613
- out = execFileSync7("git", ["diff", "--name-only", `${base}...HEAD`], {
9614
- encoding: "utf8",
9615
- stdio: ["ignore", "pipe", "pipe"]
9616
- }).trim();
9617
- } catch {
9618
- return null;
9619
- }
9620
- return out === "" ? [] : out.split(`
9621
- `).map((s) => s.trim()).filter(Boolean);
9622
- }
9623
- function resolveChangedFiles(base = process.env.BASE_SHA || "origin/main") {
9624
- return resolveDiff(base)?.files ?? null;
9625
- }
9626
- function resolveDiff(base = process.env.BASE_SHA || "origin/main") {
9627
- const root = repoRoot();
9628
- if (root === null)
9629
- return null;
9630
- const head = revParse("HEAD");
9631
- for (const ref of [base, "main"]) {
9632
- const resolved = revParse(ref);
9633
- if (resolved === null || resolved === head)
9634
- continue;
9635
- const relPaths = changedFiles(ref);
9636
- if (relPaths === null)
9637
- continue;
9638
- return { base: ref, root, files: relPaths.map((p) => join9(root, p)) };
9639
- }
9640
- return null;
9641
- }
9642
- function changedLineRanges(ref, path) {
9643
- const diff = fileDiffAgainst(ref, path);
9644
- if (diff === null)
9645
- return null;
9646
- return parseChangedLineRanges(diff)[path] ?? null;
9647
- }
9648
- function lineIsInRanges(line, ranges) {
9649
- return ranges.some(([start, end]) => line >= start && line <= end);
9650
- }
9651
- function findingsInThisDiff(findings) {
9652
- const diff = resolveDiff();
9653
- if (diff === null)
9654
- return [...findings];
9655
- const changed = new Set(diff.files);
9656
- const ranges = new Map;
9657
- return findings.filter((f) => {
9658
- const abs = resolve2(diff.root, f.file);
9659
- if (!changed.has(abs))
9660
- return false;
9661
- const relPath = relative(diff.root, abs);
9662
- if (!ranges.has(relPath))
9663
- ranges.set(relPath, changedLineRanges(diff.base, relPath));
9664
- const fileRanges = ranges.get(relPath) ?? null;
9665
- return fileRanges === null ? true : lineIsInRanges(f.line, fileRanges);
9666
- });
9667
- }
9668
-
9669
- // src/lib/dispatch.ts
9670
- var MAX_TEE_BYTES = 8 * 1024 * 1024;
9671
- var CLAUDE_MODEL_ALIASES = new Set(["fable", "opus", "sonnet", "haiku"]);
9672
- var NO_SUBSCRIPTION_LOGIN_REASON = "this agent has no subscription login in Vinaya yet, and no agent authenticates with an API key — " + "dispatch a vendor whose subscription login Vinaya can stage (claude, codex)";
9673
-
9674
- // src/commands/tokens.ts
9675
- var USAGE = [
9676
- 'Usage: vinaya tokens --phase "<task-id>: develop" --role Developer',
9677
- " [--model <id>] [--transcript <path>] [--in <tokens-in> --out <tokens-out>]",
9678
- "",
9679
- " --transcript Read this transcript directly. Supported primary route — use it whenever you know",
9680
- " which transcript is yours, and always in a repo with no track-transcript.sh hook.",
9681
- " (omitted) Resolve via the Stop-hook pointer file, if this repo installs that hook.",
9682
- " --in/--out Manual entry: the exact token figures, for a host whose usage arrives by some other",
9683
- " means than a Claude Code transcript. Both required together; skips transcript",
9684
- " resolution entirely.",
9685
- "",
9686
- "Usage: vinaya tokens --trust-collect",
9687
- " Approves this repo's declared tokens.collect command, pinned to the script's exact current",
9688
- " content, on this machine. Run this once before tokens.collect will ever execute — a changed",
9689
- " interpreter, script path, or script CONTENT needs its own fresh approval. Does not take",
9690
- " --phase/--role and never emits a Tokens: line."
9691
- ].join(`
9692
- `);
9693
-
9694
9973
  // src/lib/pr-report-engine.ts
9695
9974
  var execFileAsync6 = promisify6(execFile6);
9696
9975
  var BODY_READING_CHECK_NAMES = new Set(coreCheckRegistry().filter((spec) => {
@@ -9717,39 +9996,21 @@ function agentCommandText(line) {
9717
9996
  return (idx === -1 ? line : line.slice(0, idx)).trim();
9718
9997
  }
9719
9998
  var AGENT_COMMAND_MAX_BUFFER_BYTES = 32 * 1024 * 1024;
9720
- var TOKEN_ROW_REMEDY = [
9721
- "Nothing here established that this host cannot meter — only that this session resolved no",
9722
- "transcript of its own. Report real figures by naming your own transcript:",
9723
- "",
9724
- " vinaya pr report --write <body-file> --transcript <path>",
9725
- "",
9726
- "or, on a host whose usage arrives by some other means, format figures you already hold with:",
9727
- "",
9728
- ' vinaya tokens --phase "<task-id>: develop" --role Developer --in <tokens-in> --out <tokens-out>',
9729
- "",
9730
- "and transcribe them into the `## Token report` table. That command prints a `Tokens:` line, not",
9731
- "a table row — the table takes | Phase | Role | Agent/Model | Tokens in | Tokens out | Cost | Date |,",
9732
- "and a line inside the block that does not start with `|` truncates the table for every row after it."
9733
- ].join(`
9734
- `);
9735
- // src/commands/pr-report.ts
9736
- var USAGE2 = "Usage: vinaya pr report [--write <body-file> | --push <pr> [--body-file <path>]] [--phase <phase>] " + "[--role <role>] [--model <id>] [--transcript <path>]";
9737
-
9738
9999
  // src/lib/patch-id.ts
9739
- import { execFileSync as execFileSync8 } from "node:child_process";
10000
+ import { execFileSync as execFileSync7 } from "node:child_process";
9740
10001
  function patchIdAt(base, sha) {
9741
10002
  try {
9742
- execFileSync8("git", ["fetch", "--quiet", "origin", sha], { stdio: ["ignore", "ignore", "ignore"] });
10003
+ execFileSync7("git", ["fetch", "--quiet", "origin", sha], { stdio: ["ignore", "ignore", "ignore"] });
9743
10004
  } catch {}
9744
10005
  try {
9745
- const diff = execFileSync8("git", ["diff", `origin/${base}...${sha}`], {
10006
+ const diff = execFileSync7("git", ["diff", `origin/${base}...${sha}`], {
9746
10007
  encoding: "utf8",
9747
10008
  maxBuffer: 64 * 1024 * 1024,
9748
10009
  stdio: ["ignore", "pipe", "pipe"]
9749
10010
  });
9750
10011
  if (diff === "")
9751
10012
  return null;
9752
- const out = execFileSync8("git", ["patch-id", "--stable"], {
10013
+ const out = execFileSync7("git", ["patch-id", "--stable"], {
9753
10014
  input: diff,
9754
10015
  encoding: "utf8",
9755
10016
  stdio: ["pipe", "pipe", "pipe"]
@@ -9861,7 +10122,7 @@ function compareEvidenceBlock(resolved, resolvedHead, actualNumstat, expectedGro
9861
10122
  var DEVELOPER_ROUND_MARKER = /<!--\s*aeg:developer:round-\d+\s*-->/i;
9862
10123
  function fetchHasPriorDeveloperRound(prNumber) {
9863
10124
  try {
9864
- const out = execFileSync9("gh", ["pr", "view", String(prNumber), "--json", "comments"], {
10125
+ const out = execFileSync8("gh", ["pr", "view", String(prNumber), "--json", "comments"], {
9865
10126
  encoding: "utf8",
9866
10127
  stdio: ["ignore", "pipe", "pipe"]
9867
10128
  });
@@ -9875,7 +10136,7 @@ function fetchHasPriorDeveloperRound(prNumber) {
9875
10136
  var CHECK_NAME = "evidence-fresh";
9876
10137
  function git2(args) {
9877
10138
  try {
9878
- return execFileSync9("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
10139
+ return execFileSync8("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9879
10140
  } catch {
9880
10141
  return "";
9881
10142
  }
@@ -9894,7 +10155,7 @@ class GitCommandError2 extends Error {
9894
10155
  }
9895
10156
  function gitStrict(args) {
9896
10157
  try {
9897
- return execFileSync9("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
10158
+ return execFileSync8("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9898
10159
  } catch (err) {
9899
10160
  const stderr = err.stderr;
9900
10161
  throw new GitCommandError2(args, String(stderr ?? err.message).trim() || "non-zero exit");
@@ -9912,7 +10173,7 @@ function resolveMergeBase(head) {
9912
10173
  }
9913
10174
  function fetchPrRefs(prNumber) {
9914
10175
  try {
9915
- const out = execFileSync9("gh", ["pr", "view", String(prNumber), "--json", "headRefOid,baseRefName"], {
10176
+ const out = execFileSync8("gh", ["pr", "view", String(prNumber), "--json", "headRefOid,baseRefName"], {
9916
10177
  encoding: "utf8",
9917
10178
  stdio: ["ignore", "pipe", "pipe"]
9918
10179
  });