@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,10 +1,8 @@
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-exec-bits.ts
6
- import { execFileSync as execFileSync7 } from "node:child_process";
7
- import { readFileSync as readFileSync4 } from "node:fs";
4
+ import { execFileSync as execFileSync6 } from "node:child_process";
5
+ import { readFileSync as readFileSync6 } from "node:fs";
8
6
 
9
7
  // src/checks/contract.ts
10
8
  var CHECK_SCHEMA_VERSION = 1;
@@ -14,8 +12,8 @@ function emitCheckError(error) {
14
12
  }
15
13
 
16
14
  // src/lib/diff-evidence.ts
17
- import { execFileSync as execFileSync6 } from "node:child_process";
18
- import { join as join5, relative, resolve as resolve2 } from "node:path";
15
+ import { execFileSync as execFileSync5 } from "node:child_process";
16
+ import { join as join8, relative, resolve as resolve2 } from "node:path";
19
17
  // ../../packages/aeg-core/src/gate-audience.ts
20
18
  var GATE_AUDIENCE = {
21
19
  "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
@@ -1049,7 +1047,7 @@ function withDefaults(oldDefaults, newDefaults) {
1049
1047
  var endpoint = withDefaults(null, DEFAULTS);
1050
1048
 
1051
1049
  // ../../node_modules/fast-content-type-parse/index.js
1052
- var NullObject = function NullObject2() {};
1050
+ var NullObject = function NullObject() {};
1053
1051
  NullObject.prototype = Object.create(null);
1054
1052
  var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu;
1055
1053
  var quotedPairRE = /\\([\v\u0020-\u00ff])/gu;
@@ -1143,8 +1141,8 @@ function isPlainObject2(value) {
1143
1141
  return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
1144
1142
  }
1145
1143
  async function fetchWrapper(requestOptions) {
1146
- const fetch = requestOptions.request?.fetch || globalThis.fetch;
1147
- if (!fetch) {
1144
+ const fetch2 = requestOptions.request?.fetch || globalThis.fetch;
1145
+ if (!fetch2) {
1148
1146
  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");
1149
1147
  }
1150
1148
  const log = requestOptions.request?.log || console;
@@ -1156,7 +1154,7 @@ async function fetchWrapper(requestOptions) {
1156
1154
  ]));
1157
1155
  let fetchResponse;
1158
1156
  try {
1159
- fetchResponse = await fetch(requestOptions.url, {
1157
+ fetchResponse = await fetch2(requestOptions.url, {
1160
1158
  method: requestOptions.method,
1161
1159
  body,
1162
1160
  redirect: requestOptions.request?.redirect,
@@ -1793,27 +1791,27 @@ function splitTableRow(row) {
1793
1791
  return parts.map((p) => p.split(PLACEHOLDER).join("|"));
1794
1792
  }
1795
1793
  // ../../packages/aeg-core/src/blast-radius-domains.ts
1796
- function resolveWorkspaceEntry(entry2, listDirs) {
1797
- if (entry2.endsWith("/*")) {
1798
- const baseDir = entry2.slice(0, -2);
1794
+ function resolveWorkspaceEntry(entry, listDirs) {
1795
+ if (entry.endsWith("/*")) {
1796
+ const baseDir = entry.slice(0, -2);
1799
1797
  return listDirs(baseDir).map((name) => `${baseDir}/${name}`);
1800
1798
  }
1801
- if (entry2.includes("*"))
1799
+ if (entry.includes("*"))
1802
1800
  return [];
1803
- return [entry2];
1801
+ return [entry];
1804
1802
  }
1805
1803
  // ../../packages/aeg-core/src/consumer-enumeration.ts
1806
1804
  function deriveWorkspaceMemberDirs(workspaces, listDirs) {
1807
- const positive = workspaces.filter((entry2) => !entry2.startsWith("!"));
1808
- const negative = workspaces.filter((entry2) => entry2.startsWith("!")).map((entry2) => entry2.slice(1));
1805
+ const positive = workspaces.filter((entry) => !entry.startsWith("!"));
1806
+ const negative = workspaces.filter((entry) => entry.startsWith("!")).map((entry) => entry.slice(1));
1809
1807
  const excluded = new Set;
1810
- for (const entry2 of negative) {
1811
- for (const member of resolveWorkspaceEntry(entry2, listDirs))
1808
+ for (const entry of negative) {
1809
+ for (const member of resolveWorkspaceEntry(entry, listDirs))
1812
1810
  excluded.add(member);
1813
1811
  }
1814
1812
  const members = new Set;
1815
- for (const entry2 of positive) {
1816
- for (const member of resolveWorkspaceEntry(entry2, listDirs)) {
1813
+ for (const entry of positive) {
1814
+ for (const member of resolveWorkspaceEntry(entry, listDirs)) {
1817
1815
  if (!excluded.has(member))
1818
1816
  members.add(member);
1819
1817
  }
@@ -2059,12 +2057,24 @@ function extractBaseSha(comment) {
2059
2057
  const m = firstThirteenLines(comment).match(BASE_SHA_PATTERN);
2060
2058
  return m ? m[1].toLowerCase() : null;
2061
2059
  }
2062
- var FINDING_SEVERITY_LINE = /^\d+\.\s+\[([A-Z][A-Z]*)\]\s+(.+?)\s+—/gm;
2060
+ var FINDING_DESCRIPTION_STATE = /^F(\d+)(?:\s+\S+)?(?:\s+(open|fix-claimed|reproduced|resolved))?:/;
2061
+ function parseFindingState(description) {
2062
+ const m = FINDING_DESCRIPTION_STATE.exec(description.trim());
2063
+ if (!m)
2064
+ return { id: null, state: null };
2065
+ return { id: `F${m[1]}`, state: m[2] ?? null };
2066
+ }
2067
+ var FINDING_SEVERITY_LINE = /^\d+\.\s+\[([A-Z][A-Z]*)\]\s+(.+?)\s+—(?:\s+(.*))?$/gm;
2063
2068
  function extractFindingSeverities(comment) {
2064
- return [...comment.matchAll(FINDING_SEVERITY_LINE)].map((m) => ({
2065
- severity: m[1],
2066
- location: m[2]
2067
- }));
2069
+ return [...comment.matchAll(FINDING_SEVERITY_LINE)].map((m) => {
2070
+ const { id, state } = parseFindingState(m[3] ?? "");
2071
+ return {
2072
+ severity: m[1],
2073
+ location: m[2],
2074
+ id,
2075
+ state
2076
+ };
2077
+ });
2068
2078
  }
2069
2079
  function extractVerdict(comments, valuePattern, missingLabel) {
2070
2080
  const candidates = comments.filter((c) => valuePattern.test(c));
@@ -2137,15 +2147,15 @@ function summarizeTranscript(jsonl) {
2137
2147
  const line = rawLine.trim();
2138
2148
  if (!line)
2139
2149
  continue;
2140
- let entry2;
2150
+ let entry;
2141
2151
  try {
2142
- entry2 = JSON.parse(line);
2152
+ entry = JSON.parse(line);
2143
2153
  } catch {
2144
2154
  continue;
2145
2155
  }
2146
- if (!entry2 || typeof entry2 !== "object")
2156
+ if (!entry || typeof entry !== "object")
2147
2157
  continue;
2148
- const obj = entry2;
2158
+ const obj = entry;
2149
2159
  if (obj.type !== "assistant")
2150
2160
  continue;
2151
2161
  const message = obj.message;
@@ -2478,6 +2488,12 @@ function evaluateReviewFindings(findings, scale, threshold) {
2478
2488
  });
2479
2489
  return { outcome: blockingFindings.length > 0 ? "blocked" : "clean", blockingFindings };
2480
2490
  }
2491
+ function isConsequentialFinding(finding) {
2492
+ return finding.state !== "resolved";
2493
+ }
2494
+ function consequentialFindings(findings) {
2495
+ return findings.filter((f) => isConsequentialFinding(f));
2496
+ }
2481
2497
  function evaluateCodeReview(findings, policy) {
2482
2498
  return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold);
2483
2499
  }
@@ -2993,7 +3009,7 @@ function isStep0Block(content) {
2993
3009
  }
2994
3010
  function checkCommandsCarryOutput(prBody) {
2995
3011
  const errors = [];
2996
- for (const [label2, num] of [
3012
+ for (const [label, num] of [
2997
3013
  ["5", 5],
2998
3014
  ["6", 6]
2999
3015
  ]) {
@@ -3007,7 +3023,7 @@ function checkCommandsCarryOutput(prBody) {
3007
3023
  continue;
3008
3024
  const next = blocks[i + 1];
3009
3025
  if (!next || isCommandBlock(next.content)) {
3010
- 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.`);
3026
+ 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.`);
3011
3027
  }
3012
3028
  }
3013
3029
  }
@@ -3444,8 +3460,8 @@ function stripPartBackticks(text) {
3444
3460
  function partWordCount(text) {
3445
3461
  return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
3446
3462
  }
3447
- function looksLikeFilePath(entry2) {
3448
- const stripped = entry2.replace(/\/\*\*?$/, "");
3463
+ function looksLikeFilePath(entry) {
3464
+ const stripped = entry.replace(/\/\*\*?$/, "");
3449
3465
  const lastSegment = stripped.split("/").pop() ?? stripped;
3450
3466
  const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
3451
3467
  return extMatch !== null && extMatch.index > 0;
@@ -3931,14 +3947,14 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
3931
3947
  const referenced = extractClosesReferences(prBody);
3932
3948
  if (taskIssueRefs) {
3933
3949
  for (const n of referenced) {
3934
- const ref2 = taskIssueRefs.get(n);
3935
- if (!ref2)
3950
+ const ref = taskIssueRefs.get(n);
3951
+ if (!ref)
3936
3952
  continue;
3937
- const expectedBranch = `task/${ref2.trancheSlug}/${ref2.taskId}`;
3953
+ const expectedBranch = `task/${ref.trancheSlug}/${ref.taskId}`;
3938
3954
  if (branch !== expectedBranch) {
3939
3955
  return {
3940
3956
  ok: false,
3941
- 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.`
3957
+ 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.`
3942
3958
  };
3943
3959
  }
3944
3960
  }
@@ -3947,15 +3963,15 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
3947
3963
  if (!ref)
3948
3964
  return { ok: true };
3949
3965
  if (ref.kind === "issue") {
3950
- const expectedIssue2 = ref.issueNumber;
3951
- if (!referenced.has(expectedIssue2)) {
3966
+ const expectedIssue = ref.issueNumber;
3967
+ if (!referenced.has(expectedIssue)) {
3952
3968
  return {
3953
3969
  ok: false,
3954
- expectedIssue: expectedIssue2,
3955
- message: `closes-n: PR body does not contain \`Closes #${expectedIssue2}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
3970
+ expectedIssue,
3971
+ message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
3956
3972
  };
3957
3973
  }
3958
- return { ok: true, expectedIssue: expectedIssue2 };
3974
+ return { ok: true, expectedIssue };
3959
3975
  }
3960
3976
  const trancheSlug = ref.tranche;
3961
3977
  const taskId = ref.taskId;
@@ -4001,8 +4017,8 @@ function extractIssue(body) {
4001
4017
  const anchorNums = closesRefs(anchored);
4002
4018
  if (anchorNums.length === 0)
4003
4019
  return { issue: null, extraIssues: bodyNums, outsideHeader: false };
4004
- const issue2 = anchorNums[0];
4005
- return { issue: issue2, extraIssues: bodyNums.filter((n) => n !== issue2), outsideHeader: false };
4020
+ const issue = anchorNums[0];
4021
+ return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: false };
4006
4022
  }
4007
4023
  const headerNums = closesRefs(headerRegion(stripped));
4008
4024
  if (bodyNums.length === 0)
@@ -4071,15 +4087,15 @@ function compareManifest(echoed, current, patchIdOf) {
4071
4087
  const bothFullShas = echoedShaLen >= 40 && currentShaLen >= 40;
4072
4088
  const base = patchHead || exactHead && bothFullShas ? true : isBoundToBase(echoed, current.baseSha);
4073
4089
  const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
4074
- const objectivesVersion2 = isBoundToObjectives(echoed, current.objectivesVersion);
4090
+ const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
4075
4091
  const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
4076
4092
  const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
4077
4093
  return {
4078
- bound: head && base && briefHashBound && objectivesVersion2 && rulingOrdinal && policyDigestBound,
4094
+ bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
4079
4095
  head,
4080
4096
  base,
4081
4097
  briefHash: briefHashBound,
4082
- objectivesVersion: objectivesVersion2,
4098
+ objectivesVersion,
4083
4099
  rulingOrdinal,
4084
4100
  policyDigest: policyDigestBound
4085
4101
  };
@@ -4110,8 +4126,8 @@ function checkReviewGate(input) {
4110
4126
  let codeReviewPolicyEvaluation;
4111
4127
  let securityPolicyEvaluation;
4112
4128
  try {
4113
- codeReviewPolicyEvaluation = evaluateCodeReview(codeReview.findingSeverities, policy);
4114
- securityPolicyEvaluation = evaluateSecurityReview(security.findingSeverities, policy);
4129
+ codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy);
4130
+ securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy);
4115
4131
  } catch (err) {
4116
4132
  return {
4117
4133
  verdict: "fail",
@@ -5192,11 +5208,27 @@ var ObservedSchema = z.object({
5192
5208
  var TaskStatusInputSchema = z.object({
5193
5209
  task: TaskToolRefSchema.optional()
5194
5210
  }).merge(PageRequestSchema).strict();
5211
+ var TaskConfidenceSchema = z.object({
5212
+ round: z.number().int().positive(),
5213
+ percent: z.number().int().min(0).max(100).nullable(),
5214
+ source: z.enum(["stated", "published-summary"])
5215
+ }).strict();
5216
+ var TaskPhaseHistorySchema = z.object({
5217
+ typicalPhaseMinutes: z.number().nonnegative(),
5218
+ typicalPhaseSamples: z.number().int().positive()
5219
+ }).strict();
5195
5220
  var TaskStatusItemSchema = z.object({
5196
5221
  task: TaskToolRefSchema,
5197
5222
  issue: z.number().int().positive(),
5198
5223
  pr: z.number().int().positive().nullable(),
5199
- state: z.string()
5224
+ state: z.string(),
5225
+ round: z.number().int().positive().nullable().optional(),
5226
+ phase: z.string().min(1).nullable().optional(),
5227
+ minutesInPhase: z.number().nonnegative().nullable().optional(),
5228
+ phaseIsCurrent: z.boolean().nullable().optional(),
5229
+ lastConfidence: TaskConfidenceSchema.nullable().optional(),
5230
+ lastConfidenceUnread: z.boolean().optional(),
5231
+ phaseHistory: TaskPhaseHistorySchema.nullable().optional()
5200
5232
  }).merge(ObservedSchema);
5201
5233
  var TaskStatusResultSchema = z.object({
5202
5234
  items: z.array(TaskStatusItemSchema),
@@ -5208,7 +5240,7 @@ var EscalationInputsSchema = z.object({
5208
5240
  round: z.number().int().nonnegative(),
5209
5241
  head: z.string(),
5210
5242
  branch: z.string(),
5211
- prNumber: z.number().int().positive()
5243
+ prNumber: z.number().int().positive().nullable()
5212
5244
  });
5213
5245
  var EscalationEvidenceSchema = z.object({
5214
5246
  round: z.number().int().nonnegative(),
@@ -5244,13 +5276,45 @@ var TaskEscalationReadResultSchema = z.object({
5244
5276
  items: z.array(TaskEscalationPacketSchema),
5245
5277
  nextCursor: z.string().nullable()
5246
5278
  }).merge(ObservedSchema);
5247
- var TaskStartInputSchema = z.object({
5248
- tranche: z.string().min(1),
5249
- id: z.string().min(1)
5279
+ var TaskPrCheckSchema = z.object({
5280
+ name: z.string(),
5281
+ required: z.boolean(),
5282
+ status: z.string(),
5283
+ conclusion: z.string().nullable(),
5284
+ detailsUrl: z.string().nullable(),
5285
+ failureSummary: z.string().nullable()
5286
+ });
5287
+ var TaskPrVerdictSchema = z.object({
5288
+ role: z.enum(["code-review", "security"]),
5289
+ value: z.string(),
5290
+ judgedHead: z.string().nullable(),
5291
+ objectivesVersion: z.string().nullable()
5292
+ });
5293
+ var TaskPrPauseSchema = z.object({
5294
+ reason: z.string(),
5295
+ body: z.string()
5296
+ });
5297
+ var TaskPrReviewRecordSchema = z.object({
5298
+ verdicts: z.array(TaskPrVerdictSchema),
5299
+ roundMarkers: z.array(z.number().int().nonnegative()),
5300
+ summaryTable: z.string().nullable(),
5301
+ pause: TaskPrPauseSchema.nullable()
5302
+ });
5303
+ var TaskPrReadInputSchema = z.object({
5304
+ task: TaskToolRefSchema,
5305
+ pr: z.number().int().positive().optional()
5250
5306
  }).strict();
5307
+ var TaskPrReadResultSchema = z.object({
5308
+ task: TaskToolRefSchema,
5309
+ issue: z.number().int().positive(),
5310
+ pr: z.number().int().positive(),
5311
+ head: z.string().nullable(),
5312
+ checks: z.array(TaskPrCheckSchema),
5313
+ review: TaskPrReviewRecordSchema
5314
+ }).merge(ObservedSchema);
5251
5315
  var TaskStartResultSchema = z.object({
5252
5316
  requestId: z.string().min(1),
5253
- run: z.object({ tranche: z.string().min(1), id: z.string().min(1) }),
5317
+ run: TaskToolRefSchema,
5254
5318
  started: z.boolean(),
5255
5319
  startedAt: z.string(),
5256
5320
  mode: z.literal("attended")
@@ -5264,7 +5328,7 @@ var TaskCancelInputSchema = z.object({
5264
5328
  }).strict();
5265
5329
  var TaskResumeResultSchema = z.object({
5266
5330
  task: z.number().int().positive(),
5267
- pr: z.number().int().positive(),
5331
+ pr: z.number().int().positive().nullable(),
5268
5332
  escalationId: z.string().min(1),
5269
5333
  outcome: z.enum(["started", "already_resumed"]),
5270
5334
  authenticatedBy: z.string().min(1),
@@ -5273,7 +5337,7 @@ var TaskResumeResultSchema = z.object({
5273
5337
  var TaskCancelOutcomeSchema = z.enum(["confirmed", "pending", "uncertain"]);
5274
5338
  var TaskCancelResultSchema = z.object({
5275
5339
  task: z.number().int().positive(),
5276
- pr: z.number().int().positive(),
5340
+ pr: z.number().int().positive().nullable(),
5277
5341
  escalationId: z.string().min(1),
5278
5342
  outcome: TaskCancelOutcomeSchema,
5279
5343
  authenticatedBy: z.string().min(1),
@@ -5284,6 +5348,7 @@ var TASK_TOOL_NAMES = [
5284
5348
  "task_start",
5285
5349
  "task_status",
5286
5350
  "task_escalation_read",
5351
+ "task_pr_read",
5287
5352
  "task_resume",
5288
5353
  "task_cancel"
5289
5354
  ];
@@ -5511,6 +5576,10 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
5511
5576
  }
5512
5577
  return findings;
5513
5578
  }
5579
+ // ../../packages/aeg-core/src/dev-review-loop/types.ts
5580
+ var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5581
+ // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
5582
+ var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
5514
5583
  // ../../packages/aeg-core/src/log/envelope.ts
5515
5584
  import { createHash as createHash5 } from "node:crypto";
5516
5585
 
@@ -6049,6 +6118,7 @@ function redact(value, home) {
6049
6118
  return value;
6050
6119
  }
6051
6120
  // ../../packages/aeg-core/src/log/store.ts
6121
+ var KNOWN_SCHEMA_VERSIONS = [1, 2];
6052
6122
  function metaOf(obj) {
6053
6123
  if (obj === null || typeof obj !== "object")
6054
6124
  return null;
@@ -6071,11 +6141,61 @@ function recordIdentity(obj) {
6071
6141
  }
6072
6142
  return null;
6073
6143
  }
6074
-
6075
- // ../../packages/aeg-core/src/log/artifact.ts
6076
- var TASK_LOG_ARTIFACT_MAX_BYTES = 8 * 1024 * 1024;
6077
- // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
6078
- var STOPPED_CONDITIONS = new Set(["confidence", "reappearance", "no_progress", "max_rounds"]);
6144
+ function schemaVersionOf(obj) {
6145
+ const meta = metaOf(obj);
6146
+ const schema = meta?.schema;
6147
+ return typeof schema === "number" ? schema : null;
6148
+ }
6149
+ function isKnownSchema(version) {
6150
+ return version !== null && KNOWN_SCHEMA_VERSIONS.includes(version);
6151
+ }
6152
+ function classifyStoredLine(raw, home) {
6153
+ let obj;
6154
+ try {
6155
+ obj = JSON.parse(raw);
6156
+ } catch {
6157
+ return { status: "invalid", identity: null, raw, reason: "not valid JSON" };
6158
+ }
6159
+ const version = schemaVersionOf(obj);
6160
+ if (version === null) {
6161
+ return { status: "invalid", identity: recordIdentity(obj), raw, reason: "no readable meta.schema" };
6162
+ }
6163
+ if (!isKnownSchema(version)) {
6164
+ return {
6165
+ status: "unknown_version",
6166
+ identity: recordIdentity(obj),
6167
+ schema: version,
6168
+ raw,
6169
+ reason: `schema version ${version} is not one this build validates (${KNOWN_SCHEMA_VERSIONS.join(", ")}) — kept for diagnosis`
6170
+ };
6171
+ }
6172
+ const result = LogEventSchema.safeParse(obj);
6173
+ if (!result.success) {
6174
+ return {
6175
+ status: "invalid",
6176
+ identity: recordIdentity(obj),
6177
+ raw,
6178
+ reason: result.error.issues[0]?.message ?? "schema violation"
6179
+ };
6180
+ }
6181
+ const event = result.data;
6182
+ const identity = recordIdentity(event);
6183
+ if (identity === null) {
6184
+ return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
6185
+ }
6186
+ const redacted = redact(event, home);
6187
+ const provenance = version === 2 ? event.meta.provenance ?? null : null;
6188
+ return {
6189
+ status: "ok",
6190
+ identity,
6191
+ runId: event.meta.run_id,
6192
+ seq: event.meta.seq,
6193
+ schema: version,
6194
+ provenance,
6195
+ event,
6196
+ postLine: JSON.stringify(redacted)
6197
+ };
6198
+ }
6079
6199
  // ../../packages/aeg-core/src/control-store/records.ts
6080
6200
  import { z as z3 } from "zod";
6081
6201
  var isoTimestamp = z3.string().min(1);
@@ -6206,7 +6326,8 @@ var ResolutionRecordSchema = z3.object({
6206
6326
  consumedAt: isoTimestamp
6207
6327
  }).strict();
6208
6328
  // src/lib/config.ts
6209
- import { execFileSync as execFileSync2 } from "node:child_process";
6329
+ import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
6330
+ import { promisify as promisify4 } from "node:util";
6210
6331
  import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
6211
6332
  import { homedir } from "node:os";
6212
6333
  import { dirname, isAbsolute, join, resolve } from "node:path";
@@ -6233,10 +6354,10 @@ var CheckEntrySchema = z4.object({
6233
6354
  ownWorkflow: z4.boolean().optional(),
6234
6355
  principalOwed: z4.literal(true).optional(),
6235
6356
  validates: z4.enum(["body", "issue"]).optional()
6236
- }).superRefine((entry2, ctx) => {
6237
- if (!entry2.env)
6357
+ }).superRefine((entry, ctx) => {
6358
+ if (!entry.env)
6238
6359
  return;
6239
- for (const [key, value] of Object.entries(entry2.env)) {
6360
+ for (const [key, value] of Object.entries(entry.env)) {
6240
6361
  if (typeof value !== "object" || value === null || !("anyOf" in value))
6241
6362
  continue;
6242
6363
  const members = value.anyOf;
@@ -6393,18 +6514,19 @@ var VinayaConfigSchema = z4.object({
6393
6514
  });
6394
6515
  }
6395
6516
  }).optional(),
6396
- logPublish: z4.object({
6397
- issue: z4.number().int().positive().optional(),
6398
- pr: z4.number().int().positive().optional(),
6399
- webhookUrl: z4.string().url().optional(),
6400
- headers: z4.record(z4.string()).optional(),
6401
- maxChunksPerFlush: z4.number().int().positive().optional()
6402
- }).refine((v) => [v.issue, v.pr, v.webhookUrl].filter((x) => x !== undefined).length <= 1, {
6403
- message: "logPublish: set at most one of issue/pr/webhookUrl"
6404
- }).refine((v) => v.headers === undefined || v.webhookUrl !== undefined, {
6405
- message: "logPublish: headers requires webhookUrl"
6406
- }).optional(),
6407
- runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional()
6517
+ logPublish: z4.unknown().refine((v) => v === undefined, {
6518
+ message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
6519
+ }),
6520
+ runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
6521
+ logs: z4.object({
6522
+ folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
6523
+ url: z4.string().url().optional(),
6524
+ headers: z4.record(z4.string()).optional()
6525
+ }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
6526
+ message: "logs: set at most one of folder/url"
6527
+ }).refine((v) => v.headers === undefined || v.url !== undefined, {
6528
+ message: "logs: headers requires url"
6529
+ }).optional()
6408
6530
  });
6409
6531
  var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
6410
6532
  var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
@@ -6449,32 +6571,39 @@ function globalTokensCollectIgnoredWarning(path) {
6449
6571
  function globalRuntimeDirIgnoredWarning(path) {
6450
6572
  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.`;
6451
6573
  }
6574
+ var emittedGlobalKeyWarnings = new Set;
6575
+ function warnGlobalKeyIgnoredOnce(message) {
6576
+ if (emittedGlobalKeyWarnings.has(message))
6577
+ return;
6578
+ emittedGlobalKeyWarnings.add(message);
6579
+ console.error(`⚠ ${message}`);
6580
+ }
6452
6581
  function stripGlobalOnlyKeys(config, path) {
6453
6582
  if (path !== GLOBAL_CONFIG_PATH)
6454
6583
  return config;
6455
6584
  let result = config;
6456
6585
  if (result.checks && Object.keys(result.checks).length > 0) {
6457
- console.error(`⚠ ${globalChecksIgnoredWarning(path)}`);
6586
+ warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
6458
6587
  result = { ...result, checks: undefined };
6459
6588
  }
6460
6589
  if (result.roles && Object.keys(result.roles).length > 0) {
6461
- console.error(`⚠ ${globalRolesIgnoredWarning(path)}`);
6590
+ warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
6462
6591
  result = { ...result, roles: undefined };
6463
6592
  }
6464
6593
  if (result.principals && result.principals.length > 0) {
6465
- console.error(`⚠ ${globalPrincipalsIgnoredWarning(path)}`);
6594
+ warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
6466
6595
  result = { ...result, principals: undefined };
6467
6596
  }
6468
6597
  if (result.releaseActor) {
6469
- console.error(`⚠ ${globalReleaseActorIgnoredWarning(path)}`);
6598
+ warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
6470
6599
  result = { ...result, releaseActor: undefined };
6471
6600
  }
6472
6601
  if (result.tokens) {
6473
- console.error(`⚠ ${globalTokensCollectIgnoredWarning(path)}`);
6602
+ warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
6474
6603
  result = { ...result, tokens: undefined };
6475
6604
  }
6476
6605
  if (result.runtimeDir) {
6477
- console.error(`⚠ ${globalRuntimeDirIgnoredWarning(path)}`);
6606
+ warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
6478
6607
  result = { ...result, runtimeDir: undefined };
6479
6608
  }
6480
6609
  return result;
@@ -6507,26 +6636,102 @@ function resolveReviewPolicy(config) {
6507
6636
  maxRounds
6508
6637
  };
6509
6638
  }
6510
- function trustAnchorRepo() {
6511
- const wellFormed = (slug) => /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
6512
- const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
6513
- if (fromRunner) {
6514
- const validated = wellFormed(fromRunner);
6515
- if (validated)
6516
- return validated;
6639
+ function resolveRuntimeDirSetting(config) {
6640
+ return config?.runtimeDir ?? null;
6641
+ }
6642
+ function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
6643
+ const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
6644
+ return anchored !== null && anchored === localRuntimeDir ? anchored : null;
6645
+ }
6646
+ function resolveLogsSetting(config) {
6647
+ const raw = config?.logs;
6648
+ if (!raw)
6649
+ return null;
6650
+ if (raw.url !== undefined)
6651
+ return { url: raw.url, headers: raw.headers };
6652
+ if (raw.folder !== undefined)
6653
+ return { folder: raw.folder };
6654
+ return null;
6655
+ }
6656
+ function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
6657
+ const anchored = resolveLogsSetting(trustAnchorConfig);
6658
+ if (!anchored)
6659
+ return null;
6660
+ if ("url" in local)
6661
+ return "url" in anchored && anchored.url === local.url ? anchored : null;
6662
+ return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
6663
+ }
6664
+ function resolveLogsHeaderValues(headers, env) {
6665
+ if (!headers)
6666
+ return;
6667
+ const resolved = {};
6668
+ for (const [key, value] of Object.entries(headers)) {
6669
+ resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
6517
6670
  }
6671
+ return resolved;
6672
+ }
6673
+ function trustAnchorRepo() {
6674
+ const fromRunner = trustAnchorRepoFromRunner();
6675
+ if (fromRunner)
6676
+ return fromRunner;
6518
6677
  try {
6519
6678
  const url = execFileSync2("git", ["remote", "get-url", "origin"], {
6520
6679
  encoding: "utf-8",
6521
6680
  stdio: ["ignore", "pipe", "pipe"]
6522
- }).trim();
6523
- const m = url.match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
6524
- return m?.[1] && m[2] ? wellFormed(`${m[1]}/${m[2]}`) : null;
6681
+ });
6682
+ return trustAnchorRepoFromRemoteUrl(url);
6525
6683
  } catch {
6526
6684
  return null;
6527
6685
  }
6528
6686
  }
6687
+ async function trustAnchorRepoAsync() {
6688
+ const fromRunner = trustAnchorRepoFromRunner();
6689
+ if (fromRunner)
6690
+ return fromRunner;
6691
+ try {
6692
+ const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
6693
+ encoding: "utf-8",
6694
+ timeout: 1e4
6695
+ });
6696
+ return trustAnchorRepoFromRemoteUrl(stdout);
6697
+ } catch {
6698
+ return null;
6699
+ }
6700
+ }
6701
+ function wellFormedRepoSlug(slug) {
6702
+ return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
6703
+ }
6704
+ function trustAnchorRepoFromRunner() {
6705
+ const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
6706
+ return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
6707
+ }
6708
+ function trustAnchorRepoFromRemoteUrl(url) {
6709
+ const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
6710
+ return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
6711
+ }
6712
+ var execFileAsync4 = promisify4(execFile4);
6713
+ function resolveCiTrustAnchorProbeRef(env = process.env) {
6714
+ const ref = env.VINAYA_CI_CONFIG_PROBE_REF?.trim();
6715
+ if (!ref)
6716
+ return null;
6717
+ if (env.GITHUB_ACTIONS !== "true")
6718
+ return null;
6719
+ if ((env.GH_TOKEN ?? "").length > 0 || (env.GITHUB_TOKEN ?? "").length > 0)
6720
+ return null;
6721
+ return ref;
6722
+ }
6723
+ function readTrustAnchorConfigAtRef(ref) {
6724
+ const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
6725
+ encoding: "utf-8",
6726
+ stdio: ["ignore", "pipe", "pipe"],
6727
+ timeout: 1e4
6728
+ });
6729
+ return Buffer.from(raw, "utf-8").toString("base64");
6730
+ }
6529
6731
  function ghFetchTrustAnchorConfig() {
6732
+ const probeRef = resolveCiTrustAnchorProbeRef();
6733
+ if (probeRef)
6734
+ return readTrustAnchorConfigAtRef(probeRef);
6530
6735
  const repo = trustAnchorRepo();
6531
6736
  if (!repo)
6532
6737
  throw new Error("could not resolve repo identity for the trust-anchor read");
@@ -6535,6 +6740,21 @@ function ghFetchTrustAnchorConfig() {
6535
6740
  stdio: ["ignore", "pipe", "pipe"]
6536
6741
  });
6537
6742
  }
6743
+ async function ghFetchTrustAnchorConfigAsync() {
6744
+ const probeRef = resolveCiTrustAnchorProbeRef();
6745
+ if (probeRef) {
6746
+ const { stdout } = await execFileAsync4("git", ["show", `${probeRef}:${LOCAL_CONFIG_FILENAME}`], {
6747
+ encoding: "utf-8",
6748
+ timeout: 1e4
6749
+ });
6750
+ return Buffer.from(stdout, "utf-8").toString("base64");
6751
+ }
6752
+ const repo = await trustAnchorRepoAsync();
6753
+ if (!repo)
6754
+ throw new Error("could not resolve repo identity for the trust-anchor read");
6755
+ const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
6756
+ return stdout;
6757
+ }
6538
6758
  function firstLine(err) {
6539
6759
  return err?.message?.split(`
6540
6760
  `)[0] ?? "unknown error";
@@ -6549,16 +6769,35 @@ function isMissingFileError(err) {
6549
6769
  return /\b404\b|not found/i.test(haystack);
6550
6770
  }
6551
6771
  function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
6552
- 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.
6553
- `);
6554
6772
  let base64;
6555
6773
  try {
6556
- base64 = fetcher().trim();
6774
+ base64 = fetcher();
6557
6775
  } catch (err) {
6558
- if (!isMissingFileError(err))
6559
- warn(firstLine(err));
6560
- return null;
6776
+ return trustAnchorFetchFailed(err);
6561
6777
  }
6778
+ return parseTrustAnchorContent(base64);
6779
+ }
6780
+ async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
6781
+ const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
6782
+ let base64;
6783
+ try {
6784
+ base64 = await fetcher();
6785
+ } catch (err) {
6786
+ return trustAnchorFetchFailed(err, warn);
6787
+ }
6788
+ return parseTrustAnchorContent(base64, warn);
6789
+ }
6790
+ function warnTrustAnchorFallback(why) {
6791
+ 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.
6792
+ `);
6793
+ }
6794
+ function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
6795
+ if (!isMissingFileError(err))
6796
+ warn(firstLine(err));
6797
+ return null;
6798
+ }
6799
+ function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
6800
+ const base64 = content.trim();
6562
6801
  if (!base64)
6563
6802
  return null;
6564
6803
  try {
@@ -6588,6 +6827,8 @@ var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.j
6588
6827
 
6589
6828
  // src/lib/brief-assembly.ts
6590
6829
  import { execFileSync as execFileSync4 } from "node:child_process";
6830
+ import { existsSync as existsSync3, readFileSync as readFileSync3, readdirSync } from "node:fs";
6831
+ import { join as join3 } from "node:path";
6591
6832
 
6592
6833
  // ../../packages/sources/src/commands.ts
6593
6834
  var COMMANDS = [
@@ -6740,10 +6981,10 @@ var COMMANDS = [
6740
6981
  }
6741
6982
  ],
6742
6983
  details: [
6743
- "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.",
6984
+ "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.",
6744
6985
  "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.",
6745
- "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.",
6746
- "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."
6986
+ "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.",
6987
+ "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`)."
6747
6988
  ],
6748
6989
  status: "shipped"
6749
6990
  },
@@ -6782,7 +7023,7 @@ var COMMANDS = [
6782
7023
  details: [
6783
7024
  "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.",
6784
7025
  "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.",
6785
- "`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."
7026
+ "`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."
6786
7027
  ],
6787
7028
  status: "shipped"
6788
7029
  },
@@ -6912,48 +7153,6 @@ var COMMANDS = [
6912
7153
  ],
6913
7154
  status: "shipped"
6914
7155
  },
6915
- {
6916
- name: "log flush",
6917
- description: "Post a target Issue or PR's outbox as one or more marked comments, then truncate what the forge confirmed",
6918
- flags: [
6919
- { flag: "--issue", description: "Flush this Issue's outbox (`~/.vinaya/outbox/<owner>-<repo>/<n>.ndjson`)" },
6920
- {
6921
- flag: "--pr",
6922
- description: "Flush the Issue named by this PR's `Closes #N` line, posting the comments on the PR"
6923
- },
6924
- { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
6925
- ],
6926
- details: [
6927
- "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.",
6928
- "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.",
6929
- "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."
6930
- ],
6931
- status: "shipped"
6932
- },
6933
- {
6934
- name: "log export-artifact",
6935
- description: "Copy this run's own local outbox into a file, for the generated task-path workflow's own upload step",
6936
- flags: [],
6937
- details: [
6938
- "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.",
6939
- "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."
6940
- ],
6941
- status: "shipped"
6942
- },
6943
- {
6944
- name: "log collect-artifact",
6945
- description: "Validate a downloaded task-log artifact and publish the valid records through the existing flush path",
6946
- flags: [
6947
- { flag: "--pr", description: "The pull request this artifact belongs to" },
6948
- { flag: "--repo", description: "Expected `owner/repo` — a provenance cross-check against each record" }
6949
- ],
6950
- details: [
6951
- "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.",
6952
- "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.",
6953
- "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."
6954
- ],
6955
- status: "shipped"
6956
- },
6957
7156
  {
6958
7157
  name: "milestone create",
6959
7158
  description: "Create a GitHub Milestone from a validated body",
@@ -7283,7 +7482,7 @@ var COMMANDS = [
7283
7482
  { flag: "--task", description: "This dispatch's task Issue number — mutually exclusive with `--pr`" },
7284
7483
  {
7285
7484
  flag: "--pr",
7286
- description: "Flush the outbox to this PR's Issue after the dispatch — mutually exclusive with `--task`"
7485
+ description: "This dispatch's pull request number, for attribution — mutually exclusive with `--task`"
7287
7486
  },
7288
7487
  { flag: "--round", description: "Round number, for a dispatch inside a review loop" },
7289
7488
  {
@@ -7295,7 +7494,7 @@ var COMMANDS = [
7295
7494
  details: [
7296
7495
  "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.",
7297
7496
  "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`.",
7298
- "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.",
7497
+ "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.",
7299
7498
  "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."
7300
7499
  ],
7301
7500
  status: "shipped"
@@ -7315,7 +7514,8 @@ var COMMANDS = [
7315
7514
  "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> -->`.",
7316
7515
  "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.",
7317
7516
  "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.",
7318
- "Every dispatch and round transition is a log line through the Vinaya Log, flushed to the forge at each round boundary."
7517
+ "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.",
7518
+ "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)."
7319
7519
  ],
7320
7520
  status: "shipped"
7321
7521
  }
@@ -7452,25 +7652,6 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
7452
7652
  };
7453
7653
  }
7454
7654
 
7455
- // src/lib/brief-assembly.ts
7456
- function git(args) {
7457
- try {
7458
- return execFileSync4("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
7459
- } catch {
7460
- return "";
7461
- }
7462
- }
7463
- function expandGlob(glob) {
7464
- const out = git(["ls-files", "--", glob]);
7465
- return out.split(`
7466
- `).map((s) => s.trim()).filter(Boolean);
7467
- }
7468
- var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
7469
-
7470
- // src/checks/registry.ts
7471
- import { existsSync as existsSync3 } from "node:fs";
7472
- import { join as join3 } from "node:path";
7473
-
7474
7655
  // src/lib/package-root.ts
7475
7656
  import { existsSync as existsSync2 } from "node:fs";
7476
7657
  import { dirname as dirname2, join as join2 } from "node:path";
@@ -7488,13 +7669,33 @@ function packageRoot(moduleUrl) {
7488
7669
  return dir;
7489
7670
  }
7490
7671
 
7672
+ // src/lib/brief-assembly.ts
7673
+ var PACKAGE_ROOT = packageRoot(import.meta.url);
7674
+ var PACKAGED_TEMPLATE_PATH = join3(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
7675
+ var TEMPLATE_PATH = existsSync3(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join3(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
7676
+ function git(args) {
7677
+ try {
7678
+ return execFileSync4("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
7679
+ } catch {
7680
+ return "";
7681
+ }
7682
+ }
7683
+ function expandGlob(glob) {
7684
+ const out = git(["ls-files", "--", glob]);
7685
+ return out.split(`
7686
+ `).map((s) => s.trim()).filter(Boolean);
7687
+ }
7688
+ var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
7689
+
7491
7690
  // src/checks/registry.ts
7492
- var DIST_BIN_DIR = join3(packageRoot(import.meta.url), "dist", "checks", "bin");
7493
- var SRC_BIN_DIR = join3(packageRoot(import.meta.url), "src", "checks", "bin");
7494
- var BIN_DIR = existsSync3(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
7691
+ import { existsSync as existsSync4 } from "node:fs";
7692
+ import { join as join4 } from "node:path";
7693
+ var DIST_BIN_DIR = join4(packageRoot(import.meta.url), "dist", "checks", "bin");
7694
+ var SRC_BIN_DIR = join4(packageRoot(import.meta.url), "src", "checks", "bin");
7695
+ var BIN_DIR = existsSync4(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
7495
7696
  var BIN_EXT = BIN_DIR === DIST_BIN_DIR ? ".js" : ".ts";
7496
7697
  function bin(name) {
7497
- return join3(BIN_DIR, `${name}${BIN_EXT}`);
7698
+ return join4(BIN_DIR, `${name}${BIN_EXT}`);
7498
7699
  }
7499
7700
  var REGISTRY = [
7500
7701
  [
@@ -7906,6 +8107,16 @@ var REGISTRY = [
7906
8107
  },
7907
8108
  0
7908
8109
  ],
8110
+ [
8111
+ {
8112
+ name: "ci-shard-coverage",
8113
+ run: bin("check-ci-shard-coverage"),
8114
+ scope: "diff",
8115
+ timeoutMs: 15000,
8116
+ env: {}
8117
+ },
8118
+ 0
8119
+ ],
7909
8120
  [
7910
8121
  {
7911
8122
  name: "workspace-escape",
@@ -8043,42 +8254,541 @@ function coreCheckRegistry() {
8043
8254
  var CORE_CHECK_RING = Object.fromEntries(REGISTRY.map(([spec, ring]) => [spec.name, ring]));
8044
8255
 
8045
8256
  // src/lib/log-sink.ts
8046
- import { execFileSync as execFileSync5 } from "node:child_process";
8047
- import { randomUUID } from "node:crypto";
8257
+ import { execFile as execFile5 } from "node:child_process";
8258
+ import { randomUUID as randomUUID2 } from "node:crypto";
8259
+ import {
8260
+ closeSync as closeSync3,
8261
+ constants as fsConstants3,
8262
+ existsSync as existsSync6,
8263
+ fstatSync as fstatSync2,
8264
+ mkdirSync as mkdirSync3,
8265
+ openSync as openSync3,
8266
+ readFileSync as readFileSync5,
8267
+ renameSync as renameSync2,
8268
+ writeSync as writeSync2
8269
+ } from "node:fs";
8270
+ import { hostname as osHostname, homedir as homedir3 } from "node:os";
8271
+ import { dirname as dirname5, join as join7 } from "node:path";
8272
+ import { promisify as promisify5 } from "node:util";
8273
+
8274
+ // src/lib/run-paths.ts
8275
+ import { chmodSync, existsSync as existsSync5, realpathSync as realpathSync2 } from "node:fs";
8276
+ import { dirname as dirname3, join as join5, resolve as resolvePath } from "node:path";
8277
+ var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8278
+ function isSafeRepoSegment(segment) {
8279
+ return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
8280
+ }
8281
+ function repoSegment(repo) {
8282
+ if (!repo || !isSafeRepoSegment(repo.owner) || !isSafeRepoSegment(repo.repo))
8283
+ return "unresolved";
8284
+ return `${repo.owner}-${repo.repo}`;
8285
+ }
8286
+ function defaultRuntimeDir(repo, home = GLOBAL_VINAYA_HOME) {
8287
+ return join5(home, "runtime", repoSegment(repo));
8288
+ }
8289
+ function resolveRuntimeDir(input) {
8290
+ const local = resolveRuntimeDirSetting(input.localConfig);
8291
+ if (local === null)
8292
+ return defaultRuntimeDir(input.repo, input.home);
8293
+ if (isInsideRepo(local, input.repoRoot))
8294
+ return defaultRuntimeDir(input.repo, input.home);
8295
+ if (!input.unattended)
8296
+ return local;
8297
+ const anchored = resolveTrustAnchorRuntimeDir(local, input.trustAnchorConfig ?? null);
8298
+ return anchored ?? defaultRuntimeDir(input.repo, input.home);
8299
+ }
8300
+ function isInsideRepo(candidate, repoRoot) {
8301
+ if (!repoRoot)
8302
+ return false;
8303
+ const root = resolvePath(repoRoot);
8304
+ const target = resolvePath(candidate);
8305
+ return target === root || target.startsWith(`${root}/`);
8306
+ }
8307
+ var UNATTENDED_ENV_KEY = "VINAYA_UNATTENDED";
8308
+ var RUNTIME_DIR_ENV_KEY = "VINAYA_RUNTIME_DIR";
8309
+ function isUnattendedProcess(env = process.env) {
8310
+ return env[UNATTENDED_ENV_KEY] === "1" || (env.VINAYA_ROLE ?? "") !== "";
8311
+ }
8312
+ var memoized = null;
8313
+ async function runtimeDirForRepoAsync(repo) {
8314
+ const key = repoSegment(repo);
8315
+ if (memoized?.key === key)
8316
+ return memoized.value;
8317
+ const inputs = runtimeDirInputs();
8318
+ if (typeof inputs === "string")
8319
+ return inputs;
8320
+ const value = resolveRuntimeDir({
8321
+ repo,
8322
+ ...inputs.base,
8323
+ trustAnchorConfig: inputs.needsAnchor ? await loadTrustAnchorConfigAsync() : null
8324
+ });
8325
+ memoized = { key, value };
8326
+ return value;
8327
+ }
8328
+ function runtimeDirInputs() {
8329
+ const handedDown = process.env[RUNTIME_DIR_ENV_KEY];
8330
+ if (handedDown)
8331
+ return handedDown;
8332
+ const localConfig = loadConfig();
8333
+ const unattended = isUnattendedProcess();
8334
+ return {
8335
+ base: { localConfig, unattended, repoRoot: repoRootSync() },
8336
+ needsAnchor: unattended && resolveRuntimeDirSetting(localConfig) !== null
8337
+ };
8338
+ }
8339
+ function repoRootSync(start = process.cwd()) {
8340
+ let dir;
8341
+ try {
8342
+ dir = realpathSync2(start);
8343
+ } catch {
8344
+ return null;
8345
+ }
8346
+ for (;; ) {
8347
+ if (existsSync5(join5(dir, ".git")))
8348
+ return dir;
8349
+ const parent = dirname3(dir);
8350
+ if (parent === dir)
8351
+ return null;
8352
+ dir = parent;
8353
+ }
8354
+ }
8355
+
8356
+ // src/lib/log-webhook-drain.ts
8048
8357
  import {
8049
8358
  closeSync as closeSync2,
8050
8359
  constants as fsConstants2,
8051
- existsSync as existsSync4,
8052
- fstatSync as fstatSync2,
8360
+ lstatSync,
8053
8361
  mkdirSync as mkdirSync2,
8054
8362
  openSync as openSync2,
8055
- readFileSync as readFileSync3,
8363
+ linkSync,
8364
+ readFileSync as readFileSync4,
8056
8365
  renameSync,
8366
+ statSync,
8367
+ unlinkSync,
8368
+ utimesSync,
8369
+ writeFileSync as writeFileSync2,
8057
8370
  writeSync
8058
8371
  } from "node:fs";
8059
- import { hostname as osHostname, homedir as homedir2 } from "node:os";
8060
- import { dirname as dirname3, join as join4 } from "node:path";
8061
- var OUTBOX_MAX_BYTES = 8 * 1024 * 1024;
8372
+ import { randomUUID } from "node:crypto";
8373
+ import { homedir as homedir2 } from "node:os";
8374
+ import { dirname as dirname4, join as join6 } from "node:path";
8375
+ var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
8376
+ var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
8377
+ var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8378
+ function isSafeRepoSegment2(segment) {
8379
+ return SAFE_PATH_SEGMENT2.test(segment) && !segment.includes("..");
8380
+ }
8381
+ function isErrnoCode(err, code) {
8382
+ return typeof err === "object" && err !== null && err.code === code;
8383
+ }
8062
8384
  function isEnoent(err) {
8385
+ return isErrnoCode(err, "ENOENT");
8386
+ }
8387
+ var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
8388
+ function tryCreateLock(lockPath, token) {
8389
+ try {
8390
+ mkdirSync2(dirname4(lockPath), { recursive: true, mode: 448 });
8391
+ const fd = openSync2(lockPath, fsConstants2.O_WRONLY | fsConstants2.O_CREAT | fsConstants2.O_EXCL, 384);
8392
+ try {
8393
+ writeSync(fd, `${token}
8394
+ `);
8395
+ } finally {
8396
+ closeSync2(fd);
8397
+ }
8398
+ return true;
8399
+ } catch (err) {
8400
+ if (isErrnoCode(err, "EEXIST"))
8401
+ return false;
8402
+ throw err;
8403
+ }
8404
+ }
8405
+ function acquireDrainLock(lockPath) {
8406
+ const token = `${process.pid}:${randomUUID()}`;
8407
+ if (tryCreateLock(lockPath, token))
8408
+ return token;
8409
+ let observedMtimeMs;
8410
+ try {
8411
+ observedMtimeMs = statSync(lockPath).mtimeMs;
8412
+ } catch (err) {
8413
+ if (!isEnoent(err))
8414
+ throw err;
8415
+ return tryCreateLock(lockPath, token) ? token : null;
8416
+ }
8417
+ if (Date.now() - observedMtimeMs <= WEBHOOK_DRAIN_LOCK_STALE_MS)
8418
+ return null;
8419
+ const claimed = `${lockPath}.claimed-${randomUUID()}`;
8420
+ try {
8421
+ renameSync(lockPath, claimed);
8422
+ } catch (err) {
8423
+ if (isEnoent(err))
8424
+ return null;
8425
+ throw err;
8426
+ }
8427
+ let claimedMtimeMs = null;
8428
+ try {
8429
+ claimedMtimeMs = statSync(claimed).mtimeMs;
8430
+ } catch (err) {
8431
+ if (!isEnoent(err))
8432
+ throw err;
8433
+ }
8434
+ if (claimedMtimeMs !== observedMtimeMs) {
8435
+ try {
8436
+ linkSync(claimed, lockPath);
8437
+ } catch (err) {
8438
+ if (!isErrnoCode(err, "EEXIST"))
8439
+ throw err;
8440
+ }
8441
+ try {
8442
+ unlinkSync(claimed);
8443
+ } catch (err) {
8444
+ if (!isEnoent(err))
8445
+ throw err;
8446
+ }
8447
+ return null;
8448
+ }
8449
+ unlinkSync(claimed);
8450
+ return tryCreateLock(lockPath, token) ? token : null;
8451
+ }
8452
+ function renewDrainLock(lockPath, token) {
8453
+ let holder;
8454
+ try {
8455
+ holder = readFileSync4(lockPath, "utf8").trim();
8456
+ } catch (err) {
8457
+ if (!isEnoent(err))
8458
+ throw err;
8459
+ return false;
8460
+ }
8461
+ if (holder !== token)
8462
+ return false;
8463
+ const now = new Date;
8464
+ try {
8465
+ utimesSync(lockPath, now, now);
8466
+ } catch (err) {
8467
+ if (!isEnoent(err))
8468
+ throw err;
8469
+ return false;
8470
+ }
8471
+ return true;
8472
+ }
8473
+ function releaseDrainLock(lockPath, token) {
8474
+ try {
8475
+ const holder = readFileSync4(lockPath, "utf8").trim();
8476
+ if (holder !== token)
8477
+ return;
8478
+ unlinkSync(lockPath);
8479
+ } catch (err) {
8480
+ if (!isEnoent(err))
8481
+ throw err;
8482
+ }
8483
+ }
8484
+
8485
+ class WebhookDrainError extends Error {
8486
+ code;
8487
+ constructor(code, message) {
8488
+ super(message);
8489
+ this.code = code;
8490
+ }
8491
+ }
8492
+ function backupPathFor(queuePath) {
8493
+ return queuePath.replace(/\.ndjson$/, ".1.ndjson");
8494
+ }
8495
+ function drainingPathFor(queuePath) {
8496
+ return queuePath.replace(/\.ndjson$/, ".draining.ndjson");
8497
+ }
8498
+ function rejectedPathFor(queuePath) {
8499
+ return queuePath.replace(/\.ndjson$/, ".rejected.ndjson");
8500
+ }
8501
+ var rejectionWarnedThisProcess = false;
8502
+ function warnRejectionOnce(message) {
8503
+ if (rejectionWarnedThisProcess)
8504
+ return;
8505
+ rejectionWarnedThisProcess = true;
8506
+ try {
8507
+ process.stderr.write(message);
8508
+ } catch {}
8509
+ }
8510
+ function queueLines(buf) {
8511
+ const lines = [];
8512
+ let start = 0;
8513
+ for (let i = 0;i < buf.byteLength; i++) {
8514
+ if (buf[i] !== 10)
8515
+ continue;
8516
+ if (i > start)
8517
+ lines.push({ raw: buf.toString("utf8", start, i), end: i + 1 });
8518
+ start = i + 1;
8519
+ }
8520
+ if (start < buf.byteLength)
8521
+ lines.push({ raw: buf.toString("utf8", start), end: buf.byteLength });
8522
+ return lines;
8523
+ }
8524
+ function removeQueueHead(path, cut) {
8525
+ const remaining = readFileSync4(path);
8526
+ writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
8527
+ }
8528
+ function queueBucketSize(path) {
8529
+ let lstat;
8530
+ try {
8531
+ lstat = lstatSync(path);
8532
+ } catch (err) {
8533
+ if (!isEnoent(err))
8534
+ throw err;
8535
+ }
8536
+ if (lstat === undefined)
8537
+ return null;
8538
+ if (!lstat.isFile()) {
8539
+ 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}`);
8540
+ }
8541
+ return Number(lstat.size);
8542
+ }
8543
+ function readQueueFile(path) {
8544
+ if (queueBucketSize(path) === null)
8545
+ return null;
8546
+ return readFileSync4(path);
8547
+ }
8548
+ function rejectLine(rejectedPath, reason, status, identity, raw) {
8549
+ const record = JSON.stringify({
8550
+ rejected_at: new Date().toISOString(),
8551
+ status,
8552
+ reason,
8553
+ identity,
8554
+ bytes: Buffer.byteLength(raw, "utf8"),
8555
+ raw
8556
+ });
8557
+ const failure = appendHardenedLine(rejectedPath, `${record}
8558
+ `);
8559
+ if (failure !== null) {
8560
+ 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`);
8561
+ }
8562
+ warnRejectionOnce(`vinaya: log delivery set a queued line aside in ${rejectedPath} — ${reason}; later lines keep delivering
8563
+ `);
8564
+ }
8565
+ async function postChunk(webhookUrl, headers, body, fetchTimeoutMs, chunksAlreadyDelivered) {
8566
+ const delivered = chunksAlreadyDelivered > 0 ? ` after delivering ${chunksAlreadyDelivered} chunk(s)` : "";
8567
+ let response;
8568
+ try {
8569
+ response = await fetch(webhookUrl, {
8570
+ method: "POST",
8571
+ headers: { "content-type": "application/x-ndjson", ...headers },
8572
+ body,
8573
+ signal: AbortSignal.timeout(fetchTimeoutMs)
8574
+ });
8575
+ } catch (err) {
8576
+ const reason = err instanceof Error && err.name === "TimeoutError" ? `timed out after ${fetchTimeoutMs}ms` : err instanceof Error ? err.message : String(err);
8577
+ throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} failed${delivered}: ${reason}`);
8578
+ }
8579
+ if (!response.ok) {
8580
+ throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} returned ${response.status} ${response.statusText}${delivered}`);
8581
+ }
8582
+ }
8583
+ async function drainQueueFile(args) {
8584
+ const { path, rejectedPath, webhookUrl, headers, fetchTimeoutMs, totals } = args;
8585
+ const buf = readQueueFile(path);
8586
+ if (buf === null || buf.byteLength === 0)
8587
+ return;
8588
+ const lines = queueLines(buf);
8589
+ if (lines.length === 0) {
8590
+ removeQueueHead(path, buf.byteLength);
8591
+ return;
8592
+ }
8593
+ let removed = 0;
8594
+ let pendingEnd = 0;
8595
+ let chunk = [];
8596
+ let chunkBytes = 0;
8597
+ const deliverChunk = async () => {
8598
+ const body = `${chunk.join(`
8599
+ `)}
8600
+ `;
8601
+ args.keepLock();
8602
+ await postChunk(webhookUrl, headers, body, fetchTimeoutMs, totals.chunks);
8603
+ totals.chunks += 1;
8604
+ totals.lineCount += chunk.length;
8605
+ totals.bytes += Buffer.byteLength(body, "utf8");
8606
+ removeQueueHead(path, pendingEnd - removed);
8607
+ removed = pendingEnd;
8608
+ chunk = [];
8609
+ chunkBytes = 0;
8610
+ };
8611
+ const setAside = async (reason, status, identity, line) => {
8612
+ if (chunk.length > 0)
8613
+ await deliverChunk();
8614
+ rejectLine(rejectedPath, reason, status, identity, line.raw);
8615
+ totals.rejected += 1;
8616
+ pendingEnd = line.end;
8617
+ removeQueueHead(path, pendingEnd - removed);
8618
+ removed = pendingEnd;
8619
+ };
8620
+ for (const line of lines) {
8621
+ const record = classifyStoredLine(line.raw, homedir2());
8622
+ if (record.status !== "ok") {
8623
+ await setAside(record.reason, record.status, record.identity, line);
8624
+ continue;
8625
+ }
8626
+ const lineBytes = Buffer.byteLength(record.postLine, "utf8") + 1;
8627
+ if (lineBytes > MAX_WEBHOOK_BODY_BYTES) {
8628
+ 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);
8629
+ continue;
8630
+ }
8631
+ if (chunk.length > 0 && chunkBytes + lineBytes > MAX_WEBHOOK_BODY_BYTES)
8632
+ await deliverChunk();
8633
+ chunk.push(record.postLine);
8634
+ chunkBytes += lineBytes;
8635
+ pendingEnd = line.end;
8636
+ }
8637
+ pendingEnd = buf.byteLength;
8638
+ if (chunk.length > 0) {
8639
+ await deliverChunk();
8640
+ return;
8641
+ }
8642
+ if (pendingEnd > removed)
8643
+ removeQueueHead(path, pendingEnd - removed);
8644
+ }
8645
+ async function drainRenamedAside(args, livePath, source) {
8646
+ args.keepLock();
8647
+ const draining = drainingPathFor(livePath);
8648
+ try {
8649
+ renameSync(source, draining);
8650
+ } catch (err) {
8651
+ if (isEnoent(err))
8652
+ return;
8653
+ throw err;
8654
+ }
8655
+ await drainQueueFile({ ...args, path: draining });
8656
+ unlinkSync(draining);
8657
+ }
8658
+ async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeoutMs = WEBHOOK_FETCH_TIMEOUT_MS) {
8659
+ const resolved = await resolveRepo();
8660
+ const repo = resolved && isSafeRepoSegment2(resolved.owner) && isSafeRepoSegment2(resolved.repo) ? resolved : null;
8661
+ const outboxRoot = () => join6(GLOBAL_VINAYA_HOME, "outbox");
8662
+ const path = outboxPathFor({ outboxRoot }, repo, outboxTask);
8663
+ const lockPath = `${path}.flush-lock`;
8664
+ const lockToken = acquireDrainLock(lockPath);
8665
+ const totals = { lineCount: 0, bytes: 0, chunks: 0, rejected: 0 };
8666
+ if (lockToken === null)
8667
+ return { flushed: false, ...totals };
8668
+ try {
8669
+ const keepLock = () => {
8670
+ if (renewDrainLock(lockPath, lockToken))
8671
+ return;
8672
+ 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`);
8673
+ };
8674
+ const shared = {
8675
+ rejectedPath: rejectedPathFor(path),
8676
+ webhookUrl,
8677
+ headers,
8678
+ fetchTimeoutMs,
8679
+ totals,
8680
+ keepLock
8681
+ };
8682
+ const draining = drainingPathFor(path);
8683
+ if (queueBucketSize(draining) !== null) {
8684
+ keepLock();
8685
+ await drainQueueFile({ ...shared, path: draining });
8686
+ unlinkSync(draining);
8687
+ }
8688
+ await drainRenamedAside(shared, path, backupPathFor(path));
8689
+ await drainRenamedAside(shared, path, path);
8690
+ return { flushed: totals.chunks > 0 || totals.rejected > 0, ...totals };
8691
+ } finally {
8692
+ releaseDrainLock(lockPath, lockToken);
8693
+ }
8694
+ }
8695
+
8696
+ // src/lib/log-sink.ts
8697
+ var OUTBOX_MAX_BYTES = 8 * 1024 * 1024;
8698
+ var LOG_CONTEXT_LOOKUP_DEADLINE_MS = 3000;
8699
+ function withDeadline(work, ms, fallback) {
8700
+ return new Promise((resolve) => {
8701
+ const timer = setTimeout(() => resolve(fallback), ms);
8702
+ timer.unref?.();
8703
+ work.then((value) => {
8704
+ clearTimeout(timer);
8705
+ resolve(value);
8706
+ }, () => {
8707
+ clearTimeout(timer);
8708
+ resolve(fallback);
8709
+ });
8710
+ });
8711
+ }
8712
+ async function safeLoadTrustAnchorConfig() {
8713
+ return withDeadline(loadTrustAnchorConfigAsync(undefined, { quiet: true }), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
8714
+ }
8715
+ function logsCredentialMissing(headers, env) {
8716
+ if (!headers)
8717
+ return false;
8718
+ const varPattern = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
8719
+ for (const value of Object.values(headers)) {
8720
+ for (const match of value.matchAll(varPattern)) {
8721
+ if (!env[match[1]])
8722
+ return true;
8723
+ }
8724
+ }
8725
+ return false;
8726
+ }
8727
+ function resolveLogDestinationFrom(input) {
8728
+ const local = resolveLogsSetting(input.localConfig);
8729
+ let effective = null;
8730
+ if (input.unattended) {
8731
+ effective = local ? resolveTrustAnchorLogsDestination(local, input.trustAnchorConfig) : resolveLogsSetting(input.trustAnchorConfig);
8732
+ } else {
8733
+ effective = local;
8734
+ }
8735
+ if (hostFromEnv(input.env) === "ci") {
8736
+ if (effective && "url" in effective) {
8737
+ if (logsCredentialMissing(effective.headers, input.env)) {
8738
+ return {
8739
+ kind: "none",
8740
+ reason: "a logs.url server destination is configured, but this job holds no delivery credential (a fork pull request, or a missing repository secret)"
8741
+ };
8742
+ }
8743
+ return { kind: "server", url: effective.url, headers: resolveLogsHeaderValues(effective.headers, input.env) };
8744
+ }
8745
+ return {
8746
+ kind: "none",
8747
+ reason: "no server destination is configured for CI delivery (vinaya.config.json logs.url)"
8748
+ };
8749
+ }
8750
+ if (effective && "url" in effective) {
8751
+ return { kind: "server", url: effective.url, headers: resolveLogsHeaderValues(effective.headers, input.env) };
8752
+ }
8753
+ if (effective && "folder" in effective && isInsideRepo(effective.folder, input.repoRoot)) {
8754
+ effective = null;
8755
+ }
8756
+ const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
8757
+ return { kind: "folder", folder };
8758
+ }
8759
+ var processTrustAnchorOnce;
8760
+ function processTrustAnchor() {
8761
+ if (processTrustAnchorOnce === undefined)
8762
+ processTrustAnchorOnce = safeLoadTrustAnchorConfig();
8763
+ return processTrustAnchorOnce;
8764
+ }
8765
+ async function defaultResolveLogDestination(repo, env) {
8766
+ const localConfig = loadConfig();
8767
+ const unattended = isUnattendedProcess(process.env);
8768
+ return resolveLogDestinationFrom({
8769
+ localConfig,
8770
+ trustAnchorConfig: unattended ? await processTrustAnchor() : null,
8771
+ unattended,
8772
+ env,
8773
+ defaultFolder: join7(await runtimeDirForRepoAsync(repo), "logs"),
8774
+ repoRoot: repoRootSync()
8775
+ });
8776
+ }
8777
+ function isEnoent2(err) {
8063
8778
  return typeof err === "object" && err !== null && err.code === "ENOENT";
8064
8779
  }
8065
- function resolveDoctrine(cwd, vinayaVersion) {
8780
+ var execFileAsync5 = promisify5(execFile5);
8781
+ async function resolveDoctrine(cwd, vinayaVersion) {
8066
8782
  let toplevel;
8067
8783
  try {
8068
- toplevel = execFileSync5("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
8069
- encoding: "utf8",
8070
- stdio: ["ignore", "pipe", "pipe"]
8071
- }).trim();
8784
+ toplevel = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "--show-toplevel"], { encoding: "utf8" })).stdout.trim();
8072
8785
  } catch (err) {
8073
- return isEnoent(err) ? "unknown" : vinayaVersion;
8786
+ return isEnoent2(err) ? "unknown" : vinayaVersion;
8074
8787
  }
8075
- if (!existsSync4(join4(toplevel, "aeg-root", "roles")))
8788
+ if (!existsSync6(join7(toplevel, "aeg-root", "roles")))
8076
8789
  return vinayaVersion;
8077
8790
  try {
8078
- const sha = execFileSync5("git", ["-C", toplevel, "rev-parse", "HEAD:aeg-root"], {
8079
- encoding: "utf8",
8080
- stdio: ["ignore", "pipe", "pipe"]
8081
- }).trim();
8791
+ const sha = (await execFileAsync5("git", ["-C", toplevel, "rev-parse", "HEAD:aeg-root"], { encoding: "utf8" })).stdout.trim();
8082
8792
  return `aeg-root@${sha}`;
8083
8793
  } catch {
8084
8794
  return vinayaVersion;
@@ -8086,20 +8796,20 @@ function resolveDoctrine(cwd, vinayaVersion) {
8086
8796
  }
8087
8797
  function readVinayaVersion() {
8088
8798
  try {
8089
- const pkg = JSON.parse(readFileSync3(join4(packageRoot(import.meta.url), "package.json"), "utf8"));
8799
+ const pkg = JSON.parse(readFileSync5(join7(packageRoot(import.meta.url), "package.json"), "utf8"));
8090
8800
  return pkg.version ?? "unknown";
8091
8801
  } catch {
8092
8802
  return "unknown";
8093
8803
  }
8094
8804
  }
8095
- var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8096
- function isSafeRepoSegment(segment) {
8097
- return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
8805
+ var SAFE_PATH_SEGMENT3 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8806
+ function isSafeRepoSegment3(segment) {
8807
+ return SAFE_PATH_SEGMENT3.test(segment) && !segment.includes("..");
8098
8808
  }
8099
8809
  function outboxPathFor(deps, repo, issue) {
8100
8810
  const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
8101
8811
  const fileName = `${issue ?? "none"}.ndjson`;
8102
- return join4(deps.outboxRoot(), dirName, fileName);
8812
+ return join7(deps.outboxRoot(), dirName, fileName);
8103
8813
  }
8104
8814
  function hostFromEnv(env) {
8105
8815
  if (env.GITHUB_ACTIONS)
@@ -8110,36 +8820,60 @@ function hostFromEnv(env) {
8110
8820
  return "loop";
8111
8821
  return "cli";
8112
8822
  }
8823
+ var warnedThisProcess = false;
8824
+ function defaultStderr(message) {
8825
+ if (warnedThisProcess)
8826
+ return;
8827
+ warnedThisProcess = true;
8828
+ process.stderr.write(message);
8829
+ }
8113
8830
  function defaultDeps() {
8114
8831
  return {
8115
- outboxRoot: () => join4(GLOBAL_VINAYA_HOME, "outbox"),
8116
- home: () => homedir2(),
8832
+ outboxRoot: () => join7(GLOBAL_VINAYA_HOME, "outbox"),
8833
+ home: () => homedir3(),
8117
8834
  hostname: () => osHostname(),
8118
8835
  cwd: () => process.cwd(),
8119
8836
  now: () => new Date,
8120
8837
  env: () => process.env,
8121
8838
  resolveRepo: () => resolveRepo(),
8122
8839
  vinayaVersion: () => readVinayaVersion(),
8123
- stderr: (message) => {
8124
- process.stderr.write(message);
8125
- },
8840
+ stderr: defaultStderr,
8126
8841
  inputVersions: () => {
8127
8842
  return;
8128
- }
8843
+ },
8844
+ resolveLogDestination: defaultResolveLogDestination
8129
8845
  };
8130
8846
  }
8131
- var APPEND_OPEN_FLAGS = fsConstants2.O_WRONLY | fsConstants2.O_APPEND | fsConstants2.O_CREAT | fsConstants2.O_NOFOLLOW | fsConstants2.O_NONBLOCK;
8847
+ var APPEND_OPEN_FLAGS = fsConstants3.O_WRONLY | fsConstants3.O_APPEND | fsConstants3.O_CREAT | fsConstants3.O_NOFOLLOW | fsConstants3.O_NONBLOCK;
8132
8848
  function guardedAppendOpen(path) {
8133
8849
  try {
8134
- return openSync2(path, APPEND_OPEN_FLAGS, 384);
8850
+ return openSync3(path, APPEND_OPEN_FLAGS, 384);
8135
8851
  } catch {
8136
8852
  return;
8137
8853
  }
8138
8854
  }
8855
+ function appendHardenedLine(path, line) {
8856
+ try {
8857
+ mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
8858
+ const fd = guardedAppendOpen(path);
8859
+ if (fd === undefined)
8860
+ return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
8861
+ try {
8862
+ if (!fstatSync2(fd).isFile())
8863
+ return `target is not a regular file: ${path}`;
8864
+ writeSync2(fd, line);
8865
+ } finally {
8866
+ closeSync3(fd);
8867
+ }
8868
+ return null;
8869
+ } catch (err) {
8870
+ return err instanceof Error ? err.message : String(err);
8871
+ }
8872
+ }
8139
8873
  function reportRotationOverflow(backupPath, warn) {
8140
8874
  let raw;
8141
8875
  try {
8142
- raw = readFileSync3(backupPath, "utf8");
8876
+ raw = readFileSync5(backupPath, "utf8");
8143
8877
  } catch {
8144
8878
  return;
8145
8879
  }
@@ -8162,7 +8896,7 @@ function reportRotationOverflow(backupPath, warn) {
8162
8896
  }
8163
8897
  function appendLine(path, line, warn) {
8164
8898
  try {
8165
- mkdirSync2(dirname3(path), { recursive: true, mode: 448 });
8899
+ mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
8166
8900
  let fd = guardedAppendOpen(path);
8167
8901
  if (fd === undefined) {
8168
8902
  warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
@@ -8178,11 +8912,11 @@ function appendLine(path, line, warn) {
8178
8912
  return;
8179
8913
  }
8180
8914
  if (stat.size > OUTBOX_MAX_BYTES) {
8181
- closeSync2(fd);
8915
+ closeSync3(fd);
8182
8916
  closed = true;
8183
8917
  const backupPath = path.replace(/\.ndjson$/, ".1.ndjson");
8184
8918
  reportRotationOverflow(backupPath, warn);
8185
- renameSync(path, backupPath);
8919
+ renameSync2(path, backupPath);
8186
8920
  const rotated = guardedAppendOpen(path);
8187
8921
  if (rotated === undefined) {
8188
8922
  warn(`vinaya: log outbox target could not be reopened after rotation — refusing: ${path}
@@ -8192,10 +8926,10 @@ function appendLine(path, line, warn) {
8192
8926
  fd = rotated;
8193
8927
  closed = false;
8194
8928
  }
8195
- writeSync(fd, line);
8929
+ writeSync2(fd, line);
8196
8930
  } finally {
8197
8931
  if (!closed)
8198
- closeSync2(fd);
8932
+ closeSync3(fd);
8199
8933
  }
8200
8934
  } catch (err) {
8201
8935
  warn(`vinaya: log outbox write failed — ${err instanceof Error ? err.message : String(err)}
@@ -8204,8 +8938,8 @@ function appendLine(path, line, warn) {
8204
8938
  }
8205
8939
  function createLogSink(overrides = {}) {
8206
8940
  const deps = { ...defaultDeps(), ...overrides };
8207
- const runId = deps.env().VINAYA_RUN_ID || randomUUID();
8208
- const processId = randomUUID();
8941
+ const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
8942
+ const processId = randomUUID2();
8209
8943
  let seq = 0;
8210
8944
  let warned = false;
8211
8945
  const warnOnce = (message) => {
@@ -8218,8 +8952,9 @@ function createLogSink(overrides = {}) {
8218
8952
  };
8219
8953
  let doctrineCache;
8220
8954
  const doctrine = () => {
8221
- if (doctrineCache === undefined)
8222
- doctrineCache = resolveDoctrine(deps.cwd(), deps.vinayaVersion());
8955
+ if (doctrineCache === undefined) {
8956
+ doctrineCache = withDeadline(resolveDoctrine(deps.cwd(), deps.vinayaVersion()), LOG_CONTEXT_LOOKUP_DEADLINE_MS, deps.vinayaVersion());
8957
+ }
8223
8958
  return doctrineCache;
8224
8959
  };
8225
8960
  let resolveRepoCache;
@@ -8228,6 +8963,30 @@ function createLogSink(overrides = {}) {
8228
8963
  resolveRepoCache = deps.resolveRepo();
8229
8964
  return resolveRepoCache;
8230
8965
  };
8966
+ let contextCache;
8967
+ const context = () => {
8968
+ if (contextCache === undefined) {
8969
+ const env = deps.env();
8970
+ contextCache = Promise.all([
8971
+ withDeadline(resolveRepoOnce(), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null),
8972
+ doctrine()
8973
+ ]).then(async ([resolved, doctrineValue]) => {
8974
+ const repo = resolved && isSafeRepoSegment3(resolved.owner) && isSafeRepoSegment3(resolved.repo) ? resolved : null;
8975
+ return { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
8976
+ });
8977
+ }
8978
+ return contextCache;
8979
+ };
8980
+ let drainChain = Promise.resolve();
8981
+ const pendingWrites = new Set;
8982
+ const scheduleWebhookDrain = (issue, url, headers) => {
8983
+ drainChain = drainChain.then(() => drainOutboxToWebhook(issue, url, headers)).then(() => {
8984
+ return;
8985
+ }).catch((err) => {
8986
+ warnOnce(`vinaya: log delivery to ${url} failed — queued in the local outbox, retried on the next event: ${err instanceof Error ? err.message : String(err)}
8987
+ `);
8988
+ });
8989
+ };
8231
8990
  function log(e) {
8232
8991
  try {
8233
8992
  const env = deps.env();
@@ -8242,22 +9001,26 @@ function createLogSink(overrides = {}) {
8242
9001
  attempt: env.VINAYA_ATTEMPT,
8243
9002
  parent: env.VINAYA_PARENT_EVENT
8244
9003
  };
8245
- resolveRepoOnce().then((resolved) => {
8246
- const repo = resolved && isSafeRepoSegment(resolved.owner) && isSafeRepoSegment(resolved.repo) ? resolved : null;
9004
+ const written = context().then(({ repo, doctrine: doctrineValue, destination: resolvedDestination }) => {
8247
9005
  const header = buildHeader({
8248
9006
  now,
8249
9007
  runId,
8250
9008
  seq: mySeq,
8251
9009
  repo: repo ? `${repo.owner}/${repo.repo}` : null,
8252
9010
  vinaya: deps.vinayaVersion(),
8253
- doctrine: doctrine(),
9011
+ doctrine: doctrineValue,
8254
9012
  host,
8255
9013
  hostname: deps.hostname(),
8256
9014
  env: envFields,
8257
- eventId: randomUUID(),
9015
+ eventId: randomUUID2(),
8258
9016
  processId,
8259
9017
  inputVersions: deps.inputVersions()
8260
9018
  });
9019
+ if (resolvedDestination.kind === "none") {
9020
+ warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
9021
+ `);
9022
+ return;
9023
+ }
8261
9024
  const full = { ...e, ...header };
8262
9025
  const parsed = LogEventSchema.safeParse(full);
8263
9026
  if (!parsed.success) {
@@ -8267,25 +9030,42 @@ function createLogSink(overrides = {}) {
8267
9030
  }
8268
9031
  const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
8269
9032
  `;
8270
- appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
9033
+ const destination = resolvedDestination;
9034
+ if (destination.kind === "server") {
9035
+ appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
9036
+ scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
9037
+ } else {
9038
+ appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
9039
+ }
8271
9040
  }).catch((err) => {
8272
9041
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
8273
9042
  `);
8274
9043
  });
9044
+ pendingWrites.add(written);
9045
+ written.finally(() => pendingWrites.delete(written));
8275
9046
  } catch (err) {
8276
9047
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
8277
9048
  `);
8278
9049
  }
8279
9050
  }
8280
9051
  const warmup = () => {
8281
- doctrine();
8282
9052
  const originalWarn = console.warn;
8283
9053
  console.warn = () => {};
8284
9054
  resolveRepoOnce().finally(() => {
8285
9055
  console.warn = originalWarn;
8286
9056
  });
9057
+ context().catch(() => {
9058
+ return;
9059
+ });
9060
+ };
9061
+ const drain = async () => {
9062
+ if (pendingWrites.size > 0)
9063
+ await Promise.allSettled(Array.from(pendingWrites));
9064
+ await drainChain.catch(() => {
9065
+ return;
9066
+ });
8287
9067
  };
8288
- return { log, runId, warmup };
9068
+ return { log, runId, warmup, drain };
8289
9069
  }
8290
9070
  var defaultSink = createLogSink();
8291
9071
 
@@ -8329,7 +9109,7 @@ function parseChangedLineRanges(diffOutput) {
8329
9109
  function fileDiffAgainst(ref, path) {
8330
9110
  let out;
8331
9111
  try {
8332
- out = execFileSync6("git", ["diff", `${ref}...HEAD`, "--", path], {
9112
+ out = execFileSync5("git", ["diff", `${ref}...HEAD`, "--", path], {
8333
9113
  encoding: "utf8",
8334
9114
  stdio: ["ignore", "pipe", "pipe"]
8335
9115
  }).trim();
@@ -8340,7 +9120,7 @@ function fileDiffAgainst(ref, path) {
8340
9120
  }
8341
9121
  function revParse(ref) {
8342
9122
  try {
8343
- return execFileSync6("git", ["rev-parse", "--verify", ref], {
9123
+ return execFileSync5("git", ["rev-parse", "--verify", ref], {
8344
9124
  encoding: "utf8",
8345
9125
  stdio: ["ignore", "pipe", "pipe"]
8346
9126
  }).trim();
@@ -8350,7 +9130,7 @@ function revParse(ref) {
8350
9130
  }
8351
9131
  function repoRoot() {
8352
9132
  try {
8353
- return execFileSync6("git", ["rev-parse", "--show-toplevel"], {
9133
+ return execFileSync5("git", ["rev-parse", "--show-toplevel"], {
8354
9134
  encoding: "utf8",
8355
9135
  stdio: ["ignore", "pipe", "pipe"]
8356
9136
  }).trim();
@@ -8361,7 +9141,7 @@ function repoRoot() {
8361
9141
  function changedFiles(base) {
8362
9142
  let out;
8363
9143
  try {
8364
- out = execFileSync6("git", ["diff", "--name-only", `${base}...HEAD`], {
9144
+ out = execFileSync5("git", ["diff", "--name-only", `${base}...HEAD`], {
8365
9145
  encoding: "utf8",
8366
9146
  stdio: ["ignore", "pipe", "pipe"]
8367
9147
  }).trim();
@@ -8386,7 +9166,7 @@ function resolveDiff(base = process.env.BASE_SHA || "origin/main") {
8386
9166
  const relPaths = changedFiles(ref);
8387
9167
  if (relPaths === null)
8388
9168
  continue;
8389
- return { base: ref, root, files: relPaths.map((p) => join5(root, p)) };
9169
+ return { base: ref, root, files: relPaths.map((p) => join8(root, p)) };
8390
9170
  }
8391
9171
  return null;
8392
9172
  }
@@ -8422,7 +9202,7 @@ var CHECK_NAME = "exec-bits";
8422
9202
  var EXECUTABLE_MODE = "100755";
8423
9203
  function git2(args) {
8424
9204
  try {
8425
- return execFileSync7("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9205
+ return execFileSync6("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
8426
9206
  } catch {
8427
9207
  return null;
8428
9208
  }
@@ -8436,7 +9216,7 @@ function indexMode(path) {
8436
9216
  }
8437
9217
  function hasShebang(path) {
8438
9218
  try {
8439
- return readFileSync4(path, "utf8").startsWith("#!");
9219
+ return readFileSync6(path, "utf8").startsWith("#!");
8440
9220
  } catch {
8441
9221
  return false;
8442
9222
  }