@attalabs/vinaya 0.32.0 → 0.34.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 (218) hide show
  1. package/README.md +1 -1
  2. package/aeg-root/contracts/principal-operator.md +18 -5
  3. package/aeg-root/enforcement.md +1 -1
  4. package/aeg-root/glossary.md +4 -0
  5. package/aeg-root/roles/developer.md +3 -0
  6. package/aeg-root/roles/operator.md +89 -16
  7. package/aeg-root/roles/planner/reference.md +3 -2
  8. package/aeg-root/roles/planner.md +3 -1
  9. package/aeg-root/roles/tranche-archivist.md +1 -0
  10. package/aeg-root/skills/aeg-context-packets/SKILL.md +1 -1
  11. package/aeg-root/skills/aeg-context-packets/examples/operator-start.md +1 -1
  12. package/aeg-root/templates/brief-template.md +9 -7
  13. package/aeg-root/templates/pr-report-template.md +3 -1
  14. package/dist/checks/bin/check-body-bare-digits.js +213 -41
  15. package/dist/checks/bin/check-branch-topology.js +164 -41
  16. package/dist/checks/bin/check-brief-shape.js +219 -46
  17. package/dist/checks/bin/check-changeset-coverage.js +669 -152
  18. package/dist/checks/bin/check-closes-n.js +164 -41
  19. package/dist/checks/bin/check-coherence.js +220 -43
  20. package/dist/checks/bin/check-dead-branch-push.js +159 -40
  21. package/dist/checks/bin/check-dispatch-readiness.js +218 -42
  22. package/dist/checks/bin/check-doc-coverage-push.js +665 -148
  23. package/dist/checks/bin/check-doc-coverage.js +667 -150
  24. package/dist/checks/bin/check-doctrine-no-procedures.js +213 -41
  25. package/dist/checks/bin/check-doctrine-portability.js +666 -149
  26. package/dist/checks/bin/check-evidence-fresh.js +643 -125
  27. package/dist/checks/bin/check-exec-bits.js +663 -146
  28. package/dist/checks/bin/check-first-push-dispatch.js +218 -42
  29. package/dist/checks/bin/check-issue-assignment.js +164 -41
  30. package/dist/checks/bin/check-issue-milestone-attach.js +159 -40
  31. package/dist/checks/bin/check-issue-objectives-numbering.js +685 -41
  32. package/dist/checks/bin/check-issue-parts-coverage.js +159 -40
  33. package/dist/checks/bin/check-issue-surface-globs.js +258 -48
  34. package/dist/checks/bin/check-issue-title-grammar.js +159 -40
  35. package/dist/checks/bin/check-issue-tranche-label.js +159 -40
  36. package/dist/checks/bin/check-main-branch-refusal.js +159 -40
  37. package/dist/checks/bin/check-no-disk-state.js +159 -40
  38. package/dist/checks/bin/check-pr-premise-reassert.js +213 -41
  39. package/dist/checks/bin/check-pr-report-density.js +159 -40
  40. package/dist/checks/bin/check-principal-test-plan-wait.js +159 -40
  41. package/dist/checks/bin/check-quoted-command.js +586 -103
  42. package/dist/checks/bin/check-reader-resolvable-prose.js +637 -111
  43. package/dist/checks/bin/check-registry-gates.js +159 -40
  44. package/dist/checks/bin/check-retired-vocabulary.js +586 -103
  45. package/dist/checks/bin/check-review-gate.js +284 -152
  46. package/dist/checks/bin/check-single-plan-pr.js +159 -40
  47. package/dist/checks/bin/check-surface-scope.js +164 -41
  48. package/dist/checks/bin/check-test-plan.js +159 -40
  49. package/dist/checks/bin/check-token-collection-wired.js +159 -40
  50. package/dist/checks/bin/check-token-report.js +159 -40
  51. package/dist/checks/bin/check-workspace-escape.js +664 -147
  52. package/dist/index.js +3932 -1118
  53. package/dist/lib/pre-push-cache-test-run.js +507 -72
  54. package/dist/lib/pre-push-select-tests.js +136 -13
  55. package/package.json +1 -1
  56. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/actions.ts +10 -12
  57. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +5 -5
  58. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/archive-task.ts +42 -17
  59. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/baseline-capture.ts +1 -2
  60. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/branch-topology-gate.ts +3 -3
  61. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +554 -95
  62. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +264 -44
  63. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/claude-code-transcript.ts +9 -9
  64. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +211 -30
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/consumer-enumeration.ts +2 -2
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/index.ts +75 -0
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +961 -0
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/migration.ts +222 -0
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/outcomes.ts +135 -0
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +394 -0
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dead-branch-push-audit.ts +1 -2
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dead-branch-push-guard.ts +1 -1
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/derive-section7.ts +2 -2
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +514 -0
  75. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +110 -0
  76. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +30 -0
  77. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +219 -0
  78. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +97 -0
  79. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +240 -0
  80. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/diagram-model.ts +1 -1
  81. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/direct-main-push.ts +1 -2
  82. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +65 -22
  83. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-claim.ts +238 -0
  84. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-owners.ts +14 -1
  85. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/docs-coherence.ts +1 -1
  86. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/legacy-anchors.ts +1 -1
  87. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/node-route.ts +1 -1
  88. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/surfaced-manifest.ts +1 -1
  89. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-no-procedures.ts +1 -1
  90. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +5 -5
  91. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ensure-label.ts +1 -1
  92. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/first-push-dispatch-gate.ts +1 -1
  93. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +14 -3
  94. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +425 -11
  95. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-assignment.ts +3 -4
  96. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +1450 -33
  97. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/leftover-detection.ts +1 -2
  98. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/local-anchor-coverage.ts +2 -2
  99. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +119 -0
  100. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +75 -0
  101. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/redact.ts +87 -0
  102. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +801 -0
  103. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/store.ts +373 -0
  104. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +2 -2
  105. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/metering-io-guard.ts +1 -1
  106. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/milestone-validation.ts +2 -3
  107. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/no-disk-state.ts +2 -2
  108. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives.ts +288 -0
  109. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/parse-token-report.ts +3 -3
  110. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/parse-tranche.ts +1 -1
  111. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-report-density.ts +30 -16
  112. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-tier.ts +17 -1
  113. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/premise-check.ts +1 -1
  114. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/quoted-command.ts +1 -1
  115. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +267 -19
  116. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +91 -24
  117. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-scaffold.ts +6 -6
  118. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/report-tokens.ts +4 -4
  119. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +254 -110
  120. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +384 -0
  121. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +208 -0
  122. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +80 -28
  123. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +92 -0
  124. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/single-plan-pr.ts +4 -4
  125. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/state-machine-model.ts +40 -27
  126. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/symbol-collisions.ts +2 -2
  127. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-branch-identity.ts +38 -0
  128. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-phase-history.ts +194 -0
  129. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +712 -0
  130. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-gate.ts +7 -9
  131. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-section.ts +5 -5
  132. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/types.ts +4 -4
  133. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +368 -56
  134. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/waiver-label.ts +2 -3
  135. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/workspace-escape.ts +3 -3
  136. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  137. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  138. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  141. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  143. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  144. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  145. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  146. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  149. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js +1 -1
  150. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
  151. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  152. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  153. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  154. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  155. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +1 -1
  156. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  157. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  158. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  159. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +1 -1
  160. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  161. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  162. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  163. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +1 -1
  164. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  165. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  166. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  167. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +2 -2
  168. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  169. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  170. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  171. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +1 -1
  172. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  173. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  174. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  175. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +1 -1
  176. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  177. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  178. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  179. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +1 -1
  180. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  181. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  182. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/{[externals]__1agj1ww._.js → [externals]__0cki-x_._.js} +2 -2
  183. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +6 -6
  184. 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
  185. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +3 -0
  186. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__0r7e54g._.js → [root-of-the-server]__07uhu5z._.js} +1 -1
  187. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  188. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  189. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  190. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1r47dr7._.js → _08onyya._.js} +3 -3
  191. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  192. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  193. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  194. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  195. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0y1jv16._.js +1 -1
  196. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  197. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  198. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_15gdg48._.js +5 -5
  199. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  200. 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
  201. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  202. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  203. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  204. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  205. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bjnj-5fy4e7l.js +1 -0
  206. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ko698wh8xx2g.css +1 -0
  207. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1dc2_-c_gavj1.js → 0q9p7c6vn-x2w.js} +4 -4
  208. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3xg6-flovrcx-.js → 2174nz5he_oc4.js} +1 -1
  209. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3xnma0-359j17.js +1 -0
  210. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  211. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0hstap0._.js +0 -3
  212. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bm4nrrzwc7zi.css +0 -1
  213. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2t_rfsztmwu6y.js +0 -1
  214. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3ua4rm5f-a9k6.js +0 -1
  215. /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/vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
  216. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → HmoeqXdX1E4drt7GReFOO}/_buildManifest.js +0 -0
  217. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → HmoeqXdX1E4drt7GReFOO}/_clientMiddlewareManifest.js +0 -0
  218. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → HmoeqXdX1E4drt7GReFOO}/_ssgManifest.js +0 -0
@@ -234,6 +234,33 @@ function entry(key) {
234
234
  function label(key) {
235
235
  return entry(key).id;
236
236
  }
237
+ function trancheSlugOf(name) {
238
+ const prefix = entry("tranche").id;
239
+ return name.startsWith(prefix) ? name.slice(prefix.length) : null;
240
+ }
241
+ function findTrancheSlug(names) {
242
+ for (const n of names) {
243
+ const slug = trancheSlugOf(n);
244
+ if (slug !== null)
245
+ return slug;
246
+ }
247
+ return null;
248
+ }
249
+
250
+ // ../../packages/aeg-forge-state/src/list-tasks.ts
251
+ var TITLE_PATTERN = /^\[([^\]]+)]\s*(\S+)\s*—\s*(.+)$/;
252
+ function resolveTaskIssueRef(title, labels) {
253
+ const m = title.match(TITLE_PATTERN);
254
+ if (!m)
255
+ return null;
256
+ const taskId = (m[2] ?? "").trim();
257
+ if (!taskId)
258
+ return null;
259
+ const trancheSlug = findTrancheSlug(labels);
260
+ if (!trancheSlug)
261
+ return null;
262
+ return { trancheSlug, taskId };
263
+ }
237
264
  // ../../packages/aeg-forge-state/src/github-token.ts
238
265
  import { execFile as execFile2 } from "node:child_process";
239
266
  import { promisify as promisify2 } from "node:util";
@@ -528,15 +555,32 @@ var ObservedSchema = z.object({
528
555
  var TaskStatusInputSchema = z.object({
529
556
  task: TaskToolRefSchema.optional()
530
557
  }).merge(PageRequestSchema).strict();
558
+ var TaskConfidenceSchema = z.object({
559
+ round: z.number().int().positive(),
560
+ percent: z.number().int().min(0).max(100).nullable(),
561
+ source: z.enum(["stated", "published-summary"])
562
+ }).strict();
563
+ var TaskPhaseHistorySchema = z.object({
564
+ typicalPhaseMinutes: z.number().nonnegative(),
565
+ typicalPhaseSamples: z.number().int().positive()
566
+ }).strict();
531
567
  var TaskStatusItemSchema = z.object({
532
568
  task: TaskToolRefSchema,
533
569
  issue: z.number().int().positive(),
534
570
  pr: z.number().int().positive().nullable(),
535
- state: z.string()
571
+ state: z.string(),
572
+ round: z.number().int().positive().nullable().optional(),
573
+ phase: z.string().min(1).nullable().optional(),
574
+ minutesInPhase: z.number().nonnegative().nullable().optional(),
575
+ phaseIsCurrent: z.boolean().nullable().optional(),
576
+ lastConfidence: TaskConfidenceSchema.nullable().optional(),
577
+ lastConfidenceUnread: z.boolean().optional(),
578
+ phaseHistory: TaskPhaseHistorySchema.nullable().optional()
536
579
  }).merge(ObservedSchema);
537
580
  var TaskStatusResultSchema = z.object({
538
581
  items: z.array(TaskStatusItemSchema),
539
- nextCursor: z.string().nullable()
582
+ nextCursor: z.string().nullable(),
583
+ table: z.string()
540
584
  });
541
585
  var RequestedAuthoritySchema = z.enum(["planner", "principal", "operator", "self"]);
542
586
  var EscalationInputsSchema = z.object({
@@ -544,7 +588,7 @@ var EscalationInputsSchema = z.object({
544
588
  round: z.number().int().nonnegative(),
545
589
  head: z.string(),
546
590
  branch: z.string(),
547
- prNumber: z.number().int().positive()
591
+ prNumber: z.number().int().positive().nullable()
548
592
  });
549
593
  var EscalationEvidenceSchema = z.object({
550
594
  round: z.number().int().nonnegative(),
@@ -580,13 +624,45 @@ var TaskEscalationReadResultSchema = z.object({
580
624
  items: z.array(TaskEscalationPacketSchema),
581
625
  nextCursor: z.string().nullable()
582
626
  }).merge(ObservedSchema);
583
- var TaskStartInputSchema = z.object({
584
- tranche: z.string().min(1),
585
- id: z.string().min(1)
627
+ var TaskPrCheckSchema = z.object({
628
+ name: z.string(),
629
+ required: z.boolean(),
630
+ status: z.string(),
631
+ conclusion: z.string().nullable(),
632
+ detailsUrl: z.string().nullable(),
633
+ failureSummary: z.string().nullable()
634
+ });
635
+ var TaskPrVerdictSchema = z.object({
636
+ role: z.enum(["code-review", "security"]),
637
+ value: z.string(),
638
+ judgedHead: z.string().nullable(),
639
+ objectivesVersion: z.string().nullable()
640
+ });
641
+ var TaskPrPauseSchema = z.object({
642
+ reason: z.string(),
643
+ body: z.string()
644
+ });
645
+ var TaskPrReviewRecordSchema = z.object({
646
+ verdicts: z.array(TaskPrVerdictSchema),
647
+ roundMarkers: z.array(z.number().int().nonnegative()),
648
+ summaryTable: z.string().nullable(),
649
+ pause: TaskPrPauseSchema.nullable()
650
+ });
651
+ var TaskPrReadInputSchema = z.object({
652
+ task: TaskToolRefSchema,
653
+ pr: z.number().int().positive().optional()
586
654
  }).strict();
655
+ var TaskPrReadResultSchema = z.object({
656
+ task: TaskToolRefSchema,
657
+ issue: z.number().int().positive(),
658
+ pr: z.number().int().positive(),
659
+ head: z.string().nullable(),
660
+ checks: z.array(TaskPrCheckSchema),
661
+ review: TaskPrReviewRecordSchema
662
+ }).merge(ObservedSchema);
587
663
  var TaskStartResultSchema = z.object({
588
664
  requestId: z.string().min(1),
589
- run: z.object({ tranche: z.string().min(1), id: z.string().min(1) }),
665
+ run: TaskToolRefSchema,
590
666
  started: z.boolean(),
591
667
  startedAt: z.string(),
592
668
  mode: z.literal("attended")
@@ -600,7 +676,7 @@ var TaskCancelInputSchema = z.object({
600
676
  }).strict();
601
677
  var TaskResumeResultSchema = z.object({
602
678
  task: z.number().int().positive(),
603
- pr: z.number().int().positive(),
679
+ pr: z.number().int().positive().nullable(),
604
680
  escalationId: z.string().min(1),
605
681
  outcome: z.enum(["started", "already_resumed"]),
606
682
  authenticatedBy: z.string().min(1),
@@ -609,7 +685,7 @@ var TaskResumeResultSchema = z.object({
609
685
  var TaskCancelOutcomeSchema = z.enum(["confirmed", "pending", "uncertain"]);
610
686
  var TaskCancelResultSchema = z.object({
611
687
  task: z.number().int().positive(),
612
- pr: z.number().int().positive(),
688
+ pr: z.number().int().positive().nullable(),
613
689
  escalationId: z.string().min(1),
614
690
  outcome: TaskCancelOutcomeSchema,
615
691
  authenticatedBy: z.string().min(1),
@@ -620,6 +696,7 @@ var TASK_TOOL_NAMES = [
620
696
  "task_start",
621
697
  "task_status",
622
698
  "task_escalation_read",
699
+ "task_pr_read",
623
700
  "task_resume",
624
701
  "task_cancel"
625
702
  ];
@@ -1074,6 +1151,8 @@ function attemptFromEnv(value) {
1074
1151
  function provenanceFor(input) {
1075
1152
  if (input.provenance)
1076
1153
  return input.provenance;
1154
+ if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
1155
+ return "unavailable";
1077
1156
  if (input.env.role || input.env.task)
1078
1157
  return "env_correlated";
1079
1158
  return "unavailable";
@@ -1094,7 +1173,7 @@ function buildHeader(input) {
1094
1173
  const role = isRole(input.env.role) ? input.env.role : "unattributed";
1095
1174
  const round = roundFromEnv(input.env.round);
1096
1175
  const subject = {
1097
- issue: issueFromTask(input.env.task),
1176
+ issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
1098
1177
  role,
1099
1178
  ...round !== undefined ? { round } : {},
1100
1179
  ...input.subject ?? {}
@@ -2213,7 +2292,12 @@ var VinayaConfigSchema = z4.object({
2213
2292
  allowlist: z4.array(z4.string().min(1)).optional(),
2214
2293
  severity: z4.enum(["warning", "error"]).optional()
2215
2294
  }).optional(),
2216
- specGrandfather: z4.array(z4.string().min(1)).optional()
2295
+ specGrandfather: z4.array(z4.string().min(1)).optional(),
2296
+ specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
2297
+ message: "must be a repository-relative path, not an absolute one"
2298
+ }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
2299
+ message: "must stay inside the repository — no `..` segment"
2300
+ })).optional()
2217
2301
  }).optional(),
2218
2302
  projects: z4.array(ProjectEntrySchema).optional(),
2219
2303
  dispatch: z4.object({
@@ -2227,6 +2311,13 @@ var VinayaConfigSchema = z4.object({
2227
2311
  securityThreshold: z4.string().min(1).optional(),
2228
2312
  maxRounds: z4.number().optional()
2229
2313
  }).optional(),
2314
+ gateCutovers: z4.object({
2315
+ objectivesSinceIssue: z4.number().int().nonnegative().optional(),
2316
+ briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
2317
+ documentationSinceIssue: z4.number().int().nonnegative().optional(),
2318
+ briefRulesSincePr: z4.number().int().nonnegative().optional(),
2319
+ agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
2320
+ }).optional(),
2230
2321
  prePush: z4.object({
2231
2322
  alwaysRun: z4.array(z4.string()).optional()
2232
2323
  }).optional(),
@@ -2410,7 +2501,28 @@ function trustAnchorRepoFromRemoteUrl(url) {
2410
2501
  return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
2411
2502
  }
2412
2503
  var execFileAsync4 = promisify4(execFile4);
2504
+ function resolveCiTrustAnchorProbeRef(env = process.env) {
2505
+ const ref = env.VINAYA_CI_CONFIG_PROBE_REF?.trim();
2506
+ if (!ref)
2507
+ return null;
2508
+ if (env.GITHUB_ACTIONS !== "true")
2509
+ return null;
2510
+ if ((env.GH_TOKEN ?? "").length > 0 || (env.GITHUB_TOKEN ?? "").length > 0)
2511
+ return null;
2512
+ return ref;
2513
+ }
2514
+ function readTrustAnchorConfigAtRef(ref) {
2515
+ const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
2516
+ encoding: "utf-8",
2517
+ stdio: ["ignore", "pipe", "pipe"],
2518
+ timeout: 1e4
2519
+ });
2520
+ return Buffer.from(raw, "utf-8").toString("base64");
2521
+ }
2413
2522
  function ghFetchTrustAnchorConfig() {
2523
+ const probeRef = resolveCiTrustAnchorProbeRef();
2524
+ if (probeRef)
2525
+ return readTrustAnchorConfigAtRef(probeRef);
2414
2526
  const repo = trustAnchorRepo();
2415
2527
  if (!repo)
2416
2528
  throw new Error("could not resolve repo identity for the trust-anchor read");
@@ -2420,6 +2532,14 @@ function ghFetchTrustAnchorConfig() {
2420
2532
  });
2421
2533
  }
2422
2534
  async function ghFetchTrustAnchorConfigAsync() {
2535
+ const probeRef = resolveCiTrustAnchorProbeRef();
2536
+ if (probeRef) {
2537
+ const { stdout } = await execFileAsync4("git", ["show", `${probeRef}:${LOCAL_CONFIG_FILENAME}`], {
2538
+ encoding: "utf-8",
2539
+ timeout: 1e4
2540
+ });
2541
+ return Buffer.from(stdout, "utf-8").toString("base64");
2542
+ }
2423
2543
  const repo = await trustAnchorRepoAsync();
2424
2544
  if (!repo)
2425
2545
  throw new Error("could not resolve repo identity for the trust-anchor read");
@@ -2684,6 +2804,7 @@ import {
2684
2804
  renameSync as renameSync2,
2685
2805
  statSync as statSync2,
2686
2806
  unlinkSync as unlinkSync2,
2807
+ utimesSync,
2687
2808
  writeFileSync as writeFileSync2,
2688
2809
  writeSync as writeSync2
2689
2810
  } from "node:fs";
@@ -2767,6 +2888,27 @@ function acquireDrainLock(lockPath) {
2767
2888
  unlinkSync2(claimed);
2768
2889
  return tryCreateLock(lockPath, token) ? token : null;
2769
2890
  }
2891
+ function renewDrainLock(lockPath, token) {
2892
+ let holder;
2893
+ try {
2894
+ holder = readFileSync4(lockPath, "utf8").trim();
2895
+ } catch (err) {
2896
+ if (!isEnoent(err))
2897
+ throw err;
2898
+ return false;
2899
+ }
2900
+ if (holder !== token)
2901
+ return false;
2902
+ const now = new Date;
2903
+ try {
2904
+ utimesSync(lockPath, now, now);
2905
+ } catch (err) {
2906
+ if (!isEnoent(err))
2907
+ throw err;
2908
+ return false;
2909
+ }
2910
+ return true;
2911
+ }
2770
2912
  function releaseDrainLock(lockPath, token) {
2771
2913
  try {
2772
2914
  const holder = readFileSync4(lockPath, "utf8").trim();
@@ -2786,6 +2928,172 @@ class WebhookDrainError extends Error {
2786
2928
  this.code = code;
2787
2929
  }
2788
2930
  }
2931
+ function backupPathFor(queuePath) {
2932
+ return queuePath.replace(/\.ndjson$/, ".1.ndjson");
2933
+ }
2934
+ function drainingPathFor(queuePath) {
2935
+ return queuePath.replace(/\.ndjson$/, ".draining.ndjson");
2936
+ }
2937
+ function rejectedPathFor(queuePath) {
2938
+ return queuePath.replace(/\.ndjson$/, ".rejected.ndjson");
2939
+ }
2940
+ var rejectionWarnedThisProcess = false;
2941
+ function warnRejectionOnce(message) {
2942
+ if (rejectionWarnedThisProcess)
2943
+ return;
2944
+ rejectionWarnedThisProcess = true;
2945
+ try {
2946
+ process.stderr.write(message);
2947
+ } catch {}
2948
+ }
2949
+ function queueLines(buf) {
2950
+ const lines = [];
2951
+ let start = 0;
2952
+ for (let i = 0;i < buf.byteLength; i++) {
2953
+ if (buf[i] !== 10)
2954
+ continue;
2955
+ if (i > start)
2956
+ lines.push({ raw: buf.toString("utf8", start, i), end: i + 1 });
2957
+ start = i + 1;
2958
+ }
2959
+ if (start < buf.byteLength)
2960
+ lines.push({ raw: buf.toString("utf8", start), end: buf.byteLength });
2961
+ return lines;
2962
+ }
2963
+ function removeQueueHead(path, cut) {
2964
+ const remaining = readFileSync4(path);
2965
+ writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
2966
+ }
2967
+ function queueBucketSize(path) {
2968
+ let lstat;
2969
+ try {
2970
+ lstat = lstatSync2(path);
2971
+ } catch (err) {
2972
+ if (!isEnoent(err))
2973
+ throw err;
2974
+ }
2975
+ if (lstat === undefined)
2976
+ return null;
2977
+ if (!lstat.isFile()) {
2978
+ 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}`);
2979
+ }
2980
+ return Number(lstat.size);
2981
+ }
2982
+ function readQueueFile(path) {
2983
+ if (queueBucketSize(path) === null)
2984
+ return null;
2985
+ return readFileSync4(path);
2986
+ }
2987
+ function rejectLine(rejectedPath, reason, status, identity, raw) {
2988
+ const record = JSON.stringify({
2989
+ rejected_at: new Date().toISOString(),
2990
+ status,
2991
+ reason,
2992
+ identity,
2993
+ bytes: Buffer.byteLength(raw, "utf8"),
2994
+ raw
2995
+ });
2996
+ const failure = appendHardenedLine(rejectedPath, `${record}
2997
+ `);
2998
+ if (failure !== null) {
2999
+ 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`);
3000
+ }
3001
+ warnRejectionOnce(`vinaya: log delivery set a queued line aside in ${rejectedPath} — ${reason}; later lines keep delivering
3002
+ `);
3003
+ }
3004
+ async function postChunk(webhookUrl, headers, body, fetchTimeoutMs, chunksAlreadyDelivered) {
3005
+ const delivered = chunksAlreadyDelivered > 0 ? ` after delivering ${chunksAlreadyDelivered} chunk(s)` : "";
3006
+ let response;
3007
+ try {
3008
+ response = await fetch(webhookUrl, {
3009
+ method: "POST",
3010
+ headers: { "content-type": "application/x-ndjson", ...headers },
3011
+ body,
3012
+ signal: AbortSignal.timeout(fetchTimeoutMs)
3013
+ });
3014
+ } catch (err) {
3015
+ const reason = err instanceof Error && err.name === "TimeoutError" ? `timed out after ${fetchTimeoutMs}ms` : err instanceof Error ? err.message : String(err);
3016
+ throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} failed${delivered}: ${reason}`);
3017
+ }
3018
+ if (!response.ok) {
3019
+ throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} returned ${response.status} ${response.statusText}${delivered}`);
3020
+ }
3021
+ }
3022
+ async function drainQueueFile(args) {
3023
+ const { path, rejectedPath, webhookUrl, headers, fetchTimeoutMs, totals } = args;
3024
+ const buf = readQueueFile(path);
3025
+ if (buf === null || buf.byteLength === 0)
3026
+ return;
3027
+ const lines = queueLines(buf);
3028
+ if (lines.length === 0) {
3029
+ removeQueueHead(path, buf.byteLength);
3030
+ return;
3031
+ }
3032
+ let removed = 0;
3033
+ let pendingEnd = 0;
3034
+ let chunk = [];
3035
+ let chunkBytes = 0;
3036
+ const deliverChunk = async () => {
3037
+ const body = `${chunk.join(`
3038
+ `)}
3039
+ `;
3040
+ args.keepLock();
3041
+ await postChunk(webhookUrl, headers, body, fetchTimeoutMs, totals.chunks);
3042
+ totals.chunks += 1;
3043
+ totals.lineCount += chunk.length;
3044
+ totals.bytes += Buffer.byteLength(body, "utf8");
3045
+ removeQueueHead(path, pendingEnd - removed);
3046
+ removed = pendingEnd;
3047
+ chunk = [];
3048
+ chunkBytes = 0;
3049
+ };
3050
+ const setAside = async (reason, status, identity, line) => {
3051
+ if (chunk.length > 0)
3052
+ await deliverChunk();
3053
+ rejectLine(rejectedPath, reason, status, identity, line.raw);
3054
+ totals.rejected += 1;
3055
+ pendingEnd = line.end;
3056
+ removeQueueHead(path, pendingEnd - removed);
3057
+ removed = pendingEnd;
3058
+ };
3059
+ for (const line of lines) {
3060
+ const record = classifyStoredLine(line.raw, homedir2());
3061
+ if (record.status !== "ok") {
3062
+ await setAside(record.reason, record.status, record.identity, line);
3063
+ continue;
3064
+ }
3065
+ const lineBytes = Buffer.byteLength(record.postLine, "utf8") + 1;
3066
+ if (lineBytes > MAX_WEBHOOK_BODY_BYTES) {
3067
+ 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);
3068
+ continue;
3069
+ }
3070
+ if (chunk.length > 0 && chunkBytes + lineBytes > MAX_WEBHOOK_BODY_BYTES)
3071
+ await deliverChunk();
3072
+ chunk.push(record.postLine);
3073
+ chunkBytes += lineBytes;
3074
+ pendingEnd = line.end;
3075
+ }
3076
+ pendingEnd = buf.byteLength;
3077
+ if (chunk.length > 0) {
3078
+ await deliverChunk();
3079
+ return;
3080
+ }
3081
+ if (pendingEnd > removed)
3082
+ removeQueueHead(path, pendingEnd - removed);
3083
+ }
3084
+ async function drainRenamedAside(args, livePath, source) {
3085
+ args.keepLock();
3086
+ const draining = drainingPathFor(livePath);
3087
+ try {
3088
+ renameSync2(source, draining);
3089
+ } catch (err) {
3090
+ if (isEnoent(err))
3091
+ return;
3092
+ throw err;
3093
+ }
3094
+ await drainQueueFile({ ...args, path: draining });
3095
+ unlinkSync2(draining);
3096
+ }
2789
3097
  async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeoutMs = WEBHOOK_FETCH_TIMEOUT_MS) {
2790
3098
  const resolved = await resolveRepo();
2791
3099
  const repo = resolved && isSafeRepoSegment2(resolved.owner) && isSafeRepoSegment2(resolved.repo) ? resolved : null;
@@ -2793,61 +3101,32 @@ async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeou
2793
3101
  const path = outboxPathFor({ outboxRoot }, repo, outboxTask);
2794
3102
  const lockPath = `${path}.flush-lock`;
2795
3103
  const lockToken = acquireDrainLock(lockPath);
3104
+ const totals = { lineCount: 0, bytes: 0, chunks: 0, rejected: 0 };
2796
3105
  if (lockToken === null)
2797
- return { flushed: false };
3106
+ return { flushed: false, ...totals };
2798
3107
  try {
2799
- let lstat;
2800
- try {
2801
- lstat = lstatSync2(path);
2802
- } catch (err) {
2803
- if (!isEnoent(err))
2804
- throw err;
2805
- }
2806
- if (lstat === undefined)
2807
- return { flushed: false };
2808
- if (!lstat.isFile()) {
2809
- 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}`);
2810
- }
2811
- const buf = readFileSync4(path);
2812
- const startOffset = buf.byteLength;
2813
- const rawLines = buf.toString("utf8").split(`
2814
- `).filter((l) => l.length > 0);
2815
- if (rawLines.length === 0)
2816
- return { flushed: false };
2817
- const postLines = [];
2818
- for (let i = 0;i < rawLines.length; i++) {
2819
- const record = classifyStoredLine(rawLines[i], homedir2());
2820
- if (record.status !== "ok") {
2821
- throw new WebhookDrainError("log-webhook-drain-corrupt-line", `log webhook drain: outbox line ${i} failed schema re-validation — ${record.reason}`);
2822
- }
2823
- postLines.push(record.postLine);
2824
- }
2825
- const body = `${postLines.join(`
2826
- `)}
2827
- `;
2828
- const bytes = Buffer.byteLength(body, "utf8");
2829
- if (bytes > MAX_WEBHOOK_BODY_BYTES) {
2830
- throw new WebhookDrainError("log-webhook-drain-too-large", `log webhook drain: outbox body is ${bytes} byte(s), over the ${MAX_WEBHOOK_BODY_BYTES}-byte per-call cap — flush more often to drain it.`);
2831
- }
2832
- let response;
2833
- try {
2834
- response = await fetch(webhookUrl, {
2835
- method: "POST",
2836
- headers: { "content-type": "application/x-ndjson", ...headers },
2837
- body,
2838
- signal: AbortSignal.timeout(fetchTimeoutMs)
2839
- });
2840
- } catch (err) {
2841
- const reason = err instanceof Error && err.name === "TimeoutError" ? `timed out after ${fetchTimeoutMs}ms` : err instanceof Error ? err.message : String(err);
2842
- throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} failed: ${reason}`);
2843
- }
2844
- if (!response.ok) {
2845
- throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} returned ${response.status} ${response.statusText}`);
3108
+ const keepLock = () => {
3109
+ if (renewDrainLock(lockPath, lockToken))
3110
+ return;
3111
+ 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`);
3112
+ };
3113
+ const shared = {
3114
+ rejectedPath: rejectedPathFor(path),
3115
+ webhookUrl,
3116
+ headers,
3117
+ fetchTimeoutMs,
3118
+ totals,
3119
+ keepLock
3120
+ };
3121
+ const draining = drainingPathFor(path);
3122
+ if (queueBucketSize(draining) !== null) {
3123
+ keepLock();
3124
+ await drainQueueFile({ ...shared, path: draining });
3125
+ unlinkSync2(draining);
2846
3126
  }
2847
- const liveNow = readFileSync4(path);
2848
- const tail = liveNow.subarray(Math.min(startOffset, liveNow.byteLength));
2849
- writeFileSync2(path, tail);
2850
- return { flushed: true, lineCount: postLines.length, bytes };
3127
+ await drainRenamedAside(shared, path, backupPathFor(path));
3128
+ await drainRenamedAside(shared, path, path);
3129
+ return { flushed: totals.chunks > 0 || totals.rejected > 0, ...totals };
2851
3130
  } finally {
2852
3131
  releaseDrainLock(lockPath, lockToken);
2853
3132
  }
@@ -2954,6 +3233,96 @@ async function resolveDoctrine(cwd, vinayaVersion) {
2954
3233
  return vinayaVersion;
2955
3234
  }
2956
3235
  }
3236
+ var TRANCHE_SLUG_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
3237
+ function taskRefFromBranch2(branch) {
3238
+ const backlog = /^task\/issue-(\d+)$/.exec(branch);
3239
+ if (backlog) {
3240
+ const issue = Number(backlog[1]);
3241
+ return Number.isSafeInteger(issue) && issue > 0 ? { kind: "issue", issue } : null;
3242
+ }
3243
+ const tranche = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
3244
+ if (tranche && TRANCHE_SLUG_PATTERN.test(tranche[1] ?? "")) {
3245
+ return { kind: "tranche", tranche: tranche[1], taskId: tranche[2] };
3246
+ }
3247
+ return null;
3248
+ }
3249
+ var TRANCHE_ISSUE_LIST_LIMIT = 200;
3250
+ async function issueForTrancheTask(tranche, taskId, cwd, repo) {
3251
+ let stdout;
3252
+ try {
3253
+ ({ stdout } = await execFileAsync5("gh", [
3254
+ "issue",
3255
+ "list",
3256
+ "--state",
3257
+ "all",
3258
+ "--label",
3259
+ `vinaya/tranche:${tranche}`,
3260
+ "--json",
3261
+ "number,title,labels",
3262
+ "--limit",
3263
+ String(TRANCHE_ISSUE_LIST_LIMIT),
3264
+ ...repo === null ? [] : ["--repo", repo]
3265
+ ], {
3266
+ cwd,
3267
+ encoding: "utf8",
3268
+ maxBuffer: 8 * 1024 * 1024,
3269
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
3270
+ killSignal: "SIGKILL"
3271
+ }));
3272
+ } catch {
3273
+ return null;
3274
+ }
3275
+ let issues;
3276
+ try {
3277
+ issues = JSON.parse(stdout);
3278
+ } catch {
3279
+ return null;
3280
+ }
3281
+ for (const issue of issues) {
3282
+ const ref = resolveTaskIssueRef(issue.title, issue.labels.map((l) => l.name));
3283
+ if (ref && ref.trancheSlug === tranche && ref.taskId === taskId)
3284
+ return issue.number;
3285
+ }
3286
+ return null;
3287
+ }
3288
+ async function confirmBacklogIssue(issue, cwd, repo) {
3289
+ let stdout;
3290
+ try {
3291
+ ({ stdout } = await execFileAsync5("gh", ["issue", "view", String(issue), "--json", "number", ...repo === null ? [] : ["--repo", repo]], {
3292
+ cwd,
3293
+ encoding: "utf8",
3294
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
3295
+ killSignal: "SIGKILL"
3296
+ }));
3297
+ } catch (err) {
3298
+ const stderr = typeof err.stderr === "string" ? err.stderr : "";
3299
+ return /could not resolve|not found|no such|does not exist/i.test(stderr) ? "denied" : "unknown";
3300
+ }
3301
+ try {
3302
+ return JSON.parse(stdout).number === issue ? "confirmed" : "denied";
3303
+ } catch {
3304
+ return "unknown";
3305
+ }
3306
+ }
3307
+ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
3308
+ let branch;
3309
+ try {
3310
+ branch = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "--abbrev-ref", "HEAD"], {
3311
+ encoding: "utf8",
3312
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
3313
+ killSignal: "SIGKILL"
3314
+ })).stdout.trim();
3315
+ } catch {
3316
+ return null;
3317
+ }
3318
+ const named = branch === "HEAD" ? env.GITHUB_HEAD_REF ?? "" : branch;
3319
+ const ref = taskRefFromBranch2(named);
3320
+ if (ref === null)
3321
+ return null;
3322
+ if (ref.kind === "tranche")
3323
+ return await issueForTrancheTask(ref.tranche, ref.taskId, cwd, repo);
3324
+ return await confirmBacklogIssue(ref.issue, cwd, repo) === "denied" ? null : ref.issue;
3325
+ }
2957
3326
  function readVinayaVersion() {
2958
3327
  try {
2959
3328
  const pkg = JSON.parse(readFileSync5(join7(packageRoot(import.meta.url), "package.json"), "utf8"));
@@ -2966,6 +3335,11 @@ var SAFE_PATH_SEGMENT3 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
2966
3335
  function isSafeRepoSegment3(segment) {
2967
3336
  return SAFE_PATH_SEGMENT3.test(segment) && !segment.includes("..");
2968
3337
  }
3338
+ function safeRepoSlug(repo) {
3339
+ if (repo === null)
3340
+ return null;
3341
+ return isSafeRepoSegment3(repo.owner) && isSafeRepoSegment3(repo.repo) ? `${repo.owner}/${repo.repo}` : null;
3342
+ }
2969
3343
  function outboxPathFor(deps, repo, issue) {
2970
3344
  const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
2971
3345
  const fileName = `${issue ?? "none"}.ndjson`;
@@ -2987,6 +3361,18 @@ function defaultStderr(message) {
2987
3361
  warnedThisProcess = true;
2988
3362
  process.stderr.write(message);
2989
3363
  }
3364
+ var branchIssueFallbackEnabled = true;
3365
+ var branchIssueByCwd = new Map;
3366
+ function branchIssueRead(key, read, shared) {
3367
+ if (!shared)
3368
+ return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
3369
+ const cached = branchIssueByCwd.get(key);
3370
+ if (cached !== undefined)
3371
+ return cached;
3372
+ const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
3373
+ branchIssueByCwd.set(key, reading);
3374
+ return reading;
3375
+ }
2990
3376
  function defaultDeps() {
2991
3377
  return {
2992
3378
  outboxRoot: () => join7(GLOBAL_VINAYA_HOME, "outbox"),
@@ -3012,6 +3398,24 @@ function guardedAppendOpen(path) {
3012
3398
  return;
3013
3399
  }
3014
3400
  }
3401
+ function appendHardenedLine(path, line) {
3402
+ try {
3403
+ mkdirSync4(dirname6(path), { recursive: true, mode: 448 });
3404
+ const fd = guardedAppendOpen(path);
3405
+ if (fd === undefined)
3406
+ return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
3407
+ try {
3408
+ if (!fstatSync2(fd).isFile())
3409
+ return `target is not a regular file: ${path}`;
3410
+ writeSync3(fd, line);
3411
+ } finally {
3412
+ closeSync4(fd);
3413
+ }
3414
+ return null;
3415
+ } catch (err) {
3416
+ return err instanceof Error ? err.message : String(err);
3417
+ }
3418
+ }
3015
3419
  function reportRotationOverflow(backupPath, warn) {
3016
3420
  let raw;
3017
3421
  try {
@@ -3079,7 +3483,11 @@ function appendLine(path, line, warn) {
3079
3483
  }
3080
3484
  }
3081
3485
  function createLogSink(overrides = {}) {
3082
- const deps = { ...defaultDeps(), ...overrides };
3486
+ const deps = {
3487
+ ...defaultDeps(),
3488
+ resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
3489
+ ...overrides
3490
+ };
3083
3491
  const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
3084
3492
  const processId = randomUUID2();
3085
3493
  let seq = 0;
@@ -3099,6 +3507,19 @@ function createLogSink(overrides = {}) {
3099
3507
  }
3100
3508
  return doctrineCache;
3101
3509
  };
3510
+ const readerIsReal = overrides.resolveBranchIssue === undefined;
3511
+ let ownBranchIssue;
3512
+ const branchIssueOnce = (repo) => {
3513
+ if (!branchIssueFallbackEnabled)
3514
+ return Promise.resolve(null);
3515
+ const slug = safeRepoSlug(repo);
3516
+ const read = () => deps.resolveBranchIssue(slug);
3517
+ if (readerIsReal)
3518
+ return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
3519
+ if (ownBranchIssue === undefined)
3520
+ ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
3521
+ return ownBranchIssue;
3522
+ };
3102
3523
  let resolveRepoCache;
3103
3524
  const resolveRepoOnce = () => {
3104
3525
  if (resolveRepoCache === undefined)
@@ -3121,6 +3542,7 @@ function createLogSink(overrides = {}) {
3121
3542
  };
3122
3543
  let drainChain = Promise.resolve();
3123
3544
  const pendingWrites = new Set;
3545
+ let writeChain = Promise.resolve();
3124
3546
  const scheduleWebhookDrain = (issue, url, headers) => {
3125
3547
  drainChain = drainChain.then(() => drainOutboxToWebhook(issue, url, headers)).then(() => {
3126
3548
  return;
@@ -3143,7 +3565,14 @@ function createLogSink(overrides = {}) {
3143
3565
  attempt: env.VINAYA_ATTEMPT,
3144
3566
  parent: env.VINAYA_PARENT_EVENT
3145
3567
  };
3146
- const written = context().then(({ repo, doctrine: doctrineValue, destination: resolvedDestination }) => {
3568
+ const write = async () => {
3569
+ const { repo, doctrine: doctrineValue, destination: resolvedDestination } = await context();
3570
+ if (resolvedDestination.kind === "none") {
3571
+ warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
3572
+ `);
3573
+ return;
3574
+ }
3575
+ const branchIssue = envFields.task ? null : await branchIssueOnce(repo);
3147
3576
  const header = buildHeader({
3148
3577
  now,
3149
3578
  runId,
@@ -3154,15 +3583,11 @@ function createLogSink(overrides = {}) {
3154
3583
  host,
3155
3584
  hostname: deps.hostname(),
3156
3585
  env: envFields,
3586
+ branchIssue,
3157
3587
  eventId: randomUUID2(),
3158
3588
  processId,
3159
3589
  inputVersions: deps.inputVersions()
3160
3590
  });
3161
- if (resolvedDestination.kind === "none") {
3162
- warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
3163
- `);
3164
- return;
3165
- }
3166
3591
  const full = { ...e, ...header };
3167
3592
  const parsed = LogEventSchema.safeParse(full);
3168
3593
  if (!parsed.success) {
@@ -3179,10 +3604,12 @@ function createLogSink(overrides = {}) {
3179
3604
  } else {
3180
3605
  appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
3181
3606
  }
3182
- }).catch((err) => {
3607
+ };
3608
+ const written = writeChain.then(write).catch((err) => {
3183
3609
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
3184
3610
  `);
3185
3611
  });
3612
+ writeChain = written;
3186
3613
  pendingWrites.add(written);
3187
3614
  written.finally(() => pendingWrites.delete(written));
3188
3615
  } catch (err) {
@@ -3414,7 +3841,7 @@ var COMMANDS = [
3414
3841
  details: [
3415
3842
  "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.",
3416
3843
  "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.",
3417
- "`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."
3844
+ "`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."
3418
3845
  ],
3419
3846
  status: "shipped"
3420
3847
  },
@@ -3725,6 +4152,10 @@ var COMMANDS = [
3725
4152
  flag: "--role <name>",
3726
4153
  description: "Resolve to a specific role file (roles/<name>.md) instead of the front door"
3727
4154
  },
4155
+ {
4156
+ flag: "--template <name>",
4157
+ description: "Print a template the package ships (templates/<name>-template.md) instead of the front door"
4158
+ },
3728
4159
  {
3729
4160
  flag: "--print",
3730
4161
  description: "Emit the resolved file's body (frontmatter stripped) instead of its path — the one-hop mode every generated skill and slash command invokes. A role file whose frontmatter carries an `ack-token` emits that token as the output's own first line."
@@ -3921,6 +4352,9 @@ var StateSourceConfigSchema = z5.discriminatedUnion("kind", [
3921
4352
  var issueCache = new Map;
3922
4353
  var siblingTrancheCache = new Map;
3923
4354
 
4355
+ // src/commands/doctrine.ts
4356
+ import matter2 from "gray-matter";
4357
+
3924
4358
  // src/lib/brief-assembly.ts
3925
4359
  var PACKAGE_ROOT = packageRoot(import.meta.url);
3926
4360
  var PACKAGED_TEMPLATE_PATH = join8(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
@@ -3936,6 +4370,7 @@ var INFORMATIONAL_DISPATCH_BLOCKER_CLASSES = new Set([
3936
4370
  // src/lib/dispatch.ts
3937
4371
  var MAX_TEE_BYTES = 8 * 1024 * 1024;
3938
4372
  var CLAUDE_MODEL_ALIASES = new Set(["fable", "opus", "sonnet", "haiku"]);
4373
+ var NO_SUBSCRIPTION_LOGIN_REASON = "this agent has no subscription login in Vinaya yet, and no agent authenticates with an API key — " + "dispatch a vendor whose subscription login Vinaya can stage (claude, codex)";
3939
4374
 
3940
4375
  // src/commands/tokens.ts
3941
4376
  var USAGE = [