@attalabs/vinaya 0.31.0 → 0.33.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 (212) hide show
  1. package/README.md +2 -3
  2. package/aeg-root/contracts/principal-operator.md +18 -5
  3. package/aeg-root/roles/developer/reference.md +3 -3
  4. package/aeg-root/roles/operator.md +69 -16
  5. package/aeg-root/roles/planner/reference.md +1 -1
  6. package/aeg-root/roles/tranche-archivist.md +1 -0
  7. package/aeg-root/skills/aeg-context-packets/SKILL.md +1 -1
  8. package/aeg-root/skills/aeg-context-packets/examples/operator-start.md +1 -1
  9. package/aeg-root/templates/pr-report-template.md +7 -2
  10. package/dist/checks/bin/check-body-bare-digits.js +340 -101
  11. package/dist/checks/bin/check-branch-topology.js +184 -105
  12. package/dist/checks/bin/check-brief-shape.js +333 -94
  13. package/dist/checks/bin/check-changeset-coverage.js +1028 -248
  14. package/dist/checks/bin/check-ci-shard-coverage.js +82 -0
  15. package/dist/checks/bin/check-closes-n.js +184 -105
  16. package/dist/checks/bin/check-coherence.js +345 -145
  17. package/dist/checks/bin/check-dead-branch-push.js +179 -59
  18. package/dist/checks/bin/check-dispatch-readiness.js +350 -150
  19. package/dist/checks/bin/check-doc-coverage-push.js +1011 -231
  20. package/dist/checks/bin/check-doc-coverage.js +1015 -235
  21. package/dist/checks/bin/check-doctrine-no-procedures.js +333 -94
  22. package/dist/checks/bin/check-doctrine-portability.js +1013 -233
  23. package/dist/checks/bin/check-evidence-fresh.js +1010 -222
  24. package/dist/checks/bin/check-exec-bits.js +1009 -229
  25. package/dist/checks/bin/check-first-push-dispatch.js +343 -145
  26. package/dist/checks/bin/check-issue-assignment.js +186 -107
  27. package/dist/checks/bin/check-issue-milestone-attach.js +176 -56
  28. package/dist/checks/bin/check-issue-objectives-numbering.js +176 -56
  29. package/dist/checks/bin/check-issue-parts-coverage.js +176 -56
  30. package/dist/checks/bin/check-issue-surface-globs.js +363 -143
  31. package/dist/checks/bin/check-issue-title-grammar.js +176 -56
  32. package/dist/checks/bin/check-issue-tranche-label.js +176 -56
  33. package/dist/checks/bin/check-main-branch-refusal.js +176 -56
  34. package/dist/checks/bin/check-no-disk-state.js +176 -56
  35. package/dist/checks/bin/check-pr-premise-reassert.js +333 -92
  36. package/dist/checks/bin/check-pr-report-density.js +176 -56
  37. package/dist/checks/bin/check-principal-test-plan-wait.js +176 -54
  38. package/dist/checks/bin/check-quoted-command.js +999 -217
  39. package/dist/checks/bin/check-reader-resolvable-prose.js +1011 -229
  40. package/dist/checks/bin/check-registry-gates.js +186 -56
  41. package/dist/checks/bin/check-retired-vocabulary.js +997 -215
  42. package/dist/checks/bin/check-review-gate.js +403 -203
  43. package/dist/checks/bin/check-single-plan-pr.js +176 -56
  44. package/dist/checks/bin/check-surface-scope.js +184 -105
  45. package/dist/checks/bin/check-test-plan.js +176 -54
  46. package/dist/checks/bin/check-token-collection-wired.js +182 -57
  47. package/dist/checks/bin/check-token-report.js +178 -58
  48. package/dist/checks/bin/check-workspace-escape.js +1011 -229
  49. package/dist/index.js +5971 -3489
  50. package/dist/lib/pre-push-cache-test-run.js +4431 -0
  51. package/dist/lib/pre-push-select-tests.js +799 -110
  52. package/package.json +3 -2
  53. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/actions.ts +10 -12
  54. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +5 -5
  55. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/archive-task.ts +42 -17
  56. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/baseline-capture.ts +1 -2
  57. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/branch-topology-gate.ts +3 -3
  58. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +554 -95
  59. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +264 -44
  60. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/claude-code-transcript.ts +9 -9
  61. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +211 -30
  62. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/consumer-enumeration.ts +2 -2
  63. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/index.ts +75 -0
  64. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +961 -0
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/migration.ts +212 -0
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/outcomes.ts +135 -0
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +394 -0
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dead-branch-push-audit.ts +1 -2
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dead-branch-push-guard.ts +1 -1
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/derive-section7.ts +2 -2
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +514 -0
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +110 -0
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +27 -0
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +123 -0
  75. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +27 -0
  76. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +240 -0
  77. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/diagram-model.ts +1 -1
  78. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/direct-main-push.ts +1 -2
  79. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +65 -22
  80. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-claim.ts +238 -0
  81. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-owners.ts +14 -1
  82. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/docs-coherence.ts +1 -1
  83. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/legacy-anchors.ts +1 -1
  84. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/node-route.ts +1 -1
  85. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/surfaced-manifest.ts +1 -1
  86. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-no-procedures.ts +1 -1
  87. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +5 -5
  88. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ensure-label.ts +1 -1
  89. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/first-push-dispatch-gate.ts +1 -1
  90. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +14 -3
  91. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +379 -11
  92. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-assignment.ts +3 -4
  93. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +1450 -33
  94. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/leftover-detection.ts +1 -2
  95. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/local-anchor-coverage.ts +2 -2
  96. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +119 -0
  97. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +75 -0
  98. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/redact.ts +87 -0
  99. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +801 -0
  100. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/store.ts +373 -0
  101. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +2 -2
  102. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/metering-io-guard.ts +1 -1
  103. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/milestone-validation.ts +2 -3
  104. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/no-disk-state.ts +2 -2
  105. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives.ts +288 -0
  106. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/parse-token-report.ts +3 -3
  107. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/parse-tranche.ts +1 -1
  108. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-report-density.ts +30 -16
  109. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-tier.ts +17 -1
  110. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/premise-check.ts +1 -1
  111. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/quoted-command.ts +1 -1
  112. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +267 -19
  113. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +91 -24
  114. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-scaffold.ts +6 -6
  115. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/report-tokens.ts +4 -4
  116. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +239 -110
  117. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +384 -0
  118. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +184 -0
  119. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +65 -18
  120. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +76 -0
  121. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/single-plan-pr.ts +4 -4
  122. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/state-machine-model.ts +40 -27
  123. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/symbol-collisions.ts +2 -2
  124. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-branch-identity.ts +38 -0
  125. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +488 -0
  126. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-gate.ts +7 -9
  127. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-section.ts +5 -5
  128. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/types.ts +4 -4
  129. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +314 -56
  130. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/waiver-label.ts +2 -3
  131. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/workspace-escape.ts +3 -3
  132. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  133. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  134. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  135. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  136. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  137. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  138. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  141. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  143. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  144. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  145. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js +1 -1
  146. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  149. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  150. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  151. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +1 -1
  152. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  153. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  154. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  155. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +1 -1
  156. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  157. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  158. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  159. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +1 -1
  160. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  161. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  162. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  163. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +2 -2
  164. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  165. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  166. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  167. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +1 -1
  168. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  169. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  170. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  171. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +1 -1
  172. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  173. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  174. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  175. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +1 -1
  176. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  177. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  178. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/{[externals]__1agj1ww._.js → [externals]__0cki-x_._.js} +2 -2
  179. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +6 -6
  180. 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
  181. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +3 -0
  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]__0r7e54g._.js → [root-of-the-server]__18paley._.js} +1 -1
  184. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  185. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  186. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1r47dr7._.js → _08onyya._.js} +3 -3
  187. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  188. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  189. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  190. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  191. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0y1jv16._.js +1 -1
  192. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  193. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  194. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_15gdg48._.js +5 -5
  195. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  196. 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
  197. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  198. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  199. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  200. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  201. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bjnj-5fy4e7l.js +1 -0
  202. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1dc2_-c_gavj1.js → 1ce2dj27_cgbj.js} +4 -4
  203. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3xg6-flovrcx-.js → 22s44f5k3ecmj.js} +1 -1
  204. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/34hhdtbp20krb.js +1 -0
  205. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  206. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0hstap0._.js +0 -3
  207. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2t_rfsztmwu6y.js +0 -1
  208. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3ua4rm5f-a9k6.js +0 -1
  209. /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/{aeg-core → vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
  210. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_buildManifest.js +0 -0
  211. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_clientMiddlewareManifest.js +0 -0
  212. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_ssgManifest.js +0 -0
@@ -1,9 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { createRequire } from "node:module";
3
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
4
2
 
5
3
  // src/checks/bin/check-evidence-fresh.ts
6
- import { execFileSync as execFileSync8 } from "node:child_process";
4
+ import { execFileSync as execFileSync7 } from "node:child_process";
7
5
  // ../../packages/aeg-core/src/gate-audience.ts
8
6
  var GATE_AUDIENCE = {
9
7
  "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
@@ -1037,7 +1035,7 @@ function withDefaults(oldDefaults, newDefaults) {
1037
1035
  var endpoint = withDefaults(null, DEFAULTS);
1038
1036
 
1039
1037
  // ../../node_modules/fast-content-type-parse/index.js
1040
- var NullObject = function NullObject2() {};
1038
+ var NullObject = function NullObject() {};
1041
1039
  NullObject.prototype = Object.create(null);
1042
1040
  var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu;
1043
1041
  var quotedPairRE = /\\([\v\u0020-\u00ff])/gu;
@@ -1131,8 +1129,8 @@ function isPlainObject2(value) {
1131
1129
  return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
1132
1130
  }
1133
1131
  async function fetchWrapper(requestOptions) {
1134
- const fetch = requestOptions.request?.fetch || globalThis.fetch;
1135
- if (!fetch) {
1132
+ const fetch2 = requestOptions.request?.fetch || globalThis.fetch;
1133
+ if (!fetch2) {
1136
1134
  throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");
1137
1135
  }
1138
1136
  const log = requestOptions.request?.log || console;
@@ -1144,7 +1142,7 @@ async function fetchWrapper(requestOptions) {
1144
1142
  ]));
1145
1143
  let fetchResponse;
1146
1144
  try {
1147
- fetchResponse = await fetch(requestOptions.url, {
1145
+ fetchResponse = await fetch2(requestOptions.url, {
1148
1146
  method: requestOptions.method,
1149
1147
  body,
1150
1148
  redirect: requestOptions.request?.redirect,
@@ -1781,27 +1779,27 @@ function splitTableRow(row) {
1781
1779
  return parts.map((p) => p.split(PLACEHOLDER).join("|"));
1782
1780
  }
1783
1781
  // ../../packages/aeg-core/src/blast-radius-domains.ts
1784
- function resolveWorkspaceEntry(entry2, listDirs) {
1785
- if (entry2.endsWith("/*")) {
1786
- const baseDir = entry2.slice(0, -2);
1782
+ function resolveWorkspaceEntry(entry, listDirs) {
1783
+ if (entry.endsWith("/*")) {
1784
+ const baseDir = entry.slice(0, -2);
1787
1785
  return listDirs(baseDir).map((name) => `${baseDir}/${name}`);
1788
1786
  }
1789
- if (entry2.includes("*"))
1787
+ if (entry.includes("*"))
1790
1788
  return [];
1791
- return [entry2];
1789
+ return [entry];
1792
1790
  }
1793
1791
  // ../../packages/aeg-core/src/consumer-enumeration.ts
1794
1792
  function deriveWorkspaceMemberDirs(workspaces, listDirs) {
1795
- const positive = workspaces.filter((entry2) => !entry2.startsWith("!"));
1796
- const negative = workspaces.filter((entry2) => entry2.startsWith("!")).map((entry2) => entry2.slice(1));
1793
+ const positive = workspaces.filter((entry) => !entry.startsWith("!"));
1794
+ const negative = workspaces.filter((entry) => entry.startsWith("!")).map((entry) => entry.slice(1));
1797
1795
  const excluded = new Set;
1798
- for (const entry2 of negative) {
1799
- for (const member of resolveWorkspaceEntry(entry2, listDirs))
1796
+ for (const entry of negative) {
1797
+ for (const member of resolveWorkspaceEntry(entry, listDirs))
1800
1798
  excluded.add(member);
1801
1799
  }
1802
1800
  const members = new Set;
1803
- for (const entry2 of positive) {
1804
- for (const member of resolveWorkspaceEntry(entry2, listDirs)) {
1801
+ for (const entry of positive) {
1802
+ for (const member of resolveWorkspaceEntry(entry, listDirs)) {
1805
1803
  if (!excluded.has(member))
1806
1804
  members.add(member);
1807
1805
  }
@@ -2047,12 +2045,24 @@ function extractBaseSha(comment) {
2047
2045
  const m = firstThirteenLines(comment).match(BASE_SHA_PATTERN);
2048
2046
  return m ? m[1].toLowerCase() : null;
2049
2047
  }
2050
- var FINDING_SEVERITY_LINE = /^\d+\.\s+\[([A-Z][A-Z]*)\]\s+(.+?)\s+—/gm;
2048
+ var FINDING_DESCRIPTION_STATE = /^F(\d+)(?:\s+\S+)?(?:\s+(open|fix-claimed|reproduced|resolved))?:/;
2049
+ function parseFindingState(description) {
2050
+ const m = FINDING_DESCRIPTION_STATE.exec(description.trim());
2051
+ if (!m)
2052
+ return { id: null, state: null };
2053
+ return { id: `F${m[1]}`, state: m[2] ?? null };
2054
+ }
2055
+ var FINDING_SEVERITY_LINE = /^\d+\.\s+\[([A-Z][A-Z]*)\]\s+(.+?)\s+—(?:\s+(.*))?$/gm;
2051
2056
  function extractFindingSeverities(comment) {
2052
- return [...comment.matchAll(FINDING_SEVERITY_LINE)].map((m) => ({
2053
- severity: m[1],
2054
- location: m[2]
2055
- }));
2057
+ return [...comment.matchAll(FINDING_SEVERITY_LINE)].map((m) => {
2058
+ const { id, state } = parseFindingState(m[3] ?? "");
2059
+ return {
2060
+ severity: m[1],
2061
+ location: m[2],
2062
+ id,
2063
+ state
2064
+ };
2065
+ });
2056
2066
  }
2057
2067
  function extractVerdict(comments, valuePattern, missingLabel) {
2058
2068
  const candidates = comments.filter((c) => valuePattern.test(c));
@@ -2125,15 +2135,15 @@ function summarizeTranscript(jsonl) {
2125
2135
  const line = rawLine.trim();
2126
2136
  if (!line)
2127
2137
  continue;
2128
- let entry2;
2138
+ let entry;
2129
2139
  try {
2130
- entry2 = JSON.parse(line);
2140
+ entry = JSON.parse(line);
2131
2141
  } catch {
2132
2142
  continue;
2133
2143
  }
2134
- if (!entry2 || typeof entry2 !== "object")
2144
+ if (!entry || typeof entry !== "object")
2135
2145
  continue;
2136
- const obj = entry2;
2146
+ const obj = entry;
2137
2147
  if (obj.type !== "assistant")
2138
2148
  continue;
2139
2149
  const message = obj.message;
@@ -2466,6 +2476,12 @@ function evaluateReviewFindings(findings, scale, threshold) {
2466
2476
  });
2467
2477
  return { outcome: blockingFindings.length > 0 ? "blocked" : "clean", blockingFindings };
2468
2478
  }
2479
+ function isConsequentialFinding(finding) {
2480
+ return finding.state !== "resolved";
2481
+ }
2482
+ function consequentialFindings(findings) {
2483
+ return findings.filter((f) => isConsequentialFinding(f));
2484
+ }
2469
2485
  function evaluateCodeReview(findings, policy) {
2470
2486
  return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold);
2471
2487
  }
@@ -2981,7 +2997,7 @@ function isStep0Block(content) {
2981
2997
  }
2982
2998
  function checkCommandsCarryOutput(prBody) {
2983
2999
  const errors = [];
2984
- for (const [label2, num] of [
3000
+ for (const [label, num] of [
2985
3001
  ["5", 5],
2986
3002
  ["6", 6]
2987
3003
  ]) {
@@ -2995,7 +3011,7 @@ function checkCommandsCarryOutput(prBody) {
2995
3011
  continue;
2996
3012
  const next = blocks[i + 1];
2997
3013
  if (!next || isCommandBlock(next.content)) {
2998
- errors.push(`brief-validation commands carry output: §${label2} has a command block ("${firstNonBlankLine(block.content)}") not immediately followed by a non-command output block — the very next fenced block must hold that command's actual output, not another command.`);
3014
+ errors.push(`brief-validation commands carry output: §${label} has a command block ("${firstNonBlankLine(block.content)}") not immediately followed by a non-command output block — the very next fenced block must hold that command's actual output, not another command.`);
2999
3015
  }
3000
3016
  }
3001
3017
  }
@@ -3432,8 +3448,8 @@ function stripPartBackticks(text) {
3432
3448
  function partWordCount(text) {
3433
3449
  return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
3434
3450
  }
3435
- function looksLikeFilePath(entry2) {
3436
- const stripped = entry2.replace(/\/\*\*?$/, "");
3451
+ function looksLikeFilePath(entry) {
3452
+ const stripped = entry.replace(/\/\*\*?$/, "");
3437
3453
  const lastSegment = stripped.split("/").pop() ?? stripped;
3438
3454
  const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
3439
3455
  return extMatch !== null && extMatch.index > 0;
@@ -3919,14 +3935,14 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
3919
3935
  const referenced = extractClosesReferences(prBody);
3920
3936
  if (taskIssueRefs) {
3921
3937
  for (const n of referenced) {
3922
- const ref2 = taskIssueRefs.get(n);
3923
- if (!ref2)
3938
+ const ref = taskIssueRefs.get(n);
3939
+ if (!ref)
3924
3940
  continue;
3925
- const expectedBranch = `task/${ref2.trancheSlug}/${ref2.taskId}`;
3941
+ const expectedBranch = `task/${ref.trancheSlug}/${ref.taskId}`;
3926
3942
  if (branch !== expectedBranch) {
3927
3943
  return {
3928
3944
  ok: false,
3929
- message: `closes-n-reverse: branch "${branch}" closes #${n} (task ${ref2.taskId} of tranche "${ref2.trancheSlug}") but is not named "${expectedBranch}" — rename the branch and re-push, or if this work is intentionally outside AEG's dispatch flow, remove the Closes reference.`
3945
+ message: `closes-n-reverse: branch "${branch}" closes #${n} (task ${ref.taskId} of tranche "${ref.trancheSlug}") but is not named "${expectedBranch}" — rename the branch and re-push, or if this work is intentionally outside AEG's dispatch flow, remove the Closes reference.`
3930
3946
  };
3931
3947
  }
3932
3948
  }
@@ -3935,15 +3951,15 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
3935
3951
  if (!ref)
3936
3952
  return { ok: true };
3937
3953
  if (ref.kind === "issue") {
3938
- const expectedIssue2 = ref.issueNumber;
3939
- if (!referenced.has(expectedIssue2)) {
3954
+ const expectedIssue = ref.issueNumber;
3955
+ if (!referenced.has(expectedIssue)) {
3940
3956
  return {
3941
3957
  ok: false,
3942
- expectedIssue: expectedIssue2,
3943
- message: `closes-n: PR body does not contain \`Closes #${expectedIssue2}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
3958
+ expectedIssue,
3959
+ message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
3944
3960
  };
3945
3961
  }
3946
- return { ok: true, expectedIssue: expectedIssue2 };
3962
+ return { ok: true, expectedIssue };
3947
3963
  }
3948
3964
  const trancheSlug = ref.tranche;
3949
3965
  const taskId = ref.taskId;
@@ -3989,8 +4005,8 @@ function extractIssue(body) {
3989
4005
  const anchorNums = closesRefs(anchored);
3990
4006
  if (anchorNums.length === 0)
3991
4007
  return { issue: null, extraIssues: bodyNums, outsideHeader: false };
3992
- const issue2 = anchorNums[0];
3993
- return { issue: issue2, extraIssues: bodyNums.filter((n) => n !== issue2), outsideHeader: false };
4008
+ const issue = anchorNums[0];
4009
+ return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: false };
3994
4010
  }
3995
4011
  const headerNums = closesRefs(headerRegion(stripped));
3996
4012
  if (bodyNums.length === 0)
@@ -4059,15 +4075,15 @@ function compareManifest(echoed, current, patchIdOf) {
4059
4075
  const bothFullShas = echoedShaLen >= 40 && currentShaLen >= 40;
4060
4076
  const base = patchHead || exactHead && bothFullShas ? true : isBoundToBase(echoed, current.baseSha);
4061
4077
  const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
4062
- const objectivesVersion2 = isBoundToObjectives(echoed, current.objectivesVersion);
4078
+ const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
4063
4079
  const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
4064
4080
  const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
4065
4081
  return {
4066
- bound: head && base && briefHashBound && objectivesVersion2 && rulingOrdinal && policyDigestBound,
4082
+ bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
4067
4083
  head,
4068
4084
  base,
4069
4085
  briefHash: briefHashBound,
4070
- objectivesVersion: objectivesVersion2,
4086
+ objectivesVersion,
4071
4087
  rulingOrdinal,
4072
4088
  policyDigest: policyDigestBound
4073
4089
  };
@@ -4098,8 +4114,8 @@ function checkReviewGate(input) {
4098
4114
  let codeReviewPolicyEvaluation;
4099
4115
  let securityPolicyEvaluation;
4100
4116
  try {
4101
- codeReviewPolicyEvaluation = evaluateCodeReview(codeReview.findingSeverities, policy);
4102
- securityPolicyEvaluation = evaluateSecurityReview(security.findingSeverities, policy);
4117
+ codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy);
4118
+ securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy);
4103
4119
  } catch (err) {
4104
4120
  return {
4105
4121
  verdict: "fail",
@@ -5180,11 +5196,27 @@ var ObservedSchema = z.object({
5180
5196
  var TaskStatusInputSchema = z.object({
5181
5197
  task: TaskToolRefSchema.optional()
5182
5198
  }).merge(PageRequestSchema).strict();
5199
+ var TaskConfidenceSchema = z.object({
5200
+ round: z.number().int().positive(),
5201
+ percent: z.number().int().min(0).max(100).nullable(),
5202
+ source: z.enum(["stated", "published-summary"])
5203
+ }).strict();
5204
+ var TaskPhaseHistorySchema = z.object({
5205
+ typicalPhaseMinutes: z.number().nonnegative(),
5206
+ typicalPhaseSamples: z.number().int().positive()
5207
+ }).strict();
5183
5208
  var TaskStatusItemSchema = z.object({
5184
5209
  task: TaskToolRefSchema,
5185
5210
  issue: z.number().int().positive(),
5186
5211
  pr: z.number().int().positive().nullable(),
5187
- state: z.string()
5212
+ state: z.string(),
5213
+ round: z.number().int().positive().nullable().optional(),
5214
+ phase: z.string().min(1).nullable().optional(),
5215
+ minutesInPhase: z.number().nonnegative().nullable().optional(),
5216
+ phaseIsCurrent: z.boolean().nullable().optional(),
5217
+ lastConfidence: TaskConfidenceSchema.nullable().optional(),
5218
+ lastConfidenceUnread: z.boolean().optional(),
5219
+ phaseHistory: TaskPhaseHistorySchema.nullable().optional()
5188
5220
  }).merge(ObservedSchema);
5189
5221
  var TaskStatusResultSchema = z.object({
5190
5222
  items: z.array(TaskStatusItemSchema),
@@ -5196,7 +5228,7 @@ var EscalationInputsSchema = z.object({
5196
5228
  round: z.number().int().nonnegative(),
5197
5229
  head: z.string(),
5198
5230
  branch: z.string(),
5199
- prNumber: z.number().int().positive()
5231
+ prNumber: z.number().int().positive().nullable()
5200
5232
  });
5201
5233
  var EscalationEvidenceSchema = z.object({
5202
5234
  round: z.number().int().nonnegative(),
@@ -5232,13 +5264,45 @@ var TaskEscalationReadResultSchema = z.object({
5232
5264
  items: z.array(TaskEscalationPacketSchema),
5233
5265
  nextCursor: z.string().nullable()
5234
5266
  }).merge(ObservedSchema);
5235
- var TaskStartInputSchema = z.object({
5236
- tranche: z.string().min(1),
5237
- id: z.string().min(1)
5267
+ var TaskPrCheckSchema = z.object({
5268
+ name: z.string(),
5269
+ required: z.boolean(),
5270
+ status: z.string(),
5271
+ conclusion: z.string().nullable(),
5272
+ detailsUrl: z.string().nullable(),
5273
+ failureSummary: z.string().nullable()
5274
+ });
5275
+ var TaskPrVerdictSchema = z.object({
5276
+ role: z.enum(["code-review", "security"]),
5277
+ value: z.string(),
5278
+ judgedHead: z.string().nullable(),
5279
+ objectivesVersion: z.string().nullable()
5280
+ });
5281
+ var TaskPrPauseSchema = z.object({
5282
+ reason: z.string(),
5283
+ body: z.string()
5284
+ });
5285
+ var TaskPrReviewRecordSchema = z.object({
5286
+ verdicts: z.array(TaskPrVerdictSchema),
5287
+ roundMarkers: z.array(z.number().int().nonnegative()),
5288
+ summaryTable: z.string().nullable(),
5289
+ pause: TaskPrPauseSchema.nullable()
5290
+ });
5291
+ var TaskPrReadInputSchema = z.object({
5292
+ task: TaskToolRefSchema,
5293
+ pr: z.number().int().positive().optional()
5238
5294
  }).strict();
5295
+ var TaskPrReadResultSchema = z.object({
5296
+ task: TaskToolRefSchema,
5297
+ issue: z.number().int().positive(),
5298
+ pr: z.number().int().positive(),
5299
+ head: z.string().nullable(),
5300
+ checks: z.array(TaskPrCheckSchema),
5301
+ review: TaskPrReviewRecordSchema
5302
+ }).merge(ObservedSchema);
5239
5303
  var TaskStartResultSchema = z.object({
5240
5304
  requestId: z.string().min(1),
5241
- run: z.object({ tranche: z.string().min(1), id: z.string().min(1) }),
5305
+ run: TaskToolRefSchema,
5242
5306
  started: z.boolean(),
5243
5307
  startedAt: z.string(),
5244
5308
  mode: z.literal("attended")
@@ -5252,7 +5316,7 @@ var TaskCancelInputSchema = z.object({
5252
5316
  }).strict();
5253
5317
  var TaskResumeResultSchema = z.object({
5254
5318
  task: z.number().int().positive(),
5255
- pr: z.number().int().positive(),
5319
+ pr: z.number().int().positive().nullable(),
5256
5320
  escalationId: z.string().min(1),
5257
5321
  outcome: z.enum(["started", "already_resumed"]),
5258
5322
  authenticatedBy: z.string().min(1),
@@ -5261,7 +5325,7 @@ var TaskResumeResultSchema = z.object({
5261
5325
  var TaskCancelOutcomeSchema = z.enum(["confirmed", "pending", "uncertain"]);
5262
5326
  var TaskCancelResultSchema = z.object({
5263
5327
  task: z.number().int().positive(),
5264
- pr: z.number().int().positive(),
5328
+ pr: z.number().int().positive().nullable(),
5265
5329
  escalationId: z.string().min(1),
5266
5330
  outcome: TaskCancelOutcomeSchema,
5267
5331
  authenticatedBy: z.string().min(1),
@@ -5272,6 +5336,7 @@ var TASK_TOOL_NAMES = [
5272
5336
  "task_start",
5273
5337
  "task_status",
5274
5338
  "task_escalation_read",
5339
+ "task_pr_read",
5275
5340
  "task_resume",
5276
5341
  "task_cancel"
5277
5342
  ];
@@ -5499,6 +5564,10 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
5499
5564
  }
5500
5565
  return findings;
5501
5566
  }
5567
+ // ../../packages/aeg-core/src/dev-review-loop/types.ts
5568
+ var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5569
+ // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
5570
+ var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
5502
5571
  // ../../packages/aeg-core/src/log/envelope.ts
5503
5572
  import { createHash as createHash5 } from "node:crypto";
5504
5573
 
@@ -6037,6 +6106,7 @@ function redact(value, home) {
6037
6106
  return value;
6038
6107
  }
6039
6108
  // ../../packages/aeg-core/src/log/store.ts
6109
+ var KNOWN_SCHEMA_VERSIONS = [1, 2];
6040
6110
  function metaOf(obj) {
6041
6111
  if (obj === null || typeof obj !== "object")
6042
6112
  return null;
@@ -6059,11 +6129,61 @@ function recordIdentity(obj) {
6059
6129
  }
6060
6130
  return null;
6061
6131
  }
6062
-
6063
- // ../../packages/aeg-core/src/log/artifact.ts
6064
- var TASK_LOG_ARTIFACT_MAX_BYTES = 8 * 1024 * 1024;
6065
- // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
6066
- var STOPPED_CONDITIONS = new Set(["confidence", "reappearance", "no_progress", "max_rounds"]);
6132
+ function schemaVersionOf(obj) {
6133
+ const meta = metaOf(obj);
6134
+ const schema = meta?.schema;
6135
+ return typeof schema === "number" ? schema : null;
6136
+ }
6137
+ function isKnownSchema(version) {
6138
+ return version !== null && KNOWN_SCHEMA_VERSIONS.includes(version);
6139
+ }
6140
+ function classifyStoredLine(raw, home) {
6141
+ let obj;
6142
+ try {
6143
+ obj = JSON.parse(raw);
6144
+ } catch {
6145
+ return { status: "invalid", identity: null, raw, reason: "not valid JSON" };
6146
+ }
6147
+ const version = schemaVersionOf(obj);
6148
+ if (version === null) {
6149
+ return { status: "invalid", identity: recordIdentity(obj), raw, reason: "no readable meta.schema" };
6150
+ }
6151
+ if (!isKnownSchema(version)) {
6152
+ return {
6153
+ status: "unknown_version",
6154
+ identity: recordIdentity(obj),
6155
+ schema: version,
6156
+ raw,
6157
+ reason: `schema version ${version} is not one this build validates (${KNOWN_SCHEMA_VERSIONS.join(", ")}) — kept for diagnosis`
6158
+ };
6159
+ }
6160
+ const result = LogEventSchema.safeParse(obj);
6161
+ if (!result.success) {
6162
+ return {
6163
+ status: "invalid",
6164
+ identity: recordIdentity(obj),
6165
+ raw,
6166
+ reason: result.error.issues[0]?.message ?? "schema violation"
6167
+ };
6168
+ }
6169
+ const event = result.data;
6170
+ const identity = recordIdentity(event);
6171
+ if (identity === null) {
6172
+ return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
6173
+ }
6174
+ const redacted = redact(event, home);
6175
+ const provenance = version === 2 ? event.meta.provenance ?? null : null;
6176
+ return {
6177
+ status: "ok",
6178
+ identity,
6179
+ runId: event.meta.run_id,
6180
+ seq: event.meta.seq,
6181
+ schema: version,
6182
+ provenance,
6183
+ event,
6184
+ postLine: JSON.stringify(redacted)
6185
+ };
6186
+ }
6067
6187
  // ../../packages/aeg-core/src/control-store/records.ts
6068
6188
  import { z as z3 } from "zod";
6069
6189
  var isoTimestamp = z3.string().min(1);
@@ -6193,6 +6313,10 @@ var ResolutionRecordSchema = z3.object({
6193
6313
  authenticatedFrom: z3.string().min(1),
6194
6314
  consumedAt: isoTimestamp
6195
6315
  }).strict();
6316
+ // src/lib/pr-report-engine.ts
6317
+ import { execFile as execFile6 } from "node:child_process";
6318
+ import { promisify as promisify6 } from "node:util";
6319
+
6196
6320
  // src/checks/registry.ts
6197
6321
  import { existsSync as existsSync2 } from "node:fs";
6198
6322
  import { join as join2 } from "node:path";
@@ -6632,6 +6756,16 @@ var REGISTRY = [
6632
6756
  },
6633
6757
  0
6634
6758
  ],
6759
+ [
6760
+ {
6761
+ name: "ci-shard-coverage",
6762
+ run: bin("check-ci-shard-coverage"),
6763
+ scope: "diff",
6764
+ timeoutMs: 15000,
6765
+ env: {}
6766
+ },
6767
+ 0
6768
+ ],
6635
6769
  [
6636
6770
  {
6637
6771
  name: "workspace-escape",
@@ -6769,24 +6903,26 @@ function coreCheckRegistry() {
6769
6903
  var CORE_CHECK_RING = Object.fromEntries(REGISTRY.map(([spec, ring]) => [spec.name, ring]));
6770
6904
 
6771
6905
  // src/lib/log-sink.ts
6772
- import { execFileSync as execFileSync3 } from "node:child_process";
6773
- import { randomUUID } from "node:crypto";
6906
+ import { execFile as execFile5 } from "node:child_process";
6907
+ import { randomUUID as randomUUID2 } from "node:crypto";
6774
6908
  import {
6775
- closeSync as closeSync2,
6776
- constants as fsConstants2,
6777
- existsSync as existsSync4,
6909
+ closeSync as closeSync3,
6910
+ constants as fsConstants3,
6911
+ existsSync as existsSync5,
6778
6912
  fstatSync as fstatSync2,
6779
- mkdirSync as mkdirSync2,
6780
- openSync as openSync2,
6781
- readFileSync as readFileSync3,
6782
- renameSync,
6783
- writeSync
6913
+ mkdirSync as mkdirSync3,
6914
+ openSync as openSync3,
6915
+ readFileSync as readFileSync4,
6916
+ renameSync as renameSync2,
6917
+ writeSync as writeSync2
6784
6918
  } from "node:fs";
6785
- import { hostname as osHostname, homedir as homedir2 } from "node:os";
6786
- import { dirname as dirname3, join as join4 } from "node:path";
6919
+ import { hostname as osHostname, homedir as homedir3 } from "node:os";
6920
+ import { dirname as dirname5, join as join6 } from "node:path";
6921
+ import { promisify as promisify5 } from "node:util";
6787
6922
 
6788
6923
  // src/lib/config.ts
6789
- import { execFileSync as execFileSync2 } from "node:child_process";
6924
+ import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
6925
+ import { promisify as promisify4 } from "node:util";
6790
6926
  import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
6791
6927
  import { homedir } from "node:os";
6792
6928
  import { dirname as dirname2, isAbsolute, join as join3, resolve } from "node:path";
@@ -6813,10 +6949,10 @@ var CheckEntrySchema = z4.object({
6813
6949
  ownWorkflow: z4.boolean().optional(),
6814
6950
  principalOwed: z4.literal(true).optional(),
6815
6951
  validates: z4.enum(["body", "issue"]).optional()
6816
- }).superRefine((entry2, ctx) => {
6817
- if (!entry2.env)
6952
+ }).superRefine((entry, ctx) => {
6953
+ if (!entry.env)
6818
6954
  return;
6819
- for (const [key, value] of Object.entries(entry2.env)) {
6955
+ for (const [key, value] of Object.entries(entry.env)) {
6820
6956
  if (typeof value !== "object" || value === null || !("anyOf" in value))
6821
6957
  continue;
6822
6958
  const members = value.anyOf;
@@ -6973,18 +7109,19 @@ var VinayaConfigSchema = z4.object({
6973
7109
  });
6974
7110
  }
6975
7111
  }).optional(),
6976
- logPublish: z4.object({
6977
- issue: z4.number().int().positive().optional(),
6978
- pr: z4.number().int().positive().optional(),
6979
- webhookUrl: z4.string().url().optional(),
6980
- headers: z4.record(z4.string()).optional(),
6981
- maxChunksPerFlush: z4.number().int().positive().optional()
6982
- }).refine((v) => [v.issue, v.pr, v.webhookUrl].filter((x) => x !== undefined).length <= 1, {
6983
- message: "logPublish: set at most one of issue/pr/webhookUrl"
6984
- }).refine((v) => v.headers === undefined || v.webhookUrl !== undefined, {
6985
- message: "logPublish: headers requires webhookUrl"
6986
- }).optional(),
6987
- runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional()
7112
+ logPublish: z4.unknown().refine((v) => v === undefined, {
7113
+ message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
7114
+ }),
7115
+ runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
7116
+ logs: z4.object({
7117
+ folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
7118
+ url: z4.string().url().optional(),
7119
+ headers: z4.record(z4.string()).optional()
7120
+ }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
7121
+ message: "logs: set at most one of folder/url"
7122
+ }).refine((v) => v.headers === undefined || v.url !== undefined, {
7123
+ message: "logs: headers requires url"
7124
+ }).optional()
6988
7125
  });
6989
7126
  var GLOBAL_VINAYA_HOME = join3(homedir(), ".vinaya");
6990
7127
  var GLOBAL_CONFIG_PATH = join3(GLOBAL_VINAYA_HOME, "config.json");
@@ -7029,32 +7166,39 @@ function globalTokensCollectIgnoredWarning(path) {
7029
7166
  function globalRuntimeDirIgnoredWarning(path) {
7030
7167
  return `${path}: "runtimeDir" in the global config is ignored — it carries no repository segment, so a machine-wide value would collapse every repository's task folders into one tree. Declare it from a repo-local vinaya.config.json.`;
7031
7168
  }
7169
+ var emittedGlobalKeyWarnings = new Set;
7170
+ function warnGlobalKeyIgnoredOnce(message) {
7171
+ if (emittedGlobalKeyWarnings.has(message))
7172
+ return;
7173
+ emittedGlobalKeyWarnings.add(message);
7174
+ console.error(`⚠ ${message}`);
7175
+ }
7032
7176
  function stripGlobalOnlyKeys(config, path) {
7033
7177
  if (path !== GLOBAL_CONFIG_PATH)
7034
7178
  return config;
7035
7179
  let result = config;
7036
7180
  if (result.checks && Object.keys(result.checks).length > 0) {
7037
- console.error(`⚠ ${globalChecksIgnoredWarning(path)}`);
7181
+ warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
7038
7182
  result = { ...result, checks: undefined };
7039
7183
  }
7040
7184
  if (result.roles && Object.keys(result.roles).length > 0) {
7041
- console.error(`⚠ ${globalRolesIgnoredWarning(path)}`);
7185
+ warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
7042
7186
  result = { ...result, roles: undefined };
7043
7187
  }
7044
7188
  if (result.principals && result.principals.length > 0) {
7045
- console.error(`⚠ ${globalPrincipalsIgnoredWarning(path)}`);
7189
+ warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
7046
7190
  result = { ...result, principals: undefined };
7047
7191
  }
7048
7192
  if (result.releaseActor) {
7049
- console.error(`⚠ ${globalReleaseActorIgnoredWarning(path)}`);
7193
+ warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
7050
7194
  result = { ...result, releaseActor: undefined };
7051
7195
  }
7052
7196
  if (result.tokens) {
7053
- console.error(`⚠ ${globalTokensCollectIgnoredWarning(path)}`);
7197
+ warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
7054
7198
  result = { ...result, tokens: undefined };
7055
7199
  }
7056
7200
  if (result.runtimeDir) {
7057
- console.error(`⚠ ${globalRuntimeDirIgnoredWarning(path)}`);
7201
+ warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
7058
7202
  result = { ...result, runtimeDir: undefined };
7059
7203
  }
7060
7204
  return result;
@@ -7087,26 +7231,102 @@ function resolveReviewPolicy(config) {
7087
7231
  maxRounds
7088
7232
  };
7089
7233
  }
7090
- function trustAnchorRepo() {
7091
- const wellFormed = (slug) => /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
7092
- const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
7093
- if (fromRunner) {
7094
- const validated = wellFormed(fromRunner);
7095
- if (validated)
7096
- return validated;
7234
+ function resolveRuntimeDirSetting(config) {
7235
+ return config?.runtimeDir ?? null;
7236
+ }
7237
+ function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
7238
+ const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
7239
+ return anchored !== null && anchored === localRuntimeDir ? anchored : null;
7240
+ }
7241
+ function resolveLogsSetting(config) {
7242
+ const raw = config?.logs;
7243
+ if (!raw)
7244
+ return null;
7245
+ if (raw.url !== undefined)
7246
+ return { url: raw.url, headers: raw.headers };
7247
+ if (raw.folder !== undefined)
7248
+ return { folder: raw.folder };
7249
+ return null;
7250
+ }
7251
+ function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
7252
+ const anchored = resolveLogsSetting(trustAnchorConfig);
7253
+ if (!anchored)
7254
+ return null;
7255
+ if ("url" in local)
7256
+ return "url" in anchored && anchored.url === local.url ? anchored : null;
7257
+ return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
7258
+ }
7259
+ function resolveLogsHeaderValues(headers, env) {
7260
+ if (!headers)
7261
+ return;
7262
+ const resolved = {};
7263
+ for (const [key, value] of Object.entries(headers)) {
7264
+ resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
7097
7265
  }
7266
+ return resolved;
7267
+ }
7268
+ function trustAnchorRepo() {
7269
+ const fromRunner = trustAnchorRepoFromRunner();
7270
+ if (fromRunner)
7271
+ return fromRunner;
7098
7272
  try {
7099
7273
  const url = execFileSync2("git", ["remote", "get-url", "origin"], {
7100
7274
  encoding: "utf-8",
7101
7275
  stdio: ["ignore", "pipe", "pipe"]
7102
- }).trim();
7103
- const m = url.match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
7104
- return m?.[1] && m[2] ? wellFormed(`${m[1]}/${m[2]}`) : null;
7276
+ });
7277
+ return trustAnchorRepoFromRemoteUrl(url);
7105
7278
  } catch {
7106
7279
  return null;
7107
7280
  }
7108
7281
  }
7282
+ async function trustAnchorRepoAsync() {
7283
+ const fromRunner = trustAnchorRepoFromRunner();
7284
+ if (fromRunner)
7285
+ return fromRunner;
7286
+ try {
7287
+ const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
7288
+ encoding: "utf-8",
7289
+ timeout: 1e4
7290
+ });
7291
+ return trustAnchorRepoFromRemoteUrl(stdout);
7292
+ } catch {
7293
+ return null;
7294
+ }
7295
+ }
7296
+ function wellFormedRepoSlug(slug) {
7297
+ return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
7298
+ }
7299
+ function trustAnchorRepoFromRunner() {
7300
+ const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
7301
+ return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
7302
+ }
7303
+ function trustAnchorRepoFromRemoteUrl(url) {
7304
+ const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
7305
+ return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
7306
+ }
7307
+ var execFileAsync4 = promisify4(execFile4);
7308
+ function resolveCiTrustAnchorProbeRef(env = process.env) {
7309
+ const ref = env.VINAYA_CI_CONFIG_PROBE_REF?.trim();
7310
+ if (!ref)
7311
+ return null;
7312
+ if (env.GITHUB_ACTIONS !== "true")
7313
+ return null;
7314
+ if ((env.GH_TOKEN ?? "").length > 0 || (env.GITHUB_TOKEN ?? "").length > 0)
7315
+ return null;
7316
+ return ref;
7317
+ }
7318
+ function readTrustAnchorConfigAtRef(ref) {
7319
+ const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
7320
+ encoding: "utf-8",
7321
+ stdio: ["ignore", "pipe", "pipe"],
7322
+ timeout: 1e4
7323
+ });
7324
+ return Buffer.from(raw, "utf-8").toString("base64");
7325
+ }
7109
7326
  function ghFetchTrustAnchorConfig() {
7327
+ const probeRef = resolveCiTrustAnchorProbeRef();
7328
+ if (probeRef)
7329
+ return readTrustAnchorConfigAtRef(probeRef);
7110
7330
  const repo = trustAnchorRepo();
7111
7331
  if (!repo)
7112
7332
  throw new Error("could not resolve repo identity for the trust-anchor read");
@@ -7115,6 +7335,21 @@ function ghFetchTrustAnchorConfig() {
7115
7335
  stdio: ["ignore", "pipe", "pipe"]
7116
7336
  });
7117
7337
  }
7338
+ async function ghFetchTrustAnchorConfigAsync() {
7339
+ const probeRef = resolveCiTrustAnchorProbeRef();
7340
+ if (probeRef) {
7341
+ const { stdout } = await execFileAsync4("git", ["show", `${probeRef}:${LOCAL_CONFIG_FILENAME}`], {
7342
+ encoding: "utf-8",
7343
+ timeout: 1e4
7344
+ });
7345
+ return Buffer.from(stdout, "utf-8").toString("base64");
7346
+ }
7347
+ const repo = await trustAnchorRepoAsync();
7348
+ if (!repo)
7349
+ throw new Error("could not resolve repo identity for the trust-anchor read");
7350
+ const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
7351
+ return stdout;
7352
+ }
7118
7353
  function firstLine(err) {
7119
7354
  return err?.message?.split(`
7120
7355
  `)[0] ?? "unknown error";
@@ -7129,16 +7364,35 @@ function isMissingFileError(err) {
7129
7364
  return /\b404\b|not found/i.test(haystack);
7130
7365
  }
7131
7366
  function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
7132
- const warn = (why) => process.stdout.write(`⚠ could not read the trust-anchor config (\`principals\`/\`releaseActor\`) from the default branch (${why}) — falling back to vinaya's built-in defaults.
7133
- `);
7134
7367
  let base64;
7135
7368
  try {
7136
- base64 = fetcher().trim();
7369
+ base64 = fetcher();
7137
7370
  } catch (err) {
7138
- if (!isMissingFileError(err))
7139
- warn(firstLine(err));
7140
- return null;
7371
+ return trustAnchorFetchFailed(err);
7141
7372
  }
7373
+ return parseTrustAnchorContent(base64);
7374
+ }
7375
+ async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
7376
+ const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
7377
+ let base64;
7378
+ try {
7379
+ base64 = await fetcher();
7380
+ } catch (err) {
7381
+ return trustAnchorFetchFailed(err, warn);
7382
+ }
7383
+ return parseTrustAnchorContent(base64, warn);
7384
+ }
7385
+ function warnTrustAnchorFallback(why) {
7386
+ process.stdout.write(`⚠ could not read the trust-anchor config (\`principals\`/\`releaseActor\`) from the default branch (${why}) — falling back to vinaya's built-in defaults.
7387
+ `);
7388
+ }
7389
+ function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
7390
+ if (!isMissingFileError(err))
7391
+ warn(firstLine(err));
7392
+ return null;
7393
+ }
7394
+ function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
7395
+ const base64 = content.trim();
7142
7396
  if (!base64)
7143
7397
  return null;
7144
7398
  try {
@@ -7166,28 +7420,524 @@ function loadConfig() {
7166
7420
  }
7167
7421
  var TOKENS_COLLECT_TRUST_PATH = join3(GLOBAL_VINAYA_HOME, "tokens-collect-trust.json");
7168
7422
 
7423
+ // src/lib/run-paths.ts
7424
+ import { chmodSync, existsSync as existsSync4, realpathSync as realpathSync2 } from "node:fs";
7425
+ import { dirname as dirname3, join as join4, resolve as resolvePath } from "node:path";
7426
+ var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
7427
+ function isSafeRepoSegment(segment) {
7428
+ return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
7429
+ }
7430
+ function repoSegment(repo) {
7431
+ if (!repo || !isSafeRepoSegment(repo.owner) || !isSafeRepoSegment(repo.repo))
7432
+ return "unresolved";
7433
+ return `${repo.owner}-${repo.repo}`;
7434
+ }
7435
+ function defaultRuntimeDir(repo, home = GLOBAL_VINAYA_HOME) {
7436
+ return join4(home, "runtime", repoSegment(repo));
7437
+ }
7438
+ function resolveRuntimeDir(input) {
7439
+ const local = resolveRuntimeDirSetting(input.localConfig);
7440
+ if (local === null)
7441
+ return defaultRuntimeDir(input.repo, input.home);
7442
+ if (isInsideRepo(local, input.repoRoot))
7443
+ return defaultRuntimeDir(input.repo, input.home);
7444
+ if (!input.unattended)
7445
+ return local;
7446
+ const anchored = resolveTrustAnchorRuntimeDir(local, input.trustAnchorConfig ?? null);
7447
+ return anchored ?? defaultRuntimeDir(input.repo, input.home);
7448
+ }
7449
+ function isInsideRepo(candidate, repoRoot) {
7450
+ if (!repoRoot)
7451
+ return false;
7452
+ const root = resolvePath(repoRoot);
7453
+ const target = resolvePath(candidate);
7454
+ return target === root || target.startsWith(`${root}/`);
7455
+ }
7456
+ var UNATTENDED_ENV_KEY = "VINAYA_UNATTENDED";
7457
+ var RUNTIME_DIR_ENV_KEY = "VINAYA_RUNTIME_DIR";
7458
+ function isUnattendedProcess(env = process.env) {
7459
+ return env[UNATTENDED_ENV_KEY] === "1" || (env.VINAYA_ROLE ?? "") !== "";
7460
+ }
7461
+ var memoized = null;
7462
+ async function runtimeDirForRepoAsync(repo) {
7463
+ const key = repoSegment(repo);
7464
+ if (memoized?.key === key)
7465
+ return memoized.value;
7466
+ const inputs = runtimeDirInputs();
7467
+ if (typeof inputs === "string")
7468
+ return inputs;
7469
+ const value = resolveRuntimeDir({
7470
+ repo,
7471
+ ...inputs.base,
7472
+ trustAnchorConfig: inputs.needsAnchor ? await loadTrustAnchorConfigAsync() : null
7473
+ });
7474
+ memoized = { key, value };
7475
+ return value;
7476
+ }
7477
+ function runtimeDirInputs() {
7478
+ const handedDown = process.env[RUNTIME_DIR_ENV_KEY];
7479
+ if (handedDown)
7480
+ return handedDown;
7481
+ const localConfig = loadConfig();
7482
+ const unattended = isUnattendedProcess();
7483
+ return {
7484
+ base: { localConfig, unattended, repoRoot: repoRootSync() },
7485
+ needsAnchor: unattended && resolveRuntimeDirSetting(localConfig) !== null
7486
+ };
7487
+ }
7488
+ function repoRootSync(start = process.cwd()) {
7489
+ let dir;
7490
+ try {
7491
+ dir = realpathSync2(start);
7492
+ } catch {
7493
+ return null;
7494
+ }
7495
+ for (;; ) {
7496
+ if (existsSync4(join4(dir, ".git")))
7497
+ return dir;
7498
+ const parent = dirname3(dir);
7499
+ if (parent === dir)
7500
+ return null;
7501
+ dir = parent;
7502
+ }
7503
+ }
7504
+
7505
+ // src/lib/log-webhook-drain.ts
7506
+ import {
7507
+ closeSync as closeSync2,
7508
+ constants as fsConstants2,
7509
+ lstatSync,
7510
+ mkdirSync as mkdirSync2,
7511
+ openSync as openSync2,
7512
+ linkSync,
7513
+ readFileSync as readFileSync3,
7514
+ renameSync,
7515
+ statSync,
7516
+ unlinkSync,
7517
+ utimesSync,
7518
+ writeFileSync as writeFileSync2,
7519
+ writeSync
7520
+ } from "node:fs";
7521
+ import { randomUUID } from "node:crypto";
7522
+ import { homedir as homedir2 } from "node:os";
7523
+ import { dirname as dirname4, join as join5 } from "node:path";
7524
+ var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
7525
+ var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
7526
+ var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
7527
+ function isSafeRepoSegment2(segment) {
7528
+ return SAFE_PATH_SEGMENT2.test(segment) && !segment.includes("..");
7529
+ }
7530
+ function isErrnoCode(err, code) {
7531
+ return typeof err === "object" && err !== null && err.code === code;
7532
+ }
7533
+ function isEnoent(err) {
7534
+ return isErrnoCode(err, "ENOENT");
7535
+ }
7536
+ var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
7537
+ function tryCreateLock(lockPath, token) {
7538
+ try {
7539
+ mkdirSync2(dirname4(lockPath), { recursive: true, mode: 448 });
7540
+ const fd = openSync2(lockPath, fsConstants2.O_WRONLY | fsConstants2.O_CREAT | fsConstants2.O_EXCL, 384);
7541
+ try {
7542
+ writeSync(fd, `${token}
7543
+ `);
7544
+ } finally {
7545
+ closeSync2(fd);
7546
+ }
7547
+ return true;
7548
+ } catch (err) {
7549
+ if (isErrnoCode(err, "EEXIST"))
7550
+ return false;
7551
+ throw err;
7552
+ }
7553
+ }
7554
+ function acquireDrainLock(lockPath) {
7555
+ const token = `${process.pid}:${randomUUID()}`;
7556
+ if (tryCreateLock(lockPath, token))
7557
+ return token;
7558
+ let observedMtimeMs;
7559
+ try {
7560
+ observedMtimeMs = statSync(lockPath).mtimeMs;
7561
+ } catch (err) {
7562
+ if (!isEnoent(err))
7563
+ throw err;
7564
+ return tryCreateLock(lockPath, token) ? token : null;
7565
+ }
7566
+ if (Date.now() - observedMtimeMs <= WEBHOOK_DRAIN_LOCK_STALE_MS)
7567
+ return null;
7568
+ const claimed = `${lockPath}.claimed-${randomUUID()}`;
7569
+ try {
7570
+ renameSync(lockPath, claimed);
7571
+ } catch (err) {
7572
+ if (isEnoent(err))
7573
+ return null;
7574
+ throw err;
7575
+ }
7576
+ let claimedMtimeMs = null;
7577
+ try {
7578
+ claimedMtimeMs = statSync(claimed).mtimeMs;
7579
+ } catch (err) {
7580
+ if (!isEnoent(err))
7581
+ throw err;
7582
+ }
7583
+ if (claimedMtimeMs !== observedMtimeMs) {
7584
+ try {
7585
+ linkSync(claimed, lockPath);
7586
+ } catch (err) {
7587
+ if (!isErrnoCode(err, "EEXIST"))
7588
+ throw err;
7589
+ }
7590
+ try {
7591
+ unlinkSync(claimed);
7592
+ } catch (err) {
7593
+ if (!isEnoent(err))
7594
+ throw err;
7595
+ }
7596
+ return null;
7597
+ }
7598
+ unlinkSync(claimed);
7599
+ return tryCreateLock(lockPath, token) ? token : null;
7600
+ }
7601
+ function renewDrainLock(lockPath, token) {
7602
+ let holder;
7603
+ try {
7604
+ holder = readFileSync3(lockPath, "utf8").trim();
7605
+ } catch (err) {
7606
+ if (!isEnoent(err))
7607
+ throw err;
7608
+ return false;
7609
+ }
7610
+ if (holder !== token)
7611
+ return false;
7612
+ const now = new Date;
7613
+ try {
7614
+ utimesSync(lockPath, now, now);
7615
+ } catch (err) {
7616
+ if (!isEnoent(err))
7617
+ throw err;
7618
+ return false;
7619
+ }
7620
+ return true;
7621
+ }
7622
+ function releaseDrainLock(lockPath, token) {
7623
+ try {
7624
+ const holder = readFileSync3(lockPath, "utf8").trim();
7625
+ if (holder !== token)
7626
+ return;
7627
+ unlinkSync(lockPath);
7628
+ } catch (err) {
7629
+ if (!isEnoent(err))
7630
+ throw err;
7631
+ }
7632
+ }
7633
+
7634
+ class WebhookDrainError extends Error {
7635
+ code;
7636
+ constructor(code, message) {
7637
+ super(message);
7638
+ this.code = code;
7639
+ }
7640
+ }
7641
+ function backupPathFor(queuePath) {
7642
+ return queuePath.replace(/\.ndjson$/, ".1.ndjson");
7643
+ }
7644
+ function drainingPathFor(queuePath) {
7645
+ return queuePath.replace(/\.ndjson$/, ".draining.ndjson");
7646
+ }
7647
+ function rejectedPathFor(queuePath) {
7648
+ return queuePath.replace(/\.ndjson$/, ".rejected.ndjson");
7649
+ }
7650
+ var rejectionWarnedThisProcess = false;
7651
+ function warnRejectionOnce(message) {
7652
+ if (rejectionWarnedThisProcess)
7653
+ return;
7654
+ rejectionWarnedThisProcess = true;
7655
+ try {
7656
+ process.stderr.write(message);
7657
+ } catch {}
7658
+ }
7659
+ function queueLines(buf) {
7660
+ const lines = [];
7661
+ let start = 0;
7662
+ for (let i = 0;i < buf.byteLength; i++) {
7663
+ if (buf[i] !== 10)
7664
+ continue;
7665
+ if (i > start)
7666
+ lines.push({ raw: buf.toString("utf8", start, i), end: i + 1 });
7667
+ start = i + 1;
7668
+ }
7669
+ if (start < buf.byteLength)
7670
+ lines.push({ raw: buf.toString("utf8", start), end: buf.byteLength });
7671
+ return lines;
7672
+ }
7673
+ function removeQueueHead(path, cut) {
7674
+ const remaining = readFileSync3(path);
7675
+ writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
7676
+ }
7677
+ function queueBucketSize(path) {
7678
+ let lstat;
7679
+ try {
7680
+ lstat = lstatSync(path);
7681
+ } catch (err) {
7682
+ if (!isEnoent(err))
7683
+ throw err;
7684
+ }
7685
+ if (lstat === undefined)
7686
+ return null;
7687
+ if (!lstat.isFile()) {
7688
+ throw new WebhookDrainError("log-webhook-drain-symlink", `log webhook drain: outbox target is not a regular file (symlink, FIFO, or similar) — refusing to read: ${path}`);
7689
+ }
7690
+ return Number(lstat.size);
7691
+ }
7692
+ function readQueueFile(path) {
7693
+ if (queueBucketSize(path) === null)
7694
+ return null;
7695
+ return readFileSync3(path);
7696
+ }
7697
+ function rejectLine(rejectedPath, reason, status, identity, raw) {
7698
+ const record = JSON.stringify({
7699
+ rejected_at: new Date().toISOString(),
7700
+ status,
7701
+ reason,
7702
+ identity,
7703
+ bytes: Buffer.byteLength(raw, "utf8"),
7704
+ raw
7705
+ });
7706
+ const failure = appendHardenedLine(rejectedPath, `${record}
7707
+ `);
7708
+ if (failure !== null) {
7709
+ throw new WebhookDrainError("log-webhook-drain-rejected-write", `log webhook drain: a queued line failed re-validation (${reason}) and could not be set aside in ${rejectedPath} — ${failure}; the line stays queued`);
7710
+ }
7711
+ warnRejectionOnce(`vinaya: log delivery set a queued line aside in ${rejectedPath} — ${reason}; later lines keep delivering
7712
+ `);
7713
+ }
7714
+ async function postChunk(webhookUrl, headers, body, fetchTimeoutMs, chunksAlreadyDelivered) {
7715
+ const delivered = chunksAlreadyDelivered > 0 ? ` after delivering ${chunksAlreadyDelivered} chunk(s)` : "";
7716
+ let response;
7717
+ try {
7718
+ response = await fetch(webhookUrl, {
7719
+ method: "POST",
7720
+ headers: { "content-type": "application/x-ndjson", ...headers },
7721
+ body,
7722
+ signal: AbortSignal.timeout(fetchTimeoutMs)
7723
+ });
7724
+ } catch (err) {
7725
+ const reason = err instanceof Error && err.name === "TimeoutError" ? `timed out after ${fetchTimeoutMs}ms` : err instanceof Error ? err.message : String(err);
7726
+ throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} failed${delivered}: ${reason}`);
7727
+ }
7728
+ if (!response.ok) {
7729
+ throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} returned ${response.status} ${response.statusText}${delivered}`);
7730
+ }
7731
+ }
7732
+ async function drainQueueFile(args) {
7733
+ const { path, rejectedPath, webhookUrl, headers, fetchTimeoutMs, totals } = args;
7734
+ const buf = readQueueFile(path);
7735
+ if (buf === null || buf.byteLength === 0)
7736
+ return;
7737
+ const lines = queueLines(buf);
7738
+ if (lines.length === 0) {
7739
+ removeQueueHead(path, buf.byteLength);
7740
+ return;
7741
+ }
7742
+ let removed = 0;
7743
+ let pendingEnd = 0;
7744
+ let chunk = [];
7745
+ let chunkBytes = 0;
7746
+ const deliverChunk = async () => {
7747
+ const body = `${chunk.join(`
7748
+ `)}
7749
+ `;
7750
+ args.keepLock();
7751
+ await postChunk(webhookUrl, headers, body, fetchTimeoutMs, totals.chunks);
7752
+ totals.chunks += 1;
7753
+ totals.lineCount += chunk.length;
7754
+ totals.bytes += Buffer.byteLength(body, "utf8");
7755
+ removeQueueHead(path, pendingEnd - removed);
7756
+ removed = pendingEnd;
7757
+ chunk = [];
7758
+ chunkBytes = 0;
7759
+ };
7760
+ const setAside = async (reason, status, identity, line) => {
7761
+ if (chunk.length > 0)
7762
+ await deliverChunk();
7763
+ rejectLine(rejectedPath, reason, status, identity, line.raw);
7764
+ totals.rejected += 1;
7765
+ pendingEnd = line.end;
7766
+ removeQueueHead(path, pendingEnd - removed);
7767
+ removed = pendingEnd;
7768
+ };
7769
+ for (const line of lines) {
7770
+ const record = classifyStoredLine(line.raw, homedir2());
7771
+ if (record.status !== "ok") {
7772
+ await setAside(record.reason, record.status, record.identity, line);
7773
+ continue;
7774
+ }
7775
+ const lineBytes = Buffer.byteLength(record.postLine, "utf8") + 1;
7776
+ if (lineBytes > MAX_WEBHOOK_BODY_BYTES) {
7777
+ await setAside(`one line is ${lineBytes} byte(s), over the ${MAX_WEBHOOK_BODY_BYTES}-byte per-POST cap — no chunking can carry it`, "too_large", record.identity, line);
7778
+ continue;
7779
+ }
7780
+ if (chunk.length > 0 && chunkBytes + lineBytes > MAX_WEBHOOK_BODY_BYTES)
7781
+ await deliverChunk();
7782
+ chunk.push(record.postLine);
7783
+ chunkBytes += lineBytes;
7784
+ pendingEnd = line.end;
7785
+ }
7786
+ pendingEnd = buf.byteLength;
7787
+ if (chunk.length > 0) {
7788
+ await deliverChunk();
7789
+ return;
7790
+ }
7791
+ if (pendingEnd > removed)
7792
+ removeQueueHead(path, pendingEnd - removed);
7793
+ }
7794
+ async function drainRenamedAside(args, livePath, source) {
7795
+ args.keepLock();
7796
+ const draining = drainingPathFor(livePath);
7797
+ try {
7798
+ renameSync(source, draining);
7799
+ } catch (err) {
7800
+ if (isEnoent(err))
7801
+ return;
7802
+ throw err;
7803
+ }
7804
+ await drainQueueFile({ ...args, path: draining });
7805
+ unlinkSync(draining);
7806
+ }
7807
+ async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeoutMs = WEBHOOK_FETCH_TIMEOUT_MS) {
7808
+ const resolved = await resolveRepo();
7809
+ const repo = resolved && isSafeRepoSegment2(resolved.owner) && isSafeRepoSegment2(resolved.repo) ? resolved : null;
7810
+ const outboxRoot = () => join5(GLOBAL_VINAYA_HOME, "outbox");
7811
+ const path = outboxPathFor({ outboxRoot }, repo, outboxTask);
7812
+ const lockPath = `${path}.flush-lock`;
7813
+ const lockToken = acquireDrainLock(lockPath);
7814
+ const totals = { lineCount: 0, bytes: 0, chunks: 0, rejected: 0 };
7815
+ if (lockToken === null)
7816
+ return { flushed: false, ...totals };
7817
+ try {
7818
+ const keepLock = () => {
7819
+ if (renewDrainLock(lockPath, lockToken))
7820
+ return;
7821
+ throw new WebhookDrainError("log-webhook-drain-lock-lost", `log webhook drain: this drain's lock on ${lockPath} was taken over by another process — stopping here; that process delivers the rest`);
7822
+ };
7823
+ const shared = {
7824
+ rejectedPath: rejectedPathFor(path),
7825
+ webhookUrl,
7826
+ headers,
7827
+ fetchTimeoutMs,
7828
+ totals,
7829
+ keepLock
7830
+ };
7831
+ const draining = drainingPathFor(path);
7832
+ if (queueBucketSize(draining) !== null) {
7833
+ keepLock();
7834
+ await drainQueueFile({ ...shared, path: draining });
7835
+ unlinkSync(draining);
7836
+ }
7837
+ await drainRenamedAside(shared, path, backupPathFor(path));
7838
+ await drainRenamedAside(shared, path, path);
7839
+ return { flushed: totals.chunks > 0 || totals.rejected > 0, ...totals };
7840
+ } finally {
7841
+ releaseDrainLock(lockPath, lockToken);
7842
+ }
7843
+ }
7844
+
7169
7845
  // src/lib/log-sink.ts
7170
7846
  var OUTBOX_MAX_BYTES = 8 * 1024 * 1024;
7171
- function isEnoent(err) {
7847
+ var LOG_CONTEXT_LOOKUP_DEADLINE_MS = 3000;
7848
+ function withDeadline(work, ms, fallback) {
7849
+ return new Promise((resolve) => {
7850
+ const timer = setTimeout(() => resolve(fallback), ms);
7851
+ timer.unref?.();
7852
+ work.then((value) => {
7853
+ clearTimeout(timer);
7854
+ resolve(value);
7855
+ }, () => {
7856
+ clearTimeout(timer);
7857
+ resolve(fallback);
7858
+ });
7859
+ });
7860
+ }
7861
+ async function safeLoadTrustAnchorConfig() {
7862
+ return withDeadline(loadTrustAnchorConfigAsync(undefined, { quiet: true }), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
7863
+ }
7864
+ function logsCredentialMissing(headers, env) {
7865
+ if (!headers)
7866
+ return false;
7867
+ const varPattern = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
7868
+ for (const value of Object.values(headers)) {
7869
+ for (const match of value.matchAll(varPattern)) {
7870
+ if (!env[match[1]])
7871
+ return true;
7872
+ }
7873
+ }
7874
+ return false;
7875
+ }
7876
+ function resolveLogDestinationFrom(input) {
7877
+ const local = resolveLogsSetting(input.localConfig);
7878
+ let effective = null;
7879
+ if (input.unattended) {
7880
+ effective = local ? resolveTrustAnchorLogsDestination(local, input.trustAnchorConfig) : resolveLogsSetting(input.trustAnchorConfig);
7881
+ } else {
7882
+ effective = local;
7883
+ }
7884
+ if (hostFromEnv(input.env) === "ci") {
7885
+ if (effective && "url" in effective) {
7886
+ if (logsCredentialMissing(effective.headers, input.env)) {
7887
+ return {
7888
+ kind: "none",
7889
+ reason: "a logs.url server destination is configured, but this job holds no delivery credential (a fork pull request, or a missing repository secret)"
7890
+ };
7891
+ }
7892
+ return { kind: "server", url: effective.url, headers: resolveLogsHeaderValues(effective.headers, input.env) };
7893
+ }
7894
+ return {
7895
+ kind: "none",
7896
+ reason: "no server destination is configured for CI delivery (vinaya.config.json logs.url)"
7897
+ };
7898
+ }
7899
+ if (effective && "url" in effective) {
7900
+ return { kind: "server", url: effective.url, headers: resolveLogsHeaderValues(effective.headers, input.env) };
7901
+ }
7902
+ if (effective && "folder" in effective && isInsideRepo(effective.folder, input.repoRoot)) {
7903
+ effective = null;
7904
+ }
7905
+ const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
7906
+ return { kind: "folder", folder };
7907
+ }
7908
+ var processTrustAnchorOnce;
7909
+ function processTrustAnchor() {
7910
+ if (processTrustAnchorOnce === undefined)
7911
+ processTrustAnchorOnce = safeLoadTrustAnchorConfig();
7912
+ return processTrustAnchorOnce;
7913
+ }
7914
+ async function defaultResolveLogDestination(repo, env) {
7915
+ const localConfig = loadConfig();
7916
+ const unattended = isUnattendedProcess(process.env);
7917
+ return resolveLogDestinationFrom({
7918
+ localConfig,
7919
+ trustAnchorConfig: unattended ? await processTrustAnchor() : null,
7920
+ unattended,
7921
+ env,
7922
+ defaultFolder: join6(await runtimeDirForRepoAsync(repo), "logs"),
7923
+ repoRoot: repoRootSync()
7924
+ });
7925
+ }
7926
+ function isEnoent2(err) {
7172
7927
  return typeof err === "object" && err !== null && err.code === "ENOENT";
7173
7928
  }
7174
- function resolveDoctrine(cwd, vinayaVersion) {
7929
+ var execFileAsync5 = promisify5(execFile5);
7930
+ async function resolveDoctrine(cwd, vinayaVersion) {
7175
7931
  let toplevel;
7176
7932
  try {
7177
- toplevel = execFileSync3("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
7178
- encoding: "utf8",
7179
- stdio: ["ignore", "pipe", "pipe"]
7180
- }).trim();
7933
+ toplevel = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "--show-toplevel"], { encoding: "utf8" })).stdout.trim();
7181
7934
  } catch (err) {
7182
- return isEnoent(err) ? "unknown" : vinayaVersion;
7935
+ return isEnoent2(err) ? "unknown" : vinayaVersion;
7183
7936
  }
7184
- if (!existsSync4(join4(toplevel, "aeg-root", "roles")))
7937
+ if (!existsSync5(join6(toplevel, "aeg-root", "roles")))
7185
7938
  return vinayaVersion;
7186
7939
  try {
7187
- const sha = execFileSync3("git", ["-C", toplevel, "rev-parse", "HEAD:aeg-root"], {
7188
- encoding: "utf8",
7189
- stdio: ["ignore", "pipe", "pipe"]
7190
- }).trim();
7940
+ const sha = (await execFileAsync5("git", ["-C", toplevel, "rev-parse", "HEAD:aeg-root"], { encoding: "utf8" })).stdout.trim();
7191
7941
  return `aeg-root@${sha}`;
7192
7942
  } catch {
7193
7943
  return vinayaVersion;
@@ -7195,20 +7945,20 @@ function resolveDoctrine(cwd, vinayaVersion) {
7195
7945
  }
7196
7946
  function readVinayaVersion() {
7197
7947
  try {
7198
- const pkg = JSON.parse(readFileSync3(join4(packageRoot(import.meta.url), "package.json"), "utf8"));
7948
+ const pkg = JSON.parse(readFileSync4(join6(packageRoot(import.meta.url), "package.json"), "utf8"));
7199
7949
  return pkg.version ?? "unknown";
7200
7950
  } catch {
7201
7951
  return "unknown";
7202
7952
  }
7203
7953
  }
7204
- var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
7205
- function isSafeRepoSegment(segment) {
7206
- return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
7954
+ var SAFE_PATH_SEGMENT3 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
7955
+ function isSafeRepoSegment3(segment) {
7956
+ return SAFE_PATH_SEGMENT3.test(segment) && !segment.includes("..");
7207
7957
  }
7208
7958
  function outboxPathFor(deps, repo, issue) {
7209
7959
  const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
7210
7960
  const fileName = `${issue ?? "none"}.ndjson`;
7211
- return join4(deps.outboxRoot(), dirName, fileName);
7961
+ return join6(deps.outboxRoot(), dirName, fileName);
7212
7962
  }
7213
7963
  function hostFromEnv(env) {
7214
7964
  if (env.GITHUB_ACTIONS)
@@ -7219,36 +7969,60 @@ function hostFromEnv(env) {
7219
7969
  return "loop";
7220
7970
  return "cli";
7221
7971
  }
7972
+ var warnedThisProcess = false;
7973
+ function defaultStderr(message) {
7974
+ if (warnedThisProcess)
7975
+ return;
7976
+ warnedThisProcess = true;
7977
+ process.stderr.write(message);
7978
+ }
7222
7979
  function defaultDeps() {
7223
7980
  return {
7224
- outboxRoot: () => join4(GLOBAL_VINAYA_HOME, "outbox"),
7225
- home: () => homedir2(),
7981
+ outboxRoot: () => join6(GLOBAL_VINAYA_HOME, "outbox"),
7982
+ home: () => homedir3(),
7226
7983
  hostname: () => osHostname(),
7227
7984
  cwd: () => process.cwd(),
7228
7985
  now: () => new Date,
7229
7986
  env: () => process.env,
7230
7987
  resolveRepo: () => resolveRepo(),
7231
7988
  vinayaVersion: () => readVinayaVersion(),
7232
- stderr: (message) => {
7233
- process.stderr.write(message);
7234
- },
7989
+ stderr: defaultStderr,
7235
7990
  inputVersions: () => {
7236
7991
  return;
7237
- }
7992
+ },
7993
+ resolveLogDestination: defaultResolveLogDestination
7238
7994
  };
7239
7995
  }
7240
- var APPEND_OPEN_FLAGS = fsConstants2.O_WRONLY | fsConstants2.O_APPEND | fsConstants2.O_CREAT | fsConstants2.O_NOFOLLOW | fsConstants2.O_NONBLOCK;
7996
+ var APPEND_OPEN_FLAGS = fsConstants3.O_WRONLY | fsConstants3.O_APPEND | fsConstants3.O_CREAT | fsConstants3.O_NOFOLLOW | fsConstants3.O_NONBLOCK;
7241
7997
  function guardedAppendOpen(path) {
7242
7998
  try {
7243
- return openSync2(path, APPEND_OPEN_FLAGS, 384);
7999
+ return openSync3(path, APPEND_OPEN_FLAGS, 384);
7244
8000
  } catch {
7245
8001
  return;
7246
8002
  }
7247
8003
  }
8004
+ function appendHardenedLine(path, line) {
8005
+ try {
8006
+ mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
8007
+ const fd = guardedAppendOpen(path);
8008
+ if (fd === undefined)
8009
+ return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
8010
+ try {
8011
+ if (!fstatSync2(fd).isFile())
8012
+ return `target is not a regular file: ${path}`;
8013
+ writeSync2(fd, line);
8014
+ } finally {
8015
+ closeSync3(fd);
8016
+ }
8017
+ return null;
8018
+ } catch (err) {
8019
+ return err instanceof Error ? err.message : String(err);
8020
+ }
8021
+ }
7248
8022
  function reportRotationOverflow(backupPath, warn) {
7249
8023
  let raw;
7250
8024
  try {
7251
- raw = readFileSync3(backupPath, "utf8");
8025
+ raw = readFileSync4(backupPath, "utf8");
7252
8026
  } catch {
7253
8027
  return;
7254
8028
  }
@@ -7271,7 +8045,7 @@ function reportRotationOverflow(backupPath, warn) {
7271
8045
  }
7272
8046
  function appendLine(path, line, warn) {
7273
8047
  try {
7274
- mkdirSync2(dirname3(path), { recursive: true, mode: 448 });
8048
+ mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
7275
8049
  let fd = guardedAppendOpen(path);
7276
8050
  if (fd === undefined) {
7277
8051
  warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
@@ -7287,11 +8061,11 @@ function appendLine(path, line, warn) {
7287
8061
  return;
7288
8062
  }
7289
8063
  if (stat.size > OUTBOX_MAX_BYTES) {
7290
- closeSync2(fd);
8064
+ closeSync3(fd);
7291
8065
  closed = true;
7292
8066
  const backupPath = path.replace(/\.ndjson$/, ".1.ndjson");
7293
8067
  reportRotationOverflow(backupPath, warn);
7294
- renameSync(path, backupPath);
8068
+ renameSync2(path, backupPath);
7295
8069
  const rotated = guardedAppendOpen(path);
7296
8070
  if (rotated === undefined) {
7297
8071
  warn(`vinaya: log outbox target could not be reopened after rotation — refusing: ${path}
@@ -7301,10 +8075,10 @@ function appendLine(path, line, warn) {
7301
8075
  fd = rotated;
7302
8076
  closed = false;
7303
8077
  }
7304
- writeSync(fd, line);
8078
+ writeSync2(fd, line);
7305
8079
  } finally {
7306
8080
  if (!closed)
7307
- closeSync2(fd);
8081
+ closeSync3(fd);
7308
8082
  }
7309
8083
  } catch (err) {
7310
8084
  warn(`vinaya: log outbox write failed — ${err instanceof Error ? err.message : String(err)}
@@ -7313,8 +8087,8 @@ function appendLine(path, line, warn) {
7313
8087
  }
7314
8088
  function createLogSink(overrides = {}) {
7315
8089
  const deps = { ...defaultDeps(), ...overrides };
7316
- const runId = deps.env().VINAYA_RUN_ID || randomUUID();
7317
- const processId = randomUUID();
8090
+ const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
8091
+ const processId = randomUUID2();
7318
8092
  let seq = 0;
7319
8093
  let warned = false;
7320
8094
  const warnOnce = (message) => {
@@ -7327,8 +8101,9 @@ function createLogSink(overrides = {}) {
7327
8101
  };
7328
8102
  let doctrineCache;
7329
8103
  const doctrine = () => {
7330
- if (doctrineCache === undefined)
7331
- doctrineCache = resolveDoctrine(deps.cwd(), deps.vinayaVersion());
8104
+ if (doctrineCache === undefined) {
8105
+ doctrineCache = withDeadline(resolveDoctrine(deps.cwd(), deps.vinayaVersion()), LOG_CONTEXT_LOOKUP_DEADLINE_MS, deps.vinayaVersion());
8106
+ }
7332
8107
  return doctrineCache;
7333
8108
  };
7334
8109
  let resolveRepoCache;
@@ -7337,6 +8112,30 @@ function createLogSink(overrides = {}) {
7337
8112
  resolveRepoCache = deps.resolveRepo();
7338
8113
  return resolveRepoCache;
7339
8114
  };
8115
+ let contextCache;
8116
+ const context = () => {
8117
+ if (contextCache === undefined) {
8118
+ const env = deps.env();
8119
+ contextCache = Promise.all([
8120
+ withDeadline(resolveRepoOnce(), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null),
8121
+ doctrine()
8122
+ ]).then(async ([resolved, doctrineValue]) => {
8123
+ const repo = resolved && isSafeRepoSegment3(resolved.owner) && isSafeRepoSegment3(resolved.repo) ? resolved : null;
8124
+ return { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
8125
+ });
8126
+ }
8127
+ return contextCache;
8128
+ };
8129
+ let drainChain = Promise.resolve();
8130
+ const pendingWrites = new Set;
8131
+ const scheduleWebhookDrain = (issue, url, headers) => {
8132
+ drainChain = drainChain.then(() => drainOutboxToWebhook(issue, url, headers)).then(() => {
8133
+ return;
8134
+ }).catch((err) => {
8135
+ warnOnce(`vinaya: log delivery to ${url} failed — queued in the local outbox, retried on the next event: ${err instanceof Error ? err.message : String(err)}
8136
+ `);
8137
+ });
8138
+ };
7340
8139
  function log(e) {
7341
8140
  try {
7342
8141
  const env = deps.env();
@@ -7351,22 +8150,26 @@ function createLogSink(overrides = {}) {
7351
8150
  attempt: env.VINAYA_ATTEMPT,
7352
8151
  parent: env.VINAYA_PARENT_EVENT
7353
8152
  };
7354
- resolveRepoOnce().then((resolved) => {
7355
- const repo = resolved && isSafeRepoSegment(resolved.owner) && isSafeRepoSegment(resolved.repo) ? resolved : null;
8153
+ const written = context().then(({ repo, doctrine: doctrineValue, destination: resolvedDestination }) => {
7356
8154
  const header = buildHeader({
7357
8155
  now,
7358
8156
  runId,
7359
8157
  seq: mySeq,
7360
8158
  repo: repo ? `${repo.owner}/${repo.repo}` : null,
7361
8159
  vinaya: deps.vinayaVersion(),
7362
- doctrine: doctrine(),
8160
+ doctrine: doctrineValue,
7363
8161
  host,
7364
8162
  hostname: deps.hostname(),
7365
8163
  env: envFields,
7366
- eventId: randomUUID(),
8164
+ eventId: randomUUID2(),
7367
8165
  processId,
7368
8166
  inputVersions: deps.inputVersions()
7369
8167
  });
8168
+ if (resolvedDestination.kind === "none") {
8169
+ warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
8170
+ `);
8171
+ return;
8172
+ }
7370
8173
  const full = { ...e, ...header };
7371
8174
  const parsed = LogEventSchema.safeParse(full);
7372
8175
  if (!parsed.success) {
@@ -7376,25 +8179,42 @@ function createLogSink(overrides = {}) {
7376
8179
  }
7377
8180
  const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
7378
8181
  `;
7379
- appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
8182
+ const destination = resolvedDestination;
8183
+ if (destination.kind === "server") {
8184
+ appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
8185
+ scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
8186
+ } else {
8187
+ appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
8188
+ }
7380
8189
  }).catch((err) => {
7381
8190
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
7382
8191
  `);
7383
8192
  });
8193
+ pendingWrites.add(written);
8194
+ written.finally(() => pendingWrites.delete(written));
7384
8195
  } catch (err) {
7385
8196
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
7386
8197
  `);
7387
8198
  }
7388
8199
  }
7389
8200
  const warmup = () => {
7390
- doctrine();
7391
8201
  const originalWarn = console.warn;
7392
8202
  console.warn = () => {};
7393
8203
  resolveRepoOnce().finally(() => {
7394
8204
  console.warn = originalWarn;
7395
8205
  });
8206
+ context().catch(() => {
8207
+ return;
8208
+ });
7396
8209
  };
7397
- return { log, runId, warmup };
8210
+ const drain = async () => {
8211
+ if (pendingWrites.size > 0)
8212
+ await Promise.allSettled(Array.from(pendingWrites));
8213
+ await drainChain.catch(() => {
8214
+ return;
8215
+ });
8216
+ };
8217
+ return { log, runId, warmup, drain };
7398
8218
  }
7399
8219
  var defaultSink = createLogSink();
7400
8220
 
@@ -7425,8 +8245,8 @@ function summariseNumstat(numstat) {
7425
8245
  deleted += Number(d) || 0;
7426
8246
  }
7427
8247
  const files = `${rows.length} file${rows.length === 1 ? "" : "s"} changed`;
7428
- const bin2 = binary > 0 ? `, ${binary} binary` : "";
7429
- return `${files}, ${added} insertion${added === 1 ? "" : "s"}(+), ${deleted} deletion${deleted === 1 ? "" : "s"}(-)${bin2}`;
8248
+ const bin = binary > 0 ? `, ${binary} binary` : "";
8249
+ return `${files}, ${added} insertion${added === 1 ? "" : "s"}(+), ${deleted} deletion${deleted === 1 ? "" : "s"}(-)${bin}`;
7430
8250
  }
7431
8251
  var EVIDENCE_SUMMARY_PREFIX = "Summary: ";
7432
8252
 
@@ -7487,11 +8307,13 @@ function summaryLineIndex(maskedRegion) {
7487
8307
  var LOOP_LOG_MAX_BYTES = 8 * 1024 * 1024;
7488
8308
 
7489
8309
  // src/lib/diff-evidence.ts
7490
- import { execFileSync as execFileSync6 } from "node:child_process";
7491
- import { join as join5, relative, resolve as resolve2 } from "node:path";
8310
+ import { execFileSync as execFileSync5 } from "node:child_process";
8311
+ import { join as join8, relative, resolve as resolve2 } from "node:path";
7492
8312
 
7493
8313
  // src/lib/brief-assembly.ts
7494
- import { execFileSync as execFileSync5 } from "node:child_process";
8314
+ import { execFileSync as execFileSync4 } from "node:child_process";
8315
+ import { existsSync as existsSync6, readFileSync as readFileSync5, readdirSync } from "node:fs";
8316
+ import { join as join7 } from "node:path";
7495
8317
 
7496
8318
  // ../../packages/sources/src/commands.ts
7497
8319
  var COMMANDS = [
@@ -7644,10 +8466,10 @@ var COMMANDS = [
7644
8466
  }
7645
8467
  ],
7646
8468
  details: [
7647
- "Composes `task brief`'s own preparation (`prepareTask`) with `dev-review-loop` (`devReviewLoop`) — 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.",
8469
+ "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.",
7648
8470
  "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.",
7649
- "Refuses when the frozen brief's developer branch already has an open pull request — the old `task dispatch` followed by `task run` cannot start two developers this way.",
7650
- "Exit and printed summary distinguish a published, reviewed pull request (exit `0`, the PR URL) from a pause (exit `1`, with the exact `vinaya dev-review-loop --resume <pr>` command to continue), a usage/argv error (exit `2`), and any other failure (exit `3`) — never sharing `1` with a pause, so an unattended host tells them apart from the exit code alone. A run that pauses is resumed with the loop's own existing `--resume <pr>` flag, never a flag on this command."
8471
+ "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.",
8472
+ "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`)."
7651
8473
  ],
7652
8474
  status: "shipped"
7653
8475
  },
@@ -7686,7 +8508,7 @@ var COMMANDS = [
7686
8508
  details: [
7687
8509
  "Exposes the task-operator tool catalog (`packages/aeg-core/src/task-tools.ts`) to an agent runtime as one MCP server speaking newline-delimited JSON-RPC 2.0 (`initialize`/`tools/list`/`tools/call`). Claude registers it through the generated `.mcp.json`; Codex through its documented `~/.codex/config.toml` `[mcp_servers]` table — both point at this same command.",
7688
8510
  "stdout carries JSON-RPC and nothing else: any stray write from the CLI (a forge-read warning) is redirected to stderr, so the protocol stream is never corrupted.",
7689
- "`task_status`/`task_escalation_read` read; `task_start` starts a run in attended mode only, requiring an authenticated caller from the invocation context (`VINAYA_MCP_CALLER`) and refusing without one — MCP is a transport, not authorization. `task_resume`/`task_cancel` require the same authenticated caller, plus a current Principal ruling read fresh from the run's own PR — never a caller-supplied approval; `task_resume` triggers the existing `dev-review-loop --resume` continuation exactly once per escalation, and `task_cancel` reports a truthful `confirmed`/`pending`/`uncertain` outcome, idempotently, across repeated calls. No unattended start until the worker-isolation boundary and a capability flag land."
8511
+ "`task_status`/`task_escalation_read`/`task_pr_read` read; `task_pr_read` returns the selected task's OWN pull request — every required and reported check with its state, conclusion and failure summary, plus the principal-authored review record (newest verdicts and their judged head, round markers, published summary table, pause comment) — and refuses any other pull request; `task_start` starts a run in attended mode only, requiring an authenticated caller from the invocation context (`VINAYA_MCP_CALLER`) and refusing without one — MCP is a transport, not authorization. `task_resume`/`task_cancel` require the same authenticated caller, plus a current Principal ruling read fresh from the run's own PR — never a caller-supplied approval; `task_resume` triggers the existing `dev-review-loop --resume` continuation exactly once per escalation, and `task_cancel` reports a truthful `confirmed`/`pending`/`uncertain` outcome, idempotently, across repeated calls. No unattended start until the worker-isolation boundary and a capability flag land."
7690
8512
  ],
7691
8513
  status: "shipped"
7692
8514
  },
@@ -7816,48 +8638,6 @@ var COMMANDS = [
7816
8638
  ],
7817
8639
  status: "shipped"
7818
8640
  },
7819
- {
7820
- name: "log flush",
7821
- description: "Post a target Issue or PR's outbox as one or more marked comments, then truncate what the forge confirmed",
7822
- flags: [
7823
- { flag: "--issue", description: "Flush this Issue's outbox (`~/.vinaya/outbox/<owner>-<repo>/<n>.ndjson`)" },
7824
- {
7825
- flag: "--pr",
7826
- description: "Flush the Issue named by this PR's `Closes #N` line, posting the comments on the PR"
7827
- },
7828
- { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
7829
- ],
7830
- details: [
7831
- "Exactly one of `--issue`/`--pr` is required. `--pr` resolves the Issue from the PR body's `Closes #N` line — the same anchor every gate reads — and refuses with a check error naming the missing line when the body carries none.",
7832
- "Splits the outbox first at `run_id` boundaries (a maximal run of consecutive lines sharing one `run_id`, never a global group-by, so an interleaved outbox never produces a range spanning a gap), then at `FORGE_COMMENT_MAX_CHARS` (65536) within each run. Each comment opens with `<!-- aeg:log:<run_id>:<seq_from>-<seq_to> -->` on its own line, then one fenced `ndjson` block, one outbox line per line, verbatim. A single line too large to fit alone is refused by name, never split across two comments.",
7833
- "Logs its own `forge_write` line — `validated` before posting, `written` (with every returned comment id) after the last post succeeds, or `refused` (with gh's error) on any failure — through the same `log()` every other family uses, into the same outbox, before truncating. The outbox is truncated only to the lines confirmed posted; a failed chunk's lines, and anything appended to the outbox during the flush (including the flush's own `validated`/`written`/`refused` line), always survive to ride the next flush."
7834
- ],
7835
- status: "shipped"
7836
- },
7837
- {
7838
- name: "log export-artifact",
7839
- description: "Copy this run's own local outbox into a file, for the generated task-path workflow's own upload step",
7840
- flags: [],
7841
- details: [
7842
- "Concatenates every `*.ndjson` file under `~/.vinaya/outbox/` into `<dest>`, verbatim — no filtering, no second redaction pass (lines are already redacted at `log()`'s own write boundary). Writes nothing when the outbox is empty, and exits 0 either way: no gate events this run is a legitimate outcome, never a failure.",
7843
- "Runs inside the generated `vinaya-checks.yml` job, which holds no forge-write credential — this command never calls the forge. Both this step and the `actions/upload-artifact` step after it run `if: always()`, so a cancelled or failed job still exports whatever partial outbox it has."
7844
- ],
7845
- status: "shipped"
7846
- },
7847
- {
7848
- name: "log collect-artifact",
7849
- description: "Validate a downloaded task-log artifact and publish the valid records through the existing flush path",
7850
- flags: [
7851
- { flag: "--pr", description: "The pull request this artifact belongs to" },
7852
- { flag: "--repo", description: "Expected `owner/repo` — a provenance cross-check against each record" }
7853
- ],
7854
- details: [
7855
- "Runs inside the generated `vinaya-task-log-collector.yml` workflow — a `workflow_run`-triggered job on the default branch, holding the write credential the task-path job that produced the artifact never gets. `<path>` is already downloaded by that workflow, scoped to a specific, API-verified run id — a provenance guarantee this command never re-derives from the artifact bytes.",
7856
- "Never executes, imports, or evaluates the artifact's content: every line is read as text and validated (schema, an 8 MiB whole-artifact size cap, redaction, and a repo cross-check) before anything is trusted. A rejected line becomes a named gap — printed, never a silent drop — and the artifact is never partially trusted past that check into executing anything.",
7857
- "The valid, re-redacted survivors are appended into the same local outbox `vinaya log flush` would read for that PR's Issue, then published through the existing `flushOutbox` unmodified — reusing its chunking, its `<!-- aeg:log:… -->` marker, and its idempotent-retry read, rather than a second publisher. A retried collector run (a fresh runner, the same forge state) therefore dedupes for free: the marker already on the forge is acknowledged, never re-posted."
7858
- ],
7859
- status: "shipped"
7860
- },
7861
8641
  {
7862
8642
  name: "milestone create",
7863
8643
  description: "Create a GitHub Milestone from a validated body",
@@ -8187,7 +8967,7 @@ var COMMANDS = [
8187
8967
  { flag: "--task", description: "This dispatch's task Issue number — mutually exclusive with `--pr`" },
8188
8968
  {
8189
8969
  flag: "--pr",
8190
- description: "Flush the outbox to this PR's Issue after the dispatch — mutually exclusive with `--task`"
8970
+ description: "This dispatch's pull request number, for attribution — mutually exclusive with `--task`"
8191
8971
  },
8192
8972
  { flag: "--round", description: "Round number, for a dispatch inside a review loop" },
8193
8973
  {
@@ -8199,7 +8979,7 @@ var COMMANDS = [
8199
8979
  details: [
8200
8980
  "Sets `VINAYA_RUN_ID`/`VINAYA_ROLE`/`VINAYA_TASK`/`VINAYA_ROUND` on the child only — never on this process's own environment — and refuses by name, before any spawn attempt, when the named vendor binary is absent from `PATH` or present but not executable.",
8201
8981
  "Records `dispatched` (with the prompt's sha256), `outcome_received` (duration, the vendor's own usage when its stdout prints a recognizable shape), or `dispatch_failed` (`timeout`, `crash`, or `refused`) through the Vinaya Log's one `dispatch` family writer, `dispatchRole`. A wall-time ceiling (`dispatch.timeoutMs` in config, default one hour) sends `SIGTERM` then, after a grace window, `SIGKILL`.",
8202
- "When `--task` or `--pr` is given, flushes that outbox via `vinaya log flush` immediately after the child settles — `--task` and `--pr` are mutually exclusive here, matching `log flush`'s own single-target rule. Without either, the dispatch still runs and logs; nothing is flushed, and the lines ride to the next flush.",
8982
+ "Runs no flush of its own after the dispatch returns: every log line `dispatchRole` emits reaches its configured `logs` destination live, as it is emitted, so there is nothing left to ship in a trailing step. `--task`/`--pr` are attribution only, and remain mutually exclusive.",
8203
8983
  "A successful dispatch's `DispatchHandle` carries `resumeId` — the vendor's own session/thread identifier (claude/gemini: `session_id`; codex: `thread_id`), parsed from its stdout, `null` on any failure. Passing that value as `--resume <id>` on a later call swaps in that vendor's own resume invocation (`claude -p -r <id> ...`; `codex exec resume <id> ...`; `gemini ... --resume <id> ...`) in place of its first-dispatch args."
8204
8984
  ],
8205
8985
  status: "shipped"
@@ -8219,7 +8999,8 @@ var COMMANDS = [
8219
8999
  "Dispatches the developer through `dispatchRole` with the brief read from the Issue, waits for the PR it opens, then runs `assessRound` (`@attalabs/aeg-core`) — the entire policy — against observations this command reads from the forge: the head via `git ls-remote` only (never `gh pr view headRefOid`, which can lag a push), CI conclusion via the check-runs API (never run locally), and ruling comments matching `<!-- aeg:principal:ruling:<pr>-<k> -->`.",
8220
9000
  "Nothing is posted to the PR before the policy decides `publish`: each round's reviewer and security verdicts are dispatched fresh (never a resumed session) through `dispatchRole`, rendered through `review post`'s own render functions, and written to a local file under the outbox — never `gh pr comment`/`gh pr review`. Posting the held verdicts is a separate, later task.",
8221
9001
  "The developer's session is resumed every round via `dispatchRole`'s `resumeId` — never a fresh session — for every vendor; a round whose resume fails for a vendor that resumed successfully the round before stops the loop rather than silently falling back to a fresh developer session.",
8222
- "Every dispatch and round transition is a log line through the Vinaya Log, flushed to the forge at each round boundary."
9002
+ "Every dispatch and round transition is a log line through the Vinaya Log, delivered live to its configured `logs` destination as it is emitted — never a tracker comment.",
9003
+ "issue-711 O4: this command — `--task <n>`, `--resume <pr>`, `--cancel <pr>` alike — stays `task run`'s own one-shot debug/direct entry; the watching driver that survives a pause and continues on its own is `task run`'s (see that command's own entry)."
8223
9004
  ],
8224
9005
  status: "shipped"
8225
9006
  }
@@ -8239,7 +9020,7 @@ var StateSourceConfigSchema = z5.discriminatedUnion("kind", [
8239
9020
  z5.object({ kind: z5.literal("file"), root: z5.string().optional() })
8240
9021
  ]);
8241
9022
  // src/checks/edge-resolve.ts
8242
- import { execFileSync as execFileSync4 } from "node:child_process";
9023
+ import { execFileSync as execFileSync3 } from "node:child_process";
8243
9024
  var DIRECT_ISSUE_REF = /#(\d+)/;
8244
9025
  var issueCache = new Map;
8245
9026
  function fetchIssueState(num, repo) {
@@ -8248,7 +9029,7 @@ function fetchIssueState(num, repo) {
8248
9029
  return issueCache.get(key) ?? null;
8249
9030
  let out = null;
8250
9031
  try {
8251
- const raw = execFileSync4("gh", [
9032
+ const raw = execFileSync3("gh", [
8252
9033
  "issue",
8253
9034
  "view",
8254
9035
  String(num),
@@ -8357,9 +9138,12 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
8357
9138
  }
8358
9139
 
8359
9140
  // src/lib/brief-assembly.ts
9141
+ var PACKAGE_ROOT = packageRoot(import.meta.url);
9142
+ var PACKAGED_TEMPLATE_PATH = join7(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
9143
+ var TEMPLATE_PATH = existsSync6(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join7(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
8360
9144
  function git(args) {
8361
9145
  try {
8362
- return execFileSync5("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
9146
+ return execFileSync4("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
8363
9147
  } catch {
8364
9148
  return "";
8365
9149
  }
@@ -8408,7 +9192,7 @@ function parseChangedLineRanges(diffOutput) {
8408
9192
  function fileDiffAgainst(ref, path) {
8409
9193
  let out;
8410
9194
  try {
8411
- out = execFileSync6("git", ["diff", `${ref}...HEAD`, "--", path], {
9195
+ out = execFileSync5("git", ["diff", `${ref}...HEAD`, "--", path], {
8412
9196
  encoding: "utf8",
8413
9197
  stdio: ["ignore", "pipe", "pipe"]
8414
9198
  }).trim();
@@ -8419,7 +9203,7 @@ function fileDiffAgainst(ref, path) {
8419
9203
  }
8420
9204
  function revParse(ref) {
8421
9205
  try {
8422
- return execFileSync6("git", ["rev-parse", "--verify", ref], {
9206
+ return execFileSync5("git", ["rev-parse", "--verify", ref], {
8423
9207
  encoding: "utf8",
8424
9208
  stdio: ["ignore", "pipe", "pipe"]
8425
9209
  }).trim();
@@ -8429,7 +9213,7 @@ function revParse(ref) {
8429
9213
  }
8430
9214
  function repoRoot() {
8431
9215
  try {
8432
- return execFileSync6("git", ["rev-parse", "--show-toplevel"], {
9216
+ return execFileSync5("git", ["rev-parse", "--show-toplevel"], {
8433
9217
  encoding: "utf8",
8434
9218
  stdio: ["ignore", "pipe", "pipe"]
8435
9219
  }).trim();
@@ -8440,7 +9224,7 @@ function repoRoot() {
8440
9224
  function changedFiles(base) {
8441
9225
  let out;
8442
9226
  try {
8443
- out = execFileSync6("git", ["diff", "--name-only", `${base}...HEAD`], {
9227
+ out = execFileSync5("git", ["diff", "--name-only", `${base}...HEAD`], {
8444
9228
  encoding: "utf8",
8445
9229
  stdio: ["ignore", "pipe", "pipe"]
8446
9230
  }).trim();
@@ -8465,7 +9249,7 @@ function resolveDiff(base = process.env.BASE_SHA || "origin/main") {
8465
9249
  const relPaths = changedFiles(ref);
8466
9250
  if (relPaths === null)
8467
9251
  continue;
8468
- return { base: ref, root, files: relPaths.map((p) => join5(root, p)) };
9252
+ return { base: ref, root, files: relPaths.map((p) => join8(root, p)) };
8469
9253
  }
8470
9254
  return null;
8471
9255
  }
@@ -8499,6 +9283,7 @@ function findingsInThisDiff(findings) {
8499
9283
  // src/lib/dispatch.ts
8500
9284
  var MAX_TEE_BYTES = 8 * 1024 * 1024;
8501
9285
  var CLAUDE_MODEL_ALIASES = new Set(["fable", "opus", "sonnet", "haiku"]);
9286
+ 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)";
8502
9287
 
8503
9288
  // src/commands/tokens.ts
8504
9289
  var USAGE = [
@@ -8521,11 +9306,13 @@ var USAGE = [
8521
9306
  `);
8522
9307
 
8523
9308
  // src/lib/pr-report-engine.ts
9309
+ var execFileAsync6 = promisify6(execFile6);
8524
9310
  var BODY_READING_CHECK_NAMES = new Set(coreCheckRegistry().filter((spec) => {
8525
9311
  const decl = spec.env?.PR_BODY;
8526
9312
  return decl === true || typeof decl === "object" && decl !== null && "optional" in decl;
8527
9313
  }).map((spec) => spec.name));
8528
9314
  var FAILING_STATUSES = new Set(["fail", "error", "timeout"]);
9315
+ var NUL = String.fromCharCode(0);
8529
9316
  function extractAgentCommandLines(prBody) {
8530
9317
  const located = locateTestPlanSection(prBody);
8531
9318
  if (!located.found)
@@ -8543,6 +9330,7 @@ function agentCommandText(line) {
8543
9330
  const idx = line.indexOf("→");
8544
9331
  return (idx === -1 ? line : line.slice(0, idx)).trim();
8545
9332
  }
9333
+ var AGENT_COMMAND_MAX_BUFFER_BYTES = 32 * 1024 * 1024;
8546
9334
  var TOKEN_ROW_REMEDY = [
8547
9335
  "Nothing here established that this host cannot meter — only that this session resolved no",
8548
9336
  "transcript of its own. Report real figures by naming your own transcript:",
@@ -8562,20 +9350,20 @@ var TOKEN_ROW_REMEDY = [
8562
9350
  var USAGE2 = "Usage: vinaya pr report [--write <body-file> | --push <pr> [--body-file <path>]] [--phase <phase>] " + "[--role <role>] [--model <id>] [--transcript <path>]";
8563
9351
 
8564
9352
  // src/lib/patch-id.ts
8565
- import { execFileSync as execFileSync7 } from "node:child_process";
9353
+ import { execFileSync as execFileSync6 } from "node:child_process";
8566
9354
  function patchIdAt(base, sha) {
8567
9355
  try {
8568
- execFileSync7("git", ["fetch", "--quiet", "origin", sha], { stdio: ["ignore", "ignore", "ignore"] });
9356
+ execFileSync6("git", ["fetch", "--quiet", "origin", sha], { stdio: ["ignore", "ignore", "ignore"] });
8569
9357
  } catch {}
8570
9358
  try {
8571
- const diff = execFileSync7("git", ["diff", `origin/${base}...${sha}`], {
9359
+ const diff = execFileSync6("git", ["diff", `origin/${base}...${sha}`], {
8572
9360
  encoding: "utf8",
8573
9361
  maxBuffer: 64 * 1024 * 1024,
8574
9362
  stdio: ["ignore", "pipe", "pipe"]
8575
9363
  });
8576
9364
  if (diff === "")
8577
9365
  return null;
8578
- const out = execFileSync7("git", ["patch-id", "--stable"], {
9366
+ const out = execFileSync6("git", ["patch-id", "--stable"], {
8579
9367
  input: diff,
8580
9368
  encoding: "utf8",
8581
9369
  stdio: ["pipe", "pipe", "pipe"]
@@ -8687,7 +9475,7 @@ function compareEvidenceBlock(resolved, resolvedHead, actualNumstat, expectedGro
8687
9475
  var DEVELOPER_ROUND_MARKER = /<!--\s*aeg:developer:round-\d+\s*-->/i;
8688
9476
  function fetchHasPriorDeveloperRound(prNumber) {
8689
9477
  try {
8690
- const out = execFileSync8("gh", ["pr", "view", String(prNumber), "--json", "comments"], {
9478
+ const out = execFileSync7("gh", ["pr", "view", String(prNumber), "--json", "comments"], {
8691
9479
  encoding: "utf8",
8692
9480
  stdio: ["ignore", "pipe", "pipe"]
8693
9481
  });
@@ -8701,7 +9489,7 @@ function fetchHasPriorDeveloperRound(prNumber) {
8701
9489
  var CHECK_NAME = "evidence-fresh";
8702
9490
  function git2(args) {
8703
9491
  try {
8704
- return execFileSync8("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9492
+ return execFileSync7("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
8705
9493
  } catch {
8706
9494
  return "";
8707
9495
  }
@@ -8720,7 +9508,7 @@ class GitCommandError2 extends Error {
8720
9508
  }
8721
9509
  function gitStrict(args) {
8722
9510
  try {
8723
- return execFileSync8("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9511
+ return execFileSync7("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
8724
9512
  } catch (err) {
8725
9513
  const stderr = err.stderr;
8726
9514
  throw new GitCommandError2(args, String(stderr ?? err.message).trim() || "non-zero exit");
@@ -8738,7 +9526,7 @@ function resolveMergeBase(head) {
8738
9526
  }
8739
9527
  function fetchPrRefs(prNumber) {
8740
9528
  try {
8741
- const out = execFileSync8("gh", ["pr", "view", String(prNumber), "--json", "headRefOid,baseRefName"], {
9529
+ const out = execFileSync7("gh", ["pr", "view", String(prNumber), "--json", "headRefOid,baseRefName"], {
8742
9530
  encoding: "utf8",
8743
9531
  stdio: ["ignore", "pipe", "pipe"]
8744
9532
  });