@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
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/checks/bin/check-doctrine-portability.ts
4
4
  import { execFileSync as execFileSync8 } from "node:child_process";
5
- import { readdirSync as readdirSync3, readFileSync as readFileSync7, statSync as statSync2 } from "node:fs";
5
+ import { readdirSync as readdirSync3, readFileSync as readFileSync8, statSync as statSync3 } from "node:fs";
6
6
  import { join as join10 } from "node:path";
7
7
  // ../../packages/aeg-core/src/gate-audience.ts
8
8
  var GATE_AUDIENCE = {
@@ -1887,45 +1887,6 @@ var DERIVED_STATUSES = [
1887
1887
  "incoherent"
1888
1888
  ];
1889
1889
  var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
1890
- // ../../packages/aeg-core/src/parse-ledger.ts
1891
- function rowFromCells(cells) {
1892
- if (cells.length < 7)
1893
- return null;
1894
- const phase = (cells[0] ?? "").trim();
1895
- if (!phase)
1896
- return null;
1897
- return {
1898
- phase,
1899
- role: (cells[1] ?? "").trim(),
1900
- agentModel: (cells[2] ?? "").trim(),
1901
- tokensIn: parseIntCell(cells[3] ?? ""),
1902
- tokensOut: parseIntCell(cells[4] ?? ""),
1903
- cost: parseCostCell(cells[5] ?? ""),
1904
- date: (cells[6] ?? "").trim()
1905
- };
1906
- }
1907
- function parseIntCell(cell) {
1908
- const trimmed = cell.replace(/`/g, "").trim();
1909
- if (!trimmed || isEmDashOrDash(trimmed))
1910
- return null;
1911
- const normalized = trimmed.replace(/[,_\s]/g, "");
1912
- if (!/^-?\d+$/.test(normalized))
1913
- return null;
1914
- return Number(normalized);
1915
- }
1916
- function parseCostCell(cell) {
1917
- const trimmed = cell.replace(/`/g, "").trim();
1918
- if (!trimmed || isEmDashOrDash(trimmed))
1919
- return null;
1920
- const normalized = trimmed.replace(/^\$/, "").replace(/[,_\s]/g, "");
1921
- if (!/^-?\d+(\.\d+)?$/.test(normalized))
1922
- return null;
1923
- return Number(normalized);
1924
- }
1925
- function isEmDashOrDash(s) {
1926
- const t = s.trim();
1927
- return t === "—" || t === "-" || t === "–";
1928
- }
1929
1890
  // ../../packages/aeg-core/src/waiver-label.ts
1930
1891
  var WAIVER_LABEL = label("waiver-docs");
1931
1892
  var WAIVER_LABEL_REVIEW = label("waiver-review");
@@ -1941,61 +1902,6 @@ function isWaiverLabelActorVerified(opts) {
1941
1902
  return false;
1942
1903
  return isPrincipal(opts.labelActor, opts.principalAllowlist);
1943
1904
  }
1944
-
1945
- // ../../packages/aeg-core/src/parse-token-report.ts
1946
- var TOKEN_REPORT_HEADING = /^\s*(?:#{1,6}\s*Token report\s*|\*\*Token report\*\*)\s*$/i;
1947
- var INLINE_FIELD_LIST = /Phase:\s*([^|]+?)\s*\|\s*Role:\s*([^|]+?)\s*\|\s*Agent\/Model:\s*([^|]+?)\s*\|\s*Tokens in:\s*([^|]+?)\s*\|\s*Tokens out:\s*([^|]+?)\s*\|\s*Cost:\s*([^|]+?)\s*\|\s*Date:\s*(.+?)\s*$/im;
1948
- function parseTokenReportEntries(body) {
1949
- const lines = body.split(/\r?\n/);
1950
- const headingIdxs = [];
1951
- lines.forEach((line, i) => {
1952
- if (TOKEN_REPORT_HEADING.test(line))
1953
- headingIdxs.push(i);
1954
- });
1955
- const out = [];
1956
- for (let h = 0;h < headingIdxs.length; h++) {
1957
- const start = headingIdxs[h] + 1;
1958
- const end = h + 1 < headingIdxs.length ? headingIdxs[h + 1] : lines.length;
1959
- const section = lines.slice(start, end).join(`
1960
- `);
1961
- const tableRows = parseTableSection(section);
1962
- if (tableRows.length > 0) {
1963
- out.push(...tableRows);
1964
- continue;
1965
- }
1966
- const inlineRow = parseInlineFieldList(section);
1967
- if (inlineRow)
1968
- out.push(inlineRow);
1969
- }
1970
- return out;
1971
- }
1972
- function parseTableSection(section) {
1973
- const lines = section.split(/\r?\n/);
1974
- let i = 0;
1975
- for (;i < lines.length; i++) {
1976
- if ((lines[i] ?? "").trim().startsWith("|"))
1977
- break;
1978
- }
1979
- if (i + 1 >= lines.length)
1980
- return [];
1981
- i += 2;
1982
- const out = [];
1983
- for (;i < lines.length; i++) {
1984
- const trimmed = (lines[i] ?? "").trim();
1985
- if (!trimmed.startsWith("|"))
1986
- break;
1987
- const row = rowFromCells(splitTableRow(trimmed));
1988
- if (row)
1989
- out.push(row);
1990
- }
1991
- return out;
1992
- }
1993
- function parseInlineFieldList(section) {
1994
- const m = section.match(INLINE_FIELD_LIST);
1995
- if (!m)
1996
- return null;
1997
- return rowFromCells([m[1], m[2], m[3], m[4], m[5], m[6], m[7]]);
1998
- }
1999
1905
  // ../../packages/aeg-core/src/verdict-extraction.ts
2000
1906
  var HEAD_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged head:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
2001
1907
  var OBJECTIVES_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Objectives version:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
@@ -2444,10 +2350,12 @@ function evaluateC5(changed, docOwnersContent, prBody, fileExists, waiverActive,
2444
2350
  var CODE_REVIEW_SEVERITY_ORDER = ["BLOCKER", "MAJOR", "MINOR"];
2445
2351
  var SECURITY_SEVERITY_ORDER = ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
2446
2352
  var DEFAULT_MAX_ROUNDS = 3;
2353
+ var DEFAULT_MAX_TASK_MINUTES = 180;
2447
2354
  var DEFAULT_REVIEW_POLICY = {
2448
2355
  codeReviewThreshold: "BLOCKER",
2449
2356
  securityThreshold: "HIGH",
2450
- maxRounds: DEFAULT_MAX_ROUNDS
2357
+ maxRounds: DEFAULT_MAX_ROUNDS,
2358
+ maxTaskMinutes: DEFAULT_MAX_TASK_MINUTES
2451
2359
  };
2452
2360
  var FILE_SHAPED_LOCATION = /\.[a-zA-Z0-9]{1,10}(:\d+)?\s*$/;
2453
2361
  var PROSE_LOCATION_PATTERNS = [/\bpr\s*body\b/i, /\bcomment\b/i];
@@ -2848,11 +2756,13 @@ function checkDocUpdateList(prBody) {
2848
2756
  return headingCheck(prBody, "(?:documentation|doc)[- ]update(?:\\s+list)?", "Documentation-update list");
2849
2757
  }
2850
2758
  function checkWorktreeStep0(prBody) {
2851
- if (/git worktree add/.test(prBody))
2759
+ if (/git worktree add/.test(prBody) || /cd \.worktrees\//.test(prBody) || /bun install --frozen-lockfile/.test(prBody))
2852
2760
  return { status: "pass", errors: [] };
2853
2761
  return {
2854
2762
  status: "fail",
2855
- errors: ["brief-validation worktree Step 0: no `git worktree add` command found in the PR body."]
2763
+ errors: [
2764
+ "brief-validation worktree Step 0: no `git worktree add`, `cd .worktrees/`, or `bun install --frozen-lockfile` command found in the PR body."
2765
+ ]
2856
2766
  };
2857
2767
  }
2858
2768
  function checkStopConditions(prBody) {
@@ -3042,7 +2952,8 @@ function isCommandBlock(content) {
3042
2952
  return COMMAND_WORDS.includes(commandWordOf(firstNonBlankLine(content)));
3043
2953
  }
3044
2954
  function isStep0Block(content) {
3045
- return firstNonBlankLine(content).startsWith("git worktree add");
2955
+ const first = firstNonBlankLine(content);
2956
+ return first.startsWith("git worktree add") || first.startsWith("cd .worktrees/") || first.startsWith("bun install --frozen-lockfile");
3046
2957
  }
3047
2958
  function checkCommandsCarryOutput(prBody) {
3048
2959
  const errors = [];
@@ -3511,10 +3422,14 @@ function legacySlugPattern(legacySlugs) {
3511
3422
  const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
3512
3423
  return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
3513
3424
  }
3425
+ function specGrandfatherPaths(specGrandfather) {
3426
+ return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
3427
+ }
3514
3428
  function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
3515
3429
  const findings = [];
3516
3430
  const legacyPattern = legacySlugPattern(legacySlugs);
3517
- const grandfathered = new Set(specGrandfather);
3431
+ const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
3432
+ const limits = new Map(Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather));
3518
3433
  const patterns = [
3519
3434
  { pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
3520
3435
  { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
@@ -3533,18 +3448,19 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
3533
3448
  continue;
3534
3449
  if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
3535
3450
  continue;
3536
- if (cls === "spec" && grandfathered.has(file.path))
3451
+ if (cls === "spec" && grandfatheredWhole.has(file.path))
3537
3452
  continue;
3538
3453
  const blocking = cls === "product" || cls === "spec";
3539
3454
  const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
3540
3455
  const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
3456
+ const fileFindings = [];
3541
3457
  for (const { pattern, what, group } of patternsToRun) {
3542
3458
  pattern.lastIndex = 0;
3543
3459
  let match = pattern.exec(scrubbed);
3544
3460
  while (match !== null) {
3545
3461
  const cited = group !== undefined ? match[group] ?? match[0] : match[0];
3546
3462
  const citedIndex = match.index + match[0].indexOf(cited);
3547
- findings.push({
3463
+ fileFindings.push({
3548
3464
  file: file.path,
3549
3465
  line: lineAt(scrubbed, citedIndex),
3550
3466
  message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
@@ -3553,6 +3469,15 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
3553
3469
  match = pattern.exec(scrubbed);
3554
3470
  }
3555
3471
  }
3472
+ const limit = cls === "spec" ? limits.get(file.path) : undefined;
3473
+ if (limit !== undefined) {
3474
+ if (fileFindings.length <= limit)
3475
+ continue;
3476
+ for (const f of fileFindings) {
3477
+ f.message += `; ${file.path} carries ${fileFindings.length} such findings, over its proseGates.specGrandfather limit of ${limit}`;
3478
+ }
3479
+ }
3480
+ findings.push(...fileFindings);
3556
3481
  }
3557
3482
  return findings;
3558
3483
  }
@@ -4512,8 +4437,7 @@ function briefHash(brief) {
4512
4437
  function policyDigest(policy) {
4513
4438
  return createHash4("sha256").update(JSON.stringify({
4514
4439
  codeReviewThreshold: policy.codeReviewThreshold,
4515
- securityThreshold: policy.securityThreshold,
4516
- maxRounds: policy.maxRounds
4440
+ securityThreshold: policy.securityThreshold
4517
4441
  })).digest("hex");
4518
4442
  }
4519
4443
  function isBoundToHead(echoed, headSha) {
@@ -4826,7 +4750,46 @@ function parseEnforcementRegistry(content) {
4826
4750
  return result;
4827
4751
  }
4828
4752
  // ../../packages/aeg-core/src/registry-checks.ts
4829
- function checkG1(rows, existsFn) {
4753
+ var HOOK_DIR_PREFIXES = [".claude/hooks/", ".vinaya/hooks/", ".husky/", ".git/hooks/"];
4754
+ var BARE_HOOK_NAME = /^check-[A-Za-z0-9_.-]*\.sh$/;
4755
+ function basename(path) {
4756
+ return path.slice(path.lastIndexOf("/") + 1);
4757
+ }
4758
+ function lineOf(content, index) {
4759
+ let line = 1;
4760
+ for (let i = 0;i < index; i++)
4761
+ if (content.charCodeAt(i) === 10)
4762
+ line++;
4763
+ return line;
4764
+ }
4765
+ function findUnshippedHookRefs(docs, shipped) {
4766
+ const shippedNames = new Set([...shipped].map(basename));
4767
+ const findings = [];
4768
+ const flag = (doc, token, index) => {
4769
+ findings.push({
4770
+ path: doc.path,
4771
+ reason: `${doc.path}:${lineOf(doc.content, index)} names hook "${token}", which is neither tracked in git nor emitted by \`vinaya init\``
4772
+ });
4773
+ };
4774
+ for (const doc of docs) {
4775
+ for (const { cited, index } of extractCitedPaths(doc.content)) {
4776
+ if (cited.endsWith("/") || !HOOK_DIR_PREFIXES.some((p) => cited.startsWith(p)))
4777
+ continue;
4778
+ if (!shipped.has(cited))
4779
+ flag(doc, cited, index);
4780
+ }
4781
+ const spanPattern = /`([^`\n]+)`/g;
4782
+ let match = spanPattern.exec(doc.content);
4783
+ while (match !== null) {
4784
+ const token = match[1] ?? "";
4785
+ if (BARE_HOOK_NAME.test(token) && !shippedNames.has(token))
4786
+ flag(doc, token, match.index);
4787
+ match = spanPattern.exec(doc.content);
4788
+ }
4789
+ }
4790
+ return findings;
4791
+ }
4792
+ function checkG1(rows, existsFn, hookRefs) {
4830
4793
  const findings = [];
4831
4794
  for (const row of rows) {
4832
4795
  if (row.implementation === "")
@@ -4839,6 +4802,8 @@ function checkG1(rows, existsFn) {
4839
4802
  });
4840
4803
  }
4841
4804
  }
4805
+ if (hookRefs)
4806
+ findings.push(...findUnshippedHookRefs(hookRefs.docs, hookRefs.shipped));
4842
4807
  return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
4843
4808
  }
4844
4809
  var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
@@ -5392,7 +5357,6 @@ var TaskPrPauseSchema = z.object({
5392
5357
  var TaskPrReviewRecordSchema = z.object({
5393
5358
  verdicts: z.array(TaskPrVerdictSchema),
5394
5359
  roundMarkers: z.array(z.number().int().nonnegative()),
5395
- summaryTable: z.string().nullable(),
5396
5360
  pause: TaskPrPauseSchema.nullable()
5397
5361
  });
5398
5362
  var TaskPrReadInputSchema = z.object({
@@ -5439,16 +5403,6 @@ var TaskCancelResultSchema = z.object({
5439
5403
  authenticatedFrom: z.string().min(1),
5440
5404
  fencedEffectKeys: z.array(z.string())
5441
5405
  });
5442
- var TASK_TOOL_NAMES = [
5443
- "task_start",
5444
- "task_status",
5445
- "task_escalation_read",
5446
- "task_pr_read",
5447
- "task_resume",
5448
- "task_cancel"
5449
- ];
5450
- var OPERATOR_STATUS_FOLLOW = "task_status_follow";
5451
- var OPERATOR_TOOL_GRANT = [...TASK_TOOL_NAMES, OPERATOR_STATUS_FOLLOW];
5452
5406
  // ../../packages/aeg-core/src/first-push-dispatch-gate.ts
5453
5407
  function parseTaskBranch(branch) {
5454
5408
  const m = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
@@ -5679,15 +5633,69 @@ var NO_GATE_CUTOVERS = {
5679
5633
  briefRulesSincePr: null,
5680
5634
  agentBoxesRefusedSincePr: null
5681
5635
  };
5682
- // ../../packages/aeg-core/src/dev-review-loop/types.ts
5683
- var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5684
- // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
5685
- var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
5686
- // ../../packages/aeg-core/src/log/envelope.ts
5687
- import { createHash as createHash5 } from "node:crypto";
5688
-
5689
5636
  // ../../packages/aeg-core/src/log/schema.ts
5637
+ import { z as z3 } from "zod";
5638
+
5639
+ // ../../packages/aeg-core/src/log/custom.ts
5690
5640
  import { z as z2 } from "zod";
5641
+ var CUSTOM_EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]*\.[a-z][a-z0-9_.]*$/;
5642
+ var CUSTOM_EVENT_NAME_MAX_LENGTH = 64;
5643
+ var CUSTOM_EVENT_RESERVED_NAMESPACE = "vinaya";
5644
+ var CUSTOM_EVENT_MAX_FIELDS = 20;
5645
+ var CUSTOM_FIELD_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
5646
+ var CUSTOM_FIELD_NAME_MAX_LENGTH = 64;
5647
+ var CUSTOM_TEXT_MAX_LENGTH = 500;
5648
+ var CUSTOM_WORD_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
5649
+ var CUSTOM_WORD_MAX_LENGTH = 64;
5650
+ var CUSTOM_FIELD_MAX_WORDS = 50;
5651
+ var CustomFieldTypeSchema = z2.union([z2.enum(["text", "number", "boolean"]), z2.array(z2.string())]);
5652
+ var CustomEventDeclarationsSchema = z2.record(z2.string(), z2.object({
5653
+ fields: z2.record(z2.string(), CustomFieldTypeSchema)
5654
+ }).strict()).superRefine((events, ctx) => {
5655
+ for (const [name, declaration] of Object.entries(events)) {
5656
+ const refuse = (message, path = []) => {
5657
+ ctx.addIssue({
5658
+ code: z2.ZodIssueCode.custom,
5659
+ path: [name, ...path],
5660
+ message: `logs.events "${name}": ${message}`
5661
+ });
5662
+ };
5663
+ if (name.length > CUSTOM_EVENT_NAME_MAX_LENGTH) {
5664
+ refuse(`the name must be at most ${CUSTOM_EVENT_NAME_MAX_LENGTH} characters`);
5665
+ }
5666
+ if (!CUSTOM_EVENT_NAME_PATTERN.test(name)) {
5667
+ refuse("the name must be `<namespace>.<event>` — lowercase letters, digits and `_`, a dot between them");
5668
+ } else if (name.split(".")[0] === CUSTOM_EVENT_RESERVED_NAMESPACE) {
5669
+ refuse(`the \`${CUSTOM_EVENT_RESERVED_NAMESPACE}.\` namespace is reserved for Vinaya's own events`);
5670
+ }
5671
+ const fieldEntries = Object.entries(declaration.fields);
5672
+ if (fieldEntries.length > CUSTOM_EVENT_MAX_FIELDS) {
5673
+ refuse(`at most ${CUSTOM_EVENT_MAX_FIELDS} fields may be declared (found ${fieldEntries.length})`, ["fields"]);
5674
+ }
5675
+ for (const [field, type] of fieldEntries) {
5676
+ if (field.length > CUSTOM_FIELD_NAME_MAX_LENGTH || !CUSTOM_FIELD_NAME_PATTERN.test(field)) {
5677
+ 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]);
5678
+ }
5679
+ if (typeof type === "string")
5680
+ continue;
5681
+ if (type.length === 0) {
5682
+ refuse(`field "${field}": a list of words must name at least one word`, ["fields", field]);
5683
+ }
5684
+ if (type.length > CUSTOM_FIELD_MAX_WORDS) {
5685
+ refuse(`field "${field}": a list of words may name at most ${CUSTOM_FIELD_MAX_WORDS}`, ["fields", field]);
5686
+ }
5687
+ const bad = type.filter((w) => w.length > CUSTOM_WORD_MAX_LENGTH || !CUSTOM_WORD_PATTERN.test(w));
5688
+ if (bad.length > 0) {
5689
+ refuse(`field "${field}": a listed word is lowercase letters, digits, \`_\` and \`-\`, at most ${CUSTOM_WORD_MAX_LENGTH} characters`, ["fields", field]);
5690
+ }
5691
+ if (new Set(type).size !== type.length) {
5692
+ refuse(`field "${field}": a list of words names a word twice`, ["fields", field]);
5693
+ }
5694
+ }
5695
+ }
5696
+ });
5697
+
5698
+ // ../../packages/aeg-core/src/log/schema.ts
5691
5699
  var CONFIDENCE_REASON_MAX_LENGTH = 280;
5692
5700
  var ROLE_VALUES = [
5693
5701
  "planner",
@@ -5698,178 +5706,210 @@ var ROLE_VALUES = [
5698
5706
  "archivist",
5699
5707
  "architect"
5700
5708
  ];
5701
- var RoleSchema = z2.enum(ROLE_VALUES);
5709
+ var RoleSchema = z3.enum(ROLE_VALUES);
5702
5710
  var HOST_VALUES = ["hook", "ci", "cli", "loop"];
5703
- var HostSchema = z2.enum(HOST_VALUES);
5711
+ var HostSchema = z3.enum(HOST_VALUES);
5704
5712
  var RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
5705
5713
  var headerMetaCore = {
5706
- ts: z2.string(),
5707
- run_id: z2.string().regex(RUN_ID_PATTERN),
5708
- seq: z2.number().int().nonnegative(),
5709
- repo: z2.string().nullable(),
5710
- vinaya: z2.string(),
5711
- doctrine: z2.string(),
5714
+ ts: z3.string(),
5715
+ run_id: z3.string().regex(RUN_ID_PATTERN),
5716
+ seq: z3.number().int().nonnegative(),
5717
+ repo: z3.string().nullable(),
5718
+ vinaya: z3.string(),
5719
+ doctrine: z3.string(),
5712
5720
  host: HostSchema,
5713
- machine: z2.string()
5721
+ machine: z3.string()
5714
5722
  };
5715
- var HeaderMetaV1Schema = z2.object({
5716
- schema: z2.literal(1),
5723
+ var HeaderMetaV1Schema = z3.object({
5724
+ schema: z3.literal(1),
5717
5725
  ...headerMetaCore
5718
5726
  }).strict();
5719
- var LineageSchema = z2.object({
5720
- run: z2.string().nullable(),
5721
- attempt: z2.number().int().nullable(),
5722
- parent: z2.string().nullable()
5727
+ var LineageSchema = z3.object({
5728
+ run: z3.string().nullable(),
5729
+ attempt: z3.number().int().nullable(),
5730
+ parent: z3.string().nullable()
5723
5731
  }).strict();
5724
- var InputVersionsSchema = z2.object({
5725
- objectives_version: z2.string().nullable(),
5726
- brief_hash: z2.string().nullable(),
5727
- ruling_ordinal: z2.number().int().nullable(),
5728
- policy_digest: z2.string().nullable()
5732
+ var InputVersionsSchema = z3.object({
5733
+ objectives_version: z3.string().nullable(),
5734
+ brief_hash: z3.string().nullable(),
5735
+ ruling_ordinal: z3.number().int().nullable(),
5736
+ policy_digest: z3.string().nullable()
5729
5737
  }).strict();
5730
- var ProvenanceSchema = z2.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
5731
- var HeaderMetaV2Schema = z2.object({
5732
- schema: z2.literal(2),
5738
+ var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
5739
+ var HeaderMetaV2Schema = z3.object({
5740
+ schema: z3.literal(2),
5733
5741
  ...headerMetaCore,
5734
- event_id: z2.string().min(1),
5735
- process_id: z2.string().min(1),
5736
- actor_id: z2.string().nullable(),
5742
+ event_id: z3.string().min(1),
5743
+ process_id: z3.string().min(1),
5744
+ actor_id: z3.string().nullable(),
5737
5745
  lineage: LineageSchema,
5738
5746
  input_versions: InputVersionsSchema,
5739
5747
  provenance: ProvenanceSchema
5740
5748
  }).strict();
5741
- var HeaderMetaSchema = z2.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema]);
5742
- var SubjectSchema = z2.object({
5743
- issue: z2.number().int().nullable(),
5744
- pr: z2.number().int().optional(),
5745
- sha: z2.string().optional(),
5746
- role: z2.union([RoleSchema, z2.literal("unattributed")]),
5747
- round: z2.number().int().optional(),
5748
- objectives_version: z2.string().optional()
5749
+ var WorkSchema = z3.object({
5750
+ ref: z3.string().nullable(),
5751
+ repo: z3.string().nullable(),
5752
+ change: z3.string().nullable(),
5753
+ revision: z3.string().nullable()
5754
+ }).strict();
5755
+ var FlowSchema = z3.object({
5756
+ id: z3.string().nullable(),
5757
+ version: z3.string().nullable()
5749
5758
  }).strict();
5750
- var HeaderSchema = z2.object({
5759
+ var HeaderMetaV3Schema = z3.object({
5760
+ schema: z3.literal(3),
5761
+ ...headerMetaCore,
5762
+ event_id: z3.string().min(1),
5763
+ process_id: z3.string().min(1),
5764
+ actor_id: z3.string().nullable(),
5765
+ lineage: LineageSchema,
5766
+ input_versions: InputVersionsSchema,
5767
+ provenance: ProvenanceSchema,
5768
+ work: WorkSchema,
5769
+ flow: FlowSchema,
5770
+ runtime: z3.string().nullable(),
5771
+ source: z3.string().nullable()
5772
+ }).strict();
5773
+ var HeaderMetaSchema = z3.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema, HeaderMetaV3Schema]);
5774
+ var SubjectSchema = z3.object({
5775
+ issue: z3.number().int().nullable(),
5776
+ pr: z3.number().int().optional(),
5777
+ sha: z3.string().optional(),
5778
+ role: z3.union([RoleSchema, z3.literal("unattributed")]),
5779
+ round: z3.number().int().optional(),
5780
+ objectives_version: z3.string().optional()
5781
+ }).strict();
5782
+ var HeaderSchema = z3.object({
5751
5783
  meta: HeaderMetaSchema,
5752
5784
  subject: SubjectSchema
5753
5785
  }).strict();
5754
5786
  var envelopeTail = {
5755
- duration_ms: z2.number().nonnegative().optional(),
5756
- payload: z2.object({}).strict()
5787
+ duration_ms: z3.number().nonnegative().optional(),
5788
+ payload: z3.object({}).strict()
5757
5789
  };
5758
- var ReviewFindingSchema = z2.object({
5759
- id: z2.string(),
5760
- severity: z2.string(),
5761
- state: z2.string().optional(),
5762
- severity_scale: z2.string().optional(),
5763
- policy_treatment: z2.enum(["blocking", "non_blocking", "unavailable"]).optional(),
5764
- confidence: z2.number().min(0).max(1).optional(),
5765
- confidence_scale: z2.string().optional(),
5766
- confidence_source: z2.string().optional()
5790
+ var ReviewFindingSchema = z3.object({
5791
+ id: z3.string(),
5792
+ severity: z3.string(),
5793
+ state: z3.string().optional(),
5794
+ severity_scale: z3.string().optional(),
5795
+ policy_treatment: z3.enum(["blocking", "non_blocking", "unavailable"]).optional(),
5796
+ confidence: z3.number().min(0).max(1).optional(),
5797
+ confidence_scale: z3.string().optional(),
5798
+ confidence_source: z3.string().optional()
5767
5799
  }).strict();
5768
- var DispatchOutcomeSchema = z2.discriminatedUnion("type", [
5769
- z2.object({ type: z2.literal("pr_opened"), pr: z2.number().int(), head: z2.string() }).strict(),
5770
- z2.object({
5771
- type: z2.literal("round_pushed"),
5772
- pr: z2.number().int(),
5773
- head: z2.string(),
5774
- comment_id: z2.number().int()
5800
+ var DispatchOutcomeSchema = z3.discriminatedUnion("type", [
5801
+ z3.object({ type: z3.literal("pr_opened"), pr: z3.number().int(), head: z3.string() }).strict(),
5802
+ z3.object({
5803
+ type: z3.literal("round_pushed"),
5804
+ pr: z3.number().int(),
5805
+ head: z3.string(),
5806
+ comment_id: z3.number().int()
5775
5807
  }).strict(),
5776
- z2.object({
5777
- type: z2.literal("verdict"),
5778
- verdict: z2.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
5779
- head: z2.string(),
5780
- comment_id: z2.number().int(),
5781
- objectives: z2.array(z2.object({ id: z2.string(), met: z2.boolean() }).strict()),
5782
- findings: z2.array(ReviewFindingSchema)
5808
+ z3.object({
5809
+ type: z3.literal("verdict"),
5810
+ verdict: z3.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
5811
+ head: z3.string(),
5812
+ comment_id: z3.number().int(),
5813
+ objectives: z3.array(z3.object({ id: z3.string(), met: z3.boolean() }).strict()),
5814
+ findings: z3.array(ReviewFindingSchema)
5783
5815
  }).strict(),
5784
- z2.object({
5785
- type: z2.literal("escalation"),
5786
- class: z2.enum(["authority", "strategy", "product"]),
5787
- comment_id: z2.number().int()
5816
+ z3.object({
5817
+ type: z3.literal("escalation"),
5818
+ class: z3.enum(["authority", "strategy", "product"]),
5819
+ comment_id: z3.number().int()
5788
5820
  }).strict(),
5789
- z2.object({ type: z2.literal("brief"), comment_id: z2.number().int(), hash: z2.string() }).strict(),
5790
- z2.object({ type: z2.literal("plan"), issues: z2.array(z2.number().int()) }).strict(),
5791
- z2.object({ type: z2.literal("archive"), provenance_comment_id: z2.number().int() }).strict(),
5792
- z2.object({ type: z2.literal("completed") }).strict()
5821
+ z3.object({ type: z3.literal("brief"), comment_id: z3.number().int(), hash: z3.string() }).strict(),
5822
+ z3.object({ type: z3.literal("plan"), issues: z3.array(z3.number().int()) }).strict(),
5823
+ z3.object({ type: z3.literal("archive"), provenance_comment_id: z3.number().int() }).strict(),
5824
+ z3.object({ type: z3.literal("completed") }).strict()
5793
5825
  ]);
5794
5826
  var dispatchShared = {
5795
5827
  meta: HeaderMetaSchema,
5796
5828
  subject: SubjectSchema,
5797
- kind: z2.literal("dispatch"),
5829
+ kind: z3.literal("dispatch"),
5798
5830
  ...envelopeTail,
5799
5831
  target_role: RoleSchema,
5800
- model: z2.string(),
5801
- round: z2.number().int().optional(),
5802
- effect_id: z2.string()
5832
+ model: z3.string(),
5833
+ round: z3.number().int().optional(),
5834
+ effect_id: z3.string()
5803
5835
  };
5804
- var dispatchUsageField = z2.object({ input: z2.number().nonnegative(), output: z2.number().nonnegative() }).strict().nullable();
5805
- var DispatchEventSchema = z2.discriminatedUnion("event", [
5806
- z2.object({ ...dispatchShared, event: z2.literal("dispatched"), prompt_hash: z2.string() }).strict(),
5807
- z2.object({
5836
+ var dispatchUsageField = z3.object({ input: z3.number().nonnegative(), output: z3.number().nonnegative() }).strict().nullable();
5837
+ var DispatchEventSchema = z3.discriminatedUnion("event", [
5838
+ z3.object({ ...dispatchShared, event: z3.literal("dispatched"), prompt_hash: z3.string() }).strict(),
5839
+ z3.object({
5808
5840
  ...dispatchShared,
5809
- event: z2.literal("outcome_received"),
5841
+ event: z3.literal("outcome_received"),
5810
5842
  outcome: DispatchOutcomeSchema,
5811
5843
  usage: dispatchUsageField
5812
5844
  }).strict(),
5813
- z2.object({
5845
+ z3.object({
5814
5846
  ...dispatchShared,
5815
- event: z2.literal("dispatch_failed"),
5816
- reason: z2.enum(["timeout", "crash", "refused", "unattributed_write"]),
5847
+ event: z3.literal("dispatch_failed"),
5848
+ reason: z3.enum(["timeout", "crash", "refused", "unattributed_write"]),
5817
5849
  usage: dispatchUsageField
5818
5850
  }).strict()
5819
5851
  ]);
5852
+ var CODE_TOKEN_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
5853
+ var CodeTokenSchema = z3.string().regex(CODE_TOKEN_PATTERN);
5854
+ var ReviewerVerdictSchema = z3.object({
5855
+ role: RoleSchema,
5856
+ outcome: z3.enum(["approve", "changes_requested", "not_reviewed"]),
5857
+ blockers: z3.number().int().nonnegative()
5858
+ }).strict();
5820
5859
  var loopShared = {
5821
5860
  meta: HeaderMetaSchema,
5822
5861
  subject: SubjectSchema,
5823
- kind: z2.literal("dev_review_loop"),
5862
+ kind: z3.literal("dev_review_loop"),
5824
5863
  ...envelopeTail,
5825
- loop_id: z2.string()
5864
+ loop_id: z3.string()
5826
5865
  };
5827
- var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
5828
- z2.object({
5866
+ var DevReviewLoopEventSchema = z3.discriminatedUnion("event", [
5867
+ z3.object({
5829
5868
  ...loopShared,
5830
- event: z2.literal("loop_started"),
5831
- task: z2.number().int(),
5832
- policy: z2.object({
5833
- max_rounds: z2.number().int().nonnegative(),
5834
- reviewers: z2.array(RoleSchema),
5835
- models: z2.record(RoleSchema, z2.string())
5869
+ event: z3.literal("loop_started"),
5870
+ task: z3.number().int(),
5871
+ policy: z3.object({
5872
+ max_rounds: z3.number().int().nonnegative(),
5873
+ reviewers: z3.array(RoleSchema),
5874
+ models: z3.record(RoleSchema, z3.string())
5836
5875
  }).strict()
5837
5876
  }).strict(),
5838
- z2.object({ ...loopShared, event: z2.literal("round_started"), round: z2.number().int(), base_head: z2.string() }).strict(),
5839
- z2.object({
5877
+ z3.object({ ...loopShared, event: z3.literal("round_started"), round: z3.number().int(), base_head: z3.string() }).strict(),
5878
+ z3.object({
5840
5879
  ...loopShared,
5841
- event: z2.literal("gate_result_read"),
5842
- round: z2.number().int(),
5843
- head: z2.string(),
5844
- green: z2.boolean(),
5845
- confidence_value: z2.number().int().min(0).max(100).optional(),
5846
- confidence_reason: z2.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
5847
- confidence_unavailable: z2.boolean().optional(),
5848
- extra_turn_spent: z2.boolean().optional()
5880
+ event: z3.literal("gate_result_read"),
5881
+ round: z3.number().int(),
5882
+ head: z3.string(),
5883
+ green: z3.boolean(),
5884
+ confidence_value: z3.number().int().min(0).max(100).optional(),
5885
+ confidence_reason: z3.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
5886
+ confidence_unavailable: z3.boolean().optional(),
5887
+ extra_turn_spent: z3.boolean().optional()
5849
5888
  }).strict(),
5850
- z2.object({
5889
+ z3.object({
5851
5890
  ...loopShared,
5852
- event: z2.literal("verdicts_read"),
5853
- round: z2.number().int(),
5854
- head: z2.string(),
5855
- all_approve: z2.boolean(),
5856
- blockers: z2.number().int().nonnegative(),
5857
- findings: z2.array(ReviewFindingSchema).optional()
5891
+ event: z3.literal("verdicts_read"),
5892
+ round: z3.number().int(),
5893
+ head: z3.string(),
5894
+ all_approve: z3.boolean(),
5895
+ blockers: z3.number().int().nonnegative(),
5896
+ findings: z3.array(ReviewFindingSchema).optional(),
5897
+ reviewers: z3.array(ReviewerVerdictSchema).optional()
5858
5898
  }).strict(),
5859
- z2.object({
5899
+ z3.object({
5860
5900
  ...loopShared,
5861
- event: z2.literal("findings_compared"),
5862
- round: z2.number().int(),
5863
- open: z2.array(z2.string()),
5864
- resolved: z2.array(z2.string()),
5865
- new: z2.array(z2.string()),
5866
- recurring: z2.array(z2.string())
5901
+ event: z3.literal("findings_compared"),
5902
+ round: z3.number().int(),
5903
+ open: z3.array(z3.string()),
5904
+ resolved: z3.array(z3.string()),
5905
+ new: z3.array(z3.string()),
5906
+ recurring: z3.array(z3.string())
5867
5907
  }).strict(),
5868
- z2.object({
5908
+ z3.object({
5869
5909
  ...loopShared,
5870
- event: z2.literal("stop_condition_met"),
5871
- round: z2.number().int(),
5872
- condition: z2.enum([
5910
+ event: z3.literal("stop_condition_met"),
5911
+ round: z3.number().int(),
5912
+ condition: z3.enum([
5873
5913
  "green",
5874
5914
  "max_rounds",
5875
5915
  "no_progress",
@@ -5878,66 +5918,85 @@ var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
5878
5918
  "confidence",
5879
5919
  "reappearance",
5880
5920
  "repeat_finding",
5881
- "repeat_failure"
5921
+ "repeat_failure",
5922
+ "time_budget"
5882
5923
  ])
5883
5924
  }).strict(),
5884
- z2.object({
5925
+ z3.object({
5926
+ ...loopShared,
5927
+ event: z3.literal("paused"),
5928
+ round: z3.number().int(),
5929
+ reason: z3.enum(["escalation", "principal_item", "refreeze_needed"]),
5930
+ reason_code: CodeTokenSchema.optional()
5931
+ }).strict(),
5932
+ z3.object({
5885
5933
  ...loopShared,
5886
- event: z2.literal("paused"),
5887
- round: z2.number().int(),
5888
- reason: z2.enum(["escalation", "principal_item", "refreeze_needed"])
5934
+ event: z3.literal("resumed"),
5935
+ round: z3.number().int(),
5936
+ by: z3.enum(["principal", "driver"])
5889
5937
  }).strict(),
5890
- z2.object({
5938
+ z3.object({
5891
5939
  ...loopShared,
5892
- event: z2.literal("resumed"),
5893
- round: z2.number().int(),
5894
- by: z2.enum(["principal", "driver"])
5940
+ event: z3.literal("cancelled"),
5941
+ round: z3.number().int(),
5942
+ by: z3.literal("principal")
5895
5943
  }).strict(),
5896
- z2.object({
5944
+ z3.object({
5897
5945
  ...loopShared,
5898
- event: z2.literal("cancelled"),
5899
- round: z2.number().int(),
5900
- by: z2.literal("principal")
5946
+ event: z3.literal("unpushed_work_resume"),
5947
+ round: z3.number().int(),
5948
+ branch: z3.string(),
5949
+ detail: z3.string()
5901
5950
  }).strict(),
5902
- z2.object({
5951
+ z3.object({
5903
5952
  ...loopShared,
5904
- event: z2.literal("unpushed_work_resume"),
5905
- round: z2.number().int(),
5906
- branch: z2.string(),
5907
- detail: z2.string()
5953
+ event: z3.literal("round_ended"),
5954
+ round: z3.number().int(),
5955
+ base_head: z3.string(),
5956
+ head: z3.string(),
5957
+ files_changed: z3.number().int().nonnegative(),
5958
+ insertions: z3.number().int().nonnegative(),
5959
+ deletions: z3.number().int().nonnegative(),
5960
+ wall_ms: z3.number().nonnegative(),
5961
+ outcome: z3.enum(["green", "changes_requested", "escalated"])
5908
5962
  }).strict(),
5909
- z2.object({
5963
+ z3.object({
5910
5964
  ...loopShared,
5911
- event: z2.literal("round_ended"),
5912
- round: z2.number().int(),
5913
- base_head: z2.string(),
5914
- head: z2.string(),
5915
- files_changed: z2.number().int().nonnegative(),
5916
- insertions: z2.number().int().nonnegative(),
5917
- deletions: z2.number().int().nonnegative(),
5918
- wall_ms: z2.number().nonnegative(),
5919
- outcome: z2.enum(["green", "changes_requested", "escalated"])
5965
+ event: z3.literal("journal_finalized"),
5966
+ rounds: z3.number().int().nonnegative(),
5967
+ total_wall_ms: z3.number().nonnegative(),
5968
+ time_to_green_ms: z3.number().nonnegative().nullable(),
5969
+ files_changed_total: z3.number().int().nonnegative(),
5970
+ final_head: z3.string(),
5971
+ result: z3.enum(["merged_ready", "stopped"])
5920
5972
  }).strict(),
5921
- z2.object({
5973
+ z3.object({
5922
5974
  ...loopShared,
5923
- event: z2.literal("journal_finalized"),
5924
- rounds: z2.number().int().nonnegative(),
5925
- total_wall_ms: z2.number().nonnegative(),
5926
- time_to_green_ms: z2.number().nonnegative().nullable(),
5927
- files_changed_total: z2.number().int().nonnegative(),
5928
- final_head: z2.string(),
5929
- result: z2.enum(["merged_ready", "stopped"])
5975
+ event: z3.literal("infrastructure_retry"),
5976
+ round: z3.number().int(),
5977
+ failure_kind: z3.enum(["pause_comment_post", "developer_connection"]),
5978
+ attempts: z3.number().int().positive(),
5979
+ outcome: z3.enum(["recovered", "exhausted"])
5930
5980
  }).strict(),
5931
- z2.object({
5981
+ z3.object({
5932
5982
  ...loopShared,
5933
- event: z2.literal("infrastructure_retry"),
5934
- round: z2.number().int(),
5935
- failure_kind: z2.enum(["pause_comment_post", "developer_connection"]),
5936
- attempts: z2.number().int().positive(),
5937
- outcome: z2.enum(["recovered", "exhausted"])
5983
+ event: z3.literal("driver_heartbeat"),
5984
+ task: z3.number().int(),
5985
+ pr: z3.number().int().positive().optional(),
5986
+ round: z3.number().int(),
5987
+ phase: z3.string()
5988
+ }).strict(),
5989
+ z3.object({
5990
+ ...loopShared,
5991
+ event: z3.literal("driver_exited"),
5992
+ task: z3.number().int(),
5993
+ reason: z3.enum(["finished", "paused", "reexec", "error", "signal"]),
5994
+ last_decision: z3.string(),
5995
+ exit_code: z3.number().int().optional(),
5996
+ error_class: CodeTokenSchema.optional()
5938
5997
  }).strict()
5939
5998
  ]);
5940
- var ForgeOpSchema = z2.enum([
5999
+ var ForgeOpSchema = z3.enum([
5941
6000
  "pr.create",
5942
6001
  "pr.comment",
5943
6002
  "pr.body.replace",
@@ -5951,24 +6010,24 @@ var ForgeOpSchema = z2.enum([
5951
6010
  "label.add",
5952
6011
  "label.remove"
5953
6012
  ]);
5954
- var ForgeWriteTargetSchema = z2.object({
5955
- issue: z2.number().int().optional(),
5956
- pr: z2.number().int().optional()
6013
+ var ForgeWriteTargetSchema = z3.object({
6014
+ issue: z3.number().int().optional(),
6015
+ pr: z3.number().int().optional()
5957
6016
  }).strict();
5958
6017
  var forgeWriteShared = {
5959
6018
  meta: HeaderMetaSchema,
5960
6019
  subject: SubjectSchema,
5961
- kind: z2.literal("forge_write"),
6020
+ kind: z3.literal("forge_write"),
5962
6021
  ...envelopeTail,
5963
6022
  op: ForgeOpSchema,
5964
6023
  target: ForgeWriteTargetSchema
5965
6024
  };
5966
- var ForgeWriteEventSchema = z2.discriminatedUnion("event", [
5967
- z2.object({ ...forgeWriteShared, event: z2.literal("validated") }).strict(),
5968
- z2.object({ ...forgeWriteShared, event: z2.literal("refused"), reason: z2.string() }).strict(),
5969
- z2.object({ ...forgeWriteShared, event: z2.literal("written"), comment_ids: z2.array(z2.string()) }).strict()
6025
+ var ForgeWriteEventSchema = z3.discriminatedUnion("event", [
6026
+ z3.object({ ...forgeWriteShared, event: z3.literal("validated") }).strict(),
6027
+ z3.object({ ...forgeWriteShared, event: z3.literal("refused"), reason: z3.string() }).strict(),
6028
+ z3.object({ ...forgeWriteShared, event: z3.literal("written"), comment_ids: z3.array(z3.string()) }).strict()
5970
6029
  ]);
5971
- var GateOutcomeSchema = z2.enum([
6030
+ var GateOutcomeSchema = z3.enum([
5972
6031
  "pass",
5973
6032
  "fail",
5974
6033
  "wait",
@@ -5981,61 +6040,74 @@ var GateOutcomeSchema = z2.enum([
5981
6040
  var gateShared = {
5982
6041
  meta: HeaderMetaSchema,
5983
6042
  subject: SubjectSchema,
5984
- kind: z2.literal("gate"),
6043
+ kind: z3.literal("gate"),
5985
6044
  ...envelopeTail,
5986
- check: z2.string(),
5987
- check_version: z2.string().nullable(),
5988
- policy_version: z2.string().nullable(),
5989
- input_fingerprint: z2.string().nullable()
6045
+ check: z3.string(),
6046
+ check_version: z3.string().nullable(),
6047
+ policy_version: z3.string().nullable(),
6048
+ input_fingerprint: z3.string().nullable()
5990
6049
  };
5991
- var GateEventSchema = z2.discriminatedUnion("event", [
5992
- z2.object({
6050
+ var GateEventSchema = z3.discriminatedUnion("event", [
6051
+ z3.object({
5993
6052
  ...gateShared,
5994
- event: z2.literal("checked"),
6053
+ event: z3.literal("checked"),
5995
6054
  outcome: GateOutcomeSchema,
5996
- reason: z2.string().optional()
6055
+ reason: z3.string().optional()
6056
+ }).strict(),
6057
+ z3.object({
6058
+ meta: HeaderMetaSchema,
6059
+ subject: SubjectSchema,
6060
+ kind: z3.literal("gate"),
6061
+ ...envelopeTail,
6062
+ event: z3.literal("summary"),
6063
+ ran: z3.number().int().nonnegative(),
6064
+ passed: z3.number().int().nonnegative(),
6065
+ failed: z3.number().int().nonnegative(),
6066
+ skipped: z3.number().int().nonnegative(),
6067
+ failed_checks: z3.array(z3.string())
5997
6068
  }).strict()
5998
6069
  ]);
5999
- var OperationResultSchema = z2.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
6070
+ var OperationResultSchema = z3.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
6000
6071
  var operationShared = {
6001
6072
  meta: HeaderMetaSchema,
6002
6073
  subject: SubjectSchema,
6003
- kind: z2.literal("operation"),
6074
+ kind: z3.literal("operation"),
6004
6075
  ...envelopeTail,
6005
- operation: z2.string(),
6006
- target: z2.string().nullable()
6076
+ operation: z3.string(),
6077
+ target: z3.string().nullable()
6007
6078
  };
6008
- var OperationEventSchema = z2.discriminatedUnion("event", [
6009
- z2.object({
6079
+ var OperationEventSchema = z3.discriminatedUnion("event", [
6080
+ z3.object({
6010
6081
  ...operationShared,
6011
- event: z2.literal("completed"),
6082
+ event: z3.literal("completed"),
6012
6083
  result: OperationResultSchema,
6013
- error_class: z2.string().nullable()
6084
+ error_class: z3.string().nullable(),
6085
+ field_names: z3.array(z3.string().max(CUSTOM_FIELD_NAME_MAX_LENGTH)).max(CUSTOM_EVENT_MAX_FIELDS).optional()
6014
6086
  }).strict()
6015
6087
  ]);
6016
- var UsageUnitsSchema = z2.object({
6017
- input: z2.number().nonnegative().nullable(),
6018
- output: z2.number().nonnegative().nullable(),
6019
- cache: z2.number().nonnegative().nullable()
6088
+ var UsageUnitsSchema = z3.object({
6089
+ input: z3.number().nonnegative().nullable(),
6090
+ output: z3.number().nonnegative().nullable(),
6091
+ cache: z3.number().nonnegative().nullable()
6020
6092
  }).strict();
6021
6093
  var usageShared = {
6022
6094
  meta: HeaderMetaSchema,
6023
6095
  subject: SubjectSchema,
6024
- kind: z2.literal("usage"),
6096
+ kind: z3.literal("usage"),
6025
6097
  ...envelopeTail,
6026
- model: z2.string().nullable(),
6027
- source: z2.string(),
6028
- semantics: z2.enum(["cumulative", "delta"])
6098
+ model: z3.string().nullable(),
6099
+ source: z3.string(),
6100
+ semantics: z3.enum(["cumulative", "delta"])
6029
6101
  };
6030
- var UsageEventSchema = z2.discriminatedUnion("event", [
6031
- z2.object({
6102
+ var UsageEventSchema = z3.discriminatedUnion("event", [
6103
+ z3.object({
6032
6104
  ...usageShared,
6033
- event: z2.literal("observed"),
6105
+ event: z3.literal("observed"),
6034
6106
  units: UsageUnitsSchema,
6035
- unknown_reason: z2.string().nullable()
6107
+ unknown_reason: z3.string().nullable()
6036
6108
  }).strict()
6037
6109
  ]);
6038
- var RoleAttemptOutcomeSchema = z2.enum([
6110
+ var RoleAttemptOutcomeSchema = z3.enum([
6039
6111
  "completed",
6040
6112
  "incomplete",
6041
6113
  "infrastructure_failed",
@@ -6046,17 +6118,17 @@ var RoleAttemptOutcomeSchema = z2.enum([
6046
6118
  var roleAttemptShared = {
6047
6119
  meta: HeaderMetaSchema,
6048
6120
  subject: SubjectSchema,
6049
- kind: z2.literal("role_attempt"),
6121
+ kind: z3.literal("role_attempt"),
6050
6122
  ...envelopeTail,
6051
- actor: z2.string().nullable(),
6052
- attempt: z2.number().int().nullable(),
6053
- effect_id: z2.string(),
6054
- model: z2.string().nullable()
6123
+ actor: z3.string().nullable(),
6124
+ attempt: z3.number().int().nullable(),
6125
+ effect_id: z3.string(),
6126
+ model: z3.string().nullable()
6055
6127
  };
6056
- var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
6057
- z2.object({
6128
+ var RoleAttemptEventSchema = z3.discriminatedUnion("event", [
6129
+ z3.object({
6058
6130
  ...roleAttemptShared,
6059
- event: z2.literal("attempted"),
6131
+ event: z3.literal("attempted"),
6060
6132
  outcome: RoleAttemptOutcomeSchema,
6061
6133
  usage: dispatchUsageField
6062
6134
  }).strict()
@@ -6064,42 +6136,59 @@ var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
6064
6136
  var handoffShared = {
6065
6137
  meta: HeaderMetaSchema,
6066
6138
  subject: SubjectSchema,
6067
- kind: z2.literal("handoff"),
6139
+ kind: z3.literal("handoff"),
6068
6140
  ...envelopeTail,
6069
- class: z2.enum(["authority", "strategy", "product"]),
6070
- reason: z2.string()
6141
+ class: z3.enum(["authority", "strategy", "product"]),
6142
+ reason: z3.string()
6071
6143
  };
6072
- var HandoffEventSchema = z2.discriminatedUnion("event", [
6073
- z2.object({
6144
+ var HandoffEventSchema = z3.discriminatedUnion("event", [
6145
+ z3.object({
6074
6146
  ...handoffShared,
6075
- event: z2.literal("raised"),
6076
- requested_decision: z2.string().nullable()
6147
+ event: z3.literal("raised"),
6148
+ requested_decision: z3.string().nullable()
6077
6149
  }).strict(),
6078
- z2.object({
6150
+ z3.object({
6079
6151
  ...handoffShared,
6080
- event: z2.literal("resolved"),
6081
- resolution: z2.string().nullable(),
6082
- resolved_by: z2.string().nullable()
6152
+ event: z3.literal("resolved"),
6153
+ resolution: z3.string().nullable(),
6154
+ resolved_by: z3.string().nullable()
6083
6155
  }).strict()
6084
6156
  ]);
6085
- var EffectTargetSchema = z2.object({
6086
- kind: z2.string(),
6087
- ref: z2.string()
6157
+ var EffectTargetSchema = z3.object({
6158
+ kind: z3.string(),
6159
+ ref: z3.string()
6088
6160
  }).strict();
6089
6161
  var effectShared = {
6090
6162
  meta: HeaderMetaSchema,
6091
6163
  subject: SubjectSchema,
6092
- kind: z2.literal("effect"),
6164
+ kind: z3.literal("effect"),
6093
6165
  ...envelopeTail,
6094
- effect_id: z2.string(),
6166
+ effect_id: z3.string(),
6095
6167
  target: EffectTargetSchema
6096
6168
  };
6097
- var EffectEventSchema = z2.discriminatedUnion("event", [
6098
- z2.object({ ...effectShared, event: z2.literal("attempted") }).strict(),
6099
- z2.object({ ...effectShared, event: z2.literal("observed"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict(),
6100
- z2.object({ ...effectShared, event: z2.literal("verified"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict()
6169
+ var EffectEventSchema = z3.discriminatedUnion("event", [
6170
+ z3.object({ ...effectShared, event: z3.literal("attempted") }).strict(),
6171
+ z3.object({ ...effectShared, event: z3.literal("observed"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict(),
6172
+ z3.object({ ...effectShared, event: z3.literal("verified"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict()
6101
6173
  ]);
6102
- var LogEventSchema = z2.union([
6174
+ var CustomFieldValueSchema = z3.union([z3.string().max(CUSTOM_TEXT_MAX_LENGTH), z3.number().finite(), z3.boolean()]);
6175
+ var customShared = {
6176
+ meta: HeaderMetaV3Schema,
6177
+ subject: SubjectSchema,
6178
+ kind: z3.literal("custom"),
6179
+ ...envelopeTail
6180
+ };
6181
+ var CustomEventSchema = z3.discriminatedUnion("event", [
6182
+ z3.object({
6183
+ ...customShared,
6184
+ event: z3.literal("recorded"),
6185
+ name: z3.string().max(CUSTOM_EVENT_NAME_MAX_LENGTH).regex(CUSTOM_EVENT_NAME_PATTERN),
6186
+ 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, {
6187
+ message: `custom: at most ${CUSTOM_EVENT_MAX_FIELDS} fields`
6188
+ })
6189
+ }).strict()
6190
+ ]);
6191
+ var LogEventSchema = z3.union([
6103
6192
  DispatchEventSchema,
6104
6193
  DevReviewLoopEventSchema,
6105
6194
  ForgeWriteEventSchema,
@@ -6108,10 +6197,11 @@ var LogEventSchema = z2.union([
6108
6197
  UsageEventSchema,
6109
6198
  RoleAttemptEventSchema,
6110
6199
  HandoffEventSchema,
6111
- EffectEventSchema
6200
+ EffectEventSchema,
6201
+ CustomEventSchema
6112
6202
  ]);
6113
-
6114
6203
  // ../../packages/aeg-core/src/log/envelope.ts
6204
+ import { createHash as createHash5 } from "node:crypto";
6115
6205
  function isRole(value) {
6116
6206
  return value !== undefined && ROLE_VALUES.includes(value);
6117
6207
  }
@@ -6148,18 +6238,27 @@ function roundFromEnv(round) {
6148
6238
  const n = Number(round);
6149
6239
  return Number.isInteger(n) ? n : undefined;
6150
6240
  }
6241
+ function prFromEnv(pr) {
6242
+ if (pr === undefined || pr === "")
6243
+ return;
6244
+ const n = Number(pr);
6245
+ return Number.isInteger(n) && n > 0 ? n : undefined;
6246
+ }
6151
6247
  function buildHeader(input) {
6152
6248
  const role = isRole(input.env.role) ? input.env.role : "unattributed";
6153
6249
  const round = roundFromEnv(input.env.round);
6250
+ const pr = prFromEnv(input.env.pr);
6154
6251
  const subject = {
6155
6252
  issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
6156
6253
  role,
6157
6254
  ...round !== undefined ? { round } : {},
6255
+ ...pr !== undefined ? { pr } : {},
6158
6256
  ...input.subject ?? {}
6159
6257
  };
6258
+ const issue = subject.issue;
6160
6259
  return {
6161
6260
  meta: {
6162
- schema: 2,
6261
+ schema: 3,
6163
6262
  ts: input.now.toISOString(),
6164
6263
  run_id: input.runId,
6165
6264
  seq: input.seq,
@@ -6182,7 +6281,19 @@ function buildHeader(input) {
6182
6281
  ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
6183
6282
  policy_digest: input.inputVersions?.policyDigest ?? null
6184
6283
  },
6185
- provenance: provenanceFor(input)
6284
+ provenance: provenanceFor(input),
6285
+ work: {
6286
+ ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
6287
+ repo: input.repo,
6288
+ change: null,
6289
+ revision: null
6290
+ },
6291
+ flow: {
6292
+ id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
6293
+ version: lineageFieldFromEnv(input.env.flowVersion)
6294
+ },
6295
+ runtime: lineageFieldFromEnv(input.env.runtime),
6296
+ source: lineageFieldFromEnv(input.env.source)
6186
6297
  },
6187
6298
  subject
6188
6299
  };
@@ -6225,7 +6336,7 @@ function redact(value, home) {
6225
6336
  return value;
6226
6337
  }
6227
6338
  // ../../packages/aeg-core/src/log/store.ts
6228
- var KNOWN_SCHEMA_VERSIONS = [1, 2];
6339
+ var KNOWN_SCHEMA_VERSIONS = [1, 2, 3];
6229
6340
  function metaOf(obj) {
6230
6341
  if (obj === null || typeof obj !== "object")
6231
6342
  return null;
@@ -6291,7 +6402,7 @@ function classifyStoredLine(raw, home) {
6291
6402
  return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
6292
6403
  }
6293
6404
  const redacted = redact(event, home);
6294
- const provenance = version === 2 ? event.meta.provenance ?? null : null;
6405
+ const provenance = version >= 2 ? event.meta.provenance ?? null : null;
6295
6406
  return {
6296
6407
  status: "ok",
6297
6408
  identity,
@@ -6304,189 +6415,172 @@ function classifyStoredLine(raw, home) {
6304
6415
  };
6305
6416
  }
6306
6417
  // ../../packages/aeg-core/src/control-store/records.ts
6307
- import { z as z3 } from "zod";
6308
- var isoTimestamp = z3.string().min(1);
6309
- var taskId = z3.number().int().positive();
6310
- var epochNumber = z3.number().int().nonnegative();
6311
- var RunRecordSchema = z3.object({
6312
- version: z3.literal(1),
6313
- kind: z3.literal("run"),
6418
+ import { z as z4 } from "zod";
6419
+ var isoTimestamp = z4.string().min(1);
6420
+ var taskId = z4.number().int().positive();
6421
+ var epochNumber = z4.number().int().nonnegative();
6422
+ var RunRecordSchema = z4.object({
6423
+ version: z4.literal(1),
6424
+ kind: z4.literal("run"),
6314
6425
  task: taskId,
6315
- runId: z3.string().min(1),
6316
- pid: z3.number().int().positive(),
6317
- host: z3.string().min(1),
6426
+ runId: z4.string().min(1),
6427
+ pid: z4.number().int().positive(),
6428
+ host: z4.string().min(1),
6318
6429
  startedAt: isoTimestamp,
6319
- childStartedAt: z3.string().min(1).nullable().optional(),
6320
- childCommand: z3.string().min(1).nullable().optional()
6430
+ childStartedAt: z4.string().min(1).nullable().optional(),
6431
+ childCommand: z4.string().min(1).nullable().optional()
6321
6432
  }).strict();
6322
- var InputRecordSchema = z3.object({
6323
- version: z3.literal(1),
6324
- kind: z3.literal("input"),
6433
+ var InputRecordSchema = z4.object({
6434
+ version: z4.literal(1),
6435
+ kind: z4.literal("input"),
6325
6436
  task: taskId,
6326
- runId: z3.string().min(1),
6327
- source: z3.union([z3.literal("fresh"), z3.literal("resume")]),
6328
- pr: z3.number().int().positive().nullable(),
6329
- round: z3.number().int().nonnegative(),
6437
+ runId: z4.string().min(1),
6438
+ source: z4.union([z4.literal("fresh"), z4.literal("resume")]),
6439
+ pr: z4.number().int().positive().nullable(),
6440
+ round: z4.number().int().nonnegative(),
6330
6441
  recordedAt: isoTimestamp
6331
6442
  }).strict();
6332
- var OwnershipRecordSchema = z3.object({
6333
- version: z3.literal(1),
6334
- kind: z3.literal("ownership"),
6443
+ var OwnershipRecordSchema = z4.object({
6444
+ version: z4.literal(1),
6445
+ kind: z4.literal("ownership"),
6335
6446
  task: taskId,
6336
6447
  epoch: epochNumber,
6337
- ownerId: z3.string().min(1),
6338
- pid: z3.number().int().positive(),
6339
- host: z3.string().min(1),
6448
+ ownerId: z4.string().min(1),
6449
+ pid: z4.number().int().positive(),
6450
+ host: z4.string().min(1),
6340
6451
  acquiredAt: isoTimestamp
6341
6452
  }).strict();
6342
- var TransitionRecordSchema = z3.object({
6343
- version: z3.literal(1),
6344
- kind: z3.literal("transition"),
6453
+ var TransitionRecordSchema = z4.object({
6454
+ version: z4.literal(1),
6455
+ kind: z4.literal("transition"),
6345
6456
  task: taskId,
6346
6457
  epoch: epochNumber,
6347
- seq: z3.number().int().nonnegative(),
6348
- from: z3.string().min(1),
6349
- to: z3.string().min(1),
6350
- detail: z3.string().optional(),
6458
+ seq: z4.number().int().nonnegative(),
6459
+ from: z4.string().min(1),
6460
+ to: z4.string().min(1),
6461
+ detail: z4.string().optional(),
6351
6462
  at: isoTimestamp
6352
6463
  }).strict();
6353
- var ManifestRecordSchema = z3.object({
6354
- version: z3.literal(1),
6355
- kind: z3.literal("manifest"),
6464
+ var ManifestRecordSchema = z4.object({
6465
+ version: z4.literal(1),
6466
+ kind: z4.literal("manifest"),
6356
6467
  task: taskId,
6357
6468
  round: epochNumber,
6358
- repository: z3.string().min(1),
6359
- pr: z3.number().int().positive(),
6360
- branch: z3.string().min(1),
6361
- baseSha: z3.string().min(1).nullable(),
6362
- headSha: z3.string().min(1),
6363
- briefHash: z3.string().min(1).nullable(),
6364
- objectivesVersion: z3.string().min(1).nullable(),
6469
+ repository: z4.string().min(1),
6470
+ pr: z4.number().int().positive(),
6471
+ branch: z4.string().min(1),
6472
+ baseSha: z4.string().min(1).nullable(),
6473
+ headSha: z4.string().min(1),
6474
+ briefHash: z4.string().min(1).nullable(),
6475
+ objectivesVersion: z4.string().min(1).nullable(),
6365
6476
  rulingOrdinal: epochNumber,
6366
- policyDigest: z3.string().min(1),
6477
+ policyDigest: z4.string().min(1),
6367
6478
  recordedAt: isoTimestamp
6368
6479
  }).strict();
6369
- var roundHeadIdentity = z3.object({ round: z3.number().int().positive(), head: z3.string().min(1) }).strict();
6370
- var LoopBudgetsSchema = z3.object({
6371
- mechanicalRetries: z3.number().int().nonnegative(),
6372
- reviewRounds: z3.number().int().nonnegative(),
6373
- infrastructureRetries: z3.number().int().nonnegative()
6480
+ var roundHeadIdentity = z4.object({ round: z4.number().int().positive(), head: z4.string().min(1) }).strict();
6481
+ var LoopBudgetsSchema = z4.object({
6482
+ mechanicalRetries: z4.number().int().nonnegative(),
6483
+ reviewRounds: z4.number().int().nonnegative(),
6484
+ infrastructureRetries: z4.number().int().nonnegative()
6374
6485
  }).strict();
6375
- var LoopStateRecordSchema = z3.object({
6376
- version: z3.literal(1),
6377
- kind: z3.literal("loop_state"),
6486
+ var LoopStateRecordSchema = z4.object({
6487
+ version: z4.literal(1),
6488
+ kind: z4.literal("loop_state"),
6378
6489
  task: taskId,
6379
- round: z3.number().int().positive(),
6380
- phase: z3.string().min(1),
6381
- pauseReason: z3.string().min(1).nullable(),
6490
+ round: z4.number().int().positive(),
6491
+ phase: z4.string().min(1),
6492
+ pauseReason: z4.string().min(1).nullable(),
6382
6493
  budgets: LoopBudgetsSchema,
6383
6494
  heldResult: roundHeadIdentity.nullable(),
6384
6495
  deliveredFindings: roundHeadIdentity.nullable(),
6385
- repeatMemory: z3.object({
6386
- blockingFindings: z3.array(z3.string()),
6387
- lastFailure: z3.object({ signature: z3.string(), message: z3.string() }).nullable()
6496
+ repeatMemory: z4.object({
6497
+ blockingFindings: z4.array(z4.string()),
6498
+ lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
6388
6499
  }).strict().optional(),
6500
+ publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
6501
+ taskStartedAt: isoTimestamp.optional(),
6502
+ phaseMs: z4.record(z4.string(), z4.number().nonnegative()).optional(),
6389
6503
  recordedAt: isoTimestamp
6390
6504
  }).strict();
6391
- var EffectRecordSchema = z3.object({
6392
- version: z3.literal(1),
6393
- kind: z3.literal("effect"),
6505
+ var EffectRecordSchema = z4.object({
6506
+ version: z4.literal(1),
6507
+ kind: z4.literal("effect"),
6394
6508
  task: taskId,
6395
- key: z3.string().min(1),
6396
- operation: z3.string().min(1),
6397
- target: z3.string().min(1),
6398
- inputVersion: z3.number().int().nonnegative(),
6399
- payloadDigest: z3.string().min(1),
6400
- status: z3.union([z3.literal("started"), z3.literal("verified"), z3.literal("uncertain")]),
6401
- url: z3.string().optional(),
6509
+ key: z4.string().min(1),
6510
+ operation: z4.string().min(1),
6511
+ target: z4.string().min(1),
6512
+ inputVersion: z4.number().int().nonnegative(),
6513
+ payloadDigest: z4.string().min(1),
6514
+ status: z4.union([z4.literal("started"), z4.literal("verified"), z4.literal("uncertain")]),
6515
+ url: z4.string().optional(),
6402
6516
  recordedAt: isoTimestamp
6403
6517
  }).strict();
6404
- var EscalationRecordSchema = z3.object({
6405
- version: z3.literal(1),
6406
- kind: z3.literal("escalation"),
6518
+ var EscalationRecordSchema = z4.object({
6519
+ version: z4.literal(1),
6520
+ kind: z4.literal("escalation"),
6407
6521
  task: taskId,
6408
- escalationId: z3.string().min(1),
6522
+ escalationId: z4.string().min(1),
6409
6523
  round: epochNumber,
6410
- head: z3.string().min(1),
6411
- branch: z3.string().min(1),
6412
- pr: z3.number().int().positive().nullable(),
6413
- runId: z3.string().min(1),
6414
- pid: z3.number().int().positive(),
6415
- host: z3.string().min(1),
6416
- agent: z3.string().min(1).optional(),
6417
- reason: z3.string().min(1),
6418
- detail: z3.string().optional(),
6419
- evidence: z3.string().optional(),
6420
- attemptedRecovery: z3.string().min(1),
6421
- requestedDecision: z3.string().min(1),
6422
- recipient: z3.string().min(1),
6423
- briefHash: z3.string().min(1).nullable(),
6424
- objectivesVersion: z3.string().min(1).nullable(),
6524
+ head: z4.string().min(1),
6525
+ branch: z4.string().min(1),
6526
+ pr: z4.number().int().positive().nullable(),
6527
+ runId: z4.string().min(1),
6528
+ pid: z4.number().int().positive(),
6529
+ host: z4.string().min(1),
6530
+ agent: z4.string().min(1).optional(),
6531
+ reason: z4.string().min(1),
6532
+ detail: z4.string().optional(),
6533
+ evidence: z4.string().optional(),
6534
+ attemptedRecovery: z4.string().min(1),
6535
+ requestedDecision: z4.string().min(1),
6536
+ recipient: z4.string().min(1),
6537
+ briefHash: z4.string().min(1).nullable(),
6538
+ objectivesVersion: z4.string().min(1).nullable(),
6425
6539
  rulingOrdinal: epochNumber,
6426
- policyDigest: z3.string().min(1),
6540
+ policyDigest: z4.string().min(1),
6427
6541
  recordedAt: isoTimestamp
6428
6542
  }).strict();
6429
- var ResolutionRecordSchema = z3.object({
6430
- version: z3.literal(1),
6431
- kind: z3.literal("resolution"),
6543
+ var ResolutionRecordSchema = z4.object({
6544
+ version: z4.literal(1),
6545
+ kind: z4.literal("resolution"),
6432
6546
  task: taskId,
6433
- escalationId: z3.string().min(1),
6434
- decision: z3.union([z3.literal("resume"), z3.literal("cancel")]),
6435
- authenticatedBy: z3.string().min(1),
6436
- authenticatedFrom: z3.string().min(1),
6547
+ escalationId: z4.string().min(1),
6548
+ decision: z4.union([z4.literal("resume"), z4.literal("cancel")]),
6549
+ authenticatedBy: z4.string().min(1),
6550
+ authenticatedFrom: z4.string().min(1),
6437
6551
  consumedAt: isoTimestamp
6438
6552
  }).strict();
6553
+ // ../../packages/aeg-core/src/control-store/local.ts
6554
+ var CONTROL_AREA_DIRNAME = "control";
6439
6555
  // src/lib/config.ts
6440
- import { execFile as execFile4, execFileSync as execFileSync3 } from "node:child_process";
6556
+ import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
6441
6557
  import { promisify as promisify4 } from "node:util";
6442
6558
  import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
6443
6559
  import { homedir } from "node:os";
6444
6560
  import { dirname, isAbsolute, join, resolve } from "node:path";
6445
- import { z as z4 } from "zod";
6561
+ import { z as z5 } from "zod";
6446
6562
 
6447
6563
  // src/lib/agent-vendors.ts
6448
6564
  var AGENT_VENDORS = ["skills", "claude", "gemini"];
6449
6565
 
6450
- // src/lib/worker-boundary.ts
6451
- import { execFileSync as execFileSync2 } from "node:child_process";
6452
- var LOG_HEADER_KEYCHAIN_SERVICE = "Vinaya Log";
6453
- var logHeaderKeychainCache = new Map;
6454
- function readRealLogHeaderKeychainCredential(variable) {
6455
- if (process.platform !== "darwin")
6456
- return null;
6457
- try {
6458
- 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$/, "");
6459
- } catch {
6460
- return null;
6461
- }
6462
- }
6463
- function readLogHeaderKeychainCredential(variable) {
6464
- const cached = logHeaderKeychainCache.get(variable);
6465
- if (cached !== undefined)
6466
- return cached;
6467
- const value = readRealLogHeaderKeychainCredential(variable);
6468
- logHeaderKeychainCache.set(variable, value);
6469
- return value;
6470
- }
6471
-
6472
6566
  // src/lib/config.ts
6473
- var EnvEntrySchema = z4.union([
6474
- z4.literal(true),
6475
- z4.object({ optional: z4.literal(true) }),
6476
- z4.object({ anyOf: z4.array(z4.string()).min(2) }),
6477
- z4.string()
6567
+ var EnvEntrySchema = z5.union([
6568
+ z5.literal(true),
6569
+ z5.object({ optional: z5.literal(true) }),
6570
+ z5.object({ anyOf: z5.array(z5.string()).min(2) }),
6571
+ z5.string()
6478
6572
  ]);
6479
- var CheckEntrySchema = z4.object({
6480
- run: z4.string(),
6481
- scope: z4.enum(["diff", "full"]),
6482
- include: z4.array(z4.string()).optional(),
6483
- args: z4.array(z4.string()).optional(),
6484
- timeoutMs: z4.number().optional(),
6485
- env: z4.record(z4.string(), EnvEntrySchema).optional(),
6486
- requiresOpenPr: z4.boolean().optional(),
6487
- ownWorkflow: z4.boolean().optional(),
6488
- principalOwed: z4.literal(true).optional(),
6489
- validates: z4.enum(["body", "issue"]).optional()
6573
+ var CheckEntrySchema = z5.object({
6574
+ run: z5.string(),
6575
+ scope: z5.enum(["diff", "full"]),
6576
+ include: z5.array(z5.string()).optional(),
6577
+ args: z5.array(z5.string()).optional(),
6578
+ timeoutMs: z5.number().optional(),
6579
+ env: z5.record(z5.string(), EnvEntrySchema).optional(),
6580
+ requiresOpenPr: z5.boolean().optional(),
6581
+ ownWorkflow: z5.boolean().optional(),
6582
+ principalOwed: z5.literal(true).optional(),
6583
+ validates: z5.enum(["body", "issue"]).optional()
6490
6584
  }).superRefine((entry, ctx) => {
6491
6585
  if (!entry.env)
6492
6586
  return;
@@ -6496,22 +6590,22 @@ var CheckEntrySchema = z4.object({
6496
6590
  const members = value.anyOf;
6497
6591
  if (new Set(members).size !== members.length) {
6498
6592
  ctx.addIssue({
6499
- code: z4.ZodIssueCode.custom,
6593
+ code: z5.ZodIssueCode.custom,
6500
6594
  message: `env.${key}.anyOf has duplicate members`,
6501
6595
  path: ["env", key, "anyOf"]
6502
6596
  });
6503
6597
  }
6504
6598
  if (!members.includes(key)) {
6505
6599
  ctx.addIssue({
6506
- code: z4.ZodIssueCode.custom,
6600
+ code: z5.ZodIssueCode.custom,
6507
6601
  message: `env.${key}.anyOf must include "${key}" itself as a member`,
6508
6602
  path: ["env", key, "anyOf"]
6509
6603
  });
6510
6604
  }
6511
6605
  }
6512
6606
  });
6513
- var RoleEntrySchema = z4.object({
6514
- contract: z4.string().refine((p) => p.includes("/"), {
6607
+ var RoleEntrySchema = z5.object({
6608
+ contract: z5.string().refine((p) => p.includes("/"), {
6515
6609
  message: 'must be a path (contain at least one "/"), not a bare filename'
6516
6610
  })
6517
6611
  });
@@ -6535,17 +6629,17 @@ var BRIEF_BUILTINS = [
6535
6629
  "briefSections",
6536
6630
  "milestoneShape"
6537
6631
  ];
6538
- var BriefSectionSchema = z4.union([
6539
- z4.object({ builtin: z4.enum(BRIEF_BUILTINS) }),
6540
- z4.object({ heading: z4.string().min(1), name: z4.string().optional() }),
6541
- z4.object({ field: z4.string().min(1), name: z4.string().optional() }),
6542
- z4.object({ phrase: z4.string().min(1), name: z4.string().optional() })
6632
+ var BriefSectionSchema = z5.union([
6633
+ z5.object({ builtin: z5.enum(BRIEF_BUILTINS) }),
6634
+ z5.object({ heading: z5.string().min(1), name: z5.string().optional() }),
6635
+ z5.object({ field: z5.string().min(1), name: z5.string().optional() }),
6636
+ z5.object({ phrase: z5.string().min(1), name: z5.string().optional() })
6543
6637
  ]);
6544
- var BriefSchemaSchema = z4.object({
6545
- pr: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
6546
- issue: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
6547
- milestone: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
6548
- ack: z4.array(z4.enum(BRIEF_BUILTINS)).optional()
6638
+ var BriefSchemaSchema = z5.object({
6639
+ pr: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
6640
+ issue: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
6641
+ milestone: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
6642
+ ack: z5.array(z5.enum(BRIEF_BUILTINS)).optional()
6549
6643
  });
6550
6644
  function isSafeRepoRelPath(p) {
6551
6645
  if (p.length === 0)
@@ -6554,7 +6648,7 @@ function isSafeRepoRelPath(p) {
6554
6648
  return false;
6555
6649
  return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
6556
6650
  }
6557
- var SafeRepoRelPath = z4.string().refine(isSafeRepoRelPath, {
6651
+ var SafeRepoRelPath = z5.string().refine(isSafeRepoRelPath, {
6558
6652
  message: "must be a repo-root-relative path with no `..` segment or absolute root"
6559
6653
  });
6560
6654
  var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
@@ -6564,22 +6658,22 @@ function isCanonicalHookBlockPath(p) {
6564
6658
  var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
6565
6659
  message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
6566
6660
  });
6567
- var ManagedBlockRecordSchema = z4.object({
6661
+ var ManagedBlockRecordSchema = z5.object({
6568
6662
  path: ManagedHookBlockPath,
6569
- marker: z4.string(),
6570
- comment: z4.enum(["hash", "html"])
6663
+ marker: z5.string(),
6664
+ comment: z5.enum(["hash", "html"])
6571
6665
  });
6572
- var ManagedManifestSchema = z4.object({
6573
- version: z4.number().int().positive(),
6574
- files: z4.array(SafeRepoRelPath),
6575
- blocks: z4.array(ManagedBlockRecordSchema),
6576
- labels: z4.array(z4.string()),
6577
- agents: z4.array(z4.enum(AGENT_VENDORS)).optional()
6666
+ var ManagedManifestSchema = z5.object({
6667
+ version: z5.number().int().positive(),
6668
+ files: z5.array(SafeRepoRelPath),
6669
+ blocks: z5.array(ManagedBlockRecordSchema),
6670
+ labels: z5.array(z5.string()),
6671
+ agents: z5.array(z5.enum(AGENT_VENDORS)).optional()
6578
6672
  });
6579
- var ProjectEntrySchema = z4.object({
6580
- name: z4.string().min(1),
6581
- description: z4.string().min(1).optional(),
6582
- path: z4.string().min(1).optional()
6673
+ var ProjectEntrySchema = z5.object({
6674
+ name: z5.string().min(1),
6675
+ description: z5.string().min(1).optional(),
6676
+ path: z5.string().min(1).optional()
6583
6677
  });
6584
6678
  function parseTokensCollectDeclaration(value) {
6585
6679
  const m = value.trim().match(/^(\S+)\s+(\S+)$/);
@@ -6590,90 +6684,97 @@ function parseTokensCollectDeclaration(value) {
6590
6684
  return null;
6591
6685
  return { interpreter, script };
6592
6686
  }
6593
- var VinayaConfigSchema = z4.object({
6594
- rings: z4.object({
6595
- ring1_forgeWriteInterception: z4.boolean(),
6596
- ring2_asyncAudits: z4.boolean()
6687
+ var VinayaConfigSchema = z5.object({
6688
+ rings: z5.object({
6689
+ ring1_forgeWriteInterception: z5.boolean(),
6690
+ ring2_asyncAudits: z5.boolean()
6597
6691
  }).optional(),
6598
- checks: z4.record(z4.string(), CheckEntrySchema).optional(),
6599
- roles: z4.record(z4.string(), RoleEntrySchema).optional(),
6692
+ checks: z5.record(z5.string(), CheckEntrySchema).optional(),
6693
+ roles: z5.record(z5.string(), RoleEntrySchema).optional(),
6600
6694
  briefSchema: BriefSchemaSchema.optional(),
6601
6695
  managed: ManagedManifestSchema.optional(),
6602
- principals: z4.array(z4.string()).min(1).optional(),
6603
- releaseActor: z4.string().min(1).optional(),
6604
- ci: z4.object({ setup: z4.string().min(1) }).optional(),
6605
- tokens: z4.object({
6606
- collect: z4.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
6696
+ principals: z5.array(z5.string()).min(1).optional(),
6697
+ releaseActor: z5.string().min(1).optional(),
6698
+ ci: z5.object({ setup: z5.string().min(1) }).optional(),
6699
+ tokens: z5.object({
6700
+ collect: z5.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
6607
6701
  message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
6608
6702
  })
6609
6703
  }).optional(),
6610
- blastRadius: z4.object({ extraDomains: z4.array(z4.string()).optional() }).optional(),
6611
- proseGates: z4.object({
6612
- doctrineRoot: z4.string().min(1).optional(),
6613
- readerFacingPrefix: z4.string().min(1).optional(),
6614
- readerFacingSuffix: z4.string().min(1).optional(),
6615
- legacySlugDir: z4.string().min(1).optional(),
6616
- sourceComments: z4.object({
6617
- globs: z4.array(z4.string().min(1)).optional(),
6618
- allowlist: z4.array(z4.string().min(1)).optional(),
6619
- severity: z4.enum(["warning", "error"]).optional()
6704
+ blastRadius: z5.object({ extraDomains: z5.array(z5.string()).optional() }).optional(),
6705
+ proseGates: z5.object({
6706
+ doctrineRoot: z5.string().min(1).optional(),
6707
+ readerFacingPrefix: z5.string().min(1).optional(),
6708
+ readerFacingSuffix: z5.string().min(1).optional(),
6709
+ legacySlugDir: z5.string().min(1).optional(),
6710
+ sourceComments: z5.object({
6711
+ globs: z5.array(z5.string().min(1)).optional(),
6712
+ allowlist: z5.array(z5.string().min(1)).optional(),
6713
+ severity: z5.enum(["warning", "error"]).optional()
6620
6714
  }).optional(),
6621
- specGrandfather: z4.array(z4.string().min(1)).optional(),
6622
- specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
6715
+ specGrandfather: z5.union([z5.array(z5.string().min(1)), z5.record(z5.string().min(1), z5.number().int().min(0))]).optional(),
6716
+ specPaths: z5.array(z5.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
6623
6717
  message: "must be a repository-relative path, not an absolute one"
6624
6718
  }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
6625
6719
  message: "must stay inside the repository — no `..` segment"
6626
6720
  })).optional()
6627
6721
  }).optional(),
6628
- projects: z4.array(ProjectEntrySchema).optional(),
6629
- dispatch: z4.object({
6630
- timeoutMs: z4.number().int().positive().optional(),
6631
- killGraceMs: z4.number().int().positive().optional(),
6632
- agent: z4.enum(["claude", "codex", "gemini"]).optional(),
6633
- requireWorkerIsolation: z4.boolean().optional()
6722
+ projects: z5.array(ProjectEntrySchema).optional(),
6723
+ dispatch: z5.object({
6724
+ timeoutMs: z5.number().int().positive().optional(),
6725
+ killGraceMs: z5.number().int().positive().optional(),
6726
+ agent: z5.enum(["claude", "codex", "gemini"]).optional()
6634
6727
  }).optional(),
6635
- reviewPolicy: z4.object({
6636
- codeReviewThreshold: z4.string().min(1).optional(),
6637
- securityThreshold: z4.string().min(1).optional(),
6638
- maxRounds: z4.number().optional()
6728
+ reviewPolicy: z5.object({
6729
+ codeReviewThreshold: z5.string().min(1).optional(),
6730
+ securityThreshold: z5.string().min(1).optional(),
6731
+ maxRounds: z5.number().optional(),
6732
+ maxTaskMinutes: z5.number().optional()
6639
6733
  }).optional(),
6640
- gateCutovers: z4.object({
6641
- objectivesSinceIssue: z4.number().int().nonnegative().optional(),
6642
- briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
6643
- documentationSinceIssue: z4.number().int().nonnegative().optional(),
6644
- briefRulesSincePr: z4.number().int().nonnegative().optional(),
6645
- agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
6734
+ securityScan: z5.object({
6735
+ command: z5.array(z5.string().min(1)).min(1)
6646
6736
  }).optional(),
6647
- planning: z4.object({
6648
- collisionThreshold: z4.number().int().nonnegative().optional()
6737
+ gateCutovers: z5.object({
6738
+ objectivesSinceIssue: z5.number().int().nonnegative().optional(),
6739
+ briefSectionsSinceIssue: z5.number().int().nonnegative().optional(),
6740
+ documentationSinceIssue: z5.number().int().nonnegative().optional(),
6741
+ briefRulesSincePr: z5.number().int().nonnegative().optional(),
6742
+ agentBoxesRefusedSincePr: z5.number().int().nonnegative().optional()
6649
6743
  }).optional(),
6650
- prePush: z4.object({
6651
- alwaysRun: z4.array(z4.string()).optional()
6744
+ planning: z5.object({
6745
+ collisionThreshold: z5.number().int().nonnegative().optional()
6652
6746
  }).optional(),
6653
- report: z4.object({
6654
- commandTimeoutMs: z4.number().int().positive().optional()
6747
+ prePush: z5.object({
6748
+ alwaysRun: z5.array(z5.string()).optional()
6749
+ }).optional(),
6750
+ report: z5.object({
6751
+ commandTimeoutMs: z5.number().int().positive().optional()
6655
6752
  }).superRefine((report, ctx) => {
6656
6753
  const commandTimeoutMs = report.commandTimeoutMs;
6657
6754
  if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
6658
6755
  ctx.addIssue({
6659
- code: z4.ZodIssueCode.custom,
6756
+ code: z5.ZodIssueCode.custom,
6660
6757
  path: ["commandTimeoutMs"],
6661
6758
  message: "must be at most 3600000 (1 hour)"
6662
6759
  });
6663
6760
  }
6664
6761
  }).optional(),
6665
- logPublish: z4.unknown().refine((v) => v === undefined, {
6762
+ logPublish: z5.unknown().refine((v) => v === undefined, {
6666
6763
  message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
6667
6764
  }),
6668
- runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
6669
- logs: z4.object({
6670
- folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
6671
- url: z4.string().url().optional(),
6672
- headers: z4.record(z4.string()).optional()
6765
+ runtimeDir: z5.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
6766
+ logs: z5.object({
6767
+ folder: z5.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
6768
+ url: z5.string().url().optional(),
6769
+ headers: z5.record(z5.string()).optional(),
6770
+ readHeaders: z5.record(z5.string()).optional(),
6771
+ events: CustomEventDeclarationsSchema.optional()
6673
6772
  }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
6674
6773
  message: "logs: set at most one of folder/url"
6675
6774
  }).refine((v) => v.headers === undefined || v.url !== undefined, {
6676
6775
  message: "logs: headers requires url"
6776
+ }).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
6777
+ message: "logs: readHeaders requires url"
6677
6778
  }).optional()
6678
6779
  });
6679
6780
  var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
@@ -6778,10 +6879,15 @@ function resolveReviewPolicy(config) {
6778
6879
  if (!Number.isInteger(maxRounds) || maxRounds < 1) {
6779
6880
  throw new Error(`vinaya.config.json: reviewPolicy.maxRounds "${maxRounds}" is not a positive integer — fix the config, this never falls back to a default.`);
6780
6881
  }
6882
+ const maxTaskMinutes = raw.maxTaskMinutes ?? DEFAULT_REVIEW_POLICY.maxTaskMinutes;
6883
+ if (!Number.isInteger(maxTaskMinutes) || maxTaskMinutes < 0) {
6884
+ 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.`);
6885
+ }
6781
6886
  return {
6782
6887
  codeReviewThreshold,
6783
6888
  securityThreshold,
6784
- maxRounds
6889
+ maxRounds,
6890
+ maxTaskMinutes
6785
6891
  };
6786
6892
  }
6787
6893
  function resolveGateCutovers(config) {
@@ -6821,17 +6927,12 @@ function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
6821
6927
  return "url" in anchored && anchored.url === local.url ? anchored : null;
6822
6928
  return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
6823
6929
  }
6824
- function resolveLogsHeaderValues(headers, env, readKeychain = readLogHeaderKeychainCredential) {
6930
+ function resolveLogsHeaderValues(headers, env) {
6825
6931
  if (!headers)
6826
6932
  return;
6827
6933
  const resolved = {};
6828
6934
  for (const [key, value] of Object.entries(headers)) {
6829
- resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => {
6830
- const fromEnv = env[name];
6831
- if (fromEnv !== undefined)
6832
- return fromEnv;
6833
- return readKeychain(name) ?? "";
6834
- });
6935
+ resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
6835
6936
  }
6836
6937
  return resolved;
6837
6938
  }
@@ -6840,7 +6941,7 @@ function trustAnchorRepo() {
6840
6941
  if (fromRunner)
6841
6942
  return fromRunner;
6842
6943
  try {
6843
- const url = execFileSync3("git", ["remote", "get-url", "origin"], {
6944
+ const url = execFileSync2("git", ["remote", "get-url", "origin"], {
6844
6945
  encoding: "utf-8",
6845
6946
  stdio: ["ignore", "pipe", "pipe"]
6846
6947
  });
@@ -6887,7 +6988,7 @@ function resolveCiTrustAnchorProbeRef(env = process.env) {
6887
6988
  return ref;
6888
6989
  }
6889
6990
  function readTrustAnchorConfigAtRef(ref) {
6890
- const raw = execFileSync3("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
6991
+ const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
6891
6992
  encoding: "utf-8",
6892
6993
  stdio: ["ignore", "pipe", "pipe"],
6893
6994
  timeout: 1e4
@@ -6901,7 +7002,7 @@ function ghFetchTrustAnchorConfig() {
6901
7002
  const repo = trustAnchorRepo();
6902
7003
  if (!repo)
6903
7004
  throw new Error("could not resolve repo identity for the trust-anchor read");
6904
- return execFileSync3("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
7005
+ return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
6905
7006
  encoding: "utf-8",
6906
7007
  stdio: ["ignore", "pipe", "pipe"]
6907
7008
  });
@@ -6993,10 +7094,10 @@ var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.j
6993
7094
 
6994
7095
  // src/lib/diff-evidence.ts
6995
7096
  import { execFileSync as execFileSync7 } from "node:child_process";
6996
- import { join as join9, relative, resolve as resolve2 } from "node:path";
7097
+ import { join as join9, relative as relative2, resolve as resolve2 } from "node:path";
6997
7098
 
6998
7099
  // src/lib/brief-assembly.ts
6999
- import { execFileSync as execFileSync6 } from "node:child_process";
7100
+ import { execFileSync as execFileSync5 } from "node:child_process";
7000
7101
  import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2 } from "node:fs";
7001
7102
  import { join as join4 } from "node:path";
7002
7103
 
@@ -7154,7 +7255,7 @@ var COMMANDS = [
7154
7255
  "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.",
7155
7256
  "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.",
7156
7257
  "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.",
7157
- "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`)."
7258
+ "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`)."
7158
7259
  ],
7159
7260
  status: "shipped"
7160
7261
  },
@@ -7239,13 +7340,14 @@ var COMMANDS = [
7239
7340
  },
7240
7341
  {
7241
7342
  flag: "--push",
7242
- 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."
7343
+ 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."
7243
7344
  }
7244
7345
  ],
7245
7346
  details: [
7246
7347
  "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.",
7247
7348
  "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.",
7248
- "`--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."
7349
+ "`--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.",
7350
+ "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."
7249
7351
  ],
7250
7352
  status: "shipped"
7251
7353
  },
@@ -7270,7 +7372,7 @@ var COMMANDS = [
7270
7372
  "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.",
7271
7373
  "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.",
7272
7374
  "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.",
7273
- "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."
7375
+ "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."
7274
7376
  ],
7275
7377
  status: "shipped"
7276
7378
  },
@@ -7441,7 +7543,7 @@ var COMMANDS = [
7441
7543
  { flag: "--secrets", description: "security only: the SECRETS line" },
7442
7544
  {
7443
7545
  flag: "--secrets-evidence-file",
7444
- description: 'security only: required whenever `--secrets` claims "none found" — the pasted scanner output backing that claim'
7546
+ 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'
7445
7547
  },
7446
7548
  { flag: "--task-id", description: "the closing `Tokens:` line's task id" },
7447
7549
  { flag: "--model", description: "the closing `Tokens:` line's model name" },
@@ -7549,7 +7651,20 @@ var COMMANDS = [
7549
7651
  flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
7550
7652
  details: [
7551
7653
  "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.",
7552
- "Once every task Issue is closed, prompts for confirmation (unless `--yes`) and closes the GitHub Milestone."
7654
+ "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.",
7655
+ "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.",
7656
+ "Idempotent: on a tranche whose Milestone is already closed and carries its retrospective, changes nothing and says it is already archived.",
7657
+ "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."
7658
+ ],
7659
+ status: "shipped"
7660
+ },
7661
+ {
7662
+ name: "archive tranches",
7663
+ description: "Archive every finished tranche that has no closed Milestone carrying its retrospective",
7664
+ flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
7665
+ details: [
7666
+ "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.",
7667
+ "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."
7553
7668
  ],
7554
7669
  status: "shipped"
7555
7670
  },
@@ -7693,6 +7808,29 @@ var COMMANDS = [
7693
7808
  ],
7694
7809
  status: "shipped"
7695
7810
  },
7811
+ {
7812
+ name: "log selftest",
7813
+ 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)",
7814
+ details: [
7815
+ "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.",
7816
+ "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.",
7817
+ "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."
7818
+ ],
7819
+ status: "shipped"
7820
+ },
7821
+ {
7822
+ name: "log emit",
7823
+ description: "Record a consumer-declared event (`logs.events` in vinaya.config.json) from a script or agent outside Vinaya",
7824
+ flags: [
7825
+ { flag: "--json '<json>'", description: "The field values as one JSON object (else read from standard input)" }
7826
+ ],
7827
+ details: [
7828
+ "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.",
7829
+ "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.",
7830
+ "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)."
7831
+ ],
7832
+ status: "shipped"
7833
+ },
7696
7834
  {
7697
7835
  name: "log send",
7698
7836
  description: "Deliver this repository's locally-held log events to the configured `logs.url` server, once",
@@ -7705,12 +7843,19 @@ var COMMANDS = [
7705
7843
  status: "shipped"
7706
7844
  },
7707
7845
  {
7708
- name: "log set-credential",
7709
- description: "Store a `logs.headers` delivery credential in the macOS login Keychain, read from standard input",
7846
+ name: "sync",
7847
+ description: "Fill, resume and rebuild the local log cache from this repository's configured destination (read-only)",
7848
+ flags: [
7849
+ {
7850
+ flag: "--rebuild",
7851
+ description: "Delete the cache file and sync from the beginning of what the destination still retains"
7852
+ },
7853
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
7854
+ ],
7710
7855
  details: [
7711
- '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.',
7712
- '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.',
7713
- "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."
7856
+ "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.",
7857
+ "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.",
7858
+ "`--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."
7714
7859
  ],
7715
7860
  status: "shipped"
7716
7861
  }
@@ -7724,13 +7869,13 @@ function createForgeSource(config) {
7724
7869
  };
7725
7870
  }
7726
7871
  // ../../packages/sources/src/select-source.ts
7727
- import { z as z5 } from "zod";
7728
- var StateSourceConfigSchema = z5.discriminatedUnion("kind", [
7729
- z5.object({ kind: z5.literal("forge"), owner: z5.string(), repo: z5.string() }),
7730
- z5.object({ kind: z5.literal("file"), root: z5.string().optional() })
7872
+ import { z as z6 } from "zod";
7873
+ var StateSourceConfigSchema = z6.discriminatedUnion("kind", [
7874
+ z6.object({ kind: z6.literal("forge"), owner: z6.string(), repo: z6.string() }),
7875
+ z6.object({ kind: z6.literal("file"), root: z6.string().optional() })
7731
7876
  ]);
7732
7877
  // src/checks/edge-resolve.ts
7733
- import { execFileSync as execFileSync4 } from "node:child_process";
7878
+ import { execFileSync as execFileSync3 } from "node:child_process";
7734
7879
  var DIRECT_ISSUE_REF = /#(\d+)/;
7735
7880
  var issueCache = new Map;
7736
7881
  function fetchIssueState(num, repo) {
@@ -7739,7 +7884,7 @@ function fetchIssueState(num, repo) {
7739
7884
  return issueCache.get(key) ?? null;
7740
7885
  let out = null;
7741
7886
  try {
7742
- const raw = execFileSync4("gh", [
7887
+ const raw = execFileSync3("gh", [
7743
7888
  "issue",
7744
7889
  "view",
7745
7890
  String(num),
@@ -7865,17 +8010,26 @@ function packageRoot(moduleUrl) {
7865
8010
  }
7866
8011
 
7867
8012
  // src/commands/doctrine.ts
7868
- import { execFileSync as execFileSync5 } from "node:child_process";
8013
+ import { execFileSync as execFileSync4 } from "node:child_process";
7869
8014
  import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3 } from "node:fs";
7870
8015
  import { dirname as dirname3, join as join3, sep } from "node:path";
8016
+ import matter4 from "gray-matter";
8017
+
8018
+ // ../../packages/aeg-core/src/docs/parse-doc.ts
7871
8019
  import matter2 from "gray-matter";
8020
+ // ../../packages/aeg-core/src/docs/surfaced-manifest.ts
8021
+ var NO_MODEL_BACKED_PATHS = new Set;
8022
+ // src/roles/contract.ts
8023
+ import matter3 from "gray-matter";
8024
+
8025
+ // src/commands/doctrine.ts
7872
8026
  var ENTRY_SEGMENTS = ["skills", "aeg", "SKILL.md"];
7873
8027
  function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
7874
8028
  return resolveDoctrineRootInfo(pkg, cwd)?.root ?? null;
7875
8029
  }
7876
8030
  function gitToplevel(cwd) {
7877
8031
  try {
7878
- return execFileSync5("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
8032
+ return execFileSync4("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
7879
8033
  encoding: "utf8",
7880
8034
  stdio: ["ignore", "pipe", "pipe"]
7881
8035
  }).trim();
@@ -7904,7 +8058,7 @@ var PACKAGED_TEMPLATE_PATH = join4(PACKAGE_ROOT, "aeg-root", "templates", "brief
7904
8058
  var TEMPLATE_PATH = existsSync4(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join4(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
7905
8059
  function git(args) {
7906
8060
  try {
7907
- return execFileSync6("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
8061
+ return execFileSync5("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
7908
8062
  } catch {
7909
8063
  return "";
7910
8064
  }
@@ -7917,12 +8071,16 @@ function expandGlob(glob) {
7917
8071
  var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
7918
8072
 
7919
8073
  // src/checks/registry.ts
7920
- import { existsSync as existsSync5 } from "node:fs";
7921
- import { join as join5 } from "node:path";
7922
- var DIST_BIN_DIR = join5(packageRoot(import.meta.url), "dist", "checks", "bin");
7923
- var SRC_BIN_DIR = join5(packageRoot(import.meta.url), "src", "checks", "bin");
7924
- var BIN_DIR = existsSync5(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
7925
- var BIN_EXT = BIN_DIR === DIST_BIN_DIR ? ".js" : ".ts";
8074
+ import { join as join5, relative, sep as sep2 } from "node:path";
8075
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
8076
+ function resolveCheckBin(packageDir, moduleUrl) {
8077
+ const fromPackage = relative(packageDir, fileURLToPath2(moduleUrl));
8078
+ const bundled = fromPackage === "dist" || fromPackage.startsWith(`dist${sep2}`);
8079
+ return bundled ? { dir: join5(packageDir, "dist", "checks", "bin"), ext: ".js" } : { dir: join5(packageDir, "src", "checks", "bin"), ext: ".ts" };
8080
+ }
8081
+ var CHECK_BIN = resolveCheckBin(packageRoot(import.meta.url), import.meta.url);
8082
+ var BIN_DIR = CHECK_BIN.dir;
8083
+ var BIN_EXT = CHECK_BIN.ext;
7926
8084
  function bin(name) {
7927
8085
  return join5(BIN_DIR, `${name}${BIN_EXT}`);
7928
8086
  }
@@ -8120,23 +8278,6 @@ var REGISTRY = [
8120
8278
  },
8121
8279
  1
8122
8280
  ],
8123
- [
8124
- {
8125
- name: "token-report",
8126
- validates: "body",
8127
- run: bin("check-token-report"),
8128
- scope: "diff",
8129
- timeoutMs: 15000,
8130
- requiresOpenPr: true,
8131
- env: {
8132
- PR_BODY: { optional: true },
8133
- BRANCH: { optional: true },
8134
- CLAUDE_PROJECT_DIR: { optional: true },
8135
- CLAUDE_CODE_SESSION_ID: { optional: true }
8136
- }
8137
- },
8138
- 1
8139
- ],
8140
8281
  [
8141
8282
  {
8142
8283
  name: "no-disk-state",
@@ -8486,23 +8627,35 @@ var CORE_CHECK_RING = Object.fromEntries(REGISTRY.map(([spec, ring]) => [spec.na
8486
8627
  import { execFile as execFile5 } from "node:child_process";
8487
8628
  import { randomUUID as randomUUID2 } from "node:crypto";
8488
8629
  import {
8489
- closeSync as closeSync3,
8490
- constants as fsConstants3,
8630
+ appendFileSync,
8631
+ closeSync as closeSync4,
8632
+ constants as fsConstants4,
8491
8633
  existsSync as existsSync7,
8492
- fstatSync as fstatSync2,
8493
- mkdirSync as mkdirSync3,
8494
- openSync as openSync3,
8495
- readFileSync as readFileSync6,
8634
+ fstatSync as fstatSync3,
8635
+ mkdirSync as mkdirSync4,
8636
+ lstatSync as lstatSync2,
8637
+ openSync as openSync4,
8638
+ readFileSync as readFileSync7,
8496
8639
  renameSync as renameSync2,
8497
- writeSync as writeSync2
8640
+ writeFileSync as writeFileSync3,
8641
+ writeSync as writeSync3
8498
8642
  } from "node:fs";
8499
8643
  import { hostname as osHostname, homedir as homedir3 } from "node:os";
8500
- import { dirname as dirname6, join as join8 } from "node:path";
8644
+ import { dirname as dirname7, join as join8 } from "node:path";
8501
8645
  import { promisify as promisify5 } from "node:util";
8502
8646
 
8503
8647
  // src/lib/run-paths.ts
8504
- import { chmodSync, existsSync as existsSync6, realpathSync as realpathSync2 } from "node:fs";
8648
+ import { execFileSync as execFileSync6 } from "node:child_process";
8649
+ import { chmodSync, existsSync as existsSync5, realpathSync as realpathSync2 } from "node:fs";
8505
8650
  import { dirname as dirname4, join as join6, resolve as resolvePath } from "node:path";
8651
+ var TASKS_EXECUTION_DIRNAME = "tasks-execution";
8652
+ var RUN_AREA_DIRNAMES = {
8653
+ control: CONTROL_AREA_DIRNAME,
8654
+ sessions: "sessions",
8655
+ hooks: "hooks",
8656
+ output: "output",
8657
+ rounds: "rounds"
8658
+ };
8506
8659
  var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8507
8660
  function isSafeRepoSegment(segment) {
8508
8661
  return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
@@ -8533,12 +8686,52 @@ function isInsideRepo(candidate, repoRoot) {
8533
8686
  const target = resolvePath(candidate);
8534
8687
  return target === root || target.startsWith(`${root}/`);
8535
8688
  }
8689
+ function runPath(runtimeDir, scope, location) {
8690
+ const dir = join6(runtimeDir, TASKS_EXECUTION_DIRNAME, scopeSegment(scope));
8691
+ switch (location.area) {
8692
+ case "task":
8693
+ return location.file ? join6(dir, location.file) : dir;
8694
+ case "control": {
8695
+ const controlDir = join6(dir, RUN_AREA_DIRNAMES.control);
8696
+ return location.file ? join6(controlDir, location.file) : controlDir;
8697
+ }
8698
+ case "rounds":
8699
+ return join6(dir, RUN_AREA_DIRNAMES.rounds);
8700
+ case "round": {
8701
+ const roundDir = join6(dir, RUN_AREA_DIRNAMES.rounds, String(location.round));
8702
+ return location.file ? join6(roundDir, location.file) : roundDir;
8703
+ }
8704
+ case "developer": {
8705
+ const developerDir = join6(dir, RUN_AREA_DIRNAMES.rounds, String(location.round), "developer");
8706
+ return location.file ? join6(developerDir, location.file) : developerDir;
8707
+ }
8708
+ default: {
8709
+ const areaDir = join6(dir, RUN_AREA_DIRNAMES[location.area]);
8710
+ return location.file ? join6(areaDir, location.file) : areaDir;
8711
+ }
8712
+ }
8713
+ }
8714
+ function scopeSegment(scope) {
8715
+ if (scope === "unscoped")
8716
+ return "unscoped";
8717
+ if (typeof scope === "number")
8718
+ return String(scope);
8719
+ return `pr-${scope.pr}`;
8720
+ }
8536
8721
  var UNATTENDED_ENV_KEY = "VINAYA_UNATTENDED";
8537
8722
  var RUNTIME_DIR_ENV_KEY = "VINAYA_RUNTIME_DIR";
8538
8723
  function isUnattendedProcess(env = process.env) {
8539
8724
  return env[UNATTENDED_ENV_KEY] === "1" || (env.VINAYA_ROLE ?? "") !== "";
8540
8725
  }
8541
8726
  var memoized = null;
8727
+ function runtimeDirForRepo(repo) {
8728
+ const key = repoSegment(repo);
8729
+ if (memoized?.key === key)
8730
+ return memoized.value;
8731
+ const value = resolveRuntimeDirUncached(repo);
8732
+ memoized = { key, value };
8733
+ return value;
8734
+ }
8542
8735
  async function runtimeDirForRepoAsync(repo) {
8543
8736
  const key = repoSegment(repo);
8544
8737
  if (memoized?.key === key)
@@ -8554,6 +8747,16 @@ async function runtimeDirForRepoAsync(repo) {
8554
8747
  memoized = { key, value };
8555
8748
  return value;
8556
8749
  }
8750
+ function resolveRuntimeDirUncached(repo) {
8751
+ const inputs = runtimeDirInputs();
8752
+ if (typeof inputs === "string")
8753
+ return inputs;
8754
+ return resolveRuntimeDir({
8755
+ repo,
8756
+ ...inputs.base,
8757
+ trustAnchorConfig: inputs.needsAnchor ? loadTrustAnchorConfig() : null
8758
+ });
8759
+ }
8557
8760
  function runtimeDirInputs() {
8558
8761
  const handedDown = process.env[RUNTIME_DIR_ENV_KEY];
8559
8762
  if (handedDown)
@@ -8573,7 +8776,7 @@ function repoRootSync(start = process.cwd()) {
8573
8776
  return null;
8574
8777
  }
8575
8778
  for (;; ) {
8576
- if (existsSync6(join6(dir, ".git")))
8779
+ if (existsSync5(join6(dir, ".git")))
8577
8780
  return dir;
8578
8781
  const parent = dirname4(dir);
8579
8782
  if (parent === dir)
@@ -8581,26 +8784,94 @@ function repoRootSync(start = process.cwd()) {
8581
8784
  dir = parent;
8582
8785
  }
8583
8786
  }
8787
+ function resolveRepoSync() {
8788
+ const fromEnv = process.env.AEG_REPO;
8789
+ if (fromEnv) {
8790
+ const m = /^([^/]+)\/(.+)$/.exec(fromEnv);
8791
+ if (m?.[1] && m[2])
8792
+ return { owner: m[1], repo: m[2] };
8793
+ }
8794
+ let url;
8795
+ try {
8796
+ url = execFileSync6("git", ["remote", "get-url", "origin"], {
8797
+ encoding: "utf-8",
8798
+ stdio: ["ignore", "pipe", "pipe"]
8799
+ }).trim();
8800
+ } catch {
8801
+ return null;
8802
+ }
8803
+ const ssh = /^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/.exec(url);
8804
+ if (ssh?.[1] && ssh[2])
8805
+ return { owner: ssh[1], repo: ssh[2] };
8806
+ const https = /^https?:\/\/(?:[^@]+@)?github\.com\/([^/]+)\/(.+?)(?:\.git)?\/?$/.exec(url);
8807
+ if (https?.[1] && https[2])
8808
+ return { owner: https[1], repo: https[2] };
8809
+ return null;
8810
+ }
8811
+ var memoizedThisRepo = null;
8812
+ function runtimeDirForThisRepo() {
8813
+ if (memoizedThisRepo !== null)
8814
+ return memoizedThisRepo;
8815
+ memoizedThisRepo = runtimeDirForRepo(resolveRepoSync());
8816
+ return memoizedThisRepo;
8817
+ }
8584
8818
 
8585
- // src/lib/log-webhook-drain.ts
8819
+ // src/lib/loop-log.ts
8586
8820
  import {
8587
8821
  closeSync as closeSync2,
8588
8822
  constants as fsConstants2,
8589
- lstatSync,
8823
+ existsSync as existsSync6,
8824
+ fstatSync as fstatSync2,
8590
8825
  mkdirSync as mkdirSync2,
8591
8826
  openSync as openSync2,
8592
- linkSync,
8593
8827
  readFileSync as readFileSync5,
8594
- renameSync,
8828
+ readSync,
8595
8829
  statSync,
8830
+ writeSync
8831
+ } from "node:fs";
8832
+ import { dirname as dirname5 } from "node:path";
8833
+ function loopsRoot() {
8834
+ return runtimeDirForThisRepo();
8835
+ }
8836
+ function loopLogPathFor(_repo, issue, root = loopsRoot()) {
8837
+ return runPath(root, issue, { area: "output", file: "driver.log" });
8838
+ }
8839
+ var LOOP_LOG_MAX_BYTES = 8 * 1024 * 1024;
8840
+ function appendLoopLogLine(path, line) {
8841
+ try {
8842
+ mkdirSync2(dirname5(path), { recursive: true, mode: 448 });
8843
+ const fd = openSync2(path, fsConstants2.O_WRONLY | fsConstants2.O_APPEND | fsConstants2.O_CREAT | fsConstants2.O_NOFOLLOW, 384);
8844
+ try {
8845
+ const stat = fstatSync2(fd);
8846
+ if (stat.isFile() && stat.size < LOOP_LOG_MAX_BYTES) {
8847
+ writeSync(fd, `${line}
8848
+ `);
8849
+ }
8850
+ } finally {
8851
+ closeSync2(fd);
8852
+ }
8853
+ } catch {}
8854
+ }
8855
+
8856
+ // src/lib/log-webhook-drain.ts
8857
+ import {
8858
+ closeSync as closeSync3,
8859
+ constants as fsConstants3,
8860
+ lstatSync,
8861
+ mkdirSync as mkdirSync3,
8862
+ openSync as openSync3,
8863
+ linkSync,
8864
+ readFileSync as readFileSync6,
8865
+ renameSync,
8866
+ statSync as statSync2,
8596
8867
  unlinkSync,
8597
8868
  utimesSync,
8598
8869
  writeFileSync as writeFileSync2,
8599
- writeSync
8870
+ writeSync as writeSync2
8600
8871
  } from "node:fs";
8601
8872
  import { randomUUID } from "node:crypto";
8602
8873
  import { homedir as homedir2 } from "node:os";
8603
- import { dirname as dirname5, join as join7 } from "node:path";
8874
+ import { dirname as dirname6, join as join7 } from "node:path";
8604
8875
  var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
8605
8876
  var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
8606
8877
  var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
@@ -8616,13 +8887,13 @@ function isEnoent(err) {
8616
8887
  var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
8617
8888
  function tryCreateLock(lockPath, token) {
8618
8889
  try {
8619
- mkdirSync2(dirname5(lockPath), { recursive: true, mode: 448 });
8620
- const fd = openSync2(lockPath, fsConstants2.O_WRONLY | fsConstants2.O_CREAT | fsConstants2.O_EXCL, 384);
8890
+ mkdirSync3(dirname6(lockPath), { recursive: true, mode: 448 });
8891
+ const fd = openSync3(lockPath, fsConstants3.O_WRONLY | fsConstants3.O_CREAT | fsConstants3.O_EXCL, 384);
8621
8892
  try {
8622
- writeSync(fd, `${token}
8893
+ writeSync2(fd, `${token}
8623
8894
  `);
8624
8895
  } finally {
8625
- closeSync2(fd);
8896
+ closeSync3(fd);
8626
8897
  }
8627
8898
  return true;
8628
8899
  } catch (err) {
@@ -8637,7 +8908,7 @@ function acquireDrainLock(lockPath) {
8637
8908
  return token;
8638
8909
  let observedMtimeMs;
8639
8910
  try {
8640
- observedMtimeMs = statSync(lockPath).mtimeMs;
8911
+ observedMtimeMs = statSync2(lockPath).mtimeMs;
8641
8912
  } catch (err) {
8642
8913
  if (!isEnoent(err))
8643
8914
  throw err;
@@ -8655,7 +8926,7 @@ function acquireDrainLock(lockPath) {
8655
8926
  }
8656
8927
  let claimedMtimeMs = null;
8657
8928
  try {
8658
- claimedMtimeMs = statSync(claimed).mtimeMs;
8929
+ claimedMtimeMs = statSync2(claimed).mtimeMs;
8659
8930
  } catch (err) {
8660
8931
  if (!isEnoent(err))
8661
8932
  throw err;
@@ -8681,7 +8952,7 @@ function acquireDrainLock(lockPath) {
8681
8952
  function renewDrainLock(lockPath, token) {
8682
8953
  let holder;
8683
8954
  try {
8684
- holder = readFileSync5(lockPath, "utf8").trim();
8955
+ holder = readFileSync6(lockPath, "utf8").trim();
8685
8956
  } catch (err) {
8686
8957
  if (!isEnoent(err))
8687
8958
  throw err;
@@ -8701,7 +8972,7 @@ function renewDrainLock(lockPath, token) {
8701
8972
  }
8702
8973
  function releaseDrainLock(lockPath, token) {
8703
8974
  try {
8704
- const holder = readFileSync5(lockPath, "utf8").trim();
8975
+ const holder = readFileSync6(lockPath, "utf8").trim();
8705
8976
  if (holder !== token)
8706
8977
  return;
8707
8978
  unlinkSync(lockPath);
@@ -8751,7 +9022,7 @@ function queueLines(buf) {
8751
9022
  return lines;
8752
9023
  }
8753
9024
  function removeQueueHead(path, cut) {
8754
- const remaining = readFileSync5(path);
9025
+ const remaining = readFileSync6(path);
8755
9026
  writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
8756
9027
  }
8757
9028
  function queueBucketSize(path) {
@@ -8772,7 +9043,7 @@ function queueBucketSize(path) {
8772
9043
  function readQueueFile(path) {
8773
9044
  if (queueBucketSize(path) === null)
8774
9045
  return null;
8775
- return readFileSync5(path);
9046
+ return readFileSync6(path);
8776
9047
  }
8777
9048
  function rejectLine(rejectedPath, reason, status, identity, raw) {
8778
9049
  const record = JSON.stringify({
@@ -8954,13 +9225,19 @@ function logsCredentialMissing(headers, env) {
8954
9225
  const varPattern = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
8955
9226
  for (const value of Object.values(headers)) {
8956
9227
  for (const match of value.matchAll(varPattern)) {
8957
- if (!env[match[1]])
8958
- return true;
9228
+ const name = match[1];
9229
+ if (env[name])
9230
+ continue;
9231
+ return true;
8959
9232
  }
8960
9233
  }
8961
9234
  return false;
8962
9235
  }
8963
9236
  function resolveLogDestinationFrom(input) {
9237
+ const spoolDir = input.env.VINAYA_LOG_SPOOL_DIR;
9238
+ if (spoolDir !== undefined && spoolDir.trim() !== "") {
9239
+ return { kind: "folder", folder: spoolDir };
9240
+ }
8964
9241
  const local = resolveLogsSetting(input.localConfig);
8965
9242
  let effective = null;
8966
9243
  let fallbackReason;
@@ -9000,23 +9277,72 @@ function resolveLogDestinationFrom(input) {
9000
9277
  const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
9001
9278
  return fallbackReason ? { kind: "folder", folder, fallbackReason } : { kind: "folder", folder };
9002
9279
  }
9003
- var processTrustAnchorOnce;
9004
- function processTrustAnchor() {
9005
- if (processTrustAnchorOnce === undefined)
9006
- processTrustAnchorOnce = safeLoadTrustAnchorConfig();
9007
- return processTrustAnchorOnce;
9280
+ var processTrustAnchorByRepo = new Map;
9281
+ function processTrustAnchor(repoRoot) {
9282
+ const cached = processTrustAnchorByRepo.get(repoRoot);
9283
+ if (cached !== undefined)
9284
+ return cached;
9285
+ const reading = safeLoadTrustAnchorConfig();
9286
+ processTrustAnchorByRepo.set(repoRoot, reading);
9287
+ return reading;
9008
9288
  }
9009
9289
  async function defaultResolveLogDestination(repo, env) {
9010
9290
  const localConfig = loadConfig();
9011
9291
  const unattended = isUnattendedProcess(process.env);
9292
+ const repoRoot = repoRootSync();
9012
9293
  return resolveLogDestinationFrom({
9013
9294
  localConfig,
9014
- trustAnchorConfig: unattended ? await processTrustAnchor() : null,
9295
+ trustAnchorConfig: unattended ? await processTrustAnchor(repoRoot) : null,
9015
9296
  unattended,
9016
9297
  env,
9017
9298
  defaultFolder: join8(await runtimeDirForRepoAsync(repo), "logs"),
9018
- repoRoot: repoRootSync()
9299
+ repoRoot
9300
+ });
9301
+ }
9302
+ function unresolvedLogDestination(env) {
9303
+ if (hostFromEnv(env) === "ci") {
9304
+ return {
9305
+ kind: "none",
9306
+ reason: "the process ended before its log destination was resolved, and a CI job never records to a folder"
9307
+ };
9308
+ }
9309
+ const loaded = loadConfig();
9310
+ const localConfig = loaded?.logs?.url !== undefined ? { ...loaded, logs: undefined } : loaded;
9311
+ const unattended = isUnattendedProcess(process.env);
9312
+ const repoRoot = repoRootSync();
9313
+ const runtimeDir = process.env[RUNTIME_DIR_ENV_KEY] || resolveRuntimeDir({ repo: null, localConfig, trustAnchorConfig: null, unattended, repoRoot });
9314
+ const defaultFolder = join8(runtimeDir, "logs");
9315
+ const resolved = resolveLogDestinationFrom({
9316
+ localConfig,
9317
+ trustAnchorConfig: null,
9318
+ unattended,
9319
+ env,
9320
+ defaultFolder,
9321
+ repoRoot
9019
9322
  });
9323
+ return resolved.kind === "folder" ? resolved : { kind: "folder", folder: defaultFolder };
9324
+ }
9325
+ function folderFallbackStatePath(repo, stateRoot = GLOBAL_VINAYA_HOME) {
9326
+ const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
9327
+ return join8(stateRoot, "fallback", `${dirName}.json`);
9328
+ }
9329
+ function recordFolderFallback(repo, issue, reason, now, runtimeDir, stateRoot = GLOBAL_VINAYA_HOME) {
9330
+ const message = describeFolderFallback(reason);
9331
+ if (issue !== null) {
9332
+ appendLoopLogLine(loopLogPathFor(repo, issue, runtimeDir), `[log] ${message}`);
9333
+ }
9334
+ try {
9335
+ const record = {
9336
+ at: now.toISOString(),
9337
+ reason: message,
9338
+ intendedUrl: reason.intendedUrl,
9339
+ kind: reason.kind
9340
+ };
9341
+ const path = folderFallbackStatePath(repo, stateRoot);
9342
+ mkdirSync4(dirname7(path), { recursive: true, mode: 448 });
9343
+ writeFileSync3(path, `${JSON.stringify(record)}
9344
+ `, { mode: 384 });
9345
+ } catch {}
9020
9346
  }
9021
9347
  function isEnoent2(err) {
9022
9348
  return typeof err === "object" && err !== null && err.code === "ENOENT";
@@ -9130,7 +9456,7 @@ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
9130
9456
  }
9131
9457
  function readVinayaVersion() {
9132
9458
  try {
9133
- const pkg = JSON.parse(readFileSync6(join8(packageRoot(import.meta.url), "package.json"), "utf8"));
9459
+ const pkg = JSON.parse(readFileSync7(join8(packageRoot(import.meta.url), "package.json"), "utf8"));
9134
9460
  return pkg.version ?? "unknown";
9135
9461
  } catch {
9136
9462
  return "unknown";
@@ -9168,6 +9494,7 @@ function defaultStderr(message) {
9168
9494
  }
9169
9495
  var branchIssueFallbackEnabled = true;
9170
9496
  var branchIssueByCwd = new Map;
9497
+ var branchIssueSettledByCwd = new Map;
9171
9498
  function branchIssueRead(key, read, shared) {
9172
9499
  if (!shared)
9173
9500
  return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
@@ -9176,8 +9503,30 @@ function branchIssueRead(key, read, shared) {
9176
9503
  return cached;
9177
9504
  const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9178
9505
  branchIssueByCwd.set(key, reading);
9506
+ reading.then((value) => branchIssueSettledByCwd.set(key, value));
9179
9507
  return reading;
9180
9508
  }
9509
+ var headShaByCwd = new Map;
9510
+ var headShaSettledByCwd = new Map;
9511
+ function headShaRead(key, read, shared) {
9512
+ if (!shared)
9513
+ return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9514
+ const cached = headShaByCwd.get(key);
9515
+ if (cached !== undefined)
9516
+ return cached;
9517
+ const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9518
+ headShaByCwd.set(key, reading);
9519
+ reading.then((value) => headShaSettledByCwd.set(key, value));
9520
+ return reading;
9521
+ }
9522
+ async function resolveHeadSha(cwd) {
9523
+ try {
9524
+ const out = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "HEAD"], { encoding: "utf8" })).stdout.trim();
9525
+ return /^[0-9a-f]{40}$/.test(out) ? out : null;
9526
+ } catch {
9527
+ return null;
9528
+ }
9529
+ }
9181
9530
  function defaultDeps() {
9182
9531
  return {
9183
9532
  outboxRoot: () => join8(GLOBAL_VINAYA_HOME, "outbox"),
@@ -9192,29 +9541,30 @@ function defaultDeps() {
9192
9541
  inputVersions: () => {
9193
9542
  return;
9194
9543
  },
9195
- resolveLogDestination: defaultResolveLogDestination
9544
+ resolveLogDestination: defaultResolveLogDestination,
9545
+ unresolvedLogDestination
9196
9546
  };
9197
9547
  }
9198
- var APPEND_OPEN_FLAGS = fsConstants3.O_WRONLY | fsConstants3.O_APPEND | fsConstants3.O_CREAT | fsConstants3.O_NOFOLLOW | fsConstants3.O_NONBLOCK;
9548
+ var APPEND_OPEN_FLAGS = fsConstants4.O_WRONLY | fsConstants4.O_APPEND | fsConstants4.O_CREAT | fsConstants4.O_NOFOLLOW | fsConstants4.O_NONBLOCK;
9199
9549
  function guardedAppendOpen(path) {
9200
9550
  try {
9201
- return openSync3(path, APPEND_OPEN_FLAGS, 384);
9551
+ return openSync4(path, APPEND_OPEN_FLAGS, 384);
9202
9552
  } catch {
9203
9553
  return;
9204
9554
  }
9205
9555
  }
9206
9556
  function appendHardenedLine(path, line) {
9207
9557
  try {
9208
- mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
9558
+ mkdirSync4(dirname7(path), { recursive: true, mode: 448 });
9209
9559
  const fd = guardedAppendOpen(path);
9210
9560
  if (fd === undefined)
9211
9561
  return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
9212
9562
  try {
9213
- if (!fstatSync2(fd).isFile())
9563
+ if (!fstatSync3(fd).isFile())
9214
9564
  return `target is not a regular file: ${path}`;
9215
- writeSync2(fd, line);
9565
+ writeSync3(fd, line);
9216
9566
  } finally {
9217
- closeSync3(fd);
9567
+ closeSync4(fd);
9218
9568
  }
9219
9569
  return null;
9220
9570
  } catch (err) {
@@ -9224,7 +9574,7 @@ function appendHardenedLine(path, line) {
9224
9574
  function reportRotationOverflow(backupPath, warn) {
9225
9575
  let raw;
9226
9576
  try {
9227
- raw = readFileSync6(backupPath, "utf8");
9577
+ raw = readFileSync7(backupPath, "utf8");
9228
9578
  } catch {
9229
9579
  return;
9230
9580
  }
@@ -9247,7 +9597,7 @@ function reportRotationOverflow(backupPath, warn) {
9247
9597
  }
9248
9598
  function appendLine(path, line, warn) {
9249
9599
  try {
9250
- mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
9600
+ mkdirSync4(dirname7(path), { recursive: true, mode: 448 });
9251
9601
  let fd = guardedAppendOpen(path);
9252
9602
  if (fd === undefined) {
9253
9603
  warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
@@ -9256,14 +9606,14 @@ function appendLine(path, line, warn) {
9256
9606
  }
9257
9607
  let closed = false;
9258
9608
  try {
9259
- const stat = fstatSync2(fd);
9609
+ const stat = fstatSync3(fd);
9260
9610
  if (!stat.isFile()) {
9261
9611
  warn(`vinaya: log outbox target is not a regular file — refusing to write: ${path}
9262
9612
  `);
9263
9613
  return;
9264
9614
  }
9265
9615
  if (stat.size > OUTBOX_MAX_BYTES) {
9266
- closeSync3(fd);
9616
+ closeSync4(fd);
9267
9617
  closed = true;
9268
9618
  const backupPath = path.replace(/\.ndjson$/, ".1.ndjson");
9269
9619
  reportRotationOverflow(backupPath, warn);
@@ -9277,10 +9627,10 @@ function appendLine(path, line, warn) {
9277
9627
  fd = rotated;
9278
9628
  closed = false;
9279
9629
  }
9280
- writeSync2(fd, line);
9630
+ writeSync3(fd, line);
9281
9631
  } finally {
9282
9632
  if (!closed)
9283
- closeSync3(fd);
9633
+ closeSync4(fd);
9284
9634
  }
9285
9635
  } catch (err) {
9286
9636
  warn(`vinaya: log outbox write failed — ${err instanceof Error ? err.message : String(err)}
@@ -9291,12 +9641,14 @@ function createLogSink(overrides = {}) {
9291
9641
  const deps = {
9292
9642
  ...defaultDeps(),
9293
9643
  resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
9644
+ resolveHeadSha: () => resolveHeadSha(deps.cwd()),
9294
9645
  ...overrides
9295
9646
  };
9296
9647
  const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
9297
9648
  const processId = randomUUID2();
9298
9649
  let seq = 0;
9299
9650
  let warned = false;
9651
+ let folderFallbackRecorded = false;
9300
9652
  const warnOnce = (message) => {
9301
9653
  if (warned)
9302
9654
  return;
@@ -9314,6 +9666,7 @@ function createLogSink(overrides = {}) {
9314
9666
  };
9315
9667
  const readerIsReal = overrides.resolveBranchIssue === undefined;
9316
9668
  let ownBranchIssue;
9669
+ let ownBranchIssueSettled = null;
9317
9670
  const branchIssueOnce = (repo) => {
9318
9671
  if (!branchIssueFallbackEnabled)
9319
9672
  return Promise.resolve(null);
@@ -9321,10 +9674,36 @@ function createLogSink(overrides = {}) {
9321
9674
  const read = () => deps.resolveBranchIssue(slug);
9322
9675
  if (readerIsReal)
9323
9676
  return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
9324
- if (ownBranchIssue === undefined)
9677
+ if (ownBranchIssue === undefined) {
9325
9678
  ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
9679
+ ownBranchIssue.then((value) => {
9680
+ ownBranchIssueSettled = value;
9681
+ });
9682
+ }
9326
9683
  return ownBranchIssue;
9327
9684
  };
9685
+ const branchIssueIfSettled = (repo) => {
9686
+ if (!branchIssueFallbackEnabled)
9687
+ return null;
9688
+ if (!readerIsReal)
9689
+ return ownBranchIssueSettled;
9690
+ return branchIssueSettledByCwd.get(`${deps.cwd()}\x00${safeRepoSlug(repo) ?? ""}`) ?? null;
9691
+ };
9692
+ const headShaReaderIsReal = overrides.resolveHeadSha === undefined;
9693
+ let ownHeadSha;
9694
+ let ownHeadShaSettled = null;
9695
+ const headShaOnce = () => {
9696
+ if (headShaReaderIsReal)
9697
+ return headShaRead(deps.cwd(), deps.resolveHeadSha, true);
9698
+ if (ownHeadSha === undefined) {
9699
+ ownHeadSha = headShaRead(deps.cwd(), deps.resolveHeadSha, false);
9700
+ ownHeadSha.then((value) => {
9701
+ ownHeadShaSettled = value;
9702
+ });
9703
+ }
9704
+ return ownHeadSha;
9705
+ };
9706
+ const headShaIfSettled = () => headShaReaderIsReal ? headShaSettledByCwd.get(deps.cwd()) ?? null : ownHeadShaSettled;
9328
9707
  let resolveRepoCache;
9329
9708
  const resolveRepoOnce = () => {
9330
9709
  if (resolveRepoCache === undefined)
@@ -9332,6 +9711,7 @@ function createLogSink(overrides = {}) {
9332
9711
  return resolveRepoCache;
9333
9712
  };
9334
9713
  let contextCache;
9714
+ let settledContext;
9335
9715
  const context = () => {
9336
9716
  if (contextCache === undefined) {
9337
9717
  const env = deps.env();
@@ -9340,11 +9720,16 @@ function createLogSink(overrides = {}) {
9340
9720
  doctrine()
9341
9721
  ]).then(async ([resolved, doctrineValue]) => {
9342
9722
  const repo = resolved && isSafeRepoSegment3(resolved.owner) && isSafeRepoSegment3(resolved.repo) ? resolved : null;
9343
- return { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
9723
+ settledContext = { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
9724
+ return settledContext;
9344
9725
  });
9345
9726
  }
9346
9727
  return contextCache;
9347
9728
  };
9729
+ const resetContext = () => {
9730
+ contextCache = undefined;
9731
+ settledContext = undefined;
9732
+ };
9348
9733
  let drainChain = Promise.resolve();
9349
9734
  const pendingWrites = new Set;
9350
9735
  let writeChain = Promise.resolve();
@@ -9356,63 +9741,88 @@ function createLogSink(overrides = {}) {
9356
9741
  `);
9357
9742
  });
9358
9743
  };
9359
- function log(e) {
9360
- try {
9361
- const env = deps.env();
9362
- const host = hostFromEnv(env);
9363
- const now = deps.now();
9364
- const mySeq = seq++;
9365
- const envFields = {
9744
+ const snapshot = () => {
9745
+ const env = deps.env();
9746
+ return {
9747
+ host: hostFromEnv(env),
9748
+ now: deps.now(),
9749
+ seq: seq++,
9750
+ envFields: {
9366
9751
  role: env.VINAYA_ROLE,
9367
9752
  task: env.VINAYA_TASK,
9368
9753
  round: env.VINAYA_ROUND,
9754
+ pr: env.VINAYA_PR,
9369
9755
  run: env.VINAYA_RUN || runId,
9370
9756
  attempt: env.VINAYA_ATTEMPT,
9371
- parent: env.VINAYA_PARENT_EVENT
9372
- };
9373
- const write = async () => {
9374
- const { repo, doctrine: doctrineValue, destination: resolvedDestination } = await context();
9375
- if (resolvedDestination.kind === "none") {
9376
- warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
9757
+ parent: env.VINAYA_PARENT_EVENT,
9758
+ workRef: env.VINAYA_WORK_REF,
9759
+ flow: env.VINAYA_FLOW,
9760
+ flowVersion: env.VINAYA_FLOW_VERSION,
9761
+ runtime: env.VINAYA_RUNTIME,
9762
+ source: env.VINAYA_SOURCE
9763
+ }
9764
+ };
9765
+ };
9766
+ const writeEvent = (e, call, ctx, branchIssue, headSha, deliver) => {
9767
+ const { repo, doctrine: doctrineValue, destination } = ctx;
9768
+ if (destination.kind === "none") {
9769
+ warnOnce(`vinaya: not recording — ${destination.reason}
9377
9770
  `);
9378
- return;
9379
- }
9380
- if (resolvedDestination.kind === "folder" && resolvedDestination.fallbackReason) {
9381
- warnOnce(`vinaya: ${describeFolderFallback(resolvedDestination.fallbackReason)}
9771
+ return;
9772
+ }
9773
+ if (destination.kind === "folder" && destination.fallbackReason) {
9774
+ warnOnce(`vinaya: ${describeFolderFallback(destination.fallbackReason)}
9382
9775
  `);
9383
- }
9384
- const branchIssue = envFields.task ? null : await branchIssueOnce(repo);
9385
- const header = buildHeader({
9386
- now,
9387
- runId,
9388
- seq: mySeq,
9389
- repo: repo ? `${repo.owner}/${repo.repo}` : null,
9390
- vinaya: deps.vinayaVersion(),
9391
- doctrine: doctrineValue,
9392
- host,
9393
- hostname: deps.hostname(),
9394
- env: envFields,
9395
- branchIssue,
9396
- eventId: randomUUID2(),
9397
- processId,
9398
- inputVersions: deps.inputVersions()
9399
- });
9400
- const full = { ...e, ...header };
9401
- const parsed = LogEventSchema.safeParse(full);
9402
- if (!parsed.success) {
9403
- warnOnce(`vinaya: log() refused an invalid payload — ${parsed.error.issues[0]?.message ?? "schema violation"}
9776
+ }
9777
+ const built = buildHeader({
9778
+ now: call.now,
9779
+ runId,
9780
+ seq: call.seq,
9781
+ repo: repo ? `${repo.owner}/${repo.repo}` : null,
9782
+ vinaya: deps.vinayaVersion(),
9783
+ doctrine: doctrineValue,
9784
+ host: call.host,
9785
+ hostname: deps.hostname(),
9786
+ env: call.envFields,
9787
+ branchIssue,
9788
+ eventId: randomUUID2(),
9789
+ processId,
9790
+ inputVersions: deps.inputVersions()
9791
+ });
9792
+ const header = headSha === null ? built : { ...built, subject: { ...built.subject, sha: headSha } };
9793
+ if (destination.kind === "folder" && destination.fallbackReason && !folderFallbackRecorded) {
9794
+ folderFallbackRecorded = true;
9795
+ recordFolderFallback(repo, header.subject.issue, destination.fallbackReason, call.now, dirname7(destination.folder), join8(deps.home(), ".vinaya"));
9796
+ }
9797
+ const full = { ...e, ...header };
9798
+ const parsed = LogEventSchema.safeParse(full);
9799
+ if (!parsed.success) {
9800
+ warnOnce(`vinaya: log() refused an invalid payload — ${parsed.error.issues[0]?.message ?? "schema violation"}
9404
9801
  `);
9405
- return;
9406
- }
9407
- const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
9802
+ return;
9803
+ }
9804
+ const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
9408
9805
  `;
9409
- const destination = resolvedDestination;
9410
- if (destination.kind === "server") {
9411
- appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
9412
- scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
9413
- } else {
9414
- appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
9806
+ if (destination.kind === "server") {
9807
+ appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
9808
+ if (deliver)
9809
+ scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
9810
+ } else {
9811
+ appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
9812
+ }
9813
+ };
9814
+ function log(e) {
9815
+ try {
9816
+ const call = snapshot();
9817
+ const write = async () => {
9818
+ const ctx = await context();
9819
+ if (ctx.destination.kind === "none") {
9820
+ writeEvent(e, call, ctx, null, null, true);
9821
+ return;
9415
9822
  }
9823
+ const branchIssue = call.envFields.task ? null : await branchIssueOnce(ctx.repo);
9824
+ const headSha = e.kind === "gate" ? await headShaOnce() : null;
9825
+ writeEvent(e, call, ctx, branchIssue, headSha, true);
9416
9826
  };
9417
9827
  const written = writeChain.then(write).catch((err) => {
9418
9828
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
@@ -9423,6 +9833,26 @@ function createLogSink(overrides = {}) {
9423
9833
  written.finally(() => pendingWrites.delete(written));
9424
9834
  } catch (err) {
9425
9835
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
9836
+ `);
9837
+ }
9838
+ }
9839
+ function logSync(e, opts = {}) {
9840
+ try {
9841
+ const call = snapshot();
9842
+ let ctx = settledContext;
9843
+ if (ctx === undefined) {
9844
+ const destination = deps.unresolvedLogDestination(deps.env());
9845
+ if (destination.kind === "folder" && !opts.quiet) {
9846
+ 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
9847
+ `);
9848
+ }
9849
+ ctx = { repo: null, doctrine: "unknown", destination };
9850
+ }
9851
+ const branchIssue = ctx.destination.kind === "none" || call.envFields.task ? null : branchIssueIfSettled(ctx.repo);
9852
+ const headSha = e.kind === "gate" && ctx.destination.kind !== "none" ? headShaIfSettled() : null;
9853
+ writeEvent(e, call, ctx, branchIssue, headSha, false);
9854
+ } catch (err) {
9855
+ warnOnce(`vinaya: logSync() failed — ${err instanceof Error ? err.message : String(err)}
9426
9856
  `);
9427
9857
  }
9428
9858
  }
@@ -9443,7 +9873,7 @@ function createLogSink(overrides = {}) {
9443
9873
  return;
9444
9874
  });
9445
9875
  };
9446
- return { log, runId, warmup, drain };
9876
+ return { log, logSync, runId, warmup, drain, resetContext };
9447
9877
  }
9448
9878
  var defaultSink = createLogSink();
9449
9879
 
@@ -9576,7 +10006,7 @@ function findingsInThisDiff(findings) {
9576
10006
  const abs = resolve2(diff.root, f.file);
9577
10007
  if (!changed.has(abs))
9578
10008
  return false;
9579
- const relPath = relative(diff.root, abs);
10009
+ const relPath = relative2(diff.root, abs);
9580
10010
  if (!ranges.has(relPath))
9581
10011
  ranges.set(relPath, changedLineRanges(diff.base, relPath));
9582
10012
  const fileRanges = ranges.get(relPath) ?? null;
@@ -9606,7 +10036,7 @@ function collectWorkingTree(dir, out = []) {
9606
10036
  const full = join10(dir, name);
9607
10037
  let isDir;
9608
10038
  try {
9609
- isDir = statSync2(full).isDirectory();
10039
+ isDir = statSync3(full).isDirectory();
9610
10040
  } catch {
9611
10041
  continue;
9612
10042
  }
@@ -9621,7 +10051,7 @@ function collectWorkingTree(dir, out = []) {
9621
10051
  return out;
9622
10052
  }
9623
10053
  function readWorkingTree(paths) {
9624
- return paths.map((p) => ({ path: p, content: readFileSync7(p, "utf8") }));
10054
+ return paths.map((p) => ({ path: p, content: readFileSync8(p, "utf8") }));
9625
10055
  }
9626
10056
  function collectAtRef(ref, dir) {
9627
10057
  const listing = git2(["ls-tree", "-r", "--name-only", ref, "--", dir]);