@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-exec-bits.ts
4
4
  import { execFileSync as execFileSync8 } from "node:child_process";
5
- import { readFileSync as readFileSync7 } from "node:fs";
5
+ import { readFileSync as readFileSync8 } from "node:fs";
6
6
 
7
7
  // src/checks/contract.ts
8
8
  var CHECK_SCHEMA_VERSION = 1;
@@ -13,7 +13,7 @@ function emitCheckError(error) {
13
13
 
14
14
  // src/lib/diff-evidence.ts
15
15
  import { execFileSync as execFileSync7 } from "node:child_process";
16
- import { join as join9, relative, resolve as resolve2 } from "node:path";
16
+ import { join as join9, relative as relative2, resolve as resolve2 } from "node:path";
17
17
  // ../../packages/aeg-core/src/gate-audience.ts
18
18
  var GATE_AUDIENCE = {
19
19
  "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
@@ -1897,45 +1897,6 @@ var DERIVED_STATUSES = [
1897
1897
  "incoherent"
1898
1898
  ];
1899
1899
  var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
1900
- // ../../packages/aeg-core/src/parse-ledger.ts
1901
- function rowFromCells(cells) {
1902
- if (cells.length < 7)
1903
- return null;
1904
- const phase = (cells[0] ?? "").trim();
1905
- if (!phase)
1906
- return null;
1907
- return {
1908
- phase,
1909
- role: (cells[1] ?? "").trim(),
1910
- agentModel: (cells[2] ?? "").trim(),
1911
- tokensIn: parseIntCell(cells[3] ?? ""),
1912
- tokensOut: parseIntCell(cells[4] ?? ""),
1913
- cost: parseCostCell(cells[5] ?? ""),
1914
- date: (cells[6] ?? "").trim()
1915
- };
1916
- }
1917
- function parseIntCell(cell) {
1918
- const trimmed = cell.replace(/`/g, "").trim();
1919
- if (!trimmed || isEmDashOrDash(trimmed))
1920
- return null;
1921
- const normalized = trimmed.replace(/[,_\s]/g, "");
1922
- if (!/^-?\d+$/.test(normalized))
1923
- return null;
1924
- return Number(normalized);
1925
- }
1926
- function parseCostCell(cell) {
1927
- const trimmed = cell.replace(/`/g, "").trim();
1928
- if (!trimmed || isEmDashOrDash(trimmed))
1929
- return null;
1930
- const normalized = trimmed.replace(/^\$/, "").replace(/[,_\s]/g, "");
1931
- if (!/^-?\d+(\.\d+)?$/.test(normalized))
1932
- return null;
1933
- return Number(normalized);
1934
- }
1935
- function isEmDashOrDash(s) {
1936
- const t = s.trim();
1937
- return t === "—" || t === "-" || t === "–";
1938
- }
1939
1900
  // ../../packages/aeg-core/src/waiver-label.ts
1940
1901
  var WAIVER_LABEL = label("waiver-docs");
1941
1902
  var WAIVER_LABEL_REVIEW = label("waiver-review");
@@ -1951,61 +1912,6 @@ function isWaiverLabelActorVerified(opts) {
1951
1912
  return false;
1952
1913
  return isPrincipal(opts.labelActor, opts.principalAllowlist);
1953
1914
  }
1954
-
1955
- // ../../packages/aeg-core/src/parse-token-report.ts
1956
- var TOKEN_REPORT_HEADING = /^\s*(?:#{1,6}\s*Token report\s*|\*\*Token report\*\*)\s*$/i;
1957
- 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;
1958
- function parseTokenReportEntries(body) {
1959
- const lines = body.split(/\r?\n/);
1960
- const headingIdxs = [];
1961
- lines.forEach((line, i) => {
1962
- if (TOKEN_REPORT_HEADING.test(line))
1963
- headingIdxs.push(i);
1964
- });
1965
- const out = [];
1966
- for (let h = 0;h < headingIdxs.length; h++) {
1967
- const start = headingIdxs[h] + 1;
1968
- const end = h + 1 < headingIdxs.length ? headingIdxs[h + 1] : lines.length;
1969
- const section = lines.slice(start, end).join(`
1970
- `);
1971
- const tableRows = parseTableSection(section);
1972
- if (tableRows.length > 0) {
1973
- out.push(...tableRows);
1974
- continue;
1975
- }
1976
- const inlineRow = parseInlineFieldList(section);
1977
- if (inlineRow)
1978
- out.push(inlineRow);
1979
- }
1980
- return out;
1981
- }
1982
- function parseTableSection(section) {
1983
- const lines = section.split(/\r?\n/);
1984
- let i = 0;
1985
- for (;i < lines.length; i++) {
1986
- if ((lines[i] ?? "").trim().startsWith("|"))
1987
- break;
1988
- }
1989
- if (i + 1 >= lines.length)
1990
- return [];
1991
- i += 2;
1992
- const out = [];
1993
- for (;i < lines.length; i++) {
1994
- const trimmed = (lines[i] ?? "").trim();
1995
- if (!trimmed.startsWith("|"))
1996
- break;
1997
- const row = rowFromCells(splitTableRow(trimmed));
1998
- if (row)
1999
- out.push(row);
2000
- }
2001
- return out;
2002
- }
2003
- function parseInlineFieldList(section) {
2004
- const m = section.match(INLINE_FIELD_LIST);
2005
- if (!m)
2006
- return null;
2007
- return rowFromCells([m[1], m[2], m[3], m[4], m[5], m[6], m[7]]);
2008
- }
2009
1915
  // ../../packages/aeg-core/src/verdict-extraction.ts
2010
1916
  var HEAD_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged head:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
2011
1917
  var OBJECTIVES_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Objectives version:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
@@ -2454,10 +2360,12 @@ function evaluateC5(changed, docOwnersContent, prBody, fileExists, waiverActive,
2454
2360
  var CODE_REVIEW_SEVERITY_ORDER = ["BLOCKER", "MAJOR", "MINOR"];
2455
2361
  var SECURITY_SEVERITY_ORDER = ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
2456
2362
  var DEFAULT_MAX_ROUNDS = 3;
2363
+ var DEFAULT_MAX_TASK_MINUTES = 180;
2457
2364
  var DEFAULT_REVIEW_POLICY = {
2458
2365
  codeReviewThreshold: "BLOCKER",
2459
2366
  securityThreshold: "HIGH",
2460
- maxRounds: DEFAULT_MAX_ROUNDS
2367
+ maxRounds: DEFAULT_MAX_ROUNDS,
2368
+ maxTaskMinutes: DEFAULT_MAX_TASK_MINUTES
2461
2369
  };
2462
2370
  var FILE_SHAPED_LOCATION = /\.[a-zA-Z0-9]{1,10}(:\d+)?\s*$/;
2463
2371
  var PROSE_LOCATION_PATTERNS = [/\bpr\s*body\b/i, /\bcomment\b/i];
@@ -2858,11 +2766,13 @@ function checkDocUpdateList(prBody) {
2858
2766
  return headingCheck(prBody, "(?:documentation|doc)[- ]update(?:\\s+list)?", "Documentation-update list");
2859
2767
  }
2860
2768
  function checkWorktreeStep0(prBody) {
2861
- if (/git worktree add/.test(prBody))
2769
+ if (/git worktree add/.test(prBody) || /cd \.worktrees\//.test(prBody) || /bun install --frozen-lockfile/.test(prBody))
2862
2770
  return { status: "pass", errors: [] };
2863
2771
  return {
2864
2772
  status: "fail",
2865
- errors: ["brief-validation worktree Step 0: no `git worktree add` command found in the PR body."]
2773
+ errors: [
2774
+ "brief-validation worktree Step 0: no `git worktree add`, `cd .worktrees/`, or `bun install --frozen-lockfile` command found in the PR body."
2775
+ ]
2866
2776
  };
2867
2777
  }
2868
2778
  function checkStopConditions(prBody) {
@@ -3052,7 +2962,8 @@ function isCommandBlock(content) {
3052
2962
  return COMMAND_WORDS.includes(commandWordOf(firstNonBlankLine(content)));
3053
2963
  }
3054
2964
  function isStep0Block(content) {
3055
- return firstNonBlankLine(content).startsWith("git worktree add");
2965
+ const first = firstNonBlankLine(content);
2966
+ return first.startsWith("git worktree add") || first.startsWith("cd .worktrees/") || first.startsWith("bun install --frozen-lockfile");
3056
2967
  }
3057
2968
  function checkCommandsCarryOutput(prBody) {
3058
2969
  const errors = [];
@@ -3521,10 +3432,14 @@ function legacySlugPattern(legacySlugs) {
3521
3432
  const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
3522
3433
  return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
3523
3434
  }
3435
+ function specGrandfatherPaths(specGrandfather) {
3436
+ return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
3437
+ }
3524
3438
  function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
3525
3439
  const findings = [];
3526
3440
  const legacyPattern = legacySlugPattern(legacySlugs);
3527
- const grandfathered = new Set(specGrandfather);
3441
+ const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
3442
+ const limits = new Map(Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather));
3528
3443
  const patterns = [
3529
3444
  { pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
3530
3445
  { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
@@ -3543,18 +3458,19 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
3543
3458
  continue;
3544
3459
  if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
3545
3460
  continue;
3546
- if (cls === "spec" && grandfathered.has(file.path))
3461
+ if (cls === "spec" && grandfatheredWhole.has(file.path))
3547
3462
  continue;
3548
3463
  const blocking = cls === "product" || cls === "spec";
3549
3464
  const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
3550
3465
  const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
3466
+ const fileFindings = [];
3551
3467
  for (const { pattern, what, group } of patternsToRun) {
3552
3468
  pattern.lastIndex = 0;
3553
3469
  let match = pattern.exec(scrubbed);
3554
3470
  while (match !== null) {
3555
3471
  const cited = group !== undefined ? match[group] ?? match[0] : match[0];
3556
3472
  const citedIndex = match.index + match[0].indexOf(cited);
3557
- findings.push({
3473
+ fileFindings.push({
3558
3474
  file: file.path,
3559
3475
  line: lineAt(scrubbed, citedIndex),
3560
3476
  message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
@@ -3563,6 +3479,15 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
3563
3479
  match = pattern.exec(scrubbed);
3564
3480
  }
3565
3481
  }
3482
+ const limit = cls === "spec" ? limits.get(file.path) : undefined;
3483
+ if (limit !== undefined) {
3484
+ if (fileFindings.length <= limit)
3485
+ continue;
3486
+ for (const f of fileFindings) {
3487
+ f.message += `; ${file.path} carries ${fileFindings.length} such findings, over its proseGates.specGrandfather limit of ${limit}`;
3488
+ }
3489
+ }
3490
+ findings.push(...fileFindings);
3566
3491
  }
3567
3492
  return findings;
3568
3493
  }
@@ -4522,8 +4447,7 @@ function briefHash(brief) {
4522
4447
  function policyDigest(policy) {
4523
4448
  return createHash4("sha256").update(JSON.stringify({
4524
4449
  codeReviewThreshold: policy.codeReviewThreshold,
4525
- securityThreshold: policy.securityThreshold,
4526
- maxRounds: policy.maxRounds
4450
+ securityThreshold: policy.securityThreshold
4527
4451
  })).digest("hex");
4528
4452
  }
4529
4453
  function isBoundToHead(echoed, headSha) {
@@ -4836,7 +4760,46 @@ function parseEnforcementRegistry(content) {
4836
4760
  return result;
4837
4761
  }
4838
4762
  // ../../packages/aeg-core/src/registry-checks.ts
4839
- function checkG1(rows, existsFn) {
4763
+ var HOOK_DIR_PREFIXES = [".claude/hooks/", ".vinaya/hooks/", ".husky/", ".git/hooks/"];
4764
+ var BARE_HOOK_NAME = /^check-[A-Za-z0-9_.-]*\.sh$/;
4765
+ function basename(path) {
4766
+ return path.slice(path.lastIndexOf("/") + 1);
4767
+ }
4768
+ function lineOf(content, index) {
4769
+ let line = 1;
4770
+ for (let i = 0;i < index; i++)
4771
+ if (content.charCodeAt(i) === 10)
4772
+ line++;
4773
+ return line;
4774
+ }
4775
+ function findUnshippedHookRefs(docs, shipped) {
4776
+ const shippedNames = new Set([...shipped].map(basename));
4777
+ const findings = [];
4778
+ const flag = (doc, token, index) => {
4779
+ findings.push({
4780
+ path: doc.path,
4781
+ reason: `${doc.path}:${lineOf(doc.content, index)} names hook "${token}", which is neither tracked in git nor emitted by \`vinaya init\``
4782
+ });
4783
+ };
4784
+ for (const doc of docs) {
4785
+ for (const { cited, index } of extractCitedPaths(doc.content)) {
4786
+ if (cited.endsWith("/") || !HOOK_DIR_PREFIXES.some((p) => cited.startsWith(p)))
4787
+ continue;
4788
+ if (!shipped.has(cited))
4789
+ flag(doc, cited, index);
4790
+ }
4791
+ const spanPattern = /`([^`\n]+)`/g;
4792
+ let match = spanPattern.exec(doc.content);
4793
+ while (match !== null) {
4794
+ const token = match[1] ?? "";
4795
+ if (BARE_HOOK_NAME.test(token) && !shippedNames.has(token))
4796
+ flag(doc, token, match.index);
4797
+ match = spanPattern.exec(doc.content);
4798
+ }
4799
+ }
4800
+ return findings;
4801
+ }
4802
+ function checkG1(rows, existsFn, hookRefs) {
4840
4803
  const findings = [];
4841
4804
  for (const row of rows) {
4842
4805
  if (row.implementation === "")
@@ -4849,6 +4812,8 @@ function checkG1(rows, existsFn) {
4849
4812
  });
4850
4813
  }
4851
4814
  }
4815
+ if (hookRefs)
4816
+ findings.push(...findUnshippedHookRefs(hookRefs.docs, hookRefs.shipped));
4852
4817
  return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
4853
4818
  }
4854
4819
  var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
@@ -5402,7 +5367,6 @@ var TaskPrPauseSchema = z.object({
5402
5367
  var TaskPrReviewRecordSchema = z.object({
5403
5368
  verdicts: z.array(TaskPrVerdictSchema),
5404
5369
  roundMarkers: z.array(z.number().int().nonnegative()),
5405
- summaryTable: z.string().nullable(),
5406
5370
  pause: TaskPrPauseSchema.nullable()
5407
5371
  });
5408
5372
  var TaskPrReadInputSchema = z.object({
@@ -5449,16 +5413,6 @@ var TaskCancelResultSchema = z.object({
5449
5413
  authenticatedFrom: z.string().min(1),
5450
5414
  fencedEffectKeys: z.array(z.string())
5451
5415
  });
5452
- var TASK_TOOL_NAMES = [
5453
- "task_start",
5454
- "task_status",
5455
- "task_escalation_read",
5456
- "task_pr_read",
5457
- "task_resume",
5458
- "task_cancel"
5459
- ];
5460
- var OPERATOR_STATUS_FOLLOW = "task_status_follow";
5461
- var OPERATOR_TOOL_GRANT = [...TASK_TOOL_NAMES, OPERATOR_STATUS_FOLLOW];
5462
5416
  // ../../packages/aeg-core/src/first-push-dispatch-gate.ts
5463
5417
  function parseTaskBranch(branch) {
5464
5418
  const m = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
@@ -5689,15 +5643,69 @@ var NO_GATE_CUTOVERS = {
5689
5643
  briefRulesSincePr: null,
5690
5644
  agentBoxesRefusedSincePr: null
5691
5645
  };
5692
- // ../../packages/aeg-core/src/dev-review-loop/types.ts
5693
- var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5694
- // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
5695
- var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
5696
- // ../../packages/aeg-core/src/log/envelope.ts
5697
- import { createHash as createHash5 } from "node:crypto";
5698
-
5699
5646
  // ../../packages/aeg-core/src/log/schema.ts
5647
+ import { z as z3 } from "zod";
5648
+
5649
+ // ../../packages/aeg-core/src/log/custom.ts
5700
5650
  import { z as z2 } from "zod";
5651
+ var CUSTOM_EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]*\.[a-z][a-z0-9_.]*$/;
5652
+ var CUSTOM_EVENT_NAME_MAX_LENGTH = 64;
5653
+ var CUSTOM_EVENT_RESERVED_NAMESPACE = "vinaya";
5654
+ var CUSTOM_EVENT_MAX_FIELDS = 20;
5655
+ var CUSTOM_FIELD_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
5656
+ var CUSTOM_FIELD_NAME_MAX_LENGTH = 64;
5657
+ var CUSTOM_TEXT_MAX_LENGTH = 500;
5658
+ var CUSTOM_WORD_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
5659
+ var CUSTOM_WORD_MAX_LENGTH = 64;
5660
+ var CUSTOM_FIELD_MAX_WORDS = 50;
5661
+ var CustomFieldTypeSchema = z2.union([z2.enum(["text", "number", "boolean"]), z2.array(z2.string())]);
5662
+ var CustomEventDeclarationsSchema = z2.record(z2.string(), z2.object({
5663
+ fields: z2.record(z2.string(), CustomFieldTypeSchema)
5664
+ }).strict()).superRefine((events, ctx) => {
5665
+ for (const [name, declaration] of Object.entries(events)) {
5666
+ const refuse = (message, path = []) => {
5667
+ ctx.addIssue({
5668
+ code: z2.ZodIssueCode.custom,
5669
+ path: [name, ...path],
5670
+ message: `logs.events "${name}": ${message}`
5671
+ });
5672
+ };
5673
+ if (name.length > CUSTOM_EVENT_NAME_MAX_LENGTH) {
5674
+ refuse(`the name must be at most ${CUSTOM_EVENT_NAME_MAX_LENGTH} characters`);
5675
+ }
5676
+ if (!CUSTOM_EVENT_NAME_PATTERN.test(name)) {
5677
+ refuse("the name must be `<namespace>.<event>` — lowercase letters, digits and `_`, a dot between them");
5678
+ } else if (name.split(".")[0] === CUSTOM_EVENT_RESERVED_NAMESPACE) {
5679
+ refuse(`the \`${CUSTOM_EVENT_RESERVED_NAMESPACE}.\` namespace is reserved for Vinaya's own events`);
5680
+ }
5681
+ const fieldEntries = Object.entries(declaration.fields);
5682
+ if (fieldEntries.length > CUSTOM_EVENT_MAX_FIELDS) {
5683
+ refuse(`at most ${CUSTOM_EVENT_MAX_FIELDS} fields may be declared (found ${fieldEntries.length})`, ["fields"]);
5684
+ }
5685
+ for (const [field, type] of fieldEntries) {
5686
+ if (field.length > CUSTOM_FIELD_NAME_MAX_LENGTH || !CUSTOM_FIELD_NAME_PATTERN.test(field)) {
5687
+ 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]);
5688
+ }
5689
+ if (typeof type === "string")
5690
+ continue;
5691
+ if (type.length === 0) {
5692
+ refuse(`field "${field}": a list of words must name at least one word`, ["fields", field]);
5693
+ }
5694
+ if (type.length > CUSTOM_FIELD_MAX_WORDS) {
5695
+ refuse(`field "${field}": a list of words may name at most ${CUSTOM_FIELD_MAX_WORDS}`, ["fields", field]);
5696
+ }
5697
+ const bad = type.filter((w) => w.length > CUSTOM_WORD_MAX_LENGTH || !CUSTOM_WORD_PATTERN.test(w));
5698
+ if (bad.length > 0) {
5699
+ refuse(`field "${field}": a listed word is lowercase letters, digits, \`_\` and \`-\`, at most ${CUSTOM_WORD_MAX_LENGTH} characters`, ["fields", field]);
5700
+ }
5701
+ if (new Set(type).size !== type.length) {
5702
+ refuse(`field "${field}": a list of words names a word twice`, ["fields", field]);
5703
+ }
5704
+ }
5705
+ }
5706
+ });
5707
+
5708
+ // ../../packages/aeg-core/src/log/schema.ts
5701
5709
  var CONFIDENCE_REASON_MAX_LENGTH = 280;
5702
5710
  var ROLE_VALUES = [
5703
5711
  "planner",
@@ -5708,178 +5716,210 @@ var ROLE_VALUES = [
5708
5716
  "archivist",
5709
5717
  "architect"
5710
5718
  ];
5711
- var RoleSchema = z2.enum(ROLE_VALUES);
5719
+ var RoleSchema = z3.enum(ROLE_VALUES);
5712
5720
  var HOST_VALUES = ["hook", "ci", "cli", "loop"];
5713
- var HostSchema = z2.enum(HOST_VALUES);
5721
+ var HostSchema = z3.enum(HOST_VALUES);
5714
5722
  var RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
5715
5723
  var headerMetaCore = {
5716
- ts: z2.string(),
5717
- run_id: z2.string().regex(RUN_ID_PATTERN),
5718
- seq: z2.number().int().nonnegative(),
5719
- repo: z2.string().nullable(),
5720
- vinaya: z2.string(),
5721
- doctrine: z2.string(),
5724
+ ts: z3.string(),
5725
+ run_id: z3.string().regex(RUN_ID_PATTERN),
5726
+ seq: z3.number().int().nonnegative(),
5727
+ repo: z3.string().nullable(),
5728
+ vinaya: z3.string(),
5729
+ doctrine: z3.string(),
5722
5730
  host: HostSchema,
5723
- machine: z2.string()
5731
+ machine: z3.string()
5724
5732
  };
5725
- var HeaderMetaV1Schema = z2.object({
5726
- schema: z2.literal(1),
5733
+ var HeaderMetaV1Schema = z3.object({
5734
+ schema: z3.literal(1),
5727
5735
  ...headerMetaCore
5728
5736
  }).strict();
5729
- var LineageSchema = z2.object({
5730
- run: z2.string().nullable(),
5731
- attempt: z2.number().int().nullable(),
5732
- parent: z2.string().nullable()
5737
+ var LineageSchema = z3.object({
5738
+ run: z3.string().nullable(),
5739
+ attempt: z3.number().int().nullable(),
5740
+ parent: z3.string().nullable()
5733
5741
  }).strict();
5734
- var InputVersionsSchema = z2.object({
5735
- objectives_version: z2.string().nullable(),
5736
- brief_hash: z2.string().nullable(),
5737
- ruling_ordinal: z2.number().int().nullable(),
5738
- policy_digest: z2.string().nullable()
5742
+ var InputVersionsSchema = z3.object({
5743
+ objectives_version: z3.string().nullable(),
5744
+ brief_hash: z3.string().nullable(),
5745
+ ruling_ordinal: z3.number().int().nullable(),
5746
+ policy_digest: z3.string().nullable()
5739
5747
  }).strict();
5740
- var ProvenanceSchema = z2.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
5741
- var HeaderMetaV2Schema = z2.object({
5742
- schema: z2.literal(2),
5748
+ var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
5749
+ var HeaderMetaV2Schema = z3.object({
5750
+ schema: z3.literal(2),
5743
5751
  ...headerMetaCore,
5744
- event_id: z2.string().min(1),
5745
- process_id: z2.string().min(1),
5746
- actor_id: z2.string().nullable(),
5752
+ event_id: z3.string().min(1),
5753
+ process_id: z3.string().min(1),
5754
+ actor_id: z3.string().nullable(),
5747
5755
  lineage: LineageSchema,
5748
5756
  input_versions: InputVersionsSchema,
5749
5757
  provenance: ProvenanceSchema
5750
5758
  }).strict();
5751
- var HeaderMetaSchema = z2.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema]);
5752
- var SubjectSchema = z2.object({
5753
- issue: z2.number().int().nullable(),
5754
- pr: z2.number().int().optional(),
5755
- sha: z2.string().optional(),
5756
- role: z2.union([RoleSchema, z2.literal("unattributed")]),
5757
- round: z2.number().int().optional(),
5758
- objectives_version: z2.string().optional()
5759
+ var WorkSchema = z3.object({
5760
+ ref: z3.string().nullable(),
5761
+ repo: z3.string().nullable(),
5762
+ change: z3.string().nullable(),
5763
+ revision: z3.string().nullable()
5764
+ }).strict();
5765
+ var FlowSchema = z3.object({
5766
+ id: z3.string().nullable(),
5767
+ version: z3.string().nullable()
5759
5768
  }).strict();
5760
- var HeaderSchema = z2.object({
5769
+ var HeaderMetaV3Schema = z3.object({
5770
+ schema: z3.literal(3),
5771
+ ...headerMetaCore,
5772
+ event_id: z3.string().min(1),
5773
+ process_id: z3.string().min(1),
5774
+ actor_id: z3.string().nullable(),
5775
+ lineage: LineageSchema,
5776
+ input_versions: InputVersionsSchema,
5777
+ provenance: ProvenanceSchema,
5778
+ work: WorkSchema,
5779
+ flow: FlowSchema,
5780
+ runtime: z3.string().nullable(),
5781
+ source: z3.string().nullable()
5782
+ }).strict();
5783
+ var HeaderMetaSchema = z3.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema, HeaderMetaV3Schema]);
5784
+ var SubjectSchema = z3.object({
5785
+ issue: z3.number().int().nullable(),
5786
+ pr: z3.number().int().optional(),
5787
+ sha: z3.string().optional(),
5788
+ role: z3.union([RoleSchema, z3.literal("unattributed")]),
5789
+ round: z3.number().int().optional(),
5790
+ objectives_version: z3.string().optional()
5791
+ }).strict();
5792
+ var HeaderSchema = z3.object({
5761
5793
  meta: HeaderMetaSchema,
5762
5794
  subject: SubjectSchema
5763
5795
  }).strict();
5764
5796
  var envelopeTail = {
5765
- duration_ms: z2.number().nonnegative().optional(),
5766
- payload: z2.object({}).strict()
5797
+ duration_ms: z3.number().nonnegative().optional(),
5798
+ payload: z3.object({}).strict()
5767
5799
  };
5768
- var ReviewFindingSchema = z2.object({
5769
- id: z2.string(),
5770
- severity: z2.string(),
5771
- state: z2.string().optional(),
5772
- severity_scale: z2.string().optional(),
5773
- policy_treatment: z2.enum(["blocking", "non_blocking", "unavailable"]).optional(),
5774
- confidence: z2.number().min(0).max(1).optional(),
5775
- confidence_scale: z2.string().optional(),
5776
- confidence_source: z2.string().optional()
5800
+ var ReviewFindingSchema = z3.object({
5801
+ id: z3.string(),
5802
+ severity: z3.string(),
5803
+ state: z3.string().optional(),
5804
+ severity_scale: z3.string().optional(),
5805
+ policy_treatment: z3.enum(["blocking", "non_blocking", "unavailable"]).optional(),
5806
+ confidence: z3.number().min(0).max(1).optional(),
5807
+ confidence_scale: z3.string().optional(),
5808
+ confidence_source: z3.string().optional()
5777
5809
  }).strict();
5778
- var DispatchOutcomeSchema = z2.discriminatedUnion("type", [
5779
- z2.object({ type: z2.literal("pr_opened"), pr: z2.number().int(), head: z2.string() }).strict(),
5780
- z2.object({
5781
- type: z2.literal("round_pushed"),
5782
- pr: z2.number().int(),
5783
- head: z2.string(),
5784
- comment_id: z2.number().int()
5810
+ var DispatchOutcomeSchema = z3.discriminatedUnion("type", [
5811
+ z3.object({ type: z3.literal("pr_opened"), pr: z3.number().int(), head: z3.string() }).strict(),
5812
+ z3.object({
5813
+ type: z3.literal("round_pushed"),
5814
+ pr: z3.number().int(),
5815
+ head: z3.string(),
5816
+ comment_id: z3.number().int()
5785
5817
  }).strict(),
5786
- z2.object({
5787
- type: z2.literal("verdict"),
5788
- verdict: z2.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
5789
- head: z2.string(),
5790
- comment_id: z2.number().int(),
5791
- objectives: z2.array(z2.object({ id: z2.string(), met: z2.boolean() }).strict()),
5792
- findings: z2.array(ReviewFindingSchema)
5818
+ z3.object({
5819
+ type: z3.literal("verdict"),
5820
+ verdict: z3.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
5821
+ head: z3.string(),
5822
+ comment_id: z3.number().int(),
5823
+ objectives: z3.array(z3.object({ id: z3.string(), met: z3.boolean() }).strict()),
5824
+ findings: z3.array(ReviewFindingSchema)
5793
5825
  }).strict(),
5794
- z2.object({
5795
- type: z2.literal("escalation"),
5796
- class: z2.enum(["authority", "strategy", "product"]),
5797
- comment_id: z2.number().int()
5826
+ z3.object({
5827
+ type: z3.literal("escalation"),
5828
+ class: z3.enum(["authority", "strategy", "product"]),
5829
+ comment_id: z3.number().int()
5798
5830
  }).strict(),
5799
- z2.object({ type: z2.literal("brief"), comment_id: z2.number().int(), hash: z2.string() }).strict(),
5800
- z2.object({ type: z2.literal("plan"), issues: z2.array(z2.number().int()) }).strict(),
5801
- z2.object({ type: z2.literal("archive"), provenance_comment_id: z2.number().int() }).strict(),
5802
- z2.object({ type: z2.literal("completed") }).strict()
5831
+ z3.object({ type: z3.literal("brief"), comment_id: z3.number().int(), hash: z3.string() }).strict(),
5832
+ z3.object({ type: z3.literal("plan"), issues: z3.array(z3.number().int()) }).strict(),
5833
+ z3.object({ type: z3.literal("archive"), provenance_comment_id: z3.number().int() }).strict(),
5834
+ z3.object({ type: z3.literal("completed") }).strict()
5803
5835
  ]);
5804
5836
  var dispatchShared = {
5805
5837
  meta: HeaderMetaSchema,
5806
5838
  subject: SubjectSchema,
5807
- kind: z2.literal("dispatch"),
5839
+ kind: z3.literal("dispatch"),
5808
5840
  ...envelopeTail,
5809
5841
  target_role: RoleSchema,
5810
- model: z2.string(),
5811
- round: z2.number().int().optional(),
5812
- effect_id: z2.string()
5842
+ model: z3.string(),
5843
+ round: z3.number().int().optional(),
5844
+ effect_id: z3.string()
5813
5845
  };
5814
- var dispatchUsageField = z2.object({ input: z2.number().nonnegative(), output: z2.number().nonnegative() }).strict().nullable();
5815
- var DispatchEventSchema = z2.discriminatedUnion("event", [
5816
- z2.object({ ...dispatchShared, event: z2.literal("dispatched"), prompt_hash: z2.string() }).strict(),
5817
- z2.object({
5846
+ var dispatchUsageField = z3.object({ input: z3.number().nonnegative(), output: z3.number().nonnegative() }).strict().nullable();
5847
+ var DispatchEventSchema = z3.discriminatedUnion("event", [
5848
+ z3.object({ ...dispatchShared, event: z3.literal("dispatched"), prompt_hash: z3.string() }).strict(),
5849
+ z3.object({
5818
5850
  ...dispatchShared,
5819
- event: z2.literal("outcome_received"),
5851
+ event: z3.literal("outcome_received"),
5820
5852
  outcome: DispatchOutcomeSchema,
5821
5853
  usage: dispatchUsageField
5822
5854
  }).strict(),
5823
- z2.object({
5855
+ z3.object({
5824
5856
  ...dispatchShared,
5825
- event: z2.literal("dispatch_failed"),
5826
- reason: z2.enum(["timeout", "crash", "refused", "unattributed_write"]),
5857
+ event: z3.literal("dispatch_failed"),
5858
+ reason: z3.enum(["timeout", "crash", "refused", "unattributed_write"]),
5827
5859
  usage: dispatchUsageField
5828
5860
  }).strict()
5829
5861
  ]);
5862
+ var CODE_TOKEN_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
5863
+ var CodeTokenSchema = z3.string().regex(CODE_TOKEN_PATTERN);
5864
+ var ReviewerVerdictSchema = z3.object({
5865
+ role: RoleSchema,
5866
+ outcome: z3.enum(["approve", "changes_requested", "not_reviewed"]),
5867
+ blockers: z3.number().int().nonnegative()
5868
+ }).strict();
5830
5869
  var loopShared = {
5831
5870
  meta: HeaderMetaSchema,
5832
5871
  subject: SubjectSchema,
5833
- kind: z2.literal("dev_review_loop"),
5872
+ kind: z3.literal("dev_review_loop"),
5834
5873
  ...envelopeTail,
5835
- loop_id: z2.string()
5874
+ loop_id: z3.string()
5836
5875
  };
5837
- var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
5838
- z2.object({
5876
+ var DevReviewLoopEventSchema = z3.discriminatedUnion("event", [
5877
+ z3.object({
5839
5878
  ...loopShared,
5840
- event: z2.literal("loop_started"),
5841
- task: z2.number().int(),
5842
- policy: z2.object({
5843
- max_rounds: z2.number().int().nonnegative(),
5844
- reviewers: z2.array(RoleSchema),
5845
- models: z2.record(RoleSchema, z2.string())
5879
+ event: z3.literal("loop_started"),
5880
+ task: z3.number().int(),
5881
+ policy: z3.object({
5882
+ max_rounds: z3.number().int().nonnegative(),
5883
+ reviewers: z3.array(RoleSchema),
5884
+ models: z3.record(RoleSchema, z3.string())
5846
5885
  }).strict()
5847
5886
  }).strict(),
5848
- z2.object({ ...loopShared, event: z2.literal("round_started"), round: z2.number().int(), base_head: z2.string() }).strict(),
5849
- z2.object({
5887
+ z3.object({ ...loopShared, event: z3.literal("round_started"), round: z3.number().int(), base_head: z3.string() }).strict(),
5888
+ z3.object({
5850
5889
  ...loopShared,
5851
- event: z2.literal("gate_result_read"),
5852
- round: z2.number().int(),
5853
- head: z2.string(),
5854
- green: z2.boolean(),
5855
- confidence_value: z2.number().int().min(0).max(100).optional(),
5856
- confidence_reason: z2.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
5857
- confidence_unavailable: z2.boolean().optional(),
5858
- extra_turn_spent: z2.boolean().optional()
5890
+ event: z3.literal("gate_result_read"),
5891
+ round: z3.number().int(),
5892
+ head: z3.string(),
5893
+ green: z3.boolean(),
5894
+ confidence_value: z3.number().int().min(0).max(100).optional(),
5895
+ confidence_reason: z3.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
5896
+ confidence_unavailable: z3.boolean().optional(),
5897
+ extra_turn_spent: z3.boolean().optional()
5859
5898
  }).strict(),
5860
- z2.object({
5899
+ z3.object({
5861
5900
  ...loopShared,
5862
- event: z2.literal("verdicts_read"),
5863
- round: z2.number().int(),
5864
- head: z2.string(),
5865
- all_approve: z2.boolean(),
5866
- blockers: z2.number().int().nonnegative(),
5867
- findings: z2.array(ReviewFindingSchema).optional()
5901
+ event: z3.literal("verdicts_read"),
5902
+ round: z3.number().int(),
5903
+ head: z3.string(),
5904
+ all_approve: z3.boolean(),
5905
+ blockers: z3.number().int().nonnegative(),
5906
+ findings: z3.array(ReviewFindingSchema).optional(),
5907
+ reviewers: z3.array(ReviewerVerdictSchema).optional()
5868
5908
  }).strict(),
5869
- z2.object({
5909
+ z3.object({
5870
5910
  ...loopShared,
5871
- event: z2.literal("findings_compared"),
5872
- round: z2.number().int(),
5873
- open: z2.array(z2.string()),
5874
- resolved: z2.array(z2.string()),
5875
- new: z2.array(z2.string()),
5876
- recurring: z2.array(z2.string())
5911
+ event: z3.literal("findings_compared"),
5912
+ round: z3.number().int(),
5913
+ open: z3.array(z3.string()),
5914
+ resolved: z3.array(z3.string()),
5915
+ new: z3.array(z3.string()),
5916
+ recurring: z3.array(z3.string())
5877
5917
  }).strict(),
5878
- z2.object({
5918
+ z3.object({
5879
5919
  ...loopShared,
5880
- event: z2.literal("stop_condition_met"),
5881
- round: z2.number().int(),
5882
- condition: z2.enum([
5920
+ event: z3.literal("stop_condition_met"),
5921
+ round: z3.number().int(),
5922
+ condition: z3.enum([
5883
5923
  "green",
5884
5924
  "max_rounds",
5885
5925
  "no_progress",
@@ -5888,66 +5928,85 @@ var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
5888
5928
  "confidence",
5889
5929
  "reappearance",
5890
5930
  "repeat_finding",
5891
- "repeat_failure"
5931
+ "repeat_failure",
5932
+ "time_budget"
5892
5933
  ])
5893
5934
  }).strict(),
5894
- z2.object({
5935
+ z3.object({
5936
+ ...loopShared,
5937
+ event: z3.literal("paused"),
5938
+ round: z3.number().int(),
5939
+ reason: z3.enum(["escalation", "principal_item", "refreeze_needed"]),
5940
+ reason_code: CodeTokenSchema.optional()
5941
+ }).strict(),
5942
+ z3.object({
5895
5943
  ...loopShared,
5896
- event: z2.literal("paused"),
5897
- round: z2.number().int(),
5898
- reason: z2.enum(["escalation", "principal_item", "refreeze_needed"])
5944
+ event: z3.literal("resumed"),
5945
+ round: z3.number().int(),
5946
+ by: z3.enum(["principal", "driver"])
5899
5947
  }).strict(),
5900
- z2.object({
5948
+ z3.object({
5901
5949
  ...loopShared,
5902
- event: z2.literal("resumed"),
5903
- round: z2.number().int(),
5904
- by: z2.enum(["principal", "driver"])
5950
+ event: z3.literal("cancelled"),
5951
+ round: z3.number().int(),
5952
+ by: z3.literal("principal")
5905
5953
  }).strict(),
5906
- z2.object({
5954
+ z3.object({
5907
5955
  ...loopShared,
5908
- event: z2.literal("cancelled"),
5909
- round: z2.number().int(),
5910
- by: z2.literal("principal")
5956
+ event: z3.literal("unpushed_work_resume"),
5957
+ round: z3.number().int(),
5958
+ branch: z3.string(),
5959
+ detail: z3.string()
5911
5960
  }).strict(),
5912
- z2.object({
5961
+ z3.object({
5913
5962
  ...loopShared,
5914
- event: z2.literal("unpushed_work_resume"),
5915
- round: z2.number().int(),
5916
- branch: z2.string(),
5917
- detail: z2.string()
5963
+ event: z3.literal("round_ended"),
5964
+ round: z3.number().int(),
5965
+ base_head: z3.string(),
5966
+ head: z3.string(),
5967
+ files_changed: z3.number().int().nonnegative(),
5968
+ insertions: z3.number().int().nonnegative(),
5969
+ deletions: z3.number().int().nonnegative(),
5970
+ wall_ms: z3.number().nonnegative(),
5971
+ outcome: z3.enum(["green", "changes_requested", "escalated"])
5918
5972
  }).strict(),
5919
- z2.object({
5973
+ z3.object({
5920
5974
  ...loopShared,
5921
- event: z2.literal("round_ended"),
5922
- round: z2.number().int(),
5923
- base_head: z2.string(),
5924
- head: z2.string(),
5925
- files_changed: z2.number().int().nonnegative(),
5926
- insertions: z2.number().int().nonnegative(),
5927
- deletions: z2.number().int().nonnegative(),
5928
- wall_ms: z2.number().nonnegative(),
5929
- outcome: z2.enum(["green", "changes_requested", "escalated"])
5975
+ event: z3.literal("journal_finalized"),
5976
+ rounds: z3.number().int().nonnegative(),
5977
+ total_wall_ms: z3.number().nonnegative(),
5978
+ time_to_green_ms: z3.number().nonnegative().nullable(),
5979
+ files_changed_total: z3.number().int().nonnegative(),
5980
+ final_head: z3.string(),
5981
+ result: z3.enum(["merged_ready", "stopped"])
5930
5982
  }).strict(),
5931
- z2.object({
5983
+ z3.object({
5932
5984
  ...loopShared,
5933
- event: z2.literal("journal_finalized"),
5934
- rounds: z2.number().int().nonnegative(),
5935
- total_wall_ms: z2.number().nonnegative(),
5936
- time_to_green_ms: z2.number().nonnegative().nullable(),
5937
- files_changed_total: z2.number().int().nonnegative(),
5938
- final_head: z2.string(),
5939
- result: z2.enum(["merged_ready", "stopped"])
5985
+ event: z3.literal("infrastructure_retry"),
5986
+ round: z3.number().int(),
5987
+ failure_kind: z3.enum(["pause_comment_post", "developer_connection"]),
5988
+ attempts: z3.number().int().positive(),
5989
+ outcome: z3.enum(["recovered", "exhausted"])
5940
5990
  }).strict(),
5941
- z2.object({
5991
+ z3.object({
5942
5992
  ...loopShared,
5943
- event: z2.literal("infrastructure_retry"),
5944
- round: z2.number().int(),
5945
- failure_kind: z2.enum(["pause_comment_post", "developer_connection"]),
5946
- attempts: z2.number().int().positive(),
5947
- outcome: z2.enum(["recovered", "exhausted"])
5993
+ event: z3.literal("driver_heartbeat"),
5994
+ task: z3.number().int(),
5995
+ pr: z3.number().int().positive().optional(),
5996
+ round: z3.number().int(),
5997
+ phase: z3.string()
5998
+ }).strict(),
5999
+ z3.object({
6000
+ ...loopShared,
6001
+ event: z3.literal("driver_exited"),
6002
+ task: z3.number().int(),
6003
+ reason: z3.enum(["finished", "paused", "reexec", "error", "signal"]),
6004
+ last_decision: z3.string(),
6005
+ exit_code: z3.number().int().optional(),
6006
+ error_class: CodeTokenSchema.optional()
5948
6007
  }).strict()
5949
6008
  ]);
5950
- var ForgeOpSchema = z2.enum([
6009
+ var ForgeOpSchema = z3.enum([
5951
6010
  "pr.create",
5952
6011
  "pr.comment",
5953
6012
  "pr.body.replace",
@@ -5961,24 +6020,24 @@ var ForgeOpSchema = z2.enum([
5961
6020
  "label.add",
5962
6021
  "label.remove"
5963
6022
  ]);
5964
- var ForgeWriteTargetSchema = z2.object({
5965
- issue: z2.number().int().optional(),
5966
- pr: z2.number().int().optional()
6023
+ var ForgeWriteTargetSchema = z3.object({
6024
+ issue: z3.number().int().optional(),
6025
+ pr: z3.number().int().optional()
5967
6026
  }).strict();
5968
6027
  var forgeWriteShared = {
5969
6028
  meta: HeaderMetaSchema,
5970
6029
  subject: SubjectSchema,
5971
- kind: z2.literal("forge_write"),
6030
+ kind: z3.literal("forge_write"),
5972
6031
  ...envelopeTail,
5973
6032
  op: ForgeOpSchema,
5974
6033
  target: ForgeWriteTargetSchema
5975
6034
  };
5976
- var ForgeWriteEventSchema = z2.discriminatedUnion("event", [
5977
- z2.object({ ...forgeWriteShared, event: z2.literal("validated") }).strict(),
5978
- z2.object({ ...forgeWriteShared, event: z2.literal("refused"), reason: z2.string() }).strict(),
5979
- z2.object({ ...forgeWriteShared, event: z2.literal("written"), comment_ids: z2.array(z2.string()) }).strict()
6035
+ var ForgeWriteEventSchema = z3.discriminatedUnion("event", [
6036
+ z3.object({ ...forgeWriteShared, event: z3.literal("validated") }).strict(),
6037
+ z3.object({ ...forgeWriteShared, event: z3.literal("refused"), reason: z3.string() }).strict(),
6038
+ z3.object({ ...forgeWriteShared, event: z3.literal("written"), comment_ids: z3.array(z3.string()) }).strict()
5980
6039
  ]);
5981
- var GateOutcomeSchema = z2.enum([
6040
+ var GateOutcomeSchema = z3.enum([
5982
6041
  "pass",
5983
6042
  "fail",
5984
6043
  "wait",
@@ -5991,61 +6050,74 @@ var GateOutcomeSchema = z2.enum([
5991
6050
  var gateShared = {
5992
6051
  meta: HeaderMetaSchema,
5993
6052
  subject: SubjectSchema,
5994
- kind: z2.literal("gate"),
6053
+ kind: z3.literal("gate"),
5995
6054
  ...envelopeTail,
5996
- check: z2.string(),
5997
- check_version: z2.string().nullable(),
5998
- policy_version: z2.string().nullable(),
5999
- input_fingerprint: z2.string().nullable()
6055
+ check: z3.string(),
6056
+ check_version: z3.string().nullable(),
6057
+ policy_version: z3.string().nullable(),
6058
+ input_fingerprint: z3.string().nullable()
6000
6059
  };
6001
- var GateEventSchema = z2.discriminatedUnion("event", [
6002
- z2.object({
6060
+ var GateEventSchema = z3.discriminatedUnion("event", [
6061
+ z3.object({
6003
6062
  ...gateShared,
6004
- event: z2.literal("checked"),
6063
+ event: z3.literal("checked"),
6005
6064
  outcome: GateOutcomeSchema,
6006
- reason: z2.string().optional()
6065
+ reason: z3.string().optional()
6066
+ }).strict(),
6067
+ z3.object({
6068
+ meta: HeaderMetaSchema,
6069
+ subject: SubjectSchema,
6070
+ kind: z3.literal("gate"),
6071
+ ...envelopeTail,
6072
+ event: z3.literal("summary"),
6073
+ ran: z3.number().int().nonnegative(),
6074
+ passed: z3.number().int().nonnegative(),
6075
+ failed: z3.number().int().nonnegative(),
6076
+ skipped: z3.number().int().nonnegative(),
6077
+ failed_checks: z3.array(z3.string())
6007
6078
  }).strict()
6008
6079
  ]);
6009
- var OperationResultSchema = z2.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
6080
+ var OperationResultSchema = z3.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
6010
6081
  var operationShared = {
6011
6082
  meta: HeaderMetaSchema,
6012
6083
  subject: SubjectSchema,
6013
- kind: z2.literal("operation"),
6084
+ kind: z3.literal("operation"),
6014
6085
  ...envelopeTail,
6015
- operation: z2.string(),
6016
- target: z2.string().nullable()
6086
+ operation: z3.string(),
6087
+ target: z3.string().nullable()
6017
6088
  };
6018
- var OperationEventSchema = z2.discriminatedUnion("event", [
6019
- z2.object({
6089
+ var OperationEventSchema = z3.discriminatedUnion("event", [
6090
+ z3.object({
6020
6091
  ...operationShared,
6021
- event: z2.literal("completed"),
6092
+ event: z3.literal("completed"),
6022
6093
  result: OperationResultSchema,
6023
- error_class: z2.string().nullable()
6094
+ error_class: z3.string().nullable(),
6095
+ field_names: z3.array(z3.string().max(CUSTOM_FIELD_NAME_MAX_LENGTH)).max(CUSTOM_EVENT_MAX_FIELDS).optional()
6024
6096
  }).strict()
6025
6097
  ]);
6026
- var UsageUnitsSchema = z2.object({
6027
- input: z2.number().nonnegative().nullable(),
6028
- output: z2.number().nonnegative().nullable(),
6029
- cache: z2.number().nonnegative().nullable()
6098
+ var UsageUnitsSchema = z3.object({
6099
+ input: z3.number().nonnegative().nullable(),
6100
+ output: z3.number().nonnegative().nullable(),
6101
+ cache: z3.number().nonnegative().nullable()
6030
6102
  }).strict();
6031
6103
  var usageShared = {
6032
6104
  meta: HeaderMetaSchema,
6033
6105
  subject: SubjectSchema,
6034
- kind: z2.literal("usage"),
6106
+ kind: z3.literal("usage"),
6035
6107
  ...envelopeTail,
6036
- model: z2.string().nullable(),
6037
- source: z2.string(),
6038
- semantics: z2.enum(["cumulative", "delta"])
6108
+ model: z3.string().nullable(),
6109
+ source: z3.string(),
6110
+ semantics: z3.enum(["cumulative", "delta"])
6039
6111
  };
6040
- var UsageEventSchema = z2.discriminatedUnion("event", [
6041
- z2.object({
6112
+ var UsageEventSchema = z3.discriminatedUnion("event", [
6113
+ z3.object({
6042
6114
  ...usageShared,
6043
- event: z2.literal("observed"),
6115
+ event: z3.literal("observed"),
6044
6116
  units: UsageUnitsSchema,
6045
- unknown_reason: z2.string().nullable()
6117
+ unknown_reason: z3.string().nullable()
6046
6118
  }).strict()
6047
6119
  ]);
6048
- var RoleAttemptOutcomeSchema = z2.enum([
6120
+ var RoleAttemptOutcomeSchema = z3.enum([
6049
6121
  "completed",
6050
6122
  "incomplete",
6051
6123
  "infrastructure_failed",
@@ -6056,17 +6128,17 @@ var RoleAttemptOutcomeSchema = z2.enum([
6056
6128
  var roleAttemptShared = {
6057
6129
  meta: HeaderMetaSchema,
6058
6130
  subject: SubjectSchema,
6059
- kind: z2.literal("role_attempt"),
6131
+ kind: z3.literal("role_attempt"),
6060
6132
  ...envelopeTail,
6061
- actor: z2.string().nullable(),
6062
- attempt: z2.number().int().nullable(),
6063
- effect_id: z2.string(),
6064
- model: z2.string().nullable()
6133
+ actor: z3.string().nullable(),
6134
+ attempt: z3.number().int().nullable(),
6135
+ effect_id: z3.string(),
6136
+ model: z3.string().nullable()
6065
6137
  };
6066
- var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
6067
- z2.object({
6138
+ var RoleAttemptEventSchema = z3.discriminatedUnion("event", [
6139
+ z3.object({
6068
6140
  ...roleAttemptShared,
6069
- event: z2.literal("attempted"),
6141
+ event: z3.literal("attempted"),
6070
6142
  outcome: RoleAttemptOutcomeSchema,
6071
6143
  usage: dispatchUsageField
6072
6144
  }).strict()
@@ -6074,42 +6146,59 @@ var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
6074
6146
  var handoffShared = {
6075
6147
  meta: HeaderMetaSchema,
6076
6148
  subject: SubjectSchema,
6077
- kind: z2.literal("handoff"),
6149
+ kind: z3.literal("handoff"),
6078
6150
  ...envelopeTail,
6079
- class: z2.enum(["authority", "strategy", "product"]),
6080
- reason: z2.string()
6151
+ class: z3.enum(["authority", "strategy", "product"]),
6152
+ reason: z3.string()
6081
6153
  };
6082
- var HandoffEventSchema = z2.discriminatedUnion("event", [
6083
- z2.object({
6154
+ var HandoffEventSchema = z3.discriminatedUnion("event", [
6155
+ z3.object({
6084
6156
  ...handoffShared,
6085
- event: z2.literal("raised"),
6086
- requested_decision: z2.string().nullable()
6157
+ event: z3.literal("raised"),
6158
+ requested_decision: z3.string().nullable()
6087
6159
  }).strict(),
6088
- z2.object({
6160
+ z3.object({
6089
6161
  ...handoffShared,
6090
- event: z2.literal("resolved"),
6091
- resolution: z2.string().nullable(),
6092
- resolved_by: z2.string().nullable()
6162
+ event: z3.literal("resolved"),
6163
+ resolution: z3.string().nullable(),
6164
+ resolved_by: z3.string().nullable()
6093
6165
  }).strict()
6094
6166
  ]);
6095
- var EffectTargetSchema = z2.object({
6096
- kind: z2.string(),
6097
- ref: z2.string()
6167
+ var EffectTargetSchema = z3.object({
6168
+ kind: z3.string(),
6169
+ ref: z3.string()
6098
6170
  }).strict();
6099
6171
  var effectShared = {
6100
6172
  meta: HeaderMetaSchema,
6101
6173
  subject: SubjectSchema,
6102
- kind: z2.literal("effect"),
6174
+ kind: z3.literal("effect"),
6103
6175
  ...envelopeTail,
6104
- effect_id: z2.string(),
6176
+ effect_id: z3.string(),
6105
6177
  target: EffectTargetSchema
6106
6178
  };
6107
- var EffectEventSchema = z2.discriminatedUnion("event", [
6108
- z2.object({ ...effectShared, event: z2.literal("attempted") }).strict(),
6109
- z2.object({ ...effectShared, event: z2.literal("observed"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict(),
6110
- z2.object({ ...effectShared, event: z2.literal("verified"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict()
6179
+ var EffectEventSchema = z3.discriminatedUnion("event", [
6180
+ z3.object({ ...effectShared, event: z3.literal("attempted") }).strict(),
6181
+ z3.object({ ...effectShared, event: z3.literal("observed"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict(),
6182
+ z3.object({ ...effectShared, event: z3.literal("verified"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict()
6111
6183
  ]);
6112
- var LogEventSchema = z2.union([
6184
+ var CustomFieldValueSchema = z3.union([z3.string().max(CUSTOM_TEXT_MAX_LENGTH), z3.number().finite(), z3.boolean()]);
6185
+ var customShared = {
6186
+ meta: HeaderMetaV3Schema,
6187
+ subject: SubjectSchema,
6188
+ kind: z3.literal("custom"),
6189
+ ...envelopeTail
6190
+ };
6191
+ var CustomEventSchema = z3.discriminatedUnion("event", [
6192
+ z3.object({
6193
+ ...customShared,
6194
+ event: z3.literal("recorded"),
6195
+ name: z3.string().max(CUSTOM_EVENT_NAME_MAX_LENGTH).regex(CUSTOM_EVENT_NAME_PATTERN),
6196
+ 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, {
6197
+ message: `custom: at most ${CUSTOM_EVENT_MAX_FIELDS} fields`
6198
+ })
6199
+ }).strict()
6200
+ ]);
6201
+ var LogEventSchema = z3.union([
6113
6202
  DispatchEventSchema,
6114
6203
  DevReviewLoopEventSchema,
6115
6204
  ForgeWriteEventSchema,
@@ -6118,10 +6207,11 @@ var LogEventSchema = z2.union([
6118
6207
  UsageEventSchema,
6119
6208
  RoleAttemptEventSchema,
6120
6209
  HandoffEventSchema,
6121
- EffectEventSchema
6210
+ EffectEventSchema,
6211
+ CustomEventSchema
6122
6212
  ]);
6123
-
6124
6213
  // ../../packages/aeg-core/src/log/envelope.ts
6214
+ import { createHash as createHash5 } from "node:crypto";
6125
6215
  function isRole(value) {
6126
6216
  return value !== undefined && ROLE_VALUES.includes(value);
6127
6217
  }
@@ -6158,18 +6248,27 @@ function roundFromEnv(round) {
6158
6248
  const n = Number(round);
6159
6249
  return Number.isInteger(n) ? n : undefined;
6160
6250
  }
6251
+ function prFromEnv(pr) {
6252
+ if (pr === undefined || pr === "")
6253
+ return;
6254
+ const n = Number(pr);
6255
+ return Number.isInteger(n) && n > 0 ? n : undefined;
6256
+ }
6161
6257
  function buildHeader(input) {
6162
6258
  const role = isRole(input.env.role) ? input.env.role : "unattributed";
6163
6259
  const round = roundFromEnv(input.env.round);
6260
+ const pr = prFromEnv(input.env.pr);
6164
6261
  const subject = {
6165
6262
  issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
6166
6263
  role,
6167
6264
  ...round !== undefined ? { round } : {},
6265
+ ...pr !== undefined ? { pr } : {},
6168
6266
  ...input.subject ?? {}
6169
6267
  };
6268
+ const issue = subject.issue;
6170
6269
  return {
6171
6270
  meta: {
6172
- schema: 2,
6271
+ schema: 3,
6173
6272
  ts: input.now.toISOString(),
6174
6273
  run_id: input.runId,
6175
6274
  seq: input.seq,
@@ -6192,7 +6291,19 @@ function buildHeader(input) {
6192
6291
  ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
6193
6292
  policy_digest: input.inputVersions?.policyDigest ?? null
6194
6293
  },
6195
- provenance: provenanceFor(input)
6294
+ provenance: provenanceFor(input),
6295
+ work: {
6296
+ ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
6297
+ repo: input.repo,
6298
+ change: null,
6299
+ revision: null
6300
+ },
6301
+ flow: {
6302
+ id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
6303
+ version: lineageFieldFromEnv(input.env.flowVersion)
6304
+ },
6305
+ runtime: lineageFieldFromEnv(input.env.runtime),
6306
+ source: lineageFieldFromEnv(input.env.source)
6196
6307
  },
6197
6308
  subject
6198
6309
  };
@@ -6235,7 +6346,7 @@ function redact(value, home) {
6235
6346
  return value;
6236
6347
  }
6237
6348
  // ../../packages/aeg-core/src/log/store.ts
6238
- var KNOWN_SCHEMA_VERSIONS = [1, 2];
6349
+ var KNOWN_SCHEMA_VERSIONS = [1, 2, 3];
6239
6350
  function metaOf(obj) {
6240
6351
  if (obj === null || typeof obj !== "object")
6241
6352
  return null;
@@ -6301,7 +6412,7 @@ function classifyStoredLine(raw, home) {
6301
6412
  return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
6302
6413
  }
6303
6414
  const redacted = redact(event, home);
6304
- const provenance = version === 2 ? event.meta.provenance ?? null : null;
6415
+ const provenance = version >= 2 ? event.meta.provenance ?? null : null;
6305
6416
  return {
6306
6417
  status: "ok",
6307
6418
  identity,
@@ -6314,189 +6425,172 @@ function classifyStoredLine(raw, home) {
6314
6425
  };
6315
6426
  }
6316
6427
  // ../../packages/aeg-core/src/control-store/records.ts
6317
- import { z as z3 } from "zod";
6318
- var isoTimestamp = z3.string().min(1);
6319
- var taskId = z3.number().int().positive();
6320
- var epochNumber = z3.number().int().nonnegative();
6321
- var RunRecordSchema = z3.object({
6322
- version: z3.literal(1),
6323
- kind: z3.literal("run"),
6428
+ import { z as z4 } from "zod";
6429
+ var isoTimestamp = z4.string().min(1);
6430
+ var taskId = z4.number().int().positive();
6431
+ var epochNumber = z4.number().int().nonnegative();
6432
+ var RunRecordSchema = z4.object({
6433
+ version: z4.literal(1),
6434
+ kind: z4.literal("run"),
6324
6435
  task: taskId,
6325
- runId: z3.string().min(1),
6326
- pid: z3.number().int().positive(),
6327
- host: z3.string().min(1),
6436
+ runId: z4.string().min(1),
6437
+ pid: z4.number().int().positive(),
6438
+ host: z4.string().min(1),
6328
6439
  startedAt: isoTimestamp,
6329
- childStartedAt: z3.string().min(1).nullable().optional(),
6330
- childCommand: z3.string().min(1).nullable().optional()
6440
+ childStartedAt: z4.string().min(1).nullable().optional(),
6441
+ childCommand: z4.string().min(1).nullable().optional()
6331
6442
  }).strict();
6332
- var InputRecordSchema = z3.object({
6333
- version: z3.literal(1),
6334
- kind: z3.literal("input"),
6443
+ var InputRecordSchema = z4.object({
6444
+ version: z4.literal(1),
6445
+ kind: z4.literal("input"),
6335
6446
  task: taskId,
6336
- runId: z3.string().min(1),
6337
- source: z3.union([z3.literal("fresh"), z3.literal("resume")]),
6338
- pr: z3.number().int().positive().nullable(),
6339
- round: z3.number().int().nonnegative(),
6447
+ runId: z4.string().min(1),
6448
+ source: z4.union([z4.literal("fresh"), z4.literal("resume")]),
6449
+ pr: z4.number().int().positive().nullable(),
6450
+ round: z4.number().int().nonnegative(),
6340
6451
  recordedAt: isoTimestamp
6341
6452
  }).strict();
6342
- var OwnershipRecordSchema = z3.object({
6343
- version: z3.literal(1),
6344
- kind: z3.literal("ownership"),
6453
+ var OwnershipRecordSchema = z4.object({
6454
+ version: z4.literal(1),
6455
+ kind: z4.literal("ownership"),
6345
6456
  task: taskId,
6346
6457
  epoch: epochNumber,
6347
- ownerId: z3.string().min(1),
6348
- pid: z3.number().int().positive(),
6349
- host: z3.string().min(1),
6458
+ ownerId: z4.string().min(1),
6459
+ pid: z4.number().int().positive(),
6460
+ host: z4.string().min(1),
6350
6461
  acquiredAt: isoTimestamp
6351
6462
  }).strict();
6352
- var TransitionRecordSchema = z3.object({
6353
- version: z3.literal(1),
6354
- kind: z3.literal("transition"),
6463
+ var TransitionRecordSchema = z4.object({
6464
+ version: z4.literal(1),
6465
+ kind: z4.literal("transition"),
6355
6466
  task: taskId,
6356
6467
  epoch: epochNumber,
6357
- seq: z3.number().int().nonnegative(),
6358
- from: z3.string().min(1),
6359
- to: z3.string().min(1),
6360
- detail: z3.string().optional(),
6468
+ seq: z4.number().int().nonnegative(),
6469
+ from: z4.string().min(1),
6470
+ to: z4.string().min(1),
6471
+ detail: z4.string().optional(),
6361
6472
  at: isoTimestamp
6362
6473
  }).strict();
6363
- var ManifestRecordSchema = z3.object({
6364
- version: z3.literal(1),
6365
- kind: z3.literal("manifest"),
6474
+ var ManifestRecordSchema = z4.object({
6475
+ version: z4.literal(1),
6476
+ kind: z4.literal("manifest"),
6366
6477
  task: taskId,
6367
6478
  round: epochNumber,
6368
- repository: z3.string().min(1),
6369
- pr: z3.number().int().positive(),
6370
- branch: z3.string().min(1),
6371
- baseSha: z3.string().min(1).nullable(),
6372
- headSha: z3.string().min(1),
6373
- briefHash: z3.string().min(1).nullable(),
6374
- objectivesVersion: z3.string().min(1).nullable(),
6479
+ repository: z4.string().min(1),
6480
+ pr: z4.number().int().positive(),
6481
+ branch: z4.string().min(1),
6482
+ baseSha: z4.string().min(1).nullable(),
6483
+ headSha: z4.string().min(1),
6484
+ briefHash: z4.string().min(1).nullable(),
6485
+ objectivesVersion: z4.string().min(1).nullable(),
6375
6486
  rulingOrdinal: epochNumber,
6376
- policyDigest: z3.string().min(1),
6487
+ policyDigest: z4.string().min(1),
6377
6488
  recordedAt: isoTimestamp
6378
6489
  }).strict();
6379
- var roundHeadIdentity = z3.object({ round: z3.number().int().positive(), head: z3.string().min(1) }).strict();
6380
- var LoopBudgetsSchema = z3.object({
6381
- mechanicalRetries: z3.number().int().nonnegative(),
6382
- reviewRounds: z3.number().int().nonnegative(),
6383
- infrastructureRetries: z3.number().int().nonnegative()
6490
+ var roundHeadIdentity = z4.object({ round: z4.number().int().positive(), head: z4.string().min(1) }).strict();
6491
+ var LoopBudgetsSchema = z4.object({
6492
+ mechanicalRetries: z4.number().int().nonnegative(),
6493
+ reviewRounds: z4.number().int().nonnegative(),
6494
+ infrastructureRetries: z4.number().int().nonnegative()
6384
6495
  }).strict();
6385
- var LoopStateRecordSchema = z3.object({
6386
- version: z3.literal(1),
6387
- kind: z3.literal("loop_state"),
6496
+ var LoopStateRecordSchema = z4.object({
6497
+ version: z4.literal(1),
6498
+ kind: z4.literal("loop_state"),
6388
6499
  task: taskId,
6389
- round: z3.number().int().positive(),
6390
- phase: z3.string().min(1),
6391
- pauseReason: z3.string().min(1).nullable(),
6500
+ round: z4.number().int().positive(),
6501
+ phase: z4.string().min(1),
6502
+ pauseReason: z4.string().min(1).nullable(),
6392
6503
  budgets: LoopBudgetsSchema,
6393
6504
  heldResult: roundHeadIdentity.nullable(),
6394
6505
  deliveredFindings: roundHeadIdentity.nullable(),
6395
- repeatMemory: z3.object({
6396
- blockingFindings: z3.array(z3.string()),
6397
- lastFailure: z3.object({ signature: z3.string(), message: z3.string() }).nullable()
6506
+ repeatMemory: z4.object({
6507
+ blockingFindings: z4.array(z4.string()),
6508
+ lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
6398
6509
  }).strict().optional(),
6510
+ publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
6511
+ taskStartedAt: isoTimestamp.optional(),
6512
+ phaseMs: z4.record(z4.string(), z4.number().nonnegative()).optional(),
6399
6513
  recordedAt: isoTimestamp
6400
6514
  }).strict();
6401
- var EffectRecordSchema = z3.object({
6402
- version: z3.literal(1),
6403
- kind: z3.literal("effect"),
6515
+ var EffectRecordSchema = z4.object({
6516
+ version: z4.literal(1),
6517
+ kind: z4.literal("effect"),
6404
6518
  task: taskId,
6405
- key: z3.string().min(1),
6406
- operation: z3.string().min(1),
6407
- target: z3.string().min(1),
6408
- inputVersion: z3.number().int().nonnegative(),
6409
- payloadDigest: z3.string().min(1),
6410
- status: z3.union([z3.literal("started"), z3.literal("verified"), z3.literal("uncertain")]),
6411
- url: z3.string().optional(),
6519
+ key: z4.string().min(1),
6520
+ operation: z4.string().min(1),
6521
+ target: z4.string().min(1),
6522
+ inputVersion: z4.number().int().nonnegative(),
6523
+ payloadDigest: z4.string().min(1),
6524
+ status: z4.union([z4.literal("started"), z4.literal("verified"), z4.literal("uncertain")]),
6525
+ url: z4.string().optional(),
6412
6526
  recordedAt: isoTimestamp
6413
6527
  }).strict();
6414
- var EscalationRecordSchema = z3.object({
6415
- version: z3.literal(1),
6416
- kind: z3.literal("escalation"),
6528
+ var EscalationRecordSchema = z4.object({
6529
+ version: z4.literal(1),
6530
+ kind: z4.literal("escalation"),
6417
6531
  task: taskId,
6418
- escalationId: z3.string().min(1),
6532
+ escalationId: z4.string().min(1),
6419
6533
  round: epochNumber,
6420
- head: z3.string().min(1),
6421
- branch: z3.string().min(1),
6422
- pr: z3.number().int().positive().nullable(),
6423
- runId: z3.string().min(1),
6424
- pid: z3.number().int().positive(),
6425
- host: z3.string().min(1),
6426
- agent: z3.string().min(1).optional(),
6427
- reason: z3.string().min(1),
6428
- detail: z3.string().optional(),
6429
- evidence: z3.string().optional(),
6430
- attemptedRecovery: z3.string().min(1),
6431
- requestedDecision: z3.string().min(1),
6432
- recipient: z3.string().min(1),
6433
- briefHash: z3.string().min(1).nullable(),
6434
- objectivesVersion: z3.string().min(1).nullable(),
6534
+ head: z4.string().min(1),
6535
+ branch: z4.string().min(1),
6536
+ pr: z4.number().int().positive().nullable(),
6537
+ runId: z4.string().min(1),
6538
+ pid: z4.number().int().positive(),
6539
+ host: z4.string().min(1),
6540
+ agent: z4.string().min(1).optional(),
6541
+ reason: z4.string().min(1),
6542
+ detail: z4.string().optional(),
6543
+ evidence: z4.string().optional(),
6544
+ attemptedRecovery: z4.string().min(1),
6545
+ requestedDecision: z4.string().min(1),
6546
+ recipient: z4.string().min(1),
6547
+ briefHash: z4.string().min(1).nullable(),
6548
+ objectivesVersion: z4.string().min(1).nullable(),
6435
6549
  rulingOrdinal: epochNumber,
6436
- policyDigest: z3.string().min(1),
6550
+ policyDigest: z4.string().min(1),
6437
6551
  recordedAt: isoTimestamp
6438
6552
  }).strict();
6439
- var ResolutionRecordSchema = z3.object({
6440
- version: z3.literal(1),
6441
- kind: z3.literal("resolution"),
6553
+ var ResolutionRecordSchema = z4.object({
6554
+ version: z4.literal(1),
6555
+ kind: z4.literal("resolution"),
6442
6556
  task: taskId,
6443
- escalationId: z3.string().min(1),
6444
- decision: z3.union([z3.literal("resume"), z3.literal("cancel")]),
6445
- authenticatedBy: z3.string().min(1),
6446
- authenticatedFrom: z3.string().min(1),
6557
+ escalationId: z4.string().min(1),
6558
+ decision: z4.union([z4.literal("resume"), z4.literal("cancel")]),
6559
+ authenticatedBy: z4.string().min(1),
6560
+ authenticatedFrom: z4.string().min(1),
6447
6561
  consumedAt: isoTimestamp
6448
6562
  }).strict();
6563
+ // ../../packages/aeg-core/src/control-store/local.ts
6564
+ var CONTROL_AREA_DIRNAME = "control";
6449
6565
  // src/lib/config.ts
6450
- import { execFile as execFile4, execFileSync as execFileSync3 } from "node:child_process";
6566
+ import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
6451
6567
  import { promisify as promisify4 } from "node:util";
6452
6568
  import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
6453
6569
  import { homedir } from "node:os";
6454
6570
  import { dirname, isAbsolute, join, resolve } from "node:path";
6455
- import { z as z4 } from "zod";
6571
+ import { z as z5 } from "zod";
6456
6572
 
6457
6573
  // src/lib/agent-vendors.ts
6458
6574
  var AGENT_VENDORS = ["skills", "claude", "gemini"];
6459
6575
 
6460
- // src/lib/worker-boundary.ts
6461
- import { execFileSync as execFileSync2 } from "node:child_process";
6462
- var LOG_HEADER_KEYCHAIN_SERVICE = "Vinaya Log";
6463
- var logHeaderKeychainCache = new Map;
6464
- function readRealLogHeaderKeychainCredential(variable) {
6465
- if (process.platform !== "darwin")
6466
- return null;
6467
- try {
6468
- 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$/, "");
6469
- } catch {
6470
- return null;
6471
- }
6472
- }
6473
- function readLogHeaderKeychainCredential(variable) {
6474
- const cached = logHeaderKeychainCache.get(variable);
6475
- if (cached !== undefined)
6476
- return cached;
6477
- const value = readRealLogHeaderKeychainCredential(variable);
6478
- logHeaderKeychainCache.set(variable, value);
6479
- return value;
6480
- }
6481
-
6482
6576
  // src/lib/config.ts
6483
- var EnvEntrySchema = z4.union([
6484
- z4.literal(true),
6485
- z4.object({ optional: z4.literal(true) }),
6486
- z4.object({ anyOf: z4.array(z4.string()).min(2) }),
6487
- z4.string()
6577
+ var EnvEntrySchema = z5.union([
6578
+ z5.literal(true),
6579
+ z5.object({ optional: z5.literal(true) }),
6580
+ z5.object({ anyOf: z5.array(z5.string()).min(2) }),
6581
+ z5.string()
6488
6582
  ]);
6489
- var CheckEntrySchema = z4.object({
6490
- run: z4.string(),
6491
- scope: z4.enum(["diff", "full"]),
6492
- include: z4.array(z4.string()).optional(),
6493
- args: z4.array(z4.string()).optional(),
6494
- timeoutMs: z4.number().optional(),
6495
- env: z4.record(z4.string(), EnvEntrySchema).optional(),
6496
- requiresOpenPr: z4.boolean().optional(),
6497
- ownWorkflow: z4.boolean().optional(),
6498
- principalOwed: z4.literal(true).optional(),
6499
- validates: z4.enum(["body", "issue"]).optional()
6583
+ var CheckEntrySchema = z5.object({
6584
+ run: z5.string(),
6585
+ scope: z5.enum(["diff", "full"]),
6586
+ include: z5.array(z5.string()).optional(),
6587
+ args: z5.array(z5.string()).optional(),
6588
+ timeoutMs: z5.number().optional(),
6589
+ env: z5.record(z5.string(), EnvEntrySchema).optional(),
6590
+ requiresOpenPr: z5.boolean().optional(),
6591
+ ownWorkflow: z5.boolean().optional(),
6592
+ principalOwed: z5.literal(true).optional(),
6593
+ validates: z5.enum(["body", "issue"]).optional()
6500
6594
  }).superRefine((entry, ctx) => {
6501
6595
  if (!entry.env)
6502
6596
  return;
@@ -6506,22 +6600,22 @@ var CheckEntrySchema = z4.object({
6506
6600
  const members = value.anyOf;
6507
6601
  if (new Set(members).size !== members.length) {
6508
6602
  ctx.addIssue({
6509
- code: z4.ZodIssueCode.custom,
6603
+ code: z5.ZodIssueCode.custom,
6510
6604
  message: `env.${key}.anyOf has duplicate members`,
6511
6605
  path: ["env", key, "anyOf"]
6512
6606
  });
6513
6607
  }
6514
6608
  if (!members.includes(key)) {
6515
6609
  ctx.addIssue({
6516
- code: z4.ZodIssueCode.custom,
6610
+ code: z5.ZodIssueCode.custom,
6517
6611
  message: `env.${key}.anyOf must include "${key}" itself as a member`,
6518
6612
  path: ["env", key, "anyOf"]
6519
6613
  });
6520
6614
  }
6521
6615
  }
6522
6616
  });
6523
- var RoleEntrySchema = z4.object({
6524
- contract: z4.string().refine((p) => p.includes("/"), {
6617
+ var RoleEntrySchema = z5.object({
6618
+ contract: z5.string().refine((p) => p.includes("/"), {
6525
6619
  message: 'must be a path (contain at least one "/"), not a bare filename'
6526
6620
  })
6527
6621
  });
@@ -6545,17 +6639,17 @@ var BRIEF_BUILTINS = [
6545
6639
  "briefSections",
6546
6640
  "milestoneShape"
6547
6641
  ];
6548
- var BriefSectionSchema = z4.union([
6549
- z4.object({ builtin: z4.enum(BRIEF_BUILTINS) }),
6550
- z4.object({ heading: z4.string().min(1), name: z4.string().optional() }),
6551
- z4.object({ field: z4.string().min(1), name: z4.string().optional() }),
6552
- z4.object({ phrase: z4.string().min(1), name: z4.string().optional() })
6642
+ var BriefSectionSchema = z5.union([
6643
+ z5.object({ builtin: z5.enum(BRIEF_BUILTINS) }),
6644
+ z5.object({ heading: z5.string().min(1), name: z5.string().optional() }),
6645
+ z5.object({ field: z5.string().min(1), name: z5.string().optional() }),
6646
+ z5.object({ phrase: z5.string().min(1), name: z5.string().optional() })
6553
6647
  ]);
6554
- var BriefSchemaSchema = z4.object({
6555
- pr: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
6556
- issue: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
6557
- milestone: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
6558
- ack: z4.array(z4.enum(BRIEF_BUILTINS)).optional()
6648
+ var BriefSchemaSchema = z5.object({
6649
+ pr: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
6650
+ issue: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
6651
+ milestone: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
6652
+ ack: z5.array(z5.enum(BRIEF_BUILTINS)).optional()
6559
6653
  });
6560
6654
  function isSafeRepoRelPath(p) {
6561
6655
  if (p.length === 0)
@@ -6564,7 +6658,7 @@ function isSafeRepoRelPath(p) {
6564
6658
  return false;
6565
6659
  return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
6566
6660
  }
6567
- var SafeRepoRelPath = z4.string().refine(isSafeRepoRelPath, {
6661
+ var SafeRepoRelPath = z5.string().refine(isSafeRepoRelPath, {
6568
6662
  message: "must be a repo-root-relative path with no `..` segment or absolute root"
6569
6663
  });
6570
6664
  var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
@@ -6574,22 +6668,22 @@ function isCanonicalHookBlockPath(p) {
6574
6668
  var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
6575
6669
  message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
6576
6670
  });
6577
- var ManagedBlockRecordSchema = z4.object({
6671
+ var ManagedBlockRecordSchema = z5.object({
6578
6672
  path: ManagedHookBlockPath,
6579
- marker: z4.string(),
6580
- comment: z4.enum(["hash", "html"])
6673
+ marker: z5.string(),
6674
+ comment: z5.enum(["hash", "html"])
6581
6675
  });
6582
- var ManagedManifestSchema = z4.object({
6583
- version: z4.number().int().positive(),
6584
- files: z4.array(SafeRepoRelPath),
6585
- blocks: z4.array(ManagedBlockRecordSchema),
6586
- labels: z4.array(z4.string()),
6587
- agents: z4.array(z4.enum(AGENT_VENDORS)).optional()
6676
+ var ManagedManifestSchema = z5.object({
6677
+ version: z5.number().int().positive(),
6678
+ files: z5.array(SafeRepoRelPath),
6679
+ blocks: z5.array(ManagedBlockRecordSchema),
6680
+ labels: z5.array(z5.string()),
6681
+ agents: z5.array(z5.enum(AGENT_VENDORS)).optional()
6588
6682
  });
6589
- var ProjectEntrySchema = z4.object({
6590
- name: z4.string().min(1),
6591
- description: z4.string().min(1).optional(),
6592
- path: z4.string().min(1).optional()
6683
+ var ProjectEntrySchema = z5.object({
6684
+ name: z5.string().min(1),
6685
+ description: z5.string().min(1).optional(),
6686
+ path: z5.string().min(1).optional()
6593
6687
  });
6594
6688
  function parseTokensCollectDeclaration(value) {
6595
6689
  const m = value.trim().match(/^(\S+)\s+(\S+)$/);
@@ -6600,90 +6694,97 @@ function parseTokensCollectDeclaration(value) {
6600
6694
  return null;
6601
6695
  return { interpreter, script };
6602
6696
  }
6603
- var VinayaConfigSchema = z4.object({
6604
- rings: z4.object({
6605
- ring1_forgeWriteInterception: z4.boolean(),
6606
- ring2_asyncAudits: z4.boolean()
6697
+ var VinayaConfigSchema = z5.object({
6698
+ rings: z5.object({
6699
+ ring1_forgeWriteInterception: z5.boolean(),
6700
+ ring2_asyncAudits: z5.boolean()
6607
6701
  }).optional(),
6608
- checks: z4.record(z4.string(), CheckEntrySchema).optional(),
6609
- roles: z4.record(z4.string(), RoleEntrySchema).optional(),
6702
+ checks: z5.record(z5.string(), CheckEntrySchema).optional(),
6703
+ roles: z5.record(z5.string(), RoleEntrySchema).optional(),
6610
6704
  briefSchema: BriefSchemaSchema.optional(),
6611
6705
  managed: ManagedManifestSchema.optional(),
6612
- principals: z4.array(z4.string()).min(1).optional(),
6613
- releaseActor: z4.string().min(1).optional(),
6614
- ci: z4.object({ setup: z4.string().min(1) }).optional(),
6615
- tokens: z4.object({
6616
- collect: z4.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
6706
+ principals: z5.array(z5.string()).min(1).optional(),
6707
+ releaseActor: z5.string().min(1).optional(),
6708
+ ci: z5.object({ setup: z5.string().min(1) }).optional(),
6709
+ tokens: z5.object({
6710
+ collect: z5.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
6617
6711
  message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
6618
6712
  })
6619
6713
  }).optional(),
6620
- blastRadius: z4.object({ extraDomains: z4.array(z4.string()).optional() }).optional(),
6621
- proseGates: z4.object({
6622
- doctrineRoot: z4.string().min(1).optional(),
6623
- readerFacingPrefix: z4.string().min(1).optional(),
6624
- readerFacingSuffix: z4.string().min(1).optional(),
6625
- legacySlugDir: z4.string().min(1).optional(),
6626
- sourceComments: z4.object({
6627
- globs: z4.array(z4.string().min(1)).optional(),
6628
- allowlist: z4.array(z4.string().min(1)).optional(),
6629
- severity: z4.enum(["warning", "error"]).optional()
6714
+ blastRadius: z5.object({ extraDomains: z5.array(z5.string()).optional() }).optional(),
6715
+ proseGates: z5.object({
6716
+ doctrineRoot: z5.string().min(1).optional(),
6717
+ readerFacingPrefix: z5.string().min(1).optional(),
6718
+ readerFacingSuffix: z5.string().min(1).optional(),
6719
+ legacySlugDir: z5.string().min(1).optional(),
6720
+ sourceComments: z5.object({
6721
+ globs: z5.array(z5.string().min(1)).optional(),
6722
+ allowlist: z5.array(z5.string().min(1)).optional(),
6723
+ severity: z5.enum(["warning", "error"]).optional()
6630
6724
  }).optional(),
6631
- specGrandfather: z4.array(z4.string().min(1)).optional(),
6632
- specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
6725
+ specGrandfather: z5.union([z5.array(z5.string().min(1)), z5.record(z5.string().min(1), z5.number().int().min(0))]).optional(),
6726
+ specPaths: z5.array(z5.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
6633
6727
  message: "must be a repository-relative path, not an absolute one"
6634
6728
  }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
6635
6729
  message: "must stay inside the repository — no `..` segment"
6636
6730
  })).optional()
6637
6731
  }).optional(),
6638
- projects: z4.array(ProjectEntrySchema).optional(),
6639
- dispatch: z4.object({
6640
- timeoutMs: z4.number().int().positive().optional(),
6641
- killGraceMs: z4.number().int().positive().optional(),
6642
- agent: z4.enum(["claude", "codex", "gemini"]).optional(),
6643
- requireWorkerIsolation: z4.boolean().optional()
6732
+ projects: z5.array(ProjectEntrySchema).optional(),
6733
+ dispatch: z5.object({
6734
+ timeoutMs: z5.number().int().positive().optional(),
6735
+ killGraceMs: z5.number().int().positive().optional(),
6736
+ agent: z5.enum(["claude", "codex", "gemini"]).optional()
6644
6737
  }).optional(),
6645
- reviewPolicy: z4.object({
6646
- codeReviewThreshold: z4.string().min(1).optional(),
6647
- securityThreshold: z4.string().min(1).optional(),
6648
- maxRounds: z4.number().optional()
6738
+ reviewPolicy: z5.object({
6739
+ codeReviewThreshold: z5.string().min(1).optional(),
6740
+ securityThreshold: z5.string().min(1).optional(),
6741
+ maxRounds: z5.number().optional(),
6742
+ maxTaskMinutes: z5.number().optional()
6649
6743
  }).optional(),
6650
- gateCutovers: z4.object({
6651
- objectivesSinceIssue: z4.number().int().nonnegative().optional(),
6652
- briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
6653
- documentationSinceIssue: z4.number().int().nonnegative().optional(),
6654
- briefRulesSincePr: z4.number().int().nonnegative().optional(),
6655
- agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
6744
+ securityScan: z5.object({
6745
+ command: z5.array(z5.string().min(1)).min(1)
6656
6746
  }).optional(),
6657
- planning: z4.object({
6658
- collisionThreshold: z4.number().int().nonnegative().optional()
6747
+ gateCutovers: z5.object({
6748
+ objectivesSinceIssue: z5.number().int().nonnegative().optional(),
6749
+ briefSectionsSinceIssue: z5.number().int().nonnegative().optional(),
6750
+ documentationSinceIssue: z5.number().int().nonnegative().optional(),
6751
+ briefRulesSincePr: z5.number().int().nonnegative().optional(),
6752
+ agentBoxesRefusedSincePr: z5.number().int().nonnegative().optional()
6659
6753
  }).optional(),
6660
- prePush: z4.object({
6661
- alwaysRun: z4.array(z4.string()).optional()
6754
+ planning: z5.object({
6755
+ collisionThreshold: z5.number().int().nonnegative().optional()
6662
6756
  }).optional(),
6663
- report: z4.object({
6664
- commandTimeoutMs: z4.number().int().positive().optional()
6757
+ prePush: z5.object({
6758
+ alwaysRun: z5.array(z5.string()).optional()
6759
+ }).optional(),
6760
+ report: z5.object({
6761
+ commandTimeoutMs: z5.number().int().positive().optional()
6665
6762
  }).superRefine((report, ctx) => {
6666
6763
  const commandTimeoutMs = report.commandTimeoutMs;
6667
6764
  if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
6668
6765
  ctx.addIssue({
6669
- code: z4.ZodIssueCode.custom,
6766
+ code: z5.ZodIssueCode.custom,
6670
6767
  path: ["commandTimeoutMs"],
6671
6768
  message: "must be at most 3600000 (1 hour)"
6672
6769
  });
6673
6770
  }
6674
6771
  }).optional(),
6675
- logPublish: z4.unknown().refine((v) => v === undefined, {
6772
+ logPublish: z5.unknown().refine((v) => v === undefined, {
6676
6773
  message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
6677
6774
  }),
6678
- runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
6679
- logs: z4.object({
6680
- folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
6681
- url: z4.string().url().optional(),
6682
- headers: z4.record(z4.string()).optional()
6775
+ runtimeDir: z5.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
6776
+ logs: z5.object({
6777
+ folder: z5.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
6778
+ url: z5.string().url().optional(),
6779
+ headers: z5.record(z5.string()).optional(),
6780
+ readHeaders: z5.record(z5.string()).optional(),
6781
+ events: CustomEventDeclarationsSchema.optional()
6683
6782
  }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
6684
6783
  message: "logs: set at most one of folder/url"
6685
6784
  }).refine((v) => v.headers === undefined || v.url !== undefined, {
6686
6785
  message: "logs: headers requires url"
6786
+ }).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
6787
+ message: "logs: readHeaders requires url"
6687
6788
  }).optional()
6688
6789
  });
6689
6790
  var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
@@ -6788,10 +6889,15 @@ function resolveReviewPolicy(config) {
6788
6889
  if (!Number.isInteger(maxRounds) || maxRounds < 1) {
6789
6890
  throw new Error(`vinaya.config.json: reviewPolicy.maxRounds "${maxRounds}" is not a positive integer — fix the config, this never falls back to a default.`);
6790
6891
  }
6892
+ const maxTaskMinutes = raw.maxTaskMinutes ?? DEFAULT_REVIEW_POLICY.maxTaskMinutes;
6893
+ if (!Number.isInteger(maxTaskMinutes) || maxTaskMinutes < 0) {
6894
+ 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.`);
6895
+ }
6791
6896
  return {
6792
6897
  codeReviewThreshold,
6793
6898
  securityThreshold,
6794
- maxRounds
6899
+ maxRounds,
6900
+ maxTaskMinutes
6795
6901
  };
6796
6902
  }
6797
6903
  function resolveGateCutovers(config) {
@@ -6831,17 +6937,12 @@ function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
6831
6937
  return "url" in anchored && anchored.url === local.url ? anchored : null;
6832
6938
  return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
6833
6939
  }
6834
- function resolveLogsHeaderValues(headers, env, readKeychain = readLogHeaderKeychainCredential) {
6940
+ function resolveLogsHeaderValues(headers, env) {
6835
6941
  if (!headers)
6836
6942
  return;
6837
6943
  const resolved = {};
6838
6944
  for (const [key, value] of Object.entries(headers)) {
6839
- resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => {
6840
- const fromEnv = env[name];
6841
- if (fromEnv !== undefined)
6842
- return fromEnv;
6843
- return readKeychain(name) ?? "";
6844
- });
6945
+ resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
6845
6946
  }
6846
6947
  return resolved;
6847
6948
  }
@@ -6850,7 +6951,7 @@ function trustAnchorRepo() {
6850
6951
  if (fromRunner)
6851
6952
  return fromRunner;
6852
6953
  try {
6853
- const url = execFileSync3("git", ["remote", "get-url", "origin"], {
6954
+ const url = execFileSync2("git", ["remote", "get-url", "origin"], {
6854
6955
  encoding: "utf-8",
6855
6956
  stdio: ["ignore", "pipe", "pipe"]
6856
6957
  });
@@ -6897,7 +6998,7 @@ function resolveCiTrustAnchorProbeRef(env = process.env) {
6897
6998
  return ref;
6898
6999
  }
6899
7000
  function readTrustAnchorConfigAtRef(ref) {
6900
- const raw = execFileSync3("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
7001
+ const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
6901
7002
  encoding: "utf-8",
6902
7003
  stdio: ["ignore", "pipe", "pipe"],
6903
7004
  timeout: 1e4
@@ -6911,7 +7012,7 @@ function ghFetchTrustAnchorConfig() {
6911
7012
  const repo = trustAnchorRepo();
6912
7013
  if (!repo)
6913
7014
  throw new Error("could not resolve repo identity for the trust-anchor read");
6914
- return execFileSync3("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
7015
+ return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
6915
7016
  encoding: "utf-8",
6916
7017
  stdio: ["ignore", "pipe", "pipe"]
6917
7018
  });
@@ -7002,7 +7103,7 @@ function loadConfig() {
7002
7103
  var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
7003
7104
 
7004
7105
  // src/lib/brief-assembly.ts
7005
- import { execFileSync as execFileSync6 } from "node:child_process";
7106
+ import { execFileSync as execFileSync5 } from "node:child_process";
7006
7107
  import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2 } from "node:fs";
7007
7108
  import { join as join4 } from "node:path";
7008
7109
 
@@ -7160,7 +7261,7 @@ var COMMANDS = [
7160
7261
  "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.",
7161
7262
  "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.",
7162
7263
  "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.",
7163
- "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`)."
7264
+ "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`)."
7164
7265
  ],
7165
7266
  status: "shipped"
7166
7267
  },
@@ -7245,13 +7346,14 @@ var COMMANDS = [
7245
7346
  },
7246
7347
  {
7247
7348
  flag: "--push",
7248
- 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."
7349
+ 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."
7249
7350
  }
7250
7351
  ],
7251
7352
  details: [
7252
7353
  "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.",
7253
7354
  "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.",
7254
- "`--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."
7355
+ "`--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.",
7356
+ "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."
7255
7357
  ],
7256
7358
  status: "shipped"
7257
7359
  },
@@ -7276,7 +7378,7 @@ var COMMANDS = [
7276
7378
  "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.",
7277
7379
  "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.",
7278
7380
  "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.",
7279
- "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."
7381
+ "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."
7280
7382
  ],
7281
7383
  status: "shipped"
7282
7384
  },
@@ -7447,7 +7549,7 @@ var COMMANDS = [
7447
7549
  { flag: "--secrets", description: "security only: the SECRETS line" },
7448
7550
  {
7449
7551
  flag: "--secrets-evidence-file",
7450
- description: 'security only: required whenever `--secrets` claims "none found" — the pasted scanner output backing that claim'
7552
+ 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'
7451
7553
  },
7452
7554
  { flag: "--task-id", description: "the closing `Tokens:` line's task id" },
7453
7555
  { flag: "--model", description: "the closing `Tokens:` line's model name" },
@@ -7555,7 +7657,20 @@ var COMMANDS = [
7555
7657
  flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
7556
7658
  details: [
7557
7659
  "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.",
7558
- "Once every task Issue is closed, prompts for confirmation (unless `--yes`) and closes the GitHub Milestone."
7660
+ "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.",
7661
+ "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.",
7662
+ "Idempotent: on a tranche whose Milestone is already closed and carries its retrospective, changes nothing and says it is already archived.",
7663
+ "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."
7664
+ ],
7665
+ status: "shipped"
7666
+ },
7667
+ {
7668
+ name: "archive tranches",
7669
+ description: "Archive every finished tranche that has no closed Milestone carrying its retrospective",
7670
+ flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
7671
+ details: [
7672
+ "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.",
7673
+ "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."
7559
7674
  ],
7560
7675
  status: "shipped"
7561
7676
  },
@@ -7699,6 +7814,29 @@ var COMMANDS = [
7699
7814
  ],
7700
7815
  status: "shipped"
7701
7816
  },
7817
+ {
7818
+ name: "log selftest",
7819
+ 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)",
7820
+ details: [
7821
+ "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.",
7822
+ "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.",
7823
+ "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."
7824
+ ],
7825
+ status: "shipped"
7826
+ },
7827
+ {
7828
+ name: "log emit",
7829
+ description: "Record a consumer-declared event (`logs.events` in vinaya.config.json) from a script or agent outside Vinaya",
7830
+ flags: [
7831
+ { flag: "--json '<json>'", description: "The field values as one JSON object (else read from standard input)" }
7832
+ ],
7833
+ details: [
7834
+ "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.",
7835
+ "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.",
7836
+ "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)."
7837
+ ],
7838
+ status: "shipped"
7839
+ },
7702
7840
  {
7703
7841
  name: "log send",
7704
7842
  description: "Deliver this repository's locally-held log events to the configured `logs.url` server, once",
@@ -7711,12 +7849,19 @@ var COMMANDS = [
7711
7849
  status: "shipped"
7712
7850
  },
7713
7851
  {
7714
- name: "log set-credential",
7715
- description: "Store a `logs.headers` delivery credential in the macOS login Keychain, read from standard input",
7852
+ name: "sync",
7853
+ description: "Fill, resume and rebuild the local log cache from this repository's configured destination (read-only)",
7854
+ flags: [
7855
+ {
7856
+ flag: "--rebuild",
7857
+ description: "Delete the cache file and sync from the beginning of what the destination still retains"
7858
+ },
7859
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
7860
+ ],
7716
7861
  details: [
7717
- '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.',
7718
- '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.',
7719
- "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."
7862
+ "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.",
7863
+ "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.",
7864
+ "`--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."
7720
7865
  ],
7721
7866
  status: "shipped"
7722
7867
  }
@@ -7730,13 +7875,13 @@ function createForgeSource(config) {
7730
7875
  };
7731
7876
  }
7732
7877
  // ../../packages/sources/src/select-source.ts
7733
- import { z as z5 } from "zod";
7734
- var StateSourceConfigSchema = z5.discriminatedUnion("kind", [
7735
- z5.object({ kind: z5.literal("forge"), owner: z5.string(), repo: z5.string() }),
7736
- z5.object({ kind: z5.literal("file"), root: z5.string().optional() })
7878
+ import { z as z6 } from "zod";
7879
+ var StateSourceConfigSchema = z6.discriminatedUnion("kind", [
7880
+ z6.object({ kind: z6.literal("forge"), owner: z6.string(), repo: z6.string() }),
7881
+ z6.object({ kind: z6.literal("file"), root: z6.string().optional() })
7737
7882
  ]);
7738
7883
  // src/checks/edge-resolve.ts
7739
- import { execFileSync as execFileSync4 } from "node:child_process";
7884
+ import { execFileSync as execFileSync3 } from "node:child_process";
7740
7885
  var DIRECT_ISSUE_REF = /#(\d+)/;
7741
7886
  var issueCache = new Map;
7742
7887
  function fetchIssueState(num, repo) {
@@ -7745,7 +7890,7 @@ function fetchIssueState(num, repo) {
7745
7890
  return issueCache.get(key) ?? null;
7746
7891
  let out = null;
7747
7892
  try {
7748
- const raw = execFileSync4("gh", [
7893
+ const raw = execFileSync3("gh", [
7749
7894
  "issue",
7750
7895
  "view",
7751
7896
  String(num),
@@ -7871,17 +8016,26 @@ function packageRoot(moduleUrl) {
7871
8016
  }
7872
8017
 
7873
8018
  // src/commands/doctrine.ts
7874
- import { execFileSync as execFileSync5 } from "node:child_process";
8019
+ import { execFileSync as execFileSync4 } from "node:child_process";
7875
8020
  import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3 } from "node:fs";
7876
8021
  import { dirname as dirname3, join as join3, sep } from "node:path";
8022
+ import matter4 from "gray-matter";
8023
+
8024
+ // ../../packages/aeg-core/src/docs/parse-doc.ts
7877
8025
  import matter2 from "gray-matter";
8026
+ // ../../packages/aeg-core/src/docs/surfaced-manifest.ts
8027
+ var NO_MODEL_BACKED_PATHS = new Set;
8028
+ // src/roles/contract.ts
8029
+ import matter3 from "gray-matter";
8030
+
8031
+ // src/commands/doctrine.ts
7878
8032
  var ENTRY_SEGMENTS = ["skills", "aeg", "SKILL.md"];
7879
8033
  function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
7880
8034
  return resolveDoctrineRootInfo(pkg, cwd)?.root ?? null;
7881
8035
  }
7882
8036
  function gitToplevel(cwd) {
7883
8037
  try {
7884
- return execFileSync5("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
8038
+ return execFileSync4("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
7885
8039
  encoding: "utf8",
7886
8040
  stdio: ["ignore", "pipe", "pipe"]
7887
8041
  }).trim();
@@ -7910,7 +8064,7 @@ var PACKAGED_TEMPLATE_PATH = join4(PACKAGE_ROOT, "aeg-root", "templates", "brief
7910
8064
  var TEMPLATE_PATH = existsSync4(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join4(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
7911
8065
  function git(args) {
7912
8066
  try {
7913
- return execFileSync6("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
8067
+ return execFileSync5("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
7914
8068
  } catch {
7915
8069
  return "";
7916
8070
  }
@@ -7923,12 +8077,16 @@ function expandGlob(glob) {
7923
8077
  var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
7924
8078
 
7925
8079
  // src/checks/registry.ts
7926
- import { existsSync as existsSync5 } from "node:fs";
7927
- import { join as join5 } from "node:path";
7928
- var DIST_BIN_DIR = join5(packageRoot(import.meta.url), "dist", "checks", "bin");
7929
- var SRC_BIN_DIR = join5(packageRoot(import.meta.url), "src", "checks", "bin");
7930
- var BIN_DIR = existsSync5(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
7931
- var BIN_EXT = BIN_DIR === DIST_BIN_DIR ? ".js" : ".ts";
8080
+ import { join as join5, relative, sep as sep2 } from "node:path";
8081
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
8082
+ function resolveCheckBin(packageDir, moduleUrl) {
8083
+ const fromPackage = relative(packageDir, fileURLToPath2(moduleUrl));
8084
+ const bundled = fromPackage === "dist" || fromPackage.startsWith(`dist${sep2}`);
8085
+ return bundled ? { dir: join5(packageDir, "dist", "checks", "bin"), ext: ".js" } : { dir: join5(packageDir, "src", "checks", "bin"), ext: ".ts" };
8086
+ }
8087
+ var CHECK_BIN = resolveCheckBin(packageRoot(import.meta.url), import.meta.url);
8088
+ var BIN_DIR = CHECK_BIN.dir;
8089
+ var BIN_EXT = CHECK_BIN.ext;
7932
8090
  function bin(name) {
7933
8091
  return join5(BIN_DIR, `${name}${BIN_EXT}`);
7934
8092
  }
@@ -8126,23 +8284,6 @@ var REGISTRY = [
8126
8284
  },
8127
8285
  1
8128
8286
  ],
8129
- [
8130
- {
8131
- name: "token-report",
8132
- validates: "body",
8133
- run: bin("check-token-report"),
8134
- scope: "diff",
8135
- timeoutMs: 15000,
8136
- requiresOpenPr: true,
8137
- env: {
8138
- PR_BODY: { optional: true },
8139
- BRANCH: { optional: true },
8140
- CLAUDE_PROJECT_DIR: { optional: true },
8141
- CLAUDE_CODE_SESSION_ID: { optional: true }
8142
- }
8143
- },
8144
- 1
8145
- ],
8146
8287
  [
8147
8288
  {
8148
8289
  name: "no-disk-state",
@@ -8492,23 +8633,35 @@ var CORE_CHECK_RING = Object.fromEntries(REGISTRY.map(([spec, ring]) => [spec.na
8492
8633
  import { execFile as execFile5 } from "node:child_process";
8493
8634
  import { randomUUID as randomUUID2 } from "node:crypto";
8494
8635
  import {
8495
- closeSync as closeSync3,
8496
- constants as fsConstants3,
8636
+ appendFileSync,
8637
+ closeSync as closeSync4,
8638
+ constants as fsConstants4,
8497
8639
  existsSync as existsSync7,
8498
- fstatSync as fstatSync2,
8499
- mkdirSync as mkdirSync3,
8500
- openSync as openSync3,
8501
- readFileSync as readFileSync6,
8640
+ fstatSync as fstatSync3,
8641
+ mkdirSync as mkdirSync4,
8642
+ lstatSync as lstatSync2,
8643
+ openSync as openSync4,
8644
+ readFileSync as readFileSync7,
8502
8645
  renameSync as renameSync2,
8503
- writeSync as writeSync2
8646
+ writeFileSync as writeFileSync3,
8647
+ writeSync as writeSync3
8504
8648
  } from "node:fs";
8505
8649
  import { hostname as osHostname, homedir as homedir3 } from "node:os";
8506
- import { dirname as dirname6, join as join8 } from "node:path";
8650
+ import { dirname as dirname7, join as join8 } from "node:path";
8507
8651
  import { promisify as promisify5 } from "node:util";
8508
8652
 
8509
8653
  // src/lib/run-paths.ts
8510
- import { chmodSync, existsSync as existsSync6, realpathSync as realpathSync2 } from "node:fs";
8654
+ import { execFileSync as execFileSync6 } from "node:child_process";
8655
+ import { chmodSync, existsSync as existsSync5, realpathSync as realpathSync2 } from "node:fs";
8511
8656
  import { dirname as dirname4, join as join6, resolve as resolvePath } from "node:path";
8657
+ var TASKS_EXECUTION_DIRNAME = "tasks-execution";
8658
+ var RUN_AREA_DIRNAMES = {
8659
+ control: CONTROL_AREA_DIRNAME,
8660
+ sessions: "sessions",
8661
+ hooks: "hooks",
8662
+ output: "output",
8663
+ rounds: "rounds"
8664
+ };
8512
8665
  var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8513
8666
  function isSafeRepoSegment(segment) {
8514
8667
  return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
@@ -8539,12 +8692,52 @@ function isInsideRepo(candidate, repoRoot) {
8539
8692
  const target = resolvePath(candidate);
8540
8693
  return target === root || target.startsWith(`${root}/`);
8541
8694
  }
8695
+ function runPath(runtimeDir, scope, location) {
8696
+ const dir = join6(runtimeDir, TASKS_EXECUTION_DIRNAME, scopeSegment(scope));
8697
+ switch (location.area) {
8698
+ case "task":
8699
+ return location.file ? join6(dir, location.file) : dir;
8700
+ case "control": {
8701
+ const controlDir = join6(dir, RUN_AREA_DIRNAMES.control);
8702
+ return location.file ? join6(controlDir, location.file) : controlDir;
8703
+ }
8704
+ case "rounds":
8705
+ return join6(dir, RUN_AREA_DIRNAMES.rounds);
8706
+ case "round": {
8707
+ const roundDir = join6(dir, RUN_AREA_DIRNAMES.rounds, String(location.round));
8708
+ return location.file ? join6(roundDir, location.file) : roundDir;
8709
+ }
8710
+ case "developer": {
8711
+ const developerDir = join6(dir, RUN_AREA_DIRNAMES.rounds, String(location.round), "developer");
8712
+ return location.file ? join6(developerDir, location.file) : developerDir;
8713
+ }
8714
+ default: {
8715
+ const areaDir = join6(dir, RUN_AREA_DIRNAMES[location.area]);
8716
+ return location.file ? join6(areaDir, location.file) : areaDir;
8717
+ }
8718
+ }
8719
+ }
8720
+ function scopeSegment(scope) {
8721
+ if (scope === "unscoped")
8722
+ return "unscoped";
8723
+ if (typeof scope === "number")
8724
+ return String(scope);
8725
+ return `pr-${scope.pr}`;
8726
+ }
8542
8727
  var UNATTENDED_ENV_KEY = "VINAYA_UNATTENDED";
8543
8728
  var RUNTIME_DIR_ENV_KEY = "VINAYA_RUNTIME_DIR";
8544
8729
  function isUnattendedProcess(env = process.env) {
8545
8730
  return env[UNATTENDED_ENV_KEY] === "1" || (env.VINAYA_ROLE ?? "") !== "";
8546
8731
  }
8547
8732
  var memoized = null;
8733
+ function runtimeDirForRepo(repo) {
8734
+ const key = repoSegment(repo);
8735
+ if (memoized?.key === key)
8736
+ return memoized.value;
8737
+ const value = resolveRuntimeDirUncached(repo);
8738
+ memoized = { key, value };
8739
+ return value;
8740
+ }
8548
8741
  async function runtimeDirForRepoAsync(repo) {
8549
8742
  const key = repoSegment(repo);
8550
8743
  if (memoized?.key === key)
@@ -8560,6 +8753,16 @@ async function runtimeDirForRepoAsync(repo) {
8560
8753
  memoized = { key, value };
8561
8754
  return value;
8562
8755
  }
8756
+ function resolveRuntimeDirUncached(repo) {
8757
+ const inputs = runtimeDirInputs();
8758
+ if (typeof inputs === "string")
8759
+ return inputs;
8760
+ return resolveRuntimeDir({
8761
+ repo,
8762
+ ...inputs.base,
8763
+ trustAnchorConfig: inputs.needsAnchor ? loadTrustAnchorConfig() : null
8764
+ });
8765
+ }
8563
8766
  function runtimeDirInputs() {
8564
8767
  const handedDown = process.env[RUNTIME_DIR_ENV_KEY];
8565
8768
  if (handedDown)
@@ -8579,7 +8782,7 @@ function repoRootSync(start = process.cwd()) {
8579
8782
  return null;
8580
8783
  }
8581
8784
  for (;; ) {
8582
- if (existsSync6(join6(dir, ".git")))
8785
+ if (existsSync5(join6(dir, ".git")))
8583
8786
  return dir;
8584
8787
  const parent = dirname4(dir);
8585
8788
  if (parent === dir)
@@ -8587,26 +8790,94 @@ function repoRootSync(start = process.cwd()) {
8587
8790
  dir = parent;
8588
8791
  }
8589
8792
  }
8793
+ function resolveRepoSync() {
8794
+ const fromEnv = process.env.AEG_REPO;
8795
+ if (fromEnv) {
8796
+ const m = /^([^/]+)\/(.+)$/.exec(fromEnv);
8797
+ if (m?.[1] && m[2])
8798
+ return { owner: m[1], repo: m[2] };
8799
+ }
8800
+ let url;
8801
+ try {
8802
+ url = execFileSync6("git", ["remote", "get-url", "origin"], {
8803
+ encoding: "utf-8",
8804
+ stdio: ["ignore", "pipe", "pipe"]
8805
+ }).trim();
8806
+ } catch {
8807
+ return null;
8808
+ }
8809
+ const ssh = /^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/.exec(url);
8810
+ if (ssh?.[1] && ssh[2])
8811
+ return { owner: ssh[1], repo: ssh[2] };
8812
+ const https = /^https?:\/\/(?:[^@]+@)?github\.com\/([^/]+)\/(.+?)(?:\.git)?\/?$/.exec(url);
8813
+ if (https?.[1] && https[2])
8814
+ return { owner: https[1], repo: https[2] };
8815
+ return null;
8816
+ }
8817
+ var memoizedThisRepo = null;
8818
+ function runtimeDirForThisRepo() {
8819
+ if (memoizedThisRepo !== null)
8820
+ return memoizedThisRepo;
8821
+ memoizedThisRepo = runtimeDirForRepo(resolveRepoSync());
8822
+ return memoizedThisRepo;
8823
+ }
8590
8824
 
8591
- // src/lib/log-webhook-drain.ts
8825
+ // src/lib/loop-log.ts
8592
8826
  import {
8593
8827
  closeSync as closeSync2,
8594
8828
  constants as fsConstants2,
8595
- lstatSync,
8829
+ existsSync as existsSync6,
8830
+ fstatSync as fstatSync2,
8596
8831
  mkdirSync as mkdirSync2,
8597
8832
  openSync as openSync2,
8598
- linkSync,
8599
8833
  readFileSync as readFileSync5,
8600
- renameSync,
8834
+ readSync,
8601
8835
  statSync,
8836
+ writeSync
8837
+ } from "node:fs";
8838
+ import { dirname as dirname5 } from "node:path";
8839
+ function loopsRoot() {
8840
+ return runtimeDirForThisRepo();
8841
+ }
8842
+ function loopLogPathFor(_repo, issue, root = loopsRoot()) {
8843
+ return runPath(root, issue, { area: "output", file: "driver.log" });
8844
+ }
8845
+ var LOOP_LOG_MAX_BYTES = 8 * 1024 * 1024;
8846
+ function appendLoopLogLine(path, line) {
8847
+ try {
8848
+ mkdirSync2(dirname5(path), { recursive: true, mode: 448 });
8849
+ const fd = openSync2(path, fsConstants2.O_WRONLY | fsConstants2.O_APPEND | fsConstants2.O_CREAT | fsConstants2.O_NOFOLLOW, 384);
8850
+ try {
8851
+ const stat = fstatSync2(fd);
8852
+ if (stat.isFile() && stat.size < LOOP_LOG_MAX_BYTES) {
8853
+ writeSync(fd, `${line}
8854
+ `);
8855
+ }
8856
+ } finally {
8857
+ closeSync2(fd);
8858
+ }
8859
+ } catch {}
8860
+ }
8861
+
8862
+ // src/lib/log-webhook-drain.ts
8863
+ import {
8864
+ closeSync as closeSync3,
8865
+ constants as fsConstants3,
8866
+ lstatSync,
8867
+ mkdirSync as mkdirSync3,
8868
+ openSync as openSync3,
8869
+ linkSync,
8870
+ readFileSync as readFileSync6,
8871
+ renameSync,
8872
+ statSync as statSync2,
8602
8873
  unlinkSync,
8603
8874
  utimesSync,
8604
8875
  writeFileSync as writeFileSync2,
8605
- writeSync
8876
+ writeSync as writeSync2
8606
8877
  } from "node:fs";
8607
8878
  import { randomUUID } from "node:crypto";
8608
8879
  import { homedir as homedir2 } from "node:os";
8609
- import { dirname as dirname5, join as join7 } from "node:path";
8880
+ import { dirname as dirname6, join as join7 } from "node:path";
8610
8881
  var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
8611
8882
  var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
8612
8883
  var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
@@ -8622,13 +8893,13 @@ function isEnoent(err) {
8622
8893
  var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
8623
8894
  function tryCreateLock(lockPath, token) {
8624
8895
  try {
8625
- mkdirSync2(dirname5(lockPath), { recursive: true, mode: 448 });
8626
- const fd = openSync2(lockPath, fsConstants2.O_WRONLY | fsConstants2.O_CREAT | fsConstants2.O_EXCL, 384);
8896
+ mkdirSync3(dirname6(lockPath), { recursive: true, mode: 448 });
8897
+ const fd = openSync3(lockPath, fsConstants3.O_WRONLY | fsConstants3.O_CREAT | fsConstants3.O_EXCL, 384);
8627
8898
  try {
8628
- writeSync(fd, `${token}
8899
+ writeSync2(fd, `${token}
8629
8900
  `);
8630
8901
  } finally {
8631
- closeSync2(fd);
8902
+ closeSync3(fd);
8632
8903
  }
8633
8904
  return true;
8634
8905
  } catch (err) {
@@ -8643,7 +8914,7 @@ function acquireDrainLock(lockPath) {
8643
8914
  return token;
8644
8915
  let observedMtimeMs;
8645
8916
  try {
8646
- observedMtimeMs = statSync(lockPath).mtimeMs;
8917
+ observedMtimeMs = statSync2(lockPath).mtimeMs;
8647
8918
  } catch (err) {
8648
8919
  if (!isEnoent(err))
8649
8920
  throw err;
@@ -8661,7 +8932,7 @@ function acquireDrainLock(lockPath) {
8661
8932
  }
8662
8933
  let claimedMtimeMs = null;
8663
8934
  try {
8664
- claimedMtimeMs = statSync(claimed).mtimeMs;
8935
+ claimedMtimeMs = statSync2(claimed).mtimeMs;
8665
8936
  } catch (err) {
8666
8937
  if (!isEnoent(err))
8667
8938
  throw err;
@@ -8687,7 +8958,7 @@ function acquireDrainLock(lockPath) {
8687
8958
  function renewDrainLock(lockPath, token) {
8688
8959
  let holder;
8689
8960
  try {
8690
- holder = readFileSync5(lockPath, "utf8").trim();
8961
+ holder = readFileSync6(lockPath, "utf8").trim();
8691
8962
  } catch (err) {
8692
8963
  if (!isEnoent(err))
8693
8964
  throw err;
@@ -8707,7 +8978,7 @@ function renewDrainLock(lockPath, token) {
8707
8978
  }
8708
8979
  function releaseDrainLock(lockPath, token) {
8709
8980
  try {
8710
- const holder = readFileSync5(lockPath, "utf8").trim();
8981
+ const holder = readFileSync6(lockPath, "utf8").trim();
8711
8982
  if (holder !== token)
8712
8983
  return;
8713
8984
  unlinkSync(lockPath);
@@ -8757,7 +9028,7 @@ function queueLines(buf) {
8757
9028
  return lines;
8758
9029
  }
8759
9030
  function removeQueueHead(path, cut) {
8760
- const remaining = readFileSync5(path);
9031
+ const remaining = readFileSync6(path);
8761
9032
  writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
8762
9033
  }
8763
9034
  function queueBucketSize(path) {
@@ -8778,7 +9049,7 @@ function queueBucketSize(path) {
8778
9049
  function readQueueFile(path) {
8779
9050
  if (queueBucketSize(path) === null)
8780
9051
  return null;
8781
- return readFileSync5(path);
9052
+ return readFileSync6(path);
8782
9053
  }
8783
9054
  function rejectLine(rejectedPath, reason, status, identity, raw) {
8784
9055
  const record = JSON.stringify({
@@ -8960,13 +9231,19 @@ function logsCredentialMissing(headers, env) {
8960
9231
  const varPattern = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
8961
9232
  for (const value of Object.values(headers)) {
8962
9233
  for (const match of value.matchAll(varPattern)) {
8963
- if (!env[match[1]])
8964
- return true;
9234
+ const name = match[1];
9235
+ if (env[name])
9236
+ continue;
9237
+ return true;
8965
9238
  }
8966
9239
  }
8967
9240
  return false;
8968
9241
  }
8969
9242
  function resolveLogDestinationFrom(input) {
9243
+ const spoolDir = input.env.VINAYA_LOG_SPOOL_DIR;
9244
+ if (spoolDir !== undefined && spoolDir.trim() !== "") {
9245
+ return { kind: "folder", folder: spoolDir };
9246
+ }
8970
9247
  const local = resolveLogsSetting(input.localConfig);
8971
9248
  let effective = null;
8972
9249
  let fallbackReason;
@@ -9006,23 +9283,72 @@ function resolveLogDestinationFrom(input) {
9006
9283
  const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
9007
9284
  return fallbackReason ? { kind: "folder", folder, fallbackReason } : { kind: "folder", folder };
9008
9285
  }
9009
- var processTrustAnchorOnce;
9010
- function processTrustAnchor() {
9011
- if (processTrustAnchorOnce === undefined)
9012
- processTrustAnchorOnce = safeLoadTrustAnchorConfig();
9013
- return processTrustAnchorOnce;
9286
+ var processTrustAnchorByRepo = new Map;
9287
+ function processTrustAnchor(repoRoot) {
9288
+ const cached = processTrustAnchorByRepo.get(repoRoot);
9289
+ if (cached !== undefined)
9290
+ return cached;
9291
+ const reading = safeLoadTrustAnchorConfig();
9292
+ processTrustAnchorByRepo.set(repoRoot, reading);
9293
+ return reading;
9014
9294
  }
9015
9295
  async function defaultResolveLogDestination(repo, env) {
9016
9296
  const localConfig = loadConfig();
9017
9297
  const unattended = isUnattendedProcess(process.env);
9298
+ const repoRoot = repoRootSync();
9018
9299
  return resolveLogDestinationFrom({
9019
9300
  localConfig,
9020
- trustAnchorConfig: unattended ? await processTrustAnchor() : null,
9301
+ trustAnchorConfig: unattended ? await processTrustAnchor(repoRoot) : null,
9021
9302
  unattended,
9022
9303
  env,
9023
9304
  defaultFolder: join8(await runtimeDirForRepoAsync(repo), "logs"),
9024
- repoRoot: repoRootSync()
9305
+ repoRoot
9306
+ });
9307
+ }
9308
+ function unresolvedLogDestination(env) {
9309
+ if (hostFromEnv(env) === "ci") {
9310
+ return {
9311
+ kind: "none",
9312
+ reason: "the process ended before its log destination was resolved, and a CI job never records to a folder"
9313
+ };
9314
+ }
9315
+ const loaded = loadConfig();
9316
+ const localConfig = loaded?.logs?.url !== undefined ? { ...loaded, logs: undefined } : loaded;
9317
+ const unattended = isUnattendedProcess(process.env);
9318
+ const repoRoot = repoRootSync();
9319
+ const runtimeDir = process.env[RUNTIME_DIR_ENV_KEY] || resolveRuntimeDir({ repo: null, localConfig, trustAnchorConfig: null, unattended, repoRoot });
9320
+ const defaultFolder = join8(runtimeDir, "logs");
9321
+ const resolved = resolveLogDestinationFrom({
9322
+ localConfig,
9323
+ trustAnchorConfig: null,
9324
+ unattended,
9325
+ env,
9326
+ defaultFolder,
9327
+ repoRoot
9025
9328
  });
9329
+ return resolved.kind === "folder" ? resolved : { kind: "folder", folder: defaultFolder };
9330
+ }
9331
+ function folderFallbackStatePath(repo, stateRoot = GLOBAL_VINAYA_HOME) {
9332
+ const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
9333
+ return join8(stateRoot, "fallback", `${dirName}.json`);
9334
+ }
9335
+ function recordFolderFallback(repo, issue, reason, now, runtimeDir, stateRoot = GLOBAL_VINAYA_HOME) {
9336
+ const message = describeFolderFallback(reason);
9337
+ if (issue !== null) {
9338
+ appendLoopLogLine(loopLogPathFor(repo, issue, runtimeDir), `[log] ${message}`);
9339
+ }
9340
+ try {
9341
+ const record = {
9342
+ at: now.toISOString(),
9343
+ reason: message,
9344
+ intendedUrl: reason.intendedUrl,
9345
+ kind: reason.kind
9346
+ };
9347
+ const path = folderFallbackStatePath(repo, stateRoot);
9348
+ mkdirSync4(dirname7(path), { recursive: true, mode: 448 });
9349
+ writeFileSync3(path, `${JSON.stringify(record)}
9350
+ `, { mode: 384 });
9351
+ } catch {}
9026
9352
  }
9027
9353
  function isEnoent2(err) {
9028
9354
  return typeof err === "object" && err !== null && err.code === "ENOENT";
@@ -9136,7 +9462,7 @@ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
9136
9462
  }
9137
9463
  function readVinayaVersion() {
9138
9464
  try {
9139
- const pkg = JSON.parse(readFileSync6(join8(packageRoot(import.meta.url), "package.json"), "utf8"));
9465
+ const pkg = JSON.parse(readFileSync7(join8(packageRoot(import.meta.url), "package.json"), "utf8"));
9140
9466
  return pkg.version ?? "unknown";
9141
9467
  } catch {
9142
9468
  return "unknown";
@@ -9174,6 +9500,7 @@ function defaultStderr(message) {
9174
9500
  }
9175
9501
  var branchIssueFallbackEnabled = true;
9176
9502
  var branchIssueByCwd = new Map;
9503
+ var branchIssueSettledByCwd = new Map;
9177
9504
  function branchIssueRead(key, read, shared) {
9178
9505
  if (!shared)
9179
9506
  return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
@@ -9182,8 +9509,30 @@ function branchIssueRead(key, read, shared) {
9182
9509
  return cached;
9183
9510
  const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9184
9511
  branchIssueByCwd.set(key, reading);
9512
+ reading.then((value) => branchIssueSettledByCwd.set(key, value));
9185
9513
  return reading;
9186
9514
  }
9515
+ var headShaByCwd = new Map;
9516
+ var headShaSettledByCwd = new Map;
9517
+ function headShaRead(key, read, shared) {
9518
+ if (!shared)
9519
+ return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9520
+ const cached = headShaByCwd.get(key);
9521
+ if (cached !== undefined)
9522
+ return cached;
9523
+ const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9524
+ headShaByCwd.set(key, reading);
9525
+ reading.then((value) => headShaSettledByCwd.set(key, value));
9526
+ return reading;
9527
+ }
9528
+ async function resolveHeadSha(cwd) {
9529
+ try {
9530
+ const out = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "HEAD"], { encoding: "utf8" })).stdout.trim();
9531
+ return /^[0-9a-f]{40}$/.test(out) ? out : null;
9532
+ } catch {
9533
+ return null;
9534
+ }
9535
+ }
9187
9536
  function defaultDeps() {
9188
9537
  return {
9189
9538
  outboxRoot: () => join8(GLOBAL_VINAYA_HOME, "outbox"),
@@ -9198,29 +9547,30 @@ function defaultDeps() {
9198
9547
  inputVersions: () => {
9199
9548
  return;
9200
9549
  },
9201
- resolveLogDestination: defaultResolveLogDestination
9550
+ resolveLogDestination: defaultResolveLogDestination,
9551
+ unresolvedLogDestination
9202
9552
  };
9203
9553
  }
9204
- var APPEND_OPEN_FLAGS = fsConstants3.O_WRONLY | fsConstants3.O_APPEND | fsConstants3.O_CREAT | fsConstants3.O_NOFOLLOW | fsConstants3.O_NONBLOCK;
9554
+ var APPEND_OPEN_FLAGS = fsConstants4.O_WRONLY | fsConstants4.O_APPEND | fsConstants4.O_CREAT | fsConstants4.O_NOFOLLOW | fsConstants4.O_NONBLOCK;
9205
9555
  function guardedAppendOpen(path) {
9206
9556
  try {
9207
- return openSync3(path, APPEND_OPEN_FLAGS, 384);
9557
+ return openSync4(path, APPEND_OPEN_FLAGS, 384);
9208
9558
  } catch {
9209
9559
  return;
9210
9560
  }
9211
9561
  }
9212
9562
  function appendHardenedLine(path, line) {
9213
9563
  try {
9214
- mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
9564
+ mkdirSync4(dirname7(path), { recursive: true, mode: 448 });
9215
9565
  const fd = guardedAppendOpen(path);
9216
9566
  if (fd === undefined)
9217
9567
  return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
9218
9568
  try {
9219
- if (!fstatSync2(fd).isFile())
9569
+ if (!fstatSync3(fd).isFile())
9220
9570
  return `target is not a regular file: ${path}`;
9221
- writeSync2(fd, line);
9571
+ writeSync3(fd, line);
9222
9572
  } finally {
9223
- closeSync3(fd);
9573
+ closeSync4(fd);
9224
9574
  }
9225
9575
  return null;
9226
9576
  } catch (err) {
@@ -9230,7 +9580,7 @@ function appendHardenedLine(path, line) {
9230
9580
  function reportRotationOverflow(backupPath, warn) {
9231
9581
  let raw;
9232
9582
  try {
9233
- raw = readFileSync6(backupPath, "utf8");
9583
+ raw = readFileSync7(backupPath, "utf8");
9234
9584
  } catch {
9235
9585
  return;
9236
9586
  }
@@ -9253,7 +9603,7 @@ function reportRotationOverflow(backupPath, warn) {
9253
9603
  }
9254
9604
  function appendLine(path, line, warn) {
9255
9605
  try {
9256
- mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
9606
+ mkdirSync4(dirname7(path), { recursive: true, mode: 448 });
9257
9607
  let fd = guardedAppendOpen(path);
9258
9608
  if (fd === undefined) {
9259
9609
  warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
@@ -9262,14 +9612,14 @@ function appendLine(path, line, warn) {
9262
9612
  }
9263
9613
  let closed = false;
9264
9614
  try {
9265
- const stat = fstatSync2(fd);
9615
+ const stat = fstatSync3(fd);
9266
9616
  if (!stat.isFile()) {
9267
9617
  warn(`vinaya: log outbox target is not a regular file — refusing to write: ${path}
9268
9618
  `);
9269
9619
  return;
9270
9620
  }
9271
9621
  if (stat.size > OUTBOX_MAX_BYTES) {
9272
- closeSync3(fd);
9622
+ closeSync4(fd);
9273
9623
  closed = true;
9274
9624
  const backupPath = path.replace(/\.ndjson$/, ".1.ndjson");
9275
9625
  reportRotationOverflow(backupPath, warn);
@@ -9283,10 +9633,10 @@ function appendLine(path, line, warn) {
9283
9633
  fd = rotated;
9284
9634
  closed = false;
9285
9635
  }
9286
- writeSync2(fd, line);
9636
+ writeSync3(fd, line);
9287
9637
  } finally {
9288
9638
  if (!closed)
9289
- closeSync3(fd);
9639
+ closeSync4(fd);
9290
9640
  }
9291
9641
  } catch (err) {
9292
9642
  warn(`vinaya: log outbox write failed — ${err instanceof Error ? err.message : String(err)}
@@ -9297,12 +9647,14 @@ function createLogSink(overrides = {}) {
9297
9647
  const deps = {
9298
9648
  ...defaultDeps(),
9299
9649
  resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
9650
+ resolveHeadSha: () => resolveHeadSha(deps.cwd()),
9300
9651
  ...overrides
9301
9652
  };
9302
9653
  const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
9303
9654
  const processId = randomUUID2();
9304
9655
  let seq = 0;
9305
9656
  let warned = false;
9657
+ let folderFallbackRecorded = false;
9306
9658
  const warnOnce = (message) => {
9307
9659
  if (warned)
9308
9660
  return;
@@ -9320,6 +9672,7 @@ function createLogSink(overrides = {}) {
9320
9672
  };
9321
9673
  const readerIsReal = overrides.resolveBranchIssue === undefined;
9322
9674
  let ownBranchIssue;
9675
+ let ownBranchIssueSettled = null;
9323
9676
  const branchIssueOnce = (repo) => {
9324
9677
  if (!branchIssueFallbackEnabled)
9325
9678
  return Promise.resolve(null);
@@ -9327,10 +9680,36 @@ function createLogSink(overrides = {}) {
9327
9680
  const read = () => deps.resolveBranchIssue(slug);
9328
9681
  if (readerIsReal)
9329
9682
  return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
9330
- if (ownBranchIssue === undefined)
9683
+ if (ownBranchIssue === undefined) {
9331
9684
  ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
9685
+ ownBranchIssue.then((value) => {
9686
+ ownBranchIssueSettled = value;
9687
+ });
9688
+ }
9332
9689
  return ownBranchIssue;
9333
9690
  };
9691
+ const branchIssueIfSettled = (repo) => {
9692
+ if (!branchIssueFallbackEnabled)
9693
+ return null;
9694
+ if (!readerIsReal)
9695
+ return ownBranchIssueSettled;
9696
+ return branchIssueSettledByCwd.get(`${deps.cwd()}\x00${safeRepoSlug(repo) ?? ""}`) ?? null;
9697
+ };
9698
+ const headShaReaderIsReal = overrides.resolveHeadSha === undefined;
9699
+ let ownHeadSha;
9700
+ let ownHeadShaSettled = null;
9701
+ const headShaOnce = () => {
9702
+ if (headShaReaderIsReal)
9703
+ return headShaRead(deps.cwd(), deps.resolveHeadSha, true);
9704
+ if (ownHeadSha === undefined) {
9705
+ ownHeadSha = headShaRead(deps.cwd(), deps.resolveHeadSha, false);
9706
+ ownHeadSha.then((value) => {
9707
+ ownHeadShaSettled = value;
9708
+ });
9709
+ }
9710
+ return ownHeadSha;
9711
+ };
9712
+ const headShaIfSettled = () => headShaReaderIsReal ? headShaSettledByCwd.get(deps.cwd()) ?? null : ownHeadShaSettled;
9334
9713
  let resolveRepoCache;
9335
9714
  const resolveRepoOnce = () => {
9336
9715
  if (resolveRepoCache === undefined)
@@ -9338,6 +9717,7 @@ function createLogSink(overrides = {}) {
9338
9717
  return resolveRepoCache;
9339
9718
  };
9340
9719
  let contextCache;
9720
+ let settledContext;
9341
9721
  const context = () => {
9342
9722
  if (contextCache === undefined) {
9343
9723
  const env = deps.env();
@@ -9346,11 +9726,16 @@ function createLogSink(overrides = {}) {
9346
9726
  doctrine()
9347
9727
  ]).then(async ([resolved, doctrineValue]) => {
9348
9728
  const repo = resolved && isSafeRepoSegment3(resolved.owner) && isSafeRepoSegment3(resolved.repo) ? resolved : null;
9349
- return { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
9729
+ settledContext = { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
9730
+ return settledContext;
9350
9731
  });
9351
9732
  }
9352
9733
  return contextCache;
9353
9734
  };
9735
+ const resetContext = () => {
9736
+ contextCache = undefined;
9737
+ settledContext = undefined;
9738
+ };
9354
9739
  let drainChain = Promise.resolve();
9355
9740
  const pendingWrites = new Set;
9356
9741
  let writeChain = Promise.resolve();
@@ -9362,63 +9747,88 @@ function createLogSink(overrides = {}) {
9362
9747
  `);
9363
9748
  });
9364
9749
  };
9365
- function log(e) {
9366
- try {
9367
- const env = deps.env();
9368
- const host = hostFromEnv(env);
9369
- const now = deps.now();
9370
- const mySeq = seq++;
9371
- const envFields = {
9750
+ const snapshot = () => {
9751
+ const env = deps.env();
9752
+ return {
9753
+ host: hostFromEnv(env),
9754
+ now: deps.now(),
9755
+ seq: seq++,
9756
+ envFields: {
9372
9757
  role: env.VINAYA_ROLE,
9373
9758
  task: env.VINAYA_TASK,
9374
9759
  round: env.VINAYA_ROUND,
9760
+ pr: env.VINAYA_PR,
9375
9761
  run: env.VINAYA_RUN || runId,
9376
9762
  attempt: env.VINAYA_ATTEMPT,
9377
- parent: env.VINAYA_PARENT_EVENT
9378
- };
9379
- const write = async () => {
9380
- const { repo, doctrine: doctrineValue, destination: resolvedDestination } = await context();
9381
- if (resolvedDestination.kind === "none") {
9382
- warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
9763
+ parent: env.VINAYA_PARENT_EVENT,
9764
+ workRef: env.VINAYA_WORK_REF,
9765
+ flow: env.VINAYA_FLOW,
9766
+ flowVersion: env.VINAYA_FLOW_VERSION,
9767
+ runtime: env.VINAYA_RUNTIME,
9768
+ source: env.VINAYA_SOURCE
9769
+ }
9770
+ };
9771
+ };
9772
+ const writeEvent = (e, call, ctx, branchIssue, headSha, deliver) => {
9773
+ const { repo, doctrine: doctrineValue, destination } = ctx;
9774
+ if (destination.kind === "none") {
9775
+ warnOnce(`vinaya: not recording — ${destination.reason}
9383
9776
  `);
9384
- return;
9385
- }
9386
- if (resolvedDestination.kind === "folder" && resolvedDestination.fallbackReason) {
9387
- warnOnce(`vinaya: ${describeFolderFallback(resolvedDestination.fallbackReason)}
9777
+ return;
9778
+ }
9779
+ if (destination.kind === "folder" && destination.fallbackReason) {
9780
+ warnOnce(`vinaya: ${describeFolderFallback(destination.fallbackReason)}
9388
9781
  `);
9389
- }
9390
- const branchIssue = envFields.task ? null : await branchIssueOnce(repo);
9391
- const header = buildHeader({
9392
- now,
9393
- runId,
9394
- seq: mySeq,
9395
- repo: repo ? `${repo.owner}/${repo.repo}` : null,
9396
- vinaya: deps.vinayaVersion(),
9397
- doctrine: doctrineValue,
9398
- host,
9399
- hostname: deps.hostname(),
9400
- env: envFields,
9401
- branchIssue,
9402
- eventId: randomUUID2(),
9403
- processId,
9404
- inputVersions: deps.inputVersions()
9405
- });
9406
- const full = { ...e, ...header };
9407
- const parsed = LogEventSchema.safeParse(full);
9408
- if (!parsed.success) {
9409
- warnOnce(`vinaya: log() refused an invalid payload — ${parsed.error.issues[0]?.message ?? "schema violation"}
9782
+ }
9783
+ const built = buildHeader({
9784
+ now: call.now,
9785
+ runId,
9786
+ seq: call.seq,
9787
+ repo: repo ? `${repo.owner}/${repo.repo}` : null,
9788
+ vinaya: deps.vinayaVersion(),
9789
+ doctrine: doctrineValue,
9790
+ host: call.host,
9791
+ hostname: deps.hostname(),
9792
+ env: call.envFields,
9793
+ branchIssue,
9794
+ eventId: randomUUID2(),
9795
+ processId,
9796
+ inputVersions: deps.inputVersions()
9797
+ });
9798
+ const header = headSha === null ? built : { ...built, subject: { ...built.subject, sha: headSha } };
9799
+ if (destination.kind === "folder" && destination.fallbackReason && !folderFallbackRecorded) {
9800
+ folderFallbackRecorded = true;
9801
+ recordFolderFallback(repo, header.subject.issue, destination.fallbackReason, call.now, dirname7(destination.folder), join8(deps.home(), ".vinaya"));
9802
+ }
9803
+ const full = { ...e, ...header };
9804
+ const parsed = LogEventSchema.safeParse(full);
9805
+ if (!parsed.success) {
9806
+ warnOnce(`vinaya: log() refused an invalid payload — ${parsed.error.issues[0]?.message ?? "schema violation"}
9410
9807
  `);
9411
- return;
9412
- }
9413
- const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
9808
+ return;
9809
+ }
9810
+ const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
9414
9811
  `;
9415
- const destination = resolvedDestination;
9416
- if (destination.kind === "server") {
9417
- appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
9418
- scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
9419
- } else {
9420
- appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
9812
+ if (destination.kind === "server") {
9813
+ appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
9814
+ if (deliver)
9815
+ scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
9816
+ } else {
9817
+ appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
9818
+ }
9819
+ };
9820
+ function log(e) {
9821
+ try {
9822
+ const call = snapshot();
9823
+ const write = async () => {
9824
+ const ctx = await context();
9825
+ if (ctx.destination.kind === "none") {
9826
+ writeEvent(e, call, ctx, null, null, true);
9827
+ return;
9421
9828
  }
9829
+ const branchIssue = call.envFields.task ? null : await branchIssueOnce(ctx.repo);
9830
+ const headSha = e.kind === "gate" ? await headShaOnce() : null;
9831
+ writeEvent(e, call, ctx, branchIssue, headSha, true);
9422
9832
  };
9423
9833
  const written = writeChain.then(write).catch((err) => {
9424
9834
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
@@ -9429,6 +9839,26 @@ function createLogSink(overrides = {}) {
9429
9839
  written.finally(() => pendingWrites.delete(written));
9430
9840
  } catch (err) {
9431
9841
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
9842
+ `);
9843
+ }
9844
+ }
9845
+ function logSync(e, opts = {}) {
9846
+ try {
9847
+ const call = snapshot();
9848
+ let ctx = settledContext;
9849
+ if (ctx === undefined) {
9850
+ const destination = deps.unresolvedLogDestination(deps.env());
9851
+ if (destination.kind === "folder" && !opts.quiet) {
9852
+ 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
9853
+ `);
9854
+ }
9855
+ ctx = { repo: null, doctrine: "unknown", destination };
9856
+ }
9857
+ const branchIssue = ctx.destination.kind === "none" || call.envFields.task ? null : branchIssueIfSettled(ctx.repo);
9858
+ const headSha = e.kind === "gate" && ctx.destination.kind !== "none" ? headShaIfSettled() : null;
9859
+ writeEvent(e, call, ctx, branchIssue, headSha, false);
9860
+ } catch (err) {
9861
+ warnOnce(`vinaya: logSync() failed — ${err instanceof Error ? err.message : String(err)}
9432
9862
  `);
9433
9863
  }
9434
9864
  }
@@ -9449,7 +9879,7 @@ function createLogSink(overrides = {}) {
9449
9879
  return;
9450
9880
  });
9451
9881
  };
9452
- return { log, runId, warmup, drain };
9882
+ return { log, logSync, runId, warmup, drain, resetContext };
9453
9883
  }
9454
9884
  var defaultSink = createLogSink();
9455
9885
 
@@ -9575,7 +10005,7 @@ function findingsInThisDiff(findings) {
9575
10005
  const abs = resolve2(diff.root, f.file);
9576
10006
  if (!changed.has(abs))
9577
10007
  return false;
9578
- const relPath = relative(diff.root, abs);
10008
+ const relPath = relative2(diff.root, abs);
9579
10009
  if (!ranges.has(relPath))
9580
10010
  ranges.set(relPath, changedLineRanges(diff.base, relPath));
9581
10011
  const fileRanges = ranges.get(relPath) ?? null;
@@ -9602,7 +10032,7 @@ function indexMode(path) {
9602
10032
  }
9603
10033
  function hasShebang(path) {
9604
10034
  try {
9605
- return readFileSync7(path, "utf8").startsWith("#!");
10035
+ return readFileSync8(path, "utf8").startsWith("#!");
9606
10036
  } catch {
9607
10037
  return false;
9608
10038
  }