@attalabs/vinaya 0.32.0 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/README.md +1 -1
  2. package/aeg-root/contracts/principal-operator.md +18 -5
  3. package/aeg-root/roles/operator.md +69 -16
  4. package/aeg-root/roles/planner/reference.md +1 -1
  5. package/aeg-root/roles/tranche-archivist.md +1 -0
  6. package/aeg-root/skills/aeg-context-packets/SKILL.md +1 -1
  7. package/aeg-root/skills/aeg-context-packets/examples/operator-start.md +1 -1
  8. package/dist/checks/bin/check-body-bare-digits.js +111 -15
  9. package/dist/checks/bin/check-branch-topology.js +83 -16
  10. package/dist/checks/bin/check-brief-shape.js +111 -15
  11. package/dist/checks/bin/check-changeset-coverage.js +342 -69
  12. package/dist/checks/bin/check-closes-n.js +83 -16
  13. package/dist/checks/bin/check-coherence.js +112 -16
  14. package/dist/checks/bin/check-dead-branch-push.js +82 -15
  15. package/dist/checks/bin/check-dispatch-readiness.js +112 -16
  16. package/dist/checks/bin/check-doc-coverage-push.js +342 -69
  17. package/dist/checks/bin/check-doc-coverage.js +342 -69
  18. package/dist/checks/bin/check-doctrine-no-procedures.js +111 -15
  19. package/dist/checks/bin/check-doctrine-portability.js +342 -69
  20. package/dist/checks/bin/check-evidence-fresh.js +343 -69
  21. package/dist/checks/bin/check-exec-bits.js +342 -69
  22. package/dist/checks/bin/check-first-push-dispatch.js +112 -16
  23. package/dist/checks/bin/check-issue-assignment.js +83 -16
  24. package/dist/checks/bin/check-issue-milestone-attach.js +82 -15
  25. package/dist/checks/bin/check-issue-objectives-numbering.js +82 -15
  26. package/dist/checks/bin/check-issue-parts-coverage.js +82 -15
  27. package/dist/checks/bin/check-issue-surface-globs.js +112 -16
  28. package/dist/checks/bin/check-issue-title-grammar.js +82 -15
  29. package/dist/checks/bin/check-issue-tranche-label.js +82 -15
  30. package/dist/checks/bin/check-main-branch-refusal.js +82 -15
  31. package/dist/checks/bin/check-no-disk-state.js +82 -15
  32. package/dist/checks/bin/check-pr-premise-reassert.js +111 -15
  33. package/dist/checks/bin/check-pr-report-density.js +82 -15
  34. package/dist/checks/bin/check-principal-test-plan-wait.js +82 -15
  35. package/dist/checks/bin/check-quoted-command.js +342 -69
  36. package/dist/checks/bin/check-reader-resolvable-prose.js +342 -69
  37. package/dist/checks/bin/check-registry-gates.js +82 -15
  38. package/dist/checks/bin/check-retired-vocabulary.js +342 -69
  39. package/dist/checks/bin/check-review-gate.js +179 -124
  40. package/dist/checks/bin/check-single-plan-pr.js +82 -15
  41. package/dist/checks/bin/check-surface-scope.js +83 -16
  42. package/dist/checks/bin/check-test-plan.js +82 -15
  43. package/dist/checks/bin/check-token-collection-wired.js +82 -15
  44. package/dist/checks/bin/check-token-report.js +82 -15
  45. package/dist/checks/bin/check-workspace-escape.js +342 -69
  46. package/dist/index.js +2495 -590
  47. package/dist/lib/pre-push-cache-test-run.js +317 -61
  48. package/dist/lib/pre-push-select-tests.js +91 -10
  49. package/package.json +1 -1
  50. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/actions.ts +10 -12
  51. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/anchored-region.ts +5 -5
  52. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/archive-task.ts +42 -17
  53. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/baseline-capture.ts +1 -2
  54. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/branch-topology-gate.ts +3 -3
  55. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +554 -95
  56. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +264 -44
  57. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/claude-code-transcript.ts +9 -9
  58. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +211 -30
  59. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/consumer-enumeration.ts +2 -2
  60. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/index.ts +75 -0
  61. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/local.ts +961 -0
  62. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/migration.ts +212 -0
  63. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/outcomes.ts +135 -0
  64. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/records.ts +394 -0
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dead-branch-push-audit.ts +1 -2
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dead-branch-push-guard.ts +1 -1
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/derive-section7.ts +2 -2
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +514 -0
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/fakes.ts +110 -0
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +27 -0
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +123 -0
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +27 -0
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/types.ts +240 -0
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/diagram-model.ts +1 -1
  75. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/direct-main-push.ts +1 -2
  76. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dispatch-gate.ts +65 -22
  77. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-claim.ts +238 -0
  78. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doc-owners.ts +14 -1
  79. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/docs-coherence.ts +1 -1
  80. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/legacy-anchors.ts +1 -1
  81. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/node-route.ts +1 -1
  82. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/docs/surfaced-manifest.ts +1 -1
  83. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-no-procedures.ts +1 -1
  84. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/doctrine-portability.ts +5 -5
  85. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ensure-label.ts +1 -1
  86. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/first-push-dispatch-gate.ts +1 -1
  87. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-audience.ts +14 -3
  88. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +379 -11
  89. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-assignment.ts +3 -4
  90. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +1450 -33
  91. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/leftover-detection.ts +1 -2
  92. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/local-anchor-coverage.ts +2 -2
  93. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +119 -0
  94. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/index.ts +75 -0
  95. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/redact.ts +87 -0
  96. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/schema.ts +801 -0
  97. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/store.ts +373 -0
  98. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/main-branch-refusal.ts +2 -2
  99. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/metering-io-guard.ts +1 -1
  100. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/milestone-validation.ts +2 -3
  101. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/no-disk-state.ts +2 -2
  102. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives.ts +288 -0
  103. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/parse-token-report.ts +3 -3
  104. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/parse-tranche.ts +1 -1
  105. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-report-density.ts +30 -16
  106. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/pr-tier.ts +17 -1
  107. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/premise-check.ts +1 -1
  108. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/quoted-command.ts +1 -1
  109. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +267 -19
  110. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-checks.ts +91 -24
  111. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/registry-scaffold.ts +6 -6
  112. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/report-tokens.ts +4 -4
  113. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +239 -110
  114. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-input-manifest.ts +384 -0
  115. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +184 -0
  116. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +65 -18
  117. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +76 -0
  118. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/single-plan-pr.ts +4 -4
  119. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/state-machine-model.ts +40 -27
  120. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/symbol-collisions.ts +2 -2
  121. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-branch-identity.ts +38 -0
  122. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +488 -0
  123. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-gate.ts +7 -9
  124. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/test-plan-section.ts +5 -5
  125. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/types.ts +4 -4
  126. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +314 -56
  127. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/waiver-label.ts +2 -3
  128. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/workspace-escape.ts +3 -3
  129. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  130. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  131. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  133. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  134. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  135. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  136. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  137. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  138. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  139. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  140. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  141. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  142. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js +1 -1
  143. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
  144. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  145. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  146. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  147. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  148. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js +1 -1
  149. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  150. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  151. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  152. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js +1 -1
  153. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  154. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  155. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  156. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js +1 -1
  157. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  158. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  159. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  160. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js +2 -2
  161. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  162. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  163. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  164. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js +1 -1
  165. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  166. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  167. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  168. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js +1 -1
  169. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  170. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  171. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  172. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js +1 -1
  173. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  174. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  175. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/{[externals]__1agj1ww._.js → [externals]__0cki-x_._.js} +2 -2
  176. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +6 -6
  177. 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
  178. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +3 -0
  179. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  180. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__0r7e54g._.js → [root-of-the-server]__18paley._.js} +1 -1
  181. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  182. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  183. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__1r47dr7._.js → _08onyya._.js} +3 -3
  184. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  185. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  186. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  187. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  188. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0y1jv16._.js +1 -1
  189. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  190. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  191. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_15gdg48._.js +5 -5
  192. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  193. 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
  194. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  195. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  196. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  197. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  198. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bjnj-5fy4e7l.js +1 -0
  199. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1dc2_-c_gavj1.js → 1ce2dj27_cgbj.js} +4 -4
  200. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{3xg6-flovrcx-.js → 22s44f5k3ecmj.js} +1 -1
  201. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/34hhdtbp20krb.js +1 -0
  202. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  203. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0hstap0._.js +0 -3
  204. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/2t_rfsztmwu6y.js +0 -1
  205. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/3ua4rm5f-a9k6.js +0 -1
  206. /package/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/vinaya/studio-standalone/_node_modules/@attalabs/{aeg-core → vinaya/studio-standalone/_node_modules/@attalabs/aeg-core}/bin/verify-coherence.ts +0 -0
  207. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_buildManifest.js +0 -0
  208. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_clientMiddlewareManifest.js +0 -0
  209. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{e8XbZ2vlVz40KzHmlqhwP → vl7QVqELe1AQ-9kaOd9mR}/_ssgManifest.js +0 -0
@@ -0,0 +1,394 @@
1
+ /**
2
+ * Versioned control-store record schemas. Four record
3
+ * kinds — run, input, ownership, transition — each `.strict()` and
4
+ * carrying its own `version` literal, the same discipline
5
+ * `packages/aeg-core/src/log/schema.ts` already uses for the Vinaya Log.
6
+ *
7
+ * `parse*Record` is the one thing every storage implementation must route
8
+ * a read through: it returns a three-way `ParsedRecord<T>` rather than a
9
+ * nullable value, because a nullable read cannot tell "no record was ever
10
+ * written" apart from "a record exists but is corrupt" — the exact defect
11
+ * class the pid-lock/pause-state/effect-record side files this store
12
+ * replaces all share (`JSON.parse` wrapped in `catch { return null }`,
13
+ * indistinguishable from absence). An unknown `version` or torn/invalid
14
+ * JSON both resolve to `'corrupt'`, never `'absent'` and never a thrown
15
+ * exception — a caller that must special-case "nothing here yet" from
16
+ * "something here I can't trust" gets to do so honestly.
17
+ *
18
+ * Pure — no `fs`, no clock, no process access. `local.ts` is the one
19
+ * storage implementation that turns disk bytes (or their absence) into the
20
+ * `raw: string | undefined` these parsers accept.
21
+ */
22
+
23
+ import { z } from 'zod'
24
+
25
+ export const CONTROL_RECORD_VERSION = 1 as const
26
+
27
+ const isoTimestamp = z.string().min(1)
28
+ const taskId = z.number().int().positive()
29
+ const epochNumber = z.number().int().nonnegative()
30
+
31
+ /**
32
+ * One execution attempt against a task — written once, at start, immutable
33
+ * thereafter. `childStartedAt`/`childCommand` are the same process-identity
34
+ * pair `apps/cli/src/lib/dispatch.ts`'s `LaunchRecord` already captures for
35
+ * a dispatched role's child — reused
36
+ * here, under the identical field names, so `matchesCapturedIdentity` (which
37
+ * only requires `Pick<LaunchRecord, 'childStartedAt' | 'childCommand'>`)
38
+ * applies to a controller's own run record unchanged. `.optional()` since a
39
+ * `run` record written before this task carries neither — a reader falls
40
+ * back to "nothing captured, nothing to fail closed on" exactly as
41
+ * `matchesCapturedIdentity` already does for a pre-existing `LaunchRecord`.
42
+ */
43
+ export const RunRecordSchema = z
44
+ .object({
45
+ version: z.literal(1),
46
+ kind: z.literal('run'),
47
+ task: taskId,
48
+ runId: z.string().min(1),
49
+ pid: z.number().int().positive(),
50
+ host: z.string().min(1),
51
+ startedAt: isoTimestamp,
52
+ childStartedAt: z.string().min(1).nullable().optional(),
53
+ childCommand: z.string().min(1).nullable().optional()
54
+ })
55
+ .strict()
56
+ export type RunRecord = z.infer<typeof RunRecordSchema>
57
+
58
+ /**
59
+ * What began or resumed a run — a fresh dispatch or a `--resume` against a
60
+ * known PR — recorded so a later reader can tell what a run was actually
61
+ * told to do, distinct from the transitions it went on to produce.
62
+ */
63
+ export const InputRecordSchema = z
64
+ .object({
65
+ version: z.literal(1),
66
+ kind: z.literal('input'),
67
+ task: taskId,
68
+ runId: z.string().min(1),
69
+ source: z.union([z.literal('fresh'), z.literal('resume')]),
70
+ pr: z.number().int().positive().nullable(),
71
+ round: z.number().int().nonnegative(),
72
+ recordedAt: isoTimestamp
73
+ })
74
+ .strict()
75
+ export type InputRecord = z.infer<typeof InputRecordSchema>
76
+
77
+ /**
78
+ * The fencing token: which epoch is current for a task, and who holds it.
79
+ * Immutable per epoch once validly written — `local.ts` never overwrites an
80
+ * `ownership/epoch-<n>.json` file, only creates the next one.
81
+ */
82
+ export const OwnershipRecordSchema = z
83
+ .object({
84
+ version: z.literal(1),
85
+ kind: z.literal('ownership'),
86
+ task: taskId,
87
+ epoch: epochNumber,
88
+ ownerId: z.string().min(1),
89
+ pid: z.number().int().positive(),
90
+ host: z.string().min(1),
91
+ acquiredAt: isoTimestamp
92
+ })
93
+ .strict()
94
+ export type OwnershipRecord = z.infer<typeof OwnershipRecordSchema>
95
+
96
+ /** One state change, stamped with the epoch that produced it — the durable history a resume/audit reads back. */
97
+ export const TransitionRecordSchema = z
98
+ .object({
99
+ version: z.literal(1),
100
+ kind: z.literal('transition'),
101
+ task: taskId,
102
+ epoch: epochNumber,
103
+ seq: z.number().int().nonnegative(),
104
+ from: z.string().min(1),
105
+ to: z.string().min(1),
106
+ detail: z.string().optional(),
107
+ at: isoTimestamp
108
+ })
109
+ .strict()
110
+ export type TransitionRecord = z.infer<typeof TransitionRecordSchema>
111
+
112
+ /**
113
+ * The review-input manifest a round was dispatched against, persisted
114
+ * durably — the record the "Deferred, deliberately" paragraph in `loop.md`
115
+ * named as waiting for this store: base
116
+ * identity and a durable policy history now have a home. One immutable
117
+ * snapshot per (task, round), built by the parent before it dispatches
118
+ * reviewers, binding the complete identity of everything a verdict is judged
119
+ * against: repository and work (the PR/branch this round belongs to), base and
120
+ * candidate (`baseSha`/`headSha`), instruction and criteria versions
121
+ * (`briefHash`/`objectivesVersion`), rulings (`rulingOrdinal`), and the
122
+ * complete effective policy identity (`policyDigest`, which folds in the
123
+ * round-policy field). `baseSha`/`briefHash`/`objectivesVersion` are nullable
124
+ * exactly where the manifest itself is (`review-input-manifest.ts`'s own
125
+ * `null` = "nothing resolvable to bind against"); `rulingOrdinal`/
126
+ * `policyDigest` are never null, the same as on the manifest.
127
+ */
128
+ export const ManifestRecordSchema = z
129
+ .object({
130
+ version: z.literal(1),
131
+ kind: z.literal('manifest'),
132
+ task: taskId,
133
+ round: epochNumber,
134
+ /** Repository identity — `owner/repo`. */
135
+ repository: z.string().min(1),
136
+ /** Work identity — the PR this round's candidate lives on. */
137
+ pr: z.number().int().positive(),
138
+ /** Work identity — the branch under review. */
139
+ branch: z.string().min(1),
140
+ /** Base identity — the commit the candidate is judged against; `null` when none was resolvable. */
141
+ baseSha: z.string().min(1).nullable(),
142
+ /** Candidate identity — the round's judged head. */
143
+ headSha: z.string().min(1),
144
+ /** Instruction version — the frozen brief's hash; `null` when none was resolvable. */
145
+ briefHash: z.string().min(1).nullable(),
146
+ /** Criteria version — the objectives version; `null` pre-cutover or when none resolvable. */
147
+ objectivesVersion: z.string().min(1).nullable(),
148
+ /** Rulings — the newest principal ruling ordinal at dispatch (`0` when none). */
149
+ rulingOrdinal: epochNumber,
150
+ /** Policy identity — the complete effective review policy's digest. */
151
+ policyDigest: z.string().min(1),
152
+ recordedAt: isoTimestamp
153
+ })
154
+ .strict()
155
+ export type ManifestRecord = z.infer<typeof ManifestRecordSchema>
156
+
157
+ /** A round's identity — which round, on which head — shared by `heldResult` and `deliveredFindings` below. */
158
+ const roundHeadIdentity = z.object({ round: z.number().int().positive(), head: z.string().min(1) }).strict()
159
+ export type RoundHeadIdentity = z.infer<typeof roundHeadIdentity>
160
+
161
+ export const LoopBudgetsSchema = z
162
+ .object({
163
+ /** The mechanical gate-red/conflict-retry stall bound (`MAX_GATE_STALLED_TURNS` in `apps/cli`) — consecutive developer turns that produced no push on one head. */
164
+ mechanicalRetries: z.number().int().nonnegative(),
165
+ /** The substantive review-round count — bounded by `ReviewPolicy.maxRounds`. */
166
+ reviewRounds: z.number().int().nonnegative(),
167
+ /** The cumulative count of `'infrastructure'`/`'stale_driver'` pauses this task has ever hit — never reset by a restart, unlike the in-memory counters above (`apps/cli/specs/loop.md`). */
168
+ infrastructureRetries: z.number().int().nonnegative()
169
+ })
170
+ .strict()
171
+ export type LoopBudgets = z.infer<typeof LoopBudgetsSchema>
172
+
173
+ /**
174
+ * The dev-review-loop's own authoritative recovery record — phase, round,
175
+ * budgets, held-result and delivered-findings identity, written by the driver
176
+ * (`apps/cli/src/lib/dev-review-loop/round-assess.ts`'s `persistLoopState`)
177
+ * on every round transition and read back on start, attach and resume
178
+ * (`pause-resume.ts`'s `recoverLoopState`), replacing the driver's prior
179
+ * reliance on the task's optional, forge-flushed event history for round-
180
+ * number and budget recovery. This record's `round`, together with the pull
181
+ * request's own principal-authored markers (`journal-history.ts`'s
182
+ * `fetchLoopHistory`), is now the WHOLE round-history source the driver
183
+ * rebuilds on every entry — no log event, flushed log comment, or telemetry
184
+ * outbox is ever read to recover a run (the Log is telemetry, never authority
185
+ * for recovery). One record per task, overwritten in place —
186
+ * deliberately NOT epoch-fenced, the same precedent `ManifestRecordSchema`
187
+ * sets: the driver's own cutover to acquired-epoch ownership over this
188
+ * task's mutable state is separate, later adoption work (`loop.md`); this
189
+ * record's real concurrency guard is still the pid-lock one-driver-per-task
190
+ * check the driver already runs before touching anything.
191
+ */
192
+ export const LoopStateRecordSchema = z
193
+ .object({
194
+ version: z.literal(1),
195
+ kind: z.literal('loop_state'),
196
+ task: taskId,
197
+ round: z.number().int().positive(),
198
+ /** Mirrors `Decision['type']` (`packages/aeg-core/src/dev-review-loop/types.ts`) — a plain string here so this record stays independent of that package's own type, the same discipline `TransitionRecord.from`/`to` already uses for state names. */
199
+ phase: z.string().min(1),
200
+ /** Set only while `phase === 'pause'`. */
201
+ pauseReason: z.string().min(1).nullable(),
202
+ budgets: LoopBudgetsSchema,
203
+ /** The round whose verdict is currently held on disk, awaiting delivery or publish — `null` once nothing is held. */
204
+ heldResult: roundHeadIdentity.nullable(),
205
+ /** The round+head whose findings have already been delivered to the developer once — `null` until a delivery happens; read back so a later attach never redelivers the same (round, head) pair. */
206
+ deliveredFindings: roundHeadIdentity.nullable(),
207
+ recordedAt: isoTimestamp
208
+ })
209
+ .strict()
210
+ export type LoopStateRecord = z.infer<typeof LoopStateRecordSchema>
211
+
212
+ /**
213
+ * One external effect's identity and reconciliation state, keyed by a
214
+ * caller-chosen `key` (one file per key, overwritten in place as the
215
+ * effect's status advances — unlike `run`/`input`, which are written once).
216
+ * `operation`/`target`/`inputVersion`/`payloadDigest` together are the
217
+ * identity `apps/cli/src/lib/effects.ts`'s `EffectExecutor` binds a write
218
+ * to before ever attempting it: a later read finding a DIFFERENT identity
219
+ * under the same `key` is a changed intent, not a retry of this one.
220
+ * `'started'` — intent persisted, the external write has not yet been
221
+ * confirmed. `'verified'` — either the write's own return value was
222
+ * recorded (`url` present), or a recovery reconciled this identity against
223
+ * the remote and found it already landed. `'uncertain'` — a recovery could
224
+ * not reconcile (the remote read itself failed) — refused rather than
225
+ * blindly retried, until a later recovery attempt resolves it.
226
+ */
227
+ export const EffectRecordSchema = z
228
+ .object({
229
+ version: z.literal(1),
230
+ kind: z.literal('effect'),
231
+ task: taskId,
232
+ key: z.string().min(1),
233
+ operation: z.string().min(1),
234
+ target: z.string().min(1),
235
+ inputVersion: z.number().int().nonnegative(),
236
+ payloadDigest: z.string().min(1),
237
+ status: z.union([z.literal('started'), z.literal('verified'), z.literal('uncertain')]),
238
+ url: z.string().optional(),
239
+ recordedAt: isoTimestamp
240
+ })
241
+ .strict()
242
+ export type EffectRecord = z.infer<typeof EffectRecordSchema>
243
+ export type EffectStatus = EffectRecord['status']
244
+
245
+ /**
246
+ * Everything a paused run's human decision needs without chat history
247
+ * (O1) — one immutable record per pause instance, keyed by `escalationId`
248
+ * (`<task>-<round>-<head>`, the same
249
+ * round+head granularity `pause-resume.ts`'s own pause-comment idempotency
250
+ * key already uses, since two real pauses are told apart the identical way).
251
+ * `runId`/`pid`/`host` are the run identity; `briefHash`/`objectivesVersion`/
252
+ * `rulingOrdinal`/`policyDigest` are the input versions the round was
253
+ * judged against (the same four fields `ManifestRecord` binds a verdict to,
254
+ * reused here to bind an ESCALATION to instead); `evidence` is the last
255
+ * round's held verdict text or the pause's own `detail`, whichever the
256
+ * caller had in hand; `attemptedRecovery`/`recipient` come from the fixed
257
+ * per-`reason` profile `pause-resume.ts` owns. `pr` is nullable for the one
258
+ * pre-push escalation shape (`renderNoPushStopComment`) that has no PR yet.
259
+ * `agent` is the vendor this run was actually dispatched under (code review,
260
+ * round 2, MAJOR: `cancelDevReviewLoop` used to trust the operator-typed
261
+ * `--agent` flag with nothing persisted to cross-check it against) —
262
+ * `.optional()` since an escalation record written before this field existed
263
+ * never carries it; a reader falls back to the operator-supplied value only
264
+ * for that legacy case, never for a genuine mismatch.
265
+ */
266
+ export const EscalationRecordSchema = z
267
+ .object({
268
+ version: z.literal(1),
269
+ kind: z.literal('escalation'),
270
+ task: taskId,
271
+ escalationId: z.string().min(1),
272
+ round: epochNumber,
273
+ head: z.string().min(1),
274
+ branch: z.string().min(1),
275
+ pr: z.number().int().positive().nullable(),
276
+ runId: z.string().min(1),
277
+ pid: z.number().int().positive(),
278
+ host: z.string().min(1),
279
+ agent: z.string().min(1).optional(),
280
+ reason: z.string().min(1),
281
+ detail: z.string().optional(),
282
+ evidence: z.string().optional(),
283
+ attemptedRecovery: z.string().min(1),
284
+ requestedDecision: z.string().min(1),
285
+ recipient: z.string().min(1),
286
+ briefHash: z.string().min(1).nullable(),
287
+ objectivesVersion: z.string().min(1).nullable(),
288
+ rulingOrdinal: epochNumber,
289
+ policyDigest: z.string().min(1),
290
+ recordedAt: isoTimestamp
291
+ })
292
+ .strict()
293
+ export type EscalationRecord = z.infer<typeof EscalationRecordSchema>
294
+
295
+ /**
296
+ * The authenticated human decision an escalation resolves to — `'resume'`
297
+ * or `'cancel'` — written AT MOST ONCE per `escalationId` (`local.ts`'s
298
+ * `consumeResolutionOnce` claims the file exclusively, the same `linkSync`
299
+ * discipline an ownership epoch uses, so a second attempt at the SAME
300
+ * `escalationId` collides rather than overwriting: single consumption is a
301
+ * storage guarantee here, not an application-level check). `authenticatedBy`
302
+ * is the principal login the decision was authenticated against (or
303
+ * `'driver-self'` for the two recoverable-hiccup reasons that resume without
304
+ * a ruling); `authenticatedFrom` names the ruling marker (`<pr>-<k>`) or the
305
+ * self-recovery tag it came from.
306
+ */
307
+ export const ResolutionRecordSchema = z
308
+ .object({
309
+ version: z.literal(1),
310
+ kind: z.literal('resolution'),
311
+ task: taskId,
312
+ escalationId: z.string().min(1),
313
+ decision: z.union([z.literal('resume'), z.literal('cancel')]),
314
+ authenticatedBy: z.string().min(1),
315
+ authenticatedFrom: z.string().min(1),
316
+ consumedAt: isoTimestamp
317
+ })
318
+ .strict()
319
+ export type ResolutionRecord = z.infer<typeof ResolutionRecordSchema>
320
+
321
+ export type ControlRecord =
322
+ | RunRecord
323
+ | InputRecord
324
+ | OwnershipRecord
325
+ | TransitionRecord
326
+ | ManifestRecord
327
+ | LoopStateRecord
328
+ | EffectRecord
329
+ | EscalationRecord
330
+ | ResolutionRecord
331
+
332
+ /**
333
+ * `'absent'` — nothing was ever written at this path.
334
+ * `'corrupt'` — something was written, but it doesn't parse as this record:
335
+ * torn JSON, a schema violation, or (since `version` is a closed literal)
336
+ * an unsupported version. Never conflated with `'absent'`.
337
+ */
338
+ export type ParsedRecord<T> = { status: 'ok'; value: T } | { status: 'absent' } | { status: 'corrupt'; reason: string }
339
+
340
+ function parseWith<T>(schema: z.ZodType<T>, raw: string | undefined): ParsedRecord<T> {
341
+ if (raw === undefined) return { status: 'absent' }
342
+ let json: unknown
343
+ try {
344
+ json = JSON.parse(raw)
345
+ } catch (err) {
346
+ return {
347
+ status: 'corrupt',
348
+ reason: `invalid JSON (torn write?): ${err instanceof Error ? err.message : String(err)}`
349
+ }
350
+ }
351
+ const parsed = schema.safeParse(json)
352
+ if (!parsed.success) {
353
+ const issue = parsed.error.issues[0]
354
+ const path = issue?.path.join('.') || '(root)'
355
+ return { status: 'corrupt', reason: `${path}: ${issue?.message ?? 'schema violation'}` }
356
+ }
357
+ return { status: 'ok', value: parsed.data }
358
+ }
359
+
360
+ export function parseRunRecord(raw: string | undefined): ParsedRecord<RunRecord> {
361
+ return parseWith(RunRecordSchema, raw)
362
+ }
363
+
364
+ export function parseInputRecord(raw: string | undefined): ParsedRecord<InputRecord> {
365
+ return parseWith(InputRecordSchema, raw)
366
+ }
367
+
368
+ export function parseOwnershipRecord(raw: string | undefined): ParsedRecord<OwnershipRecord> {
369
+ return parseWith(OwnershipRecordSchema, raw)
370
+ }
371
+
372
+ export function parseTransitionRecord(raw: string | undefined): ParsedRecord<TransitionRecord> {
373
+ return parseWith(TransitionRecordSchema, raw)
374
+ }
375
+
376
+ export function parseManifestRecord(raw: string | undefined): ParsedRecord<ManifestRecord> {
377
+ return parseWith(ManifestRecordSchema, raw)
378
+ }
379
+
380
+ export function parseLoopStateRecord(raw: string | undefined): ParsedRecord<LoopStateRecord> {
381
+ return parseWith(LoopStateRecordSchema, raw)
382
+ }
383
+
384
+ export function parseEffectRecord(raw: string | undefined): ParsedRecord<EffectRecord> {
385
+ return parseWith(EffectRecordSchema, raw)
386
+ }
387
+
388
+ export function parseEscalationRecord(raw: string | undefined): ParsedRecord<EscalationRecord> {
389
+ return parseWith(EscalationRecordSchema, raw)
390
+ }
391
+
392
+ export function parseResolutionRecord(raw: string | undefined): ParsedRecord<ResolutionRecord> {
393
+ return parseWith(ResolutionRecordSchema, raw)
394
+ }
@@ -1,6 +1,5 @@
1
1
  /**
2
- * Dead-branch-push AUDIT (aeg-governance-hardening task 24, #364, Part 4 —
3
- * item 2). Distinct from the ring-0 `dead-branch-push-guard.ts` (task 18):
2
+ * Dead-branch-push AUDIT. Distinct from the ring-0 `dead-branch-push-guard.ts`:
4
3
  * that predicate answers "should THIS push be allowed right now?" at push
5
4
  * time; this one answers "did commits land on a branch AFTER its PR already
6
5
  * resolved?" retrospectively, across every remote `task/*` branch — the
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Dead-branch push guard (aeg-governance-hardening task 18, #335). Pure — no
2
+ * Dead-branch push guard. Pure — no
3
3
  * `fs`, no `gh`/`git` shell-outs. The CLI shim (`bin/check-push-target.ts`)
4
4
  * makes the one batched forge call (`gh pr list --head <branch> --state all
5
5
  * --json number,state --limit 1`), maps its result to a `PrStateFact`, and
@@ -3,8 +3,8 @@
3
3
  * surface globs against `.vinaya/doc-owners` bindings (state-machine.md
4
4
  * Section 15). Pure — parses doc-owners content via `parseDocOwners` (no
5
5
  * second parser) and does segment-wise glob overlap between each intended
6
- * surface and each binding's code glob. A Planner/Brief-Author aid only —
7
- * not wired into any CI gate.
6
+ * surface and each binding's code glob. A Planner aid only — not wired
7
+ * into any CI gate.
8
8
  */
9
9
 
10
10
  import { parseDocOwners } from './doc-owners'