@attalabs/vinaya 0.36.0 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (243) hide show
  1. package/README.md +6 -6
  2. package/aeg-root/contracts/developer-reviewer.md +1 -1
  3. package/aeg-root/contracts/planner-operator.md +1 -1
  4. package/aeg-root/contracts/principal-operator.md +6 -6
  5. package/aeg-root/contracts/security-archivist.md +1 -1
  6. package/aeg-root/enforcement.md +9 -10
  7. package/aeg-root/process.md +3 -1
  8. package/aeg-root/roles/archivist.md +2 -2
  9. package/aeg-root/roles/developer/reference.md +13 -16
  10. package/aeg-root/roles/developer.md +7 -3
  11. package/aeg-root/roles/operator.md +18 -18
  12. package/aeg-root/roles/planner/reference.md +4 -4
  13. package/aeg-root/roles/principal.md +6 -1
  14. package/aeg-root/roles/reviewer.md +9 -3
  15. package/aeg-root/roles/security.md +19 -9
  16. package/aeg-root/roles/tranche-archivist.md +14 -2
  17. package/aeg-root/state-machine.md +11 -10
  18. package/aeg-root/templates/brief-template.md +6 -4
  19. package/aeg-root/templates/pr-report-template.md +1 -9
  20. package/aeg-root/tranche-model.md +4 -4
  21. package/dist/checks/bin/check-body-bare-digits.js +685 -584
  22. package/dist/checks/bin/check-branch-topology.js +626 -466
  23. package/dist/checks/bin/check-brief-shape.js +686 -585
  24. package/dist/checks/bin/check-changeset-coverage.js +1161 -731
  25. package/dist/checks/bin/check-closes-n.js +626 -466
  26. package/dist/checks/bin/check-coherence.js +744 -599
  27. package/dist/checks/bin/check-dead-branch-push.js +567 -451
  28. package/dist/checks/bin/check-dispatch-readiness.js +747 -602
  29. package/dist/checks/bin/check-doc-coverage-push.js +1160 -730
  30. package/dist/checks/bin/check-doc-coverage.js +1160 -730
  31. package/dist/checks/bin/check-doctrine-no-procedures.js +683 -582
  32. package/dist/checks/bin/check-doctrine-portability.js +1160 -730
  33. package/dist/checks/bin/check-evidence-fresh.js +1167 -906
  34. package/dist/checks/bin/check-exec-bits.js +1159 -729
  35. package/dist/checks/bin/check-first-push-dispatch.js +747 -602
  36. package/dist/checks/bin/check-issue-assignment.js +626 -466
  37. package/dist/checks/bin/check-issue-milestone-attach.js +567 -451
  38. package/dist/checks/bin/check-issue-objectives-numbering.js +683 -582
  39. package/dist/checks/bin/check-issue-parts-coverage.js +567 -451
  40. package/dist/checks/bin/check-issue-surface-globs.js +755 -601
  41. package/dist/checks/bin/check-issue-title-grammar.js +567 -451
  42. package/dist/checks/bin/check-issue-tranche-label.js +567 -451
  43. package/dist/checks/bin/check-main-branch-refusal.js +567 -451
  44. package/dist/checks/bin/check-no-disk-state.js +567 -451
  45. package/dist/checks/bin/check-pr-premise-reassert.js +683 -582
  46. package/dist/checks/bin/check-pr-report-density.js +567 -451
  47. package/dist/checks/bin/check-principal-test-plan-wait.js +567 -451
  48. package/dist/checks/bin/check-quoted-command.js +1644 -1216
  49. package/dist/checks/bin/check-reader-resolvable-prose.js +1663 -1223
  50. package/dist/checks/bin/check-registry-gates.js +610 -481
  51. package/dist/checks/bin/check-retired-vocabulary.js +1638 -1210
  52. package/dist/checks/bin/check-review-gate.js +694 -593
  53. package/dist/checks/bin/check-single-plan-pr.js +567 -451
  54. package/dist/checks/bin/check-surface-scope.js +626 -466
  55. package/dist/checks/bin/check-test-plan.js +567 -451
  56. package/dist/checks/bin/check-token-collection-wired.js +567 -451
  57. package/dist/checks/bin/check-workspace-escape.js +1160 -730
  58. package/dist/index.js +13507 -7975
  59. package/dist/lib/pre-push-cache-test-run.js +1004 -681
  60. package/dist/lib/pre-push-select-tests.js +609 -480
  61. package/package.json +2 -2
  62. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +38 -0
  63. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +19 -0
  64. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +233 -8
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +7 -2
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +1 -0
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +38 -3
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +113 -4
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-claim.ts +32 -6
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +26 -1
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +747 -0
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +8 -1
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +52 -4
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +163 -21
  75. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  76. package/studio-standalone/apps/vinaya-studio/web/.next/app-path-routes-manifest.json +0 -1
  77. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  78. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  79. package/studio-standalone/apps/vinaya-studio/web/.next/required-server-files.json +0 -5
  80. package/studio-standalone/apps/vinaya-studio/web/.next/routes-manifest.json +0 -6
  81. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error/page.js +1 -1
  82. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error/page.js.nft.json +1 -1
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  85. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  87. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  89. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  90. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  91. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js +1 -1
  92. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  95. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js +1 -1
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  98. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +3 -3
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +3 -3
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  105. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  106. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  107. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +3 -3
  108. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  109. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +5 -5
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  113. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  114. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +3 -3
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +3 -3
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  122. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  123. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +3 -3
  124. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  125. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  126. package/studio-standalone/apps/vinaya-studio/web/.next/server/app-paths-manifest.json +0 -1
  127. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/044u_vinaya-studio_web_src_app_studio_backlog__components_BacklogTable_tsx_0oha0bt._.js +3 -0
  128. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/1q96_modules_@clerk_nextjs_dist_esm_app-router_client_keyless-creator-reader_0lom2js.js +1 -1
  129. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1bh2awk._.js → [root-of-the-server]__038scsm._.js} +2 -2
  130. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1widio3._.js → [root-of-the-server]__03__s45._.js} +2 -2
  131. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{_15gdg48._.js → [root-of-the-server]__04adkz-._.js} +3 -3
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__05zwn98._.js +14 -0
  133. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +3 -0
  134. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  135. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__10riywf._.js +3 -0
  136. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__13znegp._.js → [root-of-the-server]__134x-65._.js} +2 -2
  137. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1wy7w66._.js → [root-of-the-server]__14ui9sz._.js} +2 -2
  138. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__13eeix2._.js → [root-of-the-server]__1_l_l1u._.js} +2 -2
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1f4bb3_._.js +3 -0
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  141. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1dky4g0._.js → [root-of-the-server]__1my83lt._.js} +2 -2
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1ng2x88._.js +3 -0
  143. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__040smoa._.js → [root-of-the-server]__1qpc6at._.js} +2 -2
  144. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1snpgaw._.js +56 -0
  145. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +2 -2
  146. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_06h3wbl._.js +3 -0
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  149. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  150. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  151. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0gs4gvl._.js +3 -0
  152. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  153. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  154. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  155. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_121lrn5._.js +3 -0
  156. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  157. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1o4v6lb._.js +3 -0
  158. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1q7h5mz._.js +1 -1
  159. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1ztd4i3._.js +3 -0
  160. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_209-ugd._.js +3 -0
  161. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_214d71c._.js +3 -0
  162. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/apps_vinaya-studio_web_src_app_studio_projects_[name]_tranches_[slug]_17dho0f._.js +3 -0
  163. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_@clerk_nextjs_dist_esm_app-router_server-actions_1x7vfhn.js +2 -2
  164. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_next_dist_1lzmr5o._.js +1 -1
  165. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_animate_components_index_ts_186fje1._.js +1 -1
  166. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_basic_components_index_ts_0xk1vda._.js +1 -1
  167. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  168. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  169. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  170. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  171. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/09fcolor69bun.js +1 -0
  172. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0lcwmwzxacdie.js +1 -0
  173. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ojry7lrbzkfd.css +1 -0
  174. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{00z3-ljjd1gj9.js → 0vtfb0g813gki.js} +1 -1
  175. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1giu47hrbhroj.js +1 -0
  176. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1shz6lwruld25.js +1 -0
  177. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1ytvuy1mmnc6j.js +1 -0
  178. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3oxhhhm_psozq.js → 21a6_5cr956wj.js} +1 -1
  179. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2g8mwnydod96u.js +1 -0
  180. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3li0ueedy-ozv.js → 2nrnuawd5fwpv.js} +1 -1
  181. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2nw47832_uvfe.js +1 -0
  182. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2qdxnj8wk2h0s.js +1 -0
  183. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3b9q75p-z5ma5.js +1 -0
  184. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3cv-oe7153242.js +1 -0
  185. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3lqjwjrcvq481.js → 3l56x8wjdzvaw.js} +5 -5
  186. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3m310lbjj4p5u.js +1 -0
  187. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2o9l0b7eqbr57.js → 3qtt1v3ya-ofe.js} +1 -1
  188. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  189. package/studio-standalone/apps/vinaya-studio/web/server.js +1 -1
  190. package/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/aeg-core/bin/verify-coherence.ts +0 -1089
  191. package/studio-standalone/_node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js +0 -6
  192. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route/app-paths-manifest.json +0 -3
  193. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route/build-manifest.json +0 -9
  194. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route/server-reference-manifest.json +0 -4
  195. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js +0 -6
  196. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.map +0 -5
  197. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +0 -1
  198. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route_client-reference-manifest.js +0 -3
  199. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/044u_vinaya-studio_web__next-internal_server_app_api_coherence_route_actions_1rnzea1.js +0 -3
  200. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[externals]__0cki-x_._.js +0 -3
  201. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +0 -15
  202. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[turbopack]_runtime.js +0 -903
  203. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +0 -3
  204. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ln09ua._.js +0 -3
  205. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0oegopp._.js +0 -3
  206. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__13yxbjd._.js +0 -51
  207. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1duqmtm._.js +0 -3
  208. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1z7dml9._.js +0 -9
  209. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0bfs_u4._.js +0 -3
  210. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0g8_eot._.js +0 -3
  211. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0hrh_v-._.js +0 -181
  212. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0i4-dea._.js +0 -3
  213. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0o54suy._.js +0 -3
  214. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0rxd7s0._.js +0 -3
  215. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0y1jv16._.js +0 -3
  216. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_151m4rz._.js +0 -3
  217. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1a9dieq._.js +0 -3
  218. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1sxsf5q._.js +0 -3
  219. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1sy_yfr._.js +0 -3
  220. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_219v2an._.js +0 -3
  221. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/apps_vinaya-studio_web_src_app_studio_projects_[name]_tranches_[slug]_05ufo8i._.js +0 -3
  222. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_basic_components_form_input_tsx_0es8d8b._.js +0 -3
  223. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_brutal_components_index_ts_0n_lcc4._.js +0 -3
  224. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_retro_components_index_ts_0wvpm_z._.js +0 -3
  225. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bjnj-5fy4e7l.js +0 -1
  226. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0c8uwz_-m8s99.js +0 -165
  227. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ct0c-xj0baf6.js +0 -1
  228. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ko698wh8xx2g.css +0 -1
  229. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0t5n_r4xm__t-.js +0 -1
  230. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0vc2u252q5q6o.js +0 -1
  231. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/16r_o07lw0vm0.js +0 -1
  232. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1cah7_e5a1zvu.js +0 -1
  233. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1gjo9-6dz7nup.js +0 -1
  234. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/24tz8aro1uto4.js +0 -1
  235. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2ef2g5fozszw7.js +0 -1
  236. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2ka8dg687auhj.js +0 -1
  237. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2pf3f50gbrkyv.js +0 -1
  238. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2qq49pct3q51-.js +0 -1
  239. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3et66z7glk65w.js +0 -1
  240. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3y6u3prmrkea-.js +0 -1
  241. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{z1fTSBP6ZlUjObzFIp-qq → yR5RsCxb1OGnYggiaO09S}/_buildManifest.js +0 -0
  242. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{z1fTSBP6ZlUjObzFIp-qq → yR5RsCxb1OGnYggiaO09S}/_clientMiddlewareManifest.js +0 -0
  243. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{z1fTSBP6ZlUjObzFIp-qq → yR5RsCxb1OGnYggiaO09S}/_ssgManifest.js +0 -0
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/checks/bin/check-quoted-command.ts
4
- import { existsSync as existsSync8, readdirSync as readdirSync3, readFileSync as readFileSync7, statSync as statSync2 } from "node:fs";
5
- import { join as join10, relative as relative2, resolve as resolve3 } from "node:path";
4
+ import { existsSync as existsSync8, readdirSync as readdirSync3, readFileSync as readFileSync8, statSync as statSync3 } from "node:fs";
5
+ import { join as join10, relative as relative3, resolve as resolve3 } from "node:path";
6
6
  // ../../packages/aeg-core/src/gate-audience.ts
7
7
  var GATE_AUDIENCE = {
8
8
  "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
@@ -1886,45 +1886,6 @@ var DERIVED_STATUSES = [
1886
1886
  "incoherent"
1887
1887
  ];
1888
1888
  var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
1889
- // ../../packages/aeg-core/src/parse-ledger.ts
1890
- function rowFromCells(cells) {
1891
- if (cells.length < 7)
1892
- return null;
1893
- const phase = (cells[0] ?? "").trim();
1894
- if (!phase)
1895
- return null;
1896
- return {
1897
- phase,
1898
- role: (cells[1] ?? "").trim(),
1899
- agentModel: (cells[2] ?? "").trim(),
1900
- tokensIn: parseIntCell(cells[3] ?? ""),
1901
- tokensOut: parseIntCell(cells[4] ?? ""),
1902
- cost: parseCostCell(cells[5] ?? ""),
1903
- date: (cells[6] ?? "").trim()
1904
- };
1905
- }
1906
- function parseIntCell(cell) {
1907
- const trimmed = cell.replace(/`/g, "").trim();
1908
- if (!trimmed || isEmDashOrDash(trimmed))
1909
- return null;
1910
- const normalized = trimmed.replace(/[,_\s]/g, "");
1911
- if (!/^-?\d+$/.test(normalized))
1912
- return null;
1913
- return Number(normalized);
1914
- }
1915
- function parseCostCell(cell) {
1916
- const trimmed = cell.replace(/`/g, "").trim();
1917
- if (!trimmed || isEmDashOrDash(trimmed))
1918
- return null;
1919
- const normalized = trimmed.replace(/^\$/, "").replace(/[,_\s]/g, "");
1920
- if (!/^-?\d+(\.\d+)?$/.test(normalized))
1921
- return null;
1922
- return Number(normalized);
1923
- }
1924
- function isEmDashOrDash(s) {
1925
- const t = s.trim();
1926
- return t === "—" || t === "-" || t === "–";
1927
- }
1928
1889
  // ../../packages/aeg-core/src/waiver-label.ts
1929
1890
  var WAIVER_LABEL = label("waiver-docs");
1930
1891
  var WAIVER_LABEL_REVIEW = label("waiver-review");
@@ -1940,61 +1901,6 @@ function isWaiverLabelActorVerified(opts) {
1940
1901
  return false;
1941
1902
  return isPrincipal(opts.labelActor, opts.principalAllowlist);
1942
1903
  }
1943
-
1944
- // ../../packages/aeg-core/src/parse-token-report.ts
1945
- var TOKEN_REPORT_HEADING = /^\s*(?:#{1,6}\s*Token report\s*|\*\*Token report\*\*)\s*$/i;
1946
- 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;
1947
- function parseTokenReportEntries(body) {
1948
- const lines = body.split(/\r?\n/);
1949
- const headingIdxs = [];
1950
- lines.forEach((line, i) => {
1951
- if (TOKEN_REPORT_HEADING.test(line))
1952
- headingIdxs.push(i);
1953
- });
1954
- const out = [];
1955
- for (let h = 0;h < headingIdxs.length; h++) {
1956
- const start = headingIdxs[h] + 1;
1957
- const end = h + 1 < headingIdxs.length ? headingIdxs[h + 1] : lines.length;
1958
- const section = lines.slice(start, end).join(`
1959
- `);
1960
- const tableRows = parseTableSection(section);
1961
- if (tableRows.length > 0) {
1962
- out.push(...tableRows);
1963
- continue;
1964
- }
1965
- const inlineRow = parseInlineFieldList(section);
1966
- if (inlineRow)
1967
- out.push(inlineRow);
1968
- }
1969
- return out;
1970
- }
1971
- function parseTableSection(section) {
1972
- const lines = section.split(/\r?\n/);
1973
- let i = 0;
1974
- for (;i < lines.length; i++) {
1975
- if ((lines[i] ?? "").trim().startsWith("|"))
1976
- break;
1977
- }
1978
- if (i + 1 >= lines.length)
1979
- return [];
1980
- i += 2;
1981
- const out = [];
1982
- for (;i < lines.length; i++) {
1983
- const trimmed = (lines[i] ?? "").trim();
1984
- if (!trimmed.startsWith("|"))
1985
- break;
1986
- const row = rowFromCells(splitTableRow(trimmed));
1987
- if (row)
1988
- out.push(row);
1989
- }
1990
- return out;
1991
- }
1992
- function parseInlineFieldList(section) {
1993
- const m = section.match(INLINE_FIELD_LIST);
1994
- if (!m)
1995
- return null;
1996
- return rowFromCells([m[1], m[2], m[3], m[4], m[5], m[6], m[7]]);
1997
- }
1998
1904
  // ../../packages/aeg-core/src/verdict-extraction.ts
1999
1905
  var HEAD_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged head:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
2000
1906
  var OBJECTIVES_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Objectives version:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
@@ -2443,10 +2349,12 @@ function evaluateC5(changed, docOwnersContent, prBody, fileExists, waiverActive,
2443
2349
  var CODE_REVIEW_SEVERITY_ORDER = ["BLOCKER", "MAJOR", "MINOR"];
2444
2350
  var SECURITY_SEVERITY_ORDER = ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
2445
2351
  var DEFAULT_MAX_ROUNDS = 3;
2352
+ var DEFAULT_MAX_TASK_MINUTES = 180;
2446
2353
  var DEFAULT_REVIEW_POLICY = {
2447
2354
  codeReviewThreshold: "BLOCKER",
2448
2355
  securityThreshold: "HIGH",
2449
- maxRounds: DEFAULT_MAX_ROUNDS
2356
+ maxRounds: DEFAULT_MAX_ROUNDS,
2357
+ maxTaskMinutes: DEFAULT_MAX_TASK_MINUTES
2450
2358
  };
2451
2359
  var FILE_SHAPED_LOCATION = /\.[a-zA-Z0-9]{1,10}(:\d+)?\s*$/;
2452
2360
  var PROSE_LOCATION_PATTERNS = [/\bpr\s*body\b/i, /\bcomment\b/i];
@@ -2847,11 +2755,13 @@ function checkDocUpdateList(prBody) {
2847
2755
  return headingCheck(prBody, "(?:documentation|doc)[- ]update(?:\\s+list)?", "Documentation-update list");
2848
2756
  }
2849
2757
  function checkWorktreeStep0(prBody) {
2850
- if (/git worktree add/.test(prBody))
2758
+ if (/git worktree add/.test(prBody) || /cd \.worktrees\//.test(prBody) || /bun install --frozen-lockfile/.test(prBody))
2851
2759
  return { status: "pass", errors: [] };
2852
2760
  return {
2853
2761
  status: "fail",
2854
- errors: ["brief-validation worktree Step 0: no `git worktree add` command found in the PR body."]
2762
+ errors: [
2763
+ "brief-validation worktree Step 0: no `git worktree add`, `cd .worktrees/`, or `bun install --frozen-lockfile` command found in the PR body."
2764
+ ]
2855
2765
  };
2856
2766
  }
2857
2767
  function checkStopConditions(prBody) {
@@ -3041,7 +2951,8 @@ function isCommandBlock(content) {
3041
2951
  return COMMAND_WORDS.includes(commandWordOf(firstNonBlankLine(content)));
3042
2952
  }
3043
2953
  function isStep0Block(content) {
3044
- return firstNonBlankLine(content).startsWith("git worktree add");
2954
+ const first = firstNonBlankLine(content);
2955
+ return first.startsWith("git worktree add") || first.startsWith("cd .worktrees/") || first.startsWith("bun install --frozen-lockfile");
3045
2956
  }
3046
2957
  function checkCommandsCarryOutput(prBody) {
3047
2958
  const errors = [];
@@ -3510,10 +3421,14 @@ function legacySlugPattern(legacySlugs) {
3510
3421
  const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
3511
3422
  return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
3512
3423
  }
3424
+ function specGrandfatherPaths(specGrandfather) {
3425
+ return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
3426
+ }
3513
3427
  function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
3514
3428
  const findings = [];
3515
3429
  const legacyPattern = legacySlugPattern(legacySlugs);
3516
- const grandfathered = new Set(specGrandfather);
3430
+ const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
3431
+ const limits = new Map(Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather));
3517
3432
  const patterns = [
3518
3433
  { pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
3519
3434
  { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
@@ -3532,18 +3447,19 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
3532
3447
  continue;
3533
3448
  if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
3534
3449
  continue;
3535
- if (cls === "spec" && grandfathered.has(file.path))
3450
+ if (cls === "spec" && grandfatheredWhole.has(file.path))
3536
3451
  continue;
3537
3452
  const blocking = cls === "product" || cls === "spec";
3538
3453
  const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
3539
3454
  const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
3455
+ const fileFindings = [];
3540
3456
  for (const { pattern, what, group } of patternsToRun) {
3541
3457
  pattern.lastIndex = 0;
3542
3458
  let match = pattern.exec(scrubbed);
3543
3459
  while (match !== null) {
3544
3460
  const cited = group !== undefined ? match[group] ?? match[0] : match[0];
3545
3461
  const citedIndex = match.index + match[0].indexOf(cited);
3546
- findings.push({
3462
+ fileFindings.push({
3547
3463
  file: file.path,
3548
3464
  line: lineAt(scrubbed, citedIndex),
3549
3465
  message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
@@ -3552,6 +3468,15 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
3552
3468
  match = pattern.exec(scrubbed);
3553
3469
  }
3554
3470
  }
3471
+ const limit = cls === "spec" ? limits.get(file.path) : undefined;
3472
+ if (limit !== undefined) {
3473
+ if (fileFindings.length <= limit)
3474
+ continue;
3475
+ for (const f of fileFindings) {
3476
+ f.message += `; ${file.path} carries ${fileFindings.length} such findings, over its proseGates.specGrandfather limit of ${limit}`;
3477
+ }
3478
+ }
3479
+ findings.push(...fileFindings);
3555
3480
  }
3556
3481
  return findings;
3557
3482
  }
@@ -4511,8 +4436,7 @@ function briefHash(brief) {
4511
4436
  function policyDigest(policy) {
4512
4437
  return createHash4("sha256").update(JSON.stringify({
4513
4438
  codeReviewThreshold: policy.codeReviewThreshold,
4514
- securityThreshold: policy.securityThreshold,
4515
- maxRounds: policy.maxRounds
4439
+ securityThreshold: policy.securityThreshold
4516
4440
  })).digest("hex");
4517
4441
  }
4518
4442
  function isBoundToHead(echoed, headSha) {
@@ -4825,7 +4749,46 @@ function parseEnforcementRegistry(content) {
4825
4749
  return result;
4826
4750
  }
4827
4751
  // ../../packages/aeg-core/src/registry-checks.ts
4828
- function checkG1(rows, existsFn) {
4752
+ var HOOK_DIR_PREFIXES = [".claude/hooks/", ".vinaya/hooks/", ".husky/", ".git/hooks/"];
4753
+ var BARE_HOOK_NAME = /^check-[A-Za-z0-9_.-]*\.sh$/;
4754
+ function basename(path) {
4755
+ return path.slice(path.lastIndexOf("/") + 1);
4756
+ }
4757
+ function lineOf(content, index) {
4758
+ let line = 1;
4759
+ for (let i = 0;i < index; i++)
4760
+ if (content.charCodeAt(i) === 10)
4761
+ line++;
4762
+ return line;
4763
+ }
4764
+ function findUnshippedHookRefs(docs, shipped) {
4765
+ const shippedNames = new Set([...shipped].map(basename));
4766
+ const findings = [];
4767
+ const flag = (doc, token, index) => {
4768
+ findings.push({
4769
+ path: doc.path,
4770
+ reason: `${doc.path}:${lineOf(doc.content, index)} names hook "${token}", which is neither tracked in git nor emitted by \`vinaya init\``
4771
+ });
4772
+ };
4773
+ for (const doc of docs) {
4774
+ for (const { cited, index } of extractCitedPaths(doc.content)) {
4775
+ if (cited.endsWith("/") || !HOOK_DIR_PREFIXES.some((p) => cited.startsWith(p)))
4776
+ continue;
4777
+ if (!shipped.has(cited))
4778
+ flag(doc, cited, index);
4779
+ }
4780
+ const spanPattern = /`([^`\n]+)`/g;
4781
+ let match = spanPattern.exec(doc.content);
4782
+ while (match !== null) {
4783
+ const token = match[1] ?? "";
4784
+ if (BARE_HOOK_NAME.test(token) && !shippedNames.has(token))
4785
+ flag(doc, token, match.index);
4786
+ match = spanPattern.exec(doc.content);
4787
+ }
4788
+ }
4789
+ return findings;
4790
+ }
4791
+ function checkG1(rows, existsFn, hookRefs) {
4829
4792
  const findings = [];
4830
4793
  for (const row of rows) {
4831
4794
  if (row.implementation === "")
@@ -4838,6 +4801,8 @@ function checkG1(rows, existsFn) {
4838
4801
  });
4839
4802
  }
4840
4803
  }
4804
+ if (hookRefs)
4805
+ findings.push(...findUnshippedHookRefs(hookRefs.docs, hookRefs.shipped));
4841
4806
  return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
4842
4807
  }
4843
4808
  var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
@@ -5391,7 +5356,6 @@ var TaskPrPauseSchema = z.object({
5391
5356
  var TaskPrReviewRecordSchema = z.object({
5392
5357
  verdicts: z.array(TaskPrVerdictSchema),
5393
5358
  roundMarkers: z.array(z.number().int().nonnegative()),
5394
- summaryTable: z.string().nullable(),
5395
5359
  pause: TaskPrPauseSchema.nullable()
5396
5360
  });
5397
5361
  var TaskPrReadInputSchema = z.object({
@@ -5438,16 +5402,6 @@ var TaskCancelResultSchema = z.object({
5438
5402
  authenticatedFrom: z.string().min(1),
5439
5403
  fencedEffectKeys: z.array(z.string())
5440
5404
  });
5441
- var TASK_TOOL_NAMES = [
5442
- "task_start",
5443
- "task_status",
5444
- "task_escalation_read",
5445
- "task_pr_read",
5446
- "task_resume",
5447
- "task_cancel"
5448
- ];
5449
- var OPERATOR_STATUS_FOLLOW = "task_status_follow";
5450
- var OPERATOR_TOOL_GRANT = [...TASK_TOOL_NAMES, OPERATOR_STATUS_FOLLOW];
5451
5405
  // ../../packages/aeg-core/src/first-push-dispatch-gate.ts
5452
5406
  function parseTaskBranch(branch) {
5453
5407
  const m = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
@@ -5678,15 +5632,69 @@ var NO_GATE_CUTOVERS = {
5678
5632
  briefRulesSincePr: null,
5679
5633
  agentBoxesRefusedSincePr: null
5680
5634
  };
5681
- // ../../packages/aeg-core/src/dev-review-loop/types.ts
5682
- var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5683
- // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
5684
- var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
5685
- // ../../packages/aeg-core/src/log/envelope.ts
5686
- import { createHash as createHash5 } from "node:crypto";
5687
-
5688
5635
  // ../../packages/aeg-core/src/log/schema.ts
5636
+ import { z as z3 } from "zod";
5637
+
5638
+ // ../../packages/aeg-core/src/log/custom.ts
5689
5639
  import { z as z2 } from "zod";
5640
+ var CUSTOM_EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]*\.[a-z][a-z0-9_.]*$/;
5641
+ var CUSTOM_EVENT_NAME_MAX_LENGTH = 64;
5642
+ var CUSTOM_EVENT_RESERVED_NAMESPACE = "vinaya";
5643
+ var CUSTOM_EVENT_MAX_FIELDS = 20;
5644
+ var CUSTOM_FIELD_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
5645
+ var CUSTOM_FIELD_NAME_MAX_LENGTH = 64;
5646
+ var CUSTOM_TEXT_MAX_LENGTH = 500;
5647
+ var CUSTOM_WORD_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
5648
+ var CUSTOM_WORD_MAX_LENGTH = 64;
5649
+ var CUSTOM_FIELD_MAX_WORDS = 50;
5650
+ var CustomFieldTypeSchema = z2.union([z2.enum(["text", "number", "boolean"]), z2.array(z2.string())]);
5651
+ var CustomEventDeclarationsSchema = z2.record(z2.string(), z2.object({
5652
+ fields: z2.record(z2.string(), CustomFieldTypeSchema)
5653
+ }).strict()).superRefine((events, ctx) => {
5654
+ for (const [name, declaration] of Object.entries(events)) {
5655
+ const refuse = (message, path = []) => {
5656
+ ctx.addIssue({
5657
+ code: z2.ZodIssueCode.custom,
5658
+ path: [name, ...path],
5659
+ message: `logs.events "${name}": ${message}`
5660
+ });
5661
+ };
5662
+ if (name.length > CUSTOM_EVENT_NAME_MAX_LENGTH) {
5663
+ refuse(`the name must be at most ${CUSTOM_EVENT_NAME_MAX_LENGTH} characters`);
5664
+ }
5665
+ if (!CUSTOM_EVENT_NAME_PATTERN.test(name)) {
5666
+ refuse("the name must be `<namespace>.<event>` — lowercase letters, digits and `_`, a dot between them");
5667
+ } else if (name.split(".")[0] === CUSTOM_EVENT_RESERVED_NAMESPACE) {
5668
+ refuse(`the \`${CUSTOM_EVENT_RESERVED_NAMESPACE}.\` namespace is reserved for Vinaya's own events`);
5669
+ }
5670
+ const fieldEntries = Object.entries(declaration.fields);
5671
+ if (fieldEntries.length > CUSTOM_EVENT_MAX_FIELDS) {
5672
+ refuse(`at most ${CUSTOM_EVENT_MAX_FIELDS} fields may be declared (found ${fieldEntries.length})`, ["fields"]);
5673
+ }
5674
+ for (const [field, type] of fieldEntries) {
5675
+ if (field.length > CUSTOM_FIELD_NAME_MAX_LENGTH || !CUSTOM_FIELD_NAME_PATTERN.test(field)) {
5676
+ 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]);
5677
+ }
5678
+ if (typeof type === "string")
5679
+ continue;
5680
+ if (type.length === 0) {
5681
+ refuse(`field "${field}": a list of words must name at least one word`, ["fields", field]);
5682
+ }
5683
+ if (type.length > CUSTOM_FIELD_MAX_WORDS) {
5684
+ refuse(`field "${field}": a list of words may name at most ${CUSTOM_FIELD_MAX_WORDS}`, ["fields", field]);
5685
+ }
5686
+ const bad = type.filter((w) => w.length > CUSTOM_WORD_MAX_LENGTH || !CUSTOM_WORD_PATTERN.test(w));
5687
+ if (bad.length > 0) {
5688
+ refuse(`field "${field}": a listed word is lowercase letters, digits, \`_\` and \`-\`, at most ${CUSTOM_WORD_MAX_LENGTH} characters`, ["fields", field]);
5689
+ }
5690
+ if (new Set(type).size !== type.length) {
5691
+ refuse(`field "${field}": a list of words names a word twice`, ["fields", field]);
5692
+ }
5693
+ }
5694
+ }
5695
+ });
5696
+
5697
+ // ../../packages/aeg-core/src/log/schema.ts
5690
5698
  var CONFIDENCE_REASON_MAX_LENGTH = 280;
5691
5699
  var ROLE_VALUES = [
5692
5700
  "planner",
@@ -5697,178 +5705,210 @@ var ROLE_VALUES = [
5697
5705
  "archivist",
5698
5706
  "architect"
5699
5707
  ];
5700
- var RoleSchema = z2.enum(ROLE_VALUES);
5708
+ var RoleSchema = z3.enum(ROLE_VALUES);
5701
5709
  var HOST_VALUES = ["hook", "ci", "cli", "loop"];
5702
- var HostSchema = z2.enum(HOST_VALUES);
5710
+ var HostSchema = z3.enum(HOST_VALUES);
5703
5711
  var RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
5704
5712
  var headerMetaCore = {
5705
- ts: z2.string(),
5706
- run_id: z2.string().regex(RUN_ID_PATTERN),
5707
- seq: z2.number().int().nonnegative(),
5708
- repo: z2.string().nullable(),
5709
- vinaya: z2.string(),
5710
- doctrine: z2.string(),
5713
+ ts: z3.string(),
5714
+ run_id: z3.string().regex(RUN_ID_PATTERN),
5715
+ seq: z3.number().int().nonnegative(),
5716
+ repo: z3.string().nullable(),
5717
+ vinaya: z3.string(),
5718
+ doctrine: z3.string(),
5711
5719
  host: HostSchema,
5712
- machine: z2.string()
5720
+ machine: z3.string()
5713
5721
  };
5714
- var HeaderMetaV1Schema = z2.object({
5715
- schema: z2.literal(1),
5722
+ var HeaderMetaV1Schema = z3.object({
5723
+ schema: z3.literal(1),
5716
5724
  ...headerMetaCore
5717
5725
  }).strict();
5718
- var LineageSchema = z2.object({
5719
- run: z2.string().nullable(),
5720
- attempt: z2.number().int().nullable(),
5721
- parent: z2.string().nullable()
5726
+ var LineageSchema = z3.object({
5727
+ run: z3.string().nullable(),
5728
+ attempt: z3.number().int().nullable(),
5729
+ parent: z3.string().nullable()
5722
5730
  }).strict();
5723
- var InputVersionsSchema = z2.object({
5724
- objectives_version: z2.string().nullable(),
5725
- brief_hash: z2.string().nullable(),
5726
- ruling_ordinal: z2.number().int().nullable(),
5727
- policy_digest: z2.string().nullable()
5731
+ var InputVersionsSchema = z3.object({
5732
+ objectives_version: z3.string().nullable(),
5733
+ brief_hash: z3.string().nullable(),
5734
+ ruling_ordinal: z3.number().int().nullable(),
5735
+ policy_digest: z3.string().nullable()
5728
5736
  }).strict();
5729
- var ProvenanceSchema = z2.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
5730
- var HeaderMetaV2Schema = z2.object({
5731
- schema: z2.literal(2),
5737
+ var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
5738
+ var HeaderMetaV2Schema = z3.object({
5739
+ schema: z3.literal(2),
5732
5740
  ...headerMetaCore,
5733
- event_id: z2.string().min(1),
5734
- process_id: z2.string().min(1),
5735
- actor_id: z2.string().nullable(),
5741
+ event_id: z3.string().min(1),
5742
+ process_id: z3.string().min(1),
5743
+ actor_id: z3.string().nullable(),
5736
5744
  lineage: LineageSchema,
5737
5745
  input_versions: InputVersionsSchema,
5738
5746
  provenance: ProvenanceSchema
5739
5747
  }).strict();
5740
- var HeaderMetaSchema = z2.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema]);
5741
- var SubjectSchema = z2.object({
5742
- issue: z2.number().int().nullable(),
5743
- pr: z2.number().int().optional(),
5744
- sha: z2.string().optional(),
5745
- role: z2.union([RoleSchema, z2.literal("unattributed")]),
5746
- round: z2.number().int().optional(),
5747
- objectives_version: z2.string().optional()
5748
+ var WorkSchema = z3.object({
5749
+ ref: z3.string().nullable(),
5750
+ repo: z3.string().nullable(),
5751
+ change: z3.string().nullable(),
5752
+ revision: z3.string().nullable()
5748
5753
  }).strict();
5749
- var HeaderSchema = z2.object({
5754
+ var FlowSchema = z3.object({
5755
+ id: z3.string().nullable(),
5756
+ version: z3.string().nullable()
5757
+ }).strict();
5758
+ var HeaderMetaV3Schema = z3.object({
5759
+ schema: z3.literal(3),
5760
+ ...headerMetaCore,
5761
+ event_id: z3.string().min(1),
5762
+ process_id: z3.string().min(1),
5763
+ actor_id: z3.string().nullable(),
5764
+ lineage: LineageSchema,
5765
+ input_versions: InputVersionsSchema,
5766
+ provenance: ProvenanceSchema,
5767
+ work: WorkSchema,
5768
+ flow: FlowSchema,
5769
+ runtime: z3.string().nullable(),
5770
+ source: z3.string().nullable()
5771
+ }).strict();
5772
+ var HeaderMetaSchema = z3.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema, HeaderMetaV3Schema]);
5773
+ var SubjectSchema = z3.object({
5774
+ issue: z3.number().int().nullable(),
5775
+ pr: z3.number().int().optional(),
5776
+ sha: z3.string().optional(),
5777
+ role: z3.union([RoleSchema, z3.literal("unattributed")]),
5778
+ round: z3.number().int().optional(),
5779
+ objectives_version: z3.string().optional()
5780
+ }).strict();
5781
+ var HeaderSchema = z3.object({
5750
5782
  meta: HeaderMetaSchema,
5751
5783
  subject: SubjectSchema
5752
5784
  }).strict();
5753
5785
  var envelopeTail = {
5754
- duration_ms: z2.number().nonnegative().optional(),
5755
- payload: z2.object({}).strict()
5786
+ duration_ms: z3.number().nonnegative().optional(),
5787
+ payload: z3.object({}).strict()
5756
5788
  };
5757
- var ReviewFindingSchema = z2.object({
5758
- id: z2.string(),
5759
- severity: z2.string(),
5760
- state: z2.string().optional(),
5761
- severity_scale: z2.string().optional(),
5762
- policy_treatment: z2.enum(["blocking", "non_blocking", "unavailable"]).optional(),
5763
- confidence: z2.number().min(0).max(1).optional(),
5764
- confidence_scale: z2.string().optional(),
5765
- confidence_source: z2.string().optional()
5789
+ var ReviewFindingSchema = z3.object({
5790
+ id: z3.string(),
5791
+ severity: z3.string(),
5792
+ state: z3.string().optional(),
5793
+ severity_scale: z3.string().optional(),
5794
+ policy_treatment: z3.enum(["blocking", "non_blocking", "unavailable"]).optional(),
5795
+ confidence: z3.number().min(0).max(1).optional(),
5796
+ confidence_scale: z3.string().optional(),
5797
+ confidence_source: z3.string().optional()
5766
5798
  }).strict();
5767
- var DispatchOutcomeSchema = z2.discriminatedUnion("type", [
5768
- z2.object({ type: z2.literal("pr_opened"), pr: z2.number().int(), head: z2.string() }).strict(),
5769
- z2.object({
5770
- type: z2.literal("round_pushed"),
5771
- pr: z2.number().int(),
5772
- head: z2.string(),
5773
- comment_id: z2.number().int()
5799
+ var DispatchOutcomeSchema = z3.discriminatedUnion("type", [
5800
+ z3.object({ type: z3.literal("pr_opened"), pr: z3.number().int(), head: z3.string() }).strict(),
5801
+ z3.object({
5802
+ type: z3.literal("round_pushed"),
5803
+ pr: z3.number().int(),
5804
+ head: z3.string(),
5805
+ comment_id: z3.number().int()
5774
5806
  }).strict(),
5775
- z2.object({
5776
- type: z2.literal("verdict"),
5777
- verdict: z2.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
5778
- head: z2.string(),
5779
- comment_id: z2.number().int(),
5780
- objectives: z2.array(z2.object({ id: z2.string(), met: z2.boolean() }).strict()),
5781
- findings: z2.array(ReviewFindingSchema)
5807
+ z3.object({
5808
+ type: z3.literal("verdict"),
5809
+ verdict: z3.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
5810
+ head: z3.string(),
5811
+ comment_id: z3.number().int(),
5812
+ objectives: z3.array(z3.object({ id: z3.string(), met: z3.boolean() }).strict()),
5813
+ findings: z3.array(ReviewFindingSchema)
5782
5814
  }).strict(),
5783
- z2.object({
5784
- type: z2.literal("escalation"),
5785
- class: z2.enum(["authority", "strategy", "product"]),
5786
- comment_id: z2.number().int()
5815
+ z3.object({
5816
+ type: z3.literal("escalation"),
5817
+ class: z3.enum(["authority", "strategy", "product"]),
5818
+ comment_id: z3.number().int()
5787
5819
  }).strict(),
5788
- z2.object({ type: z2.literal("brief"), comment_id: z2.number().int(), hash: z2.string() }).strict(),
5789
- z2.object({ type: z2.literal("plan"), issues: z2.array(z2.number().int()) }).strict(),
5790
- z2.object({ type: z2.literal("archive"), provenance_comment_id: z2.number().int() }).strict(),
5791
- z2.object({ type: z2.literal("completed") }).strict()
5820
+ z3.object({ type: z3.literal("brief"), comment_id: z3.number().int(), hash: z3.string() }).strict(),
5821
+ z3.object({ type: z3.literal("plan"), issues: z3.array(z3.number().int()) }).strict(),
5822
+ z3.object({ type: z3.literal("archive"), provenance_comment_id: z3.number().int() }).strict(),
5823
+ z3.object({ type: z3.literal("completed") }).strict()
5792
5824
  ]);
5793
5825
  var dispatchShared = {
5794
5826
  meta: HeaderMetaSchema,
5795
5827
  subject: SubjectSchema,
5796
- kind: z2.literal("dispatch"),
5828
+ kind: z3.literal("dispatch"),
5797
5829
  ...envelopeTail,
5798
5830
  target_role: RoleSchema,
5799
- model: z2.string(),
5800
- round: z2.number().int().optional(),
5801
- effect_id: z2.string()
5831
+ model: z3.string(),
5832
+ round: z3.number().int().optional(),
5833
+ effect_id: z3.string()
5802
5834
  };
5803
- var dispatchUsageField = z2.object({ input: z2.number().nonnegative(), output: z2.number().nonnegative() }).strict().nullable();
5804
- var DispatchEventSchema = z2.discriminatedUnion("event", [
5805
- z2.object({ ...dispatchShared, event: z2.literal("dispatched"), prompt_hash: z2.string() }).strict(),
5806
- z2.object({
5835
+ var dispatchUsageField = z3.object({ input: z3.number().nonnegative(), output: z3.number().nonnegative() }).strict().nullable();
5836
+ var DispatchEventSchema = z3.discriminatedUnion("event", [
5837
+ z3.object({ ...dispatchShared, event: z3.literal("dispatched"), prompt_hash: z3.string() }).strict(),
5838
+ z3.object({
5807
5839
  ...dispatchShared,
5808
- event: z2.literal("outcome_received"),
5840
+ event: z3.literal("outcome_received"),
5809
5841
  outcome: DispatchOutcomeSchema,
5810
5842
  usage: dispatchUsageField
5811
5843
  }).strict(),
5812
- z2.object({
5844
+ z3.object({
5813
5845
  ...dispatchShared,
5814
- event: z2.literal("dispatch_failed"),
5815
- reason: z2.enum(["timeout", "crash", "refused", "unattributed_write"]),
5846
+ event: z3.literal("dispatch_failed"),
5847
+ reason: z3.enum(["timeout", "crash", "refused", "unattributed_write"]),
5816
5848
  usage: dispatchUsageField
5817
5849
  }).strict()
5818
5850
  ]);
5851
+ var CODE_TOKEN_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
5852
+ var CodeTokenSchema = z3.string().regex(CODE_TOKEN_PATTERN);
5853
+ var ReviewerVerdictSchema = z3.object({
5854
+ role: RoleSchema,
5855
+ outcome: z3.enum(["approve", "changes_requested", "not_reviewed"]),
5856
+ blockers: z3.number().int().nonnegative()
5857
+ }).strict();
5819
5858
  var loopShared = {
5820
5859
  meta: HeaderMetaSchema,
5821
5860
  subject: SubjectSchema,
5822
- kind: z2.literal("dev_review_loop"),
5861
+ kind: z3.literal("dev_review_loop"),
5823
5862
  ...envelopeTail,
5824
- loop_id: z2.string()
5863
+ loop_id: z3.string()
5825
5864
  };
5826
- var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
5827
- z2.object({
5865
+ var DevReviewLoopEventSchema = z3.discriminatedUnion("event", [
5866
+ z3.object({
5828
5867
  ...loopShared,
5829
- event: z2.literal("loop_started"),
5830
- task: z2.number().int(),
5831
- policy: z2.object({
5832
- max_rounds: z2.number().int().nonnegative(),
5833
- reviewers: z2.array(RoleSchema),
5834
- models: z2.record(RoleSchema, z2.string())
5868
+ event: z3.literal("loop_started"),
5869
+ task: z3.number().int(),
5870
+ policy: z3.object({
5871
+ max_rounds: z3.number().int().nonnegative(),
5872
+ reviewers: z3.array(RoleSchema),
5873
+ models: z3.record(RoleSchema, z3.string())
5835
5874
  }).strict()
5836
5875
  }).strict(),
5837
- z2.object({ ...loopShared, event: z2.literal("round_started"), round: z2.number().int(), base_head: z2.string() }).strict(),
5838
- z2.object({
5876
+ z3.object({ ...loopShared, event: z3.literal("round_started"), round: z3.number().int(), base_head: z3.string() }).strict(),
5877
+ z3.object({
5839
5878
  ...loopShared,
5840
- event: z2.literal("gate_result_read"),
5841
- round: z2.number().int(),
5842
- head: z2.string(),
5843
- green: z2.boolean(),
5844
- confidence_value: z2.number().int().min(0).max(100).optional(),
5845
- confidence_reason: z2.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
5846
- confidence_unavailable: z2.boolean().optional(),
5847
- extra_turn_spent: z2.boolean().optional()
5879
+ event: z3.literal("gate_result_read"),
5880
+ round: z3.number().int(),
5881
+ head: z3.string(),
5882
+ green: z3.boolean(),
5883
+ confidence_value: z3.number().int().min(0).max(100).optional(),
5884
+ confidence_reason: z3.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
5885
+ confidence_unavailable: z3.boolean().optional(),
5886
+ extra_turn_spent: z3.boolean().optional()
5848
5887
  }).strict(),
5849
- z2.object({
5888
+ z3.object({
5850
5889
  ...loopShared,
5851
- event: z2.literal("verdicts_read"),
5852
- round: z2.number().int(),
5853
- head: z2.string(),
5854
- all_approve: z2.boolean(),
5855
- blockers: z2.number().int().nonnegative(),
5856
- findings: z2.array(ReviewFindingSchema).optional()
5890
+ event: z3.literal("verdicts_read"),
5891
+ round: z3.number().int(),
5892
+ head: z3.string(),
5893
+ all_approve: z3.boolean(),
5894
+ blockers: z3.number().int().nonnegative(),
5895
+ findings: z3.array(ReviewFindingSchema).optional(),
5896
+ reviewers: z3.array(ReviewerVerdictSchema).optional()
5857
5897
  }).strict(),
5858
- z2.object({
5898
+ z3.object({
5859
5899
  ...loopShared,
5860
- event: z2.literal("findings_compared"),
5861
- round: z2.number().int(),
5862
- open: z2.array(z2.string()),
5863
- resolved: z2.array(z2.string()),
5864
- new: z2.array(z2.string()),
5865
- recurring: z2.array(z2.string())
5900
+ event: z3.literal("findings_compared"),
5901
+ round: z3.number().int(),
5902
+ open: z3.array(z3.string()),
5903
+ resolved: z3.array(z3.string()),
5904
+ new: z3.array(z3.string()),
5905
+ recurring: z3.array(z3.string())
5866
5906
  }).strict(),
5867
- z2.object({
5907
+ z3.object({
5868
5908
  ...loopShared,
5869
- event: z2.literal("stop_condition_met"),
5870
- round: z2.number().int(),
5871
- condition: z2.enum([
5909
+ event: z3.literal("stop_condition_met"),
5910
+ round: z3.number().int(),
5911
+ condition: z3.enum([
5872
5912
  "green",
5873
5913
  "max_rounds",
5874
5914
  "no_progress",
@@ -5877,66 +5917,85 @@ var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
5877
5917
  "confidence",
5878
5918
  "reappearance",
5879
5919
  "repeat_finding",
5880
- "repeat_failure"
5920
+ "repeat_failure",
5921
+ "time_budget"
5881
5922
  ])
5882
5923
  }).strict(),
5883
- z2.object({
5924
+ z3.object({
5925
+ ...loopShared,
5926
+ event: z3.literal("paused"),
5927
+ round: z3.number().int(),
5928
+ reason: z3.enum(["escalation", "principal_item", "refreeze_needed"]),
5929
+ reason_code: CodeTokenSchema.optional()
5930
+ }).strict(),
5931
+ z3.object({
5932
+ ...loopShared,
5933
+ event: z3.literal("resumed"),
5934
+ round: z3.number().int(),
5935
+ by: z3.enum(["principal", "driver"])
5936
+ }).strict(),
5937
+ z3.object({
5884
5938
  ...loopShared,
5885
- event: z2.literal("paused"),
5886
- round: z2.number().int(),
5887
- reason: z2.enum(["escalation", "principal_item", "refreeze_needed"])
5939
+ event: z3.literal("cancelled"),
5940
+ round: z3.number().int(),
5941
+ by: z3.literal("principal")
5888
5942
  }).strict(),
5889
- z2.object({
5943
+ z3.object({
5890
5944
  ...loopShared,
5891
- event: z2.literal("resumed"),
5892
- round: z2.number().int(),
5893
- by: z2.enum(["principal", "driver"])
5945
+ event: z3.literal("unpushed_work_resume"),
5946
+ round: z3.number().int(),
5947
+ branch: z3.string(),
5948
+ detail: z3.string()
5894
5949
  }).strict(),
5895
- z2.object({
5950
+ z3.object({
5896
5951
  ...loopShared,
5897
- event: z2.literal("cancelled"),
5898
- round: z2.number().int(),
5899
- by: z2.literal("principal")
5952
+ event: z3.literal("round_ended"),
5953
+ round: z3.number().int(),
5954
+ base_head: z3.string(),
5955
+ head: z3.string(),
5956
+ files_changed: z3.number().int().nonnegative(),
5957
+ insertions: z3.number().int().nonnegative(),
5958
+ deletions: z3.number().int().nonnegative(),
5959
+ wall_ms: z3.number().nonnegative(),
5960
+ outcome: z3.enum(["green", "changes_requested", "escalated"])
5900
5961
  }).strict(),
5901
- z2.object({
5962
+ z3.object({
5902
5963
  ...loopShared,
5903
- event: z2.literal("unpushed_work_resume"),
5904
- round: z2.number().int(),
5905
- branch: z2.string(),
5906
- detail: z2.string()
5964
+ event: z3.literal("journal_finalized"),
5965
+ rounds: z3.number().int().nonnegative(),
5966
+ total_wall_ms: z3.number().nonnegative(),
5967
+ time_to_green_ms: z3.number().nonnegative().nullable(),
5968
+ files_changed_total: z3.number().int().nonnegative(),
5969
+ final_head: z3.string(),
5970
+ result: z3.enum(["merged_ready", "stopped"])
5907
5971
  }).strict(),
5908
- z2.object({
5972
+ z3.object({
5909
5973
  ...loopShared,
5910
- event: z2.literal("round_ended"),
5911
- round: z2.number().int(),
5912
- base_head: z2.string(),
5913
- head: z2.string(),
5914
- files_changed: z2.number().int().nonnegative(),
5915
- insertions: z2.number().int().nonnegative(),
5916
- deletions: z2.number().int().nonnegative(),
5917
- wall_ms: z2.number().nonnegative(),
5918
- outcome: z2.enum(["green", "changes_requested", "escalated"])
5974
+ event: z3.literal("infrastructure_retry"),
5975
+ round: z3.number().int(),
5976
+ failure_kind: z3.enum(["pause_comment_post", "developer_connection"]),
5977
+ attempts: z3.number().int().positive(),
5978
+ outcome: z3.enum(["recovered", "exhausted"])
5919
5979
  }).strict(),
5920
- z2.object({
5980
+ z3.object({
5921
5981
  ...loopShared,
5922
- event: z2.literal("journal_finalized"),
5923
- rounds: z2.number().int().nonnegative(),
5924
- total_wall_ms: z2.number().nonnegative(),
5925
- time_to_green_ms: z2.number().nonnegative().nullable(),
5926
- files_changed_total: z2.number().int().nonnegative(),
5927
- final_head: z2.string(),
5928
- result: z2.enum(["merged_ready", "stopped"])
5982
+ event: z3.literal("driver_heartbeat"),
5983
+ task: z3.number().int(),
5984
+ pr: z3.number().int().positive().optional(),
5985
+ round: z3.number().int(),
5986
+ phase: z3.string()
5929
5987
  }).strict(),
5930
- z2.object({
5988
+ z3.object({
5931
5989
  ...loopShared,
5932
- event: z2.literal("infrastructure_retry"),
5933
- round: z2.number().int(),
5934
- failure_kind: z2.enum(["pause_comment_post", "developer_connection"]),
5935
- attempts: z2.number().int().positive(),
5936
- outcome: z2.enum(["recovered", "exhausted"])
5990
+ event: z3.literal("driver_exited"),
5991
+ task: z3.number().int(),
5992
+ reason: z3.enum(["finished", "paused", "reexec", "error", "signal"]),
5993
+ last_decision: z3.string(),
5994
+ exit_code: z3.number().int().optional(),
5995
+ error_class: CodeTokenSchema.optional()
5937
5996
  }).strict()
5938
5997
  ]);
5939
- var ForgeOpSchema = z2.enum([
5998
+ var ForgeOpSchema = z3.enum([
5940
5999
  "pr.create",
5941
6000
  "pr.comment",
5942
6001
  "pr.body.replace",
@@ -5950,24 +6009,24 @@ var ForgeOpSchema = z2.enum([
5950
6009
  "label.add",
5951
6010
  "label.remove"
5952
6011
  ]);
5953
- var ForgeWriteTargetSchema = z2.object({
5954
- issue: z2.number().int().optional(),
5955
- pr: z2.number().int().optional()
6012
+ var ForgeWriteTargetSchema = z3.object({
6013
+ issue: z3.number().int().optional(),
6014
+ pr: z3.number().int().optional()
5956
6015
  }).strict();
5957
6016
  var forgeWriteShared = {
5958
6017
  meta: HeaderMetaSchema,
5959
6018
  subject: SubjectSchema,
5960
- kind: z2.literal("forge_write"),
6019
+ kind: z3.literal("forge_write"),
5961
6020
  ...envelopeTail,
5962
6021
  op: ForgeOpSchema,
5963
6022
  target: ForgeWriteTargetSchema
5964
6023
  };
5965
- var ForgeWriteEventSchema = z2.discriminatedUnion("event", [
5966
- z2.object({ ...forgeWriteShared, event: z2.literal("validated") }).strict(),
5967
- z2.object({ ...forgeWriteShared, event: z2.literal("refused"), reason: z2.string() }).strict(),
5968
- z2.object({ ...forgeWriteShared, event: z2.literal("written"), comment_ids: z2.array(z2.string()) }).strict()
6024
+ var ForgeWriteEventSchema = z3.discriminatedUnion("event", [
6025
+ z3.object({ ...forgeWriteShared, event: z3.literal("validated") }).strict(),
6026
+ z3.object({ ...forgeWriteShared, event: z3.literal("refused"), reason: z3.string() }).strict(),
6027
+ z3.object({ ...forgeWriteShared, event: z3.literal("written"), comment_ids: z3.array(z3.string()) }).strict()
5969
6028
  ]);
5970
- var GateOutcomeSchema = z2.enum([
6029
+ var GateOutcomeSchema = z3.enum([
5971
6030
  "pass",
5972
6031
  "fail",
5973
6032
  "wait",
@@ -5980,61 +6039,74 @@ var GateOutcomeSchema = z2.enum([
5980
6039
  var gateShared = {
5981
6040
  meta: HeaderMetaSchema,
5982
6041
  subject: SubjectSchema,
5983
- kind: z2.literal("gate"),
6042
+ kind: z3.literal("gate"),
5984
6043
  ...envelopeTail,
5985
- check: z2.string(),
5986
- check_version: z2.string().nullable(),
5987
- policy_version: z2.string().nullable(),
5988
- input_fingerprint: z2.string().nullable()
6044
+ check: z3.string(),
6045
+ check_version: z3.string().nullable(),
6046
+ policy_version: z3.string().nullable(),
6047
+ input_fingerprint: z3.string().nullable()
5989
6048
  };
5990
- var GateEventSchema = z2.discriminatedUnion("event", [
5991
- z2.object({
6049
+ var GateEventSchema = z3.discriminatedUnion("event", [
6050
+ z3.object({
5992
6051
  ...gateShared,
5993
- event: z2.literal("checked"),
6052
+ event: z3.literal("checked"),
5994
6053
  outcome: GateOutcomeSchema,
5995
- reason: z2.string().optional()
6054
+ reason: z3.string().optional()
6055
+ }).strict(),
6056
+ z3.object({
6057
+ meta: HeaderMetaSchema,
6058
+ subject: SubjectSchema,
6059
+ kind: z3.literal("gate"),
6060
+ ...envelopeTail,
6061
+ event: z3.literal("summary"),
6062
+ ran: z3.number().int().nonnegative(),
6063
+ passed: z3.number().int().nonnegative(),
6064
+ failed: z3.number().int().nonnegative(),
6065
+ skipped: z3.number().int().nonnegative(),
6066
+ failed_checks: z3.array(z3.string())
5996
6067
  }).strict()
5997
6068
  ]);
5998
- var OperationResultSchema = z2.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
6069
+ var OperationResultSchema = z3.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
5999
6070
  var operationShared = {
6000
6071
  meta: HeaderMetaSchema,
6001
6072
  subject: SubjectSchema,
6002
- kind: z2.literal("operation"),
6073
+ kind: z3.literal("operation"),
6003
6074
  ...envelopeTail,
6004
- operation: z2.string(),
6005
- target: z2.string().nullable()
6075
+ operation: z3.string(),
6076
+ target: z3.string().nullable()
6006
6077
  };
6007
- var OperationEventSchema = z2.discriminatedUnion("event", [
6008
- z2.object({
6078
+ var OperationEventSchema = z3.discriminatedUnion("event", [
6079
+ z3.object({
6009
6080
  ...operationShared,
6010
- event: z2.literal("completed"),
6081
+ event: z3.literal("completed"),
6011
6082
  result: OperationResultSchema,
6012
- error_class: z2.string().nullable()
6083
+ error_class: z3.string().nullable(),
6084
+ field_names: z3.array(z3.string().max(CUSTOM_FIELD_NAME_MAX_LENGTH)).max(CUSTOM_EVENT_MAX_FIELDS).optional()
6013
6085
  }).strict()
6014
6086
  ]);
6015
- var UsageUnitsSchema = z2.object({
6016
- input: z2.number().nonnegative().nullable(),
6017
- output: z2.number().nonnegative().nullable(),
6018
- cache: z2.number().nonnegative().nullable()
6087
+ var UsageUnitsSchema = z3.object({
6088
+ input: z3.number().nonnegative().nullable(),
6089
+ output: z3.number().nonnegative().nullable(),
6090
+ cache: z3.number().nonnegative().nullable()
6019
6091
  }).strict();
6020
6092
  var usageShared = {
6021
6093
  meta: HeaderMetaSchema,
6022
6094
  subject: SubjectSchema,
6023
- kind: z2.literal("usage"),
6095
+ kind: z3.literal("usage"),
6024
6096
  ...envelopeTail,
6025
- model: z2.string().nullable(),
6026
- source: z2.string(),
6027
- semantics: z2.enum(["cumulative", "delta"])
6097
+ model: z3.string().nullable(),
6098
+ source: z3.string(),
6099
+ semantics: z3.enum(["cumulative", "delta"])
6028
6100
  };
6029
- var UsageEventSchema = z2.discriminatedUnion("event", [
6030
- z2.object({
6101
+ var UsageEventSchema = z3.discriminatedUnion("event", [
6102
+ z3.object({
6031
6103
  ...usageShared,
6032
- event: z2.literal("observed"),
6104
+ event: z3.literal("observed"),
6033
6105
  units: UsageUnitsSchema,
6034
- unknown_reason: z2.string().nullable()
6106
+ unknown_reason: z3.string().nullable()
6035
6107
  }).strict()
6036
6108
  ]);
6037
- var RoleAttemptOutcomeSchema = z2.enum([
6109
+ var RoleAttemptOutcomeSchema = z3.enum([
6038
6110
  "completed",
6039
6111
  "incomplete",
6040
6112
  "infrastructure_failed",
@@ -6045,17 +6117,17 @@ var RoleAttemptOutcomeSchema = z2.enum([
6045
6117
  var roleAttemptShared = {
6046
6118
  meta: HeaderMetaSchema,
6047
6119
  subject: SubjectSchema,
6048
- kind: z2.literal("role_attempt"),
6120
+ kind: z3.literal("role_attempt"),
6049
6121
  ...envelopeTail,
6050
- actor: z2.string().nullable(),
6051
- attempt: z2.number().int().nullable(),
6052
- effect_id: z2.string(),
6053
- model: z2.string().nullable()
6122
+ actor: z3.string().nullable(),
6123
+ attempt: z3.number().int().nullable(),
6124
+ effect_id: z3.string(),
6125
+ model: z3.string().nullable()
6054
6126
  };
6055
- var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
6056
- z2.object({
6127
+ var RoleAttemptEventSchema = z3.discriminatedUnion("event", [
6128
+ z3.object({
6057
6129
  ...roleAttemptShared,
6058
- event: z2.literal("attempted"),
6130
+ event: z3.literal("attempted"),
6059
6131
  outcome: RoleAttemptOutcomeSchema,
6060
6132
  usage: dispatchUsageField
6061
6133
  }).strict()
@@ -6063,42 +6135,59 @@ var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
6063
6135
  var handoffShared = {
6064
6136
  meta: HeaderMetaSchema,
6065
6137
  subject: SubjectSchema,
6066
- kind: z2.literal("handoff"),
6138
+ kind: z3.literal("handoff"),
6067
6139
  ...envelopeTail,
6068
- class: z2.enum(["authority", "strategy", "product"]),
6069
- reason: z2.string()
6140
+ class: z3.enum(["authority", "strategy", "product"]),
6141
+ reason: z3.string()
6070
6142
  };
6071
- var HandoffEventSchema = z2.discriminatedUnion("event", [
6072
- z2.object({
6143
+ var HandoffEventSchema = z3.discriminatedUnion("event", [
6144
+ z3.object({
6073
6145
  ...handoffShared,
6074
- event: z2.literal("raised"),
6075
- requested_decision: z2.string().nullable()
6146
+ event: z3.literal("raised"),
6147
+ requested_decision: z3.string().nullable()
6076
6148
  }).strict(),
6077
- z2.object({
6149
+ z3.object({
6078
6150
  ...handoffShared,
6079
- event: z2.literal("resolved"),
6080
- resolution: z2.string().nullable(),
6081
- resolved_by: z2.string().nullable()
6151
+ event: z3.literal("resolved"),
6152
+ resolution: z3.string().nullable(),
6153
+ resolved_by: z3.string().nullable()
6082
6154
  }).strict()
6083
6155
  ]);
6084
- var EffectTargetSchema = z2.object({
6085
- kind: z2.string(),
6086
- ref: z2.string()
6156
+ var EffectTargetSchema = z3.object({
6157
+ kind: z3.string(),
6158
+ ref: z3.string()
6087
6159
  }).strict();
6088
6160
  var effectShared = {
6089
6161
  meta: HeaderMetaSchema,
6090
6162
  subject: SubjectSchema,
6091
- kind: z2.literal("effect"),
6163
+ kind: z3.literal("effect"),
6092
6164
  ...envelopeTail,
6093
- effect_id: z2.string(),
6165
+ effect_id: z3.string(),
6094
6166
  target: EffectTargetSchema
6095
6167
  };
6096
- var EffectEventSchema = z2.discriminatedUnion("event", [
6097
- z2.object({ ...effectShared, event: z2.literal("attempted") }).strict(),
6098
- z2.object({ ...effectShared, event: z2.literal("observed"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict(),
6099
- z2.object({ ...effectShared, event: z2.literal("verified"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict()
6168
+ var EffectEventSchema = z3.discriminatedUnion("event", [
6169
+ z3.object({ ...effectShared, event: z3.literal("attempted") }).strict(),
6170
+ z3.object({ ...effectShared, event: z3.literal("observed"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict(),
6171
+ z3.object({ ...effectShared, event: z3.literal("verified"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict()
6172
+ ]);
6173
+ var CustomFieldValueSchema = z3.union([z3.string().max(CUSTOM_TEXT_MAX_LENGTH), z3.number().finite(), z3.boolean()]);
6174
+ var customShared = {
6175
+ meta: HeaderMetaV3Schema,
6176
+ subject: SubjectSchema,
6177
+ kind: z3.literal("custom"),
6178
+ ...envelopeTail
6179
+ };
6180
+ var CustomEventSchema = z3.discriminatedUnion("event", [
6181
+ z3.object({
6182
+ ...customShared,
6183
+ event: z3.literal("recorded"),
6184
+ name: z3.string().max(CUSTOM_EVENT_NAME_MAX_LENGTH).regex(CUSTOM_EVENT_NAME_PATTERN),
6185
+ 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, {
6186
+ message: `custom: at most ${CUSTOM_EVENT_MAX_FIELDS} fields`
6187
+ })
6188
+ }).strict()
6100
6189
  ]);
6101
- var LogEventSchema = z2.union([
6190
+ var LogEventSchema = z3.union([
6102
6191
  DispatchEventSchema,
6103
6192
  DevReviewLoopEventSchema,
6104
6193
  ForgeWriteEventSchema,
@@ -6107,10 +6196,11 @@ var LogEventSchema = z2.union([
6107
6196
  UsageEventSchema,
6108
6197
  RoleAttemptEventSchema,
6109
6198
  HandoffEventSchema,
6110
- EffectEventSchema
6199
+ EffectEventSchema,
6200
+ CustomEventSchema
6111
6201
  ]);
6112
-
6113
6202
  // ../../packages/aeg-core/src/log/envelope.ts
6203
+ import { createHash as createHash5 } from "node:crypto";
6114
6204
  function isRole(value) {
6115
6205
  return value !== undefined && ROLE_VALUES.includes(value);
6116
6206
  }
@@ -6147,18 +6237,27 @@ function roundFromEnv(round) {
6147
6237
  const n = Number(round);
6148
6238
  return Number.isInteger(n) ? n : undefined;
6149
6239
  }
6240
+ function prFromEnv(pr) {
6241
+ if (pr === undefined || pr === "")
6242
+ return;
6243
+ const n = Number(pr);
6244
+ return Number.isInteger(n) && n > 0 ? n : undefined;
6245
+ }
6150
6246
  function buildHeader(input) {
6151
6247
  const role = isRole(input.env.role) ? input.env.role : "unattributed";
6152
6248
  const round = roundFromEnv(input.env.round);
6249
+ const pr = prFromEnv(input.env.pr);
6153
6250
  const subject = {
6154
6251
  issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
6155
6252
  role,
6156
6253
  ...round !== undefined ? { round } : {},
6254
+ ...pr !== undefined ? { pr } : {},
6157
6255
  ...input.subject ?? {}
6158
6256
  };
6257
+ const issue = subject.issue;
6159
6258
  return {
6160
6259
  meta: {
6161
- schema: 2,
6260
+ schema: 3,
6162
6261
  ts: input.now.toISOString(),
6163
6262
  run_id: input.runId,
6164
6263
  seq: input.seq,
@@ -6181,7 +6280,19 @@ function buildHeader(input) {
6181
6280
  ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
6182
6281
  policy_digest: input.inputVersions?.policyDigest ?? null
6183
6282
  },
6184
- provenance: provenanceFor(input)
6283
+ provenance: provenanceFor(input),
6284
+ work: {
6285
+ ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
6286
+ repo: input.repo,
6287
+ change: null,
6288
+ revision: null
6289
+ },
6290
+ flow: {
6291
+ id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
6292
+ version: lineageFieldFromEnv(input.env.flowVersion)
6293
+ },
6294
+ runtime: lineageFieldFromEnv(input.env.runtime),
6295
+ source: lineageFieldFromEnv(input.env.source)
6185
6296
  },
6186
6297
  subject
6187
6298
  };
@@ -6224,7 +6335,7 @@ function redact(value, home) {
6224
6335
  return value;
6225
6336
  }
6226
6337
  // ../../packages/aeg-core/src/log/store.ts
6227
- var KNOWN_SCHEMA_VERSIONS = [1, 2];
6338
+ var KNOWN_SCHEMA_VERSIONS = [1, 2, 3];
6228
6339
  function metaOf(obj) {
6229
6340
  if (obj === null || typeof obj !== "object")
6230
6341
  return null;
@@ -6290,7 +6401,7 @@ function classifyStoredLine(raw, home) {
6290
6401
  return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
6291
6402
  }
6292
6403
  const redacted = redact(event, home);
6293
- const provenance = version === 2 ? event.meta.provenance ?? null : null;
6404
+ const provenance = version >= 2 ? event.meta.provenance ?? null : null;
6294
6405
  return {
6295
6406
  status: "ok",
6296
6407
  identity,
@@ -6303,143 +6414,148 @@ function classifyStoredLine(raw, home) {
6303
6414
  };
6304
6415
  }
6305
6416
  // ../../packages/aeg-core/src/control-store/records.ts
6306
- import { z as z3 } from "zod";
6307
- var isoTimestamp = z3.string().min(1);
6308
- var taskId = z3.number().int().positive();
6309
- var epochNumber = z3.number().int().nonnegative();
6310
- var RunRecordSchema = z3.object({
6311
- version: z3.literal(1),
6312
- kind: z3.literal("run"),
6417
+ import { z as z4 } from "zod";
6418
+ var isoTimestamp = z4.string().min(1);
6419
+ var taskId = z4.number().int().positive();
6420
+ var epochNumber = z4.number().int().nonnegative();
6421
+ var RunRecordSchema = z4.object({
6422
+ version: z4.literal(1),
6423
+ kind: z4.literal("run"),
6313
6424
  task: taskId,
6314
- runId: z3.string().min(1),
6315
- pid: z3.number().int().positive(),
6316
- host: z3.string().min(1),
6425
+ runId: z4.string().min(1),
6426
+ pid: z4.number().int().positive(),
6427
+ host: z4.string().min(1),
6317
6428
  startedAt: isoTimestamp,
6318
- childStartedAt: z3.string().min(1).nullable().optional(),
6319
- childCommand: z3.string().min(1).nullable().optional()
6429
+ childStartedAt: z4.string().min(1).nullable().optional(),
6430
+ childCommand: z4.string().min(1).nullable().optional()
6320
6431
  }).strict();
6321
- var InputRecordSchema = z3.object({
6322
- version: z3.literal(1),
6323
- kind: z3.literal("input"),
6432
+ var InputRecordSchema = z4.object({
6433
+ version: z4.literal(1),
6434
+ kind: z4.literal("input"),
6324
6435
  task: taskId,
6325
- runId: z3.string().min(1),
6326
- source: z3.union([z3.literal("fresh"), z3.literal("resume")]),
6327
- pr: z3.number().int().positive().nullable(),
6328
- round: z3.number().int().nonnegative(),
6436
+ runId: z4.string().min(1),
6437
+ source: z4.union([z4.literal("fresh"), z4.literal("resume")]),
6438
+ pr: z4.number().int().positive().nullable(),
6439
+ round: z4.number().int().nonnegative(),
6329
6440
  recordedAt: isoTimestamp
6330
6441
  }).strict();
6331
- var OwnershipRecordSchema = z3.object({
6332
- version: z3.literal(1),
6333
- kind: z3.literal("ownership"),
6442
+ var OwnershipRecordSchema = z4.object({
6443
+ version: z4.literal(1),
6444
+ kind: z4.literal("ownership"),
6334
6445
  task: taskId,
6335
6446
  epoch: epochNumber,
6336
- ownerId: z3.string().min(1),
6337
- pid: z3.number().int().positive(),
6338
- host: z3.string().min(1),
6447
+ ownerId: z4.string().min(1),
6448
+ pid: z4.number().int().positive(),
6449
+ host: z4.string().min(1),
6339
6450
  acquiredAt: isoTimestamp
6340
6451
  }).strict();
6341
- var TransitionRecordSchema = z3.object({
6342
- version: z3.literal(1),
6343
- kind: z3.literal("transition"),
6452
+ var TransitionRecordSchema = z4.object({
6453
+ version: z4.literal(1),
6454
+ kind: z4.literal("transition"),
6344
6455
  task: taskId,
6345
6456
  epoch: epochNumber,
6346
- seq: z3.number().int().nonnegative(),
6347
- from: z3.string().min(1),
6348
- to: z3.string().min(1),
6349
- detail: z3.string().optional(),
6457
+ seq: z4.number().int().nonnegative(),
6458
+ from: z4.string().min(1),
6459
+ to: z4.string().min(1),
6460
+ detail: z4.string().optional(),
6350
6461
  at: isoTimestamp
6351
6462
  }).strict();
6352
- var ManifestRecordSchema = z3.object({
6353
- version: z3.literal(1),
6354
- kind: z3.literal("manifest"),
6463
+ var ManifestRecordSchema = z4.object({
6464
+ version: z4.literal(1),
6465
+ kind: z4.literal("manifest"),
6355
6466
  task: taskId,
6356
6467
  round: epochNumber,
6357
- repository: z3.string().min(1),
6358
- pr: z3.number().int().positive(),
6359
- branch: z3.string().min(1),
6360
- baseSha: z3.string().min(1).nullable(),
6361
- headSha: z3.string().min(1),
6362
- briefHash: z3.string().min(1).nullable(),
6363
- objectivesVersion: z3.string().min(1).nullable(),
6468
+ repository: z4.string().min(1),
6469
+ pr: z4.number().int().positive(),
6470
+ branch: z4.string().min(1),
6471
+ baseSha: z4.string().min(1).nullable(),
6472
+ headSha: z4.string().min(1),
6473
+ briefHash: z4.string().min(1).nullable(),
6474
+ objectivesVersion: z4.string().min(1).nullable(),
6364
6475
  rulingOrdinal: epochNumber,
6365
- policyDigest: z3.string().min(1),
6476
+ policyDigest: z4.string().min(1),
6366
6477
  recordedAt: isoTimestamp
6367
6478
  }).strict();
6368
- var roundHeadIdentity = z3.object({ round: z3.number().int().positive(), head: z3.string().min(1) }).strict();
6369
- var LoopBudgetsSchema = z3.object({
6370
- mechanicalRetries: z3.number().int().nonnegative(),
6371
- reviewRounds: z3.number().int().nonnegative(),
6372
- infrastructureRetries: z3.number().int().nonnegative()
6479
+ var roundHeadIdentity = z4.object({ round: z4.number().int().positive(), head: z4.string().min(1) }).strict();
6480
+ var LoopBudgetsSchema = z4.object({
6481
+ mechanicalRetries: z4.number().int().nonnegative(),
6482
+ reviewRounds: z4.number().int().nonnegative(),
6483
+ infrastructureRetries: z4.number().int().nonnegative()
6373
6484
  }).strict();
6374
- var LoopStateRecordSchema = z3.object({
6375
- version: z3.literal(1),
6376
- kind: z3.literal("loop_state"),
6485
+ var LoopStateRecordSchema = z4.object({
6486
+ version: z4.literal(1),
6487
+ kind: z4.literal("loop_state"),
6377
6488
  task: taskId,
6378
- round: z3.number().int().positive(),
6379
- phase: z3.string().min(1),
6380
- pauseReason: z3.string().min(1).nullable(),
6489
+ round: z4.number().int().positive(),
6490
+ phase: z4.string().min(1),
6491
+ pauseReason: z4.string().min(1).nullable(),
6381
6492
  budgets: LoopBudgetsSchema,
6382
6493
  heldResult: roundHeadIdentity.nullable(),
6383
6494
  deliveredFindings: roundHeadIdentity.nullable(),
6384
- repeatMemory: z3.object({
6385
- blockingFindings: z3.array(z3.string()),
6386
- lastFailure: z3.object({ signature: z3.string(), message: z3.string() }).nullable()
6495
+ repeatMemory: z4.object({
6496
+ blockingFindings: z4.array(z4.string()),
6497
+ lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
6387
6498
  }).strict().optional(),
6499
+ publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
6500
+ taskStartedAt: isoTimestamp.optional(),
6501
+ phaseMs: z4.record(z4.string(), z4.number().nonnegative()).optional(),
6388
6502
  recordedAt: isoTimestamp
6389
6503
  }).strict();
6390
- var EffectRecordSchema = z3.object({
6391
- version: z3.literal(1),
6392
- kind: z3.literal("effect"),
6504
+ var EffectRecordSchema = z4.object({
6505
+ version: z4.literal(1),
6506
+ kind: z4.literal("effect"),
6393
6507
  task: taskId,
6394
- key: z3.string().min(1),
6395
- operation: z3.string().min(1),
6396
- target: z3.string().min(1),
6397
- inputVersion: z3.number().int().nonnegative(),
6398
- payloadDigest: z3.string().min(1),
6399
- status: z3.union([z3.literal("started"), z3.literal("verified"), z3.literal("uncertain")]),
6400
- url: z3.string().optional(),
6508
+ key: z4.string().min(1),
6509
+ operation: z4.string().min(1),
6510
+ target: z4.string().min(1),
6511
+ inputVersion: z4.number().int().nonnegative(),
6512
+ payloadDigest: z4.string().min(1),
6513
+ status: z4.union([z4.literal("started"), z4.literal("verified"), z4.literal("uncertain")]),
6514
+ url: z4.string().optional(),
6401
6515
  recordedAt: isoTimestamp
6402
6516
  }).strict();
6403
- var EscalationRecordSchema = z3.object({
6404
- version: z3.literal(1),
6405
- kind: z3.literal("escalation"),
6517
+ var EscalationRecordSchema = z4.object({
6518
+ version: z4.literal(1),
6519
+ kind: z4.literal("escalation"),
6406
6520
  task: taskId,
6407
- escalationId: z3.string().min(1),
6521
+ escalationId: z4.string().min(1),
6408
6522
  round: epochNumber,
6409
- head: z3.string().min(1),
6410
- branch: z3.string().min(1),
6411
- pr: z3.number().int().positive().nullable(),
6412
- runId: z3.string().min(1),
6413
- pid: z3.number().int().positive(),
6414
- host: z3.string().min(1),
6415
- agent: z3.string().min(1).optional(),
6416
- reason: z3.string().min(1),
6417
- detail: z3.string().optional(),
6418
- evidence: z3.string().optional(),
6419
- attemptedRecovery: z3.string().min(1),
6420
- requestedDecision: z3.string().min(1),
6421
- recipient: z3.string().min(1),
6422
- briefHash: z3.string().min(1).nullable(),
6423
- objectivesVersion: z3.string().min(1).nullable(),
6523
+ head: z4.string().min(1),
6524
+ branch: z4.string().min(1),
6525
+ pr: z4.number().int().positive().nullable(),
6526
+ runId: z4.string().min(1),
6527
+ pid: z4.number().int().positive(),
6528
+ host: z4.string().min(1),
6529
+ agent: z4.string().min(1).optional(),
6530
+ reason: z4.string().min(1),
6531
+ detail: z4.string().optional(),
6532
+ evidence: z4.string().optional(),
6533
+ attemptedRecovery: z4.string().min(1),
6534
+ requestedDecision: z4.string().min(1),
6535
+ recipient: z4.string().min(1),
6536
+ briefHash: z4.string().min(1).nullable(),
6537
+ objectivesVersion: z4.string().min(1).nullable(),
6424
6538
  rulingOrdinal: epochNumber,
6425
- policyDigest: z3.string().min(1),
6539
+ policyDigest: z4.string().min(1),
6426
6540
  recordedAt: isoTimestamp
6427
6541
  }).strict();
6428
- var ResolutionRecordSchema = z3.object({
6429
- version: z3.literal(1),
6430
- kind: z3.literal("resolution"),
6542
+ var ResolutionRecordSchema = z4.object({
6543
+ version: z4.literal(1),
6544
+ kind: z4.literal("resolution"),
6431
6545
  task: taskId,
6432
- escalationId: z3.string().min(1),
6433
- decision: z3.union([z3.literal("resume"), z3.literal("cancel")]),
6434
- authenticatedBy: z3.string().min(1),
6435
- authenticatedFrom: z3.string().min(1),
6546
+ escalationId: z4.string().min(1),
6547
+ decision: z4.union([z4.literal("resume"), z4.literal("cancel")]),
6548
+ authenticatedBy: z4.string().min(1),
6549
+ authenticatedFrom: z4.string().min(1),
6436
6550
  consumedAt: isoTimestamp
6437
6551
  }).strict();
6552
+ // ../../packages/aeg-core/src/control-store/local.ts
6553
+ var CONTROL_AREA_DIRNAME = "control";
6438
6554
  // src/commands/doctrine.ts
6439
- import { execFileSync as execFileSync2 } from "node:child_process";
6440
- import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2 } from "node:fs";
6441
- import { dirname as dirname2, join as join2, sep } from "node:path";
6442
- import matter2 from "gray-matter";
6555
+ import { execFileSync as execFileSync3 } from "node:child_process";
6556
+ import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3 } from "node:fs";
6557
+ import { dirname as dirname3, join as join3, sep } from "node:path";
6558
+ import matter4 from "gray-matter";
6443
6559
 
6444
6560
  // src/lib/package-root.ts
6445
6561
  import { existsSync } from "node:fs";
@@ -6458,607 +6574,10 @@ function packageRoot(moduleUrl) {
6458
6574
  return dir;
6459
6575
  }
6460
6576
 
6461
- // src/commands/doctrine.ts
6462
- var ENTRY_SEGMENTS = ["skills", "aeg", "SKILL.md"];
6463
- function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
6464
- return resolveDoctrineRootInfo(pkg, cwd)?.root ?? null;
6465
- }
6466
- function gitToplevel(cwd) {
6467
- try {
6468
- return execFileSync2("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
6469
- encoding: "utf8",
6470
- stdio: ["ignore", "pipe", "pipe"]
6471
- }).trim();
6472
- } catch {
6473
- return null;
6474
- }
6475
- }
6476
- function resolveDoctrineRootInfo(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
6477
- const toplevel = gitToplevel(cwd);
6478
- if (toplevel !== null) {
6479
- const treeRoot = join2(toplevel, "aeg-root");
6480
- if (existsSync2(join2(treeRoot, "roles")))
6481
- return { root: treeRoot, source: "tree" };
6482
- }
6483
- const fromSource = !pkg.split(sep).includes("node_modules");
6484
- const bundleRoot = fromSource ? join2(dirname2(dirname2(pkg)), "aeg-root") : join2(pkg, "aeg-root");
6485
- return hasDoctrineEntry(bundleRoot) ? { root: bundleRoot, source: "bundle" } : null;
6486
- }
6487
- function hasDoctrineEntry(root) {
6488
- return existsSync2(join2(root, ...ENTRY_SEGMENTS));
6489
- }
6490
-
6491
- // src/lib/config.ts
6492
- import { execFile as execFile4, execFileSync as execFileSync4 } from "node:child_process";
6493
- import { promisify as promisify4 } from "node:util";
6494
- import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync3, realpathSync, writeFileSync } from "node:fs";
6495
- import { homedir } from "node:os";
6496
- import { dirname as dirname3, isAbsolute, join as join3, resolve } from "node:path";
6497
- import { z as z4 } from "zod";
6498
-
6499
- // src/lib/agent-vendors.ts
6500
- var AGENT_VENDORS = ["skills", "claude", "gemini"];
6501
-
6502
- // src/lib/worker-boundary.ts
6503
- import { execFileSync as execFileSync3 } from "node:child_process";
6504
- var LOG_HEADER_KEYCHAIN_SERVICE = "Vinaya Log";
6505
- var logHeaderKeychainCache = new Map;
6506
- function readRealLogHeaderKeychainCredential(variable) {
6507
- if (process.platform !== "darwin")
6508
- return null;
6509
- try {
6510
- return execFileSync3("/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$/, "");
6511
- } catch {
6512
- return null;
6513
- }
6514
- }
6515
- function readLogHeaderKeychainCredential(variable) {
6516
- const cached = logHeaderKeychainCache.get(variable);
6517
- if (cached !== undefined)
6518
- return cached;
6519
- const value = readRealLogHeaderKeychainCredential(variable);
6520
- logHeaderKeychainCache.set(variable, value);
6521
- return value;
6522
- }
6523
-
6524
- // src/lib/config.ts
6525
- var EnvEntrySchema = z4.union([
6526
- z4.literal(true),
6527
- z4.object({ optional: z4.literal(true) }),
6528
- z4.object({ anyOf: z4.array(z4.string()).min(2) }),
6529
- z4.string()
6530
- ]);
6531
- var CheckEntrySchema = z4.object({
6532
- run: z4.string(),
6533
- scope: z4.enum(["diff", "full"]),
6534
- include: z4.array(z4.string()).optional(),
6535
- args: z4.array(z4.string()).optional(),
6536
- timeoutMs: z4.number().optional(),
6537
- env: z4.record(z4.string(), EnvEntrySchema).optional(),
6538
- requiresOpenPr: z4.boolean().optional(),
6539
- ownWorkflow: z4.boolean().optional(),
6540
- principalOwed: z4.literal(true).optional(),
6541
- validates: z4.enum(["body", "issue"]).optional()
6542
- }).superRefine((entry, ctx) => {
6543
- if (!entry.env)
6544
- return;
6545
- for (const [key, value] of Object.entries(entry.env)) {
6546
- if (typeof value !== "object" || value === null || !("anyOf" in value))
6547
- continue;
6548
- const members = value.anyOf;
6549
- if (new Set(members).size !== members.length) {
6550
- ctx.addIssue({
6551
- code: z4.ZodIssueCode.custom,
6552
- message: `env.${key}.anyOf has duplicate members`,
6553
- path: ["env", key, "anyOf"]
6554
- });
6555
- }
6556
- if (!members.includes(key)) {
6557
- ctx.addIssue({
6558
- code: z4.ZodIssueCode.custom,
6559
- message: `env.${key}.anyOf must include "${key}" itself as a member`,
6560
- path: ["env", key, "anyOf"]
6561
- });
6562
- }
6563
- }
6564
- });
6565
- var RoleEntrySchema = z4.object({
6566
- contract: z4.string().refine((p) => p.includes("/"), {
6567
- message: 'must be a path (contain at least one "/"), not a bare filename'
6568
- })
6569
- });
6570
- var MAX_REPORT_COMMAND_TIMEOUT_MS = 3600000;
6571
- var BRIEF_BUILTINS = [
6572
- "tier",
6573
- "testPlan",
6574
- "testPlanExclusivity",
6575
- "principalPlaceholder",
6576
- "surfaceMap",
6577
- "docUpdateList",
6578
- "worktreeStep0",
6579
- "stopConditions",
6580
- "autonomyClause",
6581
- "project",
6582
- "for",
6583
- "closesN",
6584
- "premiseCoverage",
6585
- "issueRationale",
6586
- "objectives",
6587
- "briefSections",
6588
- "milestoneShape"
6589
- ];
6590
- var BriefSectionSchema = z4.union([
6591
- z4.object({ builtin: z4.enum(BRIEF_BUILTINS) }),
6592
- z4.object({ heading: z4.string().min(1), name: z4.string().optional() }),
6593
- z4.object({ field: z4.string().min(1), name: z4.string().optional() }),
6594
- z4.object({ phrase: z4.string().min(1), name: z4.string().optional() })
6595
- ]);
6596
- var BriefSchemaSchema = z4.object({
6597
- pr: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
6598
- issue: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
6599
- milestone: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
6600
- ack: z4.array(z4.enum(BRIEF_BUILTINS)).optional()
6601
- });
6602
- function isSafeRepoRelPath(p) {
6603
- if (p.length === 0)
6604
- return false;
6605
- if (p.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(p))
6606
- return false;
6607
- return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
6608
- }
6609
- var SafeRepoRelPath = z4.string().refine(isSafeRepoRelPath, {
6610
- message: "must be a repo-root-relative path with no `..` segment or absolute root"
6611
- });
6612
- var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
6613
- function isCanonicalHookBlockPath(p) {
6614
- return CANONICAL_HOOK_BLOCK_PREFIXES.some((prefix) => p.startsWith(prefix) && p.length > prefix.length);
6615
- }
6616
- var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
6617
- message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
6618
- });
6619
- var ManagedBlockRecordSchema = z4.object({
6620
- path: ManagedHookBlockPath,
6621
- marker: z4.string(),
6622
- comment: z4.enum(["hash", "html"])
6623
- });
6624
- var ManagedManifestSchema = z4.object({
6625
- version: z4.number().int().positive(),
6626
- files: z4.array(SafeRepoRelPath),
6627
- blocks: z4.array(ManagedBlockRecordSchema),
6628
- labels: z4.array(z4.string()),
6629
- agents: z4.array(z4.enum(AGENT_VENDORS)).optional()
6630
- });
6631
- var ProjectEntrySchema = z4.object({
6632
- name: z4.string().min(1),
6633
- description: z4.string().min(1).optional(),
6634
- path: z4.string().min(1).optional()
6635
- });
6636
- function parseTokensCollectDeclaration(value) {
6637
- const m = value.trim().match(/^(\S+)\s+(\S+)$/);
6638
- if (!m)
6639
- return null;
6640
- const [, interpreter, script] = m;
6641
- if (!isSafeRepoRelPath(script))
6642
- return null;
6643
- return { interpreter, script };
6644
- }
6645
- var VinayaConfigSchema = z4.object({
6646
- rings: z4.object({
6647
- ring1_forgeWriteInterception: z4.boolean(),
6648
- ring2_asyncAudits: z4.boolean()
6649
- }).optional(),
6650
- checks: z4.record(z4.string(), CheckEntrySchema).optional(),
6651
- roles: z4.record(z4.string(), RoleEntrySchema).optional(),
6652
- briefSchema: BriefSchemaSchema.optional(),
6653
- managed: ManagedManifestSchema.optional(),
6654
- principals: z4.array(z4.string()).min(1).optional(),
6655
- releaseActor: z4.string().min(1).optional(),
6656
- ci: z4.object({ setup: z4.string().min(1) }).optional(),
6657
- tokens: z4.object({
6658
- collect: z4.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
6659
- message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
6660
- })
6661
- }).optional(),
6662
- blastRadius: z4.object({ extraDomains: z4.array(z4.string()).optional() }).optional(),
6663
- proseGates: z4.object({
6664
- doctrineRoot: z4.string().min(1).optional(),
6665
- readerFacingPrefix: z4.string().min(1).optional(),
6666
- readerFacingSuffix: z4.string().min(1).optional(),
6667
- legacySlugDir: z4.string().min(1).optional(),
6668
- sourceComments: z4.object({
6669
- globs: z4.array(z4.string().min(1)).optional(),
6670
- allowlist: z4.array(z4.string().min(1)).optional(),
6671
- severity: z4.enum(["warning", "error"]).optional()
6672
- }).optional(),
6673
- specGrandfather: z4.array(z4.string().min(1)).optional(),
6674
- specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
6675
- message: "must be a repository-relative path, not an absolute one"
6676
- }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
6677
- message: "must stay inside the repository — no `..` segment"
6678
- })).optional()
6679
- }).optional(),
6680
- projects: z4.array(ProjectEntrySchema).optional(),
6681
- dispatch: z4.object({
6682
- timeoutMs: z4.number().int().positive().optional(),
6683
- killGraceMs: z4.number().int().positive().optional(),
6684
- agent: z4.enum(["claude", "codex", "gemini"]).optional(),
6685
- requireWorkerIsolation: z4.boolean().optional()
6686
- }).optional(),
6687
- reviewPolicy: z4.object({
6688
- codeReviewThreshold: z4.string().min(1).optional(),
6689
- securityThreshold: z4.string().min(1).optional(),
6690
- maxRounds: z4.number().optional()
6691
- }).optional(),
6692
- gateCutovers: z4.object({
6693
- objectivesSinceIssue: z4.number().int().nonnegative().optional(),
6694
- briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
6695
- documentationSinceIssue: z4.number().int().nonnegative().optional(),
6696
- briefRulesSincePr: z4.number().int().nonnegative().optional(),
6697
- agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
6698
- }).optional(),
6699
- planning: z4.object({
6700
- collisionThreshold: z4.number().int().nonnegative().optional()
6701
- }).optional(),
6702
- prePush: z4.object({
6703
- alwaysRun: z4.array(z4.string()).optional()
6704
- }).optional(),
6705
- report: z4.object({
6706
- commandTimeoutMs: z4.number().int().positive().optional()
6707
- }).superRefine((report, ctx) => {
6708
- const commandTimeoutMs = report.commandTimeoutMs;
6709
- if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
6710
- ctx.addIssue({
6711
- code: z4.ZodIssueCode.custom,
6712
- path: ["commandTimeoutMs"],
6713
- message: "must be at most 3600000 (1 hour)"
6714
- });
6715
- }
6716
- }).optional(),
6717
- logPublish: z4.unknown().refine((v) => v === undefined, {
6718
- message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
6719
- }),
6720
- runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
6721
- logs: z4.object({
6722
- folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
6723
- url: z4.string().url().optional(),
6724
- headers: z4.record(z4.string()).optional()
6725
- }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
6726
- message: "logs: set at most one of folder/url"
6727
- }).refine((v) => v.headers === undefined || v.url !== undefined, {
6728
- message: "logs: headers requires url"
6729
- }).optional()
6730
- });
6731
- var GLOBAL_VINAYA_HOME = join3(homedir(), ".vinaya");
6732
- var GLOBAL_CONFIG_PATH = join3(GLOBAL_VINAYA_HOME, "config.json");
6733
- var LOCAL_CONFIG_FILENAME = "vinaya.config.json";
6734
- function findLocalConfig() {
6735
- let dir = process.cwd();
6736
- while (true) {
6737
- const candidate = join3(dir, LOCAL_CONFIG_FILENAME);
6738
- if (existsSync3(candidate))
6739
- return candidate;
6740
- if (existsSync3(join3(dir, ".git")))
6741
- return null;
6742
- const parent = dirname3(dir);
6743
- if (parent === dir)
6744
- return null;
6745
- dir = parent;
6746
- }
6747
- }
6748
- function configPath() {
6749
- const local = findLocalConfig();
6750
- if (local)
6751
- return local;
6752
- if (existsSync3(GLOBAL_CONFIG_PATH))
6753
- return GLOBAL_CONFIG_PATH;
6754
- return null;
6755
- }
6756
- function globalChecksIgnoredWarning(path) {
6757
- return `${path}: "checks" registration in the global config is ignored — checks may only be registered from a repo-local vinaya.config.json.`;
6758
- }
6759
- function globalPrincipalsIgnoredWarning(path) {
6760
- return `${path}: "principals" in the global config is ignored — principals may only be declared from a repo-local vinaya.config.json.`;
6761
- }
6762
- function globalRolesIgnoredWarning(path) {
6763
- return `${path}: "roles" registration in the global config is ignored — roles may only be registered from a repo-local vinaya.config.json.`;
6764
- }
6765
- function globalReleaseActorIgnoredWarning(path) {
6766
- return `${path}: "releaseActor" in the global config is ignored — releaseActor may only be declared from a repo-local vinaya.config.json.`;
6767
- }
6768
- function globalTokensCollectIgnoredWarning(path) {
6769
- return `${path}: "tokens" in the global config is ignored — tokens.collect may only be declared from a repo-local vinaya.config.json.`;
6770
- }
6771
- function globalRuntimeDirIgnoredWarning(path) {
6772
- return `${path}: "runtimeDir" in the global config is ignored — it carries no repository segment, so a machine-wide value would collapse every repository's task folders into one tree. Declare it from a repo-local vinaya.config.json.`;
6773
- }
6774
- var emittedGlobalKeyWarnings = new Set;
6775
- function warnGlobalKeyIgnoredOnce(message) {
6776
- if (emittedGlobalKeyWarnings.has(message))
6777
- return;
6778
- emittedGlobalKeyWarnings.add(message);
6779
- console.error(`⚠ ${message}`);
6780
- }
6781
- function stripGlobalOnlyKeys(config, path) {
6782
- if (path !== GLOBAL_CONFIG_PATH)
6783
- return config;
6784
- let result = config;
6785
- if (result.checks && Object.keys(result.checks).length > 0) {
6786
- warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
6787
- result = { ...result, checks: undefined };
6788
- }
6789
- if (result.roles && Object.keys(result.roles).length > 0) {
6790
- warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
6791
- result = { ...result, roles: undefined };
6792
- }
6793
- if (result.principals && result.principals.length > 0) {
6794
- warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
6795
- result = { ...result, principals: undefined };
6796
- }
6797
- if (result.releaseActor) {
6798
- warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
6799
- result = { ...result, releaseActor: undefined };
6800
- }
6801
- if (result.tokens) {
6802
- warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
6803
- result = { ...result, tokens: undefined };
6804
- }
6805
- if (result.runtimeDir) {
6806
- warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
6807
- result = { ...result, runtimeDir: undefined };
6808
- }
6809
- return result;
6810
- }
6811
- function resolvePrincipalAllowlist(config) {
6812
- return config?.principals ?? PRINCIPAL_ALLOWLIST;
6813
- }
6814
- function resolveReleaseActor(config) {
6815
- return config?.releaseActor ?? DEFAULT_RELEASE_ACTOR;
6816
- }
6817
- function resolveReviewPolicy(config) {
6818
- const raw = config?.reviewPolicy;
6819
- if (!raw)
6820
- return DEFAULT_REVIEW_POLICY;
6821
- const codeReviewThreshold = raw.codeReviewThreshold ?? DEFAULT_REVIEW_POLICY.codeReviewThreshold;
6822
- if (!isKnownSeverity(CODE_REVIEW_SEVERITY_ORDER, codeReviewThreshold)) {
6823
- throw new Error(`vinaya.config.json: reviewPolicy.codeReviewThreshold "${codeReviewThreshold}" is not one of ${CODE_REVIEW_SEVERITY_ORDER.join(" > ")} — fix the config, this never falls back to a default.`);
6824
- }
6825
- const securityThreshold = raw.securityThreshold ?? DEFAULT_REVIEW_POLICY.securityThreshold;
6826
- if (!isKnownSeverity(SECURITY_SEVERITY_ORDER, securityThreshold)) {
6827
- throw new Error(`vinaya.config.json: reviewPolicy.securityThreshold "${securityThreshold}" is not one of ${SECURITY_SEVERITY_ORDER.join(" > ")} — fix the config, this never falls back to a default.`);
6828
- }
6829
- const maxRounds = raw.maxRounds ?? DEFAULT_REVIEW_POLICY.maxRounds;
6830
- if (!Number.isInteger(maxRounds) || maxRounds < 1) {
6831
- throw new Error(`vinaya.config.json: reviewPolicy.maxRounds "${maxRounds}" is not a positive integer — fix the config, this never falls back to a default.`);
6832
- }
6833
- return {
6834
- codeReviewThreshold,
6835
- securityThreshold,
6836
- maxRounds
6837
- };
6838
- }
6839
- function resolveGateCutovers(config) {
6840
- const raw = config?.gateCutovers;
6841
- if (!raw)
6842
- return NO_GATE_CUTOVERS;
6843
- return {
6844
- objectivesSinceIssue: raw.objectivesSinceIssue ?? null,
6845
- briefSectionsSinceIssue: raw.briefSectionsSinceIssue ?? null,
6846
- documentationSinceIssue: raw.documentationSinceIssue ?? null,
6847
- briefRulesSincePr: raw.briefRulesSincePr ?? null,
6848
- agentBoxesRefusedSincePr: raw.agentBoxesRefusedSincePr ?? null
6849
- };
6850
- }
6851
- function resolveRuntimeDirSetting(config) {
6852
- return config?.runtimeDir ?? null;
6853
- }
6854
- function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
6855
- const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
6856
- return anchored !== null && anchored === localRuntimeDir ? anchored : null;
6857
- }
6858
- function resolveLogsSetting(config) {
6859
- const raw = config?.logs;
6860
- if (!raw)
6861
- return null;
6862
- if (raw.url !== undefined)
6863
- return { url: raw.url, headers: raw.headers };
6864
- if (raw.folder !== undefined)
6865
- return { folder: raw.folder };
6866
- return null;
6867
- }
6868
- function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
6869
- const anchored = resolveLogsSetting(trustAnchorConfig);
6870
- if (!anchored)
6871
- return null;
6872
- if ("url" in local)
6873
- return "url" in anchored && anchored.url === local.url ? anchored : null;
6874
- return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
6875
- }
6876
- function resolveLogsHeaderValues(headers, env, readKeychain = readLogHeaderKeychainCredential) {
6877
- if (!headers)
6878
- return;
6879
- const resolved = {};
6880
- for (const [key, value] of Object.entries(headers)) {
6881
- resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => {
6882
- const fromEnv = env[name];
6883
- if (fromEnv !== undefined)
6884
- return fromEnv;
6885
- return readKeychain(name) ?? "";
6886
- });
6887
- }
6888
- return resolved;
6889
- }
6890
- function trustAnchorRepo() {
6891
- const fromRunner = trustAnchorRepoFromRunner();
6892
- if (fromRunner)
6893
- return fromRunner;
6894
- try {
6895
- const url = execFileSync4("git", ["remote", "get-url", "origin"], {
6896
- encoding: "utf-8",
6897
- stdio: ["ignore", "pipe", "pipe"]
6898
- });
6899
- return trustAnchorRepoFromRemoteUrl(url);
6900
- } catch {
6901
- return null;
6902
- }
6903
- }
6904
- async function trustAnchorRepoAsync() {
6905
- const fromRunner = trustAnchorRepoFromRunner();
6906
- if (fromRunner)
6907
- return fromRunner;
6908
- try {
6909
- const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
6910
- encoding: "utf-8",
6911
- timeout: 1e4,
6912
- killSignal: "SIGKILL"
6913
- });
6914
- return trustAnchorRepoFromRemoteUrl(stdout);
6915
- } catch {
6916
- return null;
6917
- }
6918
- }
6919
- function wellFormedRepoSlug(slug) {
6920
- return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
6921
- }
6922
- function trustAnchorRepoFromRunner() {
6923
- const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
6924
- return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
6925
- }
6926
- function trustAnchorRepoFromRemoteUrl(url) {
6927
- const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
6928
- return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
6929
- }
6930
- var execFileAsync4 = promisify4(execFile4);
6931
- function resolveCiTrustAnchorProbeRef(env = process.env) {
6932
- const ref = env.VINAYA_CI_CONFIG_PROBE_REF?.trim();
6933
- if (!ref)
6934
- return null;
6935
- if (env.GITHUB_ACTIONS !== "true")
6936
- return null;
6937
- if ((env.GH_TOKEN ?? "").length > 0 || (env.GITHUB_TOKEN ?? "").length > 0)
6938
- return null;
6939
- return ref;
6940
- }
6941
- function readTrustAnchorConfigAtRef(ref) {
6942
- const raw = execFileSync4("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
6943
- encoding: "utf-8",
6944
- stdio: ["ignore", "pipe", "pipe"],
6945
- timeout: 1e4
6946
- });
6947
- return Buffer.from(raw, "utf-8").toString("base64");
6948
- }
6949
- function ghFetchTrustAnchorConfig() {
6950
- const probeRef = resolveCiTrustAnchorProbeRef();
6951
- if (probeRef)
6952
- return readTrustAnchorConfigAtRef(probeRef);
6953
- const repo = trustAnchorRepo();
6954
- if (!repo)
6955
- throw new Error("could not resolve repo identity for the trust-anchor read");
6956
- return execFileSync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
6957
- encoding: "utf-8",
6958
- stdio: ["ignore", "pipe", "pipe"]
6959
- });
6960
- }
6961
- async function ghFetchTrustAnchorConfigAsync() {
6962
- const probeRef = resolveCiTrustAnchorProbeRef();
6963
- if (probeRef) {
6964
- const { stdout } = await execFileAsync4("git", ["show", `${probeRef}:${LOCAL_CONFIG_FILENAME}`], {
6965
- encoding: "utf-8",
6966
- timeout: 1e4
6967
- });
6968
- return Buffer.from(stdout, "utf-8").toString("base64");
6969
- }
6970
- const repo = await trustAnchorRepoAsync();
6971
- if (!repo)
6972
- throw new Error("could not resolve repo identity for the trust-anchor read");
6973
- const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4, killSignal: "SIGKILL" });
6974
- return stdout;
6975
- }
6976
- function firstLine(err) {
6977
- return err?.message?.split(`
6978
- `)[0] ?? "unknown error";
6979
- }
6980
- function isMissingFileError(err) {
6981
- const stderr = err?.stderr;
6982
- const haystack = [
6983
- err?.message ?? "",
6984
- typeof stderr === "string" ? stderr : stderr?.toString() ?? ""
6985
- ].join(`
6986
- `);
6987
- return /\b404\b|not found/i.test(haystack);
6988
- }
6989
- function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
6990
- let base64;
6991
- try {
6992
- base64 = fetcher();
6993
- } catch (err) {
6994
- return trustAnchorFetchFailed(err);
6995
- }
6996
- return parseTrustAnchorContent(base64);
6997
- }
6998
- async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
6999
- const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
7000
- let base64;
7001
- try {
7002
- base64 = await fetcher();
7003
- } catch (err) {
7004
- return trustAnchorFetchFailed(err, warn);
7005
- }
7006
- return parseTrustAnchorContent(base64, warn);
7007
- }
7008
- function warnTrustAnchorFallback(why) {
7009
- process.stdout.write(`⚠ could not read the trust-anchor config (\`principals\`/\`releaseActor\`) from the default branch (${why}) — falling back to vinaya's built-in defaults.
7010
- `);
7011
- }
7012
- function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
7013
- if (!isMissingFileError(err))
7014
- warn(firstLine(err));
7015
- return null;
7016
- }
7017
- function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
7018
- const base64 = content.trim();
7019
- if (!base64)
7020
- return null;
7021
- try {
7022
- const raw = Buffer.from(base64, "base64").toString("utf-8");
7023
- const parsed = VinayaConfigSchema.safeParse(JSON.parse(raw));
7024
- if (parsed.success)
7025
- return parsed.data;
7026
- warn("it did not satisfy the config schema");
7027
- return null;
7028
- } catch {
7029
- warn("it was not readable as JSON");
7030
- return null;
7031
- }
7032
- }
7033
- function loadConfig() {
7034
- const path = configPath();
7035
- if (!path)
7036
- return null;
7037
- try {
7038
- const raw = JSON.parse(readFileSync3(path, "utf-8"));
7039
- return stripGlobalOnlyKeys(VinayaConfigSchema.parse(raw), path);
7040
- } catch {
7041
- return null;
7042
- }
7043
- }
7044
- var TOKENS_COLLECT_TRUST_PATH = join3(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
7045
-
7046
- // src/checks/contract.ts
7047
- var CHECK_SCHEMA_VERSION = 1;
7048
- function emitCheckError(error) {
7049
- process.stderr.write(`${JSON.stringify(error)}
7050
- `);
7051
- }
7052
-
7053
- // src/lib/diff-evidence.ts
7054
- import { execFileSync as execFileSync7 } from "node:child_process";
7055
- import { join as join9, relative, resolve as resolve2 } from "node:path";
7056
-
7057
- // src/lib/brief-assembly.ts
7058
- import { execFileSync as execFileSync6 } from "node:child_process";
7059
- import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2 } from "node:fs";
7060
- import { join as join4 } from "node:path";
7061
-
6577
+ // ../../packages/aeg-core/src/docs/parse-doc.ts
6578
+ import matter2 from "gray-matter";
6579
+ // ../../packages/aeg-core/src/docs/surfaced-manifest.ts
6580
+ var NO_MODEL_BACKED_PATHS = new Set;
7062
6581
  // ../../packages/sources/src/commands.ts
7063
6582
  var COMMANDS = [
7064
6583
  {
@@ -7213,7 +6732,7 @@ var COMMANDS = [
7213
6732
  "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.",
7214
6733
  "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.",
7215
6734
  "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.",
7216
- "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`)."
6735
+ "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`)."
7217
6736
  ],
7218
6737
  status: "shipped"
7219
6738
  },
@@ -7298,13 +6817,14 @@ var COMMANDS = [
7298
6817
  },
7299
6818
  {
7300
6819
  flag: "--push",
7301
- 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."
6820
+ 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."
7302
6821
  }
7303
6822
  ],
7304
6823
  details: [
7305
6824
  "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.",
7306
6825
  "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.",
7307
- "`--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."
6826
+ "`--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.",
6827
+ "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."
7308
6828
  ],
7309
6829
  status: "shipped"
7310
6830
  },
@@ -7329,7 +6849,7 @@ var COMMANDS = [
7329
6849
  "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.",
7330
6850
  "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.",
7331
6851
  "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.",
7332
- "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."
6852
+ "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."
7333
6853
  ],
7334
6854
  status: "shipped"
7335
6855
  },
@@ -7500,7 +7020,7 @@ var COMMANDS = [
7500
7020
  { flag: "--secrets", description: "security only: the SECRETS line" },
7501
7021
  {
7502
7022
  flag: "--secrets-evidence-file",
7503
- description: 'security only: required whenever `--secrets` claims "none found" — the pasted scanner output backing that claim'
7023
+ 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'
7504
7024
  },
7505
7025
  { flag: "--task-id", description: "the closing `Tokens:` line's task id" },
7506
7026
  { flag: "--model", description: "the closing `Tokens:` line's model name" },
@@ -7608,7 +7128,20 @@ var COMMANDS = [
7608
7128
  flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
7609
7129
  details: [
7610
7130
  "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.",
7611
- "Once every task Issue is closed, prompts for confirmation (unless `--yes`) and closes the GitHub Milestone."
7131
+ "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.",
7132
+ "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.",
7133
+ "Idempotent: on a tranche whose Milestone is already closed and carries its retrospective, changes nothing and says it is already archived.",
7134
+ "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."
7135
+ ],
7136
+ status: "shipped"
7137
+ },
7138
+ {
7139
+ name: "archive tranches",
7140
+ description: "Archive every finished tranche that has no closed Milestone carrying its retrospective",
7141
+ flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
7142
+ details: [
7143
+ "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.",
7144
+ "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."
7612
7145
  ],
7613
7146
  status: "shipped"
7614
7147
  },
@@ -7752,6 +7285,29 @@ var COMMANDS = [
7752
7285
  ],
7753
7286
  status: "shipped"
7754
7287
  },
7288
+ {
7289
+ name: "log selftest",
7290
+ 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)",
7291
+ details: [
7292
+ "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.",
7293
+ "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.",
7294
+ "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."
7295
+ ],
7296
+ status: "shipped"
7297
+ },
7298
+ {
7299
+ name: "log emit",
7300
+ description: "Record a consumer-declared event (`logs.events` in vinaya.config.json) from a script or agent outside Vinaya",
7301
+ flags: [
7302
+ { flag: "--json '<json>'", description: "The field values as one JSON object (else read from standard input)" }
7303
+ ],
7304
+ details: [
7305
+ "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.",
7306
+ "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.",
7307
+ "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)."
7308
+ ],
7309
+ status: "shipped"
7310
+ },
7755
7311
  {
7756
7312
  name: "log send",
7757
7313
  description: "Deliver this repository's locally-held log events to the configured `logs.url` server, once",
@@ -7764,32 +7320,628 @@ var COMMANDS = [
7764
7320
  status: "shipped"
7765
7321
  },
7766
7322
  {
7767
- name: "log set-credential",
7768
- description: "Store a `logs.headers` delivery credential in the macOS login Keychain, read from standard input",
7323
+ name: "sync",
7324
+ description: "Fill, resume and rebuild the local log cache from this repository's configured destination (read-only)",
7325
+ flags: [
7326
+ {
7327
+ flag: "--rebuild",
7328
+ description: "Delete the cache file and sync from the beginning of what the destination still retains"
7329
+ },
7330
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
7331
+ ],
7769
7332
  details: [
7770
- '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.',
7771
- '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.',
7772
- "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."
7333
+ "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.",
7334
+ "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.",
7335
+ "`--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."
7773
7336
  ],
7774
7337
  status: "shipped"
7775
7338
  }
7776
- ];
7777
- // ../../packages/sources/src/forge-adapter.ts
7778
- function createForgeSource(config) {
7779
- return {
7780
- async getTranche(slug) {
7781
- return deriveTrancheFromForge(config.owner, config.repo, slug);
7782
- }
7783
- };
7339
+ ];
7340
+ // ../../packages/sources/src/forge-adapter.ts
7341
+ function createForgeSource(config) {
7342
+ return {
7343
+ async getTranche(slug) {
7344
+ return deriveTrancheFromForge(config.owner, config.repo, slug);
7345
+ }
7346
+ };
7347
+ }
7348
+ // ../../packages/sources/src/select-source.ts
7349
+ import { z as z5 } from "zod";
7350
+ var StateSourceConfigSchema = z5.discriminatedUnion("kind", [
7351
+ z5.object({ kind: z5.literal("forge"), owner: z5.string(), repo: z5.string() }),
7352
+ z5.object({ kind: z5.literal("file"), root: z5.string().optional() })
7353
+ ]);
7354
+ // src/lib/config.ts
7355
+ import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
7356
+ import { promisify as promisify4 } from "node:util";
7357
+ import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
7358
+ import { homedir } from "node:os";
7359
+ import { dirname as dirname2, isAbsolute, join as join2, resolve } from "node:path";
7360
+ import { z as z6 } from "zod";
7361
+
7362
+ // src/lib/agent-vendors.ts
7363
+ var AGENT_VENDORS = ["skills", "claude", "gemini"];
7364
+
7365
+ // src/lib/config.ts
7366
+ var EnvEntrySchema = z6.union([
7367
+ z6.literal(true),
7368
+ z6.object({ optional: z6.literal(true) }),
7369
+ z6.object({ anyOf: z6.array(z6.string()).min(2) }),
7370
+ z6.string()
7371
+ ]);
7372
+ var CheckEntrySchema = z6.object({
7373
+ run: z6.string(),
7374
+ scope: z6.enum(["diff", "full"]),
7375
+ include: z6.array(z6.string()).optional(),
7376
+ args: z6.array(z6.string()).optional(),
7377
+ timeoutMs: z6.number().optional(),
7378
+ env: z6.record(z6.string(), EnvEntrySchema).optional(),
7379
+ requiresOpenPr: z6.boolean().optional(),
7380
+ ownWorkflow: z6.boolean().optional(),
7381
+ principalOwed: z6.literal(true).optional(),
7382
+ validates: z6.enum(["body", "issue"]).optional()
7383
+ }).superRefine((entry, ctx) => {
7384
+ if (!entry.env)
7385
+ return;
7386
+ for (const [key, value] of Object.entries(entry.env)) {
7387
+ if (typeof value !== "object" || value === null || !("anyOf" in value))
7388
+ continue;
7389
+ const members = value.anyOf;
7390
+ if (new Set(members).size !== members.length) {
7391
+ ctx.addIssue({
7392
+ code: z6.ZodIssueCode.custom,
7393
+ message: `env.${key}.anyOf has duplicate members`,
7394
+ path: ["env", key, "anyOf"]
7395
+ });
7396
+ }
7397
+ if (!members.includes(key)) {
7398
+ ctx.addIssue({
7399
+ code: z6.ZodIssueCode.custom,
7400
+ message: `env.${key}.anyOf must include "${key}" itself as a member`,
7401
+ path: ["env", key, "anyOf"]
7402
+ });
7403
+ }
7404
+ }
7405
+ });
7406
+ var RoleEntrySchema = z6.object({
7407
+ contract: z6.string().refine((p) => p.includes("/"), {
7408
+ message: 'must be a path (contain at least one "/"), not a bare filename'
7409
+ })
7410
+ });
7411
+ var MAX_REPORT_COMMAND_TIMEOUT_MS = 3600000;
7412
+ var BRIEF_BUILTINS = [
7413
+ "tier",
7414
+ "testPlan",
7415
+ "testPlanExclusivity",
7416
+ "principalPlaceholder",
7417
+ "surfaceMap",
7418
+ "docUpdateList",
7419
+ "worktreeStep0",
7420
+ "stopConditions",
7421
+ "autonomyClause",
7422
+ "project",
7423
+ "for",
7424
+ "closesN",
7425
+ "premiseCoverage",
7426
+ "issueRationale",
7427
+ "objectives",
7428
+ "briefSections",
7429
+ "milestoneShape"
7430
+ ];
7431
+ var BriefSectionSchema = z6.union([
7432
+ z6.object({ builtin: z6.enum(BRIEF_BUILTINS) }),
7433
+ z6.object({ heading: z6.string().min(1), name: z6.string().optional() }),
7434
+ z6.object({ field: z6.string().min(1), name: z6.string().optional() }),
7435
+ z6.object({ phrase: z6.string().min(1), name: z6.string().optional() })
7436
+ ]);
7437
+ var BriefSchemaSchema = z6.object({
7438
+ pr: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
7439
+ issue: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
7440
+ milestone: z6.object({ sections: z6.array(BriefSectionSchema) }).optional(),
7441
+ ack: z6.array(z6.enum(BRIEF_BUILTINS)).optional()
7442
+ });
7443
+ function isSafeRepoRelPath(p) {
7444
+ if (p.length === 0)
7445
+ return false;
7446
+ if (p.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(p))
7447
+ return false;
7448
+ return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
7449
+ }
7450
+ var SafeRepoRelPath = z6.string().refine(isSafeRepoRelPath, {
7451
+ message: "must be a repo-root-relative path with no `..` segment or absolute root"
7452
+ });
7453
+ var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
7454
+ function isCanonicalHookBlockPath(p) {
7455
+ return CANONICAL_HOOK_BLOCK_PREFIXES.some((prefix) => p.startsWith(prefix) && p.length > prefix.length);
7456
+ }
7457
+ var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
7458
+ message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
7459
+ });
7460
+ var ManagedBlockRecordSchema = z6.object({
7461
+ path: ManagedHookBlockPath,
7462
+ marker: z6.string(),
7463
+ comment: z6.enum(["hash", "html"])
7464
+ });
7465
+ var ManagedManifestSchema = z6.object({
7466
+ version: z6.number().int().positive(),
7467
+ files: z6.array(SafeRepoRelPath),
7468
+ blocks: z6.array(ManagedBlockRecordSchema),
7469
+ labels: z6.array(z6.string()),
7470
+ agents: z6.array(z6.enum(AGENT_VENDORS)).optional()
7471
+ });
7472
+ var ProjectEntrySchema = z6.object({
7473
+ name: z6.string().min(1),
7474
+ description: z6.string().min(1).optional(),
7475
+ path: z6.string().min(1).optional()
7476
+ });
7477
+ function parseTokensCollectDeclaration(value) {
7478
+ const m = value.trim().match(/^(\S+)\s+(\S+)$/);
7479
+ if (!m)
7480
+ return null;
7481
+ const [, interpreter, script] = m;
7482
+ if (!isSafeRepoRelPath(script))
7483
+ return null;
7484
+ return { interpreter, script };
7485
+ }
7486
+ var VinayaConfigSchema = z6.object({
7487
+ rings: z6.object({
7488
+ ring1_forgeWriteInterception: z6.boolean(),
7489
+ ring2_asyncAudits: z6.boolean()
7490
+ }).optional(),
7491
+ checks: z6.record(z6.string(), CheckEntrySchema).optional(),
7492
+ roles: z6.record(z6.string(), RoleEntrySchema).optional(),
7493
+ briefSchema: BriefSchemaSchema.optional(),
7494
+ managed: ManagedManifestSchema.optional(),
7495
+ principals: z6.array(z6.string()).min(1).optional(),
7496
+ releaseActor: z6.string().min(1).optional(),
7497
+ ci: z6.object({ setup: z6.string().min(1) }).optional(),
7498
+ tokens: z6.object({
7499
+ collect: z6.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
7500
+ message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
7501
+ })
7502
+ }).optional(),
7503
+ blastRadius: z6.object({ extraDomains: z6.array(z6.string()).optional() }).optional(),
7504
+ proseGates: z6.object({
7505
+ doctrineRoot: z6.string().min(1).optional(),
7506
+ readerFacingPrefix: z6.string().min(1).optional(),
7507
+ readerFacingSuffix: z6.string().min(1).optional(),
7508
+ legacySlugDir: z6.string().min(1).optional(),
7509
+ sourceComments: z6.object({
7510
+ globs: z6.array(z6.string().min(1)).optional(),
7511
+ allowlist: z6.array(z6.string().min(1)).optional(),
7512
+ severity: z6.enum(["warning", "error"]).optional()
7513
+ }).optional(),
7514
+ specGrandfather: z6.union([z6.array(z6.string().min(1)), z6.record(z6.string().min(1), z6.number().int().min(0))]).optional(),
7515
+ specPaths: z6.array(z6.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
7516
+ message: "must be a repository-relative path, not an absolute one"
7517
+ }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
7518
+ message: "must stay inside the repository — no `..` segment"
7519
+ })).optional()
7520
+ }).optional(),
7521
+ projects: z6.array(ProjectEntrySchema).optional(),
7522
+ dispatch: z6.object({
7523
+ timeoutMs: z6.number().int().positive().optional(),
7524
+ killGraceMs: z6.number().int().positive().optional(),
7525
+ agent: z6.enum(["claude", "codex", "gemini"]).optional()
7526
+ }).optional(),
7527
+ reviewPolicy: z6.object({
7528
+ codeReviewThreshold: z6.string().min(1).optional(),
7529
+ securityThreshold: z6.string().min(1).optional(),
7530
+ maxRounds: z6.number().optional(),
7531
+ maxTaskMinutes: z6.number().optional()
7532
+ }).optional(),
7533
+ securityScan: z6.object({
7534
+ command: z6.array(z6.string().min(1)).min(1)
7535
+ }).optional(),
7536
+ gateCutovers: z6.object({
7537
+ objectivesSinceIssue: z6.number().int().nonnegative().optional(),
7538
+ briefSectionsSinceIssue: z6.number().int().nonnegative().optional(),
7539
+ documentationSinceIssue: z6.number().int().nonnegative().optional(),
7540
+ briefRulesSincePr: z6.number().int().nonnegative().optional(),
7541
+ agentBoxesRefusedSincePr: z6.number().int().nonnegative().optional()
7542
+ }).optional(),
7543
+ planning: z6.object({
7544
+ collisionThreshold: z6.number().int().nonnegative().optional()
7545
+ }).optional(),
7546
+ prePush: z6.object({
7547
+ alwaysRun: z6.array(z6.string()).optional()
7548
+ }).optional(),
7549
+ report: z6.object({
7550
+ commandTimeoutMs: z6.number().int().positive().optional()
7551
+ }).superRefine((report, ctx) => {
7552
+ const commandTimeoutMs = report.commandTimeoutMs;
7553
+ if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
7554
+ ctx.addIssue({
7555
+ code: z6.ZodIssueCode.custom,
7556
+ path: ["commandTimeoutMs"],
7557
+ message: "must be at most 3600000 (1 hour)"
7558
+ });
7559
+ }
7560
+ }).optional(),
7561
+ logPublish: z6.unknown().refine((v) => v === undefined, {
7562
+ message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
7563
+ }),
7564
+ runtimeDir: z6.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
7565
+ logs: z6.object({
7566
+ folder: z6.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
7567
+ url: z6.string().url().optional(),
7568
+ headers: z6.record(z6.string()).optional(),
7569
+ readHeaders: z6.record(z6.string()).optional(),
7570
+ events: CustomEventDeclarationsSchema.optional()
7571
+ }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
7572
+ message: "logs: set at most one of folder/url"
7573
+ }).refine((v) => v.headers === undefined || v.url !== undefined, {
7574
+ message: "logs: headers requires url"
7575
+ }).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
7576
+ message: "logs: readHeaders requires url"
7577
+ }).optional()
7578
+ });
7579
+ var GLOBAL_VINAYA_HOME = join2(homedir(), ".vinaya");
7580
+ var GLOBAL_CONFIG_PATH = join2(GLOBAL_VINAYA_HOME, "config.json");
7581
+ var LOCAL_CONFIG_FILENAME = "vinaya.config.json";
7582
+ function findLocalConfig() {
7583
+ let dir = process.cwd();
7584
+ while (true) {
7585
+ const candidate = join2(dir, LOCAL_CONFIG_FILENAME);
7586
+ if (existsSync2(candidate))
7587
+ return candidate;
7588
+ if (existsSync2(join2(dir, ".git")))
7589
+ return null;
7590
+ const parent = dirname2(dir);
7591
+ if (parent === dir)
7592
+ return null;
7593
+ dir = parent;
7594
+ }
7595
+ }
7596
+ function configPath() {
7597
+ const local = findLocalConfig();
7598
+ if (local)
7599
+ return local;
7600
+ if (existsSync2(GLOBAL_CONFIG_PATH))
7601
+ return GLOBAL_CONFIG_PATH;
7602
+ return null;
7603
+ }
7604
+ function globalChecksIgnoredWarning(path) {
7605
+ return `${path}: "checks" registration in the global config is ignored — checks may only be registered from a repo-local vinaya.config.json.`;
7606
+ }
7607
+ function globalPrincipalsIgnoredWarning(path) {
7608
+ return `${path}: "principals" in the global config is ignored — principals may only be declared from a repo-local vinaya.config.json.`;
7609
+ }
7610
+ function globalRolesIgnoredWarning(path) {
7611
+ return `${path}: "roles" registration in the global config is ignored — roles may only be registered from a repo-local vinaya.config.json.`;
7612
+ }
7613
+ function globalReleaseActorIgnoredWarning(path) {
7614
+ return `${path}: "releaseActor" in the global config is ignored — releaseActor may only be declared from a repo-local vinaya.config.json.`;
7615
+ }
7616
+ function globalTokensCollectIgnoredWarning(path) {
7617
+ return `${path}: "tokens" in the global config is ignored — tokens.collect may only be declared from a repo-local vinaya.config.json.`;
7618
+ }
7619
+ function globalRuntimeDirIgnoredWarning(path) {
7620
+ return `${path}: "runtimeDir" in the global config is ignored — it carries no repository segment, so a machine-wide value would collapse every repository's task folders into one tree. Declare it from a repo-local vinaya.config.json.`;
7621
+ }
7622
+ var emittedGlobalKeyWarnings = new Set;
7623
+ function warnGlobalKeyIgnoredOnce(message) {
7624
+ if (emittedGlobalKeyWarnings.has(message))
7625
+ return;
7626
+ emittedGlobalKeyWarnings.add(message);
7627
+ console.error(`⚠ ${message}`);
7628
+ }
7629
+ function stripGlobalOnlyKeys(config, path) {
7630
+ if (path !== GLOBAL_CONFIG_PATH)
7631
+ return config;
7632
+ let result = config;
7633
+ if (result.checks && Object.keys(result.checks).length > 0) {
7634
+ warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
7635
+ result = { ...result, checks: undefined };
7636
+ }
7637
+ if (result.roles && Object.keys(result.roles).length > 0) {
7638
+ warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
7639
+ result = { ...result, roles: undefined };
7640
+ }
7641
+ if (result.principals && result.principals.length > 0) {
7642
+ warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
7643
+ result = { ...result, principals: undefined };
7644
+ }
7645
+ if (result.releaseActor) {
7646
+ warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
7647
+ result = { ...result, releaseActor: undefined };
7648
+ }
7649
+ if (result.tokens) {
7650
+ warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
7651
+ result = { ...result, tokens: undefined };
7652
+ }
7653
+ if (result.runtimeDir) {
7654
+ warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
7655
+ result = { ...result, runtimeDir: undefined };
7656
+ }
7657
+ return result;
7658
+ }
7659
+ function resolvePrincipalAllowlist(config) {
7660
+ return config?.principals ?? PRINCIPAL_ALLOWLIST;
7661
+ }
7662
+ function resolveReleaseActor(config) {
7663
+ return config?.releaseActor ?? DEFAULT_RELEASE_ACTOR;
7664
+ }
7665
+ function resolveReviewPolicy(config) {
7666
+ const raw = config?.reviewPolicy;
7667
+ if (!raw)
7668
+ return DEFAULT_REVIEW_POLICY;
7669
+ const codeReviewThreshold = raw.codeReviewThreshold ?? DEFAULT_REVIEW_POLICY.codeReviewThreshold;
7670
+ if (!isKnownSeverity(CODE_REVIEW_SEVERITY_ORDER, codeReviewThreshold)) {
7671
+ throw new Error(`vinaya.config.json: reviewPolicy.codeReviewThreshold "${codeReviewThreshold}" is not one of ${CODE_REVIEW_SEVERITY_ORDER.join(" > ")} — fix the config, this never falls back to a default.`);
7672
+ }
7673
+ const securityThreshold = raw.securityThreshold ?? DEFAULT_REVIEW_POLICY.securityThreshold;
7674
+ if (!isKnownSeverity(SECURITY_SEVERITY_ORDER, securityThreshold)) {
7675
+ throw new Error(`vinaya.config.json: reviewPolicy.securityThreshold "${securityThreshold}" is not one of ${SECURITY_SEVERITY_ORDER.join(" > ")} — fix the config, this never falls back to a default.`);
7676
+ }
7677
+ const maxRounds = raw.maxRounds ?? DEFAULT_REVIEW_POLICY.maxRounds;
7678
+ if (!Number.isInteger(maxRounds) || maxRounds < 1) {
7679
+ throw new Error(`vinaya.config.json: reviewPolicy.maxRounds "${maxRounds}" is not a positive integer — fix the config, this never falls back to a default.`);
7680
+ }
7681
+ const maxTaskMinutes = raw.maxTaskMinutes ?? DEFAULT_REVIEW_POLICY.maxTaskMinutes;
7682
+ if (!Number.isInteger(maxTaskMinutes) || maxTaskMinutes < 0) {
7683
+ 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.`);
7684
+ }
7685
+ return {
7686
+ codeReviewThreshold,
7687
+ securityThreshold,
7688
+ maxRounds,
7689
+ maxTaskMinutes
7690
+ };
7691
+ }
7692
+ function resolveGateCutovers(config) {
7693
+ const raw = config?.gateCutovers;
7694
+ if (!raw)
7695
+ return NO_GATE_CUTOVERS;
7696
+ return {
7697
+ objectivesSinceIssue: raw.objectivesSinceIssue ?? null,
7698
+ briefSectionsSinceIssue: raw.briefSectionsSinceIssue ?? null,
7699
+ documentationSinceIssue: raw.documentationSinceIssue ?? null,
7700
+ briefRulesSincePr: raw.briefRulesSincePr ?? null,
7701
+ agentBoxesRefusedSincePr: raw.agentBoxesRefusedSincePr ?? null
7702
+ };
7703
+ }
7704
+ function resolveRuntimeDirSetting(config) {
7705
+ return config?.runtimeDir ?? null;
7706
+ }
7707
+ function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
7708
+ const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
7709
+ return anchored !== null && anchored === localRuntimeDir ? anchored : null;
7710
+ }
7711
+ function resolveLogsSetting(config) {
7712
+ const raw = config?.logs;
7713
+ if (!raw)
7714
+ return null;
7715
+ if (raw.url !== undefined)
7716
+ return { url: raw.url, headers: raw.headers };
7717
+ if (raw.folder !== undefined)
7718
+ return { folder: raw.folder };
7719
+ return null;
7720
+ }
7721
+ function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
7722
+ const anchored = resolveLogsSetting(trustAnchorConfig);
7723
+ if (!anchored)
7724
+ return null;
7725
+ if ("url" in local)
7726
+ return "url" in anchored && anchored.url === local.url ? anchored : null;
7727
+ return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
7728
+ }
7729
+ function resolveLogsHeaderValues(headers, env) {
7730
+ if (!headers)
7731
+ return;
7732
+ const resolved = {};
7733
+ for (const [key, value] of Object.entries(headers)) {
7734
+ resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
7735
+ }
7736
+ return resolved;
7737
+ }
7738
+ function trustAnchorRepo() {
7739
+ const fromRunner = trustAnchorRepoFromRunner();
7740
+ if (fromRunner)
7741
+ return fromRunner;
7742
+ try {
7743
+ const url = execFileSync2("git", ["remote", "get-url", "origin"], {
7744
+ encoding: "utf-8",
7745
+ stdio: ["ignore", "pipe", "pipe"]
7746
+ });
7747
+ return trustAnchorRepoFromRemoteUrl(url);
7748
+ } catch {
7749
+ return null;
7750
+ }
7751
+ }
7752
+ async function trustAnchorRepoAsync() {
7753
+ const fromRunner = trustAnchorRepoFromRunner();
7754
+ if (fromRunner)
7755
+ return fromRunner;
7756
+ try {
7757
+ const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
7758
+ encoding: "utf-8",
7759
+ timeout: 1e4,
7760
+ killSignal: "SIGKILL"
7761
+ });
7762
+ return trustAnchorRepoFromRemoteUrl(stdout);
7763
+ } catch {
7764
+ return null;
7765
+ }
7766
+ }
7767
+ function wellFormedRepoSlug(slug) {
7768
+ return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
7769
+ }
7770
+ function trustAnchorRepoFromRunner() {
7771
+ const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
7772
+ return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
7773
+ }
7774
+ function trustAnchorRepoFromRemoteUrl(url) {
7775
+ const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
7776
+ return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
7777
+ }
7778
+ var execFileAsync4 = promisify4(execFile4);
7779
+ function resolveCiTrustAnchorProbeRef(env = process.env) {
7780
+ const ref = env.VINAYA_CI_CONFIG_PROBE_REF?.trim();
7781
+ if (!ref)
7782
+ return null;
7783
+ if (env.GITHUB_ACTIONS !== "true")
7784
+ return null;
7785
+ if ((env.GH_TOKEN ?? "").length > 0 || (env.GITHUB_TOKEN ?? "").length > 0)
7786
+ return null;
7787
+ return ref;
7788
+ }
7789
+ function readTrustAnchorConfigAtRef(ref) {
7790
+ const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
7791
+ encoding: "utf-8",
7792
+ stdio: ["ignore", "pipe", "pipe"],
7793
+ timeout: 1e4
7794
+ });
7795
+ return Buffer.from(raw, "utf-8").toString("base64");
7796
+ }
7797
+ function ghFetchTrustAnchorConfig() {
7798
+ const probeRef = resolveCiTrustAnchorProbeRef();
7799
+ if (probeRef)
7800
+ return readTrustAnchorConfigAtRef(probeRef);
7801
+ const repo = trustAnchorRepo();
7802
+ if (!repo)
7803
+ throw new Error("could not resolve repo identity for the trust-anchor read");
7804
+ return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
7805
+ encoding: "utf-8",
7806
+ stdio: ["ignore", "pipe", "pipe"]
7807
+ });
7808
+ }
7809
+ async function ghFetchTrustAnchorConfigAsync() {
7810
+ const probeRef = resolveCiTrustAnchorProbeRef();
7811
+ if (probeRef) {
7812
+ const { stdout } = await execFileAsync4("git", ["show", `${probeRef}:${LOCAL_CONFIG_FILENAME}`], {
7813
+ encoding: "utf-8",
7814
+ timeout: 1e4
7815
+ });
7816
+ return Buffer.from(stdout, "utf-8").toString("base64");
7817
+ }
7818
+ const repo = await trustAnchorRepoAsync();
7819
+ if (!repo)
7820
+ throw new Error("could not resolve repo identity for the trust-anchor read");
7821
+ const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4, killSignal: "SIGKILL" });
7822
+ return stdout;
7823
+ }
7824
+ function firstLine(err) {
7825
+ return err?.message?.split(`
7826
+ `)[0] ?? "unknown error";
7827
+ }
7828
+ function isMissingFileError(err) {
7829
+ const stderr = err?.stderr;
7830
+ const haystack = [
7831
+ err?.message ?? "",
7832
+ typeof stderr === "string" ? stderr : stderr?.toString() ?? ""
7833
+ ].join(`
7834
+ `);
7835
+ return /\b404\b|not found/i.test(haystack);
7836
+ }
7837
+ function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
7838
+ let base64;
7839
+ try {
7840
+ base64 = fetcher();
7841
+ } catch (err) {
7842
+ return trustAnchorFetchFailed(err);
7843
+ }
7844
+ return parseTrustAnchorContent(base64);
7845
+ }
7846
+ async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
7847
+ const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
7848
+ let base64;
7849
+ try {
7850
+ base64 = await fetcher();
7851
+ } catch (err) {
7852
+ return trustAnchorFetchFailed(err, warn);
7853
+ }
7854
+ return parseTrustAnchorContent(base64, warn);
7855
+ }
7856
+ function warnTrustAnchorFallback(why) {
7857
+ process.stdout.write(`⚠ could not read the trust-anchor config (\`principals\`/\`releaseActor\`) from the default branch (${why}) — falling back to vinaya's built-in defaults.
7858
+ `);
7859
+ }
7860
+ function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
7861
+ if (!isMissingFileError(err))
7862
+ warn(firstLine(err));
7863
+ return null;
7864
+ }
7865
+ function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
7866
+ const base64 = content.trim();
7867
+ if (!base64)
7868
+ return null;
7869
+ try {
7870
+ const raw = Buffer.from(base64, "base64").toString("utf-8");
7871
+ const parsed = VinayaConfigSchema.safeParse(JSON.parse(raw));
7872
+ if (parsed.success)
7873
+ return parsed.data;
7874
+ warn("it did not satisfy the config schema");
7875
+ return null;
7876
+ } catch {
7877
+ warn("it was not readable as JSON");
7878
+ return null;
7879
+ }
7784
7880
  }
7785
- // ../../packages/sources/src/select-source.ts
7786
- import { z as z5 } from "zod";
7787
- var StateSourceConfigSchema = z5.discriminatedUnion("kind", [
7788
- z5.object({ kind: z5.literal("forge"), owner: z5.string(), repo: z5.string() }),
7789
- z5.object({ kind: z5.literal("file"), root: z5.string().optional() })
7790
- ]);
7791
- // src/checks/edge-resolve.ts
7881
+ function loadConfig() {
7882
+ const path = configPath();
7883
+ if (!path)
7884
+ return null;
7885
+ try {
7886
+ const raw = JSON.parse(readFileSync2(path, "utf-8"));
7887
+ return stripGlobalOnlyKeys(VinayaConfigSchema.parse(raw), path);
7888
+ } catch {
7889
+ return null;
7890
+ }
7891
+ }
7892
+ var TOKENS_COLLECT_TRUST_PATH = join2(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
7893
+
7894
+ // src/roles/contract.ts
7895
+ import matter3 from "gray-matter";
7896
+
7897
+ // src/commands/doctrine.ts
7898
+ var ENTRY_SEGMENTS = ["skills", "aeg", "SKILL.md"];
7899
+ function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
7900
+ return resolveDoctrineRootInfo(pkg, cwd)?.root ?? null;
7901
+ }
7902
+ function gitToplevel(cwd) {
7903
+ try {
7904
+ return execFileSync3("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
7905
+ encoding: "utf8",
7906
+ stdio: ["ignore", "pipe", "pipe"]
7907
+ }).trim();
7908
+ } catch {
7909
+ return null;
7910
+ }
7911
+ }
7912
+ function resolveDoctrineRootInfo(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
7913
+ const toplevel = gitToplevel(cwd);
7914
+ if (toplevel !== null) {
7915
+ const treeRoot = join3(toplevel, "aeg-root");
7916
+ if (existsSync3(join3(treeRoot, "roles")))
7917
+ return { root: treeRoot, source: "tree" };
7918
+ }
7919
+ const fromSource = !pkg.split(sep).includes("node_modules");
7920
+ const bundleRoot = fromSource ? join3(dirname3(dirname3(pkg)), "aeg-root") : join3(pkg, "aeg-root");
7921
+ return hasDoctrineEntry(bundleRoot) ? { root: bundleRoot, source: "bundle" } : null;
7922
+ }
7923
+ function hasDoctrineEntry(root) {
7924
+ return existsSync3(join3(root, ...ENTRY_SEGMENTS));
7925
+ }
7926
+
7927
+ // src/checks/contract.ts
7928
+ var CHECK_SCHEMA_VERSION = 1;
7929
+ function emitCheckError(error) {
7930
+ process.stderr.write(`${JSON.stringify(error)}
7931
+ `);
7932
+ }
7933
+
7934
+ // src/lib/diff-evidence.ts
7935
+ import { execFileSync as execFileSync7 } from "node:child_process";
7936
+ import { join as join9, relative as relative2, resolve as resolve2 } from "node:path";
7937
+
7938
+ // src/lib/brief-assembly.ts
7792
7939
  import { execFileSync as execFileSync5 } from "node:child_process";
7940
+ import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2 } from "node:fs";
7941
+ import { join as join4 } from "node:path";
7942
+
7943
+ // src/checks/edge-resolve.ts
7944
+ import { execFileSync as execFileSync4 } from "node:child_process";
7793
7945
  var DIRECT_ISSUE_REF = /#(\d+)/;
7794
7946
  var issueCache = new Map;
7795
7947
  function fetchIssueState(num, repo) {
@@ -7798,7 +7950,7 @@ function fetchIssueState(num, repo) {
7798
7950
  return issueCache.get(key) ?? null;
7799
7951
  let out = null;
7800
7952
  try {
7801
- const raw = execFileSync5("gh", [
7953
+ const raw = execFileSync4("gh", [
7802
7954
  "issue",
7803
7955
  "view",
7804
7956
  String(num),
@@ -7912,7 +8064,7 @@ var PACKAGED_TEMPLATE_PATH = join4(PACKAGE_ROOT, "aeg-root", "templates", "brief
7912
8064
  var TEMPLATE_PATH = existsSync4(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join4(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
7913
8065
  function git(args) {
7914
8066
  try {
7915
- return execFileSync6("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
8067
+ return execFileSync5("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
7916
8068
  } catch {
7917
8069
  return "";
7918
8070
  }
@@ -7925,12 +8077,16 @@ function expandGlob(glob) {
7925
8077
  var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
7926
8078
 
7927
8079
  // src/checks/registry.ts
7928
- import { existsSync as existsSync5 } from "node:fs";
7929
- import { join as join5 } from "node:path";
7930
- var DIST_BIN_DIR = join5(packageRoot(import.meta.url), "dist", "checks", "bin");
7931
- var SRC_BIN_DIR = join5(packageRoot(import.meta.url), "src", "checks", "bin");
7932
- var BIN_DIR = existsSync5(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
7933
- 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;
7934
8090
  function bin(name) {
7935
8091
  return join5(BIN_DIR, `${name}${BIN_EXT}`);
7936
8092
  }
@@ -8128,23 +8284,6 @@ var REGISTRY = [
8128
8284
  },
8129
8285
  1
8130
8286
  ],
8131
- [
8132
- {
8133
- name: "token-report",
8134
- validates: "body",
8135
- run: bin("check-token-report"),
8136
- scope: "diff",
8137
- timeoutMs: 15000,
8138
- requiresOpenPr: true,
8139
- env: {
8140
- PR_BODY: { optional: true },
8141
- BRANCH: { optional: true },
8142
- CLAUDE_PROJECT_DIR: { optional: true },
8143
- CLAUDE_CODE_SESSION_ID: { optional: true }
8144
- }
8145
- },
8146
- 1
8147
- ],
8148
8287
  [
8149
8288
  {
8150
8289
  name: "no-disk-state",
@@ -8494,23 +8633,35 @@ var CORE_CHECK_RING = Object.fromEntries(REGISTRY.map(([spec, ring]) => [spec.na
8494
8633
  import { execFile as execFile5 } from "node:child_process";
8495
8634
  import { randomUUID as randomUUID2 } from "node:crypto";
8496
8635
  import {
8497
- closeSync as closeSync3,
8498
- constants as fsConstants3,
8636
+ appendFileSync,
8637
+ closeSync as closeSync4,
8638
+ constants as fsConstants4,
8499
8639
  existsSync as existsSync7,
8500
- fstatSync as fstatSync2,
8501
- mkdirSync as mkdirSync3,
8502
- openSync as openSync3,
8503
- readFileSync as readFileSync6,
8640
+ fstatSync as fstatSync3,
8641
+ mkdirSync as mkdirSync4,
8642
+ lstatSync as lstatSync2,
8643
+ openSync as openSync4,
8644
+ readFileSync as readFileSync7,
8504
8645
  renameSync as renameSync2,
8505
- writeSync as writeSync2
8646
+ writeFileSync as writeFileSync3,
8647
+ writeSync as writeSync3
8506
8648
  } from "node:fs";
8507
8649
  import { hostname as osHostname, homedir as homedir3 } from "node:os";
8508
- import { dirname as dirname6, join as join8 } from "node:path";
8650
+ import { dirname as dirname7, join as join8 } from "node:path";
8509
8651
  import { promisify as promisify5 } from "node:util";
8510
8652
 
8511
8653
  // src/lib/run-paths.ts
8512
- 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";
8513
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
+ };
8514
8665
  var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8515
8666
  function isSafeRepoSegment(segment) {
8516
8667
  return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
@@ -8541,12 +8692,52 @@ function isInsideRepo(candidate, repoRoot) {
8541
8692
  const target = resolvePath(candidate);
8542
8693
  return target === root || target.startsWith(`${root}/`);
8543
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
+ }
8544
8727
  var UNATTENDED_ENV_KEY = "VINAYA_UNATTENDED";
8545
8728
  var RUNTIME_DIR_ENV_KEY = "VINAYA_RUNTIME_DIR";
8546
8729
  function isUnattendedProcess(env = process.env) {
8547
8730
  return env[UNATTENDED_ENV_KEY] === "1" || (env.VINAYA_ROLE ?? "") !== "";
8548
8731
  }
8549
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
+ }
8550
8741
  async function runtimeDirForRepoAsync(repo) {
8551
8742
  const key = repoSegment(repo);
8552
8743
  if (memoized?.key === key)
@@ -8562,6 +8753,16 @@ async function runtimeDirForRepoAsync(repo) {
8562
8753
  memoized = { key, value };
8563
8754
  return value;
8564
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
+ }
8565
8766
  function runtimeDirInputs() {
8566
8767
  const handedDown = process.env[RUNTIME_DIR_ENV_KEY];
8567
8768
  if (handedDown)
@@ -8581,7 +8782,7 @@ function repoRootSync(start = process.cwd()) {
8581
8782
  return null;
8582
8783
  }
8583
8784
  for (;; ) {
8584
- if (existsSync6(join6(dir, ".git")))
8785
+ if (existsSync5(join6(dir, ".git")))
8585
8786
  return dir;
8586
8787
  const parent = dirname4(dir);
8587
8788
  if (parent === dir)
@@ -8589,26 +8790,94 @@ function repoRootSync(start = process.cwd()) {
8589
8790
  dir = parent;
8590
8791
  }
8591
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
+ }
8592
8824
 
8593
- // src/lib/log-webhook-drain.ts
8825
+ // src/lib/loop-log.ts
8594
8826
  import {
8595
8827
  closeSync as closeSync2,
8596
8828
  constants as fsConstants2,
8597
- lstatSync,
8829
+ existsSync as existsSync6,
8830
+ fstatSync as fstatSync2,
8598
8831
  mkdirSync as mkdirSync2,
8599
8832
  openSync as openSync2,
8600
- linkSync,
8601
8833
  readFileSync as readFileSync5,
8602
- renameSync,
8834
+ readSync,
8603
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,
8604
8873
  unlinkSync,
8605
8874
  utimesSync,
8606
8875
  writeFileSync as writeFileSync2,
8607
- writeSync
8876
+ writeSync as writeSync2
8608
8877
  } from "node:fs";
8609
8878
  import { randomUUID } from "node:crypto";
8610
8879
  import { homedir as homedir2 } from "node:os";
8611
- import { dirname as dirname5, join as join7 } from "node:path";
8880
+ import { dirname as dirname6, join as join7 } from "node:path";
8612
8881
  var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
8613
8882
  var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
8614
8883
  var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
@@ -8624,13 +8893,13 @@ function isEnoent(err) {
8624
8893
  var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
8625
8894
  function tryCreateLock(lockPath, token) {
8626
8895
  try {
8627
- mkdirSync2(dirname5(lockPath), { recursive: true, mode: 448 });
8628
- 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);
8629
8898
  try {
8630
- writeSync(fd, `${token}
8899
+ writeSync2(fd, `${token}
8631
8900
  `);
8632
8901
  } finally {
8633
- closeSync2(fd);
8902
+ closeSync3(fd);
8634
8903
  }
8635
8904
  return true;
8636
8905
  } catch (err) {
@@ -8645,7 +8914,7 @@ function acquireDrainLock(lockPath) {
8645
8914
  return token;
8646
8915
  let observedMtimeMs;
8647
8916
  try {
8648
- observedMtimeMs = statSync(lockPath).mtimeMs;
8917
+ observedMtimeMs = statSync2(lockPath).mtimeMs;
8649
8918
  } catch (err) {
8650
8919
  if (!isEnoent(err))
8651
8920
  throw err;
@@ -8663,7 +8932,7 @@ function acquireDrainLock(lockPath) {
8663
8932
  }
8664
8933
  let claimedMtimeMs = null;
8665
8934
  try {
8666
- claimedMtimeMs = statSync(claimed).mtimeMs;
8935
+ claimedMtimeMs = statSync2(claimed).mtimeMs;
8667
8936
  } catch (err) {
8668
8937
  if (!isEnoent(err))
8669
8938
  throw err;
@@ -8689,7 +8958,7 @@ function acquireDrainLock(lockPath) {
8689
8958
  function renewDrainLock(lockPath, token) {
8690
8959
  let holder;
8691
8960
  try {
8692
- holder = readFileSync5(lockPath, "utf8").trim();
8961
+ holder = readFileSync6(lockPath, "utf8").trim();
8693
8962
  } catch (err) {
8694
8963
  if (!isEnoent(err))
8695
8964
  throw err;
@@ -8709,7 +8978,7 @@ function renewDrainLock(lockPath, token) {
8709
8978
  }
8710
8979
  function releaseDrainLock(lockPath, token) {
8711
8980
  try {
8712
- const holder = readFileSync5(lockPath, "utf8").trim();
8981
+ const holder = readFileSync6(lockPath, "utf8").trim();
8713
8982
  if (holder !== token)
8714
8983
  return;
8715
8984
  unlinkSync(lockPath);
@@ -8759,7 +9028,7 @@ function queueLines(buf) {
8759
9028
  return lines;
8760
9029
  }
8761
9030
  function removeQueueHead(path, cut) {
8762
- const remaining = readFileSync5(path);
9031
+ const remaining = readFileSync6(path);
8763
9032
  writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
8764
9033
  }
8765
9034
  function queueBucketSize(path) {
@@ -8780,7 +9049,7 @@ function queueBucketSize(path) {
8780
9049
  function readQueueFile(path) {
8781
9050
  if (queueBucketSize(path) === null)
8782
9051
  return null;
8783
- return readFileSync5(path);
9052
+ return readFileSync6(path);
8784
9053
  }
8785
9054
  function rejectLine(rejectedPath, reason, status, identity, raw) {
8786
9055
  const record = JSON.stringify({
@@ -8962,13 +9231,19 @@ function logsCredentialMissing(headers, env) {
8962
9231
  const varPattern = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
8963
9232
  for (const value of Object.values(headers)) {
8964
9233
  for (const match of value.matchAll(varPattern)) {
8965
- if (!env[match[1]])
8966
- return true;
9234
+ const name = match[1];
9235
+ if (env[name])
9236
+ continue;
9237
+ return true;
8967
9238
  }
8968
9239
  }
8969
9240
  return false;
8970
9241
  }
8971
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
+ }
8972
9247
  const local = resolveLogsSetting(input.localConfig);
8973
9248
  let effective = null;
8974
9249
  let fallbackReason;
@@ -9008,23 +9283,72 @@ function resolveLogDestinationFrom(input) {
9008
9283
  const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
9009
9284
  return fallbackReason ? { kind: "folder", folder, fallbackReason } : { kind: "folder", folder };
9010
9285
  }
9011
- var processTrustAnchorOnce;
9012
- function processTrustAnchor() {
9013
- if (processTrustAnchorOnce === undefined)
9014
- processTrustAnchorOnce = safeLoadTrustAnchorConfig();
9015
- 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;
9016
9294
  }
9017
9295
  async function defaultResolveLogDestination(repo, env) {
9018
9296
  const localConfig = loadConfig();
9019
9297
  const unattended = isUnattendedProcess(process.env);
9298
+ const repoRoot = repoRootSync();
9020
9299
  return resolveLogDestinationFrom({
9021
9300
  localConfig,
9022
- trustAnchorConfig: unattended ? await processTrustAnchor() : null,
9301
+ trustAnchorConfig: unattended ? await processTrustAnchor(repoRoot) : null,
9023
9302
  unattended,
9024
9303
  env,
9025
9304
  defaultFolder: join8(await runtimeDirForRepoAsync(repo), "logs"),
9026
- 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
9027
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 {}
9028
9352
  }
9029
9353
  function isEnoent2(err) {
9030
9354
  return typeof err === "object" && err !== null && err.code === "ENOENT";
@@ -9138,7 +9462,7 @@ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
9138
9462
  }
9139
9463
  function readVinayaVersion() {
9140
9464
  try {
9141
- 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"));
9142
9466
  return pkg.version ?? "unknown";
9143
9467
  } catch {
9144
9468
  return "unknown";
@@ -9176,6 +9500,7 @@ function defaultStderr(message) {
9176
9500
  }
9177
9501
  var branchIssueFallbackEnabled = true;
9178
9502
  var branchIssueByCwd = new Map;
9503
+ var branchIssueSettledByCwd = new Map;
9179
9504
  function branchIssueRead(key, read, shared) {
9180
9505
  if (!shared)
9181
9506
  return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
@@ -9184,8 +9509,30 @@ function branchIssueRead(key, read, shared) {
9184
9509
  return cached;
9185
9510
  const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9186
9511
  branchIssueByCwd.set(key, reading);
9512
+ reading.then((value) => branchIssueSettledByCwd.set(key, value));
9513
+ return reading;
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));
9187
9526
  return reading;
9188
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
+ }
9189
9536
  function defaultDeps() {
9190
9537
  return {
9191
9538
  outboxRoot: () => join8(GLOBAL_VINAYA_HOME, "outbox"),
@@ -9200,29 +9547,30 @@ function defaultDeps() {
9200
9547
  inputVersions: () => {
9201
9548
  return;
9202
9549
  },
9203
- resolveLogDestination: defaultResolveLogDestination
9550
+ resolveLogDestination: defaultResolveLogDestination,
9551
+ unresolvedLogDestination
9204
9552
  };
9205
9553
  }
9206
- 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;
9207
9555
  function guardedAppendOpen(path) {
9208
9556
  try {
9209
- return openSync3(path, APPEND_OPEN_FLAGS, 384);
9557
+ return openSync4(path, APPEND_OPEN_FLAGS, 384);
9210
9558
  } catch {
9211
9559
  return;
9212
9560
  }
9213
9561
  }
9214
9562
  function appendHardenedLine(path, line) {
9215
9563
  try {
9216
- mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
9564
+ mkdirSync4(dirname7(path), { recursive: true, mode: 448 });
9217
9565
  const fd = guardedAppendOpen(path);
9218
9566
  if (fd === undefined)
9219
9567
  return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
9220
9568
  try {
9221
- if (!fstatSync2(fd).isFile())
9569
+ if (!fstatSync3(fd).isFile())
9222
9570
  return `target is not a regular file: ${path}`;
9223
- writeSync2(fd, line);
9571
+ writeSync3(fd, line);
9224
9572
  } finally {
9225
- closeSync3(fd);
9573
+ closeSync4(fd);
9226
9574
  }
9227
9575
  return null;
9228
9576
  } catch (err) {
@@ -9232,7 +9580,7 @@ function appendHardenedLine(path, line) {
9232
9580
  function reportRotationOverflow(backupPath, warn) {
9233
9581
  let raw;
9234
9582
  try {
9235
- raw = readFileSync6(backupPath, "utf8");
9583
+ raw = readFileSync7(backupPath, "utf8");
9236
9584
  } catch {
9237
9585
  return;
9238
9586
  }
@@ -9255,7 +9603,7 @@ function reportRotationOverflow(backupPath, warn) {
9255
9603
  }
9256
9604
  function appendLine(path, line, warn) {
9257
9605
  try {
9258
- mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
9606
+ mkdirSync4(dirname7(path), { recursive: true, mode: 448 });
9259
9607
  let fd = guardedAppendOpen(path);
9260
9608
  if (fd === undefined) {
9261
9609
  warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
@@ -9264,14 +9612,14 @@ function appendLine(path, line, warn) {
9264
9612
  }
9265
9613
  let closed = false;
9266
9614
  try {
9267
- const stat = fstatSync2(fd);
9615
+ const stat = fstatSync3(fd);
9268
9616
  if (!stat.isFile()) {
9269
9617
  warn(`vinaya: log outbox target is not a regular file — refusing to write: ${path}
9270
9618
  `);
9271
9619
  return;
9272
9620
  }
9273
9621
  if (stat.size > OUTBOX_MAX_BYTES) {
9274
- closeSync3(fd);
9622
+ closeSync4(fd);
9275
9623
  closed = true;
9276
9624
  const backupPath = path.replace(/\.ndjson$/, ".1.ndjson");
9277
9625
  reportRotationOverflow(backupPath, warn);
@@ -9285,10 +9633,10 @@ function appendLine(path, line, warn) {
9285
9633
  fd = rotated;
9286
9634
  closed = false;
9287
9635
  }
9288
- writeSync2(fd, line);
9636
+ writeSync3(fd, line);
9289
9637
  } finally {
9290
9638
  if (!closed)
9291
- closeSync3(fd);
9639
+ closeSync4(fd);
9292
9640
  }
9293
9641
  } catch (err) {
9294
9642
  warn(`vinaya: log outbox write failed — ${err instanceof Error ? err.message : String(err)}
@@ -9299,12 +9647,14 @@ function createLogSink(overrides = {}) {
9299
9647
  const deps = {
9300
9648
  ...defaultDeps(),
9301
9649
  resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
9650
+ resolveHeadSha: () => resolveHeadSha(deps.cwd()),
9302
9651
  ...overrides
9303
9652
  };
9304
9653
  const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
9305
9654
  const processId = randomUUID2();
9306
9655
  let seq = 0;
9307
9656
  let warned = false;
9657
+ let folderFallbackRecorded = false;
9308
9658
  const warnOnce = (message) => {
9309
9659
  if (warned)
9310
9660
  return;
@@ -9322,6 +9672,7 @@ function createLogSink(overrides = {}) {
9322
9672
  };
9323
9673
  const readerIsReal = overrides.resolveBranchIssue === undefined;
9324
9674
  let ownBranchIssue;
9675
+ let ownBranchIssueSettled = null;
9325
9676
  const branchIssueOnce = (repo) => {
9326
9677
  if (!branchIssueFallbackEnabled)
9327
9678
  return Promise.resolve(null);
@@ -9329,10 +9680,36 @@ function createLogSink(overrides = {}) {
9329
9680
  const read = () => deps.resolveBranchIssue(slug);
9330
9681
  if (readerIsReal)
9331
9682
  return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
9332
- if (ownBranchIssue === undefined)
9683
+ if (ownBranchIssue === undefined) {
9333
9684
  ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
9685
+ ownBranchIssue.then((value) => {
9686
+ ownBranchIssueSettled = value;
9687
+ });
9688
+ }
9334
9689
  return ownBranchIssue;
9335
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;
9336
9713
  let resolveRepoCache;
9337
9714
  const resolveRepoOnce = () => {
9338
9715
  if (resolveRepoCache === undefined)
@@ -9340,6 +9717,7 @@ function createLogSink(overrides = {}) {
9340
9717
  return resolveRepoCache;
9341
9718
  };
9342
9719
  let contextCache;
9720
+ let settledContext;
9343
9721
  const context = () => {
9344
9722
  if (contextCache === undefined) {
9345
9723
  const env = deps.env();
@@ -9348,11 +9726,16 @@ function createLogSink(overrides = {}) {
9348
9726
  doctrine()
9349
9727
  ]).then(async ([resolved, doctrineValue]) => {
9350
9728
  const repo = resolved && isSafeRepoSegment3(resolved.owner) && isSafeRepoSegment3(resolved.repo) ? resolved : null;
9351
- return { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
9729
+ settledContext = { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
9730
+ return settledContext;
9352
9731
  });
9353
9732
  }
9354
9733
  return contextCache;
9355
9734
  };
9735
+ const resetContext = () => {
9736
+ contextCache = undefined;
9737
+ settledContext = undefined;
9738
+ };
9356
9739
  let drainChain = Promise.resolve();
9357
9740
  const pendingWrites = new Set;
9358
9741
  let writeChain = Promise.resolve();
@@ -9364,63 +9747,88 @@ function createLogSink(overrides = {}) {
9364
9747
  `);
9365
9748
  });
9366
9749
  };
9367
- function log(e) {
9368
- try {
9369
- const env = deps.env();
9370
- const host = hostFromEnv(env);
9371
- const now = deps.now();
9372
- const mySeq = seq++;
9373
- 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: {
9374
9757
  role: env.VINAYA_ROLE,
9375
9758
  task: env.VINAYA_TASK,
9376
9759
  round: env.VINAYA_ROUND,
9760
+ pr: env.VINAYA_PR,
9377
9761
  run: env.VINAYA_RUN || runId,
9378
9762
  attempt: env.VINAYA_ATTEMPT,
9379
- parent: env.VINAYA_PARENT_EVENT
9380
- };
9381
- const write = async () => {
9382
- const { repo, doctrine: doctrineValue, destination: resolvedDestination } = await context();
9383
- if (resolvedDestination.kind === "none") {
9384
- 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}
9385
9776
  `);
9386
- return;
9387
- }
9388
- if (resolvedDestination.kind === "folder" && resolvedDestination.fallbackReason) {
9389
- warnOnce(`vinaya: ${describeFolderFallback(resolvedDestination.fallbackReason)}
9777
+ return;
9778
+ }
9779
+ if (destination.kind === "folder" && destination.fallbackReason) {
9780
+ warnOnce(`vinaya: ${describeFolderFallback(destination.fallbackReason)}
9390
9781
  `);
9391
- }
9392
- const branchIssue = envFields.task ? null : await branchIssueOnce(repo);
9393
- const header = buildHeader({
9394
- now,
9395
- runId,
9396
- seq: mySeq,
9397
- repo: repo ? `${repo.owner}/${repo.repo}` : null,
9398
- vinaya: deps.vinayaVersion(),
9399
- doctrine: doctrineValue,
9400
- host,
9401
- hostname: deps.hostname(),
9402
- env: envFields,
9403
- branchIssue,
9404
- eventId: randomUUID2(),
9405
- processId,
9406
- inputVersions: deps.inputVersions()
9407
- });
9408
- const full = { ...e, ...header };
9409
- const parsed = LogEventSchema.safeParse(full);
9410
- if (!parsed.success) {
9411
- 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"}
9412
9807
  `);
9413
- return;
9414
- }
9415
- const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
9808
+ return;
9809
+ }
9810
+ const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
9416
9811
  `;
9417
- const destination = resolvedDestination;
9418
- if (destination.kind === "server") {
9419
- appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
9420
- scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
9421
- } else {
9422
- 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;
9423
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);
9424
9832
  };
9425
9833
  const written = writeChain.then(write).catch((err) => {
9426
9834
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
@@ -9431,6 +9839,26 @@ function createLogSink(overrides = {}) {
9431
9839
  written.finally(() => pendingWrites.delete(written));
9432
9840
  } catch (err) {
9433
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)}
9434
9862
  `);
9435
9863
  }
9436
9864
  }
@@ -9451,7 +9879,7 @@ function createLogSink(overrides = {}) {
9451
9879
  return;
9452
9880
  });
9453
9881
  };
9454
- return { log, runId, warmup, drain };
9882
+ return { log, logSync, runId, warmup, drain, resetContext };
9455
9883
  }
9456
9884
  var defaultSink = createLogSink();
9457
9885
 
@@ -9577,7 +10005,7 @@ function findingsInThisDiff(findings) {
9577
10005
  const abs = resolve2(diff.root, f.file);
9578
10006
  if (!changed.has(abs))
9579
10007
  return false;
9580
- const relPath = relative(diff.root, abs);
10008
+ const relPath = relative2(diff.root, abs);
9581
10009
  if (!ranges.has(relPath))
9582
10010
  ranges.set(relPath, changedLineRanges(diff.base, relPath));
9583
10011
  const fileRanges = ranges.get(relPath) ?? null;
@@ -9603,7 +10031,7 @@ function collect(dir, out = []) {
9603
10031
  const full = join10(dir, name);
9604
10032
  let isDir;
9605
10033
  try {
9606
- isDir = statSync2(full).isDirectory();
10034
+ isDir = statSync3(full).isDirectory();
9607
10035
  } catch {
9608
10036
  continue;
9609
10037
  }
@@ -9618,7 +10046,7 @@ function collect(dir, out = []) {
9618
10046
  return out;
9619
10047
  }
9620
10048
  function readAll(paths) {
9621
- return paths.map((p) => ({ path: p, content: readFileSync7(p, "utf8") }));
10049
+ return paths.map((p) => ({ path: p, content: readFileSync8(p, "utf8") }));
9622
10050
  }
9623
10051
  function toPosix(p) {
9624
10052
  return p.split("\\").join("/");
@@ -9626,15 +10054,15 @@ function toPosix(p) {
9626
10054
  function main() {
9627
10055
  const root = repoRoot() ?? process.cwd();
9628
10056
  const docRootAbs = resolve3(root, DOCTRINE_ROOT);
9629
- const shipsPrefix = `${toPosix(relative2(root, docRootAbs))}/`;
10057
+ const shipsPrefix = `${toPosix(relative3(root, docRootAbs))}/`;
9630
10058
  const shipsPaths = collect(docRootAbs).filter((p) => p.endsWith(".md"));
9631
10059
  const readerFacingRootAbs = READER_FACING_ACTIVE && READER_FACING_PREFIX !== null ? resolve3(root, READER_FACING_PREFIX) : null;
9632
10060
  const readerFacingPaths = readerFacingRootAbs !== null && READER_FACING_SUFFIX !== null ? collect(readerFacingRootAbs).filter((p) => p.endsWith(READER_FACING_SUFFIX)) : [];
9633
10061
  const docs = readAll([...shipsPaths, ...readerFacingPaths]).map((f) => ({
9634
10062
  ...f,
9635
- path: toPosix(relative2(root, f.path))
10063
+ path: toPosix(relative3(root, f.path))
9636
10064
  }));
9637
- const readerFacingPrefix = readerFacingRootAbs !== null ? `${toPosix(relative2(root, readerFacingRootAbs))}/` : "/no-reader-facing-surface";
10065
+ const readerFacingPrefix = readerFacingRootAbs !== null ? `${toPosix(relative3(root, readerFacingRootAbs))}/` : "/no-reader-facing-surface";
9638
10066
  const readerFacingSuffix = READER_FACING_ACTIVE && READER_FACING_SUFFIX !== null ? READER_FACING_SUFFIX : "/page.tsx";
9639
10067
  const citedQuotes = findCitedQuotes(docs, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
9640
10068
  const citedFileContents = new Map;
@@ -9644,8 +10072,8 @@ function main() {
9644
10072
  if (!isValidCitedFilePath(quote.citedFile))
9645
10073
  continue;
9646
10074
  const abs = join10(root, quote.citedFile);
9647
- if (existsSync8(abs) && statSync2(abs).isFile()) {
9648
- citedFileContents.set(quote.citedFile, readFileSync7(abs, "utf8"));
10075
+ if (existsSync8(abs) && statSync3(abs).isFile()) {
10076
+ citedFileContents.set(quote.citedFile, readFileSync8(abs, "utf8"));
9649
10077
  }
9650
10078
  }
9651
10079
  const findings = evaluateCitedQuotes(citedQuotes, citedFileContents);