@attalabs/vinaya 0.36.0 → 0.38.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 (292) 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 +14 -14
  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 +36 -37
  10. package/aeg-root/roles/developer.md +9 -5
  11. package/aeg-root/roles/operator.md +18 -18
  12. package/aeg-root/roles/planner/reference.md +15 -4
  13. package/aeg-root/roles/principal.md +6 -1
  14. package/aeg-root/roles/reviewer.md +14 -6
  15. package/aeg-root/roles/security.md +22 -11
  16. package/aeg-root/roles/tranche-archivist.md +14 -2
  17. package/aeg-root/state-machine.md +12 -11
  18. package/aeg-root/templates/brief-template.md +8 -6
  19. package/aeg-root/templates/pr-report-template.md +1 -9
  20. package/aeg-root/tranche-model.md +10 -4
  21. package/dist/checks/bin/check-body-bare-digits.js +823 -595
  22. package/dist/checks/bin/check-branch-topology.js +796 -478
  23. package/dist/checks/bin/check-brief-shape.js +824 -596
  24. package/dist/checks/bin/check-changeset-coverage.js +1337 -747
  25. package/dist/checks/bin/check-closes-n.js +796 -478
  26. package/dist/checks/bin/check-coherence.js +914 -611
  27. package/dist/checks/bin/check-dead-branch-push.js +705 -462
  28. package/dist/checks/bin/check-dispatch-readiness.js +941 -624
  29. package/dist/checks/bin/check-doc-coverage-push.js +1332 -742
  30. package/dist/checks/bin/check-doc-coverage.js +1339 -742
  31. package/dist/checks/bin/check-doctrine-no-procedures.js +821 -593
  32. package/dist/checks/bin/check-doctrine-portability.js +1332 -742
  33. package/dist/checks/bin/check-evidence-fresh.js +1339 -918
  34. package/dist/checks/bin/check-exec-bits.js +1331 -741
  35. package/dist/checks/bin/check-first-push-dispatch.js +917 -614
  36. package/dist/checks/bin/check-issue-assignment.js +796 -478
  37. package/dist/checks/bin/check-issue-milestone-attach.js +705 -462
  38. package/dist/checks/bin/check-issue-objectives-numbering.js +821 -593
  39. package/dist/checks/bin/check-issue-parts-coverage.js +705 -462
  40. package/dist/checks/bin/check-issue-surface-globs.js +925 -613
  41. package/dist/checks/bin/check-issue-title-grammar.js +705 -462
  42. package/dist/checks/bin/check-issue-tranche-label.js +705 -462
  43. package/dist/checks/bin/check-main-branch-refusal.js +705 -462
  44. package/dist/checks/bin/check-no-disk-state.js +705 -462
  45. package/dist/checks/bin/check-pr-premise-reassert.js +821 -593
  46. package/dist/checks/bin/check-pr-report-density.js +705 -462
  47. package/dist/checks/bin/check-principal-test-plan-wait.js +705 -462
  48. package/dist/checks/bin/check-quoted-command.js +1816 -1228
  49. package/dist/checks/bin/check-reader-resolvable-prose.js +1835 -1235
  50. package/dist/checks/bin/check-registry-gates.js +993 -526
  51. package/dist/checks/bin/check-retired-vocabulary.js +1810 -1222
  52. package/dist/checks/bin/check-review-gate.js +832 -604
  53. package/dist/checks/bin/check-single-plan-pr.js +705 -462
  54. package/dist/checks/bin/check-surface-scope.js +796 -478
  55. package/dist/checks/bin/check-test-plan.js +705 -462
  56. package/dist/checks/bin/check-token-collection-wired.js +705 -462
  57. package/dist/checks/bin/check-workspace-escape.js +1332 -742
  58. package/dist/checks/bin/verify-dispatch.js +3849 -0
  59. package/dist/index.js +20876 -10091
  60. package/dist/lib/pre-push-cache-test-run.js +1045 -682
  61. package/dist/lib/pre-push-changed-files.js +16 -11
  62. package/dist/lib/pre-push-select-tests.js +785 -500
  63. package/package.json +2 -2
  64. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +7 -6
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +71 -15
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +51 -12
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/index.ts +1 -0
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +31 -0
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +50 -2
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +443 -28
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +18 -5
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +6 -4
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +13 -13
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +46 -110
  75. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +169 -11
  76. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-claim.ts +32 -6
  77. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/index.ts +3 -1
  78. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/published-prose.ts +30 -0
  79. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +6 -2
  80. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +0 -1
  81. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +82 -8
  82. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +754 -7
  83. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/leftover-detection.ts +24 -6
  84. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/custom.ts +157 -0
  85. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +44 -6
  86. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/executions.ts +493 -0
  87. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/fact-sheets.ts +111 -0
  88. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/generator.ts +155 -0
  89. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/fixtures/index.ts +12 -0
  90. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +128 -0
  91. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/catches.ts +63 -0
  92. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/checks.ts +146 -0
  93. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/common.ts +137 -0
  94. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/completion.ts +137 -0
  95. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/convergence.ts +420 -0
  96. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/determinism.ts +65 -0
  97. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/index.ts +69 -0
  98. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/judgment.ts +132 -0
  99. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/labels.ts +21 -0
  100. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/time.ts +167 -0
  101. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/questions/usage.ts +139 -0
  102. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +226 -15
  103. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/store.ts +7 -7
  104. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/cache-contract.ts +207 -0
  105. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/contracts.ts +105 -0
  106. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/engine.ts +308 -0
  107. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/index.ts +34 -0
  108. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/measured.ts +20 -0
  109. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/memory-cache.ts +78 -0
  110. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/normalize.ts +156 -0
  111. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/sync/row.ts +103 -0
  112. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +34 -6
  113. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +70 -6
  114. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +52 -4
  115. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +19 -14
  116. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +201 -24
  117. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +5 -2
  118. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-phase-history.ts +46 -0
  119. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +15 -28
  120. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/app-path-routes-manifest.json +0 -1
  122. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  123. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  124. package/studio-standalone/apps/vinaya-studio/web/.next/required-server-files.json +0 -5
  125. package/studio-standalone/apps/vinaya-studio/web/.next/routes-manifest.json +0 -6
  126. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error/page.js +1 -1
  127. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error/page.js.nft.json +1 -1
  128. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  129. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  130. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  131. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  133. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  134. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  135. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  136. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  137. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js +1 -1
  138. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  141. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js +1 -1
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  143. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  144. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  145. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +3 -3
  146. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  149. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +3 -3
  150. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  151. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  152. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  153. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +3 -3
  154. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  155. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  156. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  157. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +5 -5
  158. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  159. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  160. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  161. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +3 -3
  162. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  163. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  164. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  165. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +3 -3
  166. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  167. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  168. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  169. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +3 -3
  170. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  171. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  172. package/studio-standalone/apps/vinaya-studio/web/.next/server/app-paths-manifest.json +0 -1
  173. 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
  174. 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
  175. 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
  176. 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
  177. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{_15gdg48._.js → [root-of-the-server]__04adkz-._.js} +3 -3
  178. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__05zwn98._.js +14 -0
  179. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__08e39jo._.js +3 -0
  180. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0h9yhwx._.js +1 -1
  181. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1wy7w66._.js → [root-of-the-server]__0jdjsxe._.js} +2 -2
  182. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  183. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__10riywf._.js +3 -0
  184. 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
  185. 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
  186. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1f4bb3_._.js +3 -0
  187. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  188. 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
  189. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1ng2x88._.js +3 -0
  190. 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
  191. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1snpgaw._.js +56 -0
  192. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +2 -2
  193. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_06h3wbl._.js +3 -0
  194. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
  195. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  196. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  197. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  198. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0gs4gvl._.js +3 -0
  199. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  200. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  201. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  202. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_121lrn5._.js +3 -0
  203. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  204. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1o4v6lb._.js +3 -0
  205. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1q7h5mz._.js +1 -1
  206. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1ztd4i3._.js +3 -0
  207. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_209-ugd._.js +3 -0
  208. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_214d71c._.js +3 -0
  209. 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
  210. 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
  211. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/node_modules_next_dist_1lzmr5o._.js +1 -1
  212. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_animate_components_index_ts_186fje1._.js +1 -1
  213. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_basic_components_index_ts_0xk1vda._.js +1 -1
  214. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  215. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  216. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  217. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  218. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/09fcolor69bun.js +1 -0
  219. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0lcwmwzxacdie.js +1 -0
  220. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ojry7lrbzkfd.css +1 -0
  221. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1-acpmtfmrc35.js +1 -0
  222. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1giu47hrbhroj.js +1 -0
  223. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1shz6lwruld25.js +1 -0
  224. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1ytvuy1mmnc6j.js +1 -0
  225. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3oxhhhm_psozq.js → 21a6_5cr956wj.js} +1 -1
  226. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{2o9l0b7eqbr57.js → 2f2y8xxok8zph.js} +1 -1
  227. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2g8mwnydod96u.js +1 -0
  228. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3li0ueedy-ozv.js → 2nrnuawd5fwpv.js} +1 -1
  229. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2nw47832_uvfe.js +1 -0
  230. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2qdxnj8wk2h0s.js +1 -0
  231. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3lqjwjrcvq481.js → 2xevgia1h8g0y.js} +2 -2
  232. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3b9q75p-z5ma5.js +1 -0
  233. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3cv-oe7153242.js +1 -0
  234. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3m310lbjj4p5u.js +1 -0
  235. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  236. package/studio-standalone/apps/vinaya-studio/web/server.js +1 -1
  237. package/dist/checks/bin/check-token-report.js +0 -6526
  238. 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
  239. package/studio-standalone/_node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js +0 -6
  240. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route/app-paths-manifest.json +0 -3
  241. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route/build-manifest.json +0 -9
  242. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route/server-reference-manifest.json +0 -4
  243. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js +0 -6
  244. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.map +0 -5
  245. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +0 -1
  246. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route_client-reference-manifest.js +0 -3
  247. 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
  248. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[externals]__0cki-x_._.js +0 -3
  249. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +0 -15
  250. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[turbopack]_runtime.js +0 -903
  251. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +0 -3
  252. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ln09ua._.js +0 -3
  253. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0oegopp._.js +0 -3
  254. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__13yxbjd._.js +0 -51
  255. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1duqmtm._.js +0 -3
  256. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1z7dml9._.js +0 -9
  257. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0bfs_u4._.js +0 -3
  258. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0g8_eot._.js +0 -3
  259. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0hrh_v-._.js +0 -181
  260. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0i4-dea._.js +0 -3
  261. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0o54suy._.js +0 -3
  262. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0rxd7s0._.js +0 -3
  263. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0y1jv16._.js +0 -3
  264. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_151m4rz._.js +0 -3
  265. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1a9dieq._.js +0 -3
  266. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1sxsf5q._.js +0 -3
  267. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1sy_yfr._.js +0 -3
  268. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_219v2an._.js +0 -3
  269. 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
  270. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_basic_components_form_input_tsx_0es8d8b._.js +0 -3
  271. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_brutal_components_index_ts_0n_lcc4._.js +0 -3
  272. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/packages_ui_libraries_retro_components_index_ts_0wvpm_z._.js +0 -3
  273. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/00z3-ljjd1gj9.js +0 -1
  274. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bjnj-5fy4e7l.js +0 -1
  275. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0c8uwz_-m8s99.js +0 -165
  276. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ct0c-xj0baf6.js +0 -1
  277. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ko698wh8xx2g.css +0 -1
  278. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0t5n_r4xm__t-.js +0 -1
  279. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0vc2u252q5q6o.js +0 -1
  280. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/16r_o07lw0vm0.js +0 -1
  281. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1cah7_e5a1zvu.js +0 -1
  282. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/1gjo9-6dz7nup.js +0 -1
  283. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/24tz8aro1uto4.js +0 -1
  284. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2ef2g5fozszw7.js +0 -1
  285. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2ka8dg687auhj.js +0 -1
  286. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2pf3f50gbrkyv.js +0 -1
  287. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2qq49pct3q51-.js +0 -1
  288. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3et66z7glk65w.js +0 -1
  289. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3y6u3prmrkea-.js +0 -1
  290. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{z1fTSBP6ZlUjObzFIp-qq → yNZEFRSjP9BLUfdf96Eol}/_buildManifest.js +0 -0
  291. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{z1fTSBP6ZlUjObzFIp-qq → yNZEFRSjP9BLUfdf96Eol}/_clientMiddlewareManifest.js +0 -0
  292. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{z1fTSBP6ZlUjObzFIp-qq → yNZEFRSjP9BLUfdf96Eol}/_ssgManifest.js +0 -0
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/checks/bin/check-exec-bits.ts
4
4
  import { execFileSync as execFileSync8 } from "node:child_process";
5
- import { readFileSync as readFileSync7 } from "node:fs";
5
+ import { readFileSync as readFileSync8 } from "node:fs";
6
6
 
7
7
  // src/checks/contract.ts
8
8
  var CHECK_SCHEMA_VERSION = 1;
@@ -13,7 +13,7 @@ function emitCheckError(error) {
13
13
 
14
14
  // src/lib/diff-evidence.ts
15
15
  import { execFileSync as execFileSync7 } from "node:child_process";
16
- import { join as join9, relative, resolve as resolve2 } from "node:path";
16
+ import { join as join9, relative as relative2, resolve as resolve2 } from "node:path";
17
17
  // ../../packages/aeg-core/src/gate-audience.ts
18
18
  var GATE_AUDIENCE = {
19
19
  "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
@@ -639,6 +639,33 @@ function tasksFromIssues(issues) {
639
639
  }
640
640
  return tasks.sort((a, b) => compareTaskIds(a.id, b.id));
641
641
  }
642
+ function resolveDuplicateTasks(tasks, isOpen) {
643
+ const byId = new Map;
644
+ for (const t of tasks)
645
+ byId.set(t.id, [...byId.get(t.id) ?? [], t]);
646
+ const resolved = [];
647
+ const conflicts = [];
648
+ for (const [id, group] of byId) {
649
+ const first = group[0];
650
+ if (!first)
651
+ continue;
652
+ if (group.length === 1) {
653
+ resolved.push(first);
654
+ continue;
655
+ }
656
+ const number = (t) => t.issue ?? 0;
657
+ const open = group.filter((t) => t.issue !== null && isOpen(t.issue)).sort((a, b) => number(a) - number(b));
658
+ if (open.length > 1) {
659
+ conflicts.push({ id, issues: open.map(number) });
660
+ resolved.push(open[0]);
661
+ } else if (open.length === 1) {
662
+ resolved.push(open[0]);
663
+ } else {
664
+ resolved.push([...group].sort((a, b) => number(b) - number(a))[0]);
665
+ }
666
+ }
667
+ return { tasks: resolved.sort((a, b) => compareTaskIds(a.id, b.id)), conflicts };
668
+ }
642
669
  async function fetchTrancheIssuesAsync(owner, repo, slug) {
643
670
  return ghIssueListByAnyLabelAsync(owner, repo, [trancheLabel(slug)]);
644
671
  }
@@ -1446,7 +1473,7 @@ function mapReviewDecision(decision) {
1446
1473
  function buildBranchName(tranche, taskId) {
1447
1474
  return `task/${tranche}/${taskId}`;
1448
1475
  }
1449
- async function fetchForgeFacts(input) {
1476
+ async function fetchForgeFactsByIssue(input) {
1450
1477
  const token = await resolveGithubToken(input.token);
1451
1478
  if (!token) {
1452
1479
  return {
@@ -1456,7 +1483,13 @@ async function fetchForgeFacts(input) {
1456
1483
  reason: "No GitHub token available (set GITHUB_TOKEN/GH_TOKEN or `gh auth login`)."
1457
1484
  };
1458
1485
  }
1459
- const queriedTasks = input.tasks.filter((t) => t.issue !== null);
1486
+ const seen = new Set;
1487
+ const queriedTasks = input.tasks.filter((t) => {
1488
+ if (t.issue === null || seen.has(t.issue))
1489
+ return false;
1490
+ seen.add(t.issue);
1491
+ return true;
1492
+ });
1460
1493
  if (queriedTasks.length === 0) {
1461
1494
  return { facts: new Map, prRefs: new Map, unavailable: false };
1462
1495
  }
@@ -1484,21 +1517,52 @@ async function fetchForgeFacts(input) {
1484
1517
  };
1485
1518
  }
1486
1519
  for (const task of queriedTasks) {
1487
- const alias = aliasFor(task.id);
1488
- const raw = extractRawFromResponse(response.repository, alias);
1520
+ const raw = extractRawFromResponse(response.repository, aliasFor(task.issue));
1489
1521
  const mapped = mapForgeFacts(raw);
1490
1522
  if (mapped)
1491
- facts.set(task.id, mapped);
1523
+ facts.set(task.issue, mapped);
1492
1524
  const pr = raw.pullRequest;
1493
1525
  if (pr && typeof pr.number === "number" && typeof pr.url === "string") {
1494
- prRefs.set(task.id, { number: pr.number, url: pr.url, state: pr.state });
1526
+ prRefs.set(task.issue, { number: pr.number, url: pr.url, state: pr.state });
1495
1527
  }
1496
1528
  }
1497
1529
  return { facts, prRefs, unavailable: false };
1498
1530
  }
1531
+ async function fetchForgeFacts(input) {
1532
+ const byIssue = await fetchForgeFactsByIssue(input);
1533
+ if (byIssue.unavailable) {
1534
+ return { facts: new Map, prRefs: new Map, unavailable: true, reason: byIssue.reason };
1535
+ }
1536
+ const facts = new Map;
1537
+ const prRefs = new Map;
1538
+ const winner = new Map;
1539
+ for (const task of input.tasks) {
1540
+ if (task.issue === null)
1541
+ continue;
1542
+ const current = winner.get(task.id);
1543
+ if (current === undefined || outranks(byIssue.facts, task.issue, current))
1544
+ winner.set(task.id, task.issue);
1545
+ }
1546
+ for (const [taskId, issue] of winner) {
1547
+ const f = byIssue.facts.get(issue);
1548
+ if (f)
1549
+ facts.set(taskId, f);
1550
+ const pr = byIssue.prRefs.get(issue);
1551
+ if (pr)
1552
+ prRefs.set(taskId, pr);
1553
+ }
1554
+ return { facts, prRefs, unavailable: false };
1555
+ }
1556
+ function outranks(facts, candidate, current) {
1557
+ const candidateOpen = facts.get(candidate)?.issueState === "open";
1558
+ const currentOpen = facts.get(current)?.issueState === "open";
1559
+ if (candidateOpen !== currentOpen)
1560
+ return candidateOpen;
1561
+ return candidate > current;
1562
+ }
1499
1563
  function buildBatchQuery(tranche, tasks) {
1500
1564
  const perTask = tasks.map((task) => {
1501
- const a = aliasFor(task.id);
1565
+ const a = aliasFor(task.issue);
1502
1566
  const branch = buildBranchName(tranche, task.id);
1503
1567
  return `
1504
1568
  ${a}_issue: issue(number: ${task.issue}) {
@@ -1540,9 +1604,8 @@ function buildBatchQuery(tranche, tasks) {
1540
1604
  }
1541
1605
  }`;
1542
1606
  }
1543
- function aliasFor(taskId) {
1544
- const sanitized = taskId.replace(/[^a-zA-Z0-9_]/g, "_");
1545
- return `t_${sanitized}`;
1607
+ function aliasFor(issue) {
1608
+ return `i_${issue}`;
1546
1609
  }
1547
1610
  function extractRawFromResponse(repository, alias) {
1548
1611
  const issue = repository[`${alias}_issue`];
@@ -1897,45 +1960,6 @@ var DERIVED_STATUSES = [
1897
1960
  "incoherent"
1898
1961
  ];
1899
1962
  var DERIVABLE_STATUSES = DERIVED_STATUSES.filter((s) => s !== "backlog");
1900
- // ../../packages/aeg-core/src/parse-ledger.ts
1901
- function rowFromCells(cells) {
1902
- if (cells.length < 7)
1903
- return null;
1904
- const phase = (cells[0] ?? "").trim();
1905
- if (!phase)
1906
- return null;
1907
- return {
1908
- phase,
1909
- role: (cells[1] ?? "").trim(),
1910
- agentModel: (cells[2] ?? "").trim(),
1911
- tokensIn: parseIntCell(cells[3] ?? ""),
1912
- tokensOut: parseIntCell(cells[4] ?? ""),
1913
- cost: parseCostCell(cells[5] ?? ""),
1914
- date: (cells[6] ?? "").trim()
1915
- };
1916
- }
1917
- function parseIntCell(cell) {
1918
- const trimmed = cell.replace(/`/g, "").trim();
1919
- if (!trimmed || isEmDashOrDash(trimmed))
1920
- return null;
1921
- const normalized = trimmed.replace(/[,_\s]/g, "");
1922
- if (!/^-?\d+$/.test(normalized))
1923
- return null;
1924
- return Number(normalized);
1925
- }
1926
- function parseCostCell(cell) {
1927
- const trimmed = cell.replace(/`/g, "").trim();
1928
- if (!trimmed || isEmDashOrDash(trimmed))
1929
- return null;
1930
- const normalized = trimmed.replace(/^\$/, "").replace(/[,_\s]/g, "");
1931
- if (!/^-?\d+(\.\d+)?$/.test(normalized))
1932
- return null;
1933
- return Number(normalized);
1934
- }
1935
- function isEmDashOrDash(s) {
1936
- const t = s.trim();
1937
- return t === "—" || t === "-" || t === "–";
1938
- }
1939
1963
  // ../../packages/aeg-core/src/waiver-label.ts
1940
1964
  var WAIVER_LABEL = label("waiver-docs");
1941
1965
  var WAIVER_LABEL_REVIEW = label("waiver-review");
@@ -1951,61 +1975,6 @@ function isWaiverLabelActorVerified(opts) {
1951
1975
  return false;
1952
1976
  return isPrincipal(opts.labelActor, opts.principalAllowlist);
1953
1977
  }
1954
-
1955
- // ../../packages/aeg-core/src/parse-token-report.ts
1956
- var TOKEN_REPORT_HEADING = /^\s*(?:#{1,6}\s*Token report\s*|\*\*Token report\*\*)\s*$/i;
1957
- var INLINE_FIELD_LIST = /Phase:\s*([^|]+?)\s*\|\s*Role:\s*([^|]+?)\s*\|\s*Agent\/Model:\s*([^|]+?)\s*\|\s*Tokens in:\s*([^|]+?)\s*\|\s*Tokens out:\s*([^|]+?)\s*\|\s*Cost:\s*([^|]+?)\s*\|\s*Date:\s*(.+?)\s*$/im;
1958
- function parseTokenReportEntries(body) {
1959
- const lines = body.split(/\r?\n/);
1960
- const headingIdxs = [];
1961
- lines.forEach((line, i) => {
1962
- if (TOKEN_REPORT_HEADING.test(line))
1963
- headingIdxs.push(i);
1964
- });
1965
- const out = [];
1966
- for (let h = 0;h < headingIdxs.length; h++) {
1967
- const start = headingIdxs[h] + 1;
1968
- const end = h + 1 < headingIdxs.length ? headingIdxs[h + 1] : lines.length;
1969
- const section = lines.slice(start, end).join(`
1970
- `);
1971
- const tableRows = parseTableSection(section);
1972
- if (tableRows.length > 0) {
1973
- out.push(...tableRows);
1974
- continue;
1975
- }
1976
- const inlineRow = parseInlineFieldList(section);
1977
- if (inlineRow)
1978
- out.push(inlineRow);
1979
- }
1980
- return out;
1981
- }
1982
- function parseTableSection(section) {
1983
- const lines = section.split(/\r?\n/);
1984
- let i = 0;
1985
- for (;i < lines.length; i++) {
1986
- if ((lines[i] ?? "").trim().startsWith("|"))
1987
- break;
1988
- }
1989
- if (i + 1 >= lines.length)
1990
- return [];
1991
- i += 2;
1992
- const out = [];
1993
- for (;i < lines.length; i++) {
1994
- const trimmed = (lines[i] ?? "").trim();
1995
- if (!trimmed.startsWith("|"))
1996
- break;
1997
- const row = rowFromCells(splitTableRow(trimmed));
1998
- if (row)
1999
- out.push(row);
2000
- }
2001
- return out;
2002
- }
2003
- function parseInlineFieldList(section) {
2004
- const m = section.match(INLINE_FIELD_LIST);
2005
- if (!m)
2006
- return null;
2007
- return rowFromCells([m[1], m[2], m[3], m[4], m[5], m[6], m[7]]);
2008
- }
2009
1978
  // ../../packages/aeg-core/src/verdict-extraction.ts
2010
1979
  var HEAD_SHA_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Judged head:\s*([0-9a-f]{7,40})(?![A-Za-z0-9])/im;
2011
1980
  var OBJECTIVES_VERSION_PATTERN = /^[ \t]*(?:\*{1,3}|_{1,3})?Objectives version:\s*([0-9a-f]{64})(?![A-Za-z0-9])/im;
@@ -2454,10 +2423,12 @@ function evaluateC5(changed, docOwnersContent, prBody, fileExists, waiverActive,
2454
2423
  var CODE_REVIEW_SEVERITY_ORDER = ["BLOCKER", "MAJOR", "MINOR"];
2455
2424
  var SECURITY_SEVERITY_ORDER = ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
2456
2425
  var DEFAULT_MAX_ROUNDS = 3;
2426
+ var DEFAULT_MAX_TASK_MINUTES = 180;
2457
2427
  var DEFAULT_REVIEW_POLICY = {
2458
2428
  codeReviewThreshold: "BLOCKER",
2459
2429
  securityThreshold: "HIGH",
2460
- maxRounds: DEFAULT_MAX_ROUNDS
2430
+ maxRounds: DEFAULT_MAX_ROUNDS,
2431
+ maxTaskMinutes: DEFAULT_MAX_TASK_MINUTES
2461
2432
  };
2462
2433
  var FILE_SHAPED_LOCATION = /\.[a-zA-Z0-9]{1,10}(:\d+)?\s*$/;
2463
2434
  var PROSE_LOCATION_PATTERNS = [/\bpr\s*body\b/i, /\bcomment\b/i];
@@ -2465,6 +2436,9 @@ var ROLE_FILE_LOCATION = /(^|\/)aeg-root\/roles\//i;
2465
2436
  function isProseLocation(location) {
2466
2437
  if (ROLE_FILE_LOCATION.test(location))
2467
2438
  return true;
2439
+ return isBodyOrCommentLocation(location);
2440
+ }
2441
+ function isBodyOrCommentLocation(location) {
2468
2442
  if (FILE_SHAPED_LOCATION.test(location))
2469
2443
  return false;
2470
2444
  return PROSE_LOCATION_PATTERNS.some((pattern) => pattern.test(location));
@@ -2491,7 +2465,7 @@ function classifyFinding(finding, scale, threshold, context = {}) {
2491
2465
  const wouldBlock = blockingSeverities(scale, threshold).includes(effectiveSeverity);
2492
2466
  if (!wouldBlock)
2493
2467
  return { outcome: "non_blocking", deferralReason: null };
2494
- const hasLocation = location !== undefined && location.length > 0;
2468
+ const hasLocation = location !== undefined && location.length > 0 && !isBodyOrCommentLocation(location);
2495
2469
  if (hasLocation && context.inSurface && !context.inSurface(location)) {
2496
2470
  return { outcome: "deferred", deferralReason: "outside-surface" };
2497
2471
  }
@@ -2858,11 +2832,13 @@ function checkDocUpdateList(prBody) {
2858
2832
  return headingCheck(prBody, "(?:documentation|doc)[- ]update(?:\\s+list)?", "Documentation-update list");
2859
2833
  }
2860
2834
  function checkWorktreeStep0(prBody) {
2861
- if (/git worktree add/.test(prBody))
2835
+ if (/git worktree add/.test(prBody) || /cd \.worktrees\//.test(prBody) || /bun install --frozen-lockfile/.test(prBody))
2862
2836
  return { status: "pass", errors: [] };
2863
2837
  return {
2864
2838
  status: "fail",
2865
- errors: ["brief-validation worktree Step 0: no `git worktree add` command found in the PR body."]
2839
+ errors: [
2840
+ "brief-validation worktree Step 0: no `git worktree add`, `cd .worktrees/`, or `bun install --frozen-lockfile` command found in the PR body."
2841
+ ]
2866
2842
  };
2867
2843
  }
2868
2844
  function checkStopConditions(prBody) {
@@ -3052,7 +3028,8 @@ function isCommandBlock(content) {
3052
3028
  return COMMAND_WORDS.includes(commandWordOf(firstNonBlankLine(content)));
3053
3029
  }
3054
3030
  function isStep0Block(content) {
3055
- return firstNonBlankLine(content).startsWith("git worktree add");
3031
+ const first = firstNonBlankLine(content);
3032
+ return first.startsWith("git worktree add") || first.startsWith("cd .worktrees/") || first.startsWith("bun install --frozen-lockfile");
3056
3033
  }
3057
3034
  function checkCommandsCarryOutput(prBody) {
3058
3035
  const errors = [];
@@ -3521,10 +3498,14 @@ function legacySlugPattern(legacySlugs) {
3521
3498
  const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
3522
3499
  return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
3523
3500
  }
3501
+ function specGrandfatherPaths(specGrandfather) {
3502
+ return Array.isArray(specGrandfather) ? [...specGrandfather] : Object.keys(specGrandfather);
3503
+ }
3524
3504
  function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
3525
3505
  const findings = [];
3526
3506
  const legacyPattern = legacySlugPattern(legacySlugs);
3527
- const grandfathered = new Set(specGrandfather);
3507
+ const grandfatheredWhole = new Set(Array.isArray(specGrandfather) ? specGrandfather : []);
3508
+ const limits = new Map(Array.isArray(specGrandfather) ? [] : Object.entries(specGrandfather));
3528
3509
  const patterns = [
3529
3510
  { pattern: FORGE_NUMBER_PATTERN, what: "a forge number" },
3530
3511
  { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug" },
@@ -3543,18 +3524,19 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
3543
3524
  continue;
3544
3525
  if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
3545
3526
  continue;
3546
- if (cls === "spec" && grandfathered.has(file.path))
3527
+ if (cls === "spec" && grandfatheredWhole.has(file.path))
3547
3528
  continue;
3548
3529
  const blocking = cls === "product" || cls === "spec";
3549
3530
  const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
3550
3531
  const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
3532
+ const fileFindings = [];
3551
3533
  for (const { pattern, what, group } of patternsToRun) {
3552
3534
  pattern.lastIndex = 0;
3553
3535
  let match = pattern.exec(scrubbed);
3554
3536
  while (match !== null) {
3555
3537
  const cited = group !== undefined ? match[group] ?? match[0] : match[0];
3556
3538
  const citedIndex = match.index + match[0].indexOf(cited);
3557
- findings.push({
3539
+ fileFindings.push({
3558
3540
  file: file.path,
3559
3541
  line: lineAt(scrubbed, citedIndex),
3560
3542
  message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
@@ -3563,6 +3545,15 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
3563
3545
  match = pattern.exec(scrubbed);
3564
3546
  }
3565
3547
  }
3548
+ const limit = cls === "spec" ? limits.get(file.path) : undefined;
3549
+ if (limit !== undefined) {
3550
+ if (fileFindings.length <= limit)
3551
+ continue;
3552
+ for (const f of fileFindings) {
3553
+ f.message += `; ${file.path} carries ${fileFindings.length} such findings, over its proseGates.specGrandfather limit of ${limit}`;
3554
+ }
3555
+ }
3556
+ findings.push(...fileFindings);
3566
3557
  }
3567
3558
  return findings;
3568
3559
  }
@@ -4144,6 +4135,8 @@ var FILE_EXTENSIONS = new Set([
4144
4135
  "html",
4145
4136
  "css"
4146
4137
  ]);
4138
+ var CI_SHARD_DIR = "apps/cli/tests/ci-shards";
4139
+ var CI_SHARD_PROBE = `${CI_SHARD_DIR}/shard-1.txt`;
4147
4140
 
4148
4141
  // ../../packages/aeg-core/src/task-branch-identity.ts
4149
4142
  var ISSUE_BRANCH_PATTERN = /^task\/issue-(\d+)$/;
@@ -4522,8 +4515,7 @@ function briefHash(brief) {
4522
4515
  function policyDigest(policy) {
4523
4516
  return createHash4("sha256").update(JSON.stringify({
4524
4517
  codeReviewThreshold: policy.codeReviewThreshold,
4525
- securityThreshold: policy.securityThreshold,
4526
- maxRounds: policy.maxRounds
4518
+ securityThreshold: policy.securityThreshold
4527
4519
  })).digest("hex");
4528
4520
  }
4529
4521
  function isBoundToHead(echoed, headSha) {
@@ -4836,7 +4828,46 @@ function parseEnforcementRegistry(content) {
4836
4828
  return result;
4837
4829
  }
4838
4830
  // ../../packages/aeg-core/src/registry-checks.ts
4839
- function checkG1(rows, existsFn) {
4831
+ var HOOK_DIR_PREFIXES = [".claude/hooks/", ".vinaya/hooks/", ".husky/", ".git/hooks/"];
4832
+ var BARE_HOOK_NAME = /^check-[A-Za-z0-9_.-]*\.sh$/;
4833
+ function basename(path) {
4834
+ return path.slice(path.lastIndexOf("/") + 1);
4835
+ }
4836
+ function lineOf(content, index) {
4837
+ let line = 1;
4838
+ for (let i = 0;i < index; i++)
4839
+ if (content.charCodeAt(i) === 10)
4840
+ line++;
4841
+ return line;
4842
+ }
4843
+ function findUnshippedHookRefs(docs, shipped) {
4844
+ const shippedNames = new Set([...shipped].map(basename));
4845
+ const findings = [];
4846
+ const flag = (doc, token, index) => {
4847
+ findings.push({
4848
+ path: doc.path,
4849
+ reason: `${doc.path}:${lineOf(doc.content, index)} names hook "${token}", which is neither tracked in git nor emitted by \`vinaya init\``
4850
+ });
4851
+ };
4852
+ for (const doc of docs) {
4853
+ for (const { cited, index } of extractCitedPaths(doc.content)) {
4854
+ if (cited.endsWith("/") || !HOOK_DIR_PREFIXES.some((p) => cited.startsWith(p)))
4855
+ continue;
4856
+ if (!shipped.has(cited))
4857
+ flag(doc, cited, index);
4858
+ }
4859
+ const spanPattern = /`([^`\n]+)`/g;
4860
+ let match = spanPattern.exec(doc.content);
4861
+ while (match !== null) {
4862
+ const token = match[1] ?? "";
4863
+ if (BARE_HOOK_NAME.test(token) && !shippedNames.has(token))
4864
+ flag(doc, token, match.index);
4865
+ match = spanPattern.exec(doc.content);
4866
+ }
4867
+ }
4868
+ return findings;
4869
+ }
4870
+ function checkG1(rows, existsFn, hookRefs) {
4840
4871
  const findings = [];
4841
4872
  for (const row of rows) {
4842
4873
  if (row.implementation === "")
@@ -4849,6 +4880,8 @@ function checkG1(rows, existsFn) {
4849
4880
  });
4850
4881
  }
4851
4882
  }
4883
+ if (hookRefs)
4884
+ findings.push(...findUnshippedHookRefs(hookRefs.docs, hookRefs.shipped));
4852
4885
  return { check: "G1", status: findings.length > 0 ? "fail" : "pass", findings };
4853
4886
  }
4854
4887
  var SCAFFOLD_PLACEHOLDER = "[undocumented — fill in why]";
@@ -4981,6 +5014,55 @@ function checkG6(rows, registeredCheckNames) {
4981
5014
  }
4982
5015
  return { check: "G6", status: findings.length > 0 ? "fail" : "pass", findings };
4983
5016
  }
5017
+ function reachesProducer(file, producers, imports) {
5018
+ const seen = new Set([file]);
5019
+ const queue = [file];
5020
+ for (let next = queue.pop();next !== undefined; next = queue.pop()) {
5021
+ if (producers.has(next))
5022
+ return true;
5023
+ for (const dep of imports.get(next) ?? []) {
5024
+ if (!seen.has(dep)) {
5025
+ seen.add(dep);
5026
+ queue.push(dep);
5027
+ }
5028
+ }
5029
+ }
5030
+ return false;
5031
+ }
5032
+ function checkG7(input) {
5033
+ if (!input.enforcementMapPresent)
5034
+ return { check: "G7", status: "info", findings: [] };
5035
+ const subjects = new Set([...input.crossingFiles, ...input.blockingFiles]);
5036
+ const findings = [];
5037
+ for (const path of subjects) {
5038
+ if (path in input.exemptions)
5039
+ continue;
5040
+ if (!reachesProducer(path, input.producers, input.imports)) {
5041
+ findings.push({
5042
+ path,
5043
+ reason: `"${path}" ${input.crossingFiles.includes(path) ? "makes a GitHub-writing call" : "implements a blocking gate"} but neither is a log producer nor imports one, and it is not exempted with a reason`
5044
+ });
5045
+ }
5046
+ }
5047
+ for (const [path, reason] of Object.entries(input.exemptions)) {
5048
+ if (reason.trim() === "") {
5049
+ findings.push({ path, reason: `exemption for "${path}" states no reason` });
5050
+ } else if (!input.existsFn(path)) {
5051
+ findings.push({ path, reason: `exemption names "${path}", which no longer exists` });
5052
+ } else if (!subjects.has(path)) {
5053
+ findings.push({
5054
+ path,
5055
+ reason: `exemption names "${path}", which is neither a GitHub-writing file nor a blocking gate's implementation`
5056
+ });
5057
+ } else if (reachesProducer(path, input.producers, input.imports)) {
5058
+ findings.push({
5059
+ path,
5060
+ reason: `exemption names "${path}", which does reach a log producer — remove the exemption`
5061
+ });
5062
+ }
5063
+ }
5064
+ return { check: "G7", status: findings.length > 0 ? "fail" : "pass", findings };
5065
+ }
4984
5066
  // ../../packages/aeg-core/src/dead-branch-push-guard.ts
4985
5067
  function checkDeadBranchPush(input) {
4986
5068
  const { branch, prState, prNumber } = input;
@@ -5160,6 +5242,11 @@ function checkDispatchReadiness(input) {
5160
5242
  push("depends-on-unresolvable", `dispatch-gate depends-on: ${taskLabel} depends on "${dep.id}", which is UNRESOLVABLE — the resolver could not find a matching tranche/task/Issue for this edge (not a claim about merge status). Not dispatchable until the edge is corrected.`);
5161
5243
  continue;
5162
5244
  }
5245
+ if (dep.readFailed === true) {
5246
+ const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
5247
+ push("depends-on-read-failed", `dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, but the forge could not be read for that dependency — not a claim about its merge status. Retry the check.`);
5248
+ continue;
5249
+ }
5163
5250
  if (!dep.merged && !isHandClosedByRecognizedPrincipal(dep, principalAllowlist)) {
5164
5251
  const issueStr = dep.issue !== null ? ` (#${dep.issue})` : "";
5165
5252
  push("depends-on-not-merged", `dispatch-gate depends-on: ${taskLabel} depends on ${dep.id}${issueStr}, whose PR is not merged yet — not dispatchable, it serializes behind it.`);
@@ -5402,7 +5489,6 @@ var TaskPrPauseSchema = z.object({
5402
5489
  var TaskPrReviewRecordSchema = z.object({
5403
5490
  verdicts: z.array(TaskPrVerdictSchema),
5404
5491
  roundMarkers: z.array(z.number().int().nonnegative()),
5405
- summaryTable: z.string().nullable(),
5406
5492
  pause: TaskPrPauseSchema.nullable()
5407
5493
  });
5408
5494
  var TaskPrReadInputSchema = z.object({
@@ -5449,16 +5535,6 @@ var TaskCancelResultSchema = z.object({
5449
5535
  authenticatedFrom: z.string().min(1),
5450
5536
  fencedEffectKeys: z.array(z.string())
5451
5537
  });
5452
- var TASK_TOOL_NAMES = [
5453
- "task_start",
5454
- "task_status",
5455
- "task_escalation_read",
5456
- "task_pr_read",
5457
- "task_resume",
5458
- "task_cancel"
5459
- ];
5460
- var OPERATOR_STATUS_FOLLOW = "task_status_follow";
5461
- var OPERATOR_TOOL_GRANT = [...TASK_TOOL_NAMES, OPERATOR_STATUS_FOLLOW];
5462
5538
  // ../../packages/aeg-core/src/first-push-dispatch-gate.ts
5463
5539
  function parseTaskBranch(branch) {
5464
5540
  const m = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
@@ -5689,16 +5765,71 @@ var NO_GATE_CUTOVERS = {
5689
5765
  briefRulesSincePr: null,
5690
5766
  agentBoxesRefusedSincePr: null
5691
5767
  };
5692
- // ../../packages/aeg-core/src/dev-review-loop/types.ts
5693
- var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5694
- // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
5695
- var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
5696
- // ../../packages/aeg-core/src/log/envelope.ts
5697
- import { createHash as createHash5 } from "node:crypto";
5698
-
5699
5768
  // ../../packages/aeg-core/src/log/schema.ts
5769
+ import { z as z3 } from "zod";
5770
+
5771
+ // ../../packages/aeg-core/src/log/custom.ts
5700
5772
  import { z as z2 } from "zod";
5773
+ var CUSTOM_EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]*\.[a-z][a-z0-9_.]*$/;
5774
+ var CUSTOM_EVENT_NAME_MAX_LENGTH = 64;
5775
+ var CUSTOM_EVENT_RESERVED_NAMESPACE = "vinaya";
5776
+ var CUSTOM_EVENT_MAX_FIELDS = 20;
5777
+ var CUSTOM_FIELD_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
5778
+ var CUSTOM_FIELD_NAME_MAX_LENGTH = 64;
5779
+ var CUSTOM_TEXT_MAX_LENGTH = 500;
5780
+ var CUSTOM_WORD_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
5781
+ var CUSTOM_WORD_MAX_LENGTH = 64;
5782
+ var CUSTOM_FIELD_MAX_WORDS = 50;
5783
+ var CustomFieldTypeSchema = z2.union([z2.enum(["text", "number", "boolean"]), z2.array(z2.string())]);
5784
+ var CustomEventDeclarationsSchema = z2.record(z2.string(), z2.object({
5785
+ fields: z2.record(z2.string(), CustomFieldTypeSchema)
5786
+ }).strict()).superRefine((events, ctx) => {
5787
+ for (const [name, declaration] of Object.entries(events)) {
5788
+ const refuse = (message, path = []) => {
5789
+ ctx.addIssue({
5790
+ code: z2.ZodIssueCode.custom,
5791
+ path: [name, ...path],
5792
+ message: `logs.events "${name}": ${message}`
5793
+ });
5794
+ };
5795
+ if (name.length > CUSTOM_EVENT_NAME_MAX_LENGTH) {
5796
+ refuse(`the name must be at most ${CUSTOM_EVENT_NAME_MAX_LENGTH} characters`);
5797
+ }
5798
+ if (!CUSTOM_EVENT_NAME_PATTERN.test(name)) {
5799
+ refuse("the name must be `<namespace>.<event>` — lowercase letters, digits and `_`, a dot between them");
5800
+ } else if (name.split(".")[0] === CUSTOM_EVENT_RESERVED_NAMESPACE) {
5801
+ refuse(`the \`${CUSTOM_EVENT_RESERVED_NAMESPACE}.\` namespace is reserved for Vinaya's own events`);
5802
+ }
5803
+ const fieldEntries = Object.entries(declaration.fields);
5804
+ if (fieldEntries.length > CUSTOM_EVENT_MAX_FIELDS) {
5805
+ refuse(`at most ${CUSTOM_EVENT_MAX_FIELDS} fields may be declared (found ${fieldEntries.length})`, ["fields"]);
5806
+ }
5807
+ for (const [field, type] of fieldEntries) {
5808
+ if (field.length > CUSTOM_FIELD_NAME_MAX_LENGTH || !CUSTOM_FIELD_NAME_PATTERN.test(field)) {
5809
+ 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]);
5810
+ }
5811
+ if (typeof type === "string")
5812
+ continue;
5813
+ if (type.length === 0) {
5814
+ refuse(`field "${field}": a list of words must name at least one word`, ["fields", field]);
5815
+ }
5816
+ if (type.length > CUSTOM_FIELD_MAX_WORDS) {
5817
+ refuse(`field "${field}": a list of words may name at most ${CUSTOM_FIELD_MAX_WORDS}`, ["fields", field]);
5818
+ }
5819
+ const bad = type.filter((w) => w.length > CUSTOM_WORD_MAX_LENGTH || !CUSTOM_WORD_PATTERN.test(w));
5820
+ if (bad.length > 0) {
5821
+ refuse(`field "${field}": a listed word is lowercase letters, digits, \`_\` and \`-\`, at most ${CUSTOM_WORD_MAX_LENGTH} characters`, ["fields", field]);
5822
+ }
5823
+ if (new Set(type).size !== type.length) {
5824
+ refuse(`field "${field}": a list of words names a word twice`, ["fields", field]);
5825
+ }
5826
+ }
5827
+ }
5828
+ });
5829
+
5830
+ // ../../packages/aeg-core/src/log/schema.ts
5701
5831
  var CONFIDENCE_REASON_MAX_LENGTH = 280;
5832
+ var REVIEW_FINDING_DESCRIPTION_MAX_LENGTH = 1000;
5702
5833
  var ROLE_VALUES = [
5703
5834
  "planner",
5704
5835
  "developer",
@@ -5708,178 +5839,214 @@ var ROLE_VALUES = [
5708
5839
  "archivist",
5709
5840
  "architect"
5710
5841
  ];
5711
- var RoleSchema = z2.enum(ROLE_VALUES);
5842
+ var RoleSchema = z3.enum(ROLE_VALUES);
5712
5843
  var HOST_VALUES = ["hook", "ci", "cli", "loop"];
5713
- var HostSchema = z2.enum(HOST_VALUES);
5844
+ var HostSchema = z3.enum(HOST_VALUES);
5714
5845
  var RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
5715
5846
  var headerMetaCore = {
5716
- ts: z2.string(),
5717
- run_id: z2.string().regex(RUN_ID_PATTERN),
5718
- seq: z2.number().int().nonnegative(),
5719
- repo: z2.string().nullable(),
5720
- vinaya: z2.string(),
5721
- doctrine: z2.string(),
5847
+ ts: z3.string(),
5848
+ run_id: z3.string().regex(RUN_ID_PATTERN),
5849
+ seq: z3.number().int().nonnegative(),
5850
+ repo: z3.string().nullable(),
5851
+ vinaya: z3.string(),
5852
+ doctrine: z3.string(),
5722
5853
  host: HostSchema,
5723
- machine: z2.string()
5854
+ machine: z3.string()
5724
5855
  };
5725
- var HeaderMetaV1Schema = z2.object({
5726
- schema: z2.literal(1),
5856
+ var HeaderMetaV1Schema = z3.object({
5857
+ schema: z3.literal(1),
5727
5858
  ...headerMetaCore
5728
5859
  }).strict();
5729
- var LineageSchema = z2.object({
5730
- run: z2.string().nullable(),
5731
- attempt: z2.number().int().nullable(),
5732
- parent: z2.string().nullable()
5860
+ var LineageSchema = z3.object({
5861
+ run: z3.string().nullable(),
5862
+ attempt: z3.number().int().nullable(),
5863
+ parent: z3.string().nullable()
5733
5864
  }).strict();
5734
- var InputVersionsSchema = z2.object({
5735
- objectives_version: z2.string().nullable(),
5736
- brief_hash: z2.string().nullable(),
5737
- ruling_ordinal: z2.number().int().nullable(),
5738
- policy_digest: z2.string().nullable()
5865
+ var InputVersionsSchema = z3.object({
5866
+ objectives_version: z3.string().nullable(),
5867
+ brief_hash: z3.string().nullable(),
5868
+ ruling_ordinal: z3.number().int().nullable(),
5869
+ policy_digest: z3.string().nullable()
5739
5870
  }).strict();
5740
- var ProvenanceSchema = z2.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
5741
- var HeaderMetaV2Schema = z2.object({
5742
- schema: z2.literal(2),
5871
+ var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
5872
+ var HeaderMetaV2Schema = z3.object({
5873
+ schema: z3.literal(2),
5743
5874
  ...headerMetaCore,
5744
- event_id: z2.string().min(1),
5745
- process_id: z2.string().min(1),
5746
- actor_id: z2.string().nullable(),
5875
+ event_id: z3.string().min(1),
5876
+ process_id: z3.string().min(1),
5877
+ actor_id: z3.string().nullable(),
5747
5878
  lineage: LineageSchema,
5748
5879
  input_versions: InputVersionsSchema,
5749
5880
  provenance: ProvenanceSchema
5750
5881
  }).strict();
5751
- var HeaderMetaSchema = z2.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema]);
5752
- var SubjectSchema = z2.object({
5753
- issue: z2.number().int().nullable(),
5754
- pr: z2.number().int().optional(),
5755
- sha: z2.string().optional(),
5756
- role: z2.union([RoleSchema, z2.literal("unattributed")]),
5757
- round: z2.number().int().optional(),
5758
- objectives_version: z2.string().optional()
5882
+ var WorkSchema = z3.object({
5883
+ ref: z3.string().nullable(),
5884
+ repo: z3.string().nullable(),
5885
+ change: z3.string().nullable(),
5886
+ revision: z3.string().nullable()
5887
+ }).strict();
5888
+ var FlowSchema = z3.object({
5889
+ id: z3.string().nullable(),
5890
+ version: z3.string().nullable()
5891
+ }).strict();
5892
+ var HeaderMetaV3Schema = z3.object({
5893
+ schema: z3.literal(3),
5894
+ ...headerMetaCore,
5895
+ event_id: z3.string().min(1),
5896
+ process_id: z3.string().min(1),
5897
+ actor_id: z3.string().nullable(),
5898
+ lineage: LineageSchema,
5899
+ input_versions: InputVersionsSchema,
5900
+ provenance: ProvenanceSchema,
5901
+ work: WorkSchema,
5902
+ flow: FlowSchema,
5903
+ runtime: z3.string().nullable(),
5904
+ source: z3.string().nullable()
5759
5905
  }).strict();
5760
- var HeaderSchema = z2.object({
5906
+ var HeaderMetaSchema = z3.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema, HeaderMetaV3Schema]);
5907
+ var SubjectSchema = z3.object({
5908
+ issue: z3.number().int().nullable(),
5909
+ pr: z3.number().int().optional(),
5910
+ sha: z3.string().optional(),
5911
+ role: z3.union([RoleSchema, z3.literal("unattributed")]),
5912
+ round: z3.number().int().optional(),
5913
+ objectives_version: z3.string().optional()
5914
+ }).strict();
5915
+ var HeaderSchema = z3.object({
5761
5916
  meta: HeaderMetaSchema,
5762
5917
  subject: SubjectSchema
5763
5918
  }).strict();
5764
5919
  var envelopeTail = {
5765
- duration_ms: z2.number().nonnegative().optional(),
5766
- payload: z2.object({}).strict()
5920
+ duration_ms: z3.number().nonnegative().optional(),
5921
+ payload: z3.object({}).strict()
5767
5922
  };
5768
- var ReviewFindingSchema = z2.object({
5769
- id: z2.string(),
5770
- severity: z2.string(),
5771
- state: z2.string().optional(),
5772
- severity_scale: z2.string().optional(),
5773
- policy_treatment: z2.enum(["blocking", "non_blocking", "unavailable"]).optional(),
5774
- confidence: z2.number().min(0).max(1).optional(),
5775
- confidence_scale: z2.string().optional(),
5776
- confidence_source: z2.string().optional()
5923
+ var ReviewFindingSchema = z3.object({
5924
+ id: z3.string(),
5925
+ severity: z3.string(),
5926
+ location: z3.string().optional(),
5927
+ deferral_reason: z3.enum(["outside-surface", "unchanged-line"]).optional(),
5928
+ description: z3.string().max(REVIEW_FINDING_DESCRIPTION_MAX_LENGTH).optional(),
5929
+ state: z3.string().optional(),
5930
+ severity_scale: z3.string().optional(),
5931
+ policy_treatment: z3.enum(["blocking", "non_blocking", "unavailable"]).optional(),
5932
+ confidence: z3.number().min(0).max(1).optional(),
5933
+ confidence_scale: z3.string().optional(),
5934
+ confidence_source: z3.string().optional()
5777
5935
  }).strict();
5778
- var DispatchOutcomeSchema = z2.discriminatedUnion("type", [
5779
- z2.object({ type: z2.literal("pr_opened"), pr: z2.number().int(), head: z2.string() }).strict(),
5780
- z2.object({
5781
- type: z2.literal("round_pushed"),
5782
- pr: z2.number().int(),
5783
- head: z2.string(),
5784
- comment_id: z2.number().int()
5936
+ var DispatchOutcomeSchema = z3.discriminatedUnion("type", [
5937
+ z3.object({ type: z3.literal("pr_opened"), pr: z3.number().int(), head: z3.string() }).strict(),
5938
+ z3.object({
5939
+ type: z3.literal("round_pushed"),
5940
+ pr: z3.number().int(),
5941
+ head: z3.string(),
5942
+ comment_id: z3.number().int()
5785
5943
  }).strict(),
5786
- z2.object({
5787
- type: z2.literal("verdict"),
5788
- verdict: z2.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
5789
- head: z2.string(),
5790
- comment_id: z2.number().int(),
5791
- objectives: z2.array(z2.object({ id: z2.string(), met: z2.boolean() }).strict()),
5792
- findings: z2.array(ReviewFindingSchema)
5944
+ z3.object({
5945
+ type: z3.literal("verdict"),
5946
+ verdict: z3.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
5947
+ head: z3.string(),
5948
+ comment_id: z3.number().int(),
5949
+ objectives: z3.array(z3.object({ id: z3.string(), met: z3.boolean() }).strict()),
5950
+ findings: z3.array(ReviewFindingSchema)
5793
5951
  }).strict(),
5794
- z2.object({
5795
- type: z2.literal("escalation"),
5796
- class: z2.enum(["authority", "strategy", "product"]),
5797
- comment_id: z2.number().int()
5952
+ z3.object({
5953
+ type: z3.literal("escalation"),
5954
+ class: z3.enum(["authority", "strategy", "product"]),
5955
+ comment_id: z3.number().int()
5798
5956
  }).strict(),
5799
- z2.object({ type: z2.literal("brief"), comment_id: z2.number().int(), hash: z2.string() }).strict(),
5800
- z2.object({ type: z2.literal("plan"), issues: z2.array(z2.number().int()) }).strict(),
5801
- z2.object({ type: z2.literal("archive"), provenance_comment_id: z2.number().int() }).strict(),
5802
- z2.object({ type: z2.literal("completed") }).strict()
5957
+ z3.object({ type: z3.literal("brief"), comment_id: z3.number().int(), hash: z3.string() }).strict(),
5958
+ z3.object({ type: z3.literal("plan"), issues: z3.array(z3.number().int()) }).strict(),
5959
+ z3.object({ type: z3.literal("archive"), provenance_comment_id: z3.number().int() }).strict(),
5960
+ z3.object({ type: z3.literal("completed") }).strict()
5803
5961
  ]);
5804
5962
  var dispatchShared = {
5805
5963
  meta: HeaderMetaSchema,
5806
5964
  subject: SubjectSchema,
5807
- kind: z2.literal("dispatch"),
5965
+ kind: z3.literal("dispatch"),
5808
5966
  ...envelopeTail,
5809
5967
  target_role: RoleSchema,
5810
- model: z2.string(),
5811
- round: z2.number().int().optional(),
5812
- effect_id: z2.string()
5968
+ model: z3.string(),
5969
+ round: z3.number().int().optional(),
5970
+ effect_id: z3.string()
5813
5971
  };
5814
- var dispatchUsageField = z2.object({ input: z2.number().nonnegative(), output: z2.number().nonnegative() }).strict().nullable();
5815
- var DispatchEventSchema = z2.discriminatedUnion("event", [
5816
- z2.object({ ...dispatchShared, event: z2.literal("dispatched"), prompt_hash: z2.string() }).strict(),
5817
- z2.object({
5972
+ var dispatchUsageField = z3.object({ input: z3.number().nonnegative(), output: z3.number().nonnegative() }).strict().nullable();
5973
+ var DispatchEventSchema = z3.discriminatedUnion("event", [
5974
+ z3.object({ ...dispatchShared, event: z3.literal("dispatched"), prompt_hash: z3.string() }).strict(),
5975
+ z3.object({
5818
5976
  ...dispatchShared,
5819
- event: z2.literal("outcome_received"),
5977
+ event: z3.literal("outcome_received"),
5820
5978
  outcome: DispatchOutcomeSchema,
5821
5979
  usage: dispatchUsageField
5822
5980
  }).strict(),
5823
- z2.object({
5981
+ z3.object({
5824
5982
  ...dispatchShared,
5825
- event: z2.literal("dispatch_failed"),
5826
- reason: z2.enum(["timeout", "crash", "refused", "unattributed_write"]),
5983
+ event: z3.literal("dispatch_failed"),
5984
+ reason: z3.enum(["timeout", "crash", "refused", "unattributed_write", "usage_limit"]),
5985
+ usage_limit: z3.object({ agent: z3.string().min(1), reset_at: z3.string().nullable() }).strict().optional(),
5827
5986
  usage: dispatchUsageField
5828
5987
  }).strict()
5829
5988
  ]);
5989
+ var CODE_TOKEN_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
5990
+ var CodeTokenSchema = z3.string().regex(CODE_TOKEN_PATTERN);
5991
+ var ReviewerVerdictSchema = z3.object({
5992
+ role: RoleSchema,
5993
+ outcome: z3.enum(["approve", "changes_requested", "not_reviewed"]),
5994
+ blockers: z3.number().int().nonnegative()
5995
+ }).strict();
5830
5996
  var loopShared = {
5831
5997
  meta: HeaderMetaSchema,
5832
5998
  subject: SubjectSchema,
5833
- kind: z2.literal("dev_review_loop"),
5999
+ kind: z3.literal("dev_review_loop"),
5834
6000
  ...envelopeTail,
5835
- loop_id: z2.string()
6001
+ loop_id: z3.string()
5836
6002
  };
5837
- var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
5838
- z2.object({
6003
+ var DevReviewLoopEventSchema = z3.discriminatedUnion("event", [
6004
+ z3.object({
5839
6005
  ...loopShared,
5840
- event: z2.literal("loop_started"),
5841
- task: z2.number().int(),
5842
- policy: z2.object({
5843
- max_rounds: z2.number().int().nonnegative(),
5844
- reviewers: z2.array(RoleSchema),
5845
- models: z2.record(RoleSchema, z2.string())
6006
+ event: z3.literal("loop_started"),
6007
+ task: z3.number().int(),
6008
+ policy: z3.object({
6009
+ max_rounds: z3.number().int().nonnegative(),
6010
+ reviewers: z3.array(RoleSchema),
6011
+ models: z3.record(RoleSchema, z3.string())
5846
6012
  }).strict()
5847
6013
  }).strict(),
5848
- z2.object({ ...loopShared, event: z2.literal("round_started"), round: z2.number().int(), base_head: z2.string() }).strict(),
5849
- z2.object({
6014
+ z3.object({ ...loopShared, event: z3.literal("round_started"), round: z3.number().int(), base_head: z3.string() }).strict(),
6015
+ z3.object({
5850
6016
  ...loopShared,
5851
- event: z2.literal("gate_result_read"),
5852
- round: z2.number().int(),
5853
- head: z2.string(),
5854
- green: z2.boolean(),
5855
- confidence_value: z2.number().int().min(0).max(100).optional(),
5856
- confidence_reason: z2.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
5857
- confidence_unavailable: z2.boolean().optional(),
5858
- extra_turn_spent: z2.boolean().optional()
6017
+ event: z3.literal("gate_result_read"),
6018
+ round: z3.number().int(),
6019
+ head: z3.string(),
6020
+ green: z3.boolean(),
6021
+ confidence_value: z3.number().int().min(0).max(100).optional(),
6022
+ confidence_reason: z3.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
6023
+ confidence_unavailable: z3.boolean().optional(),
6024
+ extra_turn_spent: z3.boolean().optional()
5859
6025
  }).strict(),
5860
- z2.object({
6026
+ z3.object({
5861
6027
  ...loopShared,
5862
- event: z2.literal("verdicts_read"),
5863
- round: z2.number().int(),
5864
- head: z2.string(),
5865
- all_approve: z2.boolean(),
5866
- blockers: z2.number().int().nonnegative(),
5867
- findings: z2.array(ReviewFindingSchema).optional()
6028
+ event: z3.literal("verdicts_read"),
6029
+ round: z3.number().int(),
6030
+ head: z3.string(),
6031
+ all_approve: z3.boolean(),
6032
+ blockers: z3.number().int().nonnegative(),
6033
+ findings: z3.array(ReviewFindingSchema).optional(),
6034
+ reviewers: z3.array(ReviewerVerdictSchema).optional()
5868
6035
  }).strict(),
5869
- z2.object({
6036
+ z3.object({
5870
6037
  ...loopShared,
5871
- event: z2.literal("findings_compared"),
5872
- round: z2.number().int(),
5873
- open: z2.array(z2.string()),
5874
- resolved: z2.array(z2.string()),
5875
- new: z2.array(z2.string()),
5876
- recurring: z2.array(z2.string())
6038
+ event: z3.literal("findings_compared"),
6039
+ round: z3.number().int(),
6040
+ open: z3.array(z3.string()),
6041
+ resolved: z3.array(z3.string()),
6042
+ new: z3.array(z3.string()),
6043
+ recurring: z3.array(z3.string())
5877
6044
  }).strict(),
5878
- z2.object({
6045
+ z3.object({
5879
6046
  ...loopShared,
5880
- event: z2.literal("stop_condition_met"),
5881
- round: z2.number().int(),
5882
- condition: z2.enum([
6047
+ event: z3.literal("stop_condition_met"),
6048
+ round: z3.number().int(),
6049
+ condition: z3.enum([
5883
6050
  "green",
5884
6051
  "max_rounds",
5885
6052
  "no_progress",
@@ -5888,66 +6055,85 @@ var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
5888
6055
  "confidence",
5889
6056
  "reappearance",
5890
6057
  "repeat_finding",
5891
- "repeat_failure"
6058
+ "repeat_failure",
6059
+ "time_budget"
5892
6060
  ])
5893
6061
  }).strict(),
5894
- z2.object({
6062
+ z3.object({
6063
+ ...loopShared,
6064
+ event: z3.literal("paused"),
6065
+ round: z3.number().int(),
6066
+ reason: z3.enum(["escalation", "principal_item", "refreeze_needed"]),
6067
+ reason_code: CodeTokenSchema.optional()
6068
+ }).strict(),
6069
+ z3.object({
6070
+ ...loopShared,
6071
+ event: z3.literal("resumed"),
6072
+ round: z3.number().int(),
6073
+ by: z3.enum(["principal", "driver"])
6074
+ }).strict(),
6075
+ z3.object({
5895
6076
  ...loopShared,
5896
- event: z2.literal("paused"),
5897
- round: z2.number().int(),
5898
- reason: z2.enum(["escalation", "principal_item", "refreeze_needed"])
6077
+ event: z3.literal("cancelled"),
6078
+ round: z3.number().int(),
6079
+ by: z3.literal("principal")
5899
6080
  }).strict(),
5900
- z2.object({
6081
+ z3.object({
5901
6082
  ...loopShared,
5902
- event: z2.literal("resumed"),
5903
- round: z2.number().int(),
5904
- by: z2.enum(["principal", "driver"])
6083
+ event: z3.literal("unpushed_work_resume"),
6084
+ round: z3.number().int(),
6085
+ branch: z3.string(),
6086
+ detail: z3.string()
5905
6087
  }).strict(),
5906
- z2.object({
6088
+ z3.object({
5907
6089
  ...loopShared,
5908
- event: z2.literal("cancelled"),
5909
- round: z2.number().int(),
5910
- by: z2.literal("principal")
6090
+ event: z3.literal("round_ended"),
6091
+ round: z3.number().int(),
6092
+ base_head: z3.string(),
6093
+ head: z3.string(),
6094
+ files_changed: z3.number().int().nonnegative(),
6095
+ insertions: z3.number().int().nonnegative(),
6096
+ deletions: z3.number().int().nonnegative(),
6097
+ wall_ms: z3.number().nonnegative(),
6098
+ outcome: z3.enum(["green", "changes_requested", "escalated"])
5911
6099
  }).strict(),
5912
- z2.object({
6100
+ z3.object({
5913
6101
  ...loopShared,
5914
- event: z2.literal("unpushed_work_resume"),
5915
- round: z2.number().int(),
5916
- branch: z2.string(),
5917
- detail: z2.string()
6102
+ event: z3.literal("journal_finalized"),
6103
+ rounds: z3.number().int().nonnegative(),
6104
+ total_wall_ms: z3.number().nonnegative(),
6105
+ time_to_green_ms: z3.number().nonnegative().nullable(),
6106
+ files_changed_total: z3.number().int().nonnegative(),
6107
+ final_head: z3.string(),
6108
+ result: z3.enum(["merged_ready", "stopped"])
5918
6109
  }).strict(),
5919
- z2.object({
6110
+ z3.object({
5920
6111
  ...loopShared,
5921
- event: z2.literal("round_ended"),
5922
- round: z2.number().int(),
5923
- base_head: z2.string(),
5924
- head: z2.string(),
5925
- files_changed: z2.number().int().nonnegative(),
5926
- insertions: z2.number().int().nonnegative(),
5927
- deletions: z2.number().int().nonnegative(),
5928
- wall_ms: z2.number().nonnegative(),
5929
- outcome: z2.enum(["green", "changes_requested", "escalated"])
6112
+ event: z3.literal("infrastructure_retry"),
6113
+ round: z3.number().int(),
6114
+ failure_kind: z3.enum(["pause_comment_post", "developer_connection"]),
6115
+ attempts: z3.number().int().positive(),
6116
+ outcome: z3.enum(["recovered", "exhausted"])
5930
6117
  }).strict(),
5931
- z2.object({
6118
+ z3.object({
5932
6119
  ...loopShared,
5933
- event: z2.literal("journal_finalized"),
5934
- rounds: z2.number().int().nonnegative(),
5935
- total_wall_ms: z2.number().nonnegative(),
5936
- time_to_green_ms: z2.number().nonnegative().nullable(),
5937
- files_changed_total: z2.number().int().nonnegative(),
5938
- final_head: z2.string(),
5939
- result: z2.enum(["merged_ready", "stopped"])
6120
+ event: z3.literal("driver_heartbeat"),
6121
+ task: z3.number().int(),
6122
+ pr: z3.number().int().positive().optional(),
6123
+ round: z3.number().int(),
6124
+ phase: z3.string()
5940
6125
  }).strict(),
5941
- z2.object({
6126
+ z3.object({
5942
6127
  ...loopShared,
5943
- event: z2.literal("infrastructure_retry"),
5944
- round: z2.number().int(),
5945
- failure_kind: z2.enum(["pause_comment_post", "developer_connection"]),
5946
- attempts: z2.number().int().positive(),
5947
- outcome: z2.enum(["recovered", "exhausted"])
6128
+ event: z3.literal("driver_exited"),
6129
+ task: z3.number().int(),
6130
+ reason: z3.enum(["finished", "paused", "reexec", "error", "signal"]),
6131
+ last_decision: z3.string(),
6132
+ exit_code: z3.number().int().optional(),
6133
+ error_class: CodeTokenSchema.optional()
5948
6134
  }).strict()
5949
6135
  ]);
5950
- var ForgeOpSchema = z2.enum([
6136
+ var ForgeOpSchema = z3.enum([
5951
6137
  "pr.create",
5952
6138
  "pr.comment",
5953
6139
  "pr.body.replace",
@@ -5961,24 +6147,24 @@ var ForgeOpSchema = z2.enum([
5961
6147
  "label.add",
5962
6148
  "label.remove"
5963
6149
  ]);
5964
- var ForgeWriteTargetSchema = z2.object({
5965
- issue: z2.number().int().optional(),
5966
- pr: z2.number().int().optional()
6150
+ var ForgeWriteTargetSchema = z3.object({
6151
+ issue: z3.number().int().optional(),
6152
+ pr: z3.number().int().optional()
5967
6153
  }).strict();
5968
6154
  var forgeWriteShared = {
5969
6155
  meta: HeaderMetaSchema,
5970
6156
  subject: SubjectSchema,
5971
- kind: z2.literal("forge_write"),
6157
+ kind: z3.literal("forge_write"),
5972
6158
  ...envelopeTail,
5973
6159
  op: ForgeOpSchema,
5974
6160
  target: ForgeWriteTargetSchema
5975
6161
  };
5976
- var ForgeWriteEventSchema = z2.discriminatedUnion("event", [
5977
- z2.object({ ...forgeWriteShared, event: z2.literal("validated") }).strict(),
5978
- z2.object({ ...forgeWriteShared, event: z2.literal("refused"), reason: z2.string() }).strict(),
5979
- z2.object({ ...forgeWriteShared, event: z2.literal("written"), comment_ids: z2.array(z2.string()) }).strict()
6162
+ var ForgeWriteEventSchema = z3.discriminatedUnion("event", [
6163
+ z3.object({ ...forgeWriteShared, event: z3.literal("validated") }).strict(),
6164
+ z3.object({ ...forgeWriteShared, event: z3.literal("refused"), reason: z3.string() }).strict(),
6165
+ z3.object({ ...forgeWriteShared, event: z3.literal("written"), comment_ids: z3.array(z3.string()) }).strict()
5980
6166
  ]);
5981
- var GateOutcomeSchema = z2.enum([
6167
+ var GateOutcomeSchema = z3.enum([
5982
6168
  "pass",
5983
6169
  "fail",
5984
6170
  "wait",
@@ -5991,61 +6177,74 @@ var GateOutcomeSchema = z2.enum([
5991
6177
  var gateShared = {
5992
6178
  meta: HeaderMetaSchema,
5993
6179
  subject: SubjectSchema,
5994
- kind: z2.literal("gate"),
6180
+ kind: z3.literal("gate"),
5995
6181
  ...envelopeTail,
5996
- check: z2.string(),
5997
- check_version: z2.string().nullable(),
5998
- policy_version: z2.string().nullable(),
5999
- input_fingerprint: z2.string().nullable()
6182
+ check: z3.string(),
6183
+ check_version: z3.string().nullable(),
6184
+ policy_version: z3.string().nullable(),
6185
+ input_fingerprint: z3.string().nullable()
6000
6186
  };
6001
- var GateEventSchema = z2.discriminatedUnion("event", [
6002
- z2.object({
6187
+ var GateEventSchema = z3.discriminatedUnion("event", [
6188
+ z3.object({
6003
6189
  ...gateShared,
6004
- event: z2.literal("checked"),
6190
+ event: z3.literal("checked"),
6005
6191
  outcome: GateOutcomeSchema,
6006
- reason: z2.string().optional()
6192
+ reason: z3.string().optional()
6193
+ }).strict(),
6194
+ z3.object({
6195
+ meta: HeaderMetaSchema,
6196
+ subject: SubjectSchema,
6197
+ kind: z3.literal("gate"),
6198
+ ...envelopeTail,
6199
+ event: z3.literal("summary"),
6200
+ ran: z3.number().int().nonnegative(),
6201
+ passed: z3.number().int().nonnegative(),
6202
+ failed: z3.number().int().nonnegative(),
6203
+ skipped: z3.number().int().nonnegative(),
6204
+ failed_checks: z3.array(z3.string())
6007
6205
  }).strict()
6008
6206
  ]);
6009
- var OperationResultSchema = z2.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
6207
+ var OperationResultSchema = z3.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
6010
6208
  var operationShared = {
6011
6209
  meta: HeaderMetaSchema,
6012
6210
  subject: SubjectSchema,
6013
- kind: z2.literal("operation"),
6211
+ kind: z3.literal("operation"),
6014
6212
  ...envelopeTail,
6015
- operation: z2.string(),
6016
- target: z2.string().nullable()
6213
+ operation: z3.string(),
6214
+ target: z3.string().nullable()
6017
6215
  };
6018
- var OperationEventSchema = z2.discriminatedUnion("event", [
6019
- z2.object({
6216
+ var OperationEventSchema = z3.discriminatedUnion("event", [
6217
+ z3.object({
6020
6218
  ...operationShared,
6021
- event: z2.literal("completed"),
6219
+ event: z3.literal("completed"),
6022
6220
  result: OperationResultSchema,
6023
- error_class: z2.string().nullable()
6221
+ error_class: z3.string().nullable(),
6222
+ field_names: z3.array(z3.string().max(CUSTOM_FIELD_NAME_MAX_LENGTH)).max(CUSTOM_EVENT_MAX_FIELDS).optional()
6024
6223
  }).strict()
6025
6224
  ]);
6026
- var UsageUnitsSchema = z2.object({
6027
- input: z2.number().nonnegative().nullable(),
6028
- output: z2.number().nonnegative().nullable(),
6029
- cache: z2.number().nonnegative().nullable()
6225
+ var UsageUnitsSchema = z3.object({
6226
+ input: z3.number().nonnegative().nullable(),
6227
+ output: z3.number().nonnegative().nullable(),
6228
+ cache: z3.number().nonnegative().nullable()
6030
6229
  }).strict();
6031
6230
  var usageShared = {
6032
6231
  meta: HeaderMetaSchema,
6033
6232
  subject: SubjectSchema,
6034
- kind: z2.literal("usage"),
6233
+ kind: z3.literal("usage"),
6035
6234
  ...envelopeTail,
6036
- model: z2.string().nullable(),
6037
- source: z2.string(),
6038
- semantics: z2.enum(["cumulative", "delta"])
6235
+ model: z3.string().nullable(),
6236
+ source: z3.string(),
6237
+ semantics: z3.enum(["cumulative", "delta"])
6039
6238
  };
6040
- var UsageEventSchema = z2.discriminatedUnion("event", [
6041
- z2.object({
6239
+ var UsageEventSchema = z3.discriminatedUnion("event", [
6240
+ z3.object({
6042
6241
  ...usageShared,
6043
- event: z2.literal("observed"),
6242
+ event: z3.literal("observed"),
6044
6243
  units: UsageUnitsSchema,
6045
- unknown_reason: z2.string().nullable()
6244
+ unknown_reason: z3.string().nullable()
6046
6245
  }).strict()
6047
6246
  ]);
6048
- var RoleAttemptOutcomeSchema = z2.enum([
6247
+ var RoleAttemptOutcomeSchema = z3.enum([
6049
6248
  "completed",
6050
6249
  "incomplete",
6051
6250
  "infrastructure_failed",
@@ -6056,17 +6255,17 @@ var RoleAttemptOutcomeSchema = z2.enum([
6056
6255
  var roleAttemptShared = {
6057
6256
  meta: HeaderMetaSchema,
6058
6257
  subject: SubjectSchema,
6059
- kind: z2.literal("role_attempt"),
6258
+ kind: z3.literal("role_attempt"),
6060
6259
  ...envelopeTail,
6061
- actor: z2.string().nullable(),
6062
- attempt: z2.number().int().nullable(),
6063
- effect_id: z2.string(),
6064
- model: z2.string().nullable()
6260
+ actor: z3.string().nullable(),
6261
+ attempt: z3.number().int().nullable(),
6262
+ effect_id: z3.string(),
6263
+ model: z3.string().nullable()
6065
6264
  };
6066
- var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
6067
- z2.object({
6265
+ var RoleAttemptEventSchema = z3.discriminatedUnion("event", [
6266
+ z3.object({
6068
6267
  ...roleAttemptShared,
6069
- event: z2.literal("attempted"),
6268
+ event: z3.literal("attempted"),
6070
6269
  outcome: RoleAttemptOutcomeSchema,
6071
6270
  usage: dispatchUsageField
6072
6271
  }).strict()
@@ -6074,42 +6273,59 @@ var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
6074
6273
  var handoffShared = {
6075
6274
  meta: HeaderMetaSchema,
6076
6275
  subject: SubjectSchema,
6077
- kind: z2.literal("handoff"),
6276
+ kind: z3.literal("handoff"),
6078
6277
  ...envelopeTail,
6079
- class: z2.enum(["authority", "strategy", "product"]),
6080
- reason: z2.string()
6278
+ class: z3.enum(["authority", "strategy", "product"]),
6279
+ reason: z3.string()
6081
6280
  };
6082
- var HandoffEventSchema = z2.discriminatedUnion("event", [
6083
- z2.object({
6281
+ var HandoffEventSchema = z3.discriminatedUnion("event", [
6282
+ z3.object({
6084
6283
  ...handoffShared,
6085
- event: z2.literal("raised"),
6086
- requested_decision: z2.string().nullable()
6284
+ event: z3.literal("raised"),
6285
+ requested_decision: z3.string().nullable()
6087
6286
  }).strict(),
6088
- z2.object({
6287
+ z3.object({
6089
6288
  ...handoffShared,
6090
- event: z2.literal("resolved"),
6091
- resolution: z2.string().nullable(),
6092
- resolved_by: z2.string().nullable()
6289
+ event: z3.literal("resolved"),
6290
+ resolution: z3.string().nullable(),
6291
+ resolved_by: z3.string().nullable()
6093
6292
  }).strict()
6094
6293
  ]);
6095
- var EffectTargetSchema = z2.object({
6096
- kind: z2.string(),
6097
- ref: z2.string()
6294
+ var EffectTargetSchema = z3.object({
6295
+ kind: z3.string(),
6296
+ ref: z3.string()
6098
6297
  }).strict();
6099
6298
  var effectShared = {
6100
6299
  meta: HeaderMetaSchema,
6101
6300
  subject: SubjectSchema,
6102
- kind: z2.literal("effect"),
6301
+ kind: z3.literal("effect"),
6103
6302
  ...envelopeTail,
6104
- effect_id: z2.string(),
6303
+ effect_id: z3.string(),
6105
6304
  target: EffectTargetSchema
6106
6305
  };
6107
- var EffectEventSchema = z2.discriminatedUnion("event", [
6108
- z2.object({ ...effectShared, event: z2.literal("attempted") }).strict(),
6109
- z2.object({ ...effectShared, event: z2.literal("observed"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict(),
6110
- z2.object({ ...effectShared, event: z2.literal("verified"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict()
6306
+ var EffectEventSchema = z3.discriminatedUnion("event", [
6307
+ z3.object({ ...effectShared, event: z3.literal("attempted") }).strict(),
6308
+ z3.object({ ...effectShared, event: z3.literal("observed"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict(),
6309
+ z3.object({ ...effectShared, event: z3.literal("verified"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict()
6310
+ ]);
6311
+ var CustomFieldValueSchema = z3.union([z3.string().max(CUSTOM_TEXT_MAX_LENGTH), z3.number().finite(), z3.boolean()]);
6312
+ var customShared = {
6313
+ meta: HeaderMetaV3Schema,
6314
+ subject: SubjectSchema,
6315
+ kind: z3.literal("custom"),
6316
+ ...envelopeTail
6317
+ };
6318
+ var CustomEventSchema = z3.discriminatedUnion("event", [
6319
+ z3.object({
6320
+ ...customShared,
6321
+ event: z3.literal("recorded"),
6322
+ name: z3.string().max(CUSTOM_EVENT_NAME_MAX_LENGTH).regex(CUSTOM_EVENT_NAME_PATTERN),
6323
+ 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, {
6324
+ message: `custom: at most ${CUSTOM_EVENT_MAX_FIELDS} fields`
6325
+ })
6326
+ }).strict()
6111
6327
  ]);
6112
- var LogEventSchema = z2.union([
6328
+ var LogEventSchema = z3.union([
6113
6329
  DispatchEventSchema,
6114
6330
  DevReviewLoopEventSchema,
6115
6331
  ForgeWriteEventSchema,
@@ -6118,10 +6334,11 @@ var LogEventSchema = z2.union([
6118
6334
  UsageEventSchema,
6119
6335
  RoleAttemptEventSchema,
6120
6336
  HandoffEventSchema,
6121
- EffectEventSchema
6337
+ EffectEventSchema,
6338
+ CustomEventSchema
6122
6339
  ]);
6123
-
6124
6340
  // ../../packages/aeg-core/src/log/envelope.ts
6341
+ import { createHash as createHash5 } from "node:crypto";
6125
6342
  function isRole(value) {
6126
6343
  return value !== undefined && ROLE_VALUES.includes(value);
6127
6344
  }
@@ -6158,18 +6375,27 @@ function roundFromEnv(round) {
6158
6375
  const n = Number(round);
6159
6376
  return Number.isInteger(n) ? n : undefined;
6160
6377
  }
6378
+ function prFromEnv(pr) {
6379
+ if (pr === undefined || pr === "")
6380
+ return;
6381
+ const n = Number(pr);
6382
+ return Number.isInteger(n) && n > 0 ? n : undefined;
6383
+ }
6161
6384
  function buildHeader(input) {
6162
6385
  const role = isRole(input.env.role) ? input.env.role : "unattributed";
6163
6386
  const round = roundFromEnv(input.env.round);
6387
+ const pr = prFromEnv(input.env.pr);
6164
6388
  const subject = {
6165
6389
  issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
6166
6390
  role,
6167
6391
  ...round !== undefined ? { round } : {},
6392
+ ...pr !== undefined ? { pr } : {},
6168
6393
  ...input.subject ?? {}
6169
6394
  };
6395
+ const issue = subject.issue;
6170
6396
  return {
6171
6397
  meta: {
6172
- schema: 2,
6398
+ schema: 3,
6173
6399
  ts: input.now.toISOString(),
6174
6400
  run_id: input.runId,
6175
6401
  seq: input.seq,
@@ -6192,7 +6418,19 @@ function buildHeader(input) {
6192
6418
  ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
6193
6419
  policy_digest: input.inputVersions?.policyDigest ?? null
6194
6420
  },
6195
- provenance: provenanceFor(input)
6421
+ provenance: provenanceFor(input),
6422
+ work: {
6423
+ ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
6424
+ repo: input.repo,
6425
+ change: null,
6426
+ revision: null
6427
+ },
6428
+ flow: {
6429
+ id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
6430
+ version: lineageFieldFromEnv(input.env.flowVersion)
6431
+ },
6432
+ runtime: lineageFieldFromEnv(input.env.runtime),
6433
+ source: lineageFieldFromEnv(input.env.source)
6196
6434
  },
6197
6435
  subject
6198
6436
  };
@@ -6235,7 +6473,7 @@ function redact(value, home) {
6235
6473
  return value;
6236
6474
  }
6237
6475
  // ../../packages/aeg-core/src/log/store.ts
6238
- var KNOWN_SCHEMA_VERSIONS = [1, 2];
6476
+ var KNOWN_SCHEMA_VERSIONS = [1, 2, 3];
6239
6477
  function metaOf(obj) {
6240
6478
  if (obj === null || typeof obj !== "object")
6241
6479
  return null;
@@ -6301,7 +6539,7 @@ function classifyStoredLine(raw, home) {
6301
6539
  return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
6302
6540
  }
6303
6541
  const redacted = redact(event, home);
6304
- const provenance = version === 2 ? event.meta.provenance ?? null : null;
6542
+ const provenance = version >= 2 ? event.meta.provenance ?? null : null;
6305
6543
  return {
6306
6544
  status: "ok",
6307
6545
  identity,
@@ -6314,189 +6552,172 @@ function classifyStoredLine(raw, home) {
6314
6552
  };
6315
6553
  }
6316
6554
  // ../../packages/aeg-core/src/control-store/records.ts
6317
- import { z as z3 } from "zod";
6318
- var isoTimestamp = z3.string().min(1);
6319
- var taskId = z3.number().int().positive();
6320
- var epochNumber = z3.number().int().nonnegative();
6321
- var RunRecordSchema = z3.object({
6322
- version: z3.literal(1),
6323
- kind: z3.literal("run"),
6555
+ import { z as z4 } from "zod";
6556
+ var isoTimestamp = z4.string().min(1);
6557
+ var taskId = z4.number().int().positive();
6558
+ var epochNumber = z4.number().int().nonnegative();
6559
+ var RunRecordSchema = z4.object({
6560
+ version: z4.literal(1),
6561
+ kind: z4.literal("run"),
6324
6562
  task: taskId,
6325
- runId: z3.string().min(1),
6326
- pid: z3.number().int().positive(),
6327
- host: z3.string().min(1),
6563
+ runId: z4.string().min(1),
6564
+ pid: z4.number().int().positive(),
6565
+ host: z4.string().min(1),
6328
6566
  startedAt: isoTimestamp,
6329
- childStartedAt: z3.string().min(1).nullable().optional(),
6330
- childCommand: z3.string().min(1).nullable().optional()
6567
+ childStartedAt: z4.string().min(1).nullable().optional(),
6568
+ childCommand: z4.string().min(1).nullable().optional()
6331
6569
  }).strict();
6332
- var InputRecordSchema = z3.object({
6333
- version: z3.literal(1),
6334
- kind: z3.literal("input"),
6570
+ var InputRecordSchema = z4.object({
6571
+ version: z4.literal(1),
6572
+ kind: z4.literal("input"),
6335
6573
  task: taskId,
6336
- runId: z3.string().min(1),
6337
- source: z3.union([z3.literal("fresh"), z3.literal("resume")]),
6338
- pr: z3.number().int().positive().nullable(),
6339
- round: z3.number().int().nonnegative(),
6574
+ runId: z4.string().min(1),
6575
+ source: z4.union([z4.literal("fresh"), z4.literal("resume")]),
6576
+ pr: z4.number().int().positive().nullable(),
6577
+ round: z4.number().int().nonnegative(),
6340
6578
  recordedAt: isoTimestamp
6341
6579
  }).strict();
6342
- var OwnershipRecordSchema = z3.object({
6343
- version: z3.literal(1),
6344
- kind: z3.literal("ownership"),
6580
+ var OwnershipRecordSchema = z4.object({
6581
+ version: z4.literal(1),
6582
+ kind: z4.literal("ownership"),
6345
6583
  task: taskId,
6346
6584
  epoch: epochNumber,
6347
- ownerId: z3.string().min(1),
6348
- pid: z3.number().int().positive(),
6349
- host: z3.string().min(1),
6585
+ ownerId: z4.string().min(1),
6586
+ pid: z4.number().int().positive(),
6587
+ host: z4.string().min(1),
6350
6588
  acquiredAt: isoTimestamp
6351
6589
  }).strict();
6352
- var TransitionRecordSchema = z3.object({
6353
- version: z3.literal(1),
6354
- kind: z3.literal("transition"),
6590
+ var TransitionRecordSchema = z4.object({
6591
+ version: z4.literal(1),
6592
+ kind: z4.literal("transition"),
6355
6593
  task: taskId,
6356
6594
  epoch: epochNumber,
6357
- seq: z3.number().int().nonnegative(),
6358
- from: z3.string().min(1),
6359
- to: z3.string().min(1),
6360
- detail: z3.string().optional(),
6595
+ seq: z4.number().int().nonnegative(),
6596
+ from: z4.string().min(1),
6597
+ to: z4.string().min(1),
6598
+ detail: z4.string().optional(),
6361
6599
  at: isoTimestamp
6362
6600
  }).strict();
6363
- var ManifestRecordSchema = z3.object({
6364
- version: z3.literal(1),
6365
- kind: z3.literal("manifest"),
6601
+ var ManifestRecordSchema = z4.object({
6602
+ version: z4.literal(1),
6603
+ kind: z4.literal("manifest"),
6366
6604
  task: taskId,
6367
6605
  round: epochNumber,
6368
- repository: z3.string().min(1),
6369
- pr: z3.number().int().positive(),
6370
- branch: z3.string().min(1),
6371
- baseSha: z3.string().min(1).nullable(),
6372
- headSha: z3.string().min(1),
6373
- briefHash: z3.string().min(1).nullable(),
6374
- objectivesVersion: z3.string().min(1).nullable(),
6606
+ repository: z4.string().min(1),
6607
+ pr: z4.number().int().positive(),
6608
+ branch: z4.string().min(1),
6609
+ baseSha: z4.string().min(1).nullable(),
6610
+ headSha: z4.string().min(1),
6611
+ briefHash: z4.string().min(1).nullable(),
6612
+ objectivesVersion: z4.string().min(1).nullable(),
6375
6613
  rulingOrdinal: epochNumber,
6376
- policyDigest: z3.string().min(1),
6614
+ policyDigest: z4.string().min(1),
6377
6615
  recordedAt: isoTimestamp
6378
6616
  }).strict();
6379
- var roundHeadIdentity = z3.object({ round: z3.number().int().positive(), head: z3.string().min(1) }).strict();
6380
- var LoopBudgetsSchema = z3.object({
6381
- mechanicalRetries: z3.number().int().nonnegative(),
6382
- reviewRounds: z3.number().int().nonnegative(),
6383
- infrastructureRetries: z3.number().int().nonnegative()
6617
+ var roundHeadIdentity = z4.object({ round: z4.number().int().positive(), head: z4.string().min(1) }).strict();
6618
+ var LoopBudgetsSchema = z4.object({
6619
+ mechanicalRetries: z4.number().int().nonnegative(),
6620
+ reviewRounds: z4.number().int().nonnegative(),
6621
+ infrastructureRetries: z4.number().int().nonnegative()
6384
6622
  }).strict();
6385
- var LoopStateRecordSchema = z3.object({
6386
- version: z3.literal(1),
6387
- kind: z3.literal("loop_state"),
6623
+ var LoopStateRecordSchema = z4.object({
6624
+ version: z4.literal(1),
6625
+ kind: z4.literal("loop_state"),
6388
6626
  task: taskId,
6389
- round: z3.number().int().positive(),
6390
- phase: z3.string().min(1),
6391
- pauseReason: z3.string().min(1).nullable(),
6627
+ round: z4.number().int().positive(),
6628
+ phase: z4.string().min(1),
6629
+ pauseReason: z4.string().min(1).nullable(),
6392
6630
  budgets: LoopBudgetsSchema,
6393
6631
  heldResult: roundHeadIdentity.nullable(),
6394
6632
  deliveredFindings: roundHeadIdentity.nullable(),
6395
- repeatMemory: z3.object({
6396
- blockingFindings: z3.array(z3.string()),
6397
- lastFailure: z3.object({ signature: z3.string(), message: z3.string() }).nullable()
6633
+ repeatMemory: z4.object({
6634
+ blockingFindings: z4.array(z4.string()),
6635
+ lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
6398
6636
  }).strict().optional(),
6637
+ publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
6638
+ taskStartedAt: isoTimestamp.optional(),
6639
+ phaseMs: z4.record(z4.string(), z4.number().nonnegative()).optional(),
6399
6640
  recordedAt: isoTimestamp
6400
6641
  }).strict();
6401
- var EffectRecordSchema = z3.object({
6402
- version: z3.literal(1),
6403
- kind: z3.literal("effect"),
6642
+ var EffectRecordSchema = z4.object({
6643
+ version: z4.literal(1),
6644
+ kind: z4.literal("effect"),
6404
6645
  task: taskId,
6405
- key: z3.string().min(1),
6406
- operation: z3.string().min(1),
6407
- target: z3.string().min(1),
6408
- inputVersion: z3.number().int().nonnegative(),
6409
- payloadDigest: z3.string().min(1),
6410
- status: z3.union([z3.literal("started"), z3.literal("verified"), z3.literal("uncertain")]),
6411
- url: z3.string().optional(),
6646
+ key: z4.string().min(1),
6647
+ operation: z4.string().min(1),
6648
+ target: z4.string().min(1),
6649
+ inputVersion: z4.number().int().nonnegative(),
6650
+ payloadDigest: z4.string().min(1),
6651
+ status: z4.union([z4.literal("started"), z4.literal("verified"), z4.literal("uncertain")]),
6652
+ url: z4.string().optional(),
6412
6653
  recordedAt: isoTimestamp
6413
6654
  }).strict();
6414
- var EscalationRecordSchema = z3.object({
6415
- version: z3.literal(1),
6416
- kind: z3.literal("escalation"),
6655
+ var EscalationRecordSchema = z4.object({
6656
+ version: z4.literal(1),
6657
+ kind: z4.literal("escalation"),
6417
6658
  task: taskId,
6418
- escalationId: z3.string().min(1),
6659
+ escalationId: z4.string().min(1),
6419
6660
  round: epochNumber,
6420
- head: z3.string().min(1),
6421
- branch: z3.string().min(1),
6422
- pr: z3.number().int().positive().nullable(),
6423
- runId: z3.string().min(1),
6424
- pid: z3.number().int().positive(),
6425
- host: z3.string().min(1),
6426
- agent: z3.string().min(1).optional(),
6427
- reason: z3.string().min(1),
6428
- detail: z3.string().optional(),
6429
- evidence: z3.string().optional(),
6430
- attemptedRecovery: z3.string().min(1),
6431
- requestedDecision: z3.string().min(1),
6432
- recipient: z3.string().min(1),
6433
- briefHash: z3.string().min(1).nullable(),
6434
- objectivesVersion: z3.string().min(1).nullable(),
6661
+ head: z4.string().min(1),
6662
+ branch: z4.string().min(1),
6663
+ pr: z4.number().int().positive().nullable(),
6664
+ runId: z4.string().min(1),
6665
+ pid: z4.number().int().positive(),
6666
+ host: z4.string().min(1),
6667
+ agent: z4.string().min(1).optional(),
6668
+ reason: z4.string().min(1),
6669
+ detail: z4.string().optional(),
6670
+ evidence: z4.string().optional(),
6671
+ attemptedRecovery: z4.string().min(1),
6672
+ requestedDecision: z4.string().min(1),
6673
+ recipient: z4.string().min(1),
6674
+ briefHash: z4.string().min(1).nullable(),
6675
+ objectivesVersion: z4.string().min(1).nullable(),
6435
6676
  rulingOrdinal: epochNumber,
6436
- policyDigest: z3.string().min(1),
6677
+ policyDigest: z4.string().min(1),
6437
6678
  recordedAt: isoTimestamp
6438
6679
  }).strict();
6439
- var ResolutionRecordSchema = z3.object({
6440
- version: z3.literal(1),
6441
- kind: z3.literal("resolution"),
6680
+ var ResolutionRecordSchema = z4.object({
6681
+ version: z4.literal(1),
6682
+ kind: z4.literal("resolution"),
6442
6683
  task: taskId,
6443
- escalationId: z3.string().min(1),
6444
- decision: z3.union([z3.literal("resume"), z3.literal("cancel")]),
6445
- authenticatedBy: z3.string().min(1),
6446
- authenticatedFrom: z3.string().min(1),
6684
+ escalationId: z4.string().min(1),
6685
+ decision: z4.union([z4.literal("resume"), z4.literal("cancel")]),
6686
+ authenticatedBy: z4.string().min(1),
6687
+ authenticatedFrom: z4.string().min(1),
6447
6688
  consumedAt: isoTimestamp
6448
6689
  }).strict();
6690
+ // ../../packages/aeg-core/src/control-store/local.ts
6691
+ var CONTROL_AREA_DIRNAME = "control";
6449
6692
  // src/lib/config.ts
6450
- import { execFile as execFile4, execFileSync as execFileSync3 } from "node:child_process";
6693
+ import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
6451
6694
  import { promisify as promisify4 } from "node:util";
6452
6695
  import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
6453
6696
  import { homedir } from "node:os";
6454
6697
  import { dirname, isAbsolute, join, resolve } from "node:path";
6455
- import { z as z4 } from "zod";
6698
+ import { z as z5 } from "zod";
6456
6699
 
6457
6700
  // src/lib/agent-vendors.ts
6458
6701
  var AGENT_VENDORS = ["skills", "claude", "gemini"];
6459
6702
 
6460
- // src/lib/worker-boundary.ts
6461
- import { execFileSync as execFileSync2 } from "node:child_process";
6462
- var LOG_HEADER_KEYCHAIN_SERVICE = "Vinaya Log";
6463
- var logHeaderKeychainCache = new Map;
6464
- function readRealLogHeaderKeychainCredential(variable) {
6465
- if (process.platform !== "darwin")
6466
- return null;
6467
- try {
6468
- return execFileSync2("/usr/bin/security", ["find-generic-password", "-s", LOG_HEADER_KEYCHAIN_SERVICE, "-a", variable, "-w"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 5000, maxBuffer: 1024 * 1024 }).replace(/\n$/, "");
6469
- } catch {
6470
- return null;
6471
- }
6472
- }
6473
- function readLogHeaderKeychainCredential(variable) {
6474
- const cached = logHeaderKeychainCache.get(variable);
6475
- if (cached !== undefined)
6476
- return cached;
6477
- const value = readRealLogHeaderKeychainCredential(variable);
6478
- logHeaderKeychainCache.set(variable, value);
6479
- return value;
6480
- }
6481
-
6482
6703
  // src/lib/config.ts
6483
- var EnvEntrySchema = z4.union([
6484
- z4.literal(true),
6485
- z4.object({ optional: z4.literal(true) }),
6486
- z4.object({ anyOf: z4.array(z4.string()).min(2) }),
6487
- z4.string()
6704
+ var EnvEntrySchema = z5.union([
6705
+ z5.literal(true),
6706
+ z5.object({ optional: z5.literal(true) }),
6707
+ z5.object({ anyOf: z5.array(z5.string()).min(2) }),
6708
+ z5.string()
6488
6709
  ]);
6489
- var CheckEntrySchema = z4.object({
6490
- run: z4.string(),
6491
- scope: z4.enum(["diff", "full"]),
6492
- include: z4.array(z4.string()).optional(),
6493
- args: z4.array(z4.string()).optional(),
6494
- timeoutMs: z4.number().optional(),
6495
- env: z4.record(z4.string(), EnvEntrySchema).optional(),
6496
- requiresOpenPr: z4.boolean().optional(),
6497
- ownWorkflow: z4.boolean().optional(),
6498
- principalOwed: z4.literal(true).optional(),
6499
- validates: z4.enum(["body", "issue"]).optional()
6710
+ var CheckEntrySchema = z5.object({
6711
+ run: z5.string(),
6712
+ scope: z5.enum(["diff", "full"]),
6713
+ include: z5.array(z5.string()).optional(),
6714
+ args: z5.array(z5.string()).optional(),
6715
+ timeoutMs: z5.number().optional(),
6716
+ env: z5.record(z5.string(), EnvEntrySchema).optional(),
6717
+ requiresOpenPr: z5.boolean().optional(),
6718
+ ownWorkflow: z5.boolean().optional(),
6719
+ principalOwed: z5.literal(true).optional(),
6720
+ validates: z5.enum(["body", "issue"]).optional()
6500
6721
  }).superRefine((entry, ctx) => {
6501
6722
  if (!entry.env)
6502
6723
  return;
@@ -6506,22 +6727,22 @@ var CheckEntrySchema = z4.object({
6506
6727
  const members = value.anyOf;
6507
6728
  if (new Set(members).size !== members.length) {
6508
6729
  ctx.addIssue({
6509
- code: z4.ZodIssueCode.custom,
6730
+ code: z5.ZodIssueCode.custom,
6510
6731
  message: `env.${key}.anyOf has duplicate members`,
6511
6732
  path: ["env", key, "anyOf"]
6512
6733
  });
6513
6734
  }
6514
6735
  if (!members.includes(key)) {
6515
6736
  ctx.addIssue({
6516
- code: z4.ZodIssueCode.custom,
6737
+ code: z5.ZodIssueCode.custom,
6517
6738
  message: `env.${key}.anyOf must include "${key}" itself as a member`,
6518
6739
  path: ["env", key, "anyOf"]
6519
6740
  });
6520
6741
  }
6521
6742
  }
6522
6743
  });
6523
- var RoleEntrySchema = z4.object({
6524
- contract: z4.string().refine((p) => p.includes("/"), {
6744
+ var RoleEntrySchema = z5.object({
6745
+ contract: z5.string().refine((p) => p.includes("/"), {
6525
6746
  message: 'must be a path (contain at least one "/"), not a bare filename'
6526
6747
  })
6527
6748
  });
@@ -6545,17 +6766,17 @@ var BRIEF_BUILTINS = [
6545
6766
  "briefSections",
6546
6767
  "milestoneShape"
6547
6768
  ];
6548
- var BriefSectionSchema = z4.union([
6549
- z4.object({ builtin: z4.enum(BRIEF_BUILTINS) }),
6550
- z4.object({ heading: z4.string().min(1), name: z4.string().optional() }),
6551
- z4.object({ field: z4.string().min(1), name: z4.string().optional() }),
6552
- z4.object({ phrase: z4.string().min(1), name: z4.string().optional() })
6769
+ var BriefSectionSchema = z5.union([
6770
+ z5.object({ builtin: z5.enum(BRIEF_BUILTINS) }),
6771
+ z5.object({ heading: z5.string().min(1), name: z5.string().optional() }),
6772
+ z5.object({ field: z5.string().min(1), name: z5.string().optional() }),
6773
+ z5.object({ phrase: z5.string().min(1), name: z5.string().optional() })
6553
6774
  ]);
6554
- var BriefSchemaSchema = z4.object({
6555
- pr: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
6556
- issue: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
6557
- milestone: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
6558
- ack: z4.array(z4.enum(BRIEF_BUILTINS)).optional()
6775
+ var BriefSchemaSchema = z5.object({
6776
+ pr: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
6777
+ issue: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
6778
+ milestone: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
6779
+ ack: z5.array(z5.enum(BRIEF_BUILTINS)).optional()
6559
6780
  });
6560
6781
  function isSafeRepoRelPath(p) {
6561
6782
  if (p.length === 0)
@@ -6564,7 +6785,7 @@ function isSafeRepoRelPath(p) {
6564
6785
  return false;
6565
6786
  return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
6566
6787
  }
6567
- var SafeRepoRelPath = z4.string().refine(isSafeRepoRelPath, {
6788
+ var SafeRepoRelPath = z5.string().refine(isSafeRepoRelPath, {
6568
6789
  message: "must be a repo-root-relative path with no `..` segment or absolute root"
6569
6790
  });
6570
6791
  var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
@@ -6574,22 +6795,22 @@ function isCanonicalHookBlockPath(p) {
6574
6795
  var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
6575
6796
  message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
6576
6797
  });
6577
- var ManagedBlockRecordSchema = z4.object({
6798
+ var ManagedBlockRecordSchema = z5.object({
6578
6799
  path: ManagedHookBlockPath,
6579
- marker: z4.string(),
6580
- comment: z4.enum(["hash", "html"])
6800
+ marker: z5.string(),
6801
+ comment: z5.enum(["hash", "html"])
6581
6802
  });
6582
- var ManagedManifestSchema = z4.object({
6583
- version: z4.number().int().positive(),
6584
- files: z4.array(SafeRepoRelPath),
6585
- blocks: z4.array(ManagedBlockRecordSchema),
6586
- labels: z4.array(z4.string()),
6587
- agents: z4.array(z4.enum(AGENT_VENDORS)).optional()
6803
+ var ManagedManifestSchema = z5.object({
6804
+ version: z5.number().int().positive(),
6805
+ files: z5.array(SafeRepoRelPath),
6806
+ blocks: z5.array(ManagedBlockRecordSchema),
6807
+ labels: z5.array(z5.string()),
6808
+ agents: z5.array(z5.enum(AGENT_VENDORS)).optional()
6588
6809
  });
6589
- var ProjectEntrySchema = z4.object({
6590
- name: z4.string().min(1),
6591
- description: z4.string().min(1).optional(),
6592
- path: z4.string().min(1).optional()
6810
+ var ProjectEntrySchema = z5.object({
6811
+ name: z5.string().min(1),
6812
+ description: z5.string().min(1).optional(),
6813
+ path: z5.string().min(1).optional()
6593
6814
  });
6594
6815
  function parseTokensCollectDeclaration(value) {
6595
6816
  const m = value.trim().match(/^(\S+)\s+(\S+)$/);
@@ -6600,90 +6821,97 @@ function parseTokensCollectDeclaration(value) {
6600
6821
  return null;
6601
6822
  return { interpreter, script };
6602
6823
  }
6603
- var VinayaConfigSchema = z4.object({
6604
- rings: z4.object({
6605
- ring1_forgeWriteInterception: z4.boolean(),
6606
- ring2_asyncAudits: z4.boolean()
6824
+ var VinayaConfigSchema = z5.object({
6825
+ rings: z5.object({
6826
+ ring1_forgeWriteInterception: z5.boolean(),
6827
+ ring2_asyncAudits: z5.boolean()
6607
6828
  }).optional(),
6608
- checks: z4.record(z4.string(), CheckEntrySchema).optional(),
6609
- roles: z4.record(z4.string(), RoleEntrySchema).optional(),
6829
+ checks: z5.record(z5.string(), CheckEntrySchema).optional(),
6830
+ roles: z5.record(z5.string(), RoleEntrySchema).optional(),
6610
6831
  briefSchema: BriefSchemaSchema.optional(),
6611
6832
  managed: ManagedManifestSchema.optional(),
6612
- principals: z4.array(z4.string()).min(1).optional(),
6613
- releaseActor: z4.string().min(1).optional(),
6614
- ci: z4.object({ setup: z4.string().min(1) }).optional(),
6615
- tokens: z4.object({
6616
- collect: z4.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
6833
+ principals: z5.array(z5.string()).min(1).optional(),
6834
+ releaseActor: z5.string().min(1).optional(),
6835
+ ci: z5.object({ setup: z5.string().min(1) }).optional(),
6836
+ tokens: z5.object({
6837
+ collect: z5.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
6617
6838
  message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
6618
6839
  })
6619
6840
  }).optional(),
6620
- blastRadius: z4.object({ extraDomains: z4.array(z4.string()).optional() }).optional(),
6621
- proseGates: z4.object({
6622
- doctrineRoot: z4.string().min(1).optional(),
6623
- readerFacingPrefix: z4.string().min(1).optional(),
6624
- readerFacingSuffix: z4.string().min(1).optional(),
6625
- legacySlugDir: z4.string().min(1).optional(),
6626
- sourceComments: z4.object({
6627
- globs: z4.array(z4.string().min(1)).optional(),
6628
- allowlist: z4.array(z4.string().min(1)).optional(),
6629
- severity: z4.enum(["warning", "error"]).optional()
6841
+ blastRadius: z5.object({ extraDomains: z5.array(z5.string()).optional() }).optional(),
6842
+ proseGates: z5.object({
6843
+ doctrineRoot: z5.string().min(1).optional(),
6844
+ readerFacingPrefix: z5.string().min(1).optional(),
6845
+ readerFacingSuffix: z5.string().min(1).optional(),
6846
+ legacySlugDir: z5.string().min(1).optional(),
6847
+ sourceComments: z5.object({
6848
+ globs: z5.array(z5.string().min(1)).optional(),
6849
+ allowlist: z5.array(z5.string().min(1)).optional(),
6850
+ severity: z5.enum(["warning", "error"]).optional()
6630
6851
  }).optional(),
6631
- specGrandfather: z4.array(z4.string().min(1)).optional(),
6632
- specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
6852
+ specGrandfather: z5.union([z5.array(z5.string().min(1)), z5.record(z5.string().min(1), z5.number().int().min(0))]).optional(),
6853
+ specPaths: z5.array(z5.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
6633
6854
  message: "must be a repository-relative path, not an absolute one"
6634
6855
  }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
6635
6856
  message: "must stay inside the repository — no `..` segment"
6636
6857
  })).optional()
6637
6858
  }).optional(),
6638
- projects: z4.array(ProjectEntrySchema).optional(),
6639
- dispatch: z4.object({
6640
- timeoutMs: z4.number().int().positive().optional(),
6641
- killGraceMs: z4.number().int().positive().optional(),
6642
- agent: z4.enum(["claude", "codex", "gemini"]).optional(),
6643
- requireWorkerIsolation: z4.boolean().optional()
6859
+ projects: z5.array(ProjectEntrySchema).optional(),
6860
+ dispatch: z5.object({
6861
+ timeoutMs: z5.number().int().positive().optional(),
6862
+ killGraceMs: z5.number().int().positive().optional(),
6863
+ agent: z5.enum(["claude", "codex", "gemini"]).optional()
6864
+ }).optional(),
6865
+ reviewPolicy: z5.object({
6866
+ codeReviewThreshold: z5.string().min(1).optional(),
6867
+ securityThreshold: z5.string().min(1).optional(),
6868
+ maxRounds: z5.number().optional(),
6869
+ maxTaskMinutes: z5.number().optional()
6644
6870
  }).optional(),
6645
- reviewPolicy: z4.object({
6646
- codeReviewThreshold: z4.string().min(1).optional(),
6647
- securityThreshold: z4.string().min(1).optional(),
6648
- maxRounds: z4.number().optional()
6871
+ securityScan: z5.object({
6872
+ command: z5.array(z5.string().min(1)).min(1)
6649
6873
  }).optional(),
6650
- gateCutovers: z4.object({
6651
- objectivesSinceIssue: z4.number().int().nonnegative().optional(),
6652
- briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
6653
- documentationSinceIssue: z4.number().int().nonnegative().optional(),
6654
- briefRulesSincePr: z4.number().int().nonnegative().optional(),
6655
- agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
6874
+ gateCutovers: z5.object({
6875
+ objectivesSinceIssue: z5.number().int().nonnegative().optional(),
6876
+ briefSectionsSinceIssue: z5.number().int().nonnegative().optional(),
6877
+ documentationSinceIssue: z5.number().int().nonnegative().optional(),
6878
+ briefRulesSincePr: z5.number().int().nonnegative().optional(),
6879
+ agentBoxesRefusedSincePr: z5.number().int().nonnegative().optional()
6656
6880
  }).optional(),
6657
- planning: z4.object({
6658
- collisionThreshold: z4.number().int().nonnegative().optional()
6881
+ planning: z5.object({
6882
+ collisionThreshold: z5.number().int().nonnegative().optional()
6659
6883
  }).optional(),
6660
- prePush: z4.object({
6661
- alwaysRun: z4.array(z4.string()).optional()
6884
+ prePush: z5.object({
6885
+ alwaysRun: z5.array(z5.string()).optional()
6662
6886
  }).optional(),
6663
- report: z4.object({
6664
- commandTimeoutMs: z4.number().int().positive().optional()
6887
+ report: z5.object({
6888
+ commandTimeoutMs: z5.number().int().positive().optional()
6665
6889
  }).superRefine((report, ctx) => {
6666
6890
  const commandTimeoutMs = report.commandTimeoutMs;
6667
6891
  if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
6668
6892
  ctx.addIssue({
6669
- code: z4.ZodIssueCode.custom,
6893
+ code: z5.ZodIssueCode.custom,
6670
6894
  path: ["commandTimeoutMs"],
6671
6895
  message: "must be at most 3600000 (1 hour)"
6672
6896
  });
6673
6897
  }
6674
6898
  }).optional(),
6675
- logPublish: z4.unknown().refine((v) => v === undefined, {
6899
+ logPublish: z5.unknown().refine((v) => v === undefined, {
6676
6900
  message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
6677
6901
  }),
6678
- runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
6679
- logs: z4.object({
6680
- folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
6681
- url: z4.string().url().optional(),
6682
- headers: z4.record(z4.string()).optional()
6902
+ runtimeDir: z5.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
6903
+ logs: z5.object({
6904
+ folder: z5.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
6905
+ url: z5.string().url().optional(),
6906
+ headers: z5.record(z5.string()).optional(),
6907
+ readHeaders: z5.record(z5.string()).optional(),
6908
+ events: CustomEventDeclarationsSchema.optional()
6683
6909
  }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
6684
6910
  message: "logs: set at most one of folder/url"
6685
6911
  }).refine((v) => v.headers === undefined || v.url !== undefined, {
6686
6912
  message: "logs: headers requires url"
6913
+ }).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
6914
+ message: "logs: readHeaders requires url"
6687
6915
  }).optional()
6688
6916
  });
6689
6917
  var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
@@ -6788,10 +7016,15 @@ function resolveReviewPolicy(config) {
6788
7016
  if (!Number.isInteger(maxRounds) || maxRounds < 1) {
6789
7017
  throw new Error(`vinaya.config.json: reviewPolicy.maxRounds "${maxRounds}" is not a positive integer — fix the config, this never falls back to a default.`);
6790
7018
  }
7019
+ const maxTaskMinutes = raw.maxTaskMinutes ?? DEFAULT_REVIEW_POLICY.maxTaskMinutes;
7020
+ if (!Number.isInteger(maxTaskMinutes) || maxTaskMinutes < 0) {
7021
+ 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.`);
7022
+ }
6791
7023
  return {
6792
7024
  codeReviewThreshold,
6793
7025
  securityThreshold,
6794
- maxRounds
7026
+ maxRounds,
7027
+ maxTaskMinutes
6795
7028
  };
6796
7029
  }
6797
7030
  function resolveGateCutovers(config) {
@@ -6831,17 +7064,12 @@ function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
6831
7064
  return "url" in anchored && anchored.url === local.url ? anchored : null;
6832
7065
  return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
6833
7066
  }
6834
- function resolveLogsHeaderValues(headers, env, readKeychain = readLogHeaderKeychainCredential) {
7067
+ function resolveLogsHeaderValues(headers, env) {
6835
7068
  if (!headers)
6836
7069
  return;
6837
7070
  const resolved = {};
6838
7071
  for (const [key, value] of Object.entries(headers)) {
6839
- resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => {
6840
- const fromEnv = env[name];
6841
- if (fromEnv !== undefined)
6842
- return fromEnv;
6843
- return readKeychain(name) ?? "";
6844
- });
7072
+ resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
6845
7073
  }
6846
7074
  return resolved;
6847
7075
  }
@@ -6850,7 +7078,7 @@ function trustAnchorRepo() {
6850
7078
  if (fromRunner)
6851
7079
  return fromRunner;
6852
7080
  try {
6853
- const url = execFileSync3("git", ["remote", "get-url", "origin"], {
7081
+ const url = execFileSync2("git", ["remote", "get-url", "origin"], {
6854
7082
  encoding: "utf-8",
6855
7083
  stdio: ["ignore", "pipe", "pipe"]
6856
7084
  });
@@ -6897,7 +7125,7 @@ function resolveCiTrustAnchorProbeRef(env = process.env) {
6897
7125
  return ref;
6898
7126
  }
6899
7127
  function readTrustAnchorConfigAtRef(ref) {
6900
- const raw = execFileSync3("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
7128
+ const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
6901
7129
  encoding: "utf-8",
6902
7130
  stdio: ["ignore", "pipe", "pipe"],
6903
7131
  timeout: 1e4
@@ -6911,7 +7139,7 @@ function ghFetchTrustAnchorConfig() {
6911
7139
  const repo = trustAnchorRepo();
6912
7140
  if (!repo)
6913
7141
  throw new Error("could not resolve repo identity for the trust-anchor read");
6914
- return execFileSync3("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
7142
+ return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
6915
7143
  encoding: "utf-8",
6916
7144
  stdio: ["ignore", "pipe", "pipe"]
6917
7145
  });
@@ -7002,7 +7230,7 @@ function loadConfig() {
7002
7230
  var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
7003
7231
 
7004
7232
  // src/lib/brief-assembly.ts
7005
- import { execFileSync as execFileSync6 } from "node:child_process";
7233
+ import { execFileSync as execFileSync5 } from "node:child_process";
7006
7234
  import { existsSync as existsSync4, readFileSync as readFileSync4, readdirSync as readdirSync2 } from "node:fs";
7007
7235
  import { join as join4 } from "node:path";
7008
7236
 
@@ -7154,20 +7382,31 @@ var COMMANDS = [
7154
7382
  {
7155
7383
  flag: "--agent <claude|codex|gemini>",
7156
7384
  description: "Vendor for the developer and both reviewers this run dispatches"
7385
+ },
7386
+ {
7387
+ flag: "--quiet",
7388
+ description: "Hide the detail lines (an agent's prose, full commands, failed-result tails) on the live terminal; the driver log file keeps them"
7157
7389
  }
7158
7390
  ],
7159
7391
  details: [
7160
7392
  "Composes `task brief`'s own preparation (`prepareTask`) with the watching driver (`runDriverLoop`, `dev-review-loop.ts`) — nothing else. Preparation starts no agent; the loop's own round 1 reads the frozen brief off the Issue and is the only place a developer is ever dispatched from a fresh task, so exactly one developer is started by construction.",
7161
7393
  "A brief already frozen on the Issue is reused, never re-posted — the second `task dispatch`/`task brief` call this composes around does not fail the whole run, it just skips straight to running the loop. A task whose Issue refuses preparation (a missing brief section, an unmet dispatch gate) is refused before any agent starts, with nothing posted.",
7162
7394
  "Refuses when the frozen brief's developer branch already has an open pull request AND a driver is still live for it — a driver that crashed or was killed leaves its PR behind, and this command is the one that revives it, in any state, pause held or not.",
7163
- "issue-711 O4: a pause never ends this process — it keeps running and watches the pull request, continuing on its own once a newer Principal ruling appears (or, for an `'infrastructure'`/`'stale_driver'` pause, after a bounded backoff), with no `--resume` command needed for the ordinary case. Exit and printed summary distinguish a published pull request OR a watched pause's own genuine end — merged, closed, or an operator's own `--cancel` (exit `0` either way, the PR URL) — from the one pause this process can never watch (no pull request exists yet — exit `1`, with the exact `vinaya task run <tranche> <n>` command to continue by hand), a usage/argv error (exit `2`), and any other failure (exit `3`)."
7395
+ "issue-711 O4: a pause never ends this process — it keeps running and watches the pull request, continuing on its own once a newer Principal ruling appears (or, for an `'infrastructure'`/`'stale_driver'` pause, after a bounded backoff), with no `--resume` command needed for the ordinary case. Exit and printed summary distinguish a published pull request OR a watched pause's own genuine end — merged, closed, or an operator's own `--cancel` (exit `0` either way, the PR URL) — from the one pause this process can never watch (no pull request exists yet — exit `1`, with the working `vinaya task run` command for this task's own branch to continue by hand — `<tranche> <n>` for a tranche task, `--issue <n>` for a backlog one — never a `dev-review-loop --resume` line naming a pull-request number this pause does not have), a usage/argv error (exit `2`), and any other failure (exit `3`)."
7164
7396
  ],
7165
7397
  status: "shipped"
7166
7398
  },
7167
7399
  {
7168
7400
  name: "task status",
7169
7401
  description: "Every open task with a frozen brief, its pull request, and whether its loop is running, paused, or published",
7170
- flags: [{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }],
7402
+ flags: [
7403
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" },
7404
+ {
7405
+ flag: "--follow",
7406
+ description: "Tail the task's driver log live, with its detail lines, on either the `<tranche> <n>` form or `--issue <n>`"
7407
+ },
7408
+ { flag: "--quiet", description: "With `--follow`, hide the detail lines; the log file is unchanged" }
7409
+ ],
7171
7410
  details: [
7172
7411
  "Read-only: one `gh issue list` for every open task Issue across every tranche (title/label resolved through the same `resolveTaskIssueRef` `list-tasks.ts` already uses), the open pull request per branch, and the driver pid record / pause record / publish effect markers under `<outboxRoot>/dev-review-loop/<task>/` — never a `ps` scan, never a re-parse of posted verdict comments to decide `published`.",
7173
7412
  "`running` names the driver's pid (`review-validity-v1` task 7's pid record); `paused` names the reason from the pause record; `published` means the newest round's reviewer and security verdict effect markers both read `posted`; `no driver` is the fallback when none of the above holds.",
@@ -7203,6 +7442,26 @@ var COMMANDS = [
7203
7442
  ],
7204
7443
  status: "shipped"
7205
7444
  },
7445
+ {
7446
+ name: "task-tools result-proof",
7447
+ description: "Prove, live on this host, that a CLI delivers the Developer's turn result as its own structured final output",
7448
+ flags: [{ flag: "--agent <claude|codex>", description: "The CLI to prove" }],
7449
+ details: [
7450
+ "Runs real Developer-shaped dispatches on this host — the driver-run dev-tools registered and called, the agent's own sandbox where the host supports it, the subscription login, and the dispatch's own argv — and asks for the versioned `DeveloperTurnResult` (`completed`, `blocked` or `needs_ruling`) through the CLI's native structured output: Claude Code `--json-schema` under `--output-format stream-json`, with the dispatch's Stop hook plus one that rejects the first stop; Codex `--output-schema` under `exec --json` and `exec resume --json`.",
7451
+ "Cases: a first and a resumed session (the same provider session, a fresh result, exactly one accepted); a schema-valid but semantically invalid result (an unknown finding id, a ruling request naming no permissible decision), which the driver rejects; malformed output, which never reaches the driver; and a cancelled run, a provider error and context exhaustion, each ending with no accepted result. Each case prints whether a schema-valid result reached the driver, the result, and the event it was read from; exits 1 when any case fails. Never publishes, opens a pull request or writes the forge."
7452
+ ],
7453
+ status: "shipped"
7454
+ },
7455
+ {
7456
+ name: "task-tools review-result-proof",
7457
+ description: "Prove, live on this host, that a CLI delivers a reviewer's result as its own structured final output, concurrent and fresh",
7458
+ flags: [{ flag: "--agent <claude|codex>", description: "The CLI to prove" }],
7459
+ details: [
7460
+ "Runs real reviewer-shaped dispatches on this host — fresh, non-resumed sessions, the agent's own sandbox where the host supports it, the subscription login, read-only grants, and the staged diff and review-input manifest — and asks for the versioned `ReviewResult` (`completed` or `blocked`, bound to the controller's role, head and manifest digest) through the CLI's native structured output: Claude Code `--json-schema` under `--output-format stream-json`; Codex `--output-schema` under `exec --json`. Both the code-reviewer and the security-reviewer role run, concurrently against one manifest, each accepted result attributed to its own role.",
7461
+ "Cases: a role mismatch, a wrong head and a wrong manifest digest; an objective id outside the brief, a severity outside the role's scale and a finding without a file (all refused) and a finding without a line (accepted); and a blocked, malformed, missing, cancelled, provider-error and context-exhausted outcome, each recorded as no review, never approval. Each case prints whether a schema-valid result reached the driver and what the controller made of it; exits 1 when any case fails. Never writes the forge and leaves the loop's reviewer dispatch and result files untouched."
7462
+ ],
7463
+ status: "shipped"
7464
+ },
7206
7465
  {
7207
7466
  name: "pr create",
7208
7467
  description: "Open a pull request after full brief-schema validation",
@@ -7245,13 +7504,14 @@ var COMMANDS = [
7245
7504
  },
7246
7505
  {
7247
7506
  flag: "--push",
7248
- description: "PR number; splices the same content into that PR's LIVE body (fetched from the forge) and pushes it via `gh pr edit`, self-verifying nothing outside the AEG:EVIDENCE/AEG:TOKENS regions changed. Mutually exclusive with --write."
7507
+ description: "PR number; splices the same content into that PR's LIVE body (fetched from the forge) and pushes it via `gh pr edit`, self-verifying nothing outside the AEG:EVIDENCE region changed. Mutually exclusive with --write."
7249
7508
  }
7250
7509
  ],
7251
7510
  details: [
7252
7511
  "Two groups: Group A (recomputable) is the head sha and a width-invariant `git diff --numstat` against the merge-base with `BASE_SHA` (else `origin/main`, then `main`) — `check-evidence-fresh` recomputes and byte-compares this exactly. Group B (attested) is the result of `vinaya check --all --diff-only`, this CLI's own portable gate suite — `check-evidence-fresh` can only check it for staleness (the block's recorded head still matches the PR's real head), never re-run it.",
7253
7512
  "With no `--write`/`--push`, prints the block to stdout instead of writing a file. Exits non-zero whenever the gate run failed, whether or not `--write`/`--push` was given — the block records a failing result rather than hiding one, and a non-zero exit stops a scripted `--write && open-pr` (or `--push`) from carrying a failing suite onto the forge.",
7254
- "`--push` refuses before writing anything when the live body carries no real `AEG:EVIDENCE` pair (it never appends one, unlike `--write`), when the anchor resolves differently before and after normalisation, or when `<pr>` isn't a bare number. When the live body has no real `AEG:TOKENS` pair, the token splice is skipped (same reasoning, softer outcome) rather than creating one. After pushing, it re-reads the live body and restores the pre-edit body — exiting non-zero — if anything outside the two anchored regions changed."
7513
+ "`--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.",
7514
+ "A pull-request body carries no token table, and this command writes none: a dispatched turn's token use is recorded as the Vinaya log's own `usage` event instead. A body that still carries an older run's table keeps it byte for byte — it is prose this command does not own, and a change inside it reads as real drift."
7255
7515
  ],
7256
7516
  status: "shipped"
7257
7517
  },
@@ -7276,7 +7536,7 @@ var COMMANDS = [
7276
7536
  "Deliberately a command, not a check: `evidence-fresh` runs inside `vinaya check --all`, and `pr report` runs `vinaya check --all --diff-only`, so a check that regenerated the block would run the suite containing itself. That recursion is why `evidence-fresh` verifies Group A only and leaves Group B attested.",
7277
7537
  "Must be run from the repository ROOT of a CLEAN checkout at the pull request's head, and refuses otherwise. The regeneration inherits the working directory and several gates resolve their scan root from it, so a subdirectory silently narrows what the fresh run inspects. On cleanliness: Group B is regenerated by diff-scoped checks, so uncommitted or untracked files change which files are scanned and can produce a MATCH a clean checkout would not. Ignored paths are deliberately NOT inspected — `git diff` never reports one, so they cannot change the scope, and including them would refuse in every real checkout since `node_modules` is ignored and always present. The head is read from the forge and both a mismatch AND an unreadable head refuse — the verdict is bound to a commit, never merely attested. `BASE_SHA` is refused as well, since it steers the regeneration's merge-base.",
7278
7538
  "Exits 0 on MATCH; 1 on DIFFERS, HIDDEN, or no block; 2 on a refusal (dirty worktree, wrong head, usage error). HIDDEN means the anchor pair sits inside a collapsed `<details>` block, where `body-bare-digits` blanks every digit and nothing can verify what it claims.",
7279
- "Comparison is a multiset of repo-relative, control-stripped lines: absolute paths (local AND foreign, so a block generated in CI compares against one generated on a laptop) and line order are ignored — a reorder is not a fabrication. Only the AEG:EVIDENCE region is read, since AEG:TOKENS appends by design. A moved merge-base is reported ALONGSIDE the differing lines, never instead of them."
7539
+ "Comparison is a multiset of repo-relative, control-stripped lines: absolute paths (local AND foreign, so a block generated in CI compares against one generated on a laptop) and line order are ignored — a reorder is not a fabrication. Only the AEG:EVIDENCE region is read: every other section of the body is prose no regeneration reproduces. A moved merge-base is reported ALONGSIDE the differing lines, never instead of them."
7280
7540
  ],
7281
7541
  status: "shipped"
7282
7542
  },
@@ -7447,7 +7707,7 @@ var COMMANDS = [
7447
7707
  { flag: "--secrets", description: "security only: the SECRETS line" },
7448
7708
  {
7449
7709
  flag: "--secrets-evidence-file",
7450
- description: 'security only: required whenever `--secrets` claims "none found" — the pasted scanner output backing that claim'
7710
+ description: 'security only: required whenever `--secrets` claims "none found" — the passing `atta-labs/secret-scan` check result on the judged head that backs it; never run or paste the scanner'
7451
7711
  },
7452
7712
  { flag: "--task-id", description: "the closing `Tokens:` line's task id" },
7453
7713
  { flag: "--model", description: "the closing `Tokens:` line's model name" },
@@ -7555,7 +7815,20 @@ var COMMANDS = [
7555
7815
  flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
7556
7816
  details: [
7557
7817
  "Refuses if any task Issue attached to the named tranche is still open, naming each one — closing a tranche with unresolved work is never silently allowed.",
7558
- "Once every task Issue is closed, prompts for confirmation (unless `--yes`) and closes the GitHub Milestone."
7818
+ "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.",
7819
+ "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.",
7820
+ "Idempotent: on a tranche whose Milestone is already closed and carries its retrospective, changes nothing and says it is already archived.",
7821
+ "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."
7822
+ ],
7823
+ status: "shipped"
7824
+ },
7825
+ {
7826
+ name: "archive tranches",
7827
+ description: "Archive every finished tranche that has no closed Milestone carrying its retrospective",
7828
+ flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
7829
+ details: [
7830
+ "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.",
7831
+ "The generated `vinaya-archivist.yml` workflow calls it on its daily scheduled run, so a tranche that finished before the workflow could see it is archived within a day. Running it again when every finished tranche is archived changes nothing and says so."
7559
7832
  ],
7560
7833
  status: "shipped"
7561
7834
  },
@@ -7699,6 +7972,29 @@ var COMMANDS = [
7699
7972
  ],
7700
7973
  status: "shipped"
7701
7974
  },
7975
+ {
7976
+ name: "log selftest",
7977
+ 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)",
7978
+ details: [
7979
+ "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.",
7980
+ "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.",
7981
+ "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."
7982
+ ],
7983
+ status: "shipped"
7984
+ },
7985
+ {
7986
+ name: "log emit",
7987
+ description: "Record a consumer-declared event (`logs.events` in vinaya.config.json) from a script or agent outside Vinaya",
7988
+ flags: [
7989
+ { flag: "--json '<json>'", description: "The field values as one JSON object (else read from standard input)" }
7990
+ ],
7991
+ details: [
7992
+ "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.",
7993
+ "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.",
7994
+ "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)."
7995
+ ],
7996
+ status: "shipped"
7997
+ },
7702
7998
  {
7703
7999
  name: "log send",
7704
8000
  description: "Deliver this repository's locally-held log events to the configured `logs.url` server, once",
@@ -7711,12 +8007,19 @@ var COMMANDS = [
7711
8007
  status: "shipped"
7712
8008
  },
7713
8009
  {
7714
- name: "log set-credential",
7715
- description: "Store a `logs.headers` delivery credential in the macOS login Keychain, read from standard input",
8010
+ name: "sync",
8011
+ description: "Fill, resume and rebuild the local log cache from this repository's configured destination (read-only)",
8012
+ flags: [
8013
+ {
8014
+ flag: "--rebuild",
8015
+ description: "Delete the cache file and sync from the beginning of what the destination still retains"
8016
+ },
8017
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
8018
+ ],
7716
8019
  details: [
7717
- 'For a `logs.url` server whose `headers` reference a credential by variable name (`{ "authorization": "Bearer ${VINAYA_LOG_TOKEN}" }`) on a host where that variable is not in the process environment — the case an Operator the Claude desktop app starts on macOS hits, since the token lives in an interactive shell file the app never reads. It stores the value so header resolution finds it in the Keychain when the environment does not, with no token copied into any settings file.',
7718
- 'The value is read from STANDARD INPUT, never a command-line argument a `ps` listing could show — `printf %s "$TOKEN" | vinaya log set-credential VINAYA_LOG_TOKEN`. Only the variable NAME, which is not a secret, sits on the command line; the value is stored under the Keychain service `Vinaya Log` keyed by that name. The command prints a confirmation naming the variable and never echoes, returns, or logs the value.',
7719
- "macOS only (Linux keyrings are out of scope); it refuses with a clear message elsewhere. The environment still wins over the Keychain wherever the variable is set, so this changes nothing for a host that already exports it."
8020
+ "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.",
8021
+ "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.",
8022
+ "`--rebuild` deletes the cache file ALONE — never anything else under the cache directory — and syncs again from the beginning of what the destination still retains; an event already rotated out of a folder's single backup slot, or no longer retained by the destination, cannot be recovered and shows up as a gap, never silently."
7720
8023
  ],
7721
8024
  status: "shipped"
7722
8025
  }
@@ -7730,13 +8033,13 @@ function createForgeSource(config) {
7730
8033
  };
7731
8034
  }
7732
8035
  // ../../packages/sources/src/select-source.ts
7733
- import { z as z5 } from "zod";
7734
- var StateSourceConfigSchema = z5.discriminatedUnion("kind", [
7735
- z5.object({ kind: z5.literal("forge"), owner: z5.string(), repo: z5.string() }),
7736
- z5.object({ kind: z5.literal("file"), root: z5.string().optional() })
8036
+ import { z as z6 } from "zod";
8037
+ var StateSourceConfigSchema = z6.discriminatedUnion("kind", [
8038
+ z6.object({ kind: z6.literal("forge"), owner: z6.string(), repo: z6.string() }),
8039
+ z6.object({ kind: z6.literal("file"), root: z6.string().optional() })
7737
8040
  ]);
7738
8041
  // src/checks/edge-resolve.ts
7739
- import { execFileSync as execFileSync4 } from "node:child_process";
8042
+ import { execFileSync as execFileSync3 } from "node:child_process";
7740
8043
  var DIRECT_ISSUE_REF = /#(\d+)/;
7741
8044
  var issueCache = new Map;
7742
8045
  function fetchIssueState(num, repo) {
@@ -7745,7 +8048,7 @@ function fetchIssueState(num, repo) {
7745
8048
  return issueCache.get(key) ?? null;
7746
8049
  let out = null;
7747
8050
  try {
7748
- const raw = execFileSync4("gh", [
8051
+ const raw = execFileSync3("gh", [
7749
8052
  "issue",
7750
8053
  "view",
7751
8054
  String(num),
@@ -7871,17 +8174,26 @@ function packageRoot(moduleUrl) {
7871
8174
  }
7872
8175
 
7873
8176
  // src/commands/doctrine.ts
7874
- import { execFileSync as execFileSync5 } from "node:child_process";
8177
+ import { execFileSync as execFileSync4 } from "node:child_process";
7875
8178
  import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3 } from "node:fs";
7876
8179
  import { dirname as dirname3, join as join3, sep } from "node:path";
8180
+ import matter4 from "gray-matter";
8181
+
8182
+ // ../../packages/aeg-core/src/docs/parse-doc.ts
7877
8183
  import matter2 from "gray-matter";
8184
+ // ../../packages/aeg-core/src/docs/surfaced-manifest.ts
8185
+ var NO_MODEL_BACKED_PATHS = new Set;
8186
+ // src/roles/contract.ts
8187
+ import matter3 from "gray-matter";
8188
+
8189
+ // src/commands/doctrine.ts
7878
8190
  var ENTRY_SEGMENTS = ["skills", "aeg", "SKILL.md"];
7879
8191
  function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
7880
8192
  return resolveDoctrineRootInfo(pkg, cwd)?.root ?? null;
7881
8193
  }
7882
8194
  function gitToplevel(cwd) {
7883
8195
  try {
7884
- return execFileSync5("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
8196
+ return execFileSync4("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
7885
8197
  encoding: "utf8",
7886
8198
  stdio: ["ignore", "pipe", "pipe"]
7887
8199
  }).trim();
@@ -7910,7 +8222,7 @@ var PACKAGED_TEMPLATE_PATH = join4(PACKAGE_ROOT, "aeg-root", "templates", "brief
7910
8222
  var TEMPLATE_PATH = existsSync4(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join4(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
7911
8223
  function git(args) {
7912
8224
  try {
7913
- return execFileSync6("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
8225
+ return execFileSync5("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
7914
8226
  } catch {
7915
8227
  return "";
7916
8228
  }
@@ -7923,12 +8235,16 @@ function expandGlob(glob) {
7923
8235
  var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
7924
8236
 
7925
8237
  // src/checks/registry.ts
7926
- import { existsSync as existsSync5 } from "node:fs";
7927
- import { join as join5 } from "node:path";
7928
- var DIST_BIN_DIR = join5(packageRoot(import.meta.url), "dist", "checks", "bin");
7929
- var SRC_BIN_DIR = join5(packageRoot(import.meta.url), "src", "checks", "bin");
7930
- var BIN_DIR = existsSync5(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
7931
- var BIN_EXT = BIN_DIR === DIST_BIN_DIR ? ".js" : ".ts";
8238
+ import { join as join5, relative, sep as sep2 } from "node:path";
8239
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
8240
+ function resolveCheckBin(packageDir, moduleUrl) {
8241
+ const fromPackage = relative(packageDir, fileURLToPath2(moduleUrl));
8242
+ const bundled = fromPackage === "dist" || fromPackage.startsWith(`dist${sep2}`);
8243
+ return bundled ? { dir: join5(packageDir, "dist", "checks", "bin"), ext: ".js" } : { dir: join5(packageDir, "src", "checks", "bin"), ext: ".ts" };
8244
+ }
8245
+ var CHECK_BIN = resolveCheckBin(packageRoot(import.meta.url), import.meta.url);
8246
+ var BIN_DIR = CHECK_BIN.dir;
8247
+ var BIN_EXT = CHECK_BIN.ext;
7932
8248
  function bin(name) {
7933
8249
  return join5(BIN_DIR, `${name}${BIN_EXT}`);
7934
8250
  }
@@ -7972,6 +8288,8 @@ var REGISTRY = [
7972
8288
  timeoutMs: 15000,
7973
8289
  env: {
7974
8290
  BASE_SHA: { optional: true },
8291
+ GIT_INDEX_FILE: { optional: true },
8292
+ VINAYA_COMMIT_HOOK: { optional: true },
7975
8293
  PR_BODY: { optional: true },
7976
8294
  PR_BODY_FILE: { optional: true },
7977
8295
  PR_NUMBER: { optional: true },
@@ -8126,23 +8444,6 @@ var REGISTRY = [
8126
8444
  },
8127
8445
  1
8128
8446
  ],
8129
- [
8130
- {
8131
- name: "token-report",
8132
- validates: "body",
8133
- run: bin("check-token-report"),
8134
- scope: "diff",
8135
- timeoutMs: 15000,
8136
- requiresOpenPr: true,
8137
- env: {
8138
- PR_BODY: { optional: true },
8139
- BRANCH: { optional: true },
8140
- CLAUDE_PROJECT_DIR: { optional: true },
8141
- CLAUDE_CODE_SESSION_ID: { optional: true }
8142
- }
8143
- },
8144
- 1
8145
- ],
8146
8447
  [
8147
8448
  {
8148
8449
  name: "no-disk-state",
@@ -8492,23 +8793,35 @@ var CORE_CHECK_RING = Object.fromEntries(REGISTRY.map(([spec, ring]) => [spec.na
8492
8793
  import { execFile as execFile5 } from "node:child_process";
8493
8794
  import { randomUUID as randomUUID2 } from "node:crypto";
8494
8795
  import {
8495
- closeSync as closeSync3,
8496
- constants as fsConstants3,
8796
+ appendFileSync,
8797
+ closeSync as closeSync4,
8798
+ constants as fsConstants4,
8497
8799
  existsSync as existsSync7,
8498
- fstatSync as fstatSync2,
8499
- mkdirSync as mkdirSync3,
8500
- openSync as openSync3,
8501
- readFileSync as readFileSync6,
8800
+ fstatSync as fstatSync3,
8801
+ mkdirSync as mkdirSync4,
8802
+ lstatSync as lstatSync2,
8803
+ openSync as openSync4,
8804
+ readFileSync as readFileSync7,
8502
8805
  renameSync as renameSync2,
8503
- writeSync as writeSync2
8806
+ writeFileSync as writeFileSync3,
8807
+ writeSync as writeSync3
8504
8808
  } from "node:fs";
8505
8809
  import { hostname as osHostname, homedir as homedir3 } from "node:os";
8506
- import { dirname as dirname6, join as join8 } from "node:path";
8810
+ import { dirname as dirname7, join as join8 } from "node:path";
8507
8811
  import { promisify as promisify5 } from "node:util";
8508
8812
 
8509
8813
  // src/lib/run-paths.ts
8510
- import { chmodSync, existsSync as existsSync6, realpathSync as realpathSync2 } from "node:fs";
8814
+ import { execFileSync as execFileSync6 } from "node:child_process";
8815
+ import { chmodSync, existsSync as existsSync5, realpathSync as realpathSync2 } from "node:fs";
8511
8816
  import { dirname as dirname4, join as join6, resolve as resolvePath } from "node:path";
8817
+ var TASKS_EXECUTION_DIRNAME = "tasks-execution";
8818
+ var RUN_AREA_DIRNAMES = {
8819
+ control: CONTROL_AREA_DIRNAME,
8820
+ sessions: "sessions",
8821
+ hooks: "hooks",
8822
+ output: "output",
8823
+ rounds: "rounds"
8824
+ };
8512
8825
  var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8513
8826
  function isSafeRepoSegment(segment) {
8514
8827
  return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
@@ -8539,12 +8852,52 @@ function isInsideRepo(candidate, repoRoot) {
8539
8852
  const target = resolvePath(candidate);
8540
8853
  return target === root || target.startsWith(`${root}/`);
8541
8854
  }
8855
+ function runPath(runtimeDir, scope, location) {
8856
+ const dir = join6(runtimeDir, TASKS_EXECUTION_DIRNAME, scopeSegment(scope));
8857
+ switch (location.area) {
8858
+ case "task":
8859
+ return location.file ? join6(dir, location.file) : dir;
8860
+ case "control": {
8861
+ const controlDir = join6(dir, RUN_AREA_DIRNAMES.control);
8862
+ return location.file ? join6(controlDir, location.file) : controlDir;
8863
+ }
8864
+ case "rounds":
8865
+ return join6(dir, RUN_AREA_DIRNAMES.rounds);
8866
+ case "round": {
8867
+ const roundDir = join6(dir, RUN_AREA_DIRNAMES.rounds, String(location.round));
8868
+ return location.file ? join6(roundDir, location.file) : roundDir;
8869
+ }
8870
+ case "developer": {
8871
+ const developerDir = join6(dir, RUN_AREA_DIRNAMES.rounds, String(location.round), "developer");
8872
+ return location.file ? join6(developerDir, location.file) : developerDir;
8873
+ }
8874
+ default: {
8875
+ const areaDir = join6(dir, RUN_AREA_DIRNAMES[location.area]);
8876
+ return location.file ? join6(areaDir, location.file) : areaDir;
8877
+ }
8878
+ }
8879
+ }
8880
+ function scopeSegment(scope) {
8881
+ if (scope === "unscoped")
8882
+ return "unscoped";
8883
+ if (typeof scope === "number")
8884
+ return String(scope);
8885
+ return `pr-${scope.pr}`;
8886
+ }
8542
8887
  var UNATTENDED_ENV_KEY = "VINAYA_UNATTENDED";
8543
8888
  var RUNTIME_DIR_ENV_KEY = "VINAYA_RUNTIME_DIR";
8544
8889
  function isUnattendedProcess(env = process.env) {
8545
8890
  return env[UNATTENDED_ENV_KEY] === "1" || (env.VINAYA_ROLE ?? "") !== "";
8546
8891
  }
8547
8892
  var memoized = null;
8893
+ function runtimeDirForRepo(repo) {
8894
+ const key = repoSegment(repo);
8895
+ if (memoized?.key === key)
8896
+ return memoized.value;
8897
+ const value = resolveRuntimeDirUncached(repo);
8898
+ memoized = { key, value };
8899
+ return value;
8900
+ }
8548
8901
  async function runtimeDirForRepoAsync(repo) {
8549
8902
  const key = repoSegment(repo);
8550
8903
  if (memoized?.key === key)
@@ -8560,6 +8913,16 @@ async function runtimeDirForRepoAsync(repo) {
8560
8913
  memoized = { key, value };
8561
8914
  return value;
8562
8915
  }
8916
+ function resolveRuntimeDirUncached(repo) {
8917
+ const inputs = runtimeDirInputs();
8918
+ if (typeof inputs === "string")
8919
+ return inputs;
8920
+ return resolveRuntimeDir({
8921
+ repo,
8922
+ ...inputs.base,
8923
+ trustAnchorConfig: inputs.needsAnchor ? loadTrustAnchorConfig() : null
8924
+ });
8925
+ }
8563
8926
  function runtimeDirInputs() {
8564
8927
  const handedDown = process.env[RUNTIME_DIR_ENV_KEY];
8565
8928
  if (handedDown)
@@ -8579,7 +8942,7 @@ function repoRootSync(start = process.cwd()) {
8579
8942
  return null;
8580
8943
  }
8581
8944
  for (;; ) {
8582
- if (existsSync6(join6(dir, ".git")))
8945
+ if (existsSync5(join6(dir, ".git")))
8583
8946
  return dir;
8584
8947
  const parent = dirname4(dir);
8585
8948
  if (parent === dir)
@@ -8587,26 +8950,94 @@ function repoRootSync(start = process.cwd()) {
8587
8950
  dir = parent;
8588
8951
  }
8589
8952
  }
8953
+ function resolveRepoSync() {
8954
+ const fromEnv = process.env.AEG_REPO;
8955
+ if (fromEnv) {
8956
+ const m = /^([^/]+)\/(.+)$/.exec(fromEnv);
8957
+ if (m?.[1] && m[2])
8958
+ return { owner: m[1], repo: m[2] };
8959
+ }
8960
+ let url;
8961
+ try {
8962
+ url = execFileSync6("git", ["remote", "get-url", "origin"], {
8963
+ encoding: "utf-8",
8964
+ stdio: ["ignore", "pipe", "pipe"]
8965
+ }).trim();
8966
+ } catch {
8967
+ return null;
8968
+ }
8969
+ const ssh = /^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/.exec(url);
8970
+ if (ssh?.[1] && ssh[2])
8971
+ return { owner: ssh[1], repo: ssh[2] };
8972
+ const https = /^https?:\/\/(?:[^@]+@)?github\.com\/([^/]+)\/(.+?)(?:\.git)?\/?$/.exec(url);
8973
+ if (https?.[1] && https[2])
8974
+ return { owner: https[1], repo: https[2] };
8975
+ return null;
8976
+ }
8977
+ var memoizedThisRepo = null;
8978
+ function runtimeDirForThisRepo() {
8979
+ if (memoizedThisRepo !== null)
8980
+ return memoizedThisRepo;
8981
+ memoizedThisRepo = runtimeDirForRepo(resolveRepoSync());
8982
+ return memoizedThisRepo;
8983
+ }
8590
8984
 
8591
- // src/lib/log-webhook-drain.ts
8985
+ // src/lib/loop-log.ts
8592
8986
  import {
8593
8987
  closeSync as closeSync2,
8594
8988
  constants as fsConstants2,
8595
- lstatSync,
8989
+ existsSync as existsSync6,
8990
+ fstatSync as fstatSync2,
8596
8991
  mkdirSync as mkdirSync2,
8597
8992
  openSync as openSync2,
8598
- linkSync,
8599
8993
  readFileSync as readFileSync5,
8600
- renameSync,
8994
+ readSync,
8601
8995
  statSync,
8996
+ writeSync
8997
+ } from "node:fs";
8998
+ import { dirname as dirname5 } from "node:path";
8999
+ function loopsRoot() {
9000
+ return runtimeDirForThisRepo();
9001
+ }
9002
+ function loopLogPathFor(_repo, issue, root = loopsRoot()) {
9003
+ return runPath(root, issue, { area: "output", file: "driver.log" });
9004
+ }
9005
+ var LOOP_LOG_MAX_BYTES = 8 * 1024 * 1024;
9006
+ function appendLoopLogLine(path, line) {
9007
+ try {
9008
+ mkdirSync2(dirname5(path), { recursive: true, mode: 448 });
9009
+ const fd = openSync2(path, fsConstants2.O_WRONLY | fsConstants2.O_APPEND | fsConstants2.O_CREAT | fsConstants2.O_NOFOLLOW, 384);
9010
+ try {
9011
+ const stat = fstatSync2(fd);
9012
+ if (stat.isFile() && stat.size < LOOP_LOG_MAX_BYTES) {
9013
+ writeSync(fd, `${line}
9014
+ `);
9015
+ }
9016
+ } finally {
9017
+ closeSync2(fd);
9018
+ }
9019
+ } catch {}
9020
+ }
9021
+
9022
+ // src/lib/log-webhook-drain.ts
9023
+ import {
9024
+ closeSync as closeSync3,
9025
+ constants as fsConstants3,
9026
+ lstatSync,
9027
+ mkdirSync as mkdirSync3,
9028
+ openSync as openSync3,
9029
+ linkSync,
9030
+ readFileSync as readFileSync6,
9031
+ renameSync,
9032
+ statSync as statSync2,
8602
9033
  unlinkSync,
8603
9034
  utimesSync,
8604
9035
  writeFileSync as writeFileSync2,
8605
- writeSync
9036
+ writeSync as writeSync2
8606
9037
  } from "node:fs";
8607
9038
  import { randomUUID } from "node:crypto";
8608
9039
  import { homedir as homedir2 } from "node:os";
8609
- import { dirname as dirname5, join as join7 } from "node:path";
9040
+ import { dirname as dirname6, join as join7 } from "node:path";
8610
9041
  var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
8611
9042
  var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
8612
9043
  var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
@@ -8622,13 +9053,13 @@ function isEnoent(err) {
8622
9053
  var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
8623
9054
  function tryCreateLock(lockPath, token) {
8624
9055
  try {
8625
- mkdirSync2(dirname5(lockPath), { recursive: true, mode: 448 });
8626
- const fd = openSync2(lockPath, fsConstants2.O_WRONLY | fsConstants2.O_CREAT | fsConstants2.O_EXCL, 384);
9056
+ mkdirSync3(dirname6(lockPath), { recursive: true, mode: 448 });
9057
+ const fd = openSync3(lockPath, fsConstants3.O_WRONLY | fsConstants3.O_CREAT | fsConstants3.O_EXCL, 384);
8627
9058
  try {
8628
- writeSync(fd, `${token}
9059
+ writeSync2(fd, `${token}
8629
9060
  `);
8630
9061
  } finally {
8631
- closeSync2(fd);
9062
+ closeSync3(fd);
8632
9063
  }
8633
9064
  return true;
8634
9065
  } catch (err) {
@@ -8643,7 +9074,7 @@ function acquireDrainLock(lockPath) {
8643
9074
  return token;
8644
9075
  let observedMtimeMs;
8645
9076
  try {
8646
- observedMtimeMs = statSync(lockPath).mtimeMs;
9077
+ observedMtimeMs = statSync2(lockPath).mtimeMs;
8647
9078
  } catch (err) {
8648
9079
  if (!isEnoent(err))
8649
9080
  throw err;
@@ -8661,7 +9092,7 @@ function acquireDrainLock(lockPath) {
8661
9092
  }
8662
9093
  let claimedMtimeMs = null;
8663
9094
  try {
8664
- claimedMtimeMs = statSync(claimed).mtimeMs;
9095
+ claimedMtimeMs = statSync2(claimed).mtimeMs;
8665
9096
  } catch (err) {
8666
9097
  if (!isEnoent(err))
8667
9098
  throw err;
@@ -8687,7 +9118,7 @@ function acquireDrainLock(lockPath) {
8687
9118
  function renewDrainLock(lockPath, token) {
8688
9119
  let holder;
8689
9120
  try {
8690
- holder = readFileSync5(lockPath, "utf8").trim();
9121
+ holder = readFileSync6(lockPath, "utf8").trim();
8691
9122
  } catch (err) {
8692
9123
  if (!isEnoent(err))
8693
9124
  throw err;
@@ -8707,7 +9138,7 @@ function renewDrainLock(lockPath, token) {
8707
9138
  }
8708
9139
  function releaseDrainLock(lockPath, token) {
8709
9140
  try {
8710
- const holder = readFileSync5(lockPath, "utf8").trim();
9141
+ const holder = readFileSync6(lockPath, "utf8").trim();
8711
9142
  if (holder !== token)
8712
9143
  return;
8713
9144
  unlinkSync(lockPath);
@@ -8757,7 +9188,7 @@ function queueLines(buf) {
8757
9188
  return lines;
8758
9189
  }
8759
9190
  function removeQueueHead(path, cut) {
8760
- const remaining = readFileSync5(path);
9191
+ const remaining = readFileSync6(path);
8761
9192
  writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
8762
9193
  }
8763
9194
  function queueBucketSize(path) {
@@ -8778,7 +9209,7 @@ function queueBucketSize(path) {
8778
9209
  function readQueueFile(path) {
8779
9210
  if (queueBucketSize(path) === null)
8780
9211
  return null;
8781
- return readFileSync5(path);
9212
+ return readFileSync6(path);
8782
9213
  }
8783
9214
  function rejectLine(rejectedPath, reason, status, identity, raw) {
8784
9215
  const record = JSON.stringify({
@@ -8960,13 +9391,19 @@ function logsCredentialMissing(headers, env) {
8960
9391
  const varPattern = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
8961
9392
  for (const value of Object.values(headers)) {
8962
9393
  for (const match of value.matchAll(varPattern)) {
8963
- if (!env[match[1]])
8964
- return true;
9394
+ const name = match[1];
9395
+ if (env[name])
9396
+ continue;
9397
+ return true;
8965
9398
  }
8966
9399
  }
8967
9400
  return false;
8968
9401
  }
8969
9402
  function resolveLogDestinationFrom(input) {
9403
+ const spoolDir = input.env.VINAYA_LOG_SPOOL_DIR;
9404
+ if (spoolDir !== undefined && spoolDir.trim() !== "") {
9405
+ return { kind: "folder", folder: spoolDir };
9406
+ }
8970
9407
  const local = resolveLogsSetting(input.localConfig);
8971
9408
  let effective = null;
8972
9409
  let fallbackReason;
@@ -9006,24 +9443,73 @@ function resolveLogDestinationFrom(input) {
9006
9443
  const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
9007
9444
  return fallbackReason ? { kind: "folder", folder, fallbackReason } : { kind: "folder", folder };
9008
9445
  }
9009
- var processTrustAnchorOnce;
9010
- function processTrustAnchor() {
9011
- if (processTrustAnchorOnce === undefined)
9012
- processTrustAnchorOnce = safeLoadTrustAnchorConfig();
9013
- return processTrustAnchorOnce;
9446
+ var processTrustAnchorByRepo = new Map;
9447
+ function processTrustAnchor(repoRoot) {
9448
+ const cached = processTrustAnchorByRepo.get(repoRoot);
9449
+ if (cached !== undefined)
9450
+ return cached;
9451
+ const reading = safeLoadTrustAnchorConfig();
9452
+ processTrustAnchorByRepo.set(repoRoot, reading);
9453
+ return reading;
9014
9454
  }
9015
9455
  async function defaultResolveLogDestination(repo, env) {
9016
9456
  const localConfig = loadConfig();
9017
9457
  const unattended = isUnattendedProcess(process.env);
9458
+ const repoRoot = repoRootSync();
9018
9459
  return resolveLogDestinationFrom({
9019
9460
  localConfig,
9020
- trustAnchorConfig: unattended ? await processTrustAnchor() : null,
9461
+ trustAnchorConfig: unattended ? await processTrustAnchor(repoRoot) : null,
9021
9462
  unattended,
9022
9463
  env,
9023
9464
  defaultFolder: join8(await runtimeDirForRepoAsync(repo), "logs"),
9024
- repoRoot: repoRootSync()
9465
+ repoRoot
9025
9466
  });
9026
9467
  }
9468
+ function unresolvedLogDestination(env) {
9469
+ if (hostFromEnv(env) === "ci") {
9470
+ return {
9471
+ kind: "none",
9472
+ reason: "the process ended before its log destination was resolved, and a CI job never records to a folder"
9473
+ };
9474
+ }
9475
+ const loaded = loadConfig();
9476
+ const localConfig = loaded?.logs?.url !== undefined ? { ...loaded, logs: undefined } : loaded;
9477
+ const unattended = isUnattendedProcess(process.env);
9478
+ const repoRoot = repoRootSync();
9479
+ const runtimeDir = process.env[RUNTIME_DIR_ENV_KEY] || resolveRuntimeDir({ repo: null, localConfig, trustAnchorConfig: null, unattended, repoRoot });
9480
+ const defaultFolder = join8(runtimeDir, "logs");
9481
+ const resolved = resolveLogDestinationFrom({
9482
+ localConfig,
9483
+ trustAnchorConfig: null,
9484
+ unattended,
9485
+ env,
9486
+ defaultFolder,
9487
+ repoRoot
9488
+ });
9489
+ return resolved.kind === "folder" ? resolved : { kind: "folder", folder: defaultFolder };
9490
+ }
9491
+ function folderFallbackStatePath(repo, stateRoot = GLOBAL_VINAYA_HOME) {
9492
+ const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
9493
+ return join8(stateRoot, "fallback", `${dirName}.json`);
9494
+ }
9495
+ function recordFolderFallback(repo, issue, reason, now, runtimeDir, stateRoot = GLOBAL_VINAYA_HOME) {
9496
+ const message = describeFolderFallback(reason);
9497
+ if (issue !== null) {
9498
+ appendLoopLogLine(loopLogPathFor(repo, issue, runtimeDir), `[log] ${message}`);
9499
+ }
9500
+ try {
9501
+ const record = {
9502
+ at: now.toISOString(),
9503
+ reason: message,
9504
+ intendedUrl: reason.intendedUrl,
9505
+ kind: reason.kind
9506
+ };
9507
+ const path = folderFallbackStatePath(repo, stateRoot);
9508
+ mkdirSync4(dirname7(path), { recursive: true, mode: 448 });
9509
+ writeFileSync3(path, `${JSON.stringify(record)}
9510
+ `, { mode: 384 });
9511
+ } catch {}
9512
+ }
9027
9513
  function isEnoent2(err) {
9028
9514
  return typeof err === "object" && err !== null && err.code === "ENOENT";
9029
9515
  }
@@ -9136,7 +9622,7 @@ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
9136
9622
  }
9137
9623
  function readVinayaVersion() {
9138
9624
  try {
9139
- const pkg = JSON.parse(readFileSync6(join8(packageRoot(import.meta.url), "package.json"), "utf8"));
9625
+ const pkg = JSON.parse(readFileSync7(join8(packageRoot(import.meta.url), "package.json"), "utf8"));
9140
9626
  return pkg.version ?? "unknown";
9141
9627
  } catch {
9142
9628
  return "unknown";
@@ -9174,6 +9660,7 @@ function defaultStderr(message) {
9174
9660
  }
9175
9661
  var branchIssueFallbackEnabled = true;
9176
9662
  var branchIssueByCwd = new Map;
9663
+ var branchIssueSettledByCwd = new Map;
9177
9664
  function branchIssueRead(key, read, shared) {
9178
9665
  if (!shared)
9179
9666
  return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
@@ -9182,8 +9669,30 @@ function branchIssueRead(key, read, shared) {
9182
9669
  return cached;
9183
9670
  const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9184
9671
  branchIssueByCwd.set(key, reading);
9672
+ reading.then((value) => branchIssueSettledByCwd.set(key, value));
9673
+ return reading;
9674
+ }
9675
+ var headShaByCwd = new Map;
9676
+ var headShaSettledByCwd = new Map;
9677
+ function headShaRead(key, read, shared) {
9678
+ if (!shared)
9679
+ return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9680
+ const cached = headShaByCwd.get(key);
9681
+ if (cached !== undefined)
9682
+ return cached;
9683
+ const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
9684
+ headShaByCwd.set(key, reading);
9685
+ reading.then((value) => headShaSettledByCwd.set(key, value));
9185
9686
  return reading;
9186
9687
  }
9688
+ async function resolveHeadSha(cwd) {
9689
+ try {
9690
+ const out = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "HEAD"], { encoding: "utf8" })).stdout.trim();
9691
+ return /^[0-9a-f]{40}$/.test(out) ? out : null;
9692
+ } catch {
9693
+ return null;
9694
+ }
9695
+ }
9187
9696
  function defaultDeps() {
9188
9697
  return {
9189
9698
  outboxRoot: () => join8(GLOBAL_VINAYA_HOME, "outbox"),
@@ -9198,29 +9707,30 @@ function defaultDeps() {
9198
9707
  inputVersions: () => {
9199
9708
  return;
9200
9709
  },
9201
- resolveLogDestination: defaultResolveLogDestination
9710
+ resolveLogDestination: defaultResolveLogDestination,
9711
+ unresolvedLogDestination
9202
9712
  };
9203
9713
  }
9204
- var APPEND_OPEN_FLAGS = fsConstants3.O_WRONLY | fsConstants3.O_APPEND | fsConstants3.O_CREAT | fsConstants3.O_NOFOLLOW | fsConstants3.O_NONBLOCK;
9714
+ var APPEND_OPEN_FLAGS = fsConstants4.O_WRONLY | fsConstants4.O_APPEND | fsConstants4.O_CREAT | fsConstants4.O_NOFOLLOW | fsConstants4.O_NONBLOCK;
9205
9715
  function guardedAppendOpen(path) {
9206
9716
  try {
9207
- return openSync3(path, APPEND_OPEN_FLAGS, 384);
9717
+ return openSync4(path, APPEND_OPEN_FLAGS, 384);
9208
9718
  } catch {
9209
9719
  return;
9210
9720
  }
9211
9721
  }
9212
9722
  function appendHardenedLine(path, line) {
9213
9723
  try {
9214
- mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
9724
+ mkdirSync4(dirname7(path), { recursive: true, mode: 448 });
9215
9725
  const fd = guardedAppendOpen(path);
9216
9726
  if (fd === undefined)
9217
9727
  return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
9218
9728
  try {
9219
- if (!fstatSync2(fd).isFile())
9729
+ if (!fstatSync3(fd).isFile())
9220
9730
  return `target is not a regular file: ${path}`;
9221
- writeSync2(fd, line);
9731
+ writeSync3(fd, line);
9222
9732
  } finally {
9223
- closeSync3(fd);
9733
+ closeSync4(fd);
9224
9734
  }
9225
9735
  return null;
9226
9736
  } catch (err) {
@@ -9230,7 +9740,7 @@ function appendHardenedLine(path, line) {
9230
9740
  function reportRotationOverflow(backupPath, warn) {
9231
9741
  let raw;
9232
9742
  try {
9233
- raw = readFileSync6(backupPath, "utf8");
9743
+ raw = readFileSync7(backupPath, "utf8");
9234
9744
  } catch {
9235
9745
  return;
9236
9746
  }
@@ -9253,7 +9763,7 @@ function reportRotationOverflow(backupPath, warn) {
9253
9763
  }
9254
9764
  function appendLine(path, line, warn) {
9255
9765
  try {
9256
- mkdirSync3(dirname6(path), { recursive: true, mode: 448 });
9766
+ mkdirSync4(dirname7(path), { recursive: true, mode: 448 });
9257
9767
  let fd = guardedAppendOpen(path);
9258
9768
  if (fd === undefined) {
9259
9769
  warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
@@ -9262,14 +9772,14 @@ function appendLine(path, line, warn) {
9262
9772
  }
9263
9773
  let closed = false;
9264
9774
  try {
9265
- const stat = fstatSync2(fd);
9775
+ const stat = fstatSync3(fd);
9266
9776
  if (!stat.isFile()) {
9267
9777
  warn(`vinaya: log outbox target is not a regular file — refusing to write: ${path}
9268
9778
  `);
9269
9779
  return;
9270
9780
  }
9271
9781
  if (stat.size > OUTBOX_MAX_BYTES) {
9272
- closeSync3(fd);
9782
+ closeSync4(fd);
9273
9783
  closed = true;
9274
9784
  const backupPath = path.replace(/\.ndjson$/, ".1.ndjson");
9275
9785
  reportRotationOverflow(backupPath, warn);
@@ -9283,10 +9793,10 @@ function appendLine(path, line, warn) {
9283
9793
  fd = rotated;
9284
9794
  closed = false;
9285
9795
  }
9286
- writeSync2(fd, line);
9796
+ writeSync3(fd, line);
9287
9797
  } finally {
9288
9798
  if (!closed)
9289
- closeSync3(fd);
9799
+ closeSync4(fd);
9290
9800
  }
9291
9801
  } catch (err) {
9292
9802
  warn(`vinaya: log outbox write failed — ${err instanceof Error ? err.message : String(err)}
@@ -9297,12 +9807,14 @@ function createLogSink(overrides = {}) {
9297
9807
  const deps = {
9298
9808
  ...defaultDeps(),
9299
9809
  resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
9810
+ resolveHeadSha: () => resolveHeadSha(deps.cwd()),
9300
9811
  ...overrides
9301
9812
  };
9302
9813
  const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
9303
9814
  const processId = randomUUID2();
9304
9815
  let seq = 0;
9305
9816
  let warned = false;
9817
+ let folderFallbackRecorded = false;
9306
9818
  const warnOnce = (message) => {
9307
9819
  if (warned)
9308
9820
  return;
@@ -9320,6 +9832,7 @@ function createLogSink(overrides = {}) {
9320
9832
  };
9321
9833
  const readerIsReal = overrides.resolveBranchIssue === undefined;
9322
9834
  let ownBranchIssue;
9835
+ let ownBranchIssueSettled = null;
9323
9836
  const branchIssueOnce = (repo) => {
9324
9837
  if (!branchIssueFallbackEnabled)
9325
9838
  return Promise.resolve(null);
@@ -9327,10 +9840,36 @@ function createLogSink(overrides = {}) {
9327
9840
  const read = () => deps.resolveBranchIssue(slug);
9328
9841
  if (readerIsReal)
9329
9842
  return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
9330
- if (ownBranchIssue === undefined)
9843
+ if (ownBranchIssue === undefined) {
9331
9844
  ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
9845
+ ownBranchIssue.then((value) => {
9846
+ ownBranchIssueSettled = value;
9847
+ });
9848
+ }
9332
9849
  return ownBranchIssue;
9333
9850
  };
9851
+ const branchIssueIfSettled = (repo) => {
9852
+ if (!branchIssueFallbackEnabled)
9853
+ return null;
9854
+ if (!readerIsReal)
9855
+ return ownBranchIssueSettled;
9856
+ return branchIssueSettledByCwd.get(`${deps.cwd()}\x00${safeRepoSlug(repo) ?? ""}`) ?? null;
9857
+ };
9858
+ const headShaReaderIsReal = overrides.resolveHeadSha === undefined;
9859
+ let ownHeadSha;
9860
+ let ownHeadShaSettled = null;
9861
+ const headShaOnce = () => {
9862
+ if (headShaReaderIsReal)
9863
+ return headShaRead(deps.cwd(), deps.resolveHeadSha, true);
9864
+ if (ownHeadSha === undefined) {
9865
+ ownHeadSha = headShaRead(deps.cwd(), deps.resolveHeadSha, false);
9866
+ ownHeadSha.then((value) => {
9867
+ ownHeadShaSettled = value;
9868
+ });
9869
+ }
9870
+ return ownHeadSha;
9871
+ };
9872
+ const headShaIfSettled = () => headShaReaderIsReal ? headShaSettledByCwd.get(deps.cwd()) ?? null : ownHeadShaSettled;
9334
9873
  let resolveRepoCache;
9335
9874
  const resolveRepoOnce = () => {
9336
9875
  if (resolveRepoCache === undefined)
@@ -9338,6 +9877,7 @@ function createLogSink(overrides = {}) {
9338
9877
  return resolveRepoCache;
9339
9878
  };
9340
9879
  let contextCache;
9880
+ let settledContext;
9341
9881
  const context = () => {
9342
9882
  if (contextCache === undefined) {
9343
9883
  const env = deps.env();
@@ -9346,11 +9886,16 @@ function createLogSink(overrides = {}) {
9346
9886
  doctrine()
9347
9887
  ]).then(async ([resolved, doctrineValue]) => {
9348
9888
  const repo = resolved && isSafeRepoSegment3(resolved.owner) && isSafeRepoSegment3(resolved.repo) ? resolved : null;
9349
- return { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
9889
+ settledContext = { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
9890
+ return settledContext;
9350
9891
  });
9351
9892
  }
9352
9893
  return contextCache;
9353
9894
  };
9895
+ const resetContext = () => {
9896
+ contextCache = undefined;
9897
+ settledContext = undefined;
9898
+ };
9354
9899
  let drainChain = Promise.resolve();
9355
9900
  const pendingWrites = new Set;
9356
9901
  let writeChain = Promise.resolve();
@@ -9362,63 +9907,88 @@ function createLogSink(overrides = {}) {
9362
9907
  `);
9363
9908
  });
9364
9909
  };
9365
- function log(e) {
9366
- try {
9367
- const env = deps.env();
9368
- const host = hostFromEnv(env);
9369
- const now = deps.now();
9370
- const mySeq = seq++;
9371
- const envFields = {
9910
+ const snapshot = () => {
9911
+ const env = deps.env();
9912
+ return {
9913
+ host: hostFromEnv(env),
9914
+ now: deps.now(),
9915
+ seq: seq++,
9916
+ envFields: {
9372
9917
  role: env.VINAYA_ROLE,
9373
9918
  task: env.VINAYA_TASK,
9374
9919
  round: env.VINAYA_ROUND,
9920
+ pr: env.VINAYA_PR,
9375
9921
  run: env.VINAYA_RUN || runId,
9376
9922
  attempt: env.VINAYA_ATTEMPT,
9377
- parent: env.VINAYA_PARENT_EVENT
9378
- };
9379
- const write = async () => {
9380
- const { repo, doctrine: doctrineValue, destination: resolvedDestination } = await context();
9381
- if (resolvedDestination.kind === "none") {
9382
- warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
9923
+ parent: env.VINAYA_PARENT_EVENT,
9924
+ workRef: env.VINAYA_WORK_REF,
9925
+ flow: env.VINAYA_FLOW,
9926
+ flowVersion: env.VINAYA_FLOW_VERSION,
9927
+ runtime: env.VINAYA_RUNTIME,
9928
+ source: env.VINAYA_SOURCE
9929
+ }
9930
+ };
9931
+ };
9932
+ const writeEvent = (e, call, ctx, branchIssue, headSha, deliver) => {
9933
+ const { repo, doctrine: doctrineValue, destination } = ctx;
9934
+ if (destination.kind === "none") {
9935
+ warnOnce(`vinaya: not recording — ${destination.reason}
9383
9936
  `);
9384
- return;
9385
- }
9386
- if (resolvedDestination.kind === "folder" && resolvedDestination.fallbackReason) {
9387
- warnOnce(`vinaya: ${describeFolderFallback(resolvedDestination.fallbackReason)}
9937
+ return;
9938
+ }
9939
+ if (destination.kind === "folder" && destination.fallbackReason) {
9940
+ warnOnce(`vinaya: ${describeFolderFallback(destination.fallbackReason)}
9388
9941
  `);
9389
- }
9390
- const branchIssue = envFields.task ? null : await branchIssueOnce(repo);
9391
- const header = buildHeader({
9392
- now,
9393
- runId,
9394
- seq: mySeq,
9395
- repo: repo ? `${repo.owner}/${repo.repo}` : null,
9396
- vinaya: deps.vinayaVersion(),
9397
- doctrine: doctrineValue,
9398
- host,
9399
- hostname: deps.hostname(),
9400
- env: envFields,
9401
- branchIssue,
9402
- eventId: randomUUID2(),
9403
- processId,
9404
- inputVersions: deps.inputVersions()
9405
- });
9406
- const full = { ...e, ...header };
9407
- const parsed = LogEventSchema.safeParse(full);
9408
- if (!parsed.success) {
9409
- warnOnce(`vinaya: log() refused an invalid payload — ${parsed.error.issues[0]?.message ?? "schema violation"}
9942
+ }
9943
+ const built = buildHeader({
9944
+ now: call.now,
9945
+ runId,
9946
+ seq: call.seq,
9947
+ repo: repo ? `${repo.owner}/${repo.repo}` : null,
9948
+ vinaya: deps.vinayaVersion(),
9949
+ doctrine: doctrineValue,
9950
+ host: call.host,
9951
+ hostname: deps.hostname(),
9952
+ env: call.envFields,
9953
+ branchIssue,
9954
+ eventId: randomUUID2(),
9955
+ processId,
9956
+ inputVersions: deps.inputVersions()
9957
+ });
9958
+ const header = headSha === null ? built : { ...built, subject: { ...built.subject, sha: headSha } };
9959
+ if (destination.kind === "folder" && destination.fallbackReason && !folderFallbackRecorded) {
9960
+ folderFallbackRecorded = true;
9961
+ recordFolderFallback(repo, header.subject.issue, destination.fallbackReason, call.now, dirname7(destination.folder), join8(deps.home(), ".vinaya"));
9962
+ }
9963
+ const full = { ...e, ...header };
9964
+ const parsed = LogEventSchema.safeParse(full);
9965
+ if (!parsed.success) {
9966
+ warnOnce(`vinaya: log() refused an invalid payload — ${parsed.error.issues[0]?.message ?? "schema violation"}
9410
9967
  `);
9411
- return;
9412
- }
9413
- const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
9968
+ return;
9969
+ }
9970
+ const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
9414
9971
  `;
9415
- const destination = resolvedDestination;
9416
- if (destination.kind === "server") {
9417
- appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
9418
- scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
9419
- } else {
9420
- appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
9972
+ if (destination.kind === "server") {
9973
+ appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
9974
+ if (deliver)
9975
+ scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
9976
+ } else {
9977
+ appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
9978
+ }
9979
+ };
9980
+ function log(e) {
9981
+ try {
9982
+ const call = snapshot();
9983
+ const write = async () => {
9984
+ const ctx = await context();
9985
+ if (ctx.destination.kind === "none") {
9986
+ writeEvent(e, call, ctx, null, null, true);
9987
+ return;
9421
9988
  }
9989
+ const branchIssue = call.envFields.task ? null : await branchIssueOnce(ctx.repo);
9990
+ const headSha = e.kind === "gate" ? await headShaOnce() : null;
9991
+ writeEvent(e, call, ctx, branchIssue, headSha, true);
9422
9992
  };
9423
9993
  const written = writeChain.then(write).catch((err) => {
9424
9994
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
@@ -9429,6 +9999,26 @@ function createLogSink(overrides = {}) {
9429
9999
  written.finally(() => pendingWrites.delete(written));
9430
10000
  } catch (err) {
9431
10001
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
10002
+ `);
10003
+ }
10004
+ }
10005
+ function logSync(e, opts = {}) {
10006
+ try {
10007
+ const call = snapshot();
10008
+ let ctx = settledContext;
10009
+ if (ctx === undefined) {
10010
+ const destination = deps.unresolvedLogDestination(deps.env());
10011
+ if (destination.kind === "folder" && !opts.quiet) {
10012
+ 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
10013
+ `);
10014
+ }
10015
+ ctx = { repo: null, doctrine: "unknown", destination };
10016
+ }
10017
+ const branchIssue = ctx.destination.kind === "none" || call.envFields.task ? null : branchIssueIfSettled(ctx.repo);
10018
+ const headSha = e.kind === "gate" && ctx.destination.kind !== "none" ? headShaIfSettled() : null;
10019
+ writeEvent(e, call, ctx, branchIssue, headSha, false);
10020
+ } catch (err) {
10021
+ warnOnce(`vinaya: logSync() failed — ${err instanceof Error ? err.message : String(err)}
9432
10022
  `);
9433
10023
  }
9434
10024
  }
@@ -9449,7 +10039,7 @@ function createLogSink(overrides = {}) {
9449
10039
  return;
9450
10040
  });
9451
10041
  };
9452
- return { log, runId, warmup, drain };
10042
+ return { log, logSync, runId, warmup, drain, resetContext };
9453
10043
  }
9454
10044
  var defaultSink = createLogSink();
9455
10045
 
@@ -9575,7 +10165,7 @@ function findingsInThisDiff(findings) {
9575
10165
  const abs = resolve2(diff.root, f.file);
9576
10166
  if (!changed.has(abs))
9577
10167
  return false;
9578
- const relPath = relative(diff.root, abs);
10168
+ const relPath = relative2(diff.root, abs);
9579
10169
  if (!ranges.has(relPath))
9580
10170
  ranges.set(relPath, changedLineRanges(diff.base, relPath));
9581
10171
  const fileRanges = ranges.get(relPath) ?? null;
@@ -9602,7 +10192,7 @@ function indexMode(path) {
9602
10192
  }
9603
10193
  function hasShebang(path) {
9604
10194
  try {
9605
- return readFileSync7(path, "utf8").startsWith("#!");
10195
+ return readFileSync8(path, "utf8").startsWith("#!");
9606
10196
  } catch {
9607
10197
  return false;
9608
10198
  }