@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,373 @@
1
+ /**
2
+ * The Vinaya Log's typed storage contract (O1–O3). One interface —
3
+ * `append`, `readPage`, `acknowledge` — that both the
4
+ * real GitHub adapter behind `vinaya log flush`
5
+ * (`apps/cli/src/lib/log-flush.ts`) and the deterministic in-memory fixture
6
+ * backend below implement. This module is the policy layer: pure, no
7
+ * filesystem, no network, no process (`apps/cli/specs/surface.md` "The
8
+ * rule"), so the adversarial fault cases O2/O3 name — a lost acknowledgement,
9
+ * a concurrent append, an overflow, an unknown-version record, redaction on
10
+ * both boundaries — are provable against the fixture backend with no I/O at
11
+ * all.
12
+ *
13
+ * What the contract fixes, in the language of the Boundary:
14
+ * "the outbox rotates into one overwritten backup and flush retries can
15
+ * repeat remotely accepted batches." A record's identity is stable
16
+ * (`recordIdentity`), so re-appending an already-stored batch after a lost
17
+ * acknowledgement is a no-op (`AppendOutcome.duplicates`), not a duplicate;
18
+ * only acknowledged identities are ever removed (`acknowledge`); and an
19
+ * overflow past a store's capacity is REPORTED (`AppendOutcome.overflow`),
20
+ * never the silent single-slot overwrite the outbox rotation performed.
21
+ * Read-back (`readPage` / `classifyStoredLine`) validates each line's schema
22
+ * version and — for a `schema: 2` line — its provenance, re-applies
23
+ * `redact()` at the read (transport) boundary, and PRESERVES a record whose
24
+ * schema version this build has never heard of as an `unknown_version`
25
+ * record for diagnosis rather than dropping it or failing the whole page.
26
+ */
27
+
28
+ import { redact } from './redact'
29
+ import { LogEventSchema, type LogEvent, type Provenance } from './schema'
30
+
31
+ /**
32
+ * The schema versions this build validates in full. A stored line carrying a
33
+ * `meta.schema` outside this set is neither trusted nor discarded — it is
34
+ * kept as an `unknown_version` read record (O3). Mirrors the
35
+ * `HeaderMetaSchema` discriminated union in `schema.ts` (`1` | `2`); a future
36
+ * task widening that union widens this set in the same change.
37
+ */
38
+ export const KNOWN_SCHEMA_VERSIONS = [1, 2] as const
39
+
40
+ /**
41
+ * A record's stable identity across retry, concurrent append and a lost
42
+ * acknowledgement (O2). A `schema: 2` line carries a per-event `event_id`,
43
+ * generated once per `log()` call — that is the identity. A `schema: 1` line
44
+ * predates `event_id`; its identity is `${run_id}:${seq}`, the same
45
+ * `run_id`/`seq` pair the flush's `<!-- aeg:log:<run_id>:<seq> -->` marker is
46
+ * already keyed on, so the two agree. `null` when neither can be read (a
47
+ * torn or non-conforming line) — a caller treats a null-identity line as one
48
+ * it can never deduplicate or acknowledge, never as identity `""`.
49
+ */
50
+ export type RecordIdentity = string
51
+
52
+ function metaOf(obj: unknown): Record<string, unknown> | null {
53
+ if (obj === null || typeof obj !== 'object') return null
54
+ const meta = (obj as { meta?: unknown }).meta
55
+ if (meta === null || typeof meta !== 'object') return null
56
+ return meta as Record<string, unknown>
57
+ }
58
+
59
+ /**
60
+ * The stable identity of a parsed outbox object, or `null` when it carries
61
+ * neither a usable `event_id` nor a `run_id`/`seq` pair. Pure — takes an
62
+ * already-parsed object so it works on a raw, not-yet-schema-validated line
63
+ * (the read side must identify a line before it knows the line is valid).
64
+ */
65
+ export function recordIdentity(obj: unknown): RecordIdentity | null {
66
+ const meta = metaOf(obj)
67
+ if (meta === null) return null
68
+ const eventId = meta.event_id
69
+ if (typeof eventId === 'string' && eventId.length > 0) return eventId
70
+ const runId = meta.run_id
71
+ const seq = meta.seq
72
+ if (typeof runId === 'string' && runId.length > 0 && typeof seq === 'number' && Number.isInteger(seq)) {
73
+ return `${runId}:${seq}`
74
+ }
75
+ return null
76
+ }
77
+
78
+ function schemaVersionOf(obj: unknown): number | null {
79
+ const meta = metaOf(obj)
80
+ const schema = meta?.schema
81
+ return typeof schema === 'number' ? schema : null
82
+ }
83
+
84
+ function isKnownSchema(version: number | null): boolean {
85
+ return version !== null && (KNOWN_SCHEMA_VERSIONS as readonly number[]).includes(version)
86
+ }
87
+
88
+ /** A read-back record — the output of `classifyStoredLine` / `readPage`. */
89
+ export type ReadRecord =
90
+ | {
91
+ /** Full `LogEventSchema` validation passed for a known schema version. */
92
+ status: 'ok'
93
+ identity: RecordIdentity
94
+ runId: string
95
+ seq: number
96
+ schema: number
97
+ /** Trust provenance for a `schema: 2` line; `null` for a `schema: 1` line, which has no such field. */
98
+ provenance: Provenance | null
99
+ /** The re-validated event. */
100
+ event: LogEvent
101
+ /** The event re-serialized after re-applying `redact()` — what a transport (the flush) posts, never the raw file bytes. */
102
+ postLine: string
103
+ }
104
+ | {
105
+ /** The line's `meta.schema` is a version this build does not know — kept for diagnosis (O3), never dropped, never posted. */
106
+ status: 'unknown_version'
107
+ identity: RecordIdentity | null
108
+ schema: number | null
109
+ raw: string
110
+ reason: string
111
+ }
112
+ | {
113
+ /** Not JSON, or a KNOWN schema version that failed full validation (including an invalid `provenance`) — a corrupt line. */
114
+ status: 'invalid'
115
+ identity: RecordIdentity | null
116
+ raw: string
117
+ reason: string
118
+ }
119
+
120
+ /**
121
+ * Classifies one stored line: validates its schema version and (for
122
+ * `schema: 2`) its provenance, re-applies `redact(event, home)` at this read
123
+ * (transport) boundary, and distinguishes three outcomes:
124
+ *
125
+ * - `ok` — a known schema version that fully re-validated. `postLine` is the
126
+ * re-redacted, re-serialized form; `provenance` is surfaced from the
127
+ * header (`null` for `schema: 1`).
128
+ * - `unknown_version` — the line's `meta.schema` is outside
129
+ * `KNOWN_SCHEMA_VERSIONS`. Kept verbatim in `raw` for diagnosis (O3): a
130
+ * real event recorded by a newer producer is never made unreadable, and
131
+ * never silently dropped, just because this build is older.
132
+ * - `invalid` — not JSON, no readable schema, or a KNOWN version that failed
133
+ * `LogEventSchema` (a manual edit, disk corruption, a `redact.ts` gap, or
134
+ * an out-of-range `provenance`). A corrupt line, distinct from an
135
+ * unknown-version one.
136
+ */
137
+ export function classifyStoredLine(raw: string, home: string): ReadRecord {
138
+ let obj: unknown
139
+ try {
140
+ obj = JSON.parse(raw)
141
+ } catch {
142
+ return { status: 'invalid', identity: null, raw, reason: 'not valid JSON' }
143
+ }
144
+
145
+ const version = schemaVersionOf(obj)
146
+ if (version === null) {
147
+ return { status: 'invalid', identity: recordIdentity(obj), raw, reason: 'no readable meta.schema' }
148
+ }
149
+ if (!isKnownSchema(version)) {
150
+ return {
151
+ status: 'unknown_version',
152
+ identity: recordIdentity(obj),
153
+ schema: version,
154
+ raw,
155
+ reason: `schema version ${version} is not one this build validates (${KNOWN_SCHEMA_VERSIONS.join(', ')}) — kept for diagnosis`
156
+ }
157
+ }
158
+
159
+ const result = LogEventSchema.safeParse(obj)
160
+ if (!result.success) {
161
+ return {
162
+ status: 'invalid',
163
+ identity: recordIdentity(obj),
164
+ raw,
165
+ reason: result.error.issues[0]?.message ?? 'schema violation'
166
+ }
167
+ }
168
+
169
+ const event = result.data
170
+ const identity = recordIdentity(event)
171
+ if (identity === null) {
172
+ // A fully-valid event whose header carries neither event_id nor a
173
+ // run_id/seq pair is structurally impossible under LogEventSchema
174
+ // (headerMetaCore requires both run_id and seq), but the read side never
175
+ // trusts that on faith — an unidentifiable valid line is still refused.
176
+ return { status: 'invalid', identity: null, raw, reason: 'valid event with no derivable identity' }
177
+ }
178
+
179
+ const redacted = redact(event, home)
180
+ const provenance = version === 2 ? ((event.meta as { provenance?: Provenance }).provenance ?? null) : null
181
+ return {
182
+ status: 'ok',
183
+ identity,
184
+ runId: event.meta.run_id,
185
+ seq: event.meta.seq,
186
+ schema: version,
187
+ provenance,
188
+ event,
189
+ postLine: JSON.stringify(redacted)
190
+ }
191
+ }
192
+
193
+ /** Diagnostics a page read exposes alongside its records — the "observable loss" O2/O3 require, never a silent skip. */
194
+ export type ReadDiagnostics = {
195
+ total: number
196
+ ok: number
197
+ unknownVersion: number
198
+ invalid: number
199
+ }
200
+
201
+ export type ReadPage = {
202
+ records: ReadRecord[]
203
+ /** The cursor to pass for the next page, or `null` when this page reached the end. */
204
+ nextCursor: number | null
205
+ diagnostics: ReadDiagnostics
206
+ }
207
+
208
+ /**
209
+ * Reads one page of `[cursor, cursor + limit)` from `rawLines`, classifying
210
+ * each line through `classifyStoredLine`. Pure over an array a caller has
211
+ * already read (the fixture backend holds it in memory; the GitHub adapter
212
+ * splits the outbox file). `limit` is clamped to at least 1.
213
+ */
214
+ export function readPageFrom(
215
+ rawLines: readonly string[],
216
+ cursor: number | null,
217
+ limit: number,
218
+ home: string
219
+ ): ReadPage {
220
+ const start = cursor === null || cursor < 0 ? 0 : cursor
221
+ const size = Math.max(1, Math.floor(limit))
222
+ const end = Math.min(rawLines.length, start + size)
223
+ const records: ReadRecord[] = []
224
+ const diagnostics: ReadDiagnostics = { total: 0, ok: 0, unknownVersion: 0, invalid: 0 }
225
+ for (let i = start; i < end; i++) {
226
+ const record = classifyStoredLine(rawLines[i] as string, home)
227
+ records.push(record)
228
+ diagnostics.total++
229
+ if (record.status === 'ok') diagnostics.ok++
230
+ else if (record.status === 'unknown_version') diagnostics.unknownVersion++
231
+ else diagnostics.invalid++
232
+ }
233
+ return { records, nextCursor: end < rawLines.length ? end : null, diagnostics }
234
+ }
235
+
236
+ /**
237
+ * An overflow past a store's capacity, reported rather than performed
238
+ * silently (O2). Names exactly which identities were dropped, so a caller can
239
+ * surface the loss — never the single-slot `<name>.1.ndjson` overwrite the
240
+ * outbox rotation did with no record of what it discarded.
241
+ */
242
+ export type OverflowDiagnostic = {
243
+ reason: 'capacity'
244
+ dropped: number
245
+ droppedIdentities: RecordIdentity[]
246
+ }
247
+
248
+ /** The outcome of an `append` — every identity that landed, every one skipped as an already-present duplicate, and any overflow the append forced. */
249
+ export type AppendOutcome = {
250
+ appended: RecordIdentity[]
251
+ duplicates: RecordIdentity[]
252
+ overflow: OverflowDiagnostic | null
253
+ }
254
+
255
+ /**
256
+ * The storage contract. `append` is idempotent by identity; `readPage`
257
+ * validates and classifies without mutating; `acknowledge` removes ONLY the
258
+ * identities it is handed. A backend implements all four — the fixture below
259
+ * in memory, the GitHub adapter over the outbox file and the forge.
260
+ */
261
+ export interface LogStore {
262
+ /** Idempotently append records (raw ndjson strings or event objects). Redacts at this write (sink) boundary. */
263
+ append(records: readonly (string | object)[]): AppendOutcome
264
+ /** Read one page from `cursor` (validation + provenance + unknown-version preservation + transport-boundary redaction). */
265
+ readPage(cursor: number | null, limit: number): ReadPage
266
+ /** Remove exactly the named identities. Returns how many were present and removed. */
267
+ acknowledge(identities: readonly RecordIdentity[]): number
268
+ /** How many records are currently held. */
269
+ size(): number
270
+ }
271
+
272
+ export type FixtureStoreOptions = {
273
+ /**
274
+ * Maximum records held before an append overflows the oldest. Omit for an
275
+ * unbounded store. A capacity of `0` or less is treated as unbounded.
276
+ */
277
+ capacity?: number
278
+ /** Home directory passed to `redact()` for absolute-path rewriting; defaults to `''` (no path rewriting, secret patterns still apply). */
279
+ home?: string
280
+ }
281
+
282
+ type StoredEntry = { identity: RecordIdentity; raw: string }
283
+
284
+ /**
285
+ * A deterministic, in-memory `LogStore` (O1). No I/O, no clock, no randomness
286
+ * — the same calls in the same order always produce the same state, which is
287
+ * exactly what makes the adversarial O2/O3 cases (lost ack, concurrent
288
+ * append, overflow, unknown version, redaction both sides) unit-testable
289
+ * against it. `append` redacts each record at the write (sink) boundary and
290
+ * skips any whose identity is already stored; `readPage` redacts again at the
291
+ * read (transport) boundary; `acknowledge` removes only the named identities.
292
+ */
293
+ export function createFixtureStore(options: FixtureStoreOptions = {}): LogStore {
294
+ const home = options.home ?? ''
295
+ const capacity = options.capacity !== undefined && options.capacity > 0 ? Math.floor(options.capacity) : null
296
+ const entries: StoredEntry[] = []
297
+ const present = new Set<RecordIdentity>()
298
+
299
+ function normalize(record: string | object): { identity: RecordIdentity | null; raw: string } {
300
+ if (typeof record === 'string') {
301
+ let parsed: unknown
302
+ try {
303
+ parsed = JSON.parse(record)
304
+ } catch {
305
+ return { identity: null, raw: record }
306
+ }
307
+ // Redact at the sink boundary even for a raw string a caller hands in.
308
+ const redacted = redact(parsed, home)
309
+ return { identity: recordIdentity(redacted), raw: JSON.stringify(redacted) }
310
+ }
311
+ const redacted = redact(record, home)
312
+ return { identity: recordIdentity(redacted), raw: JSON.stringify(redacted) }
313
+ }
314
+
315
+ return {
316
+ append(records) {
317
+ const appended: RecordIdentity[] = []
318
+ const duplicates: RecordIdentity[] = []
319
+ const droppedIdentities: RecordIdentity[] = []
320
+ for (const record of records) {
321
+ const { identity, raw } = normalize(record)
322
+ // A line with no derivable identity cannot be deduplicated; store it
323
+ // under a positional identity so it is still readable and
324
+ // acknowledgeable, and count it as appended.
325
+ const id = identity ?? `anon:${entries.length}`
326
+ if (present.has(id)) {
327
+ duplicates.push(id)
328
+ continue
329
+ }
330
+ entries.push({ identity: id, raw })
331
+ present.add(id)
332
+ appended.push(id)
333
+ if (capacity !== null && entries.length > capacity) {
334
+ const evicted = entries.shift() as StoredEntry
335
+ present.delete(evicted.identity)
336
+ droppedIdentities.push(evicted.identity)
337
+ }
338
+ }
339
+ return {
340
+ appended,
341
+ duplicates,
342
+ overflow:
343
+ droppedIdentities.length > 0
344
+ ? { reason: 'capacity', dropped: droppedIdentities.length, droppedIdentities }
345
+ : null
346
+ }
347
+ },
348
+ readPage(cursor, limit) {
349
+ return readPageFrom(
350
+ entries.map((e) => e.raw),
351
+ cursor,
352
+ limit,
353
+ home
354
+ )
355
+ },
356
+ acknowledge(identities) {
357
+ const toRemove = new Set(identities)
358
+ let removed = 0
359
+ for (let i = entries.length - 1; i >= 0; i--) {
360
+ const entry = entries[i] as StoredEntry
361
+ if (toRemove.has(entry.identity)) {
362
+ entries.splice(i, 1)
363
+ present.delete(entry.identity)
364
+ removed++
365
+ }
366
+ }
367
+ return removed
368
+ },
369
+ size() {
370
+ return entries.length
371
+ }
372
+ }
373
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Ring-0 main-branch refusal (task 9, Issue #58). Mechanizes the
2
+ * Ring-0 main-branch refusal. Mechanizes the
3
3
  * worktree-plus-PR rule at ring 0 for adopters: refuses a commit or push
4
4
  * whose current branch IS the repo's default branch — today enforced only
5
5
  * by attalabs' hand-written husky shell (which `init` never generates) and
@@ -23,7 +23,7 @@
23
23
  * check whose job is refusing risky actions must not itself risk refusing
24
24
  * a legitimate one it cannot actually evaluate.
25
25
  *
26
- * `pushRefs` (Issue #407, O2) carries git's pre-push stdin — one line per
26
+ * `pushRefs` carries git's pre-push stdin — one line per
27
27
  * ref being pushed, `<local ref> <local sha> <remote ref> <remote sha>` —
28
28
  * newline-joined, exactly as `VINAYA_PUSH_REFS` carries it. `null` means no
29
29
  * push is in flight at all (a commit, via `check --all --diff-only
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Hardened I/O for `MeteringCapabilityDeps` (CWE-59, `#313`). Every real
2
+ * Hardened I/O for `MeteringCapabilityDeps` (CWE-59). Every real
3
3
  * caller of `resolveMeteringCapability` fills `exists`/`readFile` with the
4
4
  * factory here rather than hand-rolling `existsSync`/`readFileSync`, so the
5
5
  * guard lives once at the shared seam instead of being re-derived (or
@@ -1,6 +1,5 @@
1
1
  /**
2
- * Milestone-shape validation for `vinaya milestone create` (vinaya-milestone-model-v1
3
- * task 2). Pure — no `fs`, no `gh`. The command calls `checkMilestoneShape` before
2
+ * Milestone-shape validation for `vinaya milestone create`. Pure — no `fs`, no `gh`. The command calls `checkMilestoneShape` before
4
3
  * any forge write, so a malformed body never reaches GitHub.
5
4
  *
6
5
  * A Milestone's description carries three independent things, each parsed and
@@ -155,7 +154,7 @@ export function checkMilestoneShape(body: string): MilestoneShapeResult {
155
154
  }
156
155
 
157
156
  // ---------------------------------------------------------------------------
158
- // `vinaya milestone adopt` (vinaya-milestone-migration-v1 task 1) — checkAdoptable
157
+ // `vinaya milestone adopt` — checkAdoptable
159
158
  // ---------------------------------------------------------------------------
160
159
 
161
160
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * New-on-disk-state guard (#512 Part D). Pure — no `fs`, no `git`/`gh` I/O.
2
+ * New-on-disk-state guard. Pure — no `fs`, no `git`/`gh` I/O.
3
3
  * Flags a diff-touched path as a disk-state offender given its change
4
4
  * status (`added` — the path didn't exist on the base ref — or `modified`
5
5
  * — it already did):
@@ -7,7 +7,7 @@
7
7
  * (a) A live tranche topology file directly under `aeg-root/tranches/`
8
8
  * (not a subdirectory) — the residue class this task's own Part B proved
9
9
  * unnecessary (forge derivation already covers it, see
10
- * `aeg-drift-prevention-v1.md`'s deletion). Fails on `added` OR
10
+ * the governing spec's deletion). Fails on `added` OR
11
11
  * `modified`: this file class shouldn't exist at all post-cutover,
12
12
  * whether newly created or resurrected via an edit.
13
13
  *