@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
@@ -3,8 +3,8 @@ import { createRequire } from "node:module";
3
3
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
4
4
 
5
5
  // src/checks/bin/check-workspace-escape.ts
6
- import { readdirSync, readFileSync as readFileSync4, statSync } from "node:fs";
7
- import { join as join6 } from "node:path";
6
+ import { readdirSync as readdirSync2, readFileSync as readFileSync6, statSync as statSync2 } from "node:fs";
7
+ import { join as join9 } from "node:path";
8
8
  // ../../packages/aeg-core/src/gate-audience.ts
9
9
  var GATE_AUDIENCE = {
10
10
  "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
@@ -1038,7 +1038,7 @@ function withDefaults(oldDefaults, newDefaults) {
1038
1038
  var endpoint = withDefaults(null, DEFAULTS);
1039
1039
 
1040
1040
  // ../../node_modules/fast-content-type-parse/index.js
1041
- var NullObject = function NullObject2() {};
1041
+ var NullObject = function NullObject() {};
1042
1042
  NullObject.prototype = Object.create(null);
1043
1043
  var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu;
1044
1044
  var quotedPairRE = /\\([\v\u0020-\u00ff])/gu;
@@ -1132,8 +1132,8 @@ function isPlainObject2(value) {
1132
1132
  return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
1133
1133
  }
1134
1134
  async function fetchWrapper(requestOptions) {
1135
- const fetch = requestOptions.request?.fetch || globalThis.fetch;
1136
- if (!fetch) {
1135
+ const fetch2 = requestOptions.request?.fetch || globalThis.fetch;
1136
+ if (!fetch2) {
1137
1137
  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");
1138
1138
  }
1139
1139
  const log = requestOptions.request?.log || console;
@@ -1145,7 +1145,7 @@ async function fetchWrapper(requestOptions) {
1145
1145
  ]));
1146
1146
  let fetchResponse;
1147
1147
  try {
1148
- fetchResponse = await fetch(requestOptions.url, {
1148
+ fetchResponse = await fetch2(requestOptions.url, {
1149
1149
  method: requestOptions.method,
1150
1150
  body,
1151
1151
  redirect: requestOptions.request?.redirect,
@@ -1782,27 +1782,27 @@ function splitTableRow(row) {
1782
1782
  return parts.map((p) => p.split(PLACEHOLDER).join("|"));
1783
1783
  }
1784
1784
  // ../../packages/aeg-core/src/blast-radius-domains.ts
1785
- function resolveWorkspaceEntry(entry2, listDirs) {
1786
- if (entry2.endsWith("/*")) {
1787
- const baseDir = entry2.slice(0, -2);
1785
+ function resolveWorkspaceEntry(entry, listDirs) {
1786
+ if (entry.endsWith("/*")) {
1787
+ const baseDir = entry.slice(0, -2);
1788
1788
  return listDirs(baseDir).map((name) => `${baseDir}/${name}`);
1789
1789
  }
1790
- if (entry2.includes("*"))
1790
+ if (entry.includes("*"))
1791
1791
  return [];
1792
- return [entry2];
1792
+ return [entry];
1793
1793
  }
1794
1794
  // ../../packages/aeg-core/src/consumer-enumeration.ts
1795
1795
  function deriveWorkspaceMemberDirs(workspaces, listDirs) {
1796
- const positive = workspaces.filter((entry2) => !entry2.startsWith("!"));
1797
- const negative = workspaces.filter((entry2) => entry2.startsWith("!")).map((entry2) => entry2.slice(1));
1796
+ const positive = workspaces.filter((entry) => !entry.startsWith("!"));
1797
+ const negative = workspaces.filter((entry) => entry.startsWith("!")).map((entry) => entry.slice(1));
1798
1798
  const excluded = new Set;
1799
- for (const entry2 of negative) {
1800
- for (const member of resolveWorkspaceEntry(entry2, listDirs))
1799
+ for (const entry of negative) {
1800
+ for (const member of resolveWorkspaceEntry(entry, listDirs))
1801
1801
  excluded.add(member);
1802
1802
  }
1803
1803
  const members = new Set;
1804
- for (const entry2 of positive) {
1805
- for (const member of resolveWorkspaceEntry(entry2, listDirs)) {
1804
+ for (const entry of positive) {
1805
+ for (const member of resolveWorkspaceEntry(entry, listDirs)) {
1806
1806
  if (!excluded.has(member))
1807
1807
  members.add(member);
1808
1808
  }
@@ -2048,12 +2048,24 @@ function extractBaseSha(comment) {
2048
2048
  const m = firstThirteenLines(comment).match(BASE_SHA_PATTERN);
2049
2049
  return m ? m[1].toLowerCase() : null;
2050
2050
  }
2051
- var FINDING_SEVERITY_LINE = /^\d+\.\s+\[([A-Z][A-Z]*)\]\s+(.+?)\s+—/gm;
2051
+ var FINDING_DESCRIPTION_STATE = /^F(\d+)(?:\s+\S+)?(?:\s+(open|fix-claimed|reproduced|resolved))?:/;
2052
+ function parseFindingState(description) {
2053
+ const m = FINDING_DESCRIPTION_STATE.exec(description.trim());
2054
+ if (!m)
2055
+ return { id: null, state: null };
2056
+ return { id: `F${m[1]}`, state: m[2] ?? null };
2057
+ }
2058
+ var FINDING_SEVERITY_LINE = /^\d+\.\s+\[([A-Z][A-Z]*)\]\s+(.+?)\s+—(?:\s+(.*))?$/gm;
2052
2059
  function extractFindingSeverities(comment) {
2053
- return [...comment.matchAll(FINDING_SEVERITY_LINE)].map((m) => ({
2054
- severity: m[1],
2055
- location: m[2]
2056
- }));
2060
+ return [...comment.matchAll(FINDING_SEVERITY_LINE)].map((m) => {
2061
+ const { id, state } = parseFindingState(m[3] ?? "");
2062
+ return {
2063
+ severity: m[1],
2064
+ location: m[2],
2065
+ id,
2066
+ state
2067
+ };
2068
+ });
2057
2069
  }
2058
2070
  function extractVerdict(comments, valuePattern, missingLabel) {
2059
2071
  const candidates = comments.filter((c) => valuePattern.test(c));
@@ -2126,15 +2138,15 @@ function summarizeTranscript(jsonl) {
2126
2138
  const line = rawLine.trim();
2127
2139
  if (!line)
2128
2140
  continue;
2129
- let entry2;
2141
+ let entry;
2130
2142
  try {
2131
- entry2 = JSON.parse(line);
2143
+ entry = JSON.parse(line);
2132
2144
  } catch {
2133
2145
  continue;
2134
2146
  }
2135
- if (!entry2 || typeof entry2 !== "object")
2147
+ if (!entry || typeof entry !== "object")
2136
2148
  continue;
2137
- const obj = entry2;
2149
+ const obj = entry;
2138
2150
  if (obj.type !== "assistant")
2139
2151
  continue;
2140
2152
  const message = obj.message;
@@ -2467,6 +2479,12 @@ function evaluateReviewFindings(findings, scale, threshold) {
2467
2479
  });
2468
2480
  return { outcome: blockingFindings.length > 0 ? "blocked" : "clean", blockingFindings };
2469
2481
  }
2482
+ function isConsequentialFinding(finding) {
2483
+ return finding.state !== "resolved";
2484
+ }
2485
+ function consequentialFindings(findings) {
2486
+ return findings.filter((f) => isConsequentialFinding(f));
2487
+ }
2470
2488
  function evaluateCodeReview(findings, policy) {
2471
2489
  return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold);
2472
2490
  }
@@ -2982,7 +3000,7 @@ function isStep0Block(content) {
2982
3000
  }
2983
3001
  function checkCommandsCarryOutput(prBody) {
2984
3002
  const errors = [];
2985
- for (const [label2, num] of [
3003
+ for (const [label, num] of [
2986
3004
  ["5", 5],
2987
3005
  ["6", 6]
2988
3006
  ]) {
@@ -2996,7 +3014,7 @@ function checkCommandsCarryOutput(prBody) {
2996
3014
  continue;
2997
3015
  const next = blocks[i + 1];
2998
3016
  if (!next || isCommandBlock(next.content)) {
2999
- 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.`);
3017
+ 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.`);
3000
3018
  }
3001
3019
  }
3002
3020
  }
@@ -3433,8 +3451,8 @@ function stripPartBackticks(text) {
3433
3451
  function partWordCount(text) {
3434
3452
  return text.split(/\s+/).filter((w) => /[a-z]/i.test(w)).length;
3435
3453
  }
3436
- function looksLikeFilePath(entry2) {
3437
- const stripped = entry2.replace(/\/\*\*?$/, "");
3454
+ function looksLikeFilePath(entry) {
3455
+ const stripped = entry.replace(/\/\*\*?$/, "");
3438
3456
  const lastSegment = stripped.split("/").pop() ?? stripped;
3439
3457
  const extMatch = /\.[A-Za-z0-9]{1,6}$/.exec(lastSegment);
3440
3458
  return extMatch !== null && extMatch.index > 0;
@@ -3920,14 +3938,14 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
3920
3938
  const referenced = extractClosesReferences(prBody);
3921
3939
  if (taskIssueRefs) {
3922
3940
  for (const n of referenced) {
3923
- const ref2 = taskIssueRefs.get(n);
3924
- if (!ref2)
3941
+ const ref = taskIssueRefs.get(n);
3942
+ if (!ref)
3925
3943
  continue;
3926
- const expectedBranch = `task/${ref2.trancheSlug}/${ref2.taskId}`;
3944
+ const expectedBranch = `task/${ref.trancheSlug}/${ref.taskId}`;
3927
3945
  if (branch !== expectedBranch) {
3928
3946
  return {
3929
3947
  ok: false,
3930
- 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.`
3948
+ 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.`
3931
3949
  };
3932
3950
  }
3933
3951
  }
@@ -3936,15 +3954,15 @@ function checkClosesNTopology(branch, prBody, trancheFiles, taskIssueRefs) {
3936
3954
  if (!ref)
3937
3955
  return { ok: true };
3938
3956
  if (ref.kind === "issue") {
3939
- const expectedIssue2 = ref.issueNumber;
3940
- if (!referenced.has(expectedIssue2)) {
3957
+ const expectedIssue = ref.issueNumber;
3958
+ if (!referenced.has(expectedIssue)) {
3941
3959
  return {
3942
3960
  ok: false,
3943
- expectedIssue: expectedIssue2,
3944
- message: `closes-n: PR body does not contain \`Closes #${expectedIssue2}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
3961
+ expectedIssue,
3962
+ message: `closes-n: PR body does not contain \`Closes #${expectedIssue}\` (required for branch "${branch}"). Add it to the PR body Summary section.`
3945
3963
  };
3946
3964
  }
3947
- return { ok: true, expectedIssue: expectedIssue2 };
3965
+ return { ok: true, expectedIssue };
3948
3966
  }
3949
3967
  const trancheSlug = ref.tranche;
3950
3968
  const taskId = ref.taskId;
@@ -3990,8 +4008,8 @@ function extractIssue(body) {
3990
4008
  const anchorNums = closesRefs(anchored);
3991
4009
  if (anchorNums.length === 0)
3992
4010
  return { issue: null, extraIssues: bodyNums, outsideHeader: false };
3993
- const issue2 = anchorNums[0];
3994
- return { issue: issue2, extraIssues: bodyNums.filter((n) => n !== issue2), outsideHeader: false };
4011
+ const issue = anchorNums[0];
4012
+ return { issue, extraIssues: bodyNums.filter((n) => n !== issue), outsideHeader: false };
3995
4013
  }
3996
4014
  const headerNums = closesRefs(headerRegion(stripped));
3997
4015
  if (bodyNums.length === 0)
@@ -4060,15 +4078,15 @@ function compareManifest(echoed, current, patchIdOf) {
4060
4078
  const bothFullShas = echoedShaLen >= 40 && currentShaLen >= 40;
4061
4079
  const base = patchHead || exactHead && bothFullShas ? true : isBoundToBase(echoed, current.baseSha);
4062
4080
  const briefHashBound = isBoundToBriefHash(echoed, current.briefHash);
4063
- const objectivesVersion2 = isBoundToObjectives(echoed, current.objectivesVersion);
4081
+ const objectivesVersion = isBoundToObjectives(echoed, current.objectivesVersion);
4064
4082
  const rulingOrdinal = isBoundToRulings(echoed, current.rulingOrdinal);
4065
4083
  const policyDigestBound = isBoundToPolicy(echoed, current.policyDigest);
4066
4084
  return {
4067
- bound: head && base && briefHashBound && objectivesVersion2 && rulingOrdinal && policyDigestBound,
4085
+ bound: head && base && briefHashBound && objectivesVersion && rulingOrdinal && policyDigestBound,
4068
4086
  head,
4069
4087
  base,
4070
4088
  briefHash: briefHashBound,
4071
- objectivesVersion: objectivesVersion2,
4089
+ objectivesVersion,
4072
4090
  rulingOrdinal,
4073
4091
  policyDigest: policyDigestBound
4074
4092
  };
@@ -4099,8 +4117,8 @@ function checkReviewGate(input) {
4099
4117
  let codeReviewPolicyEvaluation;
4100
4118
  let securityPolicyEvaluation;
4101
4119
  try {
4102
- codeReviewPolicyEvaluation = evaluateCodeReview(codeReview.findingSeverities, policy);
4103
- securityPolicyEvaluation = evaluateSecurityReview(security.findingSeverities, policy);
4120
+ codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy);
4121
+ securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy);
4104
4122
  } catch (err) {
4105
4123
  return {
4106
4124
  verdict: "fail",
@@ -5181,11 +5199,27 @@ var ObservedSchema = z.object({
5181
5199
  var TaskStatusInputSchema = z.object({
5182
5200
  task: TaskToolRefSchema.optional()
5183
5201
  }).merge(PageRequestSchema).strict();
5202
+ var TaskConfidenceSchema = z.object({
5203
+ round: z.number().int().positive(),
5204
+ percent: z.number().int().min(0).max(100).nullable(),
5205
+ source: z.enum(["stated", "published-summary"])
5206
+ }).strict();
5207
+ var TaskPhaseHistorySchema = z.object({
5208
+ typicalPhaseMinutes: z.number().nonnegative(),
5209
+ typicalPhaseSamples: z.number().int().positive()
5210
+ }).strict();
5184
5211
  var TaskStatusItemSchema = z.object({
5185
5212
  task: TaskToolRefSchema,
5186
5213
  issue: z.number().int().positive(),
5187
5214
  pr: z.number().int().positive().nullable(),
5188
- state: z.string()
5215
+ state: z.string(),
5216
+ round: z.number().int().positive().nullable().optional(),
5217
+ phase: z.string().min(1).nullable().optional(),
5218
+ minutesInPhase: z.number().nonnegative().nullable().optional(),
5219
+ phaseIsCurrent: z.boolean().nullable().optional(),
5220
+ lastConfidence: TaskConfidenceSchema.nullable().optional(),
5221
+ lastConfidenceUnread: z.boolean().optional(),
5222
+ phaseHistory: TaskPhaseHistorySchema.nullable().optional()
5189
5223
  }).merge(ObservedSchema);
5190
5224
  var TaskStatusResultSchema = z.object({
5191
5225
  items: z.array(TaskStatusItemSchema),
@@ -5197,7 +5231,7 @@ var EscalationInputsSchema = z.object({
5197
5231
  round: z.number().int().nonnegative(),
5198
5232
  head: z.string(),
5199
5233
  branch: z.string(),
5200
- prNumber: z.number().int().positive()
5234
+ prNumber: z.number().int().positive().nullable()
5201
5235
  });
5202
5236
  var EscalationEvidenceSchema = z.object({
5203
5237
  round: z.number().int().nonnegative(),
@@ -5233,13 +5267,45 @@ var TaskEscalationReadResultSchema = z.object({
5233
5267
  items: z.array(TaskEscalationPacketSchema),
5234
5268
  nextCursor: z.string().nullable()
5235
5269
  }).merge(ObservedSchema);
5236
- var TaskStartInputSchema = z.object({
5237
- tranche: z.string().min(1),
5238
- id: z.string().min(1)
5270
+ var TaskPrCheckSchema = z.object({
5271
+ name: z.string(),
5272
+ required: z.boolean(),
5273
+ status: z.string(),
5274
+ conclusion: z.string().nullable(),
5275
+ detailsUrl: z.string().nullable(),
5276
+ failureSummary: z.string().nullable()
5277
+ });
5278
+ var TaskPrVerdictSchema = z.object({
5279
+ role: z.enum(["code-review", "security"]),
5280
+ value: z.string(),
5281
+ judgedHead: z.string().nullable(),
5282
+ objectivesVersion: z.string().nullable()
5283
+ });
5284
+ var TaskPrPauseSchema = z.object({
5285
+ reason: z.string(),
5286
+ body: z.string()
5287
+ });
5288
+ var TaskPrReviewRecordSchema = z.object({
5289
+ verdicts: z.array(TaskPrVerdictSchema),
5290
+ roundMarkers: z.array(z.number().int().nonnegative()),
5291
+ summaryTable: z.string().nullable(),
5292
+ pause: TaskPrPauseSchema.nullable()
5293
+ });
5294
+ var TaskPrReadInputSchema = z.object({
5295
+ task: TaskToolRefSchema,
5296
+ pr: z.number().int().positive().optional()
5239
5297
  }).strict();
5298
+ var TaskPrReadResultSchema = z.object({
5299
+ task: TaskToolRefSchema,
5300
+ issue: z.number().int().positive(),
5301
+ pr: z.number().int().positive(),
5302
+ head: z.string().nullable(),
5303
+ checks: z.array(TaskPrCheckSchema),
5304
+ review: TaskPrReviewRecordSchema
5305
+ }).merge(ObservedSchema);
5240
5306
  var TaskStartResultSchema = z.object({
5241
5307
  requestId: z.string().min(1),
5242
- run: z.object({ tranche: z.string().min(1), id: z.string().min(1) }),
5308
+ run: TaskToolRefSchema,
5243
5309
  started: z.boolean(),
5244
5310
  startedAt: z.string(),
5245
5311
  mode: z.literal("attended")
@@ -5253,7 +5319,7 @@ var TaskCancelInputSchema = z.object({
5253
5319
  }).strict();
5254
5320
  var TaskResumeResultSchema = z.object({
5255
5321
  task: z.number().int().positive(),
5256
- pr: z.number().int().positive(),
5322
+ pr: z.number().int().positive().nullable(),
5257
5323
  escalationId: z.string().min(1),
5258
5324
  outcome: z.enum(["started", "already_resumed"]),
5259
5325
  authenticatedBy: z.string().min(1),
@@ -5262,7 +5328,7 @@ var TaskResumeResultSchema = z.object({
5262
5328
  var TaskCancelOutcomeSchema = z.enum(["confirmed", "pending", "uncertain"]);
5263
5329
  var TaskCancelResultSchema = z.object({
5264
5330
  task: z.number().int().positive(),
5265
- pr: z.number().int().positive(),
5331
+ pr: z.number().int().positive().nullable(),
5266
5332
  escalationId: z.string().min(1),
5267
5333
  outcome: TaskCancelOutcomeSchema,
5268
5334
  authenticatedBy: z.string().min(1),
@@ -5273,6 +5339,7 @@ var TASK_TOOL_NAMES = [
5273
5339
  "task_start",
5274
5340
  "task_status",
5275
5341
  "task_escalation_read",
5342
+ "task_pr_read",
5276
5343
  "task_resume",
5277
5344
  "task_cancel"
5278
5345
  ];
@@ -5500,6 +5567,10 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
5500
5567
  }
5501
5568
  return findings;
5502
5569
  }
5570
+ // ../../packages/aeg-core/src/dev-review-loop/types.ts
5571
+ var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5572
+ // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
5573
+ var SUMMARY_TABLE_HEADER = `| round | ${SEVERITY_COLUMNS.join(" | ")} | confidence | outcome |`;
5503
5574
  // ../../packages/aeg-core/src/log/envelope.ts
5504
5575
  import { createHash as createHash5 } from "node:crypto";
5505
5576
 
@@ -6038,6 +6109,7 @@ function redact(value, home) {
6038
6109
  return value;
6039
6110
  }
6040
6111
  // ../../packages/aeg-core/src/log/store.ts
6112
+ var KNOWN_SCHEMA_VERSIONS = [1, 2];
6041
6113
  function metaOf(obj) {
6042
6114
  if (obj === null || typeof obj !== "object")
6043
6115
  return null;
@@ -6060,11 +6132,61 @@ function recordIdentity(obj) {
6060
6132
  }
6061
6133
  return null;
6062
6134
  }
6063
-
6064
- // ../../packages/aeg-core/src/log/artifact.ts
6065
- var TASK_LOG_ARTIFACT_MAX_BYTES = 8 * 1024 * 1024;
6066
- // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
6067
- var STOPPED_CONDITIONS = new Set(["confidence", "reappearance", "no_progress", "max_rounds"]);
6135
+ function schemaVersionOf(obj) {
6136
+ const meta = metaOf(obj);
6137
+ const schema = meta?.schema;
6138
+ return typeof schema === "number" ? schema : null;
6139
+ }
6140
+ function isKnownSchema(version) {
6141
+ return version !== null && KNOWN_SCHEMA_VERSIONS.includes(version);
6142
+ }
6143
+ function classifyStoredLine(raw, home) {
6144
+ let obj;
6145
+ try {
6146
+ obj = JSON.parse(raw);
6147
+ } catch {
6148
+ return { status: "invalid", identity: null, raw, reason: "not valid JSON" };
6149
+ }
6150
+ const version = schemaVersionOf(obj);
6151
+ if (version === null) {
6152
+ return { status: "invalid", identity: recordIdentity(obj), raw, reason: "no readable meta.schema" };
6153
+ }
6154
+ if (!isKnownSchema(version)) {
6155
+ return {
6156
+ status: "unknown_version",
6157
+ identity: recordIdentity(obj),
6158
+ schema: version,
6159
+ raw,
6160
+ reason: `schema version ${version} is not one this build validates (${KNOWN_SCHEMA_VERSIONS.join(", ")}) — kept for diagnosis`
6161
+ };
6162
+ }
6163
+ const result = LogEventSchema.safeParse(obj);
6164
+ if (!result.success) {
6165
+ return {
6166
+ status: "invalid",
6167
+ identity: recordIdentity(obj),
6168
+ raw,
6169
+ reason: result.error.issues[0]?.message ?? "schema violation"
6170
+ };
6171
+ }
6172
+ const event = result.data;
6173
+ const identity = recordIdentity(event);
6174
+ if (identity === null) {
6175
+ return { status: "invalid", identity: null, raw, reason: "valid event with no derivable identity" };
6176
+ }
6177
+ const redacted = redact(event, home);
6178
+ const provenance = version === 2 ? event.meta.provenance ?? null : null;
6179
+ return {
6180
+ status: "ok",
6181
+ identity,
6182
+ runId: event.meta.run_id,
6183
+ seq: event.meta.seq,
6184
+ schema: version,
6185
+ provenance,
6186
+ event,
6187
+ postLine: JSON.stringify(redacted)
6188
+ };
6189
+ }
6068
6190
  // ../../packages/aeg-core/src/control-store/records.ts
6069
6191
  import { z as z3 } from "zod";
6070
6192
  var isoTimestamp = z3.string().min(1);
@@ -6195,11 +6317,12 @@ var ResolutionRecordSchema = z3.object({
6195
6317
  consumedAt: isoTimestamp
6196
6318
  }).strict();
6197
6319
  // src/lib/diff-evidence.ts
6198
- import { execFileSync as execFileSync6 } from "node:child_process";
6199
- import { join as join5, relative, resolve as resolve2 } from "node:path";
6320
+ import { execFileSync as execFileSync5 } from "node:child_process";
6321
+ import { join as join8, relative, resolve as resolve2 } from "node:path";
6200
6322
 
6201
6323
  // src/lib/config.ts
6202
- import { execFileSync as execFileSync2 } from "node:child_process";
6324
+ import { execFile as execFile4, execFileSync as execFileSync2 } from "node:child_process";
6325
+ import { promisify as promisify4 } from "node:util";
6203
6326
  import { existsSync, mkdirSync, readFileSync as readFileSync2, realpathSync, writeFileSync } from "node:fs";
6204
6327
  import { homedir } from "node:os";
6205
6328
  import { dirname, isAbsolute, join, resolve } from "node:path";
@@ -6226,10 +6349,10 @@ var CheckEntrySchema = z4.object({
6226
6349
  ownWorkflow: z4.boolean().optional(),
6227
6350
  principalOwed: z4.literal(true).optional(),
6228
6351
  validates: z4.enum(["body", "issue"]).optional()
6229
- }).superRefine((entry2, ctx) => {
6230
- if (!entry2.env)
6352
+ }).superRefine((entry, ctx) => {
6353
+ if (!entry.env)
6231
6354
  return;
6232
- for (const [key, value] of Object.entries(entry2.env)) {
6355
+ for (const [key, value] of Object.entries(entry.env)) {
6233
6356
  if (typeof value !== "object" || value === null || !("anyOf" in value))
6234
6357
  continue;
6235
6358
  const members = value.anyOf;
@@ -6386,18 +6509,19 @@ var VinayaConfigSchema = z4.object({
6386
6509
  });
6387
6510
  }
6388
6511
  }).optional(),
6389
- logPublish: z4.object({
6390
- issue: z4.number().int().positive().optional(),
6391
- pr: z4.number().int().positive().optional(),
6392
- webhookUrl: z4.string().url().optional(),
6393
- headers: z4.record(z4.string()).optional(),
6394
- maxChunksPerFlush: z4.number().int().positive().optional()
6395
- }).refine((v) => [v.issue, v.pr, v.webhookUrl].filter((x) => x !== undefined).length <= 1, {
6396
- message: "logPublish: set at most one of issue/pr/webhookUrl"
6397
- }).refine((v) => v.headers === undefined || v.webhookUrl !== undefined, {
6398
- message: "logPublish: headers requires webhookUrl"
6399
- }).optional(),
6400
- runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional()
6512
+ logPublish: z4.unknown().refine((v) => v === undefined, {
6513
+ message: "logPublish is removed — telemetry is never posted to a tracker or a code host; configure `logs` instead (a folder or a server destination)"
6514
+ }),
6515
+ runtimeDir: z4.string().min(1).refine((v) => isAbsolute(v), { message: "runtimeDir: must be an absolute path" }).optional(),
6516
+ logs: z4.object({
6517
+ folder: z4.string().min(1).refine((v) => isAbsolute(v), { message: "logs.folder: must be an absolute path" }).optional(),
6518
+ url: z4.string().url().optional(),
6519
+ headers: z4.record(z4.string()).optional()
6520
+ }).refine((v) => [v.folder, v.url].filter((x) => x !== undefined).length <= 1, {
6521
+ message: "logs: set at most one of folder/url"
6522
+ }).refine((v) => v.headers === undefined || v.url !== undefined, {
6523
+ message: "logs: headers requires url"
6524
+ }).optional()
6401
6525
  });
6402
6526
  var GLOBAL_VINAYA_HOME = join(homedir(), ".vinaya");
6403
6527
  var GLOBAL_CONFIG_PATH = join(GLOBAL_VINAYA_HOME, "config.json");
@@ -6442,32 +6566,39 @@ function globalTokensCollectIgnoredWarning(path) {
6442
6566
  function globalRuntimeDirIgnoredWarning(path) {
6443
6567
  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.`;
6444
6568
  }
6569
+ var emittedGlobalKeyWarnings = new Set;
6570
+ function warnGlobalKeyIgnoredOnce(message) {
6571
+ if (emittedGlobalKeyWarnings.has(message))
6572
+ return;
6573
+ emittedGlobalKeyWarnings.add(message);
6574
+ console.error(`⚠ ${message}`);
6575
+ }
6445
6576
  function stripGlobalOnlyKeys(config, path) {
6446
6577
  if (path !== GLOBAL_CONFIG_PATH)
6447
6578
  return config;
6448
6579
  let result = config;
6449
6580
  if (result.checks && Object.keys(result.checks).length > 0) {
6450
- console.error(`⚠ ${globalChecksIgnoredWarning(path)}`);
6581
+ warnGlobalKeyIgnoredOnce(globalChecksIgnoredWarning(path));
6451
6582
  result = { ...result, checks: undefined };
6452
6583
  }
6453
6584
  if (result.roles && Object.keys(result.roles).length > 0) {
6454
- console.error(`⚠ ${globalRolesIgnoredWarning(path)}`);
6585
+ warnGlobalKeyIgnoredOnce(globalRolesIgnoredWarning(path));
6455
6586
  result = { ...result, roles: undefined };
6456
6587
  }
6457
6588
  if (result.principals && result.principals.length > 0) {
6458
- console.error(`⚠ ${globalPrincipalsIgnoredWarning(path)}`);
6589
+ warnGlobalKeyIgnoredOnce(globalPrincipalsIgnoredWarning(path));
6459
6590
  result = { ...result, principals: undefined };
6460
6591
  }
6461
6592
  if (result.releaseActor) {
6462
- console.error(`⚠ ${globalReleaseActorIgnoredWarning(path)}`);
6593
+ warnGlobalKeyIgnoredOnce(globalReleaseActorIgnoredWarning(path));
6463
6594
  result = { ...result, releaseActor: undefined };
6464
6595
  }
6465
6596
  if (result.tokens) {
6466
- console.error(`⚠ ${globalTokensCollectIgnoredWarning(path)}`);
6597
+ warnGlobalKeyIgnoredOnce(globalTokensCollectIgnoredWarning(path));
6467
6598
  result = { ...result, tokens: undefined };
6468
6599
  }
6469
6600
  if (result.runtimeDir) {
6470
- console.error(`⚠ ${globalRuntimeDirIgnoredWarning(path)}`);
6601
+ warnGlobalKeyIgnoredOnce(globalRuntimeDirIgnoredWarning(path));
6471
6602
  result = { ...result, runtimeDir: undefined };
6472
6603
  }
6473
6604
  return result;
@@ -6500,26 +6631,102 @@ function resolveReviewPolicy(config) {
6500
6631
  maxRounds
6501
6632
  };
6502
6633
  }
6503
- function trustAnchorRepo() {
6504
- const wellFormed = (slug) => /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
6505
- const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
6506
- if (fromRunner) {
6507
- const validated = wellFormed(fromRunner);
6508
- if (validated)
6509
- return validated;
6634
+ function resolveRuntimeDirSetting(config) {
6635
+ return config?.runtimeDir ?? null;
6636
+ }
6637
+ function resolveTrustAnchorRuntimeDir(localRuntimeDir, trustAnchorConfig) {
6638
+ const anchored = resolveRuntimeDirSetting(trustAnchorConfig);
6639
+ return anchored !== null && anchored === localRuntimeDir ? anchored : null;
6640
+ }
6641
+ function resolveLogsSetting(config) {
6642
+ const raw = config?.logs;
6643
+ if (!raw)
6644
+ return null;
6645
+ if (raw.url !== undefined)
6646
+ return { url: raw.url, headers: raw.headers };
6647
+ if (raw.folder !== undefined)
6648
+ return { folder: raw.folder };
6649
+ return null;
6650
+ }
6651
+ function resolveTrustAnchorLogsDestination(local, trustAnchorConfig) {
6652
+ const anchored = resolveLogsSetting(trustAnchorConfig);
6653
+ if (!anchored)
6654
+ return null;
6655
+ if ("url" in local)
6656
+ return "url" in anchored && anchored.url === local.url ? anchored : null;
6657
+ return "folder" in anchored && anchored.folder === local.folder ? anchored : null;
6658
+ }
6659
+ function resolveLogsHeaderValues(headers, env) {
6660
+ if (!headers)
6661
+ return;
6662
+ const resolved = {};
6663
+ for (const [key, value] of Object.entries(headers)) {
6664
+ resolved[key] = value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, name) => env[name] ?? "");
6510
6665
  }
6666
+ return resolved;
6667
+ }
6668
+ function trustAnchorRepo() {
6669
+ const fromRunner = trustAnchorRepoFromRunner();
6670
+ if (fromRunner)
6671
+ return fromRunner;
6511
6672
  try {
6512
6673
  const url = execFileSync2("git", ["remote", "get-url", "origin"], {
6513
6674
  encoding: "utf-8",
6514
6675
  stdio: ["ignore", "pipe", "pipe"]
6515
- }).trim();
6516
- const m = url.match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
6517
- return m?.[1] && m[2] ? wellFormed(`${m[1]}/${m[2]}`) : null;
6676
+ });
6677
+ return trustAnchorRepoFromRemoteUrl(url);
6678
+ } catch {
6679
+ return null;
6680
+ }
6681
+ }
6682
+ async function trustAnchorRepoAsync() {
6683
+ const fromRunner = trustAnchorRepoFromRunner();
6684
+ if (fromRunner)
6685
+ return fromRunner;
6686
+ try {
6687
+ const { stdout } = await execFileAsync4("git", ["remote", "get-url", "origin"], {
6688
+ encoding: "utf-8",
6689
+ timeout: 1e4
6690
+ });
6691
+ return trustAnchorRepoFromRemoteUrl(stdout);
6518
6692
  } catch {
6519
6693
  return null;
6520
6694
  }
6521
6695
  }
6696
+ function wellFormedRepoSlug(slug) {
6697
+ return /^[^/\s]+\/[^/\s]+$/.test(slug) ? slug : null;
6698
+ }
6699
+ function trustAnchorRepoFromRunner() {
6700
+ const fromRunner = process.env.GITHUB_REPOSITORY?.trim();
6701
+ return fromRunner ? wellFormedRepoSlug(fromRunner) : null;
6702
+ }
6703
+ function trustAnchorRepoFromRemoteUrl(url) {
6704
+ const m = url.trim().match(/github\.com[:/]([^/]+)\/(.+?)(?:\.git)?\/?$/);
6705
+ return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
6706
+ }
6707
+ var execFileAsync4 = promisify4(execFile4);
6708
+ function resolveCiTrustAnchorProbeRef(env = process.env) {
6709
+ const ref = env.VINAYA_CI_CONFIG_PROBE_REF?.trim();
6710
+ if (!ref)
6711
+ return null;
6712
+ if (env.GITHUB_ACTIONS !== "true")
6713
+ return null;
6714
+ if ((env.GH_TOKEN ?? "").length > 0 || (env.GITHUB_TOKEN ?? "").length > 0)
6715
+ return null;
6716
+ return ref;
6717
+ }
6718
+ function readTrustAnchorConfigAtRef(ref) {
6719
+ const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
6720
+ encoding: "utf-8",
6721
+ stdio: ["ignore", "pipe", "pipe"],
6722
+ timeout: 1e4
6723
+ });
6724
+ return Buffer.from(raw, "utf-8").toString("base64");
6725
+ }
6522
6726
  function ghFetchTrustAnchorConfig() {
6727
+ const probeRef = resolveCiTrustAnchorProbeRef();
6728
+ if (probeRef)
6729
+ return readTrustAnchorConfigAtRef(probeRef);
6523
6730
  const repo = trustAnchorRepo();
6524
6731
  if (!repo)
6525
6732
  throw new Error("could not resolve repo identity for the trust-anchor read");
@@ -6528,6 +6735,21 @@ function ghFetchTrustAnchorConfig() {
6528
6735
  stdio: ["ignore", "pipe", "pipe"]
6529
6736
  });
6530
6737
  }
6738
+ async function ghFetchTrustAnchorConfigAsync() {
6739
+ const probeRef = resolveCiTrustAnchorProbeRef();
6740
+ if (probeRef) {
6741
+ const { stdout } = await execFileAsync4("git", ["show", `${probeRef}:${LOCAL_CONFIG_FILENAME}`], {
6742
+ encoding: "utf-8",
6743
+ timeout: 1e4
6744
+ });
6745
+ return Buffer.from(stdout, "utf-8").toString("base64");
6746
+ }
6747
+ const repo = await trustAnchorRepoAsync();
6748
+ if (!repo)
6749
+ throw new Error("could not resolve repo identity for the trust-anchor read");
6750
+ const { stdout } = await execFileAsync4("gh", ["api", `repos/${repo}/contents/${LOCAL_CONFIG_FILENAME}`, "--jq", ".content"], { encoding: "utf-8", timeout: 1e4 });
6751
+ return stdout;
6752
+ }
6531
6753
  function firstLine(err) {
6532
6754
  return err?.message?.split(`
6533
6755
  `)[0] ?? "unknown error";
@@ -6542,16 +6764,35 @@ function isMissingFileError(err) {
6542
6764
  return /\b404\b|not found/i.test(haystack);
6543
6765
  }
6544
6766
  function loadTrustAnchorConfig(fetcher = ghFetchTrustAnchorConfig) {
6545
- 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.
6546
- `);
6547
6767
  let base64;
6548
6768
  try {
6549
- base64 = fetcher().trim();
6769
+ base64 = fetcher();
6550
6770
  } catch (err) {
6551
- if (!isMissingFileError(err))
6552
- warn(firstLine(err));
6553
- return null;
6771
+ return trustAnchorFetchFailed(err);
6554
6772
  }
6773
+ return parseTrustAnchorContent(base64);
6774
+ }
6775
+ async function loadTrustAnchorConfigAsync(fetcher = ghFetchTrustAnchorConfigAsync, options = {}) {
6776
+ const warn = options.quiet ? () => {} : warnTrustAnchorFallback;
6777
+ let base64;
6778
+ try {
6779
+ base64 = await fetcher();
6780
+ } catch (err) {
6781
+ return trustAnchorFetchFailed(err, warn);
6782
+ }
6783
+ return parseTrustAnchorContent(base64, warn);
6784
+ }
6785
+ function warnTrustAnchorFallback(why) {
6786
+ 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.
6787
+ `);
6788
+ }
6789
+ function trustAnchorFetchFailed(err, warn = warnTrustAnchorFallback) {
6790
+ if (!isMissingFileError(err))
6791
+ warn(firstLine(err));
6792
+ return null;
6793
+ }
6794
+ function parseTrustAnchorContent(content, warn = warnTrustAnchorFallback) {
6795
+ const base64 = content.trim();
6555
6796
  if (!base64)
6556
6797
  return null;
6557
6798
  try {
@@ -6581,6 +6822,8 @@ var TOKENS_COLLECT_TRUST_PATH = join(GLOBAL_VINAYA_HOME, "tokens-collect-trust.j
6581
6822
 
6582
6823
  // src/lib/brief-assembly.ts
6583
6824
  import { execFileSync as execFileSync4 } from "node:child_process";
6825
+ import { existsSync as existsSync3, readFileSync as readFileSync3, readdirSync } from "node:fs";
6826
+ import { join as join3 } from "node:path";
6584
6827
 
6585
6828
  // ../../packages/sources/src/commands.ts
6586
6829
  var COMMANDS = [
@@ -6733,10 +6976,10 @@ var COMMANDS = [
6733
6976
  }
6734
6977
  ],
6735
6978
  details: [
6736
- "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.",
6979
+ "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.",
6737
6980
  "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.",
6738
- "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.",
6739
- "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."
6981
+ "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.",
6982
+ "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`)."
6740
6983
  ],
6741
6984
  status: "shipped"
6742
6985
  },
@@ -6775,7 +7018,7 @@ var COMMANDS = [
6775
7018
  details: [
6776
7019
  "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.",
6777
7020
  "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.",
6778
- "`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."
7021
+ "`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."
6779
7022
  ],
6780
7023
  status: "shipped"
6781
7024
  },
@@ -6905,48 +7148,6 @@ var COMMANDS = [
6905
7148
  ],
6906
7149
  status: "shipped"
6907
7150
  },
6908
- {
6909
- name: "log flush",
6910
- description: "Post a target Issue or PR's outbox as one or more marked comments, then truncate what the forge confirmed",
6911
- flags: [
6912
- { flag: "--issue", description: "Flush this Issue's outbox (`~/.vinaya/outbox/<owner>-<repo>/<n>.ndjson`)" },
6913
- {
6914
- flag: "--pr",
6915
- description: "Flush the Issue named by this PR's `Closes #N` line, posting the comments on the PR"
6916
- },
6917
- { flag: "--json", description: "Enveloped JSON output (schema: 1)" }
6918
- ],
6919
- details: [
6920
- "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.",
6921
- "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.",
6922
- "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."
6923
- ],
6924
- status: "shipped"
6925
- },
6926
- {
6927
- name: "log export-artifact",
6928
- description: "Copy this run's own local outbox into a file, for the generated task-path workflow's own upload step",
6929
- flags: [],
6930
- details: [
6931
- "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.",
6932
- "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."
6933
- ],
6934
- status: "shipped"
6935
- },
6936
- {
6937
- name: "log collect-artifact",
6938
- description: "Validate a downloaded task-log artifact and publish the valid records through the existing flush path",
6939
- flags: [
6940
- { flag: "--pr", description: "The pull request this artifact belongs to" },
6941
- { flag: "--repo", description: "Expected `owner/repo` — a provenance cross-check against each record" }
6942
- ],
6943
- details: [
6944
- "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.",
6945
- "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.",
6946
- "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."
6947
- ],
6948
- status: "shipped"
6949
- },
6950
7151
  {
6951
7152
  name: "milestone create",
6952
7153
  description: "Create a GitHub Milestone from a validated body",
@@ -7276,7 +7477,7 @@ var COMMANDS = [
7276
7477
  { flag: "--task", description: "This dispatch's task Issue number — mutually exclusive with `--pr`" },
7277
7478
  {
7278
7479
  flag: "--pr",
7279
- description: "Flush the outbox to this PR's Issue after the dispatch — mutually exclusive with `--task`"
7480
+ description: "This dispatch's pull request number, for attribution — mutually exclusive with `--task`"
7280
7481
  },
7281
7482
  { flag: "--round", description: "Round number, for a dispatch inside a review loop" },
7282
7483
  {
@@ -7288,7 +7489,7 @@ var COMMANDS = [
7288
7489
  details: [
7289
7490
  "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.",
7290
7491
  "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`.",
7291
- "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.",
7492
+ "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.",
7292
7493
  "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."
7293
7494
  ],
7294
7495
  status: "shipped"
@@ -7308,7 +7509,8 @@ var COMMANDS = [
7308
7509
  "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> -->`.",
7309
7510
  "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.",
7310
7511
  "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.",
7311
- "Every dispatch and round transition is a log line through the Vinaya Log, flushed to the forge at each round boundary."
7512
+ "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.",
7513
+ "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)."
7312
7514
  ],
7313
7515
  status: "shipped"
7314
7516
  }
@@ -7445,25 +7647,6 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
7445
7647
  };
7446
7648
  }
7447
7649
 
7448
- // src/lib/brief-assembly.ts
7449
- function git(args) {
7450
- try {
7451
- return execFileSync4("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
7452
- } catch {
7453
- return "";
7454
- }
7455
- }
7456
- function expandGlob(glob) {
7457
- const out = git(["ls-files", "--", glob]);
7458
- return out.split(`
7459
- `).map((s) => s.trim()).filter(Boolean);
7460
- }
7461
- var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
7462
-
7463
- // src/checks/registry.ts
7464
- import { existsSync as existsSync3 } from "node:fs";
7465
- import { join as join3 } from "node:path";
7466
-
7467
7650
  // src/lib/package-root.ts
7468
7651
  import { existsSync as existsSync2 } from "node:fs";
7469
7652
  import { dirname as dirname2, join as join2 } from "node:path";
@@ -7481,13 +7664,33 @@ function packageRoot(moduleUrl) {
7481
7664
  return dir;
7482
7665
  }
7483
7666
 
7667
+ // src/lib/brief-assembly.ts
7668
+ var PACKAGE_ROOT = packageRoot(import.meta.url);
7669
+ var PACKAGED_TEMPLATE_PATH = join3(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
7670
+ var TEMPLATE_PATH = existsSync3(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join3(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
7671
+ function git(args) {
7672
+ try {
7673
+ return execFileSync4("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
7674
+ } catch {
7675
+ return "";
7676
+ }
7677
+ }
7678
+ function expandGlob(glob) {
7679
+ const out = git(["ls-files", "--", glob]);
7680
+ return out.split(`
7681
+ `).map((s) => s.trim()).filter(Boolean);
7682
+ }
7683
+ var DRAFT_ISSUE_SENTINEL = Number.MAX_SAFE_INTEGER;
7684
+
7484
7685
  // src/checks/registry.ts
7485
- var DIST_BIN_DIR = join3(packageRoot(import.meta.url), "dist", "checks", "bin");
7486
- var SRC_BIN_DIR = join3(packageRoot(import.meta.url), "src", "checks", "bin");
7487
- var BIN_DIR = existsSync3(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
7686
+ import { existsSync as existsSync4 } from "node:fs";
7687
+ import { join as join4 } from "node:path";
7688
+ var DIST_BIN_DIR = join4(packageRoot(import.meta.url), "dist", "checks", "bin");
7689
+ var SRC_BIN_DIR = join4(packageRoot(import.meta.url), "src", "checks", "bin");
7690
+ var BIN_DIR = existsSync4(DIST_BIN_DIR) ? DIST_BIN_DIR : SRC_BIN_DIR;
7488
7691
  var BIN_EXT = BIN_DIR === DIST_BIN_DIR ? ".js" : ".ts";
7489
7692
  function bin(name) {
7490
- return join3(BIN_DIR, `${name}${BIN_EXT}`);
7693
+ return join4(BIN_DIR, `${name}${BIN_EXT}`);
7491
7694
  }
7492
7695
  var REGISTRY = [
7493
7696
  [
@@ -7899,6 +8102,16 @@ var REGISTRY = [
7899
8102
  },
7900
8103
  0
7901
8104
  ],
8105
+ [
8106
+ {
8107
+ name: "ci-shard-coverage",
8108
+ run: bin("check-ci-shard-coverage"),
8109
+ scope: "diff",
8110
+ timeoutMs: 15000,
8111
+ env: {}
8112
+ },
8113
+ 0
8114
+ ],
7902
8115
  [
7903
8116
  {
7904
8117
  name: "workspace-escape",
@@ -8036,42 +8249,541 @@ function coreCheckRegistry() {
8036
8249
  var CORE_CHECK_RING = Object.fromEntries(REGISTRY.map(([spec, ring]) => [spec.name, ring]));
8037
8250
 
8038
8251
  // src/lib/log-sink.ts
8039
- import { execFileSync as execFileSync5 } from "node:child_process";
8040
- import { randomUUID } from "node:crypto";
8252
+ import { execFile as execFile5 } from "node:child_process";
8253
+ import { randomUUID as randomUUID2 } from "node:crypto";
8254
+ import {
8255
+ closeSync as closeSync3,
8256
+ constants as fsConstants3,
8257
+ existsSync as existsSync6,
8258
+ fstatSync as fstatSync2,
8259
+ mkdirSync as mkdirSync3,
8260
+ openSync as openSync3,
8261
+ readFileSync as readFileSync5,
8262
+ renameSync as renameSync2,
8263
+ writeSync as writeSync2
8264
+ } from "node:fs";
8265
+ import { hostname as osHostname, homedir as homedir3 } from "node:os";
8266
+ import { dirname as dirname5, join as join7 } from "node:path";
8267
+ import { promisify as promisify5 } from "node:util";
8268
+
8269
+ // src/lib/run-paths.ts
8270
+ import { chmodSync, existsSync as existsSync5, realpathSync as realpathSync2 } from "node:fs";
8271
+ import { dirname as dirname3, join as join5, resolve as resolvePath } from "node:path";
8272
+ var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8273
+ function isSafeRepoSegment(segment) {
8274
+ return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
8275
+ }
8276
+ function repoSegment(repo) {
8277
+ if (!repo || !isSafeRepoSegment(repo.owner) || !isSafeRepoSegment(repo.repo))
8278
+ return "unresolved";
8279
+ return `${repo.owner}-${repo.repo}`;
8280
+ }
8281
+ function defaultRuntimeDir(repo, home = GLOBAL_VINAYA_HOME) {
8282
+ return join5(home, "runtime", repoSegment(repo));
8283
+ }
8284
+ function resolveRuntimeDir(input) {
8285
+ const local = resolveRuntimeDirSetting(input.localConfig);
8286
+ if (local === null)
8287
+ return defaultRuntimeDir(input.repo, input.home);
8288
+ if (isInsideRepo(local, input.repoRoot))
8289
+ return defaultRuntimeDir(input.repo, input.home);
8290
+ if (!input.unattended)
8291
+ return local;
8292
+ const anchored = resolveTrustAnchorRuntimeDir(local, input.trustAnchorConfig ?? null);
8293
+ return anchored ?? defaultRuntimeDir(input.repo, input.home);
8294
+ }
8295
+ function isInsideRepo(candidate, repoRoot) {
8296
+ if (!repoRoot)
8297
+ return false;
8298
+ const root = resolvePath(repoRoot);
8299
+ const target = resolvePath(candidate);
8300
+ return target === root || target.startsWith(`${root}/`);
8301
+ }
8302
+ var UNATTENDED_ENV_KEY = "VINAYA_UNATTENDED";
8303
+ var RUNTIME_DIR_ENV_KEY = "VINAYA_RUNTIME_DIR";
8304
+ function isUnattendedProcess(env = process.env) {
8305
+ return env[UNATTENDED_ENV_KEY] === "1" || (env.VINAYA_ROLE ?? "") !== "";
8306
+ }
8307
+ var memoized = null;
8308
+ async function runtimeDirForRepoAsync(repo) {
8309
+ const key = repoSegment(repo);
8310
+ if (memoized?.key === key)
8311
+ return memoized.value;
8312
+ const inputs = runtimeDirInputs();
8313
+ if (typeof inputs === "string")
8314
+ return inputs;
8315
+ const value = resolveRuntimeDir({
8316
+ repo,
8317
+ ...inputs.base,
8318
+ trustAnchorConfig: inputs.needsAnchor ? await loadTrustAnchorConfigAsync() : null
8319
+ });
8320
+ memoized = { key, value };
8321
+ return value;
8322
+ }
8323
+ function runtimeDirInputs() {
8324
+ const handedDown = process.env[RUNTIME_DIR_ENV_KEY];
8325
+ if (handedDown)
8326
+ return handedDown;
8327
+ const localConfig = loadConfig();
8328
+ const unattended = isUnattendedProcess();
8329
+ return {
8330
+ base: { localConfig, unattended, repoRoot: repoRootSync() },
8331
+ needsAnchor: unattended && resolveRuntimeDirSetting(localConfig) !== null
8332
+ };
8333
+ }
8334
+ function repoRootSync(start = process.cwd()) {
8335
+ let dir;
8336
+ try {
8337
+ dir = realpathSync2(start);
8338
+ } catch {
8339
+ return null;
8340
+ }
8341
+ for (;; ) {
8342
+ if (existsSync5(join5(dir, ".git")))
8343
+ return dir;
8344
+ const parent = dirname3(dir);
8345
+ if (parent === dir)
8346
+ return null;
8347
+ dir = parent;
8348
+ }
8349
+ }
8350
+
8351
+ // src/lib/log-webhook-drain.ts
8041
8352
  import {
8042
8353
  closeSync as closeSync2,
8043
8354
  constants as fsConstants2,
8044
- existsSync as existsSync4,
8045
- fstatSync as fstatSync2,
8355
+ lstatSync,
8046
8356
  mkdirSync as mkdirSync2,
8047
8357
  openSync as openSync2,
8048
- readFileSync as readFileSync3,
8358
+ linkSync,
8359
+ readFileSync as readFileSync4,
8049
8360
  renameSync,
8361
+ statSync,
8362
+ unlinkSync,
8363
+ utimesSync,
8364
+ writeFileSync as writeFileSync2,
8050
8365
  writeSync
8051
8366
  } from "node:fs";
8052
- import { hostname as osHostname, homedir as homedir2 } from "node:os";
8053
- import { dirname as dirname3, join as join4 } from "node:path";
8054
- var OUTBOX_MAX_BYTES = 8 * 1024 * 1024;
8367
+ import { randomUUID } from "node:crypto";
8368
+ import { homedir as homedir2 } from "node:os";
8369
+ import { dirname as dirname4, join as join6 } from "node:path";
8370
+ var MAX_WEBHOOK_BODY_BYTES = 5 * 1024 * 1024;
8371
+ var WEBHOOK_FETCH_TIMEOUT_MS = 30000;
8372
+ var SAFE_PATH_SEGMENT2 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8373
+ function isSafeRepoSegment2(segment) {
8374
+ return SAFE_PATH_SEGMENT2.test(segment) && !segment.includes("..");
8375
+ }
8376
+ function isErrnoCode(err, code) {
8377
+ return typeof err === "object" && err !== null && err.code === code;
8378
+ }
8055
8379
  function isEnoent(err) {
8380
+ return isErrnoCode(err, "ENOENT");
8381
+ }
8382
+ var WEBHOOK_DRAIN_LOCK_STALE_MS = 4 * WEBHOOK_FETCH_TIMEOUT_MS;
8383
+ function tryCreateLock(lockPath, token) {
8384
+ try {
8385
+ mkdirSync2(dirname4(lockPath), { recursive: true, mode: 448 });
8386
+ const fd = openSync2(lockPath, fsConstants2.O_WRONLY | fsConstants2.O_CREAT | fsConstants2.O_EXCL, 384);
8387
+ try {
8388
+ writeSync(fd, `${token}
8389
+ `);
8390
+ } finally {
8391
+ closeSync2(fd);
8392
+ }
8393
+ return true;
8394
+ } catch (err) {
8395
+ if (isErrnoCode(err, "EEXIST"))
8396
+ return false;
8397
+ throw err;
8398
+ }
8399
+ }
8400
+ function acquireDrainLock(lockPath) {
8401
+ const token = `${process.pid}:${randomUUID()}`;
8402
+ if (tryCreateLock(lockPath, token))
8403
+ return token;
8404
+ let observedMtimeMs;
8405
+ try {
8406
+ observedMtimeMs = statSync(lockPath).mtimeMs;
8407
+ } catch (err) {
8408
+ if (!isEnoent(err))
8409
+ throw err;
8410
+ return tryCreateLock(lockPath, token) ? token : null;
8411
+ }
8412
+ if (Date.now() - observedMtimeMs <= WEBHOOK_DRAIN_LOCK_STALE_MS)
8413
+ return null;
8414
+ const claimed = `${lockPath}.claimed-${randomUUID()}`;
8415
+ try {
8416
+ renameSync(lockPath, claimed);
8417
+ } catch (err) {
8418
+ if (isEnoent(err))
8419
+ return null;
8420
+ throw err;
8421
+ }
8422
+ let claimedMtimeMs = null;
8423
+ try {
8424
+ claimedMtimeMs = statSync(claimed).mtimeMs;
8425
+ } catch (err) {
8426
+ if (!isEnoent(err))
8427
+ throw err;
8428
+ }
8429
+ if (claimedMtimeMs !== observedMtimeMs) {
8430
+ try {
8431
+ linkSync(claimed, lockPath);
8432
+ } catch (err) {
8433
+ if (!isErrnoCode(err, "EEXIST"))
8434
+ throw err;
8435
+ }
8436
+ try {
8437
+ unlinkSync(claimed);
8438
+ } catch (err) {
8439
+ if (!isEnoent(err))
8440
+ throw err;
8441
+ }
8442
+ return null;
8443
+ }
8444
+ unlinkSync(claimed);
8445
+ return tryCreateLock(lockPath, token) ? token : null;
8446
+ }
8447
+ function renewDrainLock(lockPath, token) {
8448
+ let holder;
8449
+ try {
8450
+ holder = readFileSync4(lockPath, "utf8").trim();
8451
+ } catch (err) {
8452
+ if (!isEnoent(err))
8453
+ throw err;
8454
+ return false;
8455
+ }
8456
+ if (holder !== token)
8457
+ return false;
8458
+ const now = new Date;
8459
+ try {
8460
+ utimesSync(lockPath, now, now);
8461
+ } catch (err) {
8462
+ if (!isEnoent(err))
8463
+ throw err;
8464
+ return false;
8465
+ }
8466
+ return true;
8467
+ }
8468
+ function releaseDrainLock(lockPath, token) {
8469
+ try {
8470
+ const holder = readFileSync4(lockPath, "utf8").trim();
8471
+ if (holder !== token)
8472
+ return;
8473
+ unlinkSync(lockPath);
8474
+ } catch (err) {
8475
+ if (!isEnoent(err))
8476
+ throw err;
8477
+ }
8478
+ }
8479
+
8480
+ class WebhookDrainError extends Error {
8481
+ code;
8482
+ constructor(code, message) {
8483
+ super(message);
8484
+ this.code = code;
8485
+ }
8486
+ }
8487
+ function backupPathFor(queuePath) {
8488
+ return queuePath.replace(/\.ndjson$/, ".1.ndjson");
8489
+ }
8490
+ function drainingPathFor(queuePath) {
8491
+ return queuePath.replace(/\.ndjson$/, ".draining.ndjson");
8492
+ }
8493
+ function rejectedPathFor(queuePath) {
8494
+ return queuePath.replace(/\.ndjson$/, ".rejected.ndjson");
8495
+ }
8496
+ var rejectionWarnedThisProcess = false;
8497
+ function warnRejectionOnce(message) {
8498
+ if (rejectionWarnedThisProcess)
8499
+ return;
8500
+ rejectionWarnedThisProcess = true;
8501
+ try {
8502
+ process.stderr.write(message);
8503
+ } catch {}
8504
+ }
8505
+ function queueLines(buf) {
8506
+ const lines = [];
8507
+ let start = 0;
8508
+ for (let i = 0;i < buf.byteLength; i++) {
8509
+ if (buf[i] !== 10)
8510
+ continue;
8511
+ if (i > start)
8512
+ lines.push({ raw: buf.toString("utf8", start, i), end: i + 1 });
8513
+ start = i + 1;
8514
+ }
8515
+ if (start < buf.byteLength)
8516
+ lines.push({ raw: buf.toString("utf8", start), end: buf.byteLength });
8517
+ return lines;
8518
+ }
8519
+ function removeQueueHead(path, cut) {
8520
+ const remaining = readFileSync4(path);
8521
+ writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
8522
+ }
8523
+ function queueBucketSize(path) {
8524
+ let lstat;
8525
+ try {
8526
+ lstat = lstatSync(path);
8527
+ } catch (err) {
8528
+ if (!isEnoent(err))
8529
+ throw err;
8530
+ }
8531
+ if (lstat === undefined)
8532
+ return null;
8533
+ if (!lstat.isFile()) {
8534
+ 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}`);
8535
+ }
8536
+ return Number(lstat.size);
8537
+ }
8538
+ function readQueueFile(path) {
8539
+ if (queueBucketSize(path) === null)
8540
+ return null;
8541
+ return readFileSync4(path);
8542
+ }
8543
+ function rejectLine(rejectedPath, reason, status, identity, raw) {
8544
+ const record = JSON.stringify({
8545
+ rejected_at: new Date().toISOString(),
8546
+ status,
8547
+ reason,
8548
+ identity,
8549
+ bytes: Buffer.byteLength(raw, "utf8"),
8550
+ raw
8551
+ });
8552
+ const failure = appendHardenedLine(rejectedPath, `${record}
8553
+ `);
8554
+ if (failure !== null) {
8555
+ 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`);
8556
+ }
8557
+ warnRejectionOnce(`vinaya: log delivery set a queued line aside in ${rejectedPath} — ${reason}; later lines keep delivering
8558
+ `);
8559
+ }
8560
+ async function postChunk(webhookUrl, headers, body, fetchTimeoutMs, chunksAlreadyDelivered) {
8561
+ const delivered = chunksAlreadyDelivered > 0 ? ` after delivering ${chunksAlreadyDelivered} chunk(s)` : "";
8562
+ let response;
8563
+ try {
8564
+ response = await fetch(webhookUrl, {
8565
+ method: "POST",
8566
+ headers: { "content-type": "application/x-ndjson", ...headers },
8567
+ body,
8568
+ signal: AbortSignal.timeout(fetchTimeoutMs)
8569
+ });
8570
+ } catch (err) {
8571
+ const reason = err instanceof Error && err.name === "TimeoutError" ? `timed out after ${fetchTimeoutMs}ms` : err instanceof Error ? err.message : String(err);
8572
+ throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} failed${delivered}: ${reason}`);
8573
+ }
8574
+ if (!response.ok) {
8575
+ throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} returned ${response.status} ${response.statusText}${delivered}`);
8576
+ }
8577
+ }
8578
+ async function drainQueueFile(args) {
8579
+ const { path, rejectedPath, webhookUrl, headers, fetchTimeoutMs, totals } = args;
8580
+ const buf = readQueueFile(path);
8581
+ if (buf === null || buf.byteLength === 0)
8582
+ return;
8583
+ const lines = queueLines(buf);
8584
+ if (lines.length === 0) {
8585
+ removeQueueHead(path, buf.byteLength);
8586
+ return;
8587
+ }
8588
+ let removed = 0;
8589
+ let pendingEnd = 0;
8590
+ let chunk = [];
8591
+ let chunkBytes = 0;
8592
+ const deliverChunk = async () => {
8593
+ const body = `${chunk.join(`
8594
+ `)}
8595
+ `;
8596
+ args.keepLock();
8597
+ await postChunk(webhookUrl, headers, body, fetchTimeoutMs, totals.chunks);
8598
+ totals.chunks += 1;
8599
+ totals.lineCount += chunk.length;
8600
+ totals.bytes += Buffer.byteLength(body, "utf8");
8601
+ removeQueueHead(path, pendingEnd - removed);
8602
+ removed = pendingEnd;
8603
+ chunk = [];
8604
+ chunkBytes = 0;
8605
+ };
8606
+ const setAside = async (reason, status, identity, line) => {
8607
+ if (chunk.length > 0)
8608
+ await deliverChunk();
8609
+ rejectLine(rejectedPath, reason, status, identity, line.raw);
8610
+ totals.rejected += 1;
8611
+ pendingEnd = line.end;
8612
+ removeQueueHead(path, pendingEnd - removed);
8613
+ removed = pendingEnd;
8614
+ };
8615
+ for (const line of lines) {
8616
+ const record = classifyStoredLine(line.raw, homedir2());
8617
+ if (record.status !== "ok") {
8618
+ await setAside(record.reason, record.status, record.identity, line);
8619
+ continue;
8620
+ }
8621
+ const lineBytes = Buffer.byteLength(record.postLine, "utf8") + 1;
8622
+ if (lineBytes > MAX_WEBHOOK_BODY_BYTES) {
8623
+ 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);
8624
+ continue;
8625
+ }
8626
+ if (chunk.length > 0 && chunkBytes + lineBytes > MAX_WEBHOOK_BODY_BYTES)
8627
+ await deliverChunk();
8628
+ chunk.push(record.postLine);
8629
+ chunkBytes += lineBytes;
8630
+ pendingEnd = line.end;
8631
+ }
8632
+ pendingEnd = buf.byteLength;
8633
+ if (chunk.length > 0) {
8634
+ await deliverChunk();
8635
+ return;
8636
+ }
8637
+ if (pendingEnd > removed)
8638
+ removeQueueHead(path, pendingEnd - removed);
8639
+ }
8640
+ async function drainRenamedAside(args, livePath, source) {
8641
+ args.keepLock();
8642
+ const draining = drainingPathFor(livePath);
8643
+ try {
8644
+ renameSync(source, draining);
8645
+ } catch (err) {
8646
+ if (isEnoent(err))
8647
+ return;
8648
+ throw err;
8649
+ }
8650
+ await drainQueueFile({ ...args, path: draining });
8651
+ unlinkSync(draining);
8652
+ }
8653
+ async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeoutMs = WEBHOOK_FETCH_TIMEOUT_MS) {
8654
+ const resolved = await resolveRepo();
8655
+ const repo = resolved && isSafeRepoSegment2(resolved.owner) && isSafeRepoSegment2(resolved.repo) ? resolved : null;
8656
+ const outboxRoot = () => join6(GLOBAL_VINAYA_HOME, "outbox");
8657
+ const path = outboxPathFor({ outboxRoot }, repo, outboxTask);
8658
+ const lockPath = `${path}.flush-lock`;
8659
+ const lockToken = acquireDrainLock(lockPath);
8660
+ const totals = { lineCount: 0, bytes: 0, chunks: 0, rejected: 0 };
8661
+ if (lockToken === null)
8662
+ return { flushed: false, ...totals };
8663
+ try {
8664
+ const keepLock = () => {
8665
+ if (renewDrainLock(lockPath, lockToken))
8666
+ return;
8667
+ 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`);
8668
+ };
8669
+ const shared = {
8670
+ rejectedPath: rejectedPathFor(path),
8671
+ webhookUrl,
8672
+ headers,
8673
+ fetchTimeoutMs,
8674
+ totals,
8675
+ keepLock
8676
+ };
8677
+ const draining = drainingPathFor(path);
8678
+ if (queueBucketSize(draining) !== null) {
8679
+ keepLock();
8680
+ await drainQueueFile({ ...shared, path: draining });
8681
+ unlinkSync(draining);
8682
+ }
8683
+ await drainRenamedAside(shared, path, backupPathFor(path));
8684
+ await drainRenamedAside(shared, path, path);
8685
+ return { flushed: totals.chunks > 0 || totals.rejected > 0, ...totals };
8686
+ } finally {
8687
+ releaseDrainLock(lockPath, lockToken);
8688
+ }
8689
+ }
8690
+
8691
+ // src/lib/log-sink.ts
8692
+ var OUTBOX_MAX_BYTES = 8 * 1024 * 1024;
8693
+ var LOG_CONTEXT_LOOKUP_DEADLINE_MS = 3000;
8694
+ function withDeadline(work, ms, fallback) {
8695
+ return new Promise((resolve) => {
8696
+ const timer = setTimeout(() => resolve(fallback), ms);
8697
+ timer.unref?.();
8698
+ work.then((value) => {
8699
+ clearTimeout(timer);
8700
+ resolve(value);
8701
+ }, () => {
8702
+ clearTimeout(timer);
8703
+ resolve(fallback);
8704
+ });
8705
+ });
8706
+ }
8707
+ async function safeLoadTrustAnchorConfig() {
8708
+ return withDeadline(loadTrustAnchorConfigAsync(undefined, { quiet: true }), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
8709
+ }
8710
+ function logsCredentialMissing(headers, env) {
8711
+ if (!headers)
8712
+ return false;
8713
+ const varPattern = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
8714
+ for (const value of Object.values(headers)) {
8715
+ for (const match of value.matchAll(varPattern)) {
8716
+ if (!env[match[1]])
8717
+ return true;
8718
+ }
8719
+ }
8720
+ return false;
8721
+ }
8722
+ function resolveLogDestinationFrom(input) {
8723
+ const local = resolveLogsSetting(input.localConfig);
8724
+ let effective = null;
8725
+ if (input.unattended) {
8726
+ effective = local ? resolveTrustAnchorLogsDestination(local, input.trustAnchorConfig) : resolveLogsSetting(input.trustAnchorConfig);
8727
+ } else {
8728
+ effective = local;
8729
+ }
8730
+ if (hostFromEnv(input.env) === "ci") {
8731
+ if (effective && "url" in effective) {
8732
+ if (logsCredentialMissing(effective.headers, input.env)) {
8733
+ return {
8734
+ kind: "none",
8735
+ reason: "a logs.url server destination is configured, but this job holds no delivery credential (a fork pull request, or a missing repository secret)"
8736
+ };
8737
+ }
8738
+ return { kind: "server", url: effective.url, headers: resolveLogsHeaderValues(effective.headers, input.env) };
8739
+ }
8740
+ return {
8741
+ kind: "none",
8742
+ reason: "no server destination is configured for CI delivery (vinaya.config.json logs.url)"
8743
+ };
8744
+ }
8745
+ if (effective && "url" in effective) {
8746
+ return { kind: "server", url: effective.url, headers: resolveLogsHeaderValues(effective.headers, input.env) };
8747
+ }
8748
+ if (effective && "folder" in effective && isInsideRepo(effective.folder, input.repoRoot)) {
8749
+ effective = null;
8750
+ }
8751
+ const folder = effective && "folder" in effective ? effective.folder : input.defaultFolder;
8752
+ return { kind: "folder", folder };
8753
+ }
8754
+ var processTrustAnchorOnce;
8755
+ function processTrustAnchor() {
8756
+ if (processTrustAnchorOnce === undefined)
8757
+ processTrustAnchorOnce = safeLoadTrustAnchorConfig();
8758
+ return processTrustAnchorOnce;
8759
+ }
8760
+ async function defaultResolveLogDestination(repo, env) {
8761
+ const localConfig = loadConfig();
8762
+ const unattended = isUnattendedProcess(process.env);
8763
+ return resolveLogDestinationFrom({
8764
+ localConfig,
8765
+ trustAnchorConfig: unattended ? await processTrustAnchor() : null,
8766
+ unattended,
8767
+ env,
8768
+ defaultFolder: join7(await runtimeDirForRepoAsync(repo), "logs"),
8769
+ repoRoot: repoRootSync()
8770
+ });
8771
+ }
8772
+ function isEnoent2(err) {
8056
8773
  return typeof err === "object" && err !== null && err.code === "ENOENT";
8057
8774
  }
8058
- function resolveDoctrine(cwd, vinayaVersion) {
8775
+ var execFileAsync5 = promisify5(execFile5);
8776
+ async function resolveDoctrine(cwd, vinayaVersion) {
8059
8777
  let toplevel;
8060
8778
  try {
8061
- toplevel = execFileSync5("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
8062
- encoding: "utf8",
8063
- stdio: ["ignore", "pipe", "pipe"]
8064
- }).trim();
8779
+ toplevel = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "--show-toplevel"], { encoding: "utf8" })).stdout.trim();
8065
8780
  } catch (err) {
8066
- return isEnoent(err) ? "unknown" : vinayaVersion;
8781
+ return isEnoent2(err) ? "unknown" : vinayaVersion;
8067
8782
  }
8068
- if (!existsSync4(join4(toplevel, "aeg-root", "roles")))
8783
+ if (!existsSync6(join7(toplevel, "aeg-root", "roles")))
8069
8784
  return vinayaVersion;
8070
8785
  try {
8071
- const sha = execFileSync5("git", ["-C", toplevel, "rev-parse", "HEAD:aeg-root"], {
8072
- encoding: "utf8",
8073
- stdio: ["ignore", "pipe", "pipe"]
8074
- }).trim();
8786
+ const sha = (await execFileAsync5("git", ["-C", toplevel, "rev-parse", "HEAD:aeg-root"], { encoding: "utf8" })).stdout.trim();
8075
8787
  return `aeg-root@${sha}`;
8076
8788
  } catch {
8077
8789
  return vinayaVersion;
@@ -8079,20 +8791,20 @@ function resolveDoctrine(cwd, vinayaVersion) {
8079
8791
  }
8080
8792
  function readVinayaVersion() {
8081
8793
  try {
8082
- const pkg = JSON.parse(readFileSync3(join4(packageRoot(import.meta.url), "package.json"), "utf8"));
8794
+ const pkg = JSON.parse(readFileSync5(join7(packageRoot(import.meta.url), "package.json"), "utf8"));
8083
8795
  return pkg.version ?? "unknown";
8084
8796
  } catch {
8085
8797
  return "unknown";
8086
8798
  }
8087
8799
  }
8088
- var SAFE_PATH_SEGMENT = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8089
- function isSafeRepoSegment(segment) {
8090
- return SAFE_PATH_SEGMENT.test(segment) && !segment.includes("..");
8800
+ var SAFE_PATH_SEGMENT3 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
8801
+ function isSafeRepoSegment3(segment) {
8802
+ return SAFE_PATH_SEGMENT3.test(segment) && !segment.includes("..");
8091
8803
  }
8092
8804
  function outboxPathFor(deps, repo, issue) {
8093
8805
  const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
8094
8806
  const fileName = `${issue ?? "none"}.ndjson`;
8095
- return join4(deps.outboxRoot(), dirName, fileName);
8807
+ return join7(deps.outboxRoot(), dirName, fileName);
8096
8808
  }
8097
8809
  function hostFromEnv(env) {
8098
8810
  if (env.GITHUB_ACTIONS)
@@ -8103,36 +8815,60 @@ function hostFromEnv(env) {
8103
8815
  return "loop";
8104
8816
  return "cli";
8105
8817
  }
8818
+ var warnedThisProcess = false;
8819
+ function defaultStderr(message) {
8820
+ if (warnedThisProcess)
8821
+ return;
8822
+ warnedThisProcess = true;
8823
+ process.stderr.write(message);
8824
+ }
8106
8825
  function defaultDeps() {
8107
8826
  return {
8108
- outboxRoot: () => join4(GLOBAL_VINAYA_HOME, "outbox"),
8109
- home: () => homedir2(),
8827
+ outboxRoot: () => join7(GLOBAL_VINAYA_HOME, "outbox"),
8828
+ home: () => homedir3(),
8110
8829
  hostname: () => osHostname(),
8111
8830
  cwd: () => process.cwd(),
8112
8831
  now: () => new Date,
8113
8832
  env: () => process.env,
8114
8833
  resolveRepo: () => resolveRepo(),
8115
8834
  vinayaVersion: () => readVinayaVersion(),
8116
- stderr: (message) => {
8117
- process.stderr.write(message);
8118
- },
8835
+ stderr: defaultStderr,
8119
8836
  inputVersions: () => {
8120
8837
  return;
8121
- }
8838
+ },
8839
+ resolveLogDestination: defaultResolveLogDestination
8122
8840
  };
8123
8841
  }
8124
- var APPEND_OPEN_FLAGS = fsConstants2.O_WRONLY | fsConstants2.O_APPEND | fsConstants2.O_CREAT | fsConstants2.O_NOFOLLOW | fsConstants2.O_NONBLOCK;
8842
+ var APPEND_OPEN_FLAGS = fsConstants3.O_WRONLY | fsConstants3.O_APPEND | fsConstants3.O_CREAT | fsConstants3.O_NOFOLLOW | fsConstants3.O_NONBLOCK;
8125
8843
  function guardedAppendOpen(path) {
8126
8844
  try {
8127
- return openSync2(path, APPEND_OPEN_FLAGS, 384);
8845
+ return openSync3(path, APPEND_OPEN_FLAGS, 384);
8128
8846
  } catch {
8129
8847
  return;
8130
8848
  }
8131
8849
  }
8850
+ function appendHardenedLine(path, line) {
8851
+ try {
8852
+ mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
8853
+ const fd = guardedAppendOpen(path);
8854
+ if (fd === undefined)
8855
+ return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
8856
+ try {
8857
+ if (!fstatSync2(fd).isFile())
8858
+ return `target is not a regular file: ${path}`;
8859
+ writeSync2(fd, line);
8860
+ } finally {
8861
+ closeSync3(fd);
8862
+ }
8863
+ return null;
8864
+ } catch (err) {
8865
+ return err instanceof Error ? err.message : String(err);
8866
+ }
8867
+ }
8132
8868
  function reportRotationOverflow(backupPath, warn) {
8133
8869
  let raw;
8134
8870
  try {
8135
- raw = readFileSync3(backupPath, "utf8");
8871
+ raw = readFileSync5(backupPath, "utf8");
8136
8872
  } catch {
8137
8873
  return;
8138
8874
  }
@@ -8155,7 +8891,7 @@ function reportRotationOverflow(backupPath, warn) {
8155
8891
  }
8156
8892
  function appendLine(path, line, warn) {
8157
8893
  try {
8158
- mkdirSync2(dirname3(path), { recursive: true, mode: 448 });
8894
+ mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
8159
8895
  let fd = guardedAppendOpen(path);
8160
8896
  if (fd === undefined) {
8161
8897
  warn(`vinaya: log outbox target could not be opened (symlink, FIFO, or unwritable) — refusing: ${path}
@@ -8171,11 +8907,11 @@ function appendLine(path, line, warn) {
8171
8907
  return;
8172
8908
  }
8173
8909
  if (stat.size > OUTBOX_MAX_BYTES) {
8174
- closeSync2(fd);
8910
+ closeSync3(fd);
8175
8911
  closed = true;
8176
8912
  const backupPath = path.replace(/\.ndjson$/, ".1.ndjson");
8177
8913
  reportRotationOverflow(backupPath, warn);
8178
- renameSync(path, backupPath);
8914
+ renameSync2(path, backupPath);
8179
8915
  const rotated = guardedAppendOpen(path);
8180
8916
  if (rotated === undefined) {
8181
8917
  warn(`vinaya: log outbox target could not be reopened after rotation — refusing: ${path}
@@ -8185,10 +8921,10 @@ function appendLine(path, line, warn) {
8185
8921
  fd = rotated;
8186
8922
  closed = false;
8187
8923
  }
8188
- writeSync(fd, line);
8924
+ writeSync2(fd, line);
8189
8925
  } finally {
8190
8926
  if (!closed)
8191
- closeSync2(fd);
8927
+ closeSync3(fd);
8192
8928
  }
8193
8929
  } catch (err) {
8194
8930
  warn(`vinaya: log outbox write failed — ${err instanceof Error ? err.message : String(err)}
@@ -8197,8 +8933,8 @@ function appendLine(path, line, warn) {
8197
8933
  }
8198
8934
  function createLogSink(overrides = {}) {
8199
8935
  const deps = { ...defaultDeps(), ...overrides };
8200
- const runId = deps.env().VINAYA_RUN_ID || randomUUID();
8201
- const processId = randomUUID();
8936
+ const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
8937
+ const processId = randomUUID2();
8202
8938
  let seq = 0;
8203
8939
  let warned = false;
8204
8940
  const warnOnce = (message) => {
@@ -8211,8 +8947,9 @@ function createLogSink(overrides = {}) {
8211
8947
  };
8212
8948
  let doctrineCache;
8213
8949
  const doctrine = () => {
8214
- if (doctrineCache === undefined)
8215
- doctrineCache = resolveDoctrine(deps.cwd(), deps.vinayaVersion());
8950
+ if (doctrineCache === undefined) {
8951
+ doctrineCache = withDeadline(resolveDoctrine(deps.cwd(), deps.vinayaVersion()), LOG_CONTEXT_LOOKUP_DEADLINE_MS, deps.vinayaVersion());
8952
+ }
8216
8953
  return doctrineCache;
8217
8954
  };
8218
8955
  let resolveRepoCache;
@@ -8221,6 +8958,30 @@ function createLogSink(overrides = {}) {
8221
8958
  resolveRepoCache = deps.resolveRepo();
8222
8959
  return resolveRepoCache;
8223
8960
  };
8961
+ let contextCache;
8962
+ const context = () => {
8963
+ if (contextCache === undefined) {
8964
+ const env = deps.env();
8965
+ contextCache = Promise.all([
8966
+ withDeadline(resolveRepoOnce(), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null),
8967
+ doctrine()
8968
+ ]).then(async ([resolved, doctrineValue]) => {
8969
+ const repo = resolved && isSafeRepoSegment3(resolved.owner) && isSafeRepoSegment3(resolved.repo) ? resolved : null;
8970
+ return { repo, doctrine: doctrineValue, destination: await deps.resolveLogDestination(repo, env) };
8971
+ });
8972
+ }
8973
+ return contextCache;
8974
+ };
8975
+ let drainChain = Promise.resolve();
8976
+ const pendingWrites = new Set;
8977
+ const scheduleWebhookDrain = (issue, url, headers) => {
8978
+ drainChain = drainChain.then(() => drainOutboxToWebhook(issue, url, headers)).then(() => {
8979
+ return;
8980
+ }).catch((err) => {
8981
+ warnOnce(`vinaya: log delivery to ${url} failed — queued in the local outbox, retried on the next event: ${err instanceof Error ? err.message : String(err)}
8982
+ `);
8983
+ });
8984
+ };
8224
8985
  function log(e) {
8225
8986
  try {
8226
8987
  const env = deps.env();
@@ -8235,22 +8996,26 @@ function createLogSink(overrides = {}) {
8235
8996
  attempt: env.VINAYA_ATTEMPT,
8236
8997
  parent: env.VINAYA_PARENT_EVENT
8237
8998
  };
8238
- resolveRepoOnce().then((resolved) => {
8239
- const repo = resolved && isSafeRepoSegment(resolved.owner) && isSafeRepoSegment(resolved.repo) ? resolved : null;
8999
+ const written = context().then(({ repo, doctrine: doctrineValue, destination: resolvedDestination }) => {
8240
9000
  const header = buildHeader({
8241
9001
  now,
8242
9002
  runId,
8243
9003
  seq: mySeq,
8244
9004
  repo: repo ? `${repo.owner}/${repo.repo}` : null,
8245
9005
  vinaya: deps.vinayaVersion(),
8246
- doctrine: doctrine(),
9006
+ doctrine: doctrineValue,
8247
9007
  host,
8248
9008
  hostname: deps.hostname(),
8249
9009
  env: envFields,
8250
- eventId: randomUUID(),
9010
+ eventId: randomUUID2(),
8251
9011
  processId,
8252
9012
  inputVersions: deps.inputVersions()
8253
9013
  });
9014
+ if (resolvedDestination.kind === "none") {
9015
+ warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
9016
+ `);
9017
+ return;
9018
+ }
8254
9019
  const full = { ...e, ...header };
8255
9020
  const parsed = LogEventSchema.safeParse(full);
8256
9021
  if (!parsed.success) {
@@ -8260,25 +9025,42 @@ function createLogSink(overrides = {}) {
8260
9025
  }
8261
9026
  const line = `${JSON.stringify(redact(parsed.data, deps.home()))}
8262
9027
  `;
8263
- appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
9028
+ const destination = resolvedDestination;
9029
+ if (destination.kind === "server") {
9030
+ appendLine(outboxPathFor(deps, repo, header.subject.issue), line, warnOnce);
9031
+ scheduleWebhookDrain(header.subject.issue, destination.url, destination.headers);
9032
+ } else {
9033
+ appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
9034
+ }
8264
9035
  }).catch((err) => {
8265
9036
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
8266
9037
  `);
8267
9038
  });
9039
+ pendingWrites.add(written);
9040
+ written.finally(() => pendingWrites.delete(written));
8268
9041
  } catch (err) {
8269
9042
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
8270
9043
  `);
8271
9044
  }
8272
9045
  }
8273
9046
  const warmup = () => {
8274
- doctrine();
8275
9047
  const originalWarn = console.warn;
8276
9048
  console.warn = () => {};
8277
9049
  resolveRepoOnce().finally(() => {
8278
9050
  console.warn = originalWarn;
8279
9051
  });
9052
+ context().catch(() => {
9053
+ return;
9054
+ });
9055
+ };
9056
+ const drain = async () => {
9057
+ if (pendingWrites.size > 0)
9058
+ await Promise.allSettled(Array.from(pendingWrites));
9059
+ await drainChain.catch(() => {
9060
+ return;
9061
+ });
8280
9062
  };
8281
- return { log, runId, warmup };
9063
+ return { log, runId, warmup, drain };
8282
9064
  }
8283
9065
  var defaultSink = createLogSink();
8284
9066
 
@@ -8329,7 +9111,7 @@ function parseChangedLineRanges(diffOutput) {
8329
9111
  function fileDiffAgainst(ref, path) {
8330
9112
  let out;
8331
9113
  try {
8332
- out = execFileSync6("git", ["diff", `${ref}...HEAD`, "--", path], {
9114
+ out = execFileSync5("git", ["diff", `${ref}...HEAD`, "--", path], {
8333
9115
  encoding: "utf8",
8334
9116
  stdio: ["ignore", "pipe", "pipe"]
8335
9117
  }).trim();
@@ -8340,7 +9122,7 @@ function fileDiffAgainst(ref, path) {
8340
9122
  }
8341
9123
  function revParse(ref) {
8342
9124
  try {
8343
- return execFileSync6("git", ["rev-parse", "--verify", ref], {
9125
+ return execFileSync5("git", ["rev-parse", "--verify", ref], {
8344
9126
  encoding: "utf8",
8345
9127
  stdio: ["ignore", "pipe", "pipe"]
8346
9128
  }).trim();
@@ -8350,7 +9132,7 @@ function revParse(ref) {
8350
9132
  }
8351
9133
  function repoRoot() {
8352
9134
  try {
8353
- return execFileSync6("git", ["rev-parse", "--show-toplevel"], {
9135
+ return execFileSync5("git", ["rev-parse", "--show-toplevel"], {
8354
9136
  encoding: "utf8",
8355
9137
  stdio: ["ignore", "pipe", "pipe"]
8356
9138
  }).trim();
@@ -8361,7 +9143,7 @@ function repoRoot() {
8361
9143
  function changedFiles(base) {
8362
9144
  let out;
8363
9145
  try {
8364
- out = execFileSync6("git", ["diff", "--name-only", `${base}...HEAD`], {
9146
+ out = execFileSync5("git", ["diff", "--name-only", `${base}...HEAD`], {
8365
9147
  encoding: "utf8",
8366
9148
  stdio: ["ignore", "pipe", "pipe"]
8367
9149
  }).trim();
@@ -8386,7 +9168,7 @@ function resolveDiff(base = process.env.BASE_SHA || "origin/main") {
8386
9168
  const relPaths = changedFiles(ref);
8387
9169
  if (relPaths === null)
8388
9170
  continue;
8389
- return { base: ref, root, files: relPaths.map((p) => join5(root, p)) };
9171
+ return { base: ref, root, files: relPaths.map((p) => join8(root, p)) };
8390
9172
  }
8391
9173
  return null;
8392
9174
  }
@@ -8428,17 +9210,17 @@ function isTestFile(path) {
8428
9210
  function collectAllPaths(dir, out = []) {
8429
9211
  let entries;
8430
9212
  try {
8431
- entries = readdirSync(dir);
9213
+ entries = readdirSync2(dir);
8432
9214
  } catch {
8433
9215
  return out;
8434
9216
  }
8435
9217
  for (const name of entries) {
8436
9218
  if (EXCLUDED_DIRS.has(name))
8437
9219
  continue;
8438
- const full = join6(dir, name);
9220
+ const full = join9(dir, name);
8439
9221
  let isDir;
8440
9222
  try {
8441
- isDir = statSync(full).isDirectory();
9223
+ isDir = statSync2(full).isDirectory();
8442
9224
  } catch {
8443
9225
  continue;
8444
9226
  }
@@ -8451,7 +9233,7 @@ function collectAllPaths(dir, out = []) {
8451
9233
  function main() {
8452
9234
  const allPaths = WORKSPACE_DIRS.flatMap((d) => collectAllPaths(d)).map((p) => p.split("\\").join("/"));
8453
9235
  const knownPaths = new Set(allPaths);
8454
- const sourceFiles = allPaths.filter((p) => SOURCE_EXTENSIONS.some((ext) => p.endsWith(ext))).filter((p) => !isTestFile(p)).map((p) => ({ path: p, content: readFileSync4(p, "utf8") }));
9236
+ const sourceFiles = allPaths.filter((p) => SOURCE_EXTENSIONS.some((ext) => p.endsWith(ext))).filter((p) => !isTestFile(p)).map((p) => ({ path: p, content: readFileSync6(p, "utf8") }));
8455
9237
  const findings = findWorkspaceEscapes(sourceFiles, knownPaths, WORKSPACE_DIRS);
8456
9238
  const reportable = findingsInThisDiff(findings);
8457
9239
  console.log(`${CHECK_NAME}: ${sourceFiles.length} source file(s) scanned under ${WORKSPACE_DIRS.join("/")}; ${findings.length} finding(s), ${reportable.length} in this diff`);