@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,5 +1,5 @@
1
1
  /**
2
- * The review loop's own state, derived (review-convergence-v1 task 8, #381).
2
+ * The review loop's own state, derived.
3
3
  * Pure — no `fs`, no `fetch`, no `process.env`; the CLI shim
4
4
  * (`apps/cli/src/commands/review-status.ts`) fetches the PR's comments, head
5
5
  * and base through `gh` and hands them here.
@@ -18,7 +18,7 @@
18
18
  * head it judged. There is no second `Judged head:` regex in this file.
19
19
  */
20
20
 
21
- import { extractCodeReviewVerdict, extractSecurityReviewVerdict } from './verdict-extraction'
21
+ import { extractCodeReviewVerdict, extractSecurityReviewVerdict, parseFindingState } from './verdict-extraction'
22
22
  import { isPrincipal } from './waiver-label'
23
23
 
24
24
  /**
@@ -31,24 +31,40 @@ const DEVELOPER_ROUND_MARKER = /<!--\s*aeg:developer:round-(\d+)\s*-->/i
31
31
 
32
32
  /**
33
33
  * A rendered finding line as `review-post.ts`'s `renderFindingsSection`
34
- * writes it — `<n>. [SEVERITY] <location> — F<id> <class> <state>: <text>` —
35
- * read for its id and its re-review state together. The id half deliberately
36
- * mirrors that renderer's own output rather than inventing a second finding
37
- * grammar; the state half is what round-over-round convergence is measured
38
- * from, and no exported parser carries it.
34
+ * writes it — `<n>. [SEVERITY] <location> — <description>` — matched only far
35
+ * enough to isolate the DESCRIPTION after the ` — ` separator; the id and
36
+ * re-review state are then read from that description by the shared
37
+ * `parseFindingState` (`verdict-extraction.ts`), the single definition of the
38
+ * `F<n> <class>[ <state>]:` state grammar this package carries (Traps to
39
+ * avoid — no second copy of the state token list). The `\S+` location match
40
+ * is unchanged from before this shared-parse refactor, so which lines this
41
+ * loop tracks is byte-for-byte what it tracked before.
39
42
  */
40
- const FINDING_LINE =
41
- /^\d+\.\s+\[[A-Z]+\]\s+\S+\s+—\s+F(\d+)(?:\s+\S+)?(?:\s+(open|fix-claimed|reproduced|resolved))?:/gm
43
+ const FINDING_LINE = /^\d+\.\s+\[[A-Z]+\]\s+\S+\s+—\s+(.*)$/gm
42
44
 
43
45
  export type ReviewStatus =
44
46
  | { state: 'CONTINUE' }
45
- | { state: 'PAUSE'; reason: 'reappearance' | 'zero-deaths' | 'stale' | 'max-rounds'; id?: string; round: number }
47
+ | {
48
+ state: 'PAUSE'
49
+ reason: 'reappearance' | 'zero-deaths' | 'stale' | 'objectives-moved' | 'max-rounds'
50
+ id?: string
51
+ round: number
52
+ }
46
53
 
47
54
  export type ReviewStatusInput = {
48
55
  comments: { body: string; author: string | null }[]
49
56
  headSha: string
50
57
  principalAllowlist: string[]
51
58
  maxRounds: number
59
+ /**
60
+ * The current `objectivesVersion` this PR is judged against —
61
+ * same resolution `checkReviewGate`'s caller supplies. `null` (or the field
62
+ * omitted entirely — the CLI command wiring is a separate task's surface,
63
+ * so an existing caller that does not supply it yet must keep compiling
64
+ * and behaving exactly as before) skips the `objectives-moved` pause
65
+ * entirely — the same fail-open-on-`null` rule the gate itself uses.
66
+ */
67
+ objectivesVersion?: string | null
52
68
  }
53
69
 
54
70
  /**
@@ -64,13 +80,20 @@ export function parseDeveloperRoundMarker(body: string): number | null {
64
80
  return Number.isFinite(n) ? n : null
65
81
  }
66
82
 
67
- type VerdictComment = { judgedHead: string | null; ids: Map<string, string | null> }
83
+ export type VerdictComment = {
84
+ judgedHead: string | null
85
+ objectivesVersion: string | null
86
+ ids: Map<string, string | null>
87
+ }
68
88
 
69
- function findingStates(body: string): Map<string, string | null> {
89
+ export function findingStates(body: string): Map<string, string | null> {
70
90
  const out = new Map<string, string | null>()
71
91
  for (const m of body.matchAll(FINDING_LINE)) {
72
- const id = `F${m[1]}`
73
- const state = m[2] ?? null
92
+ const { id, state } = parseFindingState(m[1] as string)
93
+ // A description with no `F<n>` head is not a tracked finding — the prior
94
+ // regex required `F(\d+)` on the line, so a line without one was never
95
+ // matched at all; skipping it here keeps that behaviour exactly.
96
+ if (id === null) continue
74
97
  // A round that lists the same id twice keeps the first state it declared;
75
98
  // a later id-less repeat must never erase a real `resolved`/`reproduced`.
76
99
  if (!out.has(id) || out.get(id) === null) out.set(id, state)
@@ -87,22 +110,35 @@ function asVerdictComment(body: string): VerdictComment | null {
87
110
  const code = extractCodeReviewVerdict([body])
88
111
  const security = extractSecurityReviewVerdict([body])
89
112
  if (code.danglingNote !== null && security.danglingNote !== null) return null
90
- return { judgedHead: code.headSha ?? security.headSha, ids: findingStates(body) }
113
+ return {
114
+ judgedHead: code.headSha ?? security.headSha,
115
+ objectivesVersion: code.objectivesVersion ?? security.objectivesVersion,
116
+ ids: findingStates(body)
117
+ }
91
118
  }
92
119
 
93
- type Round = { judgedHead: string | null; ids: Map<string, string | null> }
120
+ export type Round = { judgedHead: string | null; objectivesVersion: string | null; ids: Map<string, string | null> }
94
121
 
95
122
  /**
96
123
  * One round per `Judged head:` value, in the order that head was first
97
124
  * judged. A code-review verdict and a security verdict cast on the same head
98
125
  * are one round, not two — which is why the grouping key is the judged head
99
126
  * and not the comment count.
127
+ *
128
+ * Exported for `dev-review-loop/assess-round.ts` to reuse the same id-state merge semantics (first non-null state
129
+ * wins on a duplicate id) when it combines a round's reviewer and security
130
+ * `VerdictObservation`s into one id-state map — no behaviour change, no
131
+ * second copy of the merge rule.
100
132
  */
101
- function groupRounds(verdicts: VerdictComment[]): Round[] {
133
+ export function groupRounds(verdicts: VerdictComment[]): Round[] {
102
134
  const rounds: Round[] = []
103
135
  for (const v of verdicts) {
104
136
  const existing = rounds.find((r) => r.judgedHead === v.judgedHead)
105
- const target = existing ?? { judgedHead: v.judgedHead, ids: new Map<string, string | null>() }
137
+ const target = existing ?? {
138
+ judgedHead: v.judgedHead,
139
+ objectivesVersion: v.objectivesVersion,
140
+ ids: new Map<string, string | null>()
141
+ }
106
142
  if (!existing) rounds.push(target)
107
143
  for (const [id, state] of v.ids) {
108
144
  if (!target.ids.has(id) || target.ids.get(id) === null) target.ids.set(id, state)
@@ -113,12 +149,13 @@ function groupRounds(verdicts: VerdictComment[]): Round[] {
113
149
 
114
150
  /**
115
151
  * `CONTINUE` means the loop is still converging; a `PAUSE` names the one
116
- * reason it is not and the round that produced it. The four reasons are
152
+ * reason it is not and the round that produced it. The five reasons are
117
153
  * evaluated in the order they are declared on `ReviewStatus`, most specific
118
154
  * first: a reappearance names an individual finding, zero-deaths names a
119
- * round, staleness names the loop's own inactivity, and max-rounds is the
120
- * count alone. The first that holds is reported — a paused loop needs one
121
- * actionable reason, not a list.
155
+ * round, staleness names the loop's own inactivity, objectives-moved names
156
+ * an edit to the objectives list since the newest verdict, and max-rounds is
157
+ * the count alone. The first that holds is reported — a paused loop needs
158
+ * one actionable reason, not a list.
122
159
  */
123
160
  export function deriveReviewStatus(input: ReviewStatusInput): ReviewStatus {
124
161
  const verdicts: VerdictComment[] = []
@@ -177,6 +214,18 @@ export function deriveReviewStatus(input: ReviewStatusInput): ReviewStatus {
177
214
  return { state: 'PAUSE', reason: 'stale', round: rounds.length }
178
215
  }
179
216
 
217
+ // objectives-moved — the head is unchanged (the `stale` check
218
+ // above already passed), but the objectives list the PR is judged against
219
+ // has moved since the newest verdict. `input.objectivesVersion === null`
220
+ // skips this entirely (the same fail-open-on-`null` rule `checkReviewGate`
221
+ // uses); `newest.objectivesVersion === null` (a verdict cast before the
222
+ // block existed at all, or with no version line) counts as "differs" too —
223
+ // it cannot be the current version by definition.
224
+ const currentObjectivesVersion = input.objectivesVersion ?? null
225
+ if (currentObjectivesVersion !== null && newest.objectivesVersion !== currentObjectivesVersion) {
226
+ return { state: 'PAUSE', reason: 'objectives-moved', round: rounds.length }
227
+ }
228
+
180
229
  // max-rounds — the count alone. The loop may still be converging; it has
181
230
  // simply run long enough that the Principal decides whether it continues.
182
231
  if (rounds.length >= input.maxRounds) return { state: 'PAUSE', reason: 'max-rounds', round: rounds.length }
@@ -186,15 +235,18 @@ export function deriveReviewStatus(input: ReviewStatusInput): ReviewStatus {
186
235
 
187
236
  /**
188
237
  * The one-line rendering the CLI prints: `CONTINUE`, or `PAUSE: <reason>[ <id>]`
189
- * — except `stale`, whose condition (the newest verdict's judged head is no
190
- * longer the PR's, and no Developer round comment has answered it since) is
191
- * exactly "a commit landed after the newest verdict, unacknowledged". Verdicts
192
- * are the last forge event before merge (`roles/developer.md`), so that
193
- * condition is rendered as the actionable fact it names rather than the bare
194
- * reason word: `push after verdict — re-review required`.
238
+ * — except `stale` and `objectives-moved`, each rendered as the actionable
239
+ * fact it names rather than the bare reason word. `stale`'s condition (the
240
+ * newest verdict's judged head is no longer the PR's, and no Developer round
241
+ * comment has answered it since) is exactly "a commit landed after the
242
+ * newest verdict, unacknowledged": `push after verdict — re-review required`.
243
+ * `objectives-moved`'s condition is the same shape for the
244
+ * objectives list instead of the head: `objectives moved — re-review
245
+ * required`.
195
246
  */
196
247
  export function renderReviewStatus(status: ReviewStatus): string {
197
248
  if (status.state === 'CONTINUE') return 'CONTINUE'
198
249
  if (status.reason === 'stale') return 'push after verdict — re-review required'
250
+ if (status.reason === 'objectives-moved') return 'objectives moved — re-review required'
199
251
  return status.id !== undefined ? `PAUSE: ${status.reason} ${status.id}` : `PAUSE: ${status.reason}`
200
252
  }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * The newest principal-authored ruling ordinal on a pull request.
3
+ * One implementation, shared by
4
+ * every caller that needs it — `apps/cli/src/lib/dev-review-loop.ts` (the
5
+ * loop's own `fetchRulings`, which this duplicates the marker regex for,
6
+ * predates this package's involvement and stays local; this is the
7
+ * NEW shared logic `check-review-gate.ts` and `review-post.ts` both need
8
+ * and had no prior copy of), so the marker's parsing never drifts between
9
+ * the gate and the hand-cast command the way `verdict-extraction.ts`'s own
10
+ * module comment warns a duplicated pattern eventually would.
11
+ *
12
+ * Pure — no `fs`, no `fetch`. Every caller resolves the PR's comments via
13
+ * `gh` itself and passes them in.
14
+ */
15
+
16
+ import { isPrincipal } from './waiver-label'
17
+
18
+ /** The marker `apps/cli/src/commands/pr-rule.ts` posts: `<!-- aeg:principal:ruling:<pr>-<k> -->`, one line, nothing else on it. */
19
+ const RULING_MARKER_ORDINAL = /^<!-- aeg:principal:ruling:\d+-(\d+) -->$/
20
+
21
+ /**
22
+ * The marker line a principal ruling carries, built from the two numbers it
23
+ * encodes — `<ref>-<ordinal>`, where `ref` is the pull request or Issue the
24
+ * ruling is about and `ordinal` is the strictly-increasing `k` every reader
25
+ * here compares. It lives beside `RULING_MARKER_ORDINAL` because the two
26
+ * cannot be allowed to disagree about which slot the ordinal sits in: a
27
+ * renderer that swapped them emitted a marker that parsed as ordinal `1`
28
+ * forever, so a ruling written exactly as instructed failed the very
29
+ * freshness gate it was posted to satisfy. Any caller that WRITES a marker a
30
+ * reader here will parse should build it with this rather than by
31
+ * interpolating its own template.
32
+ */
33
+ export function principalRulingMarker(ref: number, ordinal: number): string {
34
+ return `<!-- aeg:principal:ruling:${ref}-${ordinal} -->`
35
+ }
36
+
37
+ export type RulingComment = {
38
+ body: string
39
+ /** The comment author's GitHub login, or `null` when the caller could not resolve one. */
40
+ author: string | null
41
+ }
42
+
43
+ /**
44
+ * `0` when no principal-authored ruling comment matches — never `null`: a
45
+ * PR's ruling count is always a well-defined fact, unlike an objectives
46
+ * list that can be genuinely unresolvable pre-cutover. `k` is read from the
47
+ * marker's own `<pr>-<k>` and compared numerically, never by string/lexical
48
+ * order or by comment timestamp — the ruling command assigns `k` strictly
49
+ * increasing, so the highest `k` among principal-authored matches is always
50
+ * the newest ruling, regardless of the comments array's own order.
51
+ */
52
+ export function newestPrincipalRulingOrdinal(comments: readonly RulingComment[], allowlist: readonly string[]): number {
53
+ let best = 0
54
+ for (const c of comments) {
55
+ if (!isPrincipal(c.author, allowlist as string[])) continue
56
+ const firstLine = (c.body.split('\n')[0] ?? '').trim()
57
+ const m = RULING_MARKER_ORDINAL.exec(firstLine)
58
+ if (!m) continue
59
+ const k = Number.parseInt(m[1] as string, 10)
60
+ if (k > best) best = k
61
+ }
62
+ return best
63
+ }
64
+
65
+ /**
66
+ * The AUTHOR of the newest principal-authored ruling comment — `null` when
67
+ * none matches (`newestPrincipalRulingOrdinal` returning `0` for the
68
+ * identical reason). An authenticated resolution record's own need (O2): its
69
+ * `authenticatedBy` field names WHO
70
+ * authorized a `--resume`/`--cancel`, not just that an authorization
71
+ * existed. Same scan, same ordinal-wins rule, so the two functions can never
72
+ * disagree about which ruling is newest.
73
+ */
74
+ export function newestPrincipalRulingAuthor(
75
+ comments: readonly RulingComment[],
76
+ allowlist: readonly string[]
77
+ ): string | null {
78
+ let best = 0
79
+ let bestAuthor: string | null = null
80
+ for (const c of comments) {
81
+ if (!isPrincipal(c.author, allowlist as string[])) continue
82
+ const firstLine = (c.body.split('\n')[0] ?? '').trim()
83
+ const m = RULING_MARKER_ORDINAL.exec(firstLine)
84
+ if (!m) continue
85
+ const k = Number.parseInt(m[1] as string, 10)
86
+ if (k > best) {
87
+ best = k
88
+ bestAuthor = c.author
89
+ }
90
+ }
91
+ return bestAuthor
92
+ }
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Single-plan-PR guard predicate (task 19 / #336). Extracted from
3
- * `bin/open-pr.ts` (aeg-governance-hardening task 24, #364, Part 1) so the
2
+ * Single-plan-PR guard predicate. Extracted from
3
+ * `bin/open-pr.ts` so the
4
4
  * exact same implementation can be consumed by both the ring-0 local wrapper
5
5
  * (`open-pr.ts`, prevention) and a ring-1 CI check (detection, for PRs opened
6
6
  * via the web UI that bypass the wrapper entirely) — one implementation per
@@ -27,11 +27,11 @@ export function trancheSlugFromTopologyPath(path: string): string | null {
27
27
  export type OpenPrFiles = { number: number; files: string[] }
28
28
 
29
29
  /**
30
- * Single-plan-PR guard (task 19 / #336): refuses a plan-branch diff
30
+ * Single-plan-PR guard: refuses a plan-branch diff
31
31
  * that touches a tranche's topology file when another OPEN PR's diff
32
32
  * already touches that SAME tranche's topology file. Ends the plan-PR
33
33
  * race that produced two concurrent plan PRs for `aeg-governance-hardening`
34
- * itself (#352/#354) — each cut from `origin/main` unaware of the other's
34
+ * itself — each cut from `origin/main` unaware of the other's
35
35
  * newly-cut Issue.
36
36
  *
37
37
  * `branchFiles` is this branch's diff vs `origin/main` (or vs the PR's
@@ -20,9 +20,14 @@
20
20
  * **Order is load-bearing, not incidental.** `blocked` must win over every
21
21
  * other conclusion; the reopened-after-merge rules must precede the plain
22
22
  * `merged` rule or a reopened Issue would permanently read `merged` off a
23
- * stale fact. `deriveStatus` (`derive-tranche.ts`) executes this list
24
- * verbatim, so reordering entries here changes real status everywhere — every
25
- * gate, the Studio, and the CLI read their status through it.
23
+ * stale fact; the closed-Issue rules (`closed-not-planned`, `closed-without-
24
+ * merge`) must precede `branch-exists`/`issue-open` — neither of those two
25
+ * checks `issueState`, so a closed Issue whose task branch was never cleaned
26
+ * up used to be swallowed by `branch-exists` and read as permanently
27
+ * `in-flight` instead of `dropped`/`incoherent` (issue-545, O6). `deriveStatus`
28
+ * (`derive-tranche.ts`) executes this list verbatim, so reordering entries
29
+ * here changes real status everywhere — every gate, the Studio, and the CLI
30
+ * read their status through it.
26
31
  *
27
32
  * **Deliberately not imported here: the label vocabulary.** Derivation works
28
33
  * on `ForgeFacts` — booleans and enums — never on label *strings*; the one
@@ -153,8 +158,12 @@ export type DerivationRule = {
153
158
  }
154
159
 
155
160
  /**
156
- * The ordered chain. First match wins; the final rule matches unconditionally,
157
- * so the list is total and evaluation always concludes.
161
+ * The ordered chain. First match wins. No single rule here is unconditional
162
+ * any more (issue-545, O6 narrowed `closed-without-merge`'s predicate to
163
+ * `issueState === 'closed'` so it could move ahead of `branch-exists`/
164
+ * `issue-open` without swallowing every open Issue too) — totality is
165
+ * guaranteed one level up, by `deriveStatusFromModel`'s own trailing
166
+ * fallback, not by a catch-all entry in this list.
158
167
  *
159
168
  * Every predicate is written to be safe against `undefined` facts even though
160
169
  * only the first rule can observe that case — the guard is structural, so
@@ -218,36 +227,36 @@ export const DERIVATION_RULES: DerivationRule[] = [
218
227
  why: 'Opening the PR is itself the in-flight → in-review transition; no status is ever written to record it.'
219
228
  },
220
229
  {
221
- id: 'branch-exists',
230
+ id: 'closed-not-planned',
231
+ chainStep: 6,
232
+ when: 'Issue closed NOT_PLANNED, with no merged PR',
233
+ matches: (facts) => facts?.issueState === 'closed' && facts.stateReason === 'not_planned',
234
+ status: 'dropped',
235
+ why: 'A legitimately abandoned task. Must precede branch-exists/issue-open (issue-545, O6): neither checks issueState, so a closed NOT_PLANNED Issue whose task branch was never cleaned up used to be swallowed by branch-exists and read as in-flight forever.'
236
+ },
237
+ {
238
+ id: 'closed-without-merge',
222
239
  chainStep: 6,
240
+ when: 'Issue closed for any other reason, with no merged PR',
241
+ matches: (facts) => facts?.issueState === 'closed',
242
+ status: 'incoherent',
243
+ why: "The honest terminal case for a closed, unprovable Issue. Same ordering fix as closed-not-planned (issue-545, O6) and for the identical reason: must precede branch-exists/issue-open or a closed Issue with a lingering branch read as in-flight instead. No longer the list’s unconditional catch-all — `deriveStatusFromModel`’s own trailing fallback (below) is what keeps the function total now that this predicate is scoped to `issueState === 'closed'`."
244
+ },
245
+ {
246
+ id: 'branch-exists',
247
+ chainStep: 7,
223
248
  when: 'A task branch exists, with no PR',
224
249
  matches: (facts) => facts?.branchExists === true,
225
250
  status: 'in-flight',
226
- why: 'Publishing the branch is the todo → in-flight transition. Below the PR rules, since a PR is the stronger signal.'
251
+ why: "Publishing the branch is the todo → in-flight transition. Below the PR rules (a PR is the stronger signal) and below the closed-Issue rules (issue-545, O6) — every fact set reaching this rule already has issueState === 'open'."
227
252
  },
228
253
  {
229
254
  id: 'issue-open',
230
- chainStep: 7,
255
+ chainStep: 8,
231
256
  when: 'The Issue is open, with no branch and no PR',
232
257
  matches: (facts) => facts?.issueState === 'open',
233
258
  status: 'todo',
234
259
  why: 'Not started. Assigned or not, both are todo inside a tranche.'
235
- },
236
- {
237
- id: 'closed-not-planned',
238
- chainStep: 8,
239
- when: 'Issue closed NOT_PLANNED, with no merged PR',
240
- matches: (facts) => facts?.stateReason === 'not_planned',
241
- status: 'dropped',
242
- why: 'A legitimately abandoned task. Reached only when the Issue is closed and nothing merged.'
243
- },
244
- {
245
- id: 'closed-without-merge',
246
- chainStep: 8,
247
- when: 'Issue closed for any other reason, with no merged PR',
248
- matches: () => true,
249
- status: 'incoherent',
250
- why: 'The honest terminal fallback: closed but unprovable must never read as todo. Total by design, so derivation always concludes.'
251
260
  }
252
261
  ]
253
262
 
@@ -257,9 +266,13 @@ export const DERIVATION_RULES: DerivationRule[] = [
257
266
  * rendered rules and the real derivation are the same list — the whole point
258
267
  * of the discipline.
259
268
  *
260
- * The trailing return is unreachable by construction (the final rule matches
261
- * unconditionally) and exists only to satisfy the type checker;
262
- * `state-machine-model.test.ts` asserts that totality directly.
269
+ * The trailing `return 'incoherent'` is this function's own totality
270
+ * guarantee (issue-545, O6): no rule in `DERIVATION_RULES` is unconditional
271
+ * any more, so the type checker cannot see the list as exhaustive, and in
272
+ * practice every real `ForgeFacts` (`issueState` is always `'open'` or
273
+ * `'closed'`) is fully covered by the rules above it — this line exists for
274
+ * the type checker and as a defensive floor, not as the reachable case
275
+ * `state-machine-model.test.ts` used to assert of the last array entry.
263
276
  */
264
277
  export function deriveStatusFromModel(facts: ForgeFacts | undefined): DerivedStatus {
265
278
  for (const rule of DERIVATION_RULES) {
@@ -6,8 +6,8 @@
6
6
  * third neighbour, and all three declare an unexported `stripBackticks`. So
7
7
  * "the registry's backtick stripper" names nothing a reader can resolve, and
8
8
  * checking a claim about it by grepping returns a confident answer about
9
- * whichever copy the search landed on. That happened twice while writing
10
- * atta-labs/vinaya#181: once in a verification pass that reached the right
9
+ * whichever copy the search landed on. That happened twice in real practice:
10
+ * once in a verification pass that reached the right
11
11
  * conclusion for the wrong reason, once in a filed Issue that sent a reader to
12
12
  * the wrong file. `parse-registry.ts` was also binary to git at the time (see
13
13
  * `no-binary-sources.test.ts`), so `git grep` could not have shown its copy.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Task-branch identity. A developer branch names
3
+ * its task one of two ways: `task/<tranche>/<n>`, keyed to a tranche
4
+ * topology row, or `task/issue-<n>`, keyed directly to a backlog Issue that
5
+ * carries no tranche at all. This is the one parser for both shapes — every
6
+ * check that resolves a task's identity off its branch name (`closes-n`,
7
+ * `surface-scope`, `dispatch-readiness`) reads through this, rather than
8
+ * carrying its own two-segment regex.
9
+ *
10
+ * Deliberately NOT the same export as `first-push-dispatch-gate.ts`'s
11
+ * `parseTaskBranch` — that function (and its flat `{tranche, taskId}` return
12
+ * shape) is shared by `first-push-dispatch`/`issue-assignment`/
13
+ * `assign-task-issue`, none of which are in this task's Surface or Boundary;
14
+ * widening its return type would ripple into checks this task has no brief
15
+ * coverage for. This module is the new, additional shape-parser named in the
16
+ * Traps to avoid: "`task/issue-<n>` is its own shape, parsed by one function
17
+ * next to `task/<tranche>/<n>`."
18
+ */
19
+
20
+ export type TaskBranchIdentity =
21
+ | { readonly kind: 'tranche'; readonly tranche: string; readonly taskId: string }
22
+ | { readonly kind: 'issue'; readonly issueNumber: number }
23
+
24
+ const ISSUE_BRANCH_PATTERN = /^task\/issue-(\d+)$/
25
+ const TRANCHE_BRANCH_PATTERN = /^task\/([^/]+)\/([^/]+)$/
26
+
27
+ export function parseTaskBranchIdentity(branch: string): TaskBranchIdentity | null {
28
+ const issueMatch = ISSUE_BRANCH_PATTERN.exec(branch)
29
+ if (issueMatch) return { kind: 'issue', issueNumber: Number(issueMatch[1]) }
30
+ const trancheMatch = TRANCHE_BRANCH_PATTERN.exec(branch)
31
+ if (trancheMatch) return { kind: 'tranche', tranche: trancheMatch[1] as string, taskId: trancheMatch[2] as string }
32
+ return null
33
+ }
34
+
35
+ /** `task/issue-<n>` — the branch shape for a backlog Issue with no tranche. */
36
+ export function issueBranchName(issueNumber: number): string {
37
+ return `task/issue-${issueNumber}`
38
+ }
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Where a run is, and what that place usually takes in this repository.
3
+ *
4
+ * Two pure concerns, both read by the task-status reader and the `task_status`
5
+ * tool:
6
+ *
7
+ * - **The phase vocabulary.** The dev-review-loop's own recovery record
8
+ * (`loop_state`) carries a `phase` string mirroring the driver's own
9
+ * `Decision['type']`. `TASK_PHASE_LABELS` maps each recorded phase to the
10
+ * one word a reader sees, one-to-one — never a phase invented from a
11
+ * second source, and never one recorded phase split into two.
12
+ * - **Typical phase times, from history.** `phaseSamplesFromPrComments`
13
+ * reads durations off a merged task pull request's own principal-authored
14
+ * comments: a developer round marker, then that round's verdict comments,
15
+ * then the next round's marker. The interval marker → verdicts is time
16
+ * spent reviewing; verdicts → next marker is time spent developing.
17
+ * `summarizePhaseSamples` reduces a set of those to a MEDIAN and a sample
18
+ * count, and refuses to answer at all below `MIN_PHASE_HISTORY_SAMPLES`.
19
+ *
20
+ * Every figure this module produces is history — what already happened, on
21
+ * merged work — and is named that way (`typicalPhaseMinutes`, never an ETA,
22
+ * never a remaining time, never a deadline). Nothing here predicts when a run
23
+ * in flight will finish.
24
+ *
25
+ * Only principal-authored comments contribute a sample: the same trust
26
+ * boundary every other forge read in this loop applies, so a non-principal
27
+ * commenter cannot post a round-marker- or verdict-shaped comment and shift
28
+ * what the repository reports as typical.
29
+ */
30
+
31
+ import { parseDeveloperRoundMarker } from './review-status'
32
+ import type { TaskPhaseHistory } from './task-tools'
33
+ import { extractCodeReviewVerdict, extractSecurityReviewVerdict } from './verdict-extraction'
34
+ import { isPrincipal } from './waiver-label'
35
+
36
+ // --- the phase vocabulary ---------------------------------------------------
37
+
38
+ /**
39
+ * The phases the loop actually records, and the word each reads as. One entry
40
+ * per `Decision['type']` the driver persists into `loop_state.phase`:
41
+ *
42
+ * | recorded phase | shown as |
43
+ * | -------------------- | -------------------- |
44
+ * | `dispatch_developer` | `developing` |
45
+ * | `ask_confidence` | `awaiting confidence`|
46
+ * | `dispatch_reviewers` | `reviewing` |
47
+ * | `publish` | `publishing` |
48
+ * | `pause` | `paused` |
49
+ *
50
+ * There is deliberately no separate `waiting for CI` phase: the driver polls
51
+ * the head's checks while the record still reads `dispatch_developer`, so a
52
+ * distinct CI-wait row would have to be inferred from a second source rather
53
+ * than read from the record. `developing` therefore spans the developer's own
54
+ * turn AND the gate wait that follows its push — stated here rather than left
55
+ * for a reader to assume.
56
+ */
57
+ export const TASK_PHASE_LABELS = {
58
+ dispatch_developer: 'developing',
59
+ ask_confidence: 'awaiting confidence',
60
+ dispatch_reviewers: 'reviewing',
61
+ publish: 'publishing',
62
+ pause: 'paused'
63
+ } as const
64
+
65
+ export type RecordedLoopPhase = keyof typeof TASK_PHASE_LABELS
66
+ export type TaskPhaseLabel = (typeof TASK_PHASE_LABELS)[RecordedLoopPhase]
67
+
68
+ export function isRecordedLoopPhase(phase: string): phase is RecordedLoopPhase {
69
+ return Object.hasOwn(TASK_PHASE_LABELS, phase)
70
+ }
71
+
72
+ /** The shown phase for a recorded one. A phase this vocabulary does not know (a decision type added after this mapping) reads back VERBATIM — the record's own word, never a guess at which known phase it resembles. */
73
+ export function taskPhaseLabel(phase: string): string {
74
+ return isRecordedLoopPhase(phase) ? TASK_PHASE_LABELS[phase] : phase
75
+ }
76
+
77
+ /**
78
+ * Which history class a recorded phase compares against — `null` for a phase
79
+ * the pull-request record carries no interval for. `publish` and `pause` have
80
+ * none by nature (publishing is one comment post; a pause ends when a person
81
+ * acts), and `ask_confidence` has none because it is not separable from the
82
+ * developer turn it interrupts.
83
+ */
84
+ export type PhaseHistoryClass = 'developing' | 'reviewing'
85
+
86
+ export function phaseHistoryClassFor(phase: string): PhaseHistoryClass | null {
87
+ if (phase === 'dispatch_developer') return 'developing'
88
+ if (phase === 'dispatch_reviewers') return 'reviewing'
89
+ return null
90
+ }
91
+
92
+ // --- typical phase times, from merged pull requests -------------------------
93
+
94
+ /** One comment as a history read sees it: its body, its author, and the forge's own creation timestamp. */
95
+ export type HistoryComment = { body: string; author: string | null; createdAt: string }
96
+
97
+ /** Minutes, one entry per interval the record actually carried — never a filled-in or interpolated value. */
98
+ export type PhaseSamples = { [K in PhaseHistoryClass]: number[] }
99
+
100
+ export function emptyPhaseSamples(): PhaseSamples {
101
+ return { developing: [], reviewing: [] }
102
+ }
103
+
104
+ /** A verdict comment is one either merge-gate extractor parses clean — the same "did this cast a verdict" test the gate itself applies, so this read can never disagree with it about which comment ended a round. */
105
+ function isVerdictComment(body: string): boolean {
106
+ return (
107
+ extractCodeReviewVerdict([body]).danglingNote === null || extractSecurityReviewVerdict([body]).danglingNote === null
108
+ )
109
+ }
110
+
111
+ type PhaseEvent = { kind: 'marker'; at: number } | { kind: 'verdict'; at: number }
112
+
113
+ function minutesBetween(fromMs: number, toMs: number): number | null {
114
+ const ms = toMs - fromMs
115
+ return ms >= 0 ? ms / 60_000 : null
116
+ }
117
+
118
+ /**
119
+ * The phase intervals one pull request's comments record. Ordered by the
120
+ * forge's own timestamps rather than by the order the read returned them, so
121
+ * a paginated or re-ordered read measures the same intervals.
122
+ *
123
+ * A round whose verdicts were never posted as comments contributes NOTHING —
124
+ * neither a reviewing nor a developing sample — because the record does not
125
+ * say where that round's time went. Today the driver posts a round's verdict
126
+ * comments when it publishes, so a pull request that took several rounds
127
+ * carries one reviewing interval and no developing interval at all; that is
128
+ * a thin history, and `summarizePhaseSamples` below refuses to turn a thin
129
+ * history into a number.
130
+ */
131
+ export function phaseSamplesFromPrComments(
132
+ comments: readonly HistoryComment[],
133
+ allowlist: readonly string[]
134
+ ): PhaseSamples {
135
+ const events: PhaseEvent[] = []
136
+ for (const comment of comments) {
137
+ if (!isPrincipal(comment.author, allowlist as string[])) continue
138
+ const at = Date.parse(comment.createdAt)
139
+ if (!Number.isFinite(at)) continue
140
+ if (parseDeveloperRoundMarker(comment.body) !== null) events.push({ kind: 'marker', at })
141
+ else if (isVerdictComment(comment.body)) events.push({ kind: 'verdict', at })
142
+ }
143
+ events.sort((a, b) => a.at - b.at)
144
+
145
+ const samples = emptyPhaseSamples()
146
+ let markerAt: number | null = null
147
+ let lastVerdictAt: number | null = null
148
+ const closeRound = (): void => {
149
+ if (markerAt === null || lastVerdictAt === null) return
150
+ const minutes = minutesBetween(markerAt, lastVerdictAt)
151
+ if (minutes !== null) samples.reviewing.push(minutes)
152
+ }
153
+ for (const event of events) {
154
+ if (event.kind === 'marker') {
155
+ closeRound()
156
+ if (lastVerdictAt !== null) {
157
+ const minutes = minutesBetween(lastVerdictAt, event.at)
158
+ if (minutes !== null) samples.developing.push(minutes)
159
+ }
160
+ markerAt = event.at
161
+ lastVerdictAt = null
162
+ continue
163
+ }
164
+ // A round posts more than one verdict (a code review and a security
165
+ // pass); the round's review ends at the LAST of them.
166
+ if (markerAt !== null) lastVerdictAt = lastVerdictAt === null ? event.at : Math.max(lastVerdictAt, event.at)
167
+ }
168
+ closeRound()
169
+ return samples
170
+ }
171
+
172
+ /** Below this many past intervals, a phase reports no typical time at all: two samples from two pull requests describe those two pull requests, not this repository. */
173
+ export const MIN_PHASE_HISTORY_SAMPLES = 3
174
+
175
+ // The median of a phase's past intervals, with the count it was computed
176
+ // from, is `TaskPhaseHistory` (`task-tools.ts`) — the shape the `task_status`
177
+ // result schema declares. One name for the fact, derived from the schema
178
+ // itself, so the reader and the published contract cannot drift apart.
179
+
180
+ export function medianOf(values: readonly number[]): number | null {
181
+ if (values.length === 0) return null
182
+ const sorted = [...values].sort((a, b) => a - b)
183
+ const mid = Math.floor(sorted.length / 2)
184
+ if (sorted.length % 2 === 1) return sorted[mid] as number
185
+ return ((sorted[mid - 1] as number) + (sorted[mid] as number)) / 2
186
+ }
187
+
188
+ /** `null` — no typical time, never an invented one — for a phase with fewer than `MIN_PHASE_HISTORY_SAMPLES` past intervals, and for one with none at all. */
189
+ export function summarizePhaseSamples(minutes: readonly number[]): TaskPhaseHistory | null {
190
+ if (minutes.length < MIN_PHASE_HISTORY_SAMPLES) return null
191
+ const median = medianOf(minutes)
192
+ if (median === null) return null
193
+ return { typicalPhaseMinutes: Math.round(median), typicalPhaseSamples: minutes.length }
194
+ }