@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
@@ -1,27 +1,27 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/lib/pre-push-cache-test-run.ts
4
- import { readFileSync as readFileSync8 } from "node:fs";
4
+ import { readFileSync as readFileSync9 } from "node:fs";
5
5
 
6
6
  // src/lib/pr-report-engine.ts
7
7
  import { execFile as execFile6 } from "node:child_process";
8
8
  import { createHash as createHash2, randomUUID as randomUUID3 } from "node:crypto";
9
9
  import {
10
- closeSync as closeSync5,
11
- constants as fsConstants5,
10
+ closeSync as closeSync6,
11
+ constants as fsConstants6,
12
12
  existsSync as existsSync8,
13
13
  fsyncSync as fsyncSync2,
14
- lstatSync as lstatSync3,
14
+ lstatSync as lstatSync4,
15
15
  mkdtempSync,
16
- openSync as openSync5,
17
- readFileSync as readFileSync7,
16
+ openSync as openSync6,
17
+ readFileSync as readFileSync8,
18
18
  renameSync as renameSync4,
19
19
  rmSync,
20
- writeFileSync as writeFileSync3,
21
- writeSync as writeSync4
20
+ writeFileSync as writeFileSync4,
21
+ writeSync as writeSync5
22
22
  } from "node:fs";
23
23
  import { hostname, tmpdir } from "node:os";
24
- import { dirname as dirname7, join as join9, resolve as resolvePath2 } from "node:path";
24
+ import { dirname as dirname8, join as join9, resolve as resolvePath2 } from "node:path";
25
25
  import { promisify as promisify6 } from "node:util";
26
26
  // ../../packages/aeg-forge-state/src/gh.ts
27
27
  import { execFile, execFileSync } from "node:child_process";
@@ -498,6 +498,8 @@ var FILE_EXTENSIONS = new Set([
498
498
  "html",
499
499
  "css"
500
500
  ]);
501
+ var CI_SHARD_DIR = "apps/cli/tests/ci-shards";
502
+ var CI_SHARD_PROBE = `${CI_SHARD_DIR}/shard-1.txt`;
501
503
 
502
504
  // ../../packages/aeg-core/src/coherence-checks.ts
503
505
  var R1_GRANDFATHERED_ISSUES = new Set([279, 280, 281, 282]);
@@ -677,7 +679,6 @@ var TaskPrPauseSchema = z.object({
677
679
  var TaskPrReviewRecordSchema = z.object({
678
680
  verdicts: z.array(TaskPrVerdictSchema),
679
681
  roundMarkers: z.array(z.number().int().nonnegative()),
680
- summaryTable: z.string().nullable(),
681
682
  pause: TaskPrPauseSchema.nullable()
682
683
  });
683
684
  var TaskPrReadInputSchema = z.object({
@@ -724,26 +725,71 @@ var TaskCancelResultSchema = z.object({
724
725
  authenticatedFrom: z.string().min(1),
725
726
  fencedEffectKeys: z.array(z.string())
726
727
  });
727
- var TASK_TOOL_NAMES = [
728
- "task_start",
729
- "task_status",
730
- "task_escalation_read",
731
- "task_pr_read",
732
- "task_resume",
733
- "task_cancel"
734
- ];
735
- var OPERATOR_STATUS_FOLLOW = "task_status_follow";
736
- var OPERATOR_TOOL_GRANT = [...TASK_TOOL_NAMES, OPERATOR_STATUS_FOLLOW];
737
- // ../../packages/aeg-core/src/dev-review-loop/types.ts
738
- var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
739
- // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
740
- var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
741
- // ../../packages/aeg-core/src/log/envelope.ts
742
- import { createHash } from "node:crypto";
743
-
744
728
  // ../../packages/aeg-core/src/log/schema.ts
729
+ import { z as z3 } from "zod";
730
+
731
+ // ../../packages/aeg-core/src/log/custom.ts
745
732
  import { z as z2 } from "zod";
733
+ var CUSTOM_EVENT_NAME_PATTERN = /^[a-z][a-z0-9_]*\.[a-z][a-z0-9_.]*$/;
734
+ var CUSTOM_EVENT_NAME_MAX_LENGTH = 64;
735
+ var CUSTOM_EVENT_RESERVED_NAMESPACE = "vinaya";
736
+ var CUSTOM_EVENT_MAX_FIELDS = 20;
737
+ var CUSTOM_FIELD_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
738
+ var CUSTOM_FIELD_NAME_MAX_LENGTH = 64;
739
+ var CUSTOM_TEXT_MAX_LENGTH = 500;
740
+ var CUSTOM_WORD_PATTERN = /^[a-z0-9][a-z0-9_-]*$/;
741
+ var CUSTOM_WORD_MAX_LENGTH = 64;
742
+ var CUSTOM_FIELD_MAX_WORDS = 50;
743
+ var CustomFieldTypeSchema = z2.union([z2.enum(["text", "number", "boolean"]), z2.array(z2.string())]);
744
+ var CustomEventDeclarationsSchema = z2.record(z2.string(), z2.object({
745
+ fields: z2.record(z2.string(), CustomFieldTypeSchema)
746
+ }).strict()).superRefine((events, ctx) => {
747
+ for (const [name, declaration] of Object.entries(events)) {
748
+ const refuse = (message, path = []) => {
749
+ ctx.addIssue({
750
+ code: z2.ZodIssueCode.custom,
751
+ path: [name, ...path],
752
+ message: `logs.events "${name}": ${message}`
753
+ });
754
+ };
755
+ if (name.length > CUSTOM_EVENT_NAME_MAX_LENGTH) {
756
+ refuse(`the name must be at most ${CUSTOM_EVENT_NAME_MAX_LENGTH} characters`);
757
+ }
758
+ if (!CUSTOM_EVENT_NAME_PATTERN.test(name)) {
759
+ refuse("the name must be `<namespace>.<event>` — lowercase letters, digits and `_`, a dot between them");
760
+ } else if (name.split(".")[0] === CUSTOM_EVENT_RESERVED_NAMESPACE) {
761
+ refuse(`the \`${CUSTOM_EVENT_RESERVED_NAMESPACE}.\` namespace is reserved for Vinaya's own events`);
762
+ }
763
+ const fieldEntries = Object.entries(declaration.fields);
764
+ if (fieldEntries.length > CUSTOM_EVENT_MAX_FIELDS) {
765
+ refuse(`at most ${CUSTOM_EVENT_MAX_FIELDS} fields may be declared (found ${fieldEntries.length})`, ["fields"]);
766
+ }
767
+ for (const [field, type] of fieldEntries) {
768
+ if (field.length > CUSTOM_FIELD_NAME_MAX_LENGTH || !CUSTOM_FIELD_NAME_PATTERN.test(field)) {
769
+ 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]);
770
+ }
771
+ if (typeof type === "string")
772
+ continue;
773
+ if (type.length === 0) {
774
+ refuse(`field "${field}": a list of words must name at least one word`, ["fields", field]);
775
+ }
776
+ if (type.length > CUSTOM_FIELD_MAX_WORDS) {
777
+ refuse(`field "${field}": a list of words may name at most ${CUSTOM_FIELD_MAX_WORDS}`, ["fields", field]);
778
+ }
779
+ const bad = type.filter((w) => w.length > CUSTOM_WORD_MAX_LENGTH || !CUSTOM_WORD_PATTERN.test(w));
780
+ if (bad.length > 0) {
781
+ refuse(`field "${field}": a listed word is lowercase letters, digits, \`_\` and \`-\`, at most ${CUSTOM_WORD_MAX_LENGTH} characters`, ["fields", field]);
782
+ }
783
+ if (new Set(type).size !== type.length) {
784
+ refuse(`field "${field}": a list of words names a word twice`, ["fields", field]);
785
+ }
786
+ }
787
+ }
788
+ });
789
+
790
+ // ../../packages/aeg-core/src/log/schema.ts
746
791
  var CONFIDENCE_REASON_MAX_LENGTH = 280;
792
+ var REVIEW_FINDING_DESCRIPTION_MAX_LENGTH = 1000;
747
793
  var ROLE_VALUES = [
748
794
  "planner",
749
795
  "developer",
@@ -753,178 +799,214 @@ var ROLE_VALUES = [
753
799
  "archivist",
754
800
  "architect"
755
801
  ];
756
- var RoleSchema = z2.enum(ROLE_VALUES);
802
+ var RoleSchema = z3.enum(ROLE_VALUES);
757
803
  var HOST_VALUES = ["hook", "ci", "cli", "loop"];
758
- var HostSchema = z2.enum(HOST_VALUES);
804
+ var HostSchema = z3.enum(HOST_VALUES);
759
805
  var RUN_ID_PATTERN = /^[A-Za-z0-9_.-]{1,128}$/;
760
806
  var headerMetaCore = {
761
- ts: z2.string(),
762
- run_id: z2.string().regex(RUN_ID_PATTERN),
763
- seq: z2.number().int().nonnegative(),
764
- repo: z2.string().nullable(),
765
- vinaya: z2.string(),
766
- doctrine: z2.string(),
807
+ ts: z3.string(),
808
+ run_id: z3.string().regex(RUN_ID_PATTERN),
809
+ seq: z3.number().int().nonnegative(),
810
+ repo: z3.string().nullable(),
811
+ vinaya: z3.string(),
812
+ doctrine: z3.string(),
767
813
  host: HostSchema,
768
- machine: z2.string()
814
+ machine: z3.string()
769
815
  };
770
- var HeaderMetaV1Schema = z2.object({
771
- schema: z2.literal(1),
816
+ var HeaderMetaV1Schema = z3.object({
817
+ schema: z3.literal(1),
772
818
  ...headerMetaCore
773
819
  }).strict();
774
- var LineageSchema = z2.object({
775
- run: z2.string().nullable(),
776
- attempt: z2.number().int().nullable(),
777
- parent: z2.string().nullable()
820
+ var LineageSchema = z3.object({
821
+ run: z3.string().nullable(),
822
+ attempt: z3.number().int().nullable(),
823
+ parent: z3.string().nullable()
778
824
  }).strict();
779
- var InputVersionsSchema = z2.object({
780
- objectives_version: z2.string().nullable(),
781
- brief_hash: z2.string().nullable(),
782
- ruling_ordinal: z2.number().int().nullable(),
783
- policy_digest: z2.string().nullable()
825
+ var InputVersionsSchema = z3.object({
826
+ objectives_version: z3.string().nullable(),
827
+ brief_hash: z3.string().nullable(),
828
+ ruling_ordinal: z3.number().int().nullable(),
829
+ policy_digest: z3.string().nullable()
784
830
  }).strict();
785
- var ProvenanceSchema = z2.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
786
- var HeaderMetaV2Schema = z2.object({
787
- schema: z2.literal(2),
831
+ var ProvenanceSchema = z3.enum(["parent_attributed", "env_correlated", "self_reported", "unavailable"]);
832
+ var HeaderMetaV2Schema = z3.object({
833
+ schema: z3.literal(2),
788
834
  ...headerMetaCore,
789
- event_id: z2.string().min(1),
790
- process_id: z2.string().min(1),
791
- actor_id: z2.string().nullable(),
835
+ event_id: z3.string().min(1),
836
+ process_id: z3.string().min(1),
837
+ actor_id: z3.string().nullable(),
792
838
  lineage: LineageSchema,
793
839
  input_versions: InputVersionsSchema,
794
840
  provenance: ProvenanceSchema
795
841
  }).strict();
796
- var HeaderMetaSchema = z2.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema]);
797
- var SubjectSchema = z2.object({
798
- issue: z2.number().int().nullable(),
799
- pr: z2.number().int().optional(),
800
- sha: z2.string().optional(),
801
- role: z2.union([RoleSchema, z2.literal("unattributed")]),
802
- round: z2.number().int().optional(),
803
- objectives_version: z2.string().optional()
842
+ var WorkSchema = z3.object({
843
+ ref: z3.string().nullable(),
844
+ repo: z3.string().nullable(),
845
+ change: z3.string().nullable(),
846
+ revision: z3.string().nullable()
847
+ }).strict();
848
+ var FlowSchema = z3.object({
849
+ id: z3.string().nullable(),
850
+ version: z3.string().nullable()
851
+ }).strict();
852
+ var HeaderMetaV3Schema = z3.object({
853
+ schema: z3.literal(3),
854
+ ...headerMetaCore,
855
+ event_id: z3.string().min(1),
856
+ process_id: z3.string().min(1),
857
+ actor_id: z3.string().nullable(),
858
+ lineage: LineageSchema,
859
+ input_versions: InputVersionsSchema,
860
+ provenance: ProvenanceSchema,
861
+ work: WorkSchema,
862
+ flow: FlowSchema,
863
+ runtime: z3.string().nullable(),
864
+ source: z3.string().nullable()
804
865
  }).strict();
805
- var HeaderSchema = z2.object({
866
+ var HeaderMetaSchema = z3.discriminatedUnion("schema", [HeaderMetaV1Schema, HeaderMetaV2Schema, HeaderMetaV3Schema]);
867
+ var SubjectSchema = z3.object({
868
+ issue: z3.number().int().nullable(),
869
+ pr: z3.number().int().optional(),
870
+ sha: z3.string().optional(),
871
+ role: z3.union([RoleSchema, z3.literal("unattributed")]),
872
+ round: z3.number().int().optional(),
873
+ objectives_version: z3.string().optional()
874
+ }).strict();
875
+ var HeaderSchema = z3.object({
806
876
  meta: HeaderMetaSchema,
807
877
  subject: SubjectSchema
808
878
  }).strict();
809
879
  var envelopeTail = {
810
- duration_ms: z2.number().nonnegative().optional(),
811
- payload: z2.object({}).strict()
880
+ duration_ms: z3.number().nonnegative().optional(),
881
+ payload: z3.object({}).strict()
812
882
  };
813
- var ReviewFindingSchema = z2.object({
814
- id: z2.string(),
815
- severity: z2.string(),
816
- state: z2.string().optional(),
817
- severity_scale: z2.string().optional(),
818
- policy_treatment: z2.enum(["blocking", "non_blocking", "unavailable"]).optional(),
819
- confidence: z2.number().min(0).max(1).optional(),
820
- confidence_scale: z2.string().optional(),
821
- confidence_source: z2.string().optional()
883
+ var ReviewFindingSchema = z3.object({
884
+ id: z3.string(),
885
+ severity: z3.string(),
886
+ location: z3.string().optional(),
887
+ deferral_reason: z3.enum(["outside-surface", "unchanged-line"]).optional(),
888
+ description: z3.string().max(REVIEW_FINDING_DESCRIPTION_MAX_LENGTH).optional(),
889
+ state: z3.string().optional(),
890
+ severity_scale: z3.string().optional(),
891
+ policy_treatment: z3.enum(["blocking", "non_blocking", "unavailable"]).optional(),
892
+ confidence: z3.number().min(0).max(1).optional(),
893
+ confidence_scale: z3.string().optional(),
894
+ confidence_source: z3.string().optional()
822
895
  }).strict();
823
- var DispatchOutcomeSchema = z2.discriminatedUnion("type", [
824
- z2.object({ type: z2.literal("pr_opened"), pr: z2.number().int(), head: z2.string() }).strict(),
825
- z2.object({
826
- type: z2.literal("round_pushed"),
827
- pr: z2.number().int(),
828
- head: z2.string(),
829
- comment_id: z2.number().int()
896
+ var DispatchOutcomeSchema = z3.discriminatedUnion("type", [
897
+ z3.object({ type: z3.literal("pr_opened"), pr: z3.number().int(), head: z3.string() }).strict(),
898
+ z3.object({
899
+ type: z3.literal("round_pushed"),
900
+ pr: z3.number().int(),
901
+ head: z3.string(),
902
+ comment_id: z3.number().int()
830
903
  }).strict(),
831
- z2.object({
832
- type: z2.literal("verdict"),
833
- verdict: z2.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
834
- head: z2.string(),
835
- comment_id: z2.number().int(),
836
- objectives: z2.array(z2.object({ id: z2.string(), met: z2.boolean() }).strict()),
837
- findings: z2.array(ReviewFindingSchema)
904
+ z3.object({
905
+ type: z3.literal("verdict"),
906
+ verdict: z3.enum(["APPROVE", "REQUEST CHANGES", "PASS", "FAIL"]),
907
+ head: z3.string(),
908
+ comment_id: z3.number().int(),
909
+ objectives: z3.array(z3.object({ id: z3.string(), met: z3.boolean() }).strict()),
910
+ findings: z3.array(ReviewFindingSchema)
838
911
  }).strict(),
839
- z2.object({
840
- type: z2.literal("escalation"),
841
- class: z2.enum(["authority", "strategy", "product"]),
842
- comment_id: z2.number().int()
912
+ z3.object({
913
+ type: z3.literal("escalation"),
914
+ class: z3.enum(["authority", "strategy", "product"]),
915
+ comment_id: z3.number().int()
843
916
  }).strict(),
844
- z2.object({ type: z2.literal("brief"), comment_id: z2.number().int(), hash: z2.string() }).strict(),
845
- z2.object({ type: z2.literal("plan"), issues: z2.array(z2.number().int()) }).strict(),
846
- z2.object({ type: z2.literal("archive"), provenance_comment_id: z2.number().int() }).strict(),
847
- z2.object({ type: z2.literal("completed") }).strict()
917
+ z3.object({ type: z3.literal("brief"), comment_id: z3.number().int(), hash: z3.string() }).strict(),
918
+ z3.object({ type: z3.literal("plan"), issues: z3.array(z3.number().int()) }).strict(),
919
+ z3.object({ type: z3.literal("archive"), provenance_comment_id: z3.number().int() }).strict(),
920
+ z3.object({ type: z3.literal("completed") }).strict()
848
921
  ]);
849
922
  var dispatchShared = {
850
923
  meta: HeaderMetaSchema,
851
924
  subject: SubjectSchema,
852
- kind: z2.literal("dispatch"),
925
+ kind: z3.literal("dispatch"),
853
926
  ...envelopeTail,
854
927
  target_role: RoleSchema,
855
- model: z2.string(),
856
- round: z2.number().int().optional(),
857
- effect_id: z2.string()
928
+ model: z3.string(),
929
+ round: z3.number().int().optional(),
930
+ effect_id: z3.string()
858
931
  };
859
- var dispatchUsageField = z2.object({ input: z2.number().nonnegative(), output: z2.number().nonnegative() }).strict().nullable();
860
- var DispatchEventSchema = z2.discriminatedUnion("event", [
861
- z2.object({ ...dispatchShared, event: z2.literal("dispatched"), prompt_hash: z2.string() }).strict(),
862
- z2.object({
932
+ var dispatchUsageField = z3.object({ input: z3.number().nonnegative(), output: z3.number().nonnegative() }).strict().nullable();
933
+ var DispatchEventSchema = z3.discriminatedUnion("event", [
934
+ z3.object({ ...dispatchShared, event: z3.literal("dispatched"), prompt_hash: z3.string() }).strict(),
935
+ z3.object({
863
936
  ...dispatchShared,
864
- event: z2.literal("outcome_received"),
937
+ event: z3.literal("outcome_received"),
865
938
  outcome: DispatchOutcomeSchema,
866
939
  usage: dispatchUsageField
867
940
  }).strict(),
868
- z2.object({
941
+ z3.object({
869
942
  ...dispatchShared,
870
- event: z2.literal("dispatch_failed"),
871
- reason: z2.enum(["timeout", "crash", "refused", "unattributed_write"]),
943
+ event: z3.literal("dispatch_failed"),
944
+ reason: z3.enum(["timeout", "crash", "refused", "unattributed_write", "usage_limit"]),
945
+ usage_limit: z3.object({ agent: z3.string().min(1), reset_at: z3.string().nullable() }).strict().optional(),
872
946
  usage: dispatchUsageField
873
947
  }).strict()
874
948
  ]);
949
+ var CODE_TOKEN_PATTERN = /^[A-Za-z0-9._-]{1,64}$/;
950
+ var CodeTokenSchema = z3.string().regex(CODE_TOKEN_PATTERN);
951
+ var ReviewerVerdictSchema = z3.object({
952
+ role: RoleSchema,
953
+ outcome: z3.enum(["approve", "changes_requested", "not_reviewed"]),
954
+ blockers: z3.number().int().nonnegative()
955
+ }).strict();
875
956
  var loopShared = {
876
957
  meta: HeaderMetaSchema,
877
958
  subject: SubjectSchema,
878
- kind: z2.literal("dev_review_loop"),
959
+ kind: z3.literal("dev_review_loop"),
879
960
  ...envelopeTail,
880
- loop_id: z2.string()
961
+ loop_id: z3.string()
881
962
  };
882
- var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
883
- z2.object({
963
+ var DevReviewLoopEventSchema = z3.discriminatedUnion("event", [
964
+ z3.object({
884
965
  ...loopShared,
885
- event: z2.literal("loop_started"),
886
- task: z2.number().int(),
887
- policy: z2.object({
888
- max_rounds: z2.number().int().nonnegative(),
889
- reviewers: z2.array(RoleSchema),
890
- models: z2.record(RoleSchema, z2.string())
966
+ event: z3.literal("loop_started"),
967
+ task: z3.number().int(),
968
+ policy: z3.object({
969
+ max_rounds: z3.number().int().nonnegative(),
970
+ reviewers: z3.array(RoleSchema),
971
+ models: z3.record(RoleSchema, z3.string())
891
972
  }).strict()
892
973
  }).strict(),
893
- z2.object({ ...loopShared, event: z2.literal("round_started"), round: z2.number().int(), base_head: z2.string() }).strict(),
894
- z2.object({
974
+ z3.object({ ...loopShared, event: z3.literal("round_started"), round: z3.number().int(), base_head: z3.string() }).strict(),
975
+ z3.object({
895
976
  ...loopShared,
896
- event: z2.literal("gate_result_read"),
897
- round: z2.number().int(),
898
- head: z2.string(),
899
- green: z2.boolean(),
900
- confidence_value: z2.number().int().min(0).max(100).optional(),
901
- confidence_reason: z2.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
902
- confidence_unavailable: z2.boolean().optional(),
903
- extra_turn_spent: z2.boolean().optional()
977
+ event: z3.literal("gate_result_read"),
978
+ round: z3.number().int(),
979
+ head: z3.string(),
980
+ green: z3.boolean(),
981
+ confidence_value: z3.number().int().min(0).max(100).optional(),
982
+ confidence_reason: z3.string().max(CONFIDENCE_REASON_MAX_LENGTH).optional(),
983
+ confidence_unavailable: z3.boolean().optional(),
984
+ extra_turn_spent: z3.boolean().optional()
904
985
  }).strict(),
905
- z2.object({
986
+ z3.object({
906
987
  ...loopShared,
907
- event: z2.literal("verdicts_read"),
908
- round: z2.number().int(),
909
- head: z2.string(),
910
- all_approve: z2.boolean(),
911
- blockers: z2.number().int().nonnegative(),
912
- findings: z2.array(ReviewFindingSchema).optional()
988
+ event: z3.literal("verdicts_read"),
989
+ round: z3.number().int(),
990
+ head: z3.string(),
991
+ all_approve: z3.boolean(),
992
+ blockers: z3.number().int().nonnegative(),
993
+ findings: z3.array(ReviewFindingSchema).optional(),
994
+ reviewers: z3.array(ReviewerVerdictSchema).optional()
913
995
  }).strict(),
914
- z2.object({
996
+ z3.object({
915
997
  ...loopShared,
916
- event: z2.literal("findings_compared"),
917
- round: z2.number().int(),
918
- open: z2.array(z2.string()),
919
- resolved: z2.array(z2.string()),
920
- new: z2.array(z2.string()),
921
- recurring: z2.array(z2.string())
998
+ event: z3.literal("findings_compared"),
999
+ round: z3.number().int(),
1000
+ open: z3.array(z3.string()),
1001
+ resolved: z3.array(z3.string()),
1002
+ new: z3.array(z3.string()),
1003
+ recurring: z3.array(z3.string())
922
1004
  }).strict(),
923
- z2.object({
1005
+ z3.object({
924
1006
  ...loopShared,
925
- event: z2.literal("stop_condition_met"),
926
- round: z2.number().int(),
927
- condition: z2.enum([
1007
+ event: z3.literal("stop_condition_met"),
1008
+ round: z3.number().int(),
1009
+ condition: z3.enum([
928
1010
  "green",
929
1011
  "max_rounds",
930
1012
  "no_progress",
@@ -933,66 +1015,85 @@ var DevReviewLoopEventSchema = z2.discriminatedUnion("event", [
933
1015
  "confidence",
934
1016
  "reappearance",
935
1017
  "repeat_finding",
936
- "repeat_failure"
1018
+ "repeat_failure",
1019
+ "time_budget"
937
1020
  ])
938
1021
  }).strict(),
939
- z2.object({
1022
+ z3.object({
940
1023
  ...loopShared,
941
- event: z2.literal("paused"),
942
- round: z2.number().int(),
943
- reason: z2.enum(["escalation", "principal_item", "refreeze_needed"])
1024
+ event: z3.literal("paused"),
1025
+ round: z3.number().int(),
1026
+ reason: z3.enum(["escalation", "principal_item", "refreeze_needed"]),
1027
+ reason_code: CodeTokenSchema.optional()
944
1028
  }).strict(),
945
- z2.object({
1029
+ z3.object({
946
1030
  ...loopShared,
947
- event: z2.literal("resumed"),
948
- round: z2.number().int(),
949
- by: z2.enum(["principal", "driver"])
1031
+ event: z3.literal("resumed"),
1032
+ round: z3.number().int(),
1033
+ by: z3.enum(["principal", "driver"])
950
1034
  }).strict(),
951
- z2.object({
1035
+ z3.object({
952
1036
  ...loopShared,
953
- event: z2.literal("cancelled"),
954
- round: z2.number().int(),
955
- by: z2.literal("principal")
1037
+ event: z3.literal("cancelled"),
1038
+ round: z3.number().int(),
1039
+ by: z3.literal("principal")
956
1040
  }).strict(),
957
- z2.object({
1041
+ z3.object({
958
1042
  ...loopShared,
959
- event: z2.literal("unpushed_work_resume"),
960
- round: z2.number().int(),
961
- branch: z2.string(),
962
- detail: z2.string()
1043
+ event: z3.literal("unpushed_work_resume"),
1044
+ round: z3.number().int(),
1045
+ branch: z3.string(),
1046
+ detail: z3.string()
963
1047
  }).strict(),
964
- z2.object({
1048
+ z3.object({
965
1049
  ...loopShared,
966
- event: z2.literal("round_ended"),
967
- round: z2.number().int(),
968
- base_head: z2.string(),
969
- head: z2.string(),
970
- files_changed: z2.number().int().nonnegative(),
971
- insertions: z2.number().int().nonnegative(),
972
- deletions: z2.number().int().nonnegative(),
973
- wall_ms: z2.number().nonnegative(),
974
- outcome: z2.enum(["green", "changes_requested", "escalated"])
1050
+ event: z3.literal("round_ended"),
1051
+ round: z3.number().int(),
1052
+ base_head: z3.string(),
1053
+ head: z3.string(),
1054
+ files_changed: z3.number().int().nonnegative(),
1055
+ insertions: z3.number().int().nonnegative(),
1056
+ deletions: z3.number().int().nonnegative(),
1057
+ wall_ms: z3.number().nonnegative(),
1058
+ outcome: z3.enum(["green", "changes_requested", "escalated"])
975
1059
  }).strict(),
976
- z2.object({
1060
+ z3.object({
977
1061
  ...loopShared,
978
- event: z2.literal("journal_finalized"),
979
- rounds: z2.number().int().nonnegative(),
980
- total_wall_ms: z2.number().nonnegative(),
981
- time_to_green_ms: z2.number().nonnegative().nullable(),
982
- files_changed_total: z2.number().int().nonnegative(),
983
- final_head: z2.string(),
984
- result: z2.enum(["merged_ready", "stopped"])
1062
+ event: z3.literal("journal_finalized"),
1063
+ rounds: z3.number().int().nonnegative(),
1064
+ total_wall_ms: z3.number().nonnegative(),
1065
+ time_to_green_ms: z3.number().nonnegative().nullable(),
1066
+ files_changed_total: z3.number().int().nonnegative(),
1067
+ final_head: z3.string(),
1068
+ result: z3.enum(["merged_ready", "stopped"])
985
1069
  }).strict(),
986
- z2.object({
1070
+ z3.object({
987
1071
  ...loopShared,
988
- event: z2.literal("infrastructure_retry"),
989
- round: z2.number().int(),
990
- failure_kind: z2.enum(["pause_comment_post", "developer_connection"]),
991
- attempts: z2.number().int().positive(),
992
- outcome: z2.enum(["recovered", "exhausted"])
1072
+ event: z3.literal("infrastructure_retry"),
1073
+ round: z3.number().int(),
1074
+ failure_kind: z3.enum(["pause_comment_post", "developer_connection"]),
1075
+ attempts: z3.number().int().positive(),
1076
+ outcome: z3.enum(["recovered", "exhausted"])
1077
+ }).strict(),
1078
+ z3.object({
1079
+ ...loopShared,
1080
+ event: z3.literal("driver_heartbeat"),
1081
+ task: z3.number().int(),
1082
+ pr: z3.number().int().positive().optional(),
1083
+ round: z3.number().int(),
1084
+ phase: z3.string()
1085
+ }).strict(),
1086
+ z3.object({
1087
+ ...loopShared,
1088
+ event: z3.literal("driver_exited"),
1089
+ task: z3.number().int(),
1090
+ reason: z3.enum(["finished", "paused", "reexec", "error", "signal"]),
1091
+ last_decision: z3.string(),
1092
+ exit_code: z3.number().int().optional(),
1093
+ error_class: CodeTokenSchema.optional()
993
1094
  }).strict()
994
1095
  ]);
995
- var ForgeOpSchema = z2.enum([
1096
+ var ForgeOpSchema = z3.enum([
996
1097
  "pr.create",
997
1098
  "pr.comment",
998
1099
  "pr.body.replace",
@@ -1006,24 +1107,24 @@ var ForgeOpSchema = z2.enum([
1006
1107
  "label.add",
1007
1108
  "label.remove"
1008
1109
  ]);
1009
- var ForgeWriteTargetSchema = z2.object({
1010
- issue: z2.number().int().optional(),
1011
- pr: z2.number().int().optional()
1110
+ var ForgeWriteTargetSchema = z3.object({
1111
+ issue: z3.number().int().optional(),
1112
+ pr: z3.number().int().optional()
1012
1113
  }).strict();
1013
1114
  var forgeWriteShared = {
1014
1115
  meta: HeaderMetaSchema,
1015
1116
  subject: SubjectSchema,
1016
- kind: z2.literal("forge_write"),
1117
+ kind: z3.literal("forge_write"),
1017
1118
  ...envelopeTail,
1018
1119
  op: ForgeOpSchema,
1019
1120
  target: ForgeWriteTargetSchema
1020
1121
  };
1021
- var ForgeWriteEventSchema = z2.discriminatedUnion("event", [
1022
- z2.object({ ...forgeWriteShared, event: z2.literal("validated") }).strict(),
1023
- z2.object({ ...forgeWriteShared, event: z2.literal("refused"), reason: z2.string() }).strict(),
1024
- z2.object({ ...forgeWriteShared, event: z2.literal("written"), comment_ids: z2.array(z2.string()) }).strict()
1122
+ var ForgeWriteEventSchema = z3.discriminatedUnion("event", [
1123
+ z3.object({ ...forgeWriteShared, event: z3.literal("validated") }).strict(),
1124
+ z3.object({ ...forgeWriteShared, event: z3.literal("refused"), reason: z3.string() }).strict(),
1125
+ z3.object({ ...forgeWriteShared, event: z3.literal("written"), comment_ids: z3.array(z3.string()) }).strict()
1025
1126
  ]);
1026
- var GateOutcomeSchema = z2.enum([
1127
+ var GateOutcomeSchema = z3.enum([
1027
1128
  "pass",
1028
1129
  "fail",
1029
1130
  "wait",
@@ -1036,61 +1137,74 @@ var GateOutcomeSchema = z2.enum([
1036
1137
  var gateShared = {
1037
1138
  meta: HeaderMetaSchema,
1038
1139
  subject: SubjectSchema,
1039
- kind: z2.literal("gate"),
1140
+ kind: z3.literal("gate"),
1040
1141
  ...envelopeTail,
1041
- check: z2.string(),
1042
- check_version: z2.string().nullable(),
1043
- policy_version: z2.string().nullable(),
1044
- input_fingerprint: z2.string().nullable()
1142
+ check: z3.string(),
1143
+ check_version: z3.string().nullable(),
1144
+ policy_version: z3.string().nullable(),
1145
+ input_fingerprint: z3.string().nullable()
1045
1146
  };
1046
- var GateEventSchema = z2.discriminatedUnion("event", [
1047
- z2.object({
1147
+ var GateEventSchema = z3.discriminatedUnion("event", [
1148
+ z3.object({
1048
1149
  ...gateShared,
1049
- event: z2.literal("checked"),
1150
+ event: z3.literal("checked"),
1050
1151
  outcome: GateOutcomeSchema,
1051
- reason: z2.string().optional()
1152
+ reason: z3.string().optional()
1153
+ }).strict(),
1154
+ z3.object({
1155
+ meta: HeaderMetaSchema,
1156
+ subject: SubjectSchema,
1157
+ kind: z3.literal("gate"),
1158
+ ...envelopeTail,
1159
+ event: z3.literal("summary"),
1160
+ ran: z3.number().int().nonnegative(),
1161
+ passed: z3.number().int().nonnegative(),
1162
+ failed: z3.number().int().nonnegative(),
1163
+ skipped: z3.number().int().nonnegative(),
1164
+ failed_checks: z3.array(z3.string())
1052
1165
  }).strict()
1053
1166
  ]);
1054
- var OperationResultSchema = z2.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
1167
+ var OperationResultSchema = z3.enum(["ok", "error", "refused", "timeout", "cancelled", "unavailable"]);
1055
1168
  var operationShared = {
1056
1169
  meta: HeaderMetaSchema,
1057
1170
  subject: SubjectSchema,
1058
- kind: z2.literal("operation"),
1171
+ kind: z3.literal("operation"),
1059
1172
  ...envelopeTail,
1060
- operation: z2.string(),
1061
- target: z2.string().nullable()
1173
+ operation: z3.string(),
1174
+ target: z3.string().nullable()
1062
1175
  };
1063
- var OperationEventSchema = z2.discriminatedUnion("event", [
1064
- z2.object({
1176
+ var OperationEventSchema = z3.discriminatedUnion("event", [
1177
+ z3.object({
1065
1178
  ...operationShared,
1066
- event: z2.literal("completed"),
1179
+ event: z3.literal("completed"),
1067
1180
  result: OperationResultSchema,
1068
- error_class: z2.string().nullable()
1181
+ error_class: z3.string().nullable(),
1182
+ field_names: z3.array(z3.string().max(CUSTOM_FIELD_NAME_MAX_LENGTH)).max(CUSTOM_EVENT_MAX_FIELDS).optional()
1069
1183
  }).strict()
1070
1184
  ]);
1071
- var UsageUnitsSchema = z2.object({
1072
- input: z2.number().nonnegative().nullable(),
1073
- output: z2.number().nonnegative().nullable(),
1074
- cache: z2.number().nonnegative().nullable()
1185
+ var UsageUnitsSchema = z3.object({
1186
+ input: z3.number().nonnegative().nullable(),
1187
+ output: z3.number().nonnegative().nullable(),
1188
+ cache: z3.number().nonnegative().nullable()
1075
1189
  }).strict();
1076
1190
  var usageShared = {
1077
1191
  meta: HeaderMetaSchema,
1078
1192
  subject: SubjectSchema,
1079
- kind: z2.literal("usage"),
1193
+ kind: z3.literal("usage"),
1080
1194
  ...envelopeTail,
1081
- model: z2.string().nullable(),
1082
- source: z2.string(),
1083
- semantics: z2.enum(["cumulative", "delta"])
1195
+ model: z3.string().nullable(),
1196
+ source: z3.string(),
1197
+ semantics: z3.enum(["cumulative", "delta"])
1084
1198
  };
1085
- var UsageEventSchema = z2.discriminatedUnion("event", [
1086
- z2.object({
1199
+ var UsageEventSchema = z3.discriminatedUnion("event", [
1200
+ z3.object({
1087
1201
  ...usageShared,
1088
- event: z2.literal("observed"),
1202
+ event: z3.literal("observed"),
1089
1203
  units: UsageUnitsSchema,
1090
- unknown_reason: z2.string().nullable()
1204
+ unknown_reason: z3.string().nullable()
1091
1205
  }).strict()
1092
1206
  ]);
1093
- var RoleAttemptOutcomeSchema = z2.enum([
1207
+ var RoleAttemptOutcomeSchema = z3.enum([
1094
1208
  "completed",
1095
1209
  "incomplete",
1096
1210
  "infrastructure_failed",
@@ -1101,17 +1215,17 @@ var RoleAttemptOutcomeSchema = z2.enum([
1101
1215
  var roleAttemptShared = {
1102
1216
  meta: HeaderMetaSchema,
1103
1217
  subject: SubjectSchema,
1104
- kind: z2.literal("role_attempt"),
1218
+ kind: z3.literal("role_attempt"),
1105
1219
  ...envelopeTail,
1106
- actor: z2.string().nullable(),
1107
- attempt: z2.number().int().nullable(),
1108
- effect_id: z2.string(),
1109
- model: z2.string().nullable()
1220
+ actor: z3.string().nullable(),
1221
+ attempt: z3.number().int().nullable(),
1222
+ effect_id: z3.string(),
1223
+ model: z3.string().nullable()
1110
1224
  };
1111
- var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
1112
- z2.object({
1225
+ var RoleAttemptEventSchema = z3.discriminatedUnion("event", [
1226
+ z3.object({
1113
1227
  ...roleAttemptShared,
1114
- event: z2.literal("attempted"),
1228
+ event: z3.literal("attempted"),
1115
1229
  outcome: RoleAttemptOutcomeSchema,
1116
1230
  usage: dispatchUsageField
1117
1231
  }).strict()
@@ -1119,42 +1233,59 @@ var RoleAttemptEventSchema = z2.discriminatedUnion("event", [
1119
1233
  var handoffShared = {
1120
1234
  meta: HeaderMetaSchema,
1121
1235
  subject: SubjectSchema,
1122
- kind: z2.literal("handoff"),
1236
+ kind: z3.literal("handoff"),
1123
1237
  ...envelopeTail,
1124
- class: z2.enum(["authority", "strategy", "product"]),
1125
- reason: z2.string()
1238
+ class: z3.enum(["authority", "strategy", "product"]),
1239
+ reason: z3.string()
1126
1240
  };
1127
- var HandoffEventSchema = z2.discriminatedUnion("event", [
1128
- z2.object({
1241
+ var HandoffEventSchema = z3.discriminatedUnion("event", [
1242
+ z3.object({
1129
1243
  ...handoffShared,
1130
- event: z2.literal("raised"),
1131
- requested_decision: z2.string().nullable()
1244
+ event: z3.literal("raised"),
1245
+ requested_decision: z3.string().nullable()
1132
1246
  }).strict(),
1133
- z2.object({
1247
+ z3.object({
1134
1248
  ...handoffShared,
1135
- event: z2.literal("resolved"),
1136
- resolution: z2.string().nullable(),
1137
- resolved_by: z2.string().nullable()
1249
+ event: z3.literal("resolved"),
1250
+ resolution: z3.string().nullable(),
1251
+ resolved_by: z3.string().nullable()
1138
1252
  }).strict()
1139
1253
  ]);
1140
- var EffectTargetSchema = z2.object({
1141
- kind: z2.string(),
1142
- ref: z2.string()
1254
+ var EffectTargetSchema = z3.object({
1255
+ kind: z3.string(),
1256
+ ref: z3.string()
1143
1257
  }).strict();
1144
1258
  var effectShared = {
1145
1259
  meta: HeaderMetaSchema,
1146
1260
  subject: SubjectSchema,
1147
- kind: z2.literal("effect"),
1261
+ kind: z3.literal("effect"),
1148
1262
  ...envelopeTail,
1149
- effect_id: z2.string(),
1263
+ effect_id: z3.string(),
1150
1264
  target: EffectTargetSchema
1151
1265
  };
1152
- var EffectEventSchema = z2.discriminatedUnion("event", [
1153
- z2.object({ ...effectShared, event: z2.literal("attempted") }).strict(),
1154
- z2.object({ ...effectShared, event: z2.literal("observed"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict(),
1155
- z2.object({ ...effectShared, event: z2.literal("verified"), outcome: z2.enum(["success", "failure", "uncertain"]) }).strict()
1266
+ var EffectEventSchema = z3.discriminatedUnion("event", [
1267
+ z3.object({ ...effectShared, event: z3.literal("attempted") }).strict(),
1268
+ z3.object({ ...effectShared, event: z3.literal("observed"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict(),
1269
+ z3.object({ ...effectShared, event: z3.literal("verified"), outcome: z3.enum(["success", "failure", "uncertain"]) }).strict()
1156
1270
  ]);
1157
- var LogEventSchema = z2.union([
1271
+ var CustomFieldValueSchema = z3.union([z3.string().max(CUSTOM_TEXT_MAX_LENGTH), z3.number().finite(), z3.boolean()]);
1272
+ var customShared = {
1273
+ meta: HeaderMetaV3Schema,
1274
+ subject: SubjectSchema,
1275
+ kind: z3.literal("custom"),
1276
+ ...envelopeTail
1277
+ };
1278
+ var CustomEventSchema = z3.discriminatedUnion("event", [
1279
+ z3.object({
1280
+ ...customShared,
1281
+ event: z3.literal("recorded"),
1282
+ name: z3.string().max(CUSTOM_EVENT_NAME_MAX_LENGTH).regex(CUSTOM_EVENT_NAME_PATTERN),
1283
+ 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, {
1284
+ message: `custom: at most ${CUSTOM_EVENT_MAX_FIELDS} fields`
1285
+ })
1286
+ }).strict()
1287
+ ]);
1288
+ var LogEventSchema = z3.union([
1158
1289
  DispatchEventSchema,
1159
1290
  DevReviewLoopEventSchema,
1160
1291
  ForgeWriteEventSchema,
@@ -1163,10 +1294,11 @@ var LogEventSchema = z2.union([
1163
1294
  UsageEventSchema,
1164
1295
  RoleAttemptEventSchema,
1165
1296
  HandoffEventSchema,
1166
- EffectEventSchema
1297
+ EffectEventSchema,
1298
+ CustomEventSchema
1167
1299
  ]);
1168
-
1169
1300
  // ../../packages/aeg-core/src/log/envelope.ts
1301
+ import { createHash } from "node:crypto";
1170
1302
  function isRole(value) {
1171
1303
  return value !== undefined && ROLE_VALUES.includes(value);
1172
1304
  }
@@ -1203,18 +1335,27 @@ function roundFromEnv(round) {
1203
1335
  const n = Number(round);
1204
1336
  return Number.isInteger(n) ? n : undefined;
1205
1337
  }
1338
+ function prFromEnv(pr) {
1339
+ if (pr === undefined || pr === "")
1340
+ return;
1341
+ const n = Number(pr);
1342
+ return Number.isInteger(n) && n > 0 ? n : undefined;
1343
+ }
1206
1344
  function buildHeader(input) {
1207
1345
  const role = isRole(input.env.role) ? input.env.role : "unattributed";
1208
1346
  const round = roundFromEnv(input.env.round);
1347
+ const pr = prFromEnv(input.env.pr);
1209
1348
  const subject = {
1210
1349
  issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
1211
1350
  role,
1212
1351
  ...round !== undefined ? { round } : {},
1352
+ ...pr !== undefined ? { pr } : {},
1213
1353
  ...input.subject ?? {}
1214
1354
  };
1355
+ const issue = subject.issue;
1215
1356
  return {
1216
1357
  meta: {
1217
- schema: 2,
1358
+ schema: 3,
1218
1359
  ts: input.now.toISOString(),
1219
1360
  run_id: input.runId,
1220
1361
  seq: input.seq,
@@ -1237,7 +1378,19 @@ function buildHeader(input) {
1237
1378
  ruling_ordinal: input.inputVersions?.rulingOrdinal ?? null,
1238
1379
  policy_digest: input.inputVersions?.policyDigest ?? null
1239
1380
  },
1240
- provenance: provenanceFor(input)
1381
+ provenance: provenanceFor(input),
1382
+ work: {
1383
+ ref: lineageFieldFromEnv(input.env.workRef) ?? (issue === null ? null : String(issue)),
1384
+ repo: input.repo,
1385
+ change: null,
1386
+ revision: null
1387
+ },
1388
+ flow: {
1389
+ id: lineageFieldFromEnv(input.env.flow) ?? "vinaya",
1390
+ version: lineageFieldFromEnv(input.env.flowVersion)
1391
+ },
1392
+ runtime: lineageFieldFromEnv(input.env.runtime),
1393
+ source: lineageFieldFromEnv(input.env.source)
1241
1394
  },
1242
1395
  subject
1243
1396
  };
@@ -1280,7 +1433,7 @@ function redact(value, home) {
1280
1433
  return value;
1281
1434
  }
1282
1435
  // ../../packages/aeg-core/src/log/store.ts
1283
- var KNOWN_SCHEMA_VERSIONS = [1, 2];
1436
+ var KNOWN_SCHEMA_VERSIONS = [1, 2, 3];
1284
1437
  function metaOf(obj) {
1285
1438
  if (obj === null || typeof obj !== "object")
1286
1439
  return null;
@@ -1346,7 +1499,7 @@ function classifyStoredLine(raw, home) {
1346
1499
  return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
1347
1500
  }
1348
1501
  const redacted = redact(event, home);
1349
- const provenance = version === 2 ? event.meta.provenance ?? null : null;
1502
+ const provenance = version >= 2 ? event.meta.provenance ?? null : null;
1350
1503
  return {
1351
1504
  status: "ok",
1352
1505
  identity,
@@ -1359,136 +1512,139 @@ function classifyStoredLine(raw, home) {
1359
1512
  };
1360
1513
  }
1361
1514
  // ../../packages/aeg-core/src/control-store/records.ts
1362
- import { z as z3 } from "zod";
1363
- var isoTimestamp = z3.string().min(1);
1364
- var taskId = z3.number().int().positive();
1365
- var epochNumber = z3.number().int().nonnegative();
1366
- var RunRecordSchema = z3.object({
1367
- version: z3.literal(1),
1368
- kind: z3.literal("run"),
1515
+ import { z as z4 } from "zod";
1516
+ var isoTimestamp = z4.string().min(1);
1517
+ var taskId = z4.number().int().positive();
1518
+ var epochNumber = z4.number().int().nonnegative();
1519
+ var RunRecordSchema = z4.object({
1520
+ version: z4.literal(1),
1521
+ kind: z4.literal("run"),
1369
1522
  task: taskId,
1370
- runId: z3.string().min(1),
1371
- pid: z3.number().int().positive(),
1372
- host: z3.string().min(1),
1523
+ runId: z4.string().min(1),
1524
+ pid: z4.number().int().positive(),
1525
+ host: z4.string().min(1),
1373
1526
  startedAt: isoTimestamp,
1374
- childStartedAt: z3.string().min(1).nullable().optional(),
1375
- childCommand: z3.string().min(1).nullable().optional()
1527
+ childStartedAt: z4.string().min(1).nullable().optional(),
1528
+ childCommand: z4.string().min(1).nullable().optional()
1376
1529
  }).strict();
1377
- var InputRecordSchema = z3.object({
1378
- version: z3.literal(1),
1379
- kind: z3.literal("input"),
1530
+ var InputRecordSchema = z4.object({
1531
+ version: z4.literal(1),
1532
+ kind: z4.literal("input"),
1380
1533
  task: taskId,
1381
- runId: z3.string().min(1),
1382
- source: z3.union([z3.literal("fresh"), z3.literal("resume")]),
1383
- pr: z3.number().int().positive().nullable(),
1384
- round: z3.number().int().nonnegative(),
1534
+ runId: z4.string().min(1),
1535
+ source: z4.union([z4.literal("fresh"), z4.literal("resume")]),
1536
+ pr: z4.number().int().positive().nullable(),
1537
+ round: z4.number().int().nonnegative(),
1385
1538
  recordedAt: isoTimestamp
1386
1539
  }).strict();
1387
- var OwnershipRecordSchema = z3.object({
1388
- version: z3.literal(1),
1389
- kind: z3.literal("ownership"),
1540
+ var OwnershipRecordSchema = z4.object({
1541
+ version: z4.literal(1),
1542
+ kind: z4.literal("ownership"),
1390
1543
  task: taskId,
1391
1544
  epoch: epochNumber,
1392
- ownerId: z3.string().min(1),
1393
- pid: z3.number().int().positive(),
1394
- host: z3.string().min(1),
1545
+ ownerId: z4.string().min(1),
1546
+ pid: z4.number().int().positive(),
1547
+ host: z4.string().min(1),
1395
1548
  acquiredAt: isoTimestamp
1396
1549
  }).strict();
1397
- var TransitionRecordSchema = z3.object({
1398
- version: z3.literal(1),
1399
- kind: z3.literal("transition"),
1550
+ var TransitionRecordSchema = z4.object({
1551
+ version: z4.literal(1),
1552
+ kind: z4.literal("transition"),
1400
1553
  task: taskId,
1401
1554
  epoch: epochNumber,
1402
- seq: z3.number().int().nonnegative(),
1403
- from: z3.string().min(1),
1404
- to: z3.string().min(1),
1405
- detail: z3.string().optional(),
1555
+ seq: z4.number().int().nonnegative(),
1556
+ from: z4.string().min(1),
1557
+ to: z4.string().min(1),
1558
+ detail: z4.string().optional(),
1406
1559
  at: isoTimestamp
1407
1560
  }).strict();
1408
- var ManifestRecordSchema = z3.object({
1409
- version: z3.literal(1),
1410
- kind: z3.literal("manifest"),
1561
+ var ManifestRecordSchema = z4.object({
1562
+ version: z4.literal(1),
1563
+ kind: z4.literal("manifest"),
1411
1564
  task: taskId,
1412
1565
  round: epochNumber,
1413
- repository: z3.string().min(1),
1414
- pr: z3.number().int().positive(),
1415
- branch: z3.string().min(1),
1416
- baseSha: z3.string().min(1).nullable(),
1417
- headSha: z3.string().min(1),
1418
- briefHash: z3.string().min(1).nullable(),
1419
- objectivesVersion: z3.string().min(1).nullable(),
1566
+ repository: z4.string().min(1),
1567
+ pr: z4.number().int().positive(),
1568
+ branch: z4.string().min(1),
1569
+ baseSha: z4.string().min(1).nullable(),
1570
+ headSha: z4.string().min(1),
1571
+ briefHash: z4.string().min(1).nullable(),
1572
+ objectivesVersion: z4.string().min(1).nullable(),
1420
1573
  rulingOrdinal: epochNumber,
1421
- policyDigest: z3.string().min(1),
1574
+ policyDigest: z4.string().min(1),
1422
1575
  recordedAt: isoTimestamp
1423
1576
  }).strict();
1424
- var roundHeadIdentity = z3.object({ round: z3.number().int().positive(), head: z3.string().min(1) }).strict();
1425
- var LoopBudgetsSchema = z3.object({
1426
- mechanicalRetries: z3.number().int().nonnegative(),
1427
- reviewRounds: z3.number().int().nonnegative(),
1428
- infrastructureRetries: z3.number().int().nonnegative()
1577
+ var roundHeadIdentity = z4.object({ round: z4.number().int().positive(), head: z4.string().min(1) }).strict();
1578
+ var LoopBudgetsSchema = z4.object({
1579
+ mechanicalRetries: z4.number().int().nonnegative(),
1580
+ reviewRounds: z4.number().int().nonnegative(),
1581
+ infrastructureRetries: z4.number().int().nonnegative()
1429
1582
  }).strict();
1430
- var LoopStateRecordSchema = z3.object({
1431
- version: z3.literal(1),
1432
- kind: z3.literal("loop_state"),
1583
+ var LoopStateRecordSchema = z4.object({
1584
+ version: z4.literal(1),
1585
+ kind: z4.literal("loop_state"),
1433
1586
  task: taskId,
1434
- round: z3.number().int().positive(),
1435
- phase: z3.string().min(1),
1436
- pauseReason: z3.string().min(1).nullable(),
1587
+ round: z4.number().int().positive(),
1588
+ phase: z4.string().min(1),
1589
+ pauseReason: z4.string().min(1).nullable(),
1437
1590
  budgets: LoopBudgetsSchema,
1438
1591
  heldResult: roundHeadIdentity.nullable(),
1439
1592
  deliveredFindings: roundHeadIdentity.nullable(),
1440
- repeatMemory: z3.object({
1441
- blockingFindings: z3.array(z3.string()),
1442
- lastFailure: z3.object({ signature: z3.string(), message: z3.string() }).nullable()
1593
+ repeatMemory: z4.object({
1594
+ blockingFindings: z4.array(z4.string()),
1595
+ lastFailure: z4.object({ signature: z4.string(), message: z4.string() }).nullable()
1443
1596
  }).strict().optional(),
1597
+ publicationExpectedBase: z4.string().regex(/^[0-9a-f]{40}$/).nullable().optional(),
1598
+ taskStartedAt: isoTimestamp.optional(),
1599
+ phaseMs: z4.record(z4.string(), z4.number().nonnegative()).optional(),
1444
1600
  recordedAt: isoTimestamp
1445
1601
  }).strict();
1446
- var EffectRecordSchema = z3.object({
1447
- version: z3.literal(1),
1448
- kind: z3.literal("effect"),
1602
+ var EffectRecordSchema = z4.object({
1603
+ version: z4.literal(1),
1604
+ kind: z4.literal("effect"),
1449
1605
  task: taskId,
1450
- key: z3.string().min(1),
1451
- operation: z3.string().min(1),
1452
- target: z3.string().min(1),
1453
- inputVersion: z3.number().int().nonnegative(),
1454
- payloadDigest: z3.string().min(1),
1455
- status: z3.union([z3.literal("started"), z3.literal("verified"), z3.literal("uncertain")]),
1456
- url: z3.string().optional(),
1606
+ key: z4.string().min(1),
1607
+ operation: z4.string().min(1),
1608
+ target: z4.string().min(1),
1609
+ inputVersion: z4.number().int().nonnegative(),
1610
+ payloadDigest: z4.string().min(1),
1611
+ status: z4.union([z4.literal("started"), z4.literal("verified"), z4.literal("uncertain")]),
1612
+ url: z4.string().optional(),
1457
1613
  recordedAt: isoTimestamp
1458
1614
  }).strict();
1459
- var EscalationRecordSchema = z3.object({
1460
- version: z3.literal(1),
1461
- kind: z3.literal("escalation"),
1615
+ var EscalationRecordSchema = z4.object({
1616
+ version: z4.literal(1),
1617
+ kind: z4.literal("escalation"),
1462
1618
  task: taskId,
1463
- escalationId: z3.string().min(1),
1619
+ escalationId: z4.string().min(1),
1464
1620
  round: epochNumber,
1465
- head: z3.string().min(1),
1466
- branch: z3.string().min(1),
1467
- pr: z3.number().int().positive().nullable(),
1468
- runId: z3.string().min(1),
1469
- pid: z3.number().int().positive(),
1470
- host: z3.string().min(1),
1471
- agent: z3.string().min(1).optional(),
1472
- reason: z3.string().min(1),
1473
- detail: z3.string().optional(),
1474
- evidence: z3.string().optional(),
1475
- attemptedRecovery: z3.string().min(1),
1476
- requestedDecision: z3.string().min(1),
1477
- recipient: z3.string().min(1),
1478
- briefHash: z3.string().min(1).nullable(),
1479
- objectivesVersion: z3.string().min(1).nullable(),
1621
+ head: z4.string().min(1),
1622
+ branch: z4.string().min(1),
1623
+ pr: z4.number().int().positive().nullable(),
1624
+ runId: z4.string().min(1),
1625
+ pid: z4.number().int().positive(),
1626
+ host: z4.string().min(1),
1627
+ agent: z4.string().min(1).optional(),
1628
+ reason: z4.string().min(1),
1629
+ detail: z4.string().optional(),
1630
+ evidence: z4.string().optional(),
1631
+ attemptedRecovery: z4.string().min(1),
1632
+ requestedDecision: z4.string().min(1),
1633
+ recipient: z4.string().min(1),
1634
+ briefHash: z4.string().min(1).nullable(),
1635
+ objectivesVersion: z4.string().min(1).nullable(),
1480
1636
  rulingOrdinal: epochNumber,
1481
- policyDigest: z3.string().min(1),
1637
+ policyDigest: z4.string().min(1),
1482
1638
  recordedAt: isoTimestamp
1483
1639
  }).strict();
1484
- var ResolutionRecordSchema = z3.object({
1485
- version: z3.literal(1),
1486
- kind: z3.literal("resolution"),
1640
+ var ResolutionRecordSchema = z4.object({
1641
+ version: z4.literal(1),
1642
+ kind: z4.literal("resolution"),
1487
1643
  task: taskId,
1488
- escalationId: z3.string().min(1),
1489
- decision: z3.union([z3.literal("resume"), z3.literal("cancel")]),
1490
- authenticatedBy: z3.string().min(1),
1491
- authenticatedFrom: z3.string().min(1),
1644
+ escalationId: z4.string().min(1),
1645
+ decision: z4.union([z4.literal("resume"), z4.literal("cancel")]),
1646
+ authenticatedBy: z4.string().min(1),
1647
+ authenticatedFrom: z4.string().min(1),
1492
1648
  consumedAt: isoTimestamp
1493
1649
  }).strict();
1494
1650
  // ../../packages/aeg-core/src/control-store/local.ts
@@ -1568,8 +1724,8 @@ function mkdirNoSymlinks(dir, mode, trustedRoot) {
1568
1724
  }
1569
1725
  var CONTROL_AREA_DIRNAME = "control";
1570
1726
  // src/checks/registry.ts
1571
- import { existsSync as existsSync3 } from "node:fs";
1572
- import { join as join3 } from "node:path";
1727
+ import { join as join3, relative, sep as sep2 } from "node:path";
1728
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
1573
1729
 
1574
1730
  // src/lib/package-root.ts
1575
1731
  import { existsSync as existsSync2 } from "node:fs";
@@ -1589,10 +1745,14 @@ function packageRoot(moduleUrl) {
1589
1745
  }
1590
1746
 
1591
1747
  // src/checks/registry.ts
1592
- var DIST_BIN_DIR = join3(packageRoot(import.meta.url), "dist", "checks", "bin");
1593
- var SRC_BIN_DIR = join3(packageRoot(import.meta.url), "src", "checks", "bin");
1594
- var BIN_DIR = existsSync3(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
1595
- var BIN_EXT = BIN_DIR === DIST_BIN_DIR ? ".js" : ".ts";
1748
+ function resolveCheckBin(packageDir, moduleUrl) {
1749
+ const fromPackage = relative(packageDir, fileURLToPath2(moduleUrl));
1750
+ const bundled = fromPackage === "dist" || fromPackage.startsWith(`dist${sep2}`);
1751
+ return bundled ? { dir: join3(packageDir, "dist", "checks", "bin"), ext: ".js" } : { dir: join3(packageDir, "src", "checks", "bin"), ext: ".ts" };
1752
+ }
1753
+ var CHECK_BIN = resolveCheckBin(packageRoot(import.meta.url), import.meta.url);
1754
+ var BIN_DIR = CHECK_BIN.dir;
1755
+ var BIN_EXT = CHECK_BIN.ext;
1596
1756
  function bin(name) {
1597
1757
  return join3(BIN_DIR, `${name}${BIN_EXT}`);
1598
1758
  }
@@ -1636,6 +1796,8 @@ var REGISTRY = [
1636
1796
  timeoutMs: 15000,
1637
1797
  env: {
1638
1798
  BASE_SHA: { optional: true },
1799
+ GIT_INDEX_FILE: { optional: true },
1800
+ VINAYA_COMMIT_HOOK: { optional: true },
1639
1801
  PR_BODY: { optional: true },
1640
1802
  PR_BODY_FILE: { optional: true },
1641
1803
  PR_NUMBER: { optional: true },
@@ -1790,23 +1952,6 @@ var REGISTRY = [
1790
1952
  },
1791
1953
  1
1792
1954
  ],
1793
- [
1794
- {
1795
- name: "token-report",
1796
- validates: "body",
1797
- run: bin("check-token-report"),
1798
- scope: "diff",
1799
- timeoutMs: 15000,
1800
- requiresOpenPr: true,
1801
- env: {
1802
- PR_BODY: { optional: true },
1803
- BRANCH: { optional: true },
1804
- CLAUDE_PROJECT_DIR: { optional: true },
1805
- CLAUDE_CODE_SESSION_ID: { optional: true }
1806
- }
1807
- },
1808
- 1
1809
- ],
1810
1955
  [
1811
1956
  {
1812
1957
  name: "no-disk-state",
@@ -2156,71 +2301,52 @@ var CORE_CHECK_RING = Object.fromEntries(REGISTRY.map(([spec, ring]) => [spec.na
2156
2301
  import { execFile as execFile5 } from "node:child_process";
2157
2302
  import { randomUUID as randomUUID2 } from "node:crypto";
2158
2303
  import {
2159
- closeSync as closeSync4,
2160
- constants as fsConstants4,
2304
+ appendFileSync,
2305
+ closeSync as closeSync5,
2306
+ constants as fsConstants5,
2161
2307
  existsSync as existsSync6,
2162
- fstatSync as fstatSync2,
2163
- mkdirSync as mkdirSync4,
2164
- openSync as openSync4,
2165
- readFileSync as readFileSync5,
2308
+ fstatSync as fstatSync3,
2309
+ mkdirSync as mkdirSync5,
2310
+ lstatSync as lstatSync3,
2311
+ openSync as openSync5,
2312
+ readFileSync as readFileSync6,
2166
2313
  renameSync as renameSync3,
2167
- writeSync as writeSync3
2314
+ writeFileSync as writeFileSync3,
2315
+ writeSync as writeSync4
2168
2316
  } from "node:fs";
2169
2317
  import { hostname as osHostname, homedir as homedir3 } from "node:os";
2170
- import { dirname as dirname6, join as join7 } from "node:path";
2318
+ import { dirname as dirname7, join as join7 } from "node:path";
2171
2319
  import { promisify as promisify5 } from "node:util";
2172
2320
 
2173
2321
  // src/lib/config.ts
2174
- import { execFile as execFile4, execFileSync as execFileSync3 } from "node:child_process";
2322
+ import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
2175
2323
  import { promisify as promisify4 } from "node:util";
2176
- import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, realpathSync, writeFileSync } from "node:fs";
2324
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, realpathSync, writeFileSync } from "node:fs";
2177
2325
  import { homedir } from "node:os";
2178
2326
  import { dirname as dirname3, isAbsolute, join as join4, resolve as resolve2 } from "node:path";
2179
- import { z as z4 } from "zod";
2327
+ import { z as z5 } from "zod";
2180
2328
 
2181
2329
  // src/lib/agent-vendors.ts
2182
2330
  var AGENT_VENDORS = ["skills", "claude", "gemini"];
2183
2331
 
2184
- // src/lib/worker-boundary.ts
2185
- import { execFileSync as execFileSync2 } from "node:child_process";
2186
- var LOG_HEADER_KEYCHAIN_SERVICE = "Vinaya Log";
2187
- var logHeaderKeychainCache = new Map;
2188
- function readRealLogHeaderKeychainCredential(variable) {
2189
- if (process.platform !== "darwin")
2190
- return null;
2191
- try {
2192
- 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$/, "");
2193
- } catch {
2194
- return null;
2195
- }
2196
- }
2197
- function readLogHeaderKeychainCredential(variable) {
2198
- const cached = logHeaderKeychainCache.get(variable);
2199
- if (cached !== undefined)
2200
- return cached;
2201
- const value = readRealLogHeaderKeychainCredential(variable);
2202
- logHeaderKeychainCache.set(variable, value);
2203
- return value;
2204
- }
2205
-
2206
2332
  // src/lib/config.ts
2207
- var EnvEntrySchema = z4.union([
2208
- z4.literal(true),
2209
- z4.object({ optional: z4.literal(true) }),
2210
- z4.object({ anyOf: z4.array(z4.string()).min(2) }),
2211
- z4.string()
2333
+ var EnvEntrySchema = z5.union([
2334
+ z5.literal(true),
2335
+ z5.object({ optional: z5.literal(true) }),
2336
+ z5.object({ anyOf: z5.array(z5.string()).min(2) }),
2337
+ z5.string()
2212
2338
  ]);
2213
- var CheckEntrySchema = z4.object({
2214
- run: z4.string(),
2215
- scope: z4.enum(["diff", "full"]),
2216
- include: z4.array(z4.string()).optional(),
2217
- args: z4.array(z4.string()).optional(),
2218
- timeoutMs: z4.number().optional(),
2219
- env: z4.record(z4.string(), EnvEntrySchema).optional(),
2220
- requiresOpenPr: z4.boolean().optional(),
2221
- ownWorkflow: z4.boolean().optional(),
2222
- principalOwed: z4.literal(true).optional(),
2223
- validates: z4.enum(["body", "issue"]).optional()
2339
+ var CheckEntrySchema = z5.object({
2340
+ run: z5.string(),
2341
+ scope: z5.enum(["diff", "full"]),
2342
+ include: z5.array(z5.string()).optional(),
2343
+ args: z5.array(z5.string()).optional(),
2344
+ timeoutMs: z5.number().optional(),
2345
+ env: z5.record(z5.string(), EnvEntrySchema).optional(),
2346
+ requiresOpenPr: z5.boolean().optional(),
2347
+ ownWorkflow: z5.boolean().optional(),
2348
+ principalOwed: z5.literal(true).optional(),
2349
+ validates: z5.enum(["body", "issue"]).optional()
2224
2350
  }).superRefine((entry, ctx) => {
2225
2351
  if (!entry.env)
2226
2352
  return;
@@ -2230,22 +2356,22 @@ var CheckEntrySchema = z4.object({
2230
2356
  const members = value.anyOf;
2231
2357
  if (new Set(members).size !== members.length) {
2232
2358
  ctx.addIssue({
2233
- code: z4.ZodIssueCode.custom,
2359
+ code: z5.ZodIssueCode.custom,
2234
2360
  message: `env.${key}.anyOf has duplicate members`,
2235
2361
  path: ["env", key, "anyOf"]
2236
2362
  });
2237
2363
  }
2238
2364
  if (!members.includes(key)) {
2239
2365
  ctx.addIssue({
2240
- code: z4.ZodIssueCode.custom,
2366
+ code: z5.ZodIssueCode.custom,
2241
2367
  message: `env.${key}.anyOf must include "${key}" itself as a member`,
2242
2368
  path: ["env", key, "anyOf"]
2243
2369
  });
2244
2370
  }
2245
2371
  }
2246
2372
  });
2247
- var RoleEntrySchema = z4.object({
2248
- contract: z4.string().refine((p) => p.includes("/"), {
2373
+ var RoleEntrySchema = z5.object({
2374
+ contract: z5.string().refine((p) => p.includes("/"), {
2249
2375
  message: 'must be a path (contain at least one "/"), not a bare filename'
2250
2376
  })
2251
2377
  });
@@ -2269,17 +2395,17 @@ var BRIEF_BUILTINS = [
2269
2395
  "briefSections",
2270
2396
  "milestoneShape"
2271
2397
  ];
2272
- var BriefSectionSchema = z4.union([
2273
- z4.object({ builtin: z4.enum(BRIEF_BUILTINS) }),
2274
- z4.object({ heading: z4.string().min(1), name: z4.string().optional() }),
2275
- z4.object({ field: z4.string().min(1), name: z4.string().optional() }),
2276
- z4.object({ phrase: z4.string().min(1), name: z4.string().optional() })
2398
+ var BriefSectionSchema = z5.union([
2399
+ z5.object({ builtin: z5.enum(BRIEF_BUILTINS) }),
2400
+ z5.object({ heading: z5.string().min(1), name: z5.string().optional() }),
2401
+ z5.object({ field: z5.string().min(1), name: z5.string().optional() }),
2402
+ z5.object({ phrase: z5.string().min(1), name: z5.string().optional() })
2277
2403
  ]);
2278
- var BriefSchemaSchema = z4.object({
2279
- pr: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
2280
- issue: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
2281
- milestone: z4.object({ sections: z4.array(BriefSectionSchema) }).optional(),
2282
- ack: z4.array(z4.enum(BRIEF_BUILTINS)).optional()
2404
+ var BriefSchemaSchema = z5.object({
2405
+ pr: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
2406
+ issue: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
2407
+ milestone: z5.object({ sections: z5.array(BriefSectionSchema) }).optional(),
2408
+ ack: z5.array(z5.enum(BRIEF_BUILTINS)).optional()
2283
2409
  });
2284
2410
  function isSafeRepoRelPath(p) {
2285
2411
  if (p.length === 0)
@@ -2288,7 +2414,7 @@ function isSafeRepoRelPath(p) {
2288
2414
  return false;
2289
2415
  return p.split(/[\\/]/).every((seg) => seg !== ".." && seg !== "");
2290
2416
  }
2291
- var SafeRepoRelPath = z4.string().refine(isSafeRepoRelPath, {
2417
+ var SafeRepoRelPath = z5.string().refine(isSafeRepoRelPath, {
2292
2418
  message: "must be a repo-root-relative path with no `..` segment or absolute root"
2293
2419
  });
2294
2420
  var CANONICAL_HOOK_BLOCK_PREFIXES = [".git/", ".husky/", ".vinaya/hooks/", ".claude/hooks/"];
@@ -2298,22 +2424,22 @@ function isCanonicalHookBlockPath(p) {
2298
2424
  var ManagedHookBlockPath = SafeRepoRelPath.refine(isCanonicalHookBlockPath, {
2299
2425
  message: `must start with one of ${CANONICAL_HOOK_BLOCK_PREFIXES.join(", ")} (byte-exact, case-sensitive)`
2300
2426
  });
2301
- var ManagedBlockRecordSchema = z4.object({
2427
+ var ManagedBlockRecordSchema = z5.object({
2302
2428
  path: ManagedHookBlockPath,
2303
- marker: z4.string(),
2304
- comment: z4.enum(["hash", "html"])
2429
+ marker: z5.string(),
2430
+ comment: z5.enum(["hash", "html"])
2305
2431
  });
2306
- var ManagedManifestSchema = z4.object({
2307
- version: z4.number().int().positive(),
2308
- files: z4.array(SafeRepoRelPath),
2309
- blocks: z4.array(ManagedBlockRecordSchema),
2310
- labels: z4.array(z4.string()),
2311
- agents: z4.array(z4.enum(AGENT_VENDORS)).optional()
2432
+ var ManagedManifestSchema = z5.object({
2433
+ version: z5.number().int().positive(),
2434
+ files: z5.array(SafeRepoRelPath),
2435
+ blocks: z5.array(ManagedBlockRecordSchema),
2436
+ labels: z5.array(z5.string()),
2437
+ agents: z5.array(z5.enum(AGENT_VENDORS)).optional()
2312
2438
  });
2313
- var ProjectEntrySchema = z4.object({
2314
- name: z4.string().min(1),
2315
- description: z4.string().min(1).optional(),
2316
- path: z4.string().min(1).optional()
2439
+ var ProjectEntrySchema = z5.object({
2440
+ name: z5.string().min(1),
2441
+ description: z5.string().min(1).optional(),
2442
+ path: z5.string().min(1).optional()
2317
2443
  });
2318
2444
  function parseTokensCollectDeclaration(value) {
2319
2445
  const m = value.trim().match(/^(\S+)\s+(\S+)$/);
@@ -2324,90 +2450,97 @@ function parseTokensCollectDeclaration(value) {
2324
2450
  return null;
2325
2451
  return { interpreter, script };
2326
2452
  }
2327
- var VinayaConfigSchema = z4.object({
2328
- rings: z4.object({
2329
- ring1_forgeWriteInterception: z4.boolean(),
2330
- ring2_asyncAudits: z4.boolean()
2453
+ var VinayaConfigSchema = z5.object({
2454
+ rings: z5.object({
2455
+ ring1_forgeWriteInterception: z5.boolean(),
2456
+ ring2_asyncAudits: z5.boolean()
2331
2457
  }).optional(),
2332
- checks: z4.record(z4.string(), CheckEntrySchema).optional(),
2333
- roles: z4.record(z4.string(), RoleEntrySchema).optional(),
2458
+ checks: z5.record(z5.string(), CheckEntrySchema).optional(),
2459
+ roles: z5.record(z5.string(), RoleEntrySchema).optional(),
2334
2460
  briefSchema: BriefSchemaSchema.optional(),
2335
2461
  managed: ManagedManifestSchema.optional(),
2336
- principals: z4.array(z4.string()).min(1).optional(),
2337
- releaseActor: z4.string().min(1).optional(),
2338
- ci: z4.object({ setup: z4.string().min(1) }).optional(),
2339
- tokens: z4.object({
2340
- collect: z4.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
2462
+ principals: z5.array(z5.string()).min(1).optional(),
2463
+ releaseActor: z5.string().min(1).optional(),
2464
+ ci: z5.object({ setup: z5.string().min(1) }).optional(),
2465
+ tokens: z5.object({
2466
+ collect: z5.string().min(1).refine((v) => parseTokensCollectDeclaration(v) !== null, {
2341
2467
  message: 'tokens.collect must be exactly "<interpreter> <repo-relative-script-path>" — two whitespace-separated tokens, no flags, no shell syntax, no quoting'
2342
2468
  })
2343
2469
  }).optional(),
2344
- blastRadius: z4.object({ extraDomains: z4.array(z4.string()).optional() }).optional(),
2345
- proseGates: z4.object({
2346
- doctrineRoot: z4.string().min(1).optional(),
2347
- readerFacingPrefix: z4.string().min(1).optional(),
2348
- readerFacingSuffix: z4.string().min(1).optional(),
2349
- legacySlugDir: z4.string().min(1).optional(),
2350
- sourceComments: z4.object({
2351
- globs: z4.array(z4.string().min(1)).optional(),
2352
- allowlist: z4.array(z4.string().min(1)).optional(),
2353
- severity: z4.enum(["warning", "error"]).optional()
2470
+ blastRadius: z5.object({ extraDomains: z5.array(z5.string()).optional() }).optional(),
2471
+ proseGates: z5.object({
2472
+ doctrineRoot: z5.string().min(1).optional(),
2473
+ readerFacingPrefix: z5.string().min(1).optional(),
2474
+ readerFacingSuffix: z5.string().min(1).optional(),
2475
+ legacySlugDir: z5.string().min(1).optional(),
2476
+ sourceComments: z5.object({
2477
+ globs: z5.array(z5.string().min(1)).optional(),
2478
+ allowlist: z5.array(z5.string().min(1)).optional(),
2479
+ severity: z5.enum(["warning", "error"]).optional()
2354
2480
  }).optional(),
2355
- specGrandfather: z4.array(z4.string().min(1)).optional(),
2356
- specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
2481
+ specGrandfather: z5.union([z5.array(z5.string().min(1)), z5.record(z5.string().min(1), z5.number().int().min(0))]).optional(),
2482
+ specPaths: z5.array(z5.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
2357
2483
  message: "must be a repository-relative path, not an absolute one"
2358
2484
  }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
2359
2485
  message: "must stay inside the repository — no `..` segment"
2360
2486
  })).optional()
2361
2487
  }).optional(),
2362
- projects: z4.array(ProjectEntrySchema).optional(),
2363
- dispatch: z4.object({
2364
- timeoutMs: z4.number().int().positive().optional(),
2365
- killGraceMs: z4.number().int().positive().optional(),
2366
- agent: z4.enum(["claude", "codex", "gemini"]).optional(),
2367
- requireWorkerIsolation: z4.boolean().optional()
2488
+ projects: z5.array(ProjectEntrySchema).optional(),
2489
+ dispatch: z5.object({
2490
+ timeoutMs: z5.number().int().positive().optional(),
2491
+ killGraceMs: z5.number().int().positive().optional(),
2492
+ agent: z5.enum(["claude", "codex", "gemini"]).optional()
2368
2493
  }).optional(),
2369
- reviewPolicy: z4.object({
2370
- codeReviewThreshold: z4.string().min(1).optional(),
2371
- securityThreshold: z4.string().min(1).optional(),
2372
- maxRounds: z4.number().optional()
2494
+ reviewPolicy: z5.object({
2495
+ codeReviewThreshold: z5.string().min(1).optional(),
2496
+ securityThreshold: z5.string().min(1).optional(),
2497
+ maxRounds: z5.number().optional(),
2498
+ maxTaskMinutes: z5.number().optional()
2373
2499
  }).optional(),
2374
- gateCutovers: z4.object({
2375
- objectivesSinceIssue: z4.number().int().nonnegative().optional(),
2376
- briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
2377
- documentationSinceIssue: z4.number().int().nonnegative().optional(),
2378
- briefRulesSincePr: z4.number().int().nonnegative().optional(),
2379
- agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
2500
+ securityScan: z5.object({
2501
+ command: z5.array(z5.string().min(1)).min(1)
2380
2502
  }).optional(),
2381
- planning: z4.object({
2382
- collisionThreshold: z4.number().int().nonnegative().optional()
2503
+ gateCutovers: z5.object({
2504
+ objectivesSinceIssue: z5.number().int().nonnegative().optional(),
2505
+ briefSectionsSinceIssue: z5.number().int().nonnegative().optional(),
2506
+ documentationSinceIssue: z5.number().int().nonnegative().optional(),
2507
+ briefRulesSincePr: z5.number().int().nonnegative().optional(),
2508
+ agentBoxesRefusedSincePr: z5.number().int().nonnegative().optional()
2383
2509
  }).optional(),
2384
- prePush: z4.object({
2385
- alwaysRun: z4.array(z4.string()).optional()
2510
+ planning: z5.object({
2511
+ collisionThreshold: z5.number().int().nonnegative().optional()
2386
2512
  }).optional(),
2387
- report: z4.object({
2388
- commandTimeoutMs: z4.number().int().positive().optional()
2513
+ prePush: z5.object({
2514
+ alwaysRun: z5.array(z5.string()).optional()
2515
+ }).optional(),
2516
+ report: z5.object({
2517
+ commandTimeoutMs: z5.number().int().positive().optional()
2389
2518
  }).superRefine((report, ctx) => {
2390
2519
  const commandTimeoutMs = report.commandTimeoutMs;
2391
2520
  if (commandTimeoutMs !== undefined && commandTimeoutMs > MAX_REPORT_COMMAND_TIMEOUT_MS) {
2392
2521
  ctx.addIssue({
2393
- code: z4.ZodIssueCode.custom,
2522
+ code: z5.ZodIssueCode.custom,
2394
2523
  path: ["commandTimeoutMs"],
2395
2524
  message: "must be at most 3600000 (1 hour)"
2396
2525
  });
2397
2526
  }
2398
2527
  }).optional(),
2399
- logPublish: z4.unknown().refine((v) => v === undefined, {
2528
+ logPublish: z5.unknown().refine((v) => v === undefined, {
2400
2529
  message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
2401
2530
  }),
2402
- runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
2403
- logs: z4.object({
2404
- folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
2405
- url: z4.string().url().optional(),
2406
- headers: z4.record(z4.string()).optional()
2531
+ runtimeDir: z5.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
2532
+ logs: z5.object({
2533
+ folder: z5.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
2534
+ url: z5.string().url().optional(),
2535
+ headers: z5.record(z5.string()).optional(),
2536
+ readHeaders: z5.record(z5.string()).optional(),
2537
+ events: CustomEventDeclarationsSchema.optional()
2407
2538
  }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
2408
2539
  message: "logs: set at most one of folder/url"
2409
2540
  }).refine((v) => v.headers === undefined || v.url !== undefined, {
2410
2541
  message: "logs: headers requires url"
2542
+ }).refine((v) => v.readHeaders === undefined || v.url !== undefined, {
2543
+ message: "logs: readHeaders requires url"
2411
2544
  }).optional()
2412
2545
  });
2413
2546
  var GLOBAL_VINAYA_HOME = join4(homedir(), ".vinaya");
@@ -2417,9 +2550,9 @@ function findLocalConfig() {
2417
2550
  let dir = process.cwd();
2418
2551
  while (true) {
2419
2552
  const candidate = join4(dir, LOCAL_CONFIG_FILENAME);
2420
- if (existsSync4(candidate))
2553
+ if (existsSync3(candidate))
2421
2554
  return candidate;
2422
- if (existsSync4(join4(dir, ".git")))
2555
+ if (existsSync3(join4(dir, ".git")))
2423
2556
  return null;
2424
2557
  const parent = dirname3(dir);
2425
2558
  if (parent === dir)
@@ -2431,7 +2564,7 @@ function configPath() {
2431
2564
  const local = findLocalConfig();
2432
2565
  if (local)
2433
2566
  return local;
2434
- if (existsSync4(GLOBAL_CONFIG_PATH))
2567
+ if (existsSync3(GLOBAL_CONFIG_PATH))
2435
2568
  return GLOBAL_CONFIG_PATH;
2436
2569
  return null;
2437
2570
  }
@@ -2515,17 +2648,12 @@ function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
2515
2648
  return "url" in anchored && anchored.url === local.url ? anchored : null;
2516
2649
  return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
2517
2650
  }
2518
- function resolveLogsHeaderValues(headers, env, readKeychain = readLogHeaderKeychainCredential) {
2651
+ function resolveLogsHeaderValues(headers, env) {
2519
2652
  if (!headers)
2520
2653
  return;
2521
2654
  const resolved = {};
2522
2655
  for (const [key, value] of Object.entries(headers)) {
2523
- resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => {
2524
- const fromEnv = env[name];
2525
- if (fromEnv !== undefined)
2526
- return fromEnv;
2527
- return readKeychain(name) ?? "";
2528
- });
2656
+ resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
2529
2657
  }
2530
2658
  return resolved;
2531
2659
  }
@@ -2534,7 +2662,7 @@ function trustAnchorRepo() {
2534
2662
  if (fromRunner)
2535
2663
  return fromRunner;
2536
2664
  try {
2537
- const url = execFileSync3("git", ["remote", "get-url", "origin"], {
2665
+ const url = execFileSync2("git", ["remote", "get-url", "origin"], {
2538
2666
  encoding: "utf-8",
2539
2667
  stdio: ["ignore", "pipe", "pipe"]
2540
2668
  });
@@ -2581,7 +2709,7 @@ function resolveCiTrustAnchorProbeRef(env = process.env) {
2581
2709
  return ref;
2582
2710
  }
2583
2711
  function readTrustAnchorConfigAtRef(ref) {
2584
- const raw = execFileSync3("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
2712
+ const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
2585
2713
  encoding: "utf-8",
2586
2714
  stdio: ["ignore", "pipe", "pipe"],
2587
2715
  timeout: 1e4
@@ -2595,7 +2723,7 @@ function ghFetchTrustAnchorConfig() {
2595
2723
  const repo = trustAnchorRepo();
2596
2724
  if (!repo)
2597
2725
  throw new Error("could not resolve repo identity for the trust-anchor read");
2598
- return execFileSync3("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
2726
+ return execFileSync2("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], {
2599
2727
  encoding: "utf-8",
2600
2728
  stdio: ["ignore", "pipe", "pipe"]
2601
2729
  });
@@ -2686,8 +2814,8 @@ function loadConfig() {
2686
2814
  var TOKENS_COLLECT_TRUST_PATH = join4(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
2687
2815
 
2688
2816
  // src/lib/run-paths.ts
2689
- import { execFileSync as execFileSync4 } from "node:child_process";
2690
- import { chmodSync, existsSync as existsSync5, realpathSync as realpathSync2 } from "node:fs";
2817
+ import { execFileSync as execFileSync3 } from "node:child_process";
2818
+ import { chmodSync, existsSync as existsSync4, realpathSync as realpathSync2 } from "node:fs";
2691
2819
  import { dirname as dirname4, join as join5, resolve as resolvePath } from "node:path";
2692
2820
  var TASKS_EXECUTION_DIRNAME = "tasks-execution";
2693
2821
  var RUN_AREA_DIRNAMES = {
@@ -2817,7 +2945,7 @@ function repoRootSync(start = process.cwd()) {
2817
2945
  return null;
2818
2946
  }
2819
2947
  for (;; ) {
2820
- if (existsSync5(join5(dir, ".git")))
2948
+ if (existsSync4(join5(dir, ".git")))
2821
2949
  return dir;
2822
2950
  const parent = dirname4(dir);
2823
2951
  if (parent === dir)
@@ -2834,7 +2962,7 @@ function resolveRepoSync() {
2834
2962
  }
2835
2963
  let url;
2836
2964
  try {
2837
- url = execFileSync4("git", ["remote", "get-url", "origin"], {
2965
+ url = execFileSync3("git", ["remote", "get-url", "origin"], {
2838
2966
  encoding: "utf-8",
2839
2967
  stdio: ["ignore", "pipe", "pipe"]
2840
2968
  }).trim();
@@ -2861,25 +2989,62 @@ function ensureRunDir(dir, runtimeDir) {
2861
2989
  chmodSync(dir, 448);
2862
2990
  }
2863
2991
 
2864
- // src/lib/log-webhook-drain.ts
2992
+ // src/lib/loop-log.ts
2865
2993
  import {
2866
2994
  closeSync as closeSync3,
2867
2995
  constants as fsConstants3,
2868
- lstatSync as lstatSync2,
2996
+ existsSync as existsSync5,
2997
+ fstatSync as fstatSync2,
2869
2998
  mkdirSync as mkdirSync3,
2870
2999
  openSync as openSync3,
2871
- linkSync as linkSync2,
2872
3000
  readFileSync as readFileSync4,
2873
- renameSync as renameSync2,
3001
+ readSync,
2874
3002
  statSync as statSync2,
3003
+ writeSync as writeSync2
3004
+ } from "node:fs";
3005
+ import { dirname as dirname5 } from "node:path";
3006
+ function loopsRoot() {
3007
+ return runtimeDirForThisRepo();
3008
+ }
3009
+ function loopLogPathFor(_repo, issue, root = loopsRoot()) {
3010
+ return runPath(root, issue, { area: "output", file: "driver.log" });
3011
+ }
3012
+ var LOOP_LOG_MAX_BYTES = 8 * 1024 * 1024;
3013
+ function appendLoopLogLine(path, line) {
3014
+ try {
3015
+ mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
3016
+ const fd = openSync3(path, fsConstants3.O_WRONLY | fsConstants3.O_APPEND | fsConstants3.O_CREAT | fsConstants3.O_NOFOLLOW, 384);
3017
+ try {
3018
+ const stat = fstatSync2(fd);
3019
+ if (stat.isFile() && stat.size < LOOP_LOG_MAX_BYTES) {
3020
+ writeSync2(fd, `${line}
3021
+ `);
3022
+ }
3023
+ } finally {
3024
+ closeSync3(fd);
3025
+ }
3026
+ } catch {}
3027
+ }
3028
+
3029
+ // src/lib/log-webhook-drain.ts
3030
+ import {
3031
+ closeSync as closeSync4,
3032
+ constants as fsConstants4,
3033
+ lstatSync as lstatSync2,
3034
+ mkdirSync as mkdirSync4,
3035
+ openSync as openSync4,
3036
+ linkSync as linkSync2,
3037
+ readFileSync as readFileSync5,
3038
+ renameSync as renameSync2,
3039
+ statSync as statSync3,
2875
3040
  unlinkSync as unlinkSync2,
2876
3041
  utimesSync,
2877
3042
  writeFileSync as writeFileSync2,
2878
- writeSync as writeSync2
3043
+ writeSync as writeSync3
2879
3044
  } from "node:fs";
2880
3045
  import { randomUUID } from "node:crypto";
2881
3046
  import { homedir as homedir2 } from "node:os";
2882
- import { dirname as dirname5, join as join6 } from "node:path";
3047
+ import { dirname as dirname6, join as join6 } from "node:path";
2883
3048
  var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
2884
3049
  var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
2885
3050
  var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
@@ -2895,13 +3060,13 @@ function isEnoent(err) {
2895
3060
  var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
2896
3061
  function tryCreateLock(lockPath, token) {
2897
3062
  try {
2898
- mkdirSync3(dirname5(lockPath), { recursive: true, mode: 448 });
2899
- const fd = openSync3(lockPath, fsConstants3.O_WRONLY | fsConstants3.O_CREAT | fsConstants3.O_EXCL, 384);
3063
+ mkdirSync4(dirname6(lockPath), { recursive: true, mode: 448 });
3064
+ const fd = openSync4(lockPath, fsConstants4.O_WRONLY | fsConstants4.O_CREAT | fsConstants4.O_EXCL, 384);
2900
3065
  try {
2901
- writeSync2(fd, `${token}
3066
+ writeSync3(fd, `${token}
2902
3067
  `);
2903
3068
  } finally {
2904
- closeSync3(fd);
3069
+ closeSync4(fd);
2905
3070
  }
2906
3071
  return true;
2907
3072
  } catch (err) {
@@ -2916,7 +3081,7 @@ function acquireDrainLock(lockPath) {
2916
3081
  return token;
2917
3082
  let observedMtimeMs;
2918
3083
  try {
2919
- observedMtimeMs = statSync2(lockPath).mtimeMs;
3084
+ observedMtimeMs = statSync3(lockPath).mtimeMs;
2920
3085
  } catch (err) {
2921
3086
  if (!isEnoent(err))
2922
3087
  throw err;
@@ -2934,7 +3099,7 @@ function acquireDrainLock(lockPath) {
2934
3099
  }
2935
3100
  let claimedMtimeMs = null;
2936
3101
  try {
2937
- claimedMtimeMs = statSync2(claimed).mtimeMs;
3102
+ claimedMtimeMs = statSync3(claimed).mtimeMs;
2938
3103
  } catch (err) {
2939
3104
  if (!isEnoent(err))
2940
3105
  throw err;
@@ -2960,7 +3125,7 @@ function acquireDrainLock(lockPath) {
2960
3125
  function renewDrainLock(lockPath, token) {
2961
3126
  let holder;
2962
3127
  try {
2963
- holder = readFileSync4(lockPath, "utf8").trim();
3128
+ holder = readFileSync5(lockPath, "utf8").trim();
2964
3129
  } catch (err) {
2965
3130
  if (!isEnoent(err))
2966
3131
  throw err;
@@ -2980,7 +3145,7 @@ function renewDrainLock(lockPath, token) {
2980
3145
  }
2981
3146
  function releaseDrainLock(lockPath, token) {
2982
3147
  try {
2983
- const holder = readFileSync4(lockPath, "utf8").trim();
3148
+ const holder = readFileSync5(lockPath, "utf8").trim();
2984
3149
  if (holder !== token)
2985
3150
  return;
2986
3151
  unlinkSync2(lockPath);
@@ -3030,7 +3195,7 @@ function queueLines(buf) {
3030
3195
  return lines;
3031
3196
  }
3032
3197
  function removeQueueHead(path, cut) {
3033
- const remaining = readFileSync4(path);
3198
+ const remaining = readFileSync5(path);
3034
3199
  writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
3035
3200
  }
3036
3201
  function queueBucketSize(path) {
@@ -3051,7 +3216,7 @@ function queueBucketSize(path) {
3051
3216
  function readQueueFile(path) {
3052
3217
  if (queueBucketSize(path) === null)
3053
3218
  return null;
3054
- return readFileSync4(path);
3219
+ return readFileSync5(path);
3055
3220
  }
3056
3221
  function rejectLine(rejectedPath, reason, status, identity, raw) {
3057
3222
  const record = JSON.stringify({
@@ -3233,13 +3398,19 @@ function logsCredentialMissing(headers, env) {
3233
3398
  const varPattern = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
3234
3399
  for (const value of Object.values(headers)) {
3235
3400
  for (const match of value.matchAll(varPattern)) {
3236
- if (!env[match[1]])
3237
- return true;
3401
+ const name = match[1];
3402
+ if (env[name])
3403
+ continue;
3404
+ return true;
3238
3405
  }
3239
3406
  }
3240
3407
  return false;
3241
3408
  }
3242
3409
  function resolveLogDestinationFrom(input) {
3410
+ const spoolDir = input.env.VINAYA_LOG_SPOOL_DIR;
3411
+ if (spoolDir !== undefined && spoolDir.trim() !== "") {
3412
+ return { kind: "folder", folder: spoolDir };
3413
+ }
3243
3414
  const local = resolveLogsSetting(input.localConfig);
3244
3415
  let effective = null;
3245
3416
  let fallbackReason;
@@ -3279,23 +3450,72 @@ function resolveLogDestinationFrom(input) {
3279
3450
  const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
3280
3451
  return fallbackReason ? { kind: "folder", folder, fallbackReason } : { kind: "folder", folder };
3281
3452
  }
3282
- var processTrustAnchorOnce;
3283
- function processTrustAnchor() {
3284
- if (processTrustAnchorOnce === undefined)
3285
- processTrustAnchorOnce = safeLoadTrustAnchorConfig();
3286
- return processTrustAnchorOnce;
3453
+ var processTrustAnchorByRepo = new Map;
3454
+ function processTrustAnchor(repoRoot) {
3455
+ const cached = processTrustAnchorByRepo.get(repoRoot);
3456
+ if (cached !== undefined)
3457
+ return cached;
3458
+ const reading = safeLoadTrustAnchorConfig();
3459
+ processTrustAnchorByRepo.set(repoRoot, reading);
3460
+ return reading;
3287
3461
  }
3288
3462
  async function defaultResolveLogDestination(repo, env) {
3289
3463
  const localConfig = loadConfig();
3290
3464
  const unattended = isUnattendedProcess(process.env);
3465
+ const repoRoot = repoRootSync();
3291
3466
  return resolveLogDestinationFrom({
3292
3467
  localConfig,
3293
- trustAnchorConfig: unattended ? await processTrustAnchor() : null,
3468
+ trustAnchorConfig: unattended ? await processTrustAnchor(repoRoot) : null,
3294
3469
  unattended,
3295
3470
  env,
3296
3471
  defaultFolder: join7(await runtimeDirForRepoAsync(repo), "logs"),
3297
- repoRoot: repoRootSync()
3472
+ repoRoot
3473
+ });
3474
+ }
3475
+ function unresolvedLogDestination(env) {
3476
+ if (hostFromEnv(env) === "ci") {
3477
+ return {
3478
+ kind: "none",
3479
+ reason: "the process ended before its log destination was resolved, and a CI job never records to a folder"
3480
+ };
3481
+ }
3482
+ const loaded = loadConfig();
3483
+ const localConfig = loaded?.logs?.url !== undefined ? { ...loaded, logs: undefined } : loaded;
3484
+ const unattended = isUnattendedProcess(process.env);
3485
+ const repoRoot = repoRootSync();
3486
+ const runtimeDir = process.env[RUNTIME_DIR_ENV_KEY] || resolveRuntimeDir({ repo: null, localConfig, trustAnchorConfig: null, unattended, repoRoot });
3487
+ const defaultFolder = join7(runtimeDir, "logs");
3488
+ const resolved = resolveLogDestinationFrom({
3489
+ localConfig,
3490
+ trustAnchorConfig: null,
3491
+ unattended,
3492
+ env,
3493
+ defaultFolder,
3494
+ repoRoot
3298
3495
  });
3496
+ return resolved.kind === "folder" ? resolved : { kind: "folder", folder: defaultFolder };
3497
+ }
3498
+ function folderFallbackStatePath(repo, stateRoot = GLOBAL_VINAYA_HOME) {
3499
+ const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
3500
+ return join7(stateRoot, "fallback", `${dirName}.json`);
3501
+ }
3502
+ function recordFolderFallback(repo, issue, reason, now, runtimeDir, stateRoot = GLOBAL_VINAYA_HOME) {
3503
+ const message = describeFolderFallback(reason);
3504
+ if (issue !== null) {
3505
+ appendLoopLogLine(loopLogPathFor(repo, issue, runtimeDir), `[log] ${message}`);
3506
+ }
3507
+ try {
3508
+ const record = {
3509
+ at: now.toISOString(),
3510
+ reason: message,
3511
+ intendedUrl: reason.intendedUrl,
3512
+ kind: reason.kind
3513
+ };
3514
+ const path = folderFallbackStatePath(repo, stateRoot);
3515
+ mkdirSync5(dirname7(path), { recursive: true, mode: 448 });
3516
+ writeFileSync3(path, `${JSON.stringify(record)}
3517
+ `, { mode: 384 });
3518
+ } catch {}
3299
3519
  }
3300
3520
  function isEnoent2(err) {
3301
3521
  return typeof err === "object" && err !== null && err.code === "ENOENT";
@@ -3409,7 +3629,7 @@ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
3409
3629
  }
3410
3630
  function readVinayaVersion() {
3411
3631
  try {
3412
- const pkg = JSON.parse(readFileSync5(join7(packageRoot(import.meta.url), "package.json"), "utf8"));
3632
+ const pkg = JSON.parse(readFileSync6(join7(packageRoot(import.meta.url), "package.json"), "utf8"));
3413
3633
  return pkg.version ?? "unknown";
3414
3634
  } catch {
3415
3635
  return "unknown";
@@ -3447,6 +3667,7 @@ function defaultStderr(message) {
3447
3667
  }
3448
3668
  var branchIssueFallbackEnabled = true;
3449
3669
  var branchIssueByCwd = new Map;
3670
+ var branchIssueSettledByCwd = new Map;
3450
3671
  function branchIssueRead(key, read, shared) {
3451
3672
  if (!shared)
3452
3673
  return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
@@ -3455,8 +3676,30 @@ function branchIssueRead(key, read, shared) {
3455
3676
  return cached;
3456
3677
  const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
3457
3678
  branchIssueByCwd.set(key, reading);
3679
+ reading.then((value) => branchIssueSettledByCwd.set(key, value));
3458
3680
  return reading;
3459
3681
  }
3682
+ var headShaByCwd = new Map;
3683
+ var headShaSettledByCwd = new Map;
3684
+ function headShaRead(key, read, shared) {
3685
+ if (!shared)
3686
+ return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
3687
+ const cached = headShaByCwd.get(key);
3688
+ if (cached !== undefined)
3689
+ return cached;
3690
+ const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
3691
+ headShaByCwd.set(key, reading);
3692
+ reading.then((value) => headShaSettledByCwd.set(key, value));
3693
+ return reading;
3694
+ }
3695
+ async function resolveHeadSha(cwd) {
3696
+ try {
3697
+ const out = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "HEAD"], { encoding: "utf8" })).stdout.trim();
3698
+ return /^[0-9a-f]{40}$/.test(out) ? out : null;
3699
+ } catch {
3700
+ return null;
3701
+ }
3702
+ }
3460
3703
  function defaultDeps() {
3461
3704
  return {
3462
3705
  outboxRoot: () => join7(GLOBAL_VINAYA_HOME, "outbox"),
@@ -3471,29 +3714,30 @@ function defaultDeps() {
3471
3714
  inputVersions: () => {
3472
3715
  return;
3473
3716
  },
3474
- resolveLogDestination: defaultResolveLogDestination
3717
+ resolveLogDestination: defaultResolveLogDestination,
3718
+ unresolvedLogDestination
3475
3719
  };
3476
3720
  }
3477
- var APPEND_OPEN_FLAGS = fsConstants4.O_WRONLY | fsConstants4.O_APPEND | fsConstants4.O_CREAT | fsConstants4.O_NOFOLLOW | fsConstants4.O_NONBLOCK;
3721
+ var APPEND_OPEN_FLAGS = fsConstants5.O_WRONLY | fsConstants5.O_APPEND | fsConstants5.O_CREAT | fsConstants5.O_NOFOLLOW | fsConstants5.O_NONBLOCK;
3478
3722
  function guardedAppendOpen(path) {
3479
3723
  try {
3480
- return openSync4(path, APPEND_OPEN_FLAGS, 384);
3724
+ return openSync5(path, APPEND_OPEN_FLAGS, 384);
3481
3725
  } catch {
3482
3726
  return;
3483
3727
  }
3484
3728
  }
3485
3729
  function appendHardenedLine(path, line) {
3486
3730
  try {
3487
- mkdirSync4(dirname6(path), { recursive: true, mode: 448 });
3731
+ mkdirSync5(dirname7(path), { recursive: true, mode: 448 });
3488
3732
  const fd = guardedAppendOpen(path);
3489
3733
  if (fd === undefined)
3490
3734
  return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
3491
3735
  try {
3492
- if (!fstatSync2(fd).isFile())
3736
+ if (!fstatSync3(fd).isFile())
3493
3737
  return `target is not a regular file: ${path}`;
3494
- writeSync3(fd, line);
3738
+ writeSync4(fd, line);
3495
3739
  } finally {
3496
- closeSync4(fd);
3740
+ closeSync5(fd);
3497
3741
  }
3498
3742
  return null;
3499
3743
  } catch (err) {
@@ -3503,7 +3747,7 @@ function appendHardenedLine(path, line) {
3503
3747
  function reportRotationOverflow(backupPath, warn) {
3504
3748
  let raw;
3505
3749
  try {
3506
- raw = readFileSync5(backupPath, "utf8");
3750
+ raw = readFileSync6(backupPath, "utf8");
3507
3751
  } catch {
3508
3752
  return;
3509
3753
  }
@@ -3526,7 +3770,7 @@ function reportRotationOverflow(backupPath, warn) {
3526
3770
  }
3527
3771
  function appendLine(path, line, warn) {
3528
3772
  try {
3529
- mkdirSync4(dirname6(path), { recursive: true, mode: 448 });
3773
+ mkdirSync5(dirname7(path), { recursive: true, mode: 448 });
3530
3774
  let fd = guardedAppendOpen(path);
3531
3775
  if (fd === undefined) {
3532
3776
  warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
@@ -3535,14 +3779,14 @@ function appendLine(path, line, warn) {
3535
3779
  }
3536
3780
  let closed = false;
3537
3781
  try {
3538
- const stat = fstatSync2(fd);
3782
+ const stat = fstatSync3(fd);
3539
3783
  if (!stat.isFile()) {
3540
3784
  warn(`vinaya: log outbox target is not a regular file — refusing to write: ${path}
3541
3785
  `);
3542
3786
  return;
3543
3787
  }
3544
3788
  if (stat.size > OUTBOX_MAX_BYTES) {
3545
- closeSync4(fd);
3789
+ closeSync5(fd);
3546
3790
  closed = true;
3547
3791
  const backupPath = path.replace(/\.ndjson$/, ".1.ndjson");
3548
3792
  reportRotationOverflow(backupPath, warn);
@@ -3556,10 +3800,10 @@ function appendLine(path, line, warn) {
3556
3800
  fd = rotated;
3557
3801
  closed = false;
3558
3802
  }
3559
- writeSync3(fd, line);
3803
+ writeSync4(fd, line);
3560
3804
  } finally {
3561
3805
  if (!closed)
3562
- closeSync4(fd);
3806
+ closeSync5(fd);
3563
3807
  }
3564
3808
  } catch (err) {
3565
3809
  warn(`vinaya: log outbox write failed — ${err instanceof Error ? err.message : String(err)}
@@ -3570,12 +3814,14 @@ function createLogSink(overrides = {}) {
3570
3814
  const deps = {
3571
3815
  ...defaultDeps(),
3572
3816
  resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
3817
+ resolveHeadSha: () => resolveHeadSha(deps.cwd()),
3573
3818
  ...overrides
3574
3819
  };
3575
3820
  const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
3576
3821
  const processId = randomUUID2();
3577
3822
  let seq = 0;
3578
3823
  let warned = false;
3824
+ let folderFallbackRecorded = false;
3579
3825
  const warnOnce = (message) => {
3580
3826
  if (warned)
3581
3827
  return;
@@ -3593,6 +3839,7 @@ function createLogSink(overrides = {}) {
3593
3839
  };
3594
3840
  const readerIsReal = overrides.resolveBranchIssue === undefined;
3595
3841
  let ownBranchIssue;
3842
+ let ownBranchIssueSettled = null;
3596
3843
  const branchIssueOnce = (repo) => {
3597
3844
  if (!branchIssueFallbackEnabled)
3598
3845
  return Promise.resolve(null);
@@ -3600,10 +3847,36 @@ function createLogSink(overrides = {}) {
3600
3847
  const read = () => deps.resolveBranchIssue(slug);
3601
3848
  if (readerIsReal)
3602
3849
  return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
3603
- if (ownBranchIssue === undefined)
3850
+ if (ownBranchIssue === undefined) {
3604
3851
  ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
3852
+ ownBranchIssue.then((value) => {
3853
+ ownBranchIssueSettled = value;
3854
+ });
3855
+ }
3605
3856
  return ownBranchIssue;
3606
3857
  };
3858
+ const branchIssueIfSettled = (repo) => {
3859
+ if (!branchIssueFallbackEnabled)
3860
+ return null;
3861
+ if (!readerIsReal)
3862
+ return ownBranchIssueSettled;
3863
+ return branchIssueSettledByCwd.get(`${deps.cwd()}\x00${safeRepoSlug(repo) ?? ""}`) ?? null;
3864
+ };
3865
+ const headShaReaderIsReal = overrides.resolveHeadSha === undefined;
3866
+ let ownHeadSha;
3867
+ let ownHeadShaSettled = null;
3868
+ const headShaOnce = () => {
3869
+ if (headShaReaderIsReal)
3870
+ return headShaRead(deps.cwd(), deps.resolveHeadSha, true);
3871
+ if (ownHeadSha === undefined) {
3872
+ ownHeadSha = headShaRead(deps.cwd(), deps.resolveHeadSha, false);
3873
+ ownHeadSha.then((value) => {
3874
+ ownHeadShaSettled = value;
3875
+ });
3876
+ }
3877
+ return ownHeadSha;
3878
+ };
3879
+ const headShaIfSettled = () => headShaReaderIsReal ? headShaSettledByCwd.get(deps.cwd()) ?? null : ownHeadShaSettled;
3607
3880
  let resolveRepoCache;
3608
3881
  const resolveRepoOnce = () => {
3609
3882
  if (resolveRepoCache === undefined)
@@ -3611,6 +3884,7 @@ function createLogSink(overrides = {}) {
3611
3884
  return resolveRepoCache;
3612
3885
  };
3613
3886
  let contextCache;
3887
+ let settledContext;
3614
3888
  const context = () => {
3615
3889
  if (contextCache === undefined) {
3616
3890
  const env = deps.env();
@@ -3619,11 +3893,16 @@ function createLogSink(overrides = {}) {
3619
3893
  doctrine()
3620
3894
  ]).then(async ([resolved, doctrineValue]) => {
3621
3895
  const repo = resolved && isSafeRepoSegment3(resolved.owner) && isSafeRepoSegment3(resolved.repo) ? resolved : null;
3622
- return { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
3896
+ settledContext = { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
3897
+ return settledContext;
3623
3898
  });
3624
3899
  }
3625
3900
  return contextCache;
3626
3901
  };
3902
+ const resetContext = () => {
3903
+ contextCache = undefined;
3904
+ settledContext = undefined;
3905
+ };
3627
3906
  let drainChain = Promise.resolve();
3628
3907
  const pendingWrites = new Set;
3629
3908
  let writeChain = Promise.resolve();
@@ -3635,63 +3914,88 @@ function createLogSink(overrides = {}) {
3635
3914
  `);
3636
3915
  });
3637
3916
  };
3638
- function log(e) {
3639
- try {
3640
- const env = deps.env();
3641
- const host = hostFromEnv(env);
3642
- const now = deps.now();
3643
- const mySeq = seq++;
3644
- const envFields = {
3917
+ const snapshot = () => {
3918
+ const env = deps.env();
3919
+ return {
3920
+ host: hostFromEnv(env),
3921
+ now: deps.now(),
3922
+ seq: seq++,
3923
+ envFields: {
3645
3924
  role: env.VINAYA_ROLE,
3646
3925
  task: env.VINAYA_TASK,
3647
3926
  round: env.VINAYA_ROUND,
3927
+ pr: env.VINAYA_PR,
3648
3928
  run: env.VINAYA_RUN || runId,
3649
3929
  attempt: env.VINAYA_ATTEMPT,
3650
- parent: env.VINAYA_PARENT_EVENT
3651
- };
3652
- const write = async () => {
3653
- const { repo, doctrine: doctrineValue, destination: resolvedDestination } = await context();
3654
- if (resolvedDestination.kind === "none") {
3655
- warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
3930
+ parent: env.VINAYA_PARENT_EVENT,
3931
+ workRef: env.VINAYA_WORK_REF,
3932
+ flow: env.VINAYA_FLOW,
3933
+ flowVersion: env.VINAYA_FLOW_VERSION,
3934
+ runtime: env.VINAYA_RUNTIME,
3935
+ source: env.VINAYA_SOURCE
3936
+ }
3937
+ };
3938
+ };
3939
+ const writeEvent = (e, call, ctx, branchIssue, headSha, deliver) => {
3940
+ const { repo, doctrine: doctrineValue, destination } = ctx;
3941
+ if (destination.kind === "none") {
3942
+ warnOnce(`vinaya: not recording — ${destination.reason}
3656
3943
  `);
3657
- return;
3658
- }
3659
- if (resolvedDestination.kind === "folder" && resolvedDestination.fallbackReason) {
3660
- warnOnce(`vinaya: ${describeFolderFallback(resolvedDestination.fallbackReason)}
3944
+ return;
3945
+ }
3946
+ if (destination.kind === "folder" && destination.fallbackReason) {
3947
+ warnOnce(`vinaya: ${describeFolderFallback(destination.fallbackReason)}
3661
3948
  `);
3662
- }
3663
- const branchIssue = envFields.task ? null : await branchIssueOnce(repo);
3664
- const header = buildHeader({
3665
- now,
3666
- runId,
3667
- seq: mySeq,
3668
- repo: repo ? `${repo.owner}/${repo.repo}` : null,
3669
- vinaya: deps.vinayaVersion(),
3670
- doctrine: doctrineValue,
3671
- host,
3672
- hostname: deps.hostname(),
3673
- env: envFields,
3674
- branchIssue,
3675
- eventId: randomUUID2(),
3676
- processId,
3677
- inputVersions: deps.inputVersions()
3678
- });
3679
- const full = { ...e, ...header };
3680
- const parsed = LogEventSchema.safeParse(full);
3681
- if (!parsed.success) {
3682
- warnOnce(`vinaya: log() refused an invalid payload — ${parsed.error.issues[0]?.message ?? "schema violation"}
3949
+ }
3950
+ const built = buildHeader({
3951
+ now: call.now,
3952
+ runId,
3953
+ seq: call.seq,
3954
+ repo: repo ? `${repo.owner}/${repo.repo}` : null,
3955
+ vinaya: deps.vinayaVersion(),
3956
+ doctrine: doctrineValue,
3957
+ host: call.host,
3958
+ hostname: deps.hostname(),
3959
+ env: call.envFields,
3960
+ branchIssue,
3961
+ eventId: randomUUID2(),
3962
+ processId,
3963
+ inputVersions: deps.inputVersions()
3964
+ });
3965
+ const header = headSha === null ? built : { ...built, subject: { ...built.subject, sha: headSha } };
3966
+ if (destination.kind === "folder" && destination.fallbackReason && !folderFallbackRecorded) {
3967
+ folderFallbackRecorded = true;
3968
+ recordFolderFallback(repo, header.subject.issue, destination.fallbackReason, call.now, dirname7(destination.folder), join7(deps.home(), ".vinaya"));
3969
+ }
3970
+ const full = { ...e, ...header };
3971
+ const parsed = LogEventSchema.safeParse(full);
3972
+ if (!parsed.success) {
3973
+ warnOnce(`vinaya: log() refused an invalid payload — ${parsed.error.issues[0]?.message ?? "schema violation"}
3683
3974
  `);
3684
- return;
3685
- }
3686
- const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
3975
+ return;
3976
+ }
3977
+ const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
3687
3978
  `;
3688
- const destination = resolvedDestination;
3689
- if (destination.kind === "server") {
3690
- appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
3691
- scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
3692
- } else {
3693
- appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
3979
+ if (destination.kind === "server") {
3980
+ appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
3981
+ if (deliver)
3982
+ scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
3983
+ } else {
3984
+ appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
3985
+ }
3986
+ };
3987
+ function log(e) {
3988
+ try {
3989
+ const call = snapshot();
3990
+ const write = async () => {
3991
+ const ctx = await context();
3992
+ if (ctx.destination.kind === "none") {
3993
+ writeEvent(e, call, ctx, null, null, true);
3994
+ return;
3694
3995
  }
3996
+ const branchIssue = call.envFields.task ? null : await branchIssueOnce(ctx.repo);
3997
+ const headSha = e.kind === "gate" ? await headShaOnce() : null;
3998
+ writeEvent(e, call, ctx, branchIssue, headSha, true);
3695
3999
  };
3696
4000
  const written = writeChain.then(write).catch((err) => {
3697
4001
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
@@ -3702,6 +4006,26 @@ function createLogSink(overrides = {}) {
3702
4006
  written.finally(() => pendingWrites.delete(written));
3703
4007
  } catch (err) {
3704
4008
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
4009
+ `);
4010
+ }
4011
+ }
4012
+ function logSync(e, opts = {}) {
4013
+ try {
4014
+ const call = snapshot();
4015
+ let ctx = settledContext;
4016
+ if (ctx === undefined) {
4017
+ const destination = deps.unresolvedLogDestination(deps.env());
4018
+ if (destination.kind === "folder" && !opts.quiet) {
4019
+ 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
4020
+ `);
4021
+ }
4022
+ ctx = { repo: null, doctrine: "unknown", destination };
4023
+ }
4024
+ const branchIssue = ctx.destination.kind === "none" || call.envFields.task ? null : branchIssueIfSettled(ctx.repo);
4025
+ const headSha = e.kind === "gate" && ctx.destination.kind !== "none" ? headShaIfSettled() : null;
4026
+ writeEvent(e, call, ctx, branchIssue, headSha, false);
4027
+ } catch (err) {
4028
+ warnOnce(`vinaya: logSync() failed — ${err instanceof Error ? err.message : String(err)}
3705
4029
  `);
3706
4030
  }
3707
4031
  }
@@ -3722,18 +4046,15 @@ function createLogSink(overrides = {}) {
3722
4046
  return;
3723
4047
  });
3724
4048
  };
3725
- return { log, runId, warmup, drain };
4049
+ return { log, logSync, runId, warmup, drain, resetContext };
3726
4050
  }
3727
4051
  var defaultSink = createLogSink();
3728
4052
 
3729
4053
  // src/checks/runner.ts
3730
4054
  var activeChecks = new Map;
3731
4055
 
3732
- // src/lib/loop-log.ts
3733
- var LOOP_LOG_MAX_BYTES = 8 * 1024 * 1024;
3734
-
3735
4056
  // src/lib/brief-assembly.ts
3736
- import { existsSync as existsSync7, readFileSync as readFileSync6, readdirSync as readdirSync2 } from "node:fs";
4057
+ import { existsSync as existsSync7, readFileSync as readFileSync7, readdirSync as readdirSync2 } from "node:fs";
3737
4058
  import { join as join8 } from "node:path";
3738
4059
 
3739
4060
  // ../../packages/sources/src/commands.ts
@@ -3884,20 +4205,31 @@ var COMMANDS = [
3884
4205
  {
3885
4206
  flag: "--agent <claude|codex|gemini>",
3886
4207
  description: "Vendor for the developer and both reviewers this run dispatches"
4208
+ },
4209
+ {
4210
+ flag: "--quiet",
4211
+ description: "Hide the detail lines (an agent's prose, full commands, failed-result tails) on the live terminal; the driver log file keeps them"
3887
4212
  }
3888
4213
  ],
3889
4214
  details: [
3890
4215
  "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.",
3891
4216
  "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.",
3892
4217
  "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.",
3893
- "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`)."
4218
+ "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`)."
3894
4219
  ],
3895
4220
  status: "shipped"
3896
4221
  },
3897
4222
  {
3898
4223
  name: "task status",
3899
4224
  description: "Every open task with a frozen brief, its pull request, and whether its loop is running, paused, or published",
3900
- flags: [{ flag: "--json", description: "Enveloped JSON output (schema: 1)" }],
4225
+ flags: [
4226
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" },
4227
+ {
4228
+ flag: "--follow",
4229
+ description: "Tail the task's driver log live, with its detail lines, on either the `<tranche> <n>` form or `--issue <n>`"
4230
+ },
4231
+ { flag: "--quiet", description: "With `--follow`, hide the detail lines; the log file is unchanged" }
4232
+ ],
3901
4233
  details: [
3902
4234
  "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`.",
3903
4235
  "`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.",
@@ -3933,6 +4265,26 @@ var COMMANDS = [
3933
4265
  ],
3934
4266
  status: "shipped"
3935
4267
  },
4268
+ {
4269
+ name: "task-tools result-proof",
4270
+ description: "Prove, live on this host, that a CLI delivers the Developer's turn result as its own structured final output",
4271
+ flags: [{ flag: "--agent <claude|codex>", description: "The CLI to prove" }],
4272
+ details: [
4273
+ "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`.",
4274
+ "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."
4275
+ ],
4276
+ status: "shipped"
4277
+ },
4278
+ {
4279
+ name: "task-tools review-result-proof",
4280
+ description: "Prove, live on this host, that a CLI delivers a reviewer's result as its own structured final output, concurrent and fresh",
4281
+ flags: [{ flag: "--agent <claude|codex>", description: "The CLI to prove" }],
4282
+ details: [
4283
+ "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.",
4284
+ "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."
4285
+ ],
4286
+ status: "shipped"
4287
+ },
3936
4288
  {
3937
4289
  name: "pr create",
3938
4290
  description: "Open a pull request after full brief-schema validation",
@@ -3975,13 +4327,14 @@ var COMMANDS = [
3975
4327
  },
3976
4328
  {
3977
4329
  flag: "--push",
3978
- 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."
4330
+ 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."
3979
4331
  }
3980
4332
  ],
3981
4333
  details: [
3982
4334
  "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.",
3983
4335
  "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.",
3984
- "`--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."
4336
+ "`--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.",
4337
+ "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."
3985
4338
  ],
3986
4339
  status: "shipped"
3987
4340
  },
@@ -4006,7 +4359,7 @@ var COMMANDS = [
4006
4359
  "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.",
4007
4360
  "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.",
4008
4361
  "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.",
4009
- "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."
4362
+ "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."
4010
4363
  ],
4011
4364
  status: "shipped"
4012
4365
  },
@@ -4177,7 +4530,7 @@ var COMMANDS = [
4177
4530
  { flag: "--secrets", description: "security only: the SECRETS line" },
4178
4531
  {
4179
4532
  flag: "--secrets-evidence-file",
4180
- description: 'security only: required whenever `--secrets` claims "none found" — the pasted scanner output backing that claim'
4533
+ 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'
4181
4534
  },
4182
4535
  { flag: "--task-id", description: "the closing `Tokens:` line's task id" },
4183
4536
  { flag: "--model", description: "the closing `Tokens:` line's model name" },
@@ -4285,7 +4638,20 @@ var COMMANDS = [
4285
4638
  flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
4286
4639
  details: [
4287
4640
  "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.",
4288
- "Once every task Issue is closed, prompts for confirmation (unless `--yes`) and closes the GitHub Milestone."
4641
+ "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.",
4642
+ "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.",
4643
+ "Idempotent: on a tranche whose Milestone is already closed and carries its retrospective, changes nothing and says it is already archived.",
4644
+ "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."
4645
+ ],
4646
+ status: "shipped"
4647
+ },
4648
+ {
4649
+ name: "archive tranches",
4650
+ description: "Archive every finished tranche that has no closed Milestone carrying its retrospective",
4651
+ flags: [{ flag: "--yes", description: "Skip the confirmation prompt" }],
4652
+ details: [
4653
+ "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.",
4654
+ "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."
4289
4655
  ],
4290
4656
  status: "shipped"
4291
4657
  },
@@ -4429,6 +4795,29 @@ var COMMANDS = [
4429
4795
  ],
4430
4796
  status: "shipped"
4431
4797
  },
4798
+ {
4799
+ name: "log selftest",
4800
+ 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)",
4801
+ details: [
4802
+ "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.",
4803
+ "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.",
4804
+ "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."
4805
+ ],
4806
+ status: "shipped"
4807
+ },
4808
+ {
4809
+ name: "log emit",
4810
+ description: "Record a consumer-declared event (`logs.events` in vinaya.config.json) from a script or agent outside Vinaya",
4811
+ flags: [
4812
+ { flag: "--json '<json>'", description: "The field values as one JSON object (else read from standard input)" }
4813
+ ],
4814
+ details: [
4815
+ "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.",
4816
+ "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.",
4817
+ "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)."
4818
+ ],
4819
+ status: "shipped"
4820
+ },
4432
4821
  {
4433
4822
  name: "log send",
4434
4823
  description: "Deliver this repository's locally-held log events to the configured `logs.url` server, once",
@@ -4441,28 +4830,42 @@ var COMMANDS = [
4441
4830
  status: "shipped"
4442
4831
  },
4443
4832
  {
4444
- name: "log set-credential",
4445
- description: "Store a `logs.headers` delivery credential in the macOS login Keychain, read from standard input",
4833
+ name: "sync",
4834
+ description: "Fill, resume and rebuild the local log cache from this repository's configured destination (read-only)",
4835
+ flags: [
4836
+ {
4837
+ flag: "--rebuild",
4838
+ description: "Delete the cache file and sync from the beginning of what the destination still retains"
4839
+ },
4840
+ { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
4841
+ ],
4446
4842
  details: [
4447
- '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.',
4448
- '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.',
4449
- "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."
4843
+ "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.",
4844
+ "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.",
4845
+ "`--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."
4450
4846
  ],
4451
4847
  status: "shipped"
4452
4848
  }
4453
4849
  ];
4454
4850
  // ../../packages/sources/src/select-source.ts
4455
- import { z as z5 } from "zod";
4456
- var StateSourceConfigSchema = z5.discriminatedUnion("kind", [
4457
- z5.object({ kind: z5.literal("forge"), owner: z5.string(), repo: z5.string() }),
4458
- z5.object({ kind: z5.literal("file"), root: z5.string().optional() })
4851
+ import { z as z6 } from "zod";
4852
+ var StateSourceConfigSchema = z6.discriminatedUnion("kind", [
4853
+ z6.object({ kind: z6.literal("forge"), owner: z6.string(), repo: z6.string() }),
4854
+ z6.object({ kind: z6.literal("file"), root: z6.string().optional() })
4459
4855
  ]);
4460
4856
  // src/checks/edge-resolve.ts
4461
4857
  var issueCache = new Map;
4462
4858
  var siblingTrancheCache = new Map;
4463
4859
 
4464
4860
  // src/commands/doctrine.ts
4861
+ import matter4 from "gray-matter";
4862
+
4863
+ // ../../packages/aeg-core/src/docs/parse-doc.ts
4465
4864
  import matter2 from "gray-matter";
4865
+ // ../../packages/aeg-core/src/docs/surfaced-manifest.ts
4866
+ var NO_MODEL_BACKED_PATHS = new Set;
4867
+ // src/roles/contract.ts
4868
+ import matter3 from "gray-matter";
4466
4869
 
4467
4870
  // src/lib/brief-assembly.ts
4468
4871
  var PACKAGE_ROOT = packageRoot(import.meta.url);
@@ -4478,31 +4881,6 @@ var INFORMATIONAL_DISPATCH_BLOCKER_CLASSES = new Set([
4478
4881
  "conflicts-with"
4479
4882
  ]);
4480
4883
 
4481
- // src/lib/dispatch.ts
4482
- var MAX_TEE_BYTES = 8 * 1024 * 1024;
4483
- var CLAUDE_MODEL_ALIASES = new Set(["fable", "opus", "sonnet", "haiku"]);
4484
- var NO_SUBSCRIPTION_LOGIN_REASON = "this agent has no subscription login in Vinaya yet, and no agent authenticates with an API key — " + "dispatch a vendor whose subscription login Vinaya can stage (claude, codex)";
4485
-
4486
- // src/commands/tokens.ts
4487
- var USAGE = [
4488
- 'Usage: vinaya tokens --phase "<task-id>: develop" --role Developer',
4489
- " [--model <id>] [--transcript <path>] [--in <tokens-in> --out <tokens-out>]",
4490
- "",
4491
- " --transcript Read this transcript directly. Supported primary route — use it whenever you know",
4492
- " which transcript is yours, and always in a repo with no track-transcript.sh hook.",
4493
- " (omitted) Resolve via the Stop-hook pointer file, if this repo installs that hook.",
4494
- " --in/--out Manual entry: the exact token figures, for a host whose usage arrives by some other",
4495
- " means than a Claude Code transcript. Both required together; skips transcript",
4496
- " resolution entirely.",
4497
- "",
4498
- "Usage: vinaya tokens --trust-collect",
4499
- " Approves this repo's declared tokens.collect command, pinned to the script's exact current",
4500
- " content, on this machine. Run this once before tokens.collect will ever execute — a changed",
4501
- " interpreter, script path, or script CONTENT needs its own fresh approval. Does not take",
4502
- " --phase/--role and never emits a Tokens: line."
4503
- ].join(`
4504
- `);
4505
-
4506
4884
  // src/lib/pr-report-engine.ts
4507
4885
  var execFileAsync6 = promisify6(execFile6);
4508
4886
  var BODY_READING_CHECK_NAMES = new Set(coreCheckRegistry().filter((spec) => {
@@ -4512,21 +4890,21 @@ var BODY_READING_CHECK_NAMES = new Set(coreCheckRegistry().filter((spec) => {
4512
4890
  var FAILING_STATUSES = new Set(["fail", "error", "timeout"]);
4513
4891
  function readTestRunCacheFile(path) {
4514
4892
  try {
4515
- if (!lstatSync3(path).isFile())
4893
+ if (!lstatSync4(path).isFile())
4516
4894
  return {};
4517
- return JSON.parse(readFileSync7(path, "utf8"));
4895
+ return JSON.parse(readFileSync8(path, "utf8"));
4518
4896
  } catch {
4519
4897
  return {};
4520
4898
  }
4521
4899
  }
4522
4900
  function writeTestRunCacheFile(path, all) {
4523
4901
  const tmp = `${path}.tmp-${process.pid}-${randomUUID3()}`;
4524
- const fd = openSync5(tmp, fsConstants5.O_WRONLY | fsConstants5.O_CREAT | fsConstants5.O_EXCL, 384);
4902
+ const fd = openSync6(tmp, fsConstants6.O_WRONLY | fsConstants6.O_CREAT | fsConstants6.O_EXCL, 384);
4525
4903
  try {
4526
- writeSync4(fd, JSON.stringify(all, null, 2), null, "utf8");
4904
+ writeSync5(fd, JSON.stringify(all, null, 2), null, "utf8");
4527
4905
  fsyncSync2(fd);
4528
4906
  } finally {
4529
- closeSync5(fd);
4907
+ closeSync6(fd);
4530
4908
  }
4531
4909
  renameSync4(tmp, path);
4532
4910
  }
@@ -4536,7 +4914,7 @@ function fileBackedTestRunCache(path, runtimeDir) {
4536
4914
  set: (key, record) => {
4537
4915
  const all = readTestRunCacheFile(path);
4538
4916
  all[key] = record;
4539
- ensureRunDir(dirname7(path), runtimeDir);
4917
+ ensureRunDir(dirname8(path), runtimeDir);
4540
4918
  writeTestRunCacheFile(path, all);
4541
4919
  }
4542
4920
  };
@@ -4578,7 +4956,7 @@ async function collectStateFields(cwd) {
4578
4956
  for (const f of uncommitted) {
4579
4957
  fields.push(f);
4580
4958
  try {
4581
- fields.push(readFileSync7(join9(base, f)));
4959
+ fields.push(readFileSync8(join9(base, f)));
4582
4960
  } catch {
4583
4961
  fields.push("MISSING");
4584
4962
  }
@@ -4676,21 +5054,6 @@ async function recordGreenTestRun(command, output, cwd, source, cache = defaultT
4676
5054
  }
4677
5055
  return true;
4678
5056
  }
4679
- var TOKEN_ROW_REMEDY = [
4680
- "Nothing here established that this host cannot meter — only that this session resolved no",
4681
- "transcript of its own. Report real figures by naming your own transcript:",
4682
- "",
4683
- " vinaya pr report --write <body-file> --transcript <path>",
4684
- "",
4685
- "or, on a host whose usage arrives by some other means, format figures you already hold with:",
4686
- "",
4687
- ' vinaya tokens --phase "<task-id>: develop" --role Developer --in <tokens-in> --out <tokens-out>',
4688
- "",
4689
- "and transcribe them into the `## Token report` table. That command prints a `Tokens:` line, not",
4690
- "a table row — the table takes | Phase | Role | Agent/Model | Tokens in | Tokens out | Cost | Date |,",
4691
- "and a line inside the block that does not start with `|` truncates the table for every row after it."
4692
- ].join(`
4693
- `);
4694
5057
 
4695
5058
  // src/lib/pre-push-cache-test-run.ts
4696
5059
  async function main() {
@@ -4703,7 +5066,7 @@ async function main() {
4703
5066
  }
4704
5067
  let output;
4705
5068
  try {
4706
- output = readFileSync8(logPath, "utf8");
5069
+ output = readFileSync9(logPath, "utf8");
4707
5070
  } catch (err) {
4708
5071
  process.stderr.write(`vinaya pre-push: could not read ${logPath} to cache this run — nothing recorded (${err instanceof Error ? err.message : String(err)}).
4709
5072
  `);