@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
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/checks/bin/check-evidence-fresh.ts
4
- import { execFileSync as execFileSync7 } from "node:child_process";
4
+ import { execFileSync as execFileSync8 } from "node:child_process";
5
5
  // ../../packages/aeg-core/src/gate-audience.ts
6
6
  var GATE_AUDIENCE = {
7
7
  "check-branch-topology": { shippedAs: "branch-topology", ring: 0 },
@@ -196,8 +196,8 @@ function maskIndentedCode(body, fill) {
196
196
  var SECTION_HEADER = /\*\*Dependency rationale\*\*/i;
197
197
  var NEXT_HEADER = /\*\*[A-Z][^*]*\*\*/;
198
198
  var FIELD_LABEL = /^(Depends-on|Conflicts-with)\s*:\s*(.*)$/i;
199
- var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+[a-z]?$/i;
200
- var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+[a-z]?)$/i;
199
+ var ID_TOKEN = /^(?:[\w.-]+\s+)?#?\d+$/i;
200
+ var SLUG_QUALIFIED_ID = /^([\w.-]+)\s+(#?\d+)$/i;
201
201
  function splitSlugQualifiedEdge(edge) {
202
202
  const m = edge.trim().match(SLUG_QUALIFIED_ID);
203
203
  if (!m)
@@ -2045,12 +2045,24 @@ function extractBaseSha(comment) {
2045
2045
  const m = firstThirteenLines(comment).match(BASE_SHA_PATTERN);
2046
2046
  return m ? m[1].toLowerCase() : null;
2047
2047
  }
2048
- var FINDING_SEVERITY_LINE = /^\d+\.\s+\[([A-Z][A-Z]*)\]\s+(.+?)\s+—/gm;
2048
+ var FINDING_DESCRIPTION_STATE = /^F(\d+)(?:\s+\S+)?(?:\s+(open|fix-claimed|reproduced|resolved))?:/;
2049
+ function parseFindingState(description) {
2050
+ const m = FINDING_DESCRIPTION_STATE.exec(description.trim());
2051
+ if (!m)
2052
+ return { id: null, state: null };
2053
+ return { id: `F${m[1]}`, state: m[2] ?? null };
2054
+ }
2055
+ var FINDING_SEVERITY_LINE = /^\d+\.\s+\[([A-Z][A-Z]*)\]\s+(.+?)\s+—(?:\s+(.*))?$/gm;
2049
2056
  function extractFindingSeverities(comment) {
2050
- return [...comment.matchAll(FINDING_SEVERITY_LINE)].map((m) => ({
2051
- severity: m[1],
2052
- location: m[2]
2053
- }));
2057
+ return [...comment.matchAll(FINDING_SEVERITY_LINE)].map((m) => {
2058
+ const { id, state } = parseFindingState(m[3] ?? "");
2059
+ return {
2060
+ severity: m[1],
2061
+ location: m[2],
2062
+ id,
2063
+ state
2064
+ };
2065
+ });
2054
2066
  }
2055
2067
  function extractVerdict(comments, valuePattern, missingLabel) {
2056
2068
  const candidates = comments.filter((c) => valuePattern.test(c));
@@ -2464,6 +2476,12 @@ function evaluateReviewFindings(findings, scale, threshold) {
2464
2476
  });
2465
2477
  return { outcome: blockingFindings.length > 0 ? "blocked" : "clean", blockingFindings };
2466
2478
  }
2479
+ function isConsequentialFinding(finding) {
2480
+ return finding.state !== "resolved";
2481
+ }
2482
+ function consequentialFindings(findings) {
2483
+ return findings.filter((f) => isConsequentialFinding(f));
2484
+ }
2467
2485
  function evaluateCodeReview(findings, policy) {
2468
2486
  return evaluateReviewFindings(findings, CODE_REVIEW_SEVERITY_ORDER, policy.codeReviewThreshold);
2469
2487
  }
@@ -2600,7 +2618,7 @@ function isIssueNotFoundError(err) {
2600
2618
  return /could not resolve to an (?:issue|pull request)|\b404\b|not found/i.test(haystack);
2601
2619
  }
2602
2620
  function resolveObjectivesSource(prBody, issue, cutoverIssue) {
2603
- if (issue !== null && issue < cutoverIssue)
2621
+ if (issue !== null && cutoverIssue !== null && issue < cutoverIssue)
2604
2622
  return { kind: "none" };
2605
2623
  if (issue !== null)
2606
2624
  return { kind: "issue", issue };
@@ -2876,9 +2894,18 @@ var COMMIT_TYPES = [
2876
2894
  ];
2877
2895
  var COMMIT_TYPE_STYLE = new RegExp(`^(${COMMIT_TYPES.join("|")})(\\([a-z0-9-]+\\))?: \\S`);
2878
2896
  function checkForgeTitle(title) {
2879
- const taskStyle = /^\[[a-z0-9._-]+\] \S+ — \S/;
2897
+ const taskStyle = /^\[[a-z0-9._-]+\] \d+ — \S/;
2880
2898
  if (COMMIT_TYPE_STYLE.test(title) || taskStyle.test(title))
2881
2899
  return { status: "pass", errors: [] };
2900
+ const letteredTaskId = /^\[[a-z0-9._-]+\] (\S+) — \S/.exec(title);
2901
+ if (letteredTaskId) {
2902
+ return {
2903
+ status: "fail",
2904
+ errors: [
2905
+ `brief-validation title: "${title}" names task id \`${letteredTaskId[1]}\` — task ids are whole numbers (\`1\`, \`2\`), never lettered (\`2a\`). \`vinaya task run\` and \`task dispatch\` refuse a non-numeric id, so a plan titled this way names a task that cannot be started.`
2906
+ ]
2907
+ };
2908
+ }
2882
2909
  return {
2883
2910
  status: "fail",
2884
2911
  errors: [
@@ -2911,19 +2938,31 @@ function checkNoAgentBoxes(prBody) {
2911
2938
  ]
2912
2939
  };
2913
2940
  }
2914
- function rolloutThresholdFor(message) {
2941
+ function rolloutRuleFor(message) {
2915
2942
  if (message.startsWith("brief-validation unpinned code claim:") || message.startsWith("brief-validation commands carry output:") || message.startsWith("brief-validation consumer tests:") || message.startsWith("brief-validation defeat cases:")) {
2916
- return BRIEF_RULES_SINCE_PR;
2943
+ return "briefRules";
2917
2944
  }
2918
2945
  if (message.startsWith("brief-validation no agent boxes:"))
2919
- return AGENT_BOXES_REFUSED_SINCE_PR;
2946
+ return "agentBoxes";
2920
2947
  return null;
2921
2948
  }
2922
- function partitionBriefErrorsByRollout(errors, prNumber) {
2949
+ var DEFAULT_BRIEF_ROLLOUT_CUTOVERS = {
2950
+ briefRulesSincePr: BRIEF_RULES_SINCE_PR,
2951
+ agentBoxesRefusedSincePr: AGENT_BOXES_REFUSED_SINCE_PR
2952
+ };
2953
+ function rolloutThresholdFor(message, cutovers) {
2954
+ const rule = rolloutRuleFor(message);
2955
+ if (rule === "briefRules")
2956
+ return cutovers.briefRulesSincePr;
2957
+ if (rule === "agentBoxes")
2958
+ return cutovers.agentBoxesRefusedSincePr;
2959
+ return null;
2960
+ }
2961
+ function partitionBriefErrorsByRollout(errors, prNumber, cutovers = DEFAULT_BRIEF_ROLLOUT_CUTOVERS) {
2923
2962
  const blocking = [];
2924
2963
  const info = [];
2925
2964
  for (const e of errors) {
2926
- const threshold = rolloutThresholdFor(e);
2965
+ const threshold = rolloutThresholdFor(e, cutovers);
2927
2966
  const grandfathered = threshold !== null && prNumber !== null && prNumber < threshold;
2928
2967
  (grandfathered ? info : blocking).push(e);
2929
2968
  }
@@ -3391,8 +3430,8 @@ function checkIssueRationale(body) {
3391
3430
  return { status: errors.length > 0 ? "fail" : "pass", errors };
3392
3431
  }
3393
3432
  var OBJECTIVES_SINCE_ISSUE = 404;
3394
- function checkIssueObjectives(body, issueNumber) {
3395
- if (issueNumber !== null && issueNumber < OBJECTIVES_SINCE_ISSUE)
3433
+ function checkIssueObjectives(body, issueNumber, sinceIssue = OBJECTIVES_SINCE_ISSUE) {
3434
+ if (sinceIssue !== null && issueNumber !== null && issueNumber < sinceIssue)
3396
3435
  return { status: "pass", errors: [] };
3397
3436
  const result = objectivesOf(body);
3398
3437
  if (result.ok)
@@ -3837,7 +3876,7 @@ function resolveDepEntry(dep, trancheSlug, issueToEntry, taskToEntry) {
3837
3876
  return issueToEntry.get(Number(issueMatch[1]));
3838
3877
  return taskToEntry.get(`${trancheSlug}/${dep}`) ?? taskToEntry.get(dep);
3839
3878
  }
3840
- function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
3879
+ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = [], objectivesSinceIssue) {
3841
3880
  const failures = [];
3842
3881
  for (const [slug, issues] of issuesBySlug) {
3843
3882
  for (const issue of issues) {
@@ -3846,7 +3885,7 @@ function checkR1(issuesBySlug, grandfatheredIssues, registeredNames = []) {
3846
3885
  const errors = [
3847
3886
  ...checkIssueRationale(issue.body).errors,
3848
3887
  ...checkProjectsRegistered(issue.body, issue.labels, registeredNames).errors,
3849
- ...checkIssueObjectives(issue.body, issue.number).errors,
3888
+ ...checkIssueObjectives(issue.body, issue.number, objectivesSinceIssue).errors,
3850
3889
  ...checkPartsCiteDefinedObjectives(issue.body).errors
3851
3890
  ];
3852
3891
  if (errors.length === 0)
@@ -4096,8 +4135,8 @@ function checkReviewGate(input) {
4096
4135
  let codeReviewPolicyEvaluation;
4097
4136
  let securityPolicyEvaluation;
4098
4137
  try {
4099
- codeReviewPolicyEvaluation = evaluateCodeReview(codeReview.findingSeverities, policy);
4100
- securityPolicyEvaluation = evaluateSecurityReview(security.findingSeverities, policy);
4138
+ codeReviewPolicyEvaluation = evaluateCodeReview(consequentialFindings(codeReview.findingSeverities), policy);
4139
+ securityPolicyEvaluation = evaluateSecurityReview(consequentialFindings(security.findingSeverities), policy);
4101
4140
  } catch (err) {
4102
4141
  return {
4103
4142
  verdict: "fail",
@@ -4469,13 +4508,27 @@ var SHIPS_PREFIX = "aeg-root/";
4469
4508
  function shipsArchivePrefix(shipsPrefix) {
4470
4509
  return `${shipsPrefix}tranches/completed/`;
4471
4510
  }
4472
- function isSpecFile2(path) {
4473
- return path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md");
4511
+ var DEFAULT_SPEC_PATHS = ["SPEC.md", "CONTEXT.md", "docs/adr"];
4512
+ function normalizeSpecPath(entry) {
4513
+ let out = entry.replace(/\\/g, "/");
4514
+ while (out.startsWith("./"))
4515
+ out = out.slice(2);
4516
+ out = out.replace(/\/{2,}/g, "/");
4517
+ while (out.endsWith("/"))
4518
+ out = out.slice(0, -1);
4519
+ return out;
4520
+ }
4521
+ function isSpecFile2(path, specPaths) {
4522
+ if (path.startsWith("apps/") && path.includes("/specs/") && path.endsWith(".md"))
4523
+ return true;
4524
+ if (!path.endsWith(".md"))
4525
+ return false;
4526
+ return specPaths.some((entry) => isUnderOrEqual(path, normalizeSpecPath(entry)));
4474
4527
  }
4475
4528
  function isClaudeMdFile(path) {
4476
4529
  return path === "CLAUDE.md" || path.endsWith("/CLAUDE.md");
4477
4530
  }
4478
- function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX) {
4531
+ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPrefix = SHIPS_PREFIX, specPaths = DEFAULT_SPEC_PATHS) {
4479
4532
  if (path.startsWith(shipsPrefix)) {
4480
4533
  return path.startsWith(shipsArchivePrefix(shipsPrefix)) ? "internal" : "ships";
4481
4534
  }
@@ -4484,7 +4537,7 @@ function classifyProseFile(path, readerFacingPrefix, readerFacingSuffix, shipsPr
4484
4537
  }
4485
4538
  if (isClaudeMdFile(path))
4486
4539
  return "internal";
4487
- if (isSpecFile2(path))
4540
+ if (isSpecFile2(path, specPaths))
4488
4541
  return "spec";
4489
4542
  if (isProductScopeFile(path))
4490
4543
  return "product";
@@ -4513,13 +4566,14 @@ function lineAt(content, index) {
4513
4566
  }
4514
4567
  var FORGE_NUMBER_PATTERN = /#[0-9]{2,4}/g;
4515
4568
  var TRANCHE_SLUG_VN_PATTERN = /[a-z][a-z-]+-v[0-9]/g;
4569
+ var TASK_NUMBER_PATTERN = /(^|[^a-z0-9-])(tasks?[ \t]+#?[0-9]+)/gi;
4516
4570
  function legacySlugPattern(legacySlugs) {
4517
4571
  if (legacySlugs.length === 0)
4518
4572
  return null;
4519
4573
  const alternation = legacySlugs.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
4520
4574
  return new RegExp(`(^|[^a-zA-Z0-9\\n-])(${alternation})([^a-zA-Z0-9\\n-]|$)`, "g");
4521
4575
  }
4522
- function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = []) {
4576
+ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4523
4577
  const findings = [];
4524
4578
  const legacyPattern = legacySlugPattern(legacySlugs);
4525
4579
  const grandfathered = new Set(specGrandfather);
@@ -4531,8 +4585,12 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
4531
4585
  const productPatterns = [
4532
4586
  { pattern: TRANCHE_SLUG_VN_PATTERN, what: "an internal tranche slug in product code" }
4533
4587
  ];
4588
+ const specPatterns = [
4589
+ ...patterns,
4590
+ { pattern: TASK_NUMBER_PATTERN, what: "a task number", group: 2 }
4591
+ ];
4534
4592
  for (const file of files) {
4535
- const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix);
4593
+ const cls = classifyProseFile(file.path, readerFacingPrefix, readerFacingSuffix, shipsPrefix, specPaths);
4536
4594
  if (!cls || cls === "internal")
4537
4595
  continue;
4538
4596
  if (cls !== "product" && cls !== "spec" && !SWEPT_CLASSES.has(cls))
@@ -4541,15 +4599,16 @@ function checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuff
4541
4599
  continue;
4542
4600
  const blocking = cls === "product" || cls === "spec";
4543
4601
  const scrubbed = cls === "product" ? stripNonProseForProduct(file.path, file.content) : stripNonProse(file.path, file.content);
4544
- const patternsToRun = cls === "product" ? productPatterns : patterns;
4602
+ const patternsToRun = cls === "product" ? productPatterns : cls === "spec" ? specPatterns : patterns;
4545
4603
  for (const { pattern, what, group } of patternsToRun) {
4546
4604
  pattern.lastIndex = 0;
4547
4605
  let match = pattern.exec(scrubbed);
4548
4606
  while (match !== null) {
4549
4607
  const cited = group !== undefined ? match[group] ?? match[0] : match[0];
4608
+ const citedIndex = match.index + match[0].indexOf(cited);
4550
4609
  findings.push({
4551
4610
  file: file.path,
4552
- line: lineAt(scrubbed, match.index),
4611
+ line: lineAt(scrubbed, citedIndex),
4553
4612
  message: `references ${what} ("${cited}") a reader outside this repo's tracker cannot resolve`,
4554
4613
  blocking
4555
4614
  });
@@ -4735,9 +4794,9 @@ function checkSourceComments(files, allowlist = []) {
4735
4794
  }
4736
4795
  return findings;
4737
4796
  }
4738
- function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = []) {
4797
+ function checkReaderResolvableProse(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, legacySlugs = [], shipsPrefix = SHIPS_PREFIX, specGrandfather = [], specPaths = DEFAULT_SPEC_PATHS) {
4739
4798
  return [
4740
- ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather),
4799
+ ...checkUnresolvableReferences(files, readerFacingPrefix, readerFacingSuffix, legacySlugs, shipsPrefix, specGrandfather, specPaths),
4741
4800
  ...checkUndefinedVocabulary(files, glossaryTerms, readerFacingPrefix, readerFacingSuffix, shipsPrefix)
4742
4801
  ];
4743
4802
  }
@@ -5178,15 +5237,32 @@ var ObservedSchema = z.object({
5178
5237
  var TaskStatusInputSchema = z.object({
5179
5238
  task: TaskToolRefSchema.optional()
5180
5239
  }).merge(PageRequestSchema).strict();
5240
+ var TaskConfidenceSchema = z.object({
5241
+ round: z.number().int().positive(),
5242
+ percent: z.number().int().min(0).max(100).nullable(),
5243
+ source: z.enum(["stated", "published-summary"])
5244
+ }).strict();
5245
+ var TaskPhaseHistorySchema = z.object({
5246
+ typicalPhaseMinutes: z.number().nonnegative(),
5247
+ typicalPhaseSamples: z.number().int().positive()
5248
+ }).strict();
5181
5249
  var TaskStatusItemSchema = z.object({
5182
5250
  task: TaskToolRefSchema,
5183
5251
  issue: z.number().int().positive(),
5184
5252
  pr: z.number().int().positive().nullable(),
5185
- state: z.string()
5253
+ state: z.string(),
5254
+ round: z.number().int().positive().nullable().optional(),
5255
+ phase: z.string().min(1).nullable().optional(),
5256
+ minutesInPhase: z.number().nonnegative().nullable().optional(),
5257
+ phaseIsCurrent: z.boolean().nullable().optional(),
5258
+ lastConfidence: TaskConfidenceSchema.nullable().optional(),
5259
+ lastConfidenceUnread: z.boolean().optional(),
5260
+ phaseHistory: TaskPhaseHistorySchema.nullable().optional()
5186
5261
  }).merge(ObservedSchema);
5187
5262
  var TaskStatusResultSchema = z.object({
5188
5263
  items: z.array(TaskStatusItemSchema),
5189
- nextCursor: z.string().nullable()
5264
+ nextCursor: z.string().nullable(),
5265
+ table: z.string()
5190
5266
  });
5191
5267
  var RequestedAuthoritySchema = z.enum(["planner", "principal", "operator", "self"]);
5192
5268
  var EscalationInputsSchema = z.object({
@@ -5194,7 +5270,7 @@ var EscalationInputsSchema = z.object({
5194
5270
  round: z.number().int().nonnegative(),
5195
5271
  head: z.string(),
5196
5272
  branch: z.string(),
5197
- prNumber: z.number().int().positive()
5273
+ prNumber: z.number().int().positive().nullable()
5198
5274
  });
5199
5275
  var EscalationEvidenceSchema = z.object({
5200
5276
  round: z.number().int().nonnegative(),
@@ -5230,13 +5306,45 @@ var TaskEscalationReadResultSchema = z.object({
5230
5306
  items: z.array(TaskEscalationPacketSchema),
5231
5307
  nextCursor: z.string().nullable()
5232
5308
  }).merge(ObservedSchema);
5233
- var TaskStartInputSchema = z.object({
5234
- tranche: z.string().min(1),
5235
- id: z.string().min(1)
5309
+ var TaskPrCheckSchema = z.object({
5310
+ name: z.string(),
5311
+ required: z.boolean(),
5312
+ status: z.string(),
5313
+ conclusion: z.string().nullable(),
5314
+ detailsUrl: z.string().nullable(),
5315
+ failureSummary: z.string().nullable()
5316
+ });
5317
+ var TaskPrVerdictSchema = z.object({
5318
+ role: z.enum(["code-review", "security"]),
5319
+ value: z.string(),
5320
+ judgedHead: z.string().nullable(),
5321
+ objectivesVersion: z.string().nullable()
5322
+ });
5323
+ var TaskPrPauseSchema = z.object({
5324
+ reason: z.string(),
5325
+ body: z.string()
5326
+ });
5327
+ var TaskPrReviewRecordSchema = z.object({
5328
+ verdicts: z.array(TaskPrVerdictSchema),
5329
+ roundMarkers: z.array(z.number().int().nonnegative()),
5330
+ summaryTable: z.string().nullable(),
5331
+ pause: TaskPrPauseSchema.nullable()
5332
+ });
5333
+ var TaskPrReadInputSchema = z.object({
5334
+ task: TaskToolRefSchema,
5335
+ pr: z.number().int().positive().optional()
5236
5336
  }).strict();
5337
+ var TaskPrReadResultSchema = z.object({
5338
+ task: TaskToolRefSchema,
5339
+ issue: z.number().int().positive(),
5340
+ pr: z.number().int().positive(),
5341
+ head: z.string().nullable(),
5342
+ checks: z.array(TaskPrCheckSchema),
5343
+ review: TaskPrReviewRecordSchema
5344
+ }).merge(ObservedSchema);
5237
5345
  var TaskStartResultSchema = z.object({
5238
5346
  requestId: z.string().min(1),
5239
- run: z.object({ tranche: z.string().min(1), id: z.string().min(1) }),
5347
+ run: TaskToolRefSchema,
5240
5348
  started: z.boolean(),
5241
5349
  startedAt: z.string(),
5242
5350
  mode: z.literal("attended")
@@ -5250,7 +5358,7 @@ var TaskCancelInputSchema = z.object({
5250
5358
  }).strict();
5251
5359
  var TaskResumeResultSchema = z.object({
5252
5360
  task: z.number().int().positive(),
5253
- pr: z.number().int().positive(),
5361
+ pr: z.number().int().positive().nullable(),
5254
5362
  escalationId: z.string().min(1),
5255
5363
  outcome: z.enum(["started", "already_resumed"]),
5256
5364
  authenticatedBy: z.string().min(1),
@@ -5259,7 +5367,7 @@ var TaskResumeResultSchema = z.object({
5259
5367
  var TaskCancelOutcomeSchema = z.enum(["confirmed", "pending", "uncertain"]);
5260
5368
  var TaskCancelResultSchema = z.object({
5261
5369
  task: z.number().int().positive(),
5262
- pr: z.number().int().positive(),
5370
+ pr: z.number().int().positive().nullable(),
5263
5371
  escalationId: z.string().min(1),
5264
5372
  outcome: TaskCancelOutcomeSchema,
5265
5373
  authenticatedBy: z.string().min(1),
@@ -5270,6 +5378,7 @@ var TASK_TOOL_NAMES = [
5270
5378
  "task_start",
5271
5379
  "task_status",
5272
5380
  "task_escalation_read",
5381
+ "task_pr_read",
5273
5382
  "task_resume",
5274
5383
  "task_cancel"
5275
5384
  ];
@@ -5497,6 +5606,14 @@ function findWorkspaceEscapes(files, knownPaths, workspaceDirs = DEFAULT_WORKSPA
5497
5606
  }
5498
5607
  return findings;
5499
5608
  }
5609
+ // ../../packages/aeg-core/src/gate-cutovers.ts
5610
+ var NO_GATE_CUTOVERS = {
5611
+ objectivesSinceIssue: null,
5612
+ briefSectionsSinceIssue: null,
5613
+ documentationSinceIssue: null,
5614
+ briefRulesSincePr: null,
5615
+ agentBoxesRefusedSincePr: null
5616
+ };
5500
5617
  // ../../packages/aeg-core/src/dev-review-loop/types.ts
5501
5618
  var SEVERITY_COLUMNS = ["blocker", "major", "minor", "critical", "high", "medium", "low"];
5502
5619
  // ../../packages/aeg-core/src/dev-review-loop/journal-reconstruction.ts
@@ -5946,6 +6063,8 @@ function attemptFromEnv(value) {
5946
6063
  function provenanceFor(input) {
5947
6064
  if (input.provenance)
5948
6065
  return input.provenance;
6066
+ if (issueFromTask(input.env.task) === null && (input.branchIssue ?? null) !== null)
6067
+ return "unavailable";
5949
6068
  if (input.env.role || input.env.task)
5950
6069
  return "env_correlated";
5951
6070
  return "unavailable";
@@ -5966,7 +6085,7 @@ function buildHeader(input) {
5966
6085
  const role = isRole(input.env.role) ? input.env.role : "unattributed";
5967
6086
  const round = roundFromEnv(input.env.round);
5968
6087
  const subject = {
5969
- issue: issueFromTask(input.env.task),
6088
+ issue: issueFromTask(input.env.task) ?? input.branchIssue ?? null,
5970
6089
  role,
5971
6090
  ...round !== undefined ? { round } : {},
5972
6091
  ...input.subject ?? {}
@@ -7013,7 +7132,12 @@ var VinayaConfigSchema = z4.object({
7013
7132
  allowlist: z4.array(z4.string().min(1)).optional(),
7014
7133
  severity: z4.enum(["warning", "error"]).optional()
7015
7134
  }).optional(),
7016
- specGrandfather: z4.array(z4.string().min(1)).optional()
7135
+ specGrandfather: z4.array(z4.string().min(1)).optional(),
7136
+ specPaths: z4.array(z4.string().min(1).refine((entry) => !entry.startsWith("/") && !/^[A-Za-z]:/.test(entry), {
7137
+ message: "must be a repository-relative path, not an absolute one"
7138
+ }).refine((entry) => !entry.split(/[\\/]/).includes(".."), {
7139
+ message: "must stay inside the repository — no `..` segment"
7140
+ })).optional()
7017
7141
  }).optional(),
7018
7142
  projects: z4.array(ProjectEntrySchema).optional(),
7019
7143
  dispatch: z4.object({
@@ -7027,6 +7151,13 @@ var VinayaConfigSchema = z4.object({
7027
7151
  securityThreshold: z4.string().min(1).optional(),
7028
7152
  maxRounds: z4.number().optional()
7029
7153
  }).optional(),
7154
+ gateCutovers: z4.object({
7155
+ objectivesSinceIssue: z4.number().int().nonnegative().optional(),
7156
+ briefSectionsSinceIssue: z4.number().int().nonnegative().optional(),
7157
+ documentationSinceIssue: z4.number().int().nonnegative().optional(),
7158
+ briefRulesSincePr: z4.number().int().nonnegative().optional(),
7159
+ agentBoxesRefusedSincePr: z4.number().int().nonnegative().optional()
7160
+ }).optional(),
7030
7161
  prePush: z4.object({
7031
7162
  alwaysRun: z4.array(z4.string()).optional()
7032
7163
  }).optional(),
@@ -7164,6 +7295,18 @@ function resolveReviewPolicy(config) {
7164
7295
  maxRounds
7165
7296
  };
7166
7297
  }
7298
+ function resolveGateCutovers(config) {
7299
+ const raw = config?.gateCutovers;
7300
+ if (!raw)
7301
+ return NO_GATE_CUTOVERS;
7302
+ return {
7303
+ objectivesSinceIssue: raw.objectivesSinceIssue ?? null,
7304
+ briefSectionsSinceIssue: raw.briefSectionsSinceIssue ?? null,
7305
+ documentationSinceIssue: raw.documentationSinceIssue ?? null,
7306
+ briefRulesSincePr: raw.briefRulesSincePr ?? null,
7307
+ agentBoxesRefusedSincePr: raw.agentBoxesRefusedSincePr ?? null
7308
+ };
7309
+ }
7167
7310
  function resolveRuntimeDirSetting(config) {
7168
7311
  return config?.runtimeDir ?? null;
7169
7312
  }
@@ -7238,7 +7381,28 @@ function trustAnchorRepoFromRemoteUrl(url) {
7238
7381
  return m?.[1] && m[2] ? wellFormedRepoSlug(`${m[1]}/${m[2]}`) : null;
7239
7382
  }
7240
7383
  var execFileAsync4 = promisify4(execFile4);
7384
+ function resolveCiTrustAnchorProbeRef(env = process.env) {
7385
+ const ref = env.VINAYA_CI_CONFIG_PROBE_REF?.trim();
7386
+ if (!ref)
7387
+ return null;
7388
+ if (env.GITHUB_ACTIONS !== "true")
7389
+ return null;
7390
+ if ((env.GH_TOKEN ?? "").length > 0 || (env.GITHUB_TOKEN ?? "").length > 0)
7391
+ return null;
7392
+ return ref;
7393
+ }
7394
+ function readTrustAnchorConfigAtRef(ref) {
7395
+ const raw = execFileSync2("git", ["show", `${ref}:${LOCAL_CONFIG_FILENAME}`], {
7396
+ encoding: "utf-8",
7397
+ stdio: ["ignore", "pipe", "pipe"],
7398
+ timeout: 1e4
7399
+ });
7400
+ return Buffer.from(raw, "utf-8").toString("base64");
7401
+ }
7241
7402
  function ghFetchTrustAnchorConfig() {
7403
+ const probeRef = resolveCiTrustAnchorProbeRef();
7404
+ if (probeRef)
7405
+ return readTrustAnchorConfigAtRef(probeRef);
7242
7406
  const repo = trustAnchorRepo();
7243
7407
  if (!repo)
7244
7408
  throw new Error("could not resolve repo identity for the trust-anchor read");
@@ -7248,6 +7412,14 @@ function ghFetchTrustAnchorConfig() {
7248
7412
  });
7249
7413
  }
7250
7414
  async function ghFetchTrustAnchorConfigAsync() {
7415
+ const probeRef = resolveCiTrustAnchorProbeRef();
7416
+ if (probeRef) {
7417
+ const { stdout } = await execFileAsync4("git", ["show", `${probeRef}:${LOCAL_CONFIG_FILENAME}`], {
7418
+ encoding: "utf-8",
7419
+ timeout: 1e4
7420
+ });
7421
+ return Buffer.from(stdout, "utf-8").toString("base64");
7422
+ }
7251
7423
  const repo = await trustAnchorRepoAsync();
7252
7424
  if (!repo)
7253
7425
  throw new Error("could not resolve repo identity for the trust-anchor read");
@@ -7418,6 +7590,7 @@ import {
7418
7590
  renameSync,
7419
7591
  statSync,
7420
7592
  unlinkSync,
7593
+ utimesSync,
7421
7594
  writeFileSync as writeFileSync2,
7422
7595
  writeSync
7423
7596
  } from "node:fs";
@@ -7501,6 +7674,27 @@ function acquireDrainLock(lockPath) {
7501
7674
  unlinkSync(claimed);
7502
7675
  return tryCreateLock(lockPath, token) ? token : null;
7503
7676
  }
7677
+ function renewDrainLock(lockPath, token) {
7678
+ let holder;
7679
+ try {
7680
+ holder = readFileSync3(lockPath, "utf8").trim();
7681
+ } catch (err) {
7682
+ if (!isEnoent(err))
7683
+ throw err;
7684
+ return false;
7685
+ }
7686
+ if (holder !== token)
7687
+ return false;
7688
+ const now = new Date;
7689
+ try {
7690
+ utimesSync(lockPath, now, now);
7691
+ } catch (err) {
7692
+ if (!isEnoent(err))
7693
+ throw err;
7694
+ return false;
7695
+ }
7696
+ return true;
7697
+ }
7504
7698
  function releaseDrainLock(lockPath, token) {
7505
7699
  try {
7506
7700
  const holder = readFileSync3(lockPath, "utf8").trim();
@@ -7520,6 +7714,172 @@ class WebhookDrainError extends Error {
7520
7714
  this.code = code;
7521
7715
  }
7522
7716
  }
7717
+ function backupPathFor(queuePath) {
7718
+ return queuePath.replace(/\.ndjson$/, ".1.ndjson");
7719
+ }
7720
+ function drainingPathFor(queuePath) {
7721
+ return queuePath.replace(/\.ndjson$/, ".draining.ndjson");
7722
+ }
7723
+ function rejectedPathFor(queuePath) {
7724
+ return queuePath.replace(/\.ndjson$/, ".rejected.ndjson");
7725
+ }
7726
+ var rejectionWarnedThisProcess = false;
7727
+ function warnRejectionOnce(message) {
7728
+ if (rejectionWarnedThisProcess)
7729
+ return;
7730
+ rejectionWarnedThisProcess = true;
7731
+ try {
7732
+ process.stderr.write(message);
7733
+ } catch {}
7734
+ }
7735
+ function queueLines(buf) {
7736
+ const lines = [];
7737
+ let start = 0;
7738
+ for (let i = 0;i < buf.byteLength; i++) {
7739
+ if (buf[i] !== 10)
7740
+ continue;
7741
+ if (i > start)
7742
+ lines.push({ raw: buf.toString("utf8", start, i), end: i + 1 });
7743
+ start = i + 1;
7744
+ }
7745
+ if (start < buf.byteLength)
7746
+ lines.push({ raw: buf.toString("utf8", start), end: buf.byteLength });
7747
+ return lines;
7748
+ }
7749
+ function removeQueueHead(path, cut) {
7750
+ const remaining = readFileSync3(path);
7751
+ writeFileSync2(path, remaining.subarray(Math.min(cut, remaining.byteLength)));
7752
+ }
7753
+ function queueBucketSize(path) {
7754
+ let lstat;
7755
+ try {
7756
+ lstat = lstatSync(path);
7757
+ } catch (err) {
7758
+ if (!isEnoent(err))
7759
+ throw err;
7760
+ }
7761
+ if (lstat === undefined)
7762
+ return null;
7763
+ if (!lstat.isFile()) {
7764
+ 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}`);
7765
+ }
7766
+ return Number(lstat.size);
7767
+ }
7768
+ function readQueueFile(path) {
7769
+ if (queueBucketSize(path) === null)
7770
+ return null;
7771
+ return readFileSync3(path);
7772
+ }
7773
+ function rejectLine(rejectedPath, reason, status, identity, raw) {
7774
+ const record = JSON.stringify({
7775
+ rejected_at: new Date().toISOString(),
7776
+ status,
7777
+ reason,
7778
+ identity,
7779
+ bytes: Buffer.byteLength(raw, "utf8"),
7780
+ raw
7781
+ });
7782
+ const failure = appendHardenedLine(rejectedPath, `${record}
7783
+ `);
7784
+ if (failure !== null) {
7785
+ 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`);
7786
+ }
7787
+ warnRejectionOnce(`vinaya: log delivery set a queued line aside in ${rejectedPath} — ${reason}; later lines keep delivering
7788
+ `);
7789
+ }
7790
+ async function postChunk(webhookUrl, headers, body, fetchTimeoutMs, chunksAlreadyDelivered) {
7791
+ const delivered = chunksAlreadyDelivered > 0 ? ` after delivering ${chunksAlreadyDelivered} chunk(s)` : "";
7792
+ let response;
7793
+ try {
7794
+ response = await fetch(webhookUrl, {
7795
+ method: "POST",
7796
+ headers: { "content-type": "application/x-ndjson", ...headers },
7797
+ body,
7798
+ signal: AbortSignal.timeout(fetchTimeoutMs)
7799
+ });
7800
+ } catch (err) {
7801
+ const reason = err instanceof Error && err.name === "TimeoutError" ? `timed out after ${fetchTimeoutMs}ms` : err instanceof Error ? err.message : String(err);
7802
+ throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} failed${delivered}: ${reason}`);
7803
+ }
7804
+ if (!response.ok) {
7805
+ throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} returned ${response.status} ${response.statusText}${delivered}`);
7806
+ }
7807
+ }
7808
+ async function drainQueueFile(args) {
7809
+ const { path, rejectedPath, webhookUrl, headers, fetchTimeoutMs, totals } = args;
7810
+ const buf = readQueueFile(path);
7811
+ if (buf === null || buf.byteLength === 0)
7812
+ return;
7813
+ const lines = queueLines(buf);
7814
+ if (lines.length === 0) {
7815
+ removeQueueHead(path, buf.byteLength);
7816
+ return;
7817
+ }
7818
+ let removed = 0;
7819
+ let pendingEnd = 0;
7820
+ let chunk = [];
7821
+ let chunkBytes = 0;
7822
+ const deliverChunk = async () => {
7823
+ const body = `${chunk.join(`
7824
+ `)}
7825
+ `;
7826
+ args.keepLock();
7827
+ await postChunk(webhookUrl, headers, body, fetchTimeoutMs, totals.chunks);
7828
+ totals.chunks += 1;
7829
+ totals.lineCount += chunk.length;
7830
+ totals.bytes += Buffer.byteLength(body, "utf8");
7831
+ removeQueueHead(path, pendingEnd - removed);
7832
+ removed = pendingEnd;
7833
+ chunk = [];
7834
+ chunkBytes = 0;
7835
+ };
7836
+ const setAside = async (reason, status, identity, line) => {
7837
+ if (chunk.length > 0)
7838
+ await deliverChunk();
7839
+ rejectLine(rejectedPath, reason, status, identity, line.raw);
7840
+ totals.rejected += 1;
7841
+ pendingEnd = line.end;
7842
+ removeQueueHead(path, pendingEnd - removed);
7843
+ removed = pendingEnd;
7844
+ };
7845
+ for (const line of lines) {
7846
+ const record = classifyStoredLine(line.raw, homedir2());
7847
+ if (record.status !== "ok") {
7848
+ await setAside(record.reason, record.status, record.identity, line);
7849
+ continue;
7850
+ }
7851
+ const lineBytes = Buffer.byteLength(record.postLine, "utf8") + 1;
7852
+ if (lineBytes > MAX_WEBHOOK_BODY_BYTES) {
7853
+ 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);
7854
+ continue;
7855
+ }
7856
+ if (chunk.length > 0 && chunkBytes + lineBytes > MAX_WEBHOOK_BODY_BYTES)
7857
+ await deliverChunk();
7858
+ chunk.push(record.postLine);
7859
+ chunkBytes += lineBytes;
7860
+ pendingEnd = line.end;
7861
+ }
7862
+ pendingEnd = buf.byteLength;
7863
+ if (chunk.length > 0) {
7864
+ await deliverChunk();
7865
+ return;
7866
+ }
7867
+ if (pendingEnd > removed)
7868
+ removeQueueHead(path, pendingEnd - removed);
7869
+ }
7870
+ async function drainRenamedAside(args, livePath, source) {
7871
+ args.keepLock();
7872
+ const draining = drainingPathFor(livePath);
7873
+ try {
7874
+ renameSync(source, draining);
7875
+ } catch (err) {
7876
+ if (isEnoent(err))
7877
+ return;
7878
+ throw err;
7879
+ }
7880
+ await drainQueueFile({ ...args, path: draining });
7881
+ unlinkSync(draining);
7882
+ }
7523
7883
  async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeoutMs = WEBHOOK_FETCH_TIMEOUT_MS) {
7524
7884
  const resolved = await resolveRepo();
7525
7885
  const repo = resolved && isSafeRepoSegment2(resolved.owner) && isSafeRepoSegment2(resolved.repo) ? resolved : null;
@@ -7527,61 +7887,32 @@ async function drainOutboxToWebhook(outboxTask, webhookUrl, headers, fetchTimeou
7527
7887
  const path = outboxPathFor({ outboxRoot }, repo, outboxTask);
7528
7888
  const lockPath = `${path}.flush-lock`;
7529
7889
  const lockToken = acquireDrainLock(lockPath);
7890
+ const totals = { lineCount: 0, bytes: 0, chunks: 0, rejected: 0 };
7530
7891
  if (lockToken === null)
7531
- return { flushed: false };
7892
+ return { flushed: false, ...totals };
7532
7893
  try {
7533
- let lstat;
7534
- try {
7535
- lstat = lstatSync(path);
7536
- } catch (err) {
7537
- if (!isEnoent(err))
7538
- throw err;
7539
- }
7540
- if (lstat === undefined)
7541
- return { flushed: false };
7542
- if (!lstat.isFile()) {
7543
- 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}`);
7544
- }
7545
- const buf = readFileSync3(path);
7546
- const startOffset = buf.byteLength;
7547
- const rawLines = buf.toString("utf8").split(`
7548
- `).filter((l) => l.length > 0);
7549
- if (rawLines.length === 0)
7550
- return { flushed: false };
7551
- const postLines = [];
7552
- for (let i = 0;i < rawLines.length; i++) {
7553
- const record = classifyStoredLine(rawLines[i], homedir2());
7554
- if (record.status !== "ok") {
7555
- throw new WebhookDrainError("log-webhook-drain-corrupt-line", `log webhook drain: outbox line ${i} failed schema re-validation — ${record.reason}`);
7556
- }
7557
- postLines.push(record.postLine);
7558
- }
7559
- const body = `${postLines.join(`
7560
- `)}
7561
- `;
7562
- const bytes = Buffer.byteLength(body, "utf8");
7563
- if (bytes > MAX_WEBHOOK_BODY_BYTES) {
7564
- 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.`);
7565
- }
7566
- let response;
7567
- try {
7568
- response = await fetch(webhookUrl, {
7569
- method: "POST",
7570
- headers: { "content-type": "application/x-ndjson", ...headers },
7571
- body,
7572
- signal: AbortSignal.timeout(fetchTimeoutMs)
7573
- });
7574
- } catch (err) {
7575
- const reason = err instanceof Error && err.name === "TimeoutError" ? `timed out after ${fetchTimeoutMs}ms` : err instanceof Error ? err.message : String(err);
7576
- throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} failed: ${reason}`);
7577
- }
7578
- if (!response.ok) {
7579
- throw new WebhookDrainError("log-webhook-drain-failed", `log webhook drain: POST to ${webhookUrl} returned ${response.status} ${response.statusText}`);
7580
- }
7581
- const liveNow = readFileSync3(path);
7582
- const tail = liveNow.subarray(Math.min(startOffset, liveNow.byteLength));
7583
- writeFileSync2(path, tail);
7584
- return { flushed: true, lineCount: postLines.length, bytes };
7894
+ const keepLock = () => {
7895
+ if (renewDrainLock(lockPath, lockToken))
7896
+ return;
7897
+ 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`);
7898
+ };
7899
+ const shared = {
7900
+ rejectedPath: rejectedPathFor(path),
7901
+ webhookUrl,
7902
+ headers,
7903
+ fetchTimeoutMs,
7904
+ totals,
7905
+ keepLock
7906
+ };
7907
+ const draining = drainingPathFor(path);
7908
+ if (queueBucketSize(draining) !== null) {
7909
+ keepLock();
7910
+ await drainQueueFile({ ...shared, path: draining });
7911
+ unlinkSync(draining);
7912
+ }
7913
+ await drainRenamedAside(shared, path, backupPathFor(path));
7914
+ await drainRenamedAside(shared, path, path);
7915
+ return { flushed: totals.chunks > 0 || totals.rejected > 0, ...totals };
7585
7916
  } finally {
7586
7917
  releaseDrainLock(lockPath, lockToken);
7587
7918
  }
@@ -7688,6 +8019,96 @@ async function resolveDoctrine(cwd, vinayaVersion) {
7688
8019
  return vinayaVersion;
7689
8020
  }
7690
8021
  }
8022
+ var TRANCHE_SLUG_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
8023
+ function taskRefFromBranch2(branch) {
8024
+ const backlog = /^task\/issue-(\d+)$/.exec(branch);
8025
+ if (backlog) {
8026
+ const issue = Number(backlog[1]);
8027
+ return Number.isSafeInteger(issue) && issue > 0 ? { kind: "issue", issue } : null;
8028
+ }
8029
+ const tranche = /^task\/([^/]+)\/([^/]+)$/.exec(branch);
8030
+ if (tranche && TRANCHE_SLUG_PATTERN.test(tranche[1] ?? "")) {
8031
+ return { kind: "tranche", tranche: tranche[1], taskId: tranche[2] };
8032
+ }
8033
+ return null;
8034
+ }
8035
+ var TRANCHE_ISSUE_LIST_LIMIT = 200;
8036
+ async function issueForTrancheTask(tranche, taskId, cwd, repo) {
8037
+ let stdout;
8038
+ try {
8039
+ ({ stdout } = await execFileAsync5("gh", [
8040
+ "issue",
8041
+ "list",
8042
+ "--state",
8043
+ "all",
8044
+ "--label",
8045
+ `vinaya/tranche:${tranche}`,
8046
+ "--json",
8047
+ "number,title,labels",
8048
+ "--limit",
8049
+ String(TRANCHE_ISSUE_LIST_LIMIT),
8050
+ ...repo === null ? [] : ["--repo", repo]
8051
+ ], {
8052
+ cwd,
8053
+ encoding: "utf8",
8054
+ maxBuffer: 8 * 1024 * 1024,
8055
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
8056
+ killSignal: "SIGKILL"
8057
+ }));
8058
+ } catch {
8059
+ return null;
8060
+ }
8061
+ let issues;
8062
+ try {
8063
+ issues = JSON.parse(stdout);
8064
+ } catch {
8065
+ return null;
8066
+ }
8067
+ for (const issue of issues) {
8068
+ const ref = resolveTaskIssueRef(issue.title, issue.labels.map((l) => l.name));
8069
+ if (ref && ref.trancheSlug === tranche && ref.taskId === taskId)
8070
+ return issue.number;
8071
+ }
8072
+ return null;
8073
+ }
8074
+ async function confirmBacklogIssue(issue, cwd, repo) {
8075
+ let stdout;
8076
+ try {
8077
+ ({ stdout } = await execFileAsync5("gh", ["issue", "view", String(issue), "--json", "number", ...repo === null ? [] : ["--repo", repo]], {
8078
+ cwd,
8079
+ encoding: "utf8",
8080
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
8081
+ killSignal: "SIGKILL"
8082
+ }));
8083
+ } catch (err) {
8084
+ const stderr = typeof err.stderr === "string" ? err.stderr : "";
8085
+ return /could not resolve|not found|no such|does not exist/i.test(stderr) ? "denied" : "unknown";
8086
+ }
8087
+ try {
8088
+ return JSON.parse(stdout).number === issue ? "confirmed" : "denied";
8089
+ } catch {
8090
+ return "unknown";
8091
+ }
8092
+ }
8093
+ async function resolveBranchIssue(cwd, env = process.env, repo = null) {
8094
+ let branch;
8095
+ try {
8096
+ branch = (await execFileAsync5("git", ["-C", cwd, "rev-parse", "--abbrev-ref", "HEAD"], {
8097
+ encoding: "utf8",
8098
+ timeout: LOG_CONTEXT_LOOKUP_DEADLINE_MS,
8099
+ killSignal: "SIGKILL"
8100
+ })).stdout.trim();
8101
+ } catch {
8102
+ return null;
8103
+ }
8104
+ const named = branch === "HEAD" ? env.GITHUB_HEAD_REF ?? "" : branch;
8105
+ const ref = taskRefFromBranch2(named);
8106
+ if (ref === null)
8107
+ return null;
8108
+ if (ref.kind === "tranche")
8109
+ return await issueForTrancheTask(ref.tranche, ref.taskId, cwd, repo);
8110
+ return await confirmBacklogIssue(ref.issue, cwd, repo) === "denied" ? null : ref.issue;
8111
+ }
7691
8112
  function readVinayaVersion() {
7692
8113
  try {
7693
8114
  const pkg = JSON.parse(readFileSync4(join6(packageRoot(import.meta.url), "package.json"), "utf8"));
@@ -7700,6 +8121,11 @@ var SAFE_PATH_SEGMENT3 = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
7700
8121
  function isSafeRepoSegment3(segment) {
7701
8122
  return SAFE_PATH_SEGMENT3.test(segment) && !segment.includes("..");
7702
8123
  }
8124
+ function safeRepoSlug(repo) {
8125
+ if (repo === null)
8126
+ return null;
8127
+ return isSafeRepoSegment3(repo.owner) && isSafeRepoSegment3(repo.repo) ? `${repo.owner}/${repo.repo}` : null;
8128
+ }
7703
8129
  function outboxPathFor(deps, repo, issue) {
7704
8130
  const dirName = repo ? `${repo.owner}-${repo.repo}` : "unresolved";
7705
8131
  const fileName = `${issue ?? "none"}.ndjson`;
@@ -7721,6 +8147,18 @@ function defaultStderr(message) {
7721
8147
  warnedThisProcess = true;
7722
8148
  process.stderr.write(message);
7723
8149
  }
8150
+ var branchIssueFallbackEnabled = true;
8151
+ var branchIssueByCwd = new Map;
8152
+ function branchIssueRead(key, read, shared) {
8153
+ if (!shared)
8154
+ return withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
8155
+ const cached = branchIssueByCwd.get(key);
8156
+ if (cached !== undefined)
8157
+ return cached;
8158
+ const reading = withDeadline(Promise.resolve().then(read), LOG_CONTEXT_LOOKUP_DEADLINE_MS, null);
8159
+ branchIssueByCwd.set(key, reading);
8160
+ return reading;
8161
+ }
7724
8162
  function defaultDeps() {
7725
8163
  return {
7726
8164
  outboxRoot: () => join6(GLOBAL_VINAYA_HOME, "outbox"),
@@ -7746,6 +8184,24 @@ function guardedAppendOpen(path) {
7746
8184
  return;
7747
8185
  }
7748
8186
  }
8187
+ function appendHardenedLine(path, line) {
8188
+ try {
8189
+ mkdirSync3(dirname5(path), { recursive: true, mode: 448 });
8190
+ const fd = guardedAppendOpen(path);
8191
+ if (fd === undefined)
8192
+ return `target could not be opened (symlink, FIFO, or unwritable): ${path}`;
8193
+ try {
8194
+ if (!fstatSync2(fd).isFile())
8195
+ return `target is not a regular file: ${path}`;
8196
+ writeSync2(fd, line);
8197
+ } finally {
8198
+ closeSync3(fd);
8199
+ }
8200
+ return null;
8201
+ } catch (err) {
8202
+ return err instanceof Error ? err.message : String(err);
8203
+ }
8204
+ }
7749
8205
  function reportRotationOverflow(backupPath, warn) {
7750
8206
  let raw;
7751
8207
  try {
@@ -7813,7 +8269,11 @@ function appendLine(path, line, warn) {
7813
8269
  }
7814
8270
  }
7815
8271
  function createLogSink(overrides = {}) {
7816
- const deps = { ...defaultDeps(), ...overrides };
8272
+ const deps = {
8273
+ ...defaultDeps(),
8274
+ resolveBranchIssue: (repo) => resolveBranchIssue(deps.cwd(), deps.env(), repo),
8275
+ ...overrides
8276
+ };
7817
8277
  const runId = deps.env().VINAYA_RUN_ID || randomUUID2();
7818
8278
  const processId = randomUUID2();
7819
8279
  let seq = 0;
@@ -7833,6 +8293,19 @@ function createLogSink(overrides = {}) {
7833
8293
  }
7834
8294
  return doctrineCache;
7835
8295
  };
8296
+ const readerIsReal = overrides.resolveBranchIssue === undefined;
8297
+ let ownBranchIssue;
8298
+ const branchIssueOnce = (repo) => {
8299
+ if (!branchIssueFallbackEnabled)
8300
+ return Promise.resolve(null);
8301
+ const slug = safeRepoSlug(repo);
8302
+ const read = () => deps.resolveBranchIssue(slug);
8303
+ if (readerIsReal)
8304
+ return branchIssueRead(`${deps.cwd()}\x00${slug ?? ""}`, read, true);
8305
+ if (ownBranchIssue === undefined)
8306
+ ownBranchIssue = branchIssueRead(deps.cwd(), read, false);
8307
+ return ownBranchIssue;
8308
+ };
7836
8309
  let resolveRepoCache;
7837
8310
  const resolveRepoOnce = () => {
7838
8311
  if (resolveRepoCache === undefined)
@@ -7855,6 +8328,7 @@ function createLogSink(overrides = {}) {
7855
8328
  };
7856
8329
  let drainChain = Promise.resolve();
7857
8330
  const pendingWrites = new Set;
8331
+ let writeChain = Promise.resolve();
7858
8332
  const scheduleWebhookDrain = (issue, url, headers) => {
7859
8333
  drainChain = drainChain.then(() => drainOutboxToWebhook(issue, url, headers)).then(() => {
7860
8334
  return;
@@ -7877,7 +8351,14 @@ function createLogSink(overrides = {}) {
7877
8351
  attempt: env.VINAYA_ATTEMPT,
7878
8352
  parent: env.VINAYA_PARENT_EVENT
7879
8353
  };
7880
- const written = context().then(({ repo, doctrine: doctrineValue, destination: resolvedDestination }) => {
8354
+ const write = async () => {
8355
+ const { repo, doctrine: doctrineValue, destination: resolvedDestination } = await context();
8356
+ if (resolvedDestination.kind === "none") {
8357
+ warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
8358
+ `);
8359
+ return;
8360
+ }
8361
+ const branchIssue = envFields.task ? null : await branchIssueOnce(repo);
7881
8362
  const header = buildHeader({
7882
8363
  now,
7883
8364
  runId,
@@ -7888,15 +8369,11 @@ function createLogSink(overrides = {}) {
7888
8369
  host,
7889
8370
  hostname: deps.hostname(),
7890
8371
  env: envFields,
8372
+ branchIssue,
7891
8373
  eventId: randomUUID2(),
7892
8374
  processId,
7893
8375
  inputVersions: deps.inputVersions()
7894
8376
  });
7895
- if (resolvedDestination.kind === "none") {
7896
- warnOnce(`vinaya: not recording — ${resolvedDestination.reason}
7897
- `);
7898
- return;
7899
- }
7900
8377
  const full = { ...e, ...header };
7901
8378
  const parsed = LogEventSchema.safeParse(full);
7902
8379
  if (!parsed.success) {
@@ -7913,10 +8390,12 @@ function createLogSink(overrides = {}) {
7913
8390
  } else {
7914
8391
  appendLine(outboxPathFor({ outboxRoot: () => destination.folder }, repo, header.subject.issue), line, warnOnce);
7915
8392
  }
7916
- }).catch((err) => {
8393
+ };
8394
+ const written = writeChain.then(write).catch((err) => {
7917
8395
  warnOnce(`vinaya: log() failed — ${err instanceof Error ? err.message : String(err)}
7918
8396
  `);
7919
8397
  });
8398
+ writeChain = written;
7920
8399
  pendingWrites.add(written);
7921
8400
  written.finally(() => pendingWrites.delete(written));
7922
8401
  } catch (err) {
@@ -8034,13 +8513,13 @@ function summaryLineIndex(maskedRegion) {
8034
8513
  var LOOP_LOG_MAX_BYTES = 8 * 1024 * 1024;
8035
8514
 
8036
8515
  // src/lib/diff-evidence.ts
8037
- import { execFileSync as execFileSync5 } from "node:child_process";
8038
- import { join as join8, relative, resolve as resolve2 } from "node:path";
8516
+ import { execFileSync as execFileSync6 } from "node:child_process";
8517
+ import { join as join9, relative, resolve as resolve2 } from "node:path";
8039
8518
 
8040
8519
  // src/lib/brief-assembly.ts
8041
- import { execFileSync as execFileSync4 } from "node:child_process";
8042
- import { existsSync as existsSync6, readFileSync as readFileSync5, readdirSync } from "node:fs";
8043
- import { join as join7 } from "node:path";
8520
+ import { execFileSync as execFileSync5 } from "node:child_process";
8521
+ import { existsSync as existsSync7, readFileSync as readFileSync6, readdirSync as readdirSync2 } from "node:fs";
8522
+ import { join as join8 } from "node:path";
8044
8523
 
8045
8524
  // ../../packages/sources/src/commands.ts
8046
8525
  var COMMANDS = [
@@ -8235,7 +8714,7 @@ var COMMANDS = [
8235
8714
  details: [
8236
8715
  "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.",
8237
8716
  "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.",
8238
- "`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."
8717
+ "`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."
8239
8718
  ],
8240
8719
  status: "shipped"
8241
8720
  },
@@ -8546,6 +9025,10 @@ var COMMANDS = [
8546
9025
  flag: "--role <name>",
8547
9026
  description: "Resolve to a specific role file (roles/<name>.md) instead of the front door"
8548
9027
  },
9028
+ {
9029
+ flag: "--template <name>",
9030
+ description: "Print a template the package ships (templates/<name>-template.md) instead of the front door"
9031
+ },
8549
9032
  {
8550
9033
  flag: "--print",
8551
9034
  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."
@@ -8864,13 +9347,47 @@ async function resolveEdge(id, taskById, factsByTaskId, repo, resolveSibling = d
8864
9347
  };
8865
9348
  }
8866
9349
 
9350
+ // src/commands/doctrine.ts
9351
+ import { execFileSync as execFileSync4 } from "node:child_process";
9352
+ import { existsSync as existsSync6, readdirSync, readFileSync as readFileSync5 } from "node:fs";
9353
+ import { dirname as dirname6, join as join7, sep } from "node:path";
9354
+ import matter2 from "gray-matter";
9355
+ var ENTRY_SEGMENTS = ["skills", "aeg", "SKILL.md"];
9356
+ function resolveDoctrineRoot(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
9357
+ return resolveDoctrineRootInfo(pkg, cwd)?.root ?? null;
9358
+ }
9359
+ function gitToplevel(cwd) {
9360
+ try {
9361
+ return execFileSync4("git", ["-C", cwd, "rev-parse", "--show-toplevel"], {
9362
+ encoding: "utf8",
9363
+ stdio: ["ignore", "pipe", "pipe"]
9364
+ }).trim();
9365
+ } catch {
9366
+ return null;
9367
+ }
9368
+ }
9369
+ function resolveDoctrineRootInfo(pkg = packageRoot(import.meta.url), cwd = process.cwd()) {
9370
+ const toplevel = gitToplevel(cwd);
9371
+ if (toplevel !== null) {
9372
+ const treeRoot = join7(toplevel, "aeg-root");
9373
+ if (existsSync6(join7(treeRoot, "roles")))
9374
+ return { root: treeRoot, source: "tree" };
9375
+ }
9376
+ const fromSource = !pkg.split(sep).includes("node_modules");
9377
+ const bundleRoot = fromSource ? join7(dirname6(dirname6(pkg)), "aeg-root") : join7(pkg, "aeg-root");
9378
+ return hasDoctrineEntry(bundleRoot) ? { root: bundleRoot, source: "bundle" } : null;
9379
+ }
9380
+ function hasDoctrineEntry(root) {
9381
+ return existsSync6(join7(root, ...ENTRY_SEGMENTS));
9382
+ }
9383
+
8867
9384
  // src/lib/brief-assembly.ts
8868
9385
  var PACKAGE_ROOT = packageRoot(import.meta.url);
8869
- var PACKAGED_TEMPLATE_PATH = join7(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
8870
- var TEMPLATE_PATH = existsSync6(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join7(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
9386
+ var PACKAGED_TEMPLATE_PATH = join8(PACKAGE_ROOT, "aeg-root", "templates", "brief-template.md");
9387
+ var TEMPLATE_PATH = existsSync7(PACKAGED_TEMPLATE_PATH) ? PACKAGED_TEMPLATE_PATH : join8(PACKAGE_ROOT, "..", "..", "aeg-root", "templates", "brief-template.md");
8871
9388
  function git(args) {
8872
9389
  try {
8873
- return execFileSync4("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
9390
+ return execFileSync5("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
8874
9391
  } catch {
8875
9392
  return "";
8876
9393
  }
@@ -8919,7 +9436,7 @@ function parseChangedLineRanges(diffOutput) {
8919
9436
  function fileDiffAgainst(ref, path) {
8920
9437
  let out;
8921
9438
  try {
8922
- out = execFileSync5("git", ["diff", `${ref}...HEAD`, "--", path], {
9439
+ out = execFileSync6("git", ["diff", `${ref}...HEAD`, "--", path], {
8923
9440
  encoding: "utf8",
8924
9441
  stdio: ["ignore", "pipe", "pipe"]
8925
9442
  }).trim();
@@ -8930,7 +9447,7 @@ function fileDiffAgainst(ref, path) {
8930
9447
  }
8931
9448
  function revParse(ref) {
8932
9449
  try {
8933
- return execFileSync5("git", ["rev-parse", "--verify", ref], {
9450
+ return execFileSync6("git", ["rev-parse", "--verify", ref], {
8934
9451
  encoding: "utf8",
8935
9452
  stdio: ["ignore", "pipe", "pipe"]
8936
9453
  }).trim();
@@ -8940,7 +9457,7 @@ function revParse(ref) {
8940
9457
  }
8941
9458
  function repoRoot() {
8942
9459
  try {
8943
- return execFileSync5("git", ["rev-parse", "--show-toplevel"], {
9460
+ return execFileSync6("git", ["rev-parse", "--show-toplevel"], {
8944
9461
  encoding: "utf8",
8945
9462
  stdio: ["ignore", "pipe", "pipe"]
8946
9463
  }).trim();
@@ -8951,7 +9468,7 @@ function repoRoot() {
8951
9468
  function changedFiles(base) {
8952
9469
  let out;
8953
9470
  try {
8954
- out = execFileSync5("git", ["diff", "--name-only", `${base}...HEAD`], {
9471
+ out = execFileSync6("git", ["diff", "--name-only", `${base}...HEAD`], {
8955
9472
  encoding: "utf8",
8956
9473
  stdio: ["ignore", "pipe", "pipe"]
8957
9474
  }).trim();
@@ -8976,7 +9493,7 @@ function resolveDiff(base = process.env.BASE_SHA || "origin/main") {
8976
9493
  const relPaths = changedFiles(ref);
8977
9494
  if (relPaths === null)
8978
9495
  continue;
8979
- return { base: ref, root, files: relPaths.map((p) => join8(root, p)) };
9496
+ return { base: ref, root, files: relPaths.map((p) => join9(root, p)) };
8980
9497
  }
8981
9498
  return null;
8982
9499
  }
@@ -9010,6 +9527,7 @@ function findingsInThisDiff(findings) {
9010
9527
  // src/lib/dispatch.ts
9011
9528
  var MAX_TEE_BYTES = 8 * 1024 * 1024;
9012
9529
  var CLAUDE_MODEL_ALIASES = new Set(["fable", "opus", "sonnet", "haiku"]);
9530
+ 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)";
9013
9531
 
9014
9532
  // src/commands/tokens.ts
9015
9533
  var USAGE = [
@@ -9076,20 +9594,20 @@ var TOKEN_ROW_REMEDY = [
9076
9594
  var USAGE2 = "Usage: vinaya pr report [--write <body-file> | --push <pr> [--body-file <path>]] [--phase <phase>] " + "[--role <role>] [--model <id>] [--transcript <path>]";
9077
9595
 
9078
9596
  // src/lib/patch-id.ts
9079
- import { execFileSync as execFileSync6 } from "node:child_process";
9597
+ import { execFileSync as execFileSync7 } from "node:child_process";
9080
9598
  function patchIdAt(base, sha) {
9081
9599
  try {
9082
- execFileSync6("git", ["fetch", "--quiet", "origin", sha], { stdio: ["ignore", "ignore", "ignore"] });
9600
+ execFileSync7("git", ["fetch", "--quiet", "origin", sha], { stdio: ["ignore", "ignore", "ignore"] });
9083
9601
  } catch {}
9084
9602
  try {
9085
- const diff = execFileSync6("git", ["diff", `origin/${base}...${sha}`], {
9603
+ const diff = execFileSync7("git", ["diff", `origin/${base}...${sha}`], {
9086
9604
  encoding: "utf8",
9087
9605
  maxBuffer: 64 * 1024 * 1024,
9088
9606
  stdio: ["ignore", "pipe", "pipe"]
9089
9607
  });
9090
9608
  if (diff === "")
9091
9609
  return null;
9092
- const out = execFileSync6("git", ["patch-id", "--stable"], {
9610
+ const out = execFileSync7("git", ["patch-id", "--stable"], {
9093
9611
  input: diff,
9094
9612
  encoding: "utf8",
9095
9613
  stdio: ["pipe", "pipe", "pipe"]
@@ -9201,7 +9719,7 @@ function compareEvidenceBlock(resolved, resolvedHead, actualNumstat, expectedGro
9201
9719
  var DEVELOPER_ROUND_MARKER = /<!--\s*aeg:developer:round-\d+\s*-->/i;
9202
9720
  function fetchHasPriorDeveloperRound(prNumber) {
9203
9721
  try {
9204
- const out = execFileSync7("gh", ["pr", "view", String(prNumber), "--json", "comments"], {
9722
+ const out = execFileSync8("gh", ["pr", "view", String(prNumber), "--json", "comments"], {
9205
9723
  encoding: "utf8",
9206
9724
  stdio: ["ignore", "pipe", "pipe"]
9207
9725
  });
@@ -9215,7 +9733,7 @@ function fetchHasPriorDeveloperRound(prNumber) {
9215
9733
  var CHECK_NAME = "evidence-fresh";
9216
9734
  function git2(args) {
9217
9735
  try {
9218
- return execFileSync7("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9736
+ return execFileSync8("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9219
9737
  } catch {
9220
9738
  return "";
9221
9739
  }
@@ -9234,7 +9752,7 @@ class GitCommandError2 extends Error {
9234
9752
  }
9235
9753
  function gitStrict(args) {
9236
9754
  try {
9237
- return execFileSync7("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9755
+ return execFileSync8("git", args, { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
9238
9756
  } catch (err) {
9239
9757
  const stderr = err.stderr;
9240
9758
  throw new GitCommandError2(args, String(stderr ?? err.message).trim() || "non-zero exit");
@@ -9252,7 +9770,7 @@ function resolveMergeBase(head) {
9252
9770
  }
9253
9771
  function fetchPrRefs(prNumber) {
9254
9772
  try {
9255
- const out = execFileSync7("gh", ["pr", "view", String(prNumber), "--json", "headRefOid,baseRefName"], {
9773
+ const out = execFileSync8("gh", ["pr", "view", String(prNumber), "--json", "headRefOid,baseRefName"], {
9256
9774
  encoding: "utf8",
9257
9775
  stdio: ["ignore", "pipe", "pipe"]
9258
9776
  });