@attalabs/vinaya 0.33.0 → 0.35.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 (143) hide show
  1. package/LICENSE +104 -201
  2. package/README.md +1 -1
  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 +30 -10
  7. package/aeg-root/roles/planner/reference.md +3 -2
  8. package/aeg-root/roles/planner.md +3 -1
  9. package/aeg-root/templates/brief-template.md +9 -7
  10. package/aeg-root/templates/pr-report-template.md +3 -1
  11. package/dist/checks/bin/check-body-bare-digits.js +107 -28
  12. package/dist/checks/bin/check-branch-topology.js +94 -25
  13. package/dist/checks/bin/check-brief-shape.js +113 -33
  14. package/dist/checks/bin/check-changeset-coverage.js +369 -92
  15. package/dist/checks/bin/check-closes-n.js +94 -25
  16. package/dist/checks/bin/check-coherence.js +124 -29
  17. package/dist/checks/bin/check-dead-branch-push.js +79 -25
  18. package/dist/checks/bin/check-dispatch-readiness.js +122 -28
  19. package/dist/checks/bin/check-doc-coverage-push.js +365 -88
  20. package/dist/checks/bin/check-doc-coverage.js +367 -90
  21. package/dist/checks/bin/check-doctrine-no-procedures.js +107 -28
  22. package/dist/checks/bin/check-doctrine-portability.js +366 -89
  23. package/dist/checks/bin/check-evidence-fresh.js +338 -61
  24. package/dist/checks/bin/check-exec-bits.js +363 -86
  25. package/dist/checks/bin/check-first-push-dispatch.js +122 -28
  26. package/dist/checks/bin/check-issue-assignment.js +94 -25
  27. package/dist/checks/bin/check-issue-milestone-attach.js +79 -25
  28. package/dist/checks/bin/check-issue-objectives-numbering.js +606 -26
  29. package/dist/checks/bin/check-issue-parts-coverage.js +79 -25
  30. package/dist/checks/bin/check-issue-surface-globs.js +162 -34
  31. package/dist/checks/bin/check-issue-title-grammar.js +79 -25
  32. package/dist/checks/bin/check-issue-tranche-label.js +79 -25
  33. package/dist/checks/bin/check-main-branch-refusal.js +79 -25
  34. package/dist/checks/bin/check-no-disk-state.js +79 -25
  35. package/dist/checks/bin/check-pr-premise-reassert.js +107 -28
  36. package/dist/checks/bin/check-pr-report-density.js +79 -25
  37. package/dist/checks/bin/check-principal-test-plan-wait.js +79 -25
  38. package/dist/checks/bin/check-quoted-command.js +282 -39
  39. package/dist/checks/bin/check-reader-resolvable-prose.js +333 -47
  40. package/dist/checks/bin/check-registry-gates.js +79 -25
  41. package/dist/checks/bin/check-retired-vocabulary.js +282 -39
  42. package/dist/checks/bin/check-review-gate.js +111 -31
  43. package/dist/checks/bin/check-single-plan-pr.js +79 -25
  44. package/dist/checks/bin/check-surface-scope.js +94 -25
  45. package/dist/checks/bin/check-test-plan.js +79 -25
  46. package/dist/checks/bin/check-token-collection-wired.js +79 -25
  47. package/dist/checks/bin/check-token-report.js +79 -25
  48. package/dist/checks/bin/check-workspace-escape.js +364 -87
  49. package/dist/index.js +2713 -1609
  50. package/dist/lib/pre-push-cache-test-run.js +226 -16
  51. package/dist/lib/pre-push-select-tests.js +48 -5
  52. package/package.json +2 -2
  53. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-render.ts +153 -37
  54. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/brief-validation.ts +87 -24
  55. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/coherence-checks.ts +9 -2
  56. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/control-store/migration.ts +13 -3
  57. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/assess-round.ts +7 -0
  58. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/index.ts +5 -2
  59. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/journal-reconstruction.ts +116 -20
  60. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/dev-review-loop/render-summary.ts +100 -4
  61. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/gate-cutovers.ts +49 -0
  62. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/index.ts +60 -4
  63. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/issue-validation.ts +138 -54
  64. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/log/envelope.ts +26 -3
  65. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives-cutover-config.ts +31 -0
  66. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/objectives.ts +15 -6
  67. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/reader-resolvable-prose.ts +122 -23
  68. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-gate.ts +18 -3
  69. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-policy.ts +24 -0
  70. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/review-status.ts +15 -10
  71. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/ruling-ordinal.ts +16 -0
  72. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-phase-history.ts +194 -0
  73. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/task-tools.ts +312 -53
  74. package/studio-standalone/_node_modules/@attalabs/aeg-core/src/verdict-extraction.ts +62 -8
  75. package/studio-standalone/apps/vinaya-studio/web/.next/BUILD_ID +1 -1
  76. package/studio-standalone/apps/vinaya-studio/web/.next/build-manifest.json +3 -3
  77. package/studio-standalone/apps/vinaya-studio/web/.next/prerender-manifest.json +3 -3
  78. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.html +1 -1
  79. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.rsc +1 -1
  80. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  81. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  82. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  83. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  84. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  85. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page/server-reference-manifest.json +2 -2
  86. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page.js.nft.json +1 -1
  87. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  88. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/api/coherence/route.js.nft.json +1 -1
  89. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page/server-reference-manifest.json +2 -2
  90. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page.js.nft.json +1 -1
  91. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/page_client-reference-manifest.js +1 -1
  92. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page/server-reference-manifest.json +2 -2
  93. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page.js.nft.json +1 -1
  94. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/backlog/page_client-reference-manifest.js +1 -1
  95. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page/server-reference-manifest.json +2 -2
  96. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page.js.nft.json +1 -1
  97. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/page_client-reference-manifest.js +1 -1
  98. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page/server-reference-manifest.json +2 -2
  99. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page.js.nft.json +1 -1
  100. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/page_client-reference-manifest.js +1 -1
  101. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page/server-reference-manifest.json +3 -3
  102. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page.js.nft.json +1 -1
  103. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/page_client-reference-manifest.js +1 -1
  104. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page/server-reference-manifest.json +2 -2
  105. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page.js.nft.json +1 -1
  106. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/[name]/tranches/[slug]/tasks/[taskId]/page_client-reference-manifest.js +1 -1
  107. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page/server-reference-manifest.json +2 -2
  108. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page.js.nft.json +1 -1
  109. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/projects/page_client-reference-manifest.js +1 -1
  110. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page/server-reference-manifest.json +2 -2
  111. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page.js.nft.json +1 -1
  112. package/studio-standalone/apps/vinaya-studio/web/.next/server/app/studio/tranches/page_client-reference-manifest.js +1 -1
  113. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/[root-of-the-server]__02a-3g8._.js +4 -4
  114. 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
  115. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__074w9nf._.js +1 -1
  116. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__0ls23oh._.js +1 -1
  117. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/{[root-of-the-server]__18paley._.js → [root-of-the-server]__0zc_0gx._.js} +1 -1
  118. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1gjqmhq._.js +1 -1
  119. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/[root-of-the-server]__1wc4-ip._.js +1 -1
  120. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_08onyya._.js +1 -1
  121. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_096f46i._.js +1 -1
  122. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0af2one._.js +1 -1
  123. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0e5tkdd._.js +1 -1
  124. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0kf2g72._.js +1 -1
  125. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_0zf4d27._.js +1 -1
  126. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1-wo68i._.js +1 -1
  127. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_15gdg48._.js +2 -2
  128. package/studio-standalone/apps/vinaya-studio/web/.next/server/chunks/ssr/_1achbh9._.js +1 -1
  129. 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
  130. package/studio-standalone/apps/vinaya-studio/web/.next/server/middleware-build-manifest.js +3 -3
  131. package/studio-standalone/apps/vinaya-studio/web/.next/server/pages/500.html +1 -1
  132. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.js +1 -1
  133. package/studio-standalone/apps/vinaya-studio/web/.next/server/server-reference-manifest.json +4 -4
  134. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0ko698wh8xx2g.css +1 -0
  135. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{22s44f5k3ecmj.js → 3goaig_rysc6p.js} +1 -1
  136. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{1ce2dj27_cgbj.js → 3ip5z3cf43bgo.js} +4 -4
  137. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/{34hhdtbp20krb.js → 3u9emqjwpd0t9.js} +1 -1
  138. package/studio-standalone/apps/vinaya-studio/web/package.json +2 -2
  139. package/studio-standalone/apps/vinaya-studio/web/.next/static/chunks/0bm4nrrzwc7zi.css +0 -1
  140. /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/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
  141. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{vl7QVqELe1AQ-9kaOd9mR → ca66rAHI_w9D7S7ceXDvR}/_buildManifest.js +0 -0
  142. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{vl7QVqELe1AQ-9kaOd9mR → ca66rAHI_w9D7S7ceXDvR}/_clientMiddlewareManifest.js +0 -0
  143. /package/studio-standalone/apps/vinaya-studio/web/.next/static/{vl7QVqELe1AQ-9kaOd9mR → ca66rAHI_w9D7S7ceXDvR}/_ssgManifest.js +0 -0
@@ -10,14 +10,18 @@
10
10
  * those events stopped going to the tracker.
11
11
  *
12
12
  * This module is the PURE half of the rebuild: given the round numbers the
13
- * forge's own principal-authored developer round markers carry, and whether a
14
- * ready-for-merge summary was actually published to the forge, hand back one
13
+ * forge's own principal-authored developer round markers carry, whether a
14
+ * ready-for-merge summary was actually published to the forge, and the review
15
+ * gate's verdict on the pull request's current state, hand back one
15
16
  * `RoundRecord` per round plus where the next round should start numbering.
16
17
  * The impure caller (`journal-history.ts`, `@attalabs/vinaya`) gathers those
17
- * two facts: it reads the pull request's principal-authored comments and the
18
- * control store, never a log line. The control store's own authoritative
19
- * round is recovered separately by the driver (`recoverLoopState`), and is
20
- * deliberately NOT folded into the numbering here — see `reconstructRounds`.
18
+ * facts: it reads the pull request's principal-authored comments and evaluates
19
+ * the gate, never a log line. Nothing here performs a forge read or a gate
20
+ * evaluation of its own — the gate's verdict arrives as an input fact, which is
21
+ * what keeps this half pure and testable in every combination. The control
22
+ * store's own authoritative round is recovered separately by the driver
23
+ * (`recoverLoopState`), and is deliberately NOT folded into the numbering here
24
+ * — see `reconstructRounds`.
21
25
  *
22
26
  * Honest about what the forge markers carry: a developer round marker
23
27
  * (`<!-- aeg:developer:round-<n> -->`) names only the round's own number and
@@ -51,32 +55,85 @@ export function isPublishedSummaryComment(body: string): boolean {
51
55
  }
52
56
 
53
57
  /**
54
- * The two forge-derived facts a rebuild is handed. `roundMarkers` are the
55
- * round numbers read off every principal-authored developer round marker on
56
- * the pull request (order and duplicates irrelevant — deduplicated here).
57
- * `summaryPublished` is whether a principal-authored summary comment exists.
58
+ * The forge-derived facts a rebuild is handed. `roundMarkers` are the round
59
+ * numbers read off every principal-authored developer round marker on the
60
+ * pull request (order and duplicates irrelevant — deduplicated here).
61
+ * `summaryPublished` is whether a principal-authored summary comment exists,
62
+ * and `summaryUrl` is that comment's own address when one does.
63
+ * `reviewGate` is the review gate's verdict on the pull request's CURRENT
64
+ * state.
58
65
  */
59
66
  export type ReconstructionInput = {
60
67
  roundMarkers: readonly number[]
61
68
  summaryPublished: boolean
69
+ /** The published summary comment's own url, or `null` when none is on the forge (or the caller could not resolve one). */
70
+ summaryUrl?: string | null
71
+ /**
72
+ * The review gate's verdict on the pull request's CURRENT head, objectives
73
+ * version, newest ruling, frozen brief and policy — the second half of
74
+ * "concluded" (see `journalFinalized`). The caller evaluates it
75
+ * (`checkReviewGate`; nothing here ever reads the forge) and hands the
76
+ * answer in.
77
+ */
78
+ reviewGate: ReviewGateFact
62
79
  }
63
80
 
81
+ /**
82
+ * What the caller could learn about the review gate.
83
+ *
84
+ * - `'pass'`/`'fail'` — the gate genuinely evaluated, against the pull
85
+ * request's current state.
86
+ * - `'unknown'` — nobody asked (no summary is on the forge, so the answer
87
+ * could not change the outcome), or the evaluation could not be made at all
88
+ * (a failed forge read, an unresolvable head, a thrown evaluation).
89
+ *
90
+ * `'unknown'` deliberately does NOT reopen a published review: it is the
91
+ * absence of evidence, not evidence the review moved on, and the two failure
92
+ * directions are not symmetric. Reading it as "reopened" makes one transient
93
+ * `gh` hiccup dispatch a whole extra review round against a task that was
94
+ * genuinely finished, and post its comments — the "a rerun posts nothing
95
+ * twice" invariant, lost for a fact nobody could check. Reading it as "no new
96
+ * information" costs at most one refusal that names the unevaluable gate
97
+ * (`concludedLoopRefusal`) and clears itself on the next attempt. The merge
98
+ * gate is unaffected either way: the `review-gate` check fails CLOSED on every
99
+ * one of these same unresolvable facts, so nothing merges on an unknown here.
100
+ */
101
+ export type ReviewGateFact = 'pass' | 'fail' | 'unknown'
102
+
64
103
  export type ReconstructedJournal = {
65
104
  rounds: RoundRecord[]
66
105
  /** Deliberately `0`: per-round wall time has no control-record or forge source, so it is reported unavailable rather than a fabricated sum (O3). */
67
106
  totalWallMs: number
68
107
  /** Deliberately `0`: per-round files-changed has no control-record or forge source, so it is reported unavailable rather than a fabricated sum (O3). */
69
108
  totalFilesChanged: number
109
+ /** The published summary comment's own url, or `null` when no summary is on the forge (or the caller could not resolve one). Carried even when the gate is red, so a refusal can name where the summary was posted. */
110
+ summaryUrl: string | null
111
+ /** The gate verdict this journal was reconstructed against, carried so a refusal can say the gate could not be evaluated rather than implying it passed. */
112
+ reviewGate: ReviewGateFact
70
113
  /**
71
- * `{ result: 'merged_ready' }` ONLY when a principal-authored ready-for-
72
- * merge summary comment is actually on the forge — the one honest signal a
73
- * run reached publication. A round that decided `publish` but crashed before
74
- * the summary landed (a `gh` failure mid-publish) leaves NO summary comment,
75
- * so this reads `null` and the caller never mistakes that crash for a
76
- * completion — the exact distinction the old log-derived `journal_finalized`
77
- * deferral drew, now drawn from the forge instead. Consumers only ever test
78
- * `=== 'merged_ready'`; `'stopped'` is retained in the type for parity with
79
- * the shape this replaces but is never produced here.
114
+ * `{ result: 'merged_ready' }` while a principal-authored ready-for-merge
115
+ * summary comment is actually on the forge AND the review gate has not
116
+ * FAILED against the pull request's CURRENT state (`ReviewGateFact`, whose
117
+ * own doc explains why an `'unknown'` gate is not a reopen). Concluded is a
118
+ * property of the pull request now, not a one-way latch it once passed
119
+ * through.
120
+ *
121
+ * The summary alone was the old signal, and it is sticky in a way the forge
122
+ * is not: the summary table records no head, so a summary posted for an
123
+ * older head keeps reading "done forever" after a red gate, a newer
124
+ * Principal ruling, a superseded brief or a moved head — observed on an
125
+ * adopter pull request whose every `--resume` was refused while the gate was
126
+ * red and a ruling sat unaddressed. The gate is the one evaluation already
127
+ * bound to all of those, so asking it about the current state is what makes
128
+ * this reopen when any of them moves.
129
+ *
130
+ * A round that decided `publish` but crashed before the summary landed (a
131
+ * `gh` failure mid-publish) still leaves NO summary comment, so this still
132
+ * reads `null` and no caller mistakes that crash for a completion — the
133
+ * distinction the old log-derived `journal_finalized` deferral drew is
134
+ * unchanged, now with a second condition in front of it. Consumers test this
135
+ * through `isConcludedJournal` below; `'stopped'` is retained in the type
136
+ * for parity with the shape this replaces but is never produced here.
80
137
  */
81
138
  journalFinalized: { result: 'merged_ready' | 'stopped' } | null
82
139
  }
@@ -108,14 +165,53 @@ export function reconstructRounds(input: ReconstructionInput): ReconstructedJour
108
165
  confidence: null,
109
166
  outcome: 'changes_requested'
110
167
  }))
168
+ const concluded = input.summaryPublished && input.reviewGate !== 'fail'
111
169
  return {
112
170
  rounds,
113
171
  totalWallMs: 0,
114
172
  totalFilesChanged: 0,
115
- journalFinalized: input.summaryPublished ? { result: 'merged_ready' } : null
173
+ summaryUrl: input.summaryUrl ?? null,
174
+ reviewGate: input.reviewGate,
175
+ journalFinalized: concluded ? { result: 'merged_ready' } : null
116
176
  }
117
177
  }
118
178
 
179
+ /**
180
+ * The ONE predicate every reader of "is this task's review concluded?" calls
181
+ * — the `--resume` replayed-resolution refusal, the attach's round-history
182
+ * seeding, and the held-clean carry path's "already published?" check alike.
183
+ * A second hand-written `=== 'merged_ready'` test at any of those sites is how
184
+ * they drifted apart before: two of them treated a posted summary as final
185
+ * while the pull request's own gate said otherwise.
186
+ */
187
+ export function isConcludedJournal(journal: ReconstructedJournal): boolean {
188
+ return journal.journalFinalized?.result === 'merged_ready'
189
+ }
190
+
191
+ /**
192
+ * The refusal text for a resume against a genuinely concluded review — `null`
193
+ * when the journal is not concluded, so a caller reads "no refusal owed" from
194
+ * the same call that renders one. Names the round the summary concluded at and
195
+ * where that summary is, rather than the storage layer's own
196
+ * consumed-resolution wording, which describes a mechanism the reader did not
197
+ * ask about and hid the real reason the loop would not continue.
198
+ *
199
+ * Degrades rather than inventing: a journal with no round markers at all (a
200
+ * summary posted on a pull request whose round comments were deleted) names no
201
+ * round, an unresolvable summary url says so, and a gate that could not be
202
+ * evaluated at all is named as such rather than left to read as though the gate
203
+ * had been asked and passed.
204
+ */
205
+ export function concludedLoopRefusal(journal: ReconstructedJournal): string | null {
206
+ if (!isConcludedJournal(journal)) return null
207
+ const newest = journal.rounds[journal.rounds.length - 1]
208
+ const at = newest === undefined ? '' : ` at round ${newest.round}`
209
+ const where =
210
+ journal.summaryUrl === null ? 'summary posted, comment url unavailable' : `summary posted ${journal.summaryUrl}`
211
+ const gateNote = journal.reviewGate === 'unknown' ? '; review gate could not be evaluated' : ''
212
+ return `loop already concluded${at} (${where}${gateNote})`
213
+ }
214
+
119
215
  /** Where a fresh round should start numbering after reconstruction — `1` when there is no prior history at all. */
120
216
  export function nextRoundNumber(rounds: readonly RoundRecord[]): number {
121
217
  if (rounds.length === 0) return 1
@@ -8,15 +8,53 @@
8
8
  import { SUMMARY_TABLE_HEADER } from './journal-reconstruction'
9
9
  import { SEVERITY_COLUMNS, type Confidence, type Journal, type RoundRecord } from './types'
10
10
 
11
+ /**
12
+ * The two non-numeric cells this table writes, named once so the parser below
13
+ * reads the same literals the renderer wrote. They are DIFFERENT facts: the
14
+ * loop never asked this round for a confidence at all (round 1 never is), or
15
+ * it asked and the developer stated nothing readable.
16
+ *
17
+ * `CONFIDENCE_NOT_ASKED_CELL`'s glyph is also the count columns' own
18
+ * "nothing to report" cell (`countCells` below) — one glyph for one meaning
19
+ * across the table, rather than a second literal saying the same thing. Only
20
+ * the confidence column is read back out of a posted table, so the shared
21
+ * glyph never makes a count cell parseable as a confidence.
22
+ */
23
+ export const CONFIDENCE_NOT_ASKED_CELL = '—'
24
+ export const CONFIDENCE_ABSENT_CELL = 'absent'
25
+
26
+ /** The highest percentage this table ever records — the same ceiling `CONFIDENCE_LINE`'s own `0-100` grammar accepts, named here because the parser below refuses a row that exceeds it. */
27
+ export const CONFIDENCE_MAX_PERCENT = 100
28
+
11
29
  function confidenceCell(confidence: Confidence | null): string {
12
- if (confidence === null) return '—'
13
- if (confidence === 'absent') return 'absent'
30
+ if (confidence === null) return CONFIDENCE_NOT_ASKED_CELL
31
+ if (confidence === 'absent') return CONFIDENCE_ABSENT_CELL
14
32
  return `${confidence.value}%`
15
33
  }
16
34
 
35
+ /**
36
+ * One round's count cells — numbers when the loop recorded this round's
37
+ * findings, the not-reported glyph when it never recorded them at all.
38
+ *
39
+ * A round the loop ASSESSED records every severity column, zeros included
40
+ * (`buildRoundRecord`, `assess-round.ts`), so a record carrying none of them
41
+ * is one whose counts have no source: a round rebuilt from the pull request's
42
+ * own round markers after a restart, which name a round's number and head and
43
+ * carry no finding breakdown at all (`journal-reconstruction.ts`). Writing `0`
44
+ * for those cells told a reader the round was clean — four rounds of a real
45
+ * task's published table read as zero findings when the truth was that nobody
46
+ * knew. The distinction is whether the counts were recorded, never whether
47
+ * they are zero: a round the loop assessed and found nothing in still reads
48
+ * `0`, because that zero is a measurement.
49
+ */
50
+ function countCells(record: RoundRecord): string[] {
51
+ const recorded = SEVERITY_COLUMNS.some((key) => record.countsBySeverity[key] !== undefined)
52
+ if (!recorded) return SEVERITY_COLUMNS.map(() => CONFIDENCE_NOT_ASKED_CELL)
53
+ return SEVERITY_COLUMNS.map((key) => String(record.countsBySeverity[key] ?? 0))
54
+ }
55
+
17
56
  function row(record: RoundRecord): string {
18
- const counts = SEVERITY_COLUMNS.map((key) => String(record.countsBySeverity[key] ?? 0))
19
- return `| ${record.round} | ${counts.join(' | ')} | ${confidenceCell(record.confidence)} | ${record.outcome} |`
57
+ return `| ${record.round} | ${countCells(record).join(' | ')} | ${confidenceCell(record.confidence)} | ${record.outcome} |`
20
58
  }
21
59
 
22
60
  export function renderSummary(journal: Journal): string {
@@ -25,3 +63,61 @@ export function renderSummary(journal: Journal): string {
25
63
  const rows = journal.rounds.map(row)
26
64
  return [header, divider, ...rows].join('\n')
27
65
  }
66
+
67
+ /**
68
+ * One round's confidence as this table records it, in three distinguishable
69
+ * states rather than two:
70
+ *
71
+ * - `asked: true` with a `percent` — the developer stated that figure;
72
+ * - `asked: true`, `percent: null` — the round WAS asked and the statement
73
+ * was missing or unreadable (the table's own `absent` cell);
74
+ * - `asked: false`, `percent: null` — the loop never asked this round at all
75
+ * (its `—` cell; round 1 is never asked), so the round has no confidence
76
+ * to report and a reader must not be told the developer skipped one.
77
+ */
78
+ export type SummaryConfidenceRow = { round: number; percent: number | null; asked: boolean }
79
+
80
+ /**
81
+ * The inverse of `row` above — the confidence column read back out of a
82
+ * posted summary table. Kept here, beside the renderer, so the column's
83
+ * position is written down once: a reader elsewhere would have to hand-copy
84
+ * the table's shape and would drift the first time a column moved.
85
+ *
86
+ * Only rows this renderer could have produced are read: a leading round
87
+ * number, then one cell per severity column, then the confidence cell, then
88
+ * the outcome. Anything else in the comment — prose above or below the table,
89
+ * a differently-shaped table — yields no row at all rather than a guess.
90
+ *
91
+ * This function is the boundary between pull-request comment text (which
92
+ * anybody with write access to a fork's branch can shape) and the confidence
93
+ * figure a tool result publishes, so the percentage is bounded HERE: a cell
94
+ * claiming more than `CONFIDENCE_MAX_PERCENT` is dropped rather than carried
95
+ * out of range into a caller that declares `0-100`.
96
+ */
97
+ export function parseSummaryConfidenceRows(body: string): SummaryConfidenceRow[] {
98
+ const cellCount = SEVERITY_COLUMNS.length + 3
99
+ const rows: SummaryConfidenceRow[] = []
100
+ for (const line of body.split('\n')) {
101
+ const trimmed = line.trim()
102
+ if (!trimmed.startsWith('|') || !trimmed.endsWith('|')) continue
103
+ const cells = trimmed.slice(1, -1).split('|')
104
+ if (cells.length !== cellCount) continue
105
+ const round = Number((cells[0] as string).trim())
106
+ if (!Number.isInteger(round) || round <= 0) continue
107
+ const confidenceCellText = (cells[cellCount - 2] as string).trim()
108
+ if (confidenceCellText === CONFIDENCE_NOT_ASKED_CELL) {
109
+ rows.push({ round, percent: null, asked: false })
110
+ continue
111
+ }
112
+ if (confidenceCellText === CONFIDENCE_ABSENT_CELL) {
113
+ rows.push({ round, percent: null, asked: true })
114
+ continue
115
+ }
116
+ const percentMatch = /^(\d{1,3})%$/.exec(confidenceCellText)
117
+ if (!percentMatch) continue
118
+ const percent = Number(percentMatch[1])
119
+ if (percent > CONFIDENCE_MAX_PERCENT) continue
120
+ rows.push({ round, percent, asked: true })
121
+ }
122
+ return rows
123
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The five gate cutovers as data — one Issue/PR number per gate below which
3
+ * that gate is grandfathered (an Issue/PR older than the cutover passes
4
+ * unconditionally). Pure — no `fs`, no `fetch`, no config read: the caller
5
+ * resolves the effective cutovers once (`resolveGateCutovers`,
6
+ * `apps/cli/src/lib/config.ts`, reading `vinaya.config.json`'s optional
7
+ * `gateCutovers` key) and passes them into the pure validators, exactly the
8
+ * seam `ReviewPolicy`/`resolveReviewPolicy` already use for the review
9
+ * thresholds.
10
+ *
11
+ * Each field is `number | null`, and **`null` means NO CUTOVER** — the gate
12
+ * applies to every Issue/PR, from number 1. That is the whole point of moving
13
+ * these numbers out of hardcoded constants and into an optional config key: a
14
+ * repository that declares no `gateCutovers` resolves every field to `null`
15
+ * here (`NO_GATE_CUTOVERS`), so its Issue 1 is held to the same gates a
16
+ * high-numbered Issue is (O1). A repository whose Issues predate a gate — this
17
+ * one — sets the numbers in its own `vinaya.config.json` so its older Issues
18
+ * and pull requests are judged exactly as before (O2). See
19
+ * `packages/sources/src/config-reference.ts`'s `gateCutovers` entry (O3).
20
+ *
21
+ * The built-in constants that were these numbers (`OBJECTIVES_SINCE_ISSUE`
22
+ * etc., still exported from `issue-validation.ts`/`brief-validation.ts`) remain
23
+ * as the DEFAULT parameter value of each pure validator, so a caller that does
24
+ * not resolve config (a test, an authoring path with no repo config in hand)
25
+ * keeps this repository's historical behaviour. Every ENFORCEMENT path resolves
26
+ * config and passes the value explicitly, and an absent key resolves to `null`
27
+ * there — never to the constant — which is what makes O1 hold.
28
+ */
29
+ export type GateCutovers = {
30
+ /** `## Objectives` Issue gate (`checkIssueObjectives`). */
31
+ objectivesSinceIssue: number | null
32
+ /** `## Surface`/`## Parts`/`## Test plan`/`## Stop conditions` Issue gate (`checkIssueBriefSections`). */
33
+ briefSectionsSinceIssue: number | null
34
+ /** `## Documentation` Issue gate, folded into `checkIssueBriefSections`. */
35
+ documentationSinceIssue: number | null
36
+ /** The four brief-shape rules' PR rollout (`partitionBriefErrorsByRollout`). */
37
+ briefRulesSincePr: number | null
38
+ /** The `[agent]`-checkbox refusal's PR rollout (`checkNoAgentBoxes` via the same partition). */
39
+ agentBoxesRefusedSincePr: number | null
40
+ }
41
+
42
+ /** No cutover on any gate — every gate applies from Issue/PR 1. The resolved value for a repository that declares no `gateCutovers` key (O1). */
43
+ export const NO_GATE_CUTOVERS: GateCutovers = {
44
+ objectivesSinceIssue: null,
45
+ briefSectionsSinceIssue: null,
46
+ documentationSinceIssue: null,
47
+ briefRulesSincePr: null,
48
+ agentBoxesRefusedSincePr: null
49
+ }
@@ -23,6 +23,24 @@ export { aggregateTaskTokenRows, parseTokenReportEntries, parseTokensLines } fro
23
23
  export type { TokenSourcePr } from './parse-token-report'
24
24
  export { deriveReviewStatus, parseDeveloperRoundMarker, renderReviewStatus } from './review-status'
25
25
  export type { ReviewStatus, ReviewStatusInput } from './review-status'
26
+ export {
27
+ emptyPhaseSamples,
28
+ isRecordedLoopPhase,
29
+ medianOf,
30
+ MIN_PHASE_HISTORY_SAMPLES,
31
+ phaseHistoryClassFor,
32
+ phaseSamplesFromPrComments,
33
+ summarizePhaseSamples,
34
+ TASK_PHASE_LABELS,
35
+ taskPhaseLabel
36
+ } from './task-phase-history'
37
+ export type {
38
+ HistoryComment,
39
+ PhaseHistoryClass,
40
+ PhaseSamples,
41
+ RecordedLoopPhase,
42
+ TaskPhaseLabel
43
+ } from './task-phase-history'
26
44
  export { formatBreakdown, formatTokenReportRow, formatTokensLine } from './report-tokens'
27
45
  export type { TokenReportRowInput, TokensLineInput, TranscriptSummary, UsageComponents } from './report-tokens'
28
46
  // The Claude Code collection adapter (`tranche-model.md` §12 layer 2) — one
@@ -65,10 +83,12 @@ export {
65
83
  blockingSeverities,
66
84
  CODE_REVIEW_SEVERITY_ORDER,
67
85
  codeReviewBlockingSeverities,
86
+ consequentialFindings,
68
87
  DEFAULT_REVIEW_POLICY,
69
88
  evaluateCodeReview,
70
89
  evaluateReviewFindings,
71
90
  evaluateSecurityReview,
91
+ isConsequentialFinding,
72
92
  isKnownSeverity,
73
93
  isProseLocation,
74
94
  PROSE_CAP_SEVERITY,
@@ -141,6 +161,7 @@ export {
141
161
  resolveNewestFrozenBrief
142
162
  } from './brief-validation'
143
163
  export type {
164
+ BriefRolloutCutovers,
144
165
  BriefSectionResult,
145
166
  BriefSectionsOptions,
146
167
  FencedBlock,
@@ -190,7 +211,12 @@ export {
190
211
  taskRefFromBranch
191
212
  } from './archive-task'
192
213
  export type { MergedPrFacts } from './archive-task'
193
- export { extractCodeReviewVerdict, extractSecurityReviewVerdict, VERDICT_MARKER_SOURCE } from './verdict-extraction'
214
+ export {
215
+ extractCodeReviewVerdict,
216
+ extractSecurityReviewVerdict,
217
+ parseFindingState,
218
+ VERDICT_MARKER_SOURCE
219
+ } from './verdict-extraction'
194
220
  export type { VerdictExtraction } from './verdict-extraction'
195
221
  export {
196
222
  CHANGESET_RELEASE_BRANCH,
@@ -200,7 +226,7 @@ export {
200
226
  isReviewGateExemptBranch
201
227
  } from './review-gate'
202
228
  export type { ReviewGateComment, ReviewGateInput, ReviewGateResult, ReviewGateVerdict } from './review-gate'
203
- export { newestPrincipalRulingAuthor, newestPrincipalRulingOrdinal } from './ruling-ordinal'
229
+ export { newestPrincipalRulingAuthor, newestPrincipalRulingOrdinal, principalRulingMarker } from './ruling-ordinal'
204
230
  export type { RulingComment } from './ruling-ordinal'
205
231
  export {
206
232
  briefHash,
@@ -227,6 +253,7 @@ export {
227
253
  checkConflictCompleteness,
228
254
  checkDocsWithinSurface,
229
255
  checkDocumentationCitesObjective,
256
+ checkEdgeIdsWholeNumbers,
230
257
  checkIssueBriefSections,
231
258
  checkIssueObjectives,
232
259
  checkIssueRationale,
@@ -325,11 +352,14 @@ export {
325
352
  checkUndefinedVocabulary,
326
353
  checkUnresolvableReferences,
327
354
  classifyProseFile,
355
+ DEFAULT_SPEC_PATHS,
328
356
  extractComments,
329
357
  legacySlugPattern,
358
+ normalizeSpecPath,
330
359
  parseGlossaryTerms,
331
360
  PRODUCT_SLUG_SCOPE,
332
- stripNonProse
361
+ stripNonProse,
362
+ TASK_NUMBER_PATTERN
333
363
  } from './reader-resolvable-prose'
334
364
  export type { ProseFileClass, ProseFinding, ProseSourceFile } from './reader-resolvable-prose'
335
365
  export {
@@ -393,6 +423,7 @@ export {
393
423
  OPERATOR_TOOL_GRANT,
394
424
  TASK_CANCEL_TOOL,
395
425
  TASK_ESCALATION_READ_TOOL,
426
+ TASK_PR_READ_TOOL,
396
427
  TASK_RESUME_TOOL,
397
428
  TASK_START_TOOL,
398
429
  TASK_STATUS_TOOL,
@@ -401,6 +432,8 @@ export {
401
432
  TASK_TOOL_NAMES,
402
433
  taskToolByName,
403
434
  taskToolError,
435
+ isTaskNextAction,
436
+ TASK_NEXT_ACTIONS,
404
437
  taskStartRequestIdentity,
405
438
  TaskStartResultSchema,
406
439
  EscalationEvidenceSchema,
@@ -417,10 +450,19 @@ export {
417
450
  TaskEscalationPacketSchema,
418
451
  TaskEscalationReadInputSchema,
419
452
  TaskEscalationReadResultSchema,
453
+ MAX_RETURNED_TEXT_CHARS,
454
+ TaskPrCheckSchema,
455
+ TaskPrPauseSchema,
456
+ TaskPrReadInputSchema,
457
+ TaskPrReadResultSchema,
458
+ TaskPrReviewRecordSchema,
459
+ TaskPrVerdictSchema,
420
460
  TaskToolRefSchema,
421
461
  TaskResumeInputSchema,
422
462
  TaskResumeResultSchema,
423
463
  TaskStartInputSchema,
464
+ TaskConfidenceSchema,
465
+ TaskPhaseHistorySchema,
424
466
  TaskStatusInputSchema,
425
467
  TaskStatusItemSchema,
426
468
  TaskStatusResultSchema,
@@ -429,6 +471,7 @@ export {
429
471
  export type {
430
472
  Freshness,
431
473
  OperatorGrantedTool,
474
+ TaskNextAction,
432
475
  PageRequest,
433
476
  RequestedAuthority,
434
477
  TaskCancelInput,
@@ -437,10 +480,17 @@ export type {
437
480
  TaskEscalationPacket,
438
481
  TaskEscalationReadInput,
439
482
  TaskEscalationReadResult,
483
+ TaskPrCheck,
484
+ TaskPrReadInput,
485
+ TaskPrReadResult,
486
+ TaskPrReviewRecord,
487
+ TaskPrVerdict,
440
488
  TaskResumeInput,
441
489
  TaskResumeResult,
442
490
  TaskStartInput,
443
491
  TaskStartRequestInput,
492
+ TaskConfidence,
493
+ TaskPhaseHistory,
444
494
  TaskStartResult,
445
495
  TaskStatusInput,
446
496
  TaskStatusResult,
@@ -506,7 +556,9 @@ export type {
506
556
  export { findWorkspaceEscapes } from './workspace-escape'
507
557
  export type { WorkspaceEscapeFinding, WorkspaceEscapeReason, WorkspaceEscapeSourceFile } from './workspace-escape'
508
558
  export { extractBoundaryFilePaths, extractSourceRevision, parseRationaleFields, renderBrief } from './brief-render'
509
- export type { BriefFacts, RationaleFieldKey, RenderResult, SurfaceFileFact } from './brief-render'
559
+ export type { BriefFacts, LocalGateCommands, RationaleFieldKey, RenderResult, SurfaceFileFact } from './brief-render'
560
+ export { NO_GATE_CUTOVERS } from './gate-cutovers'
561
+ export type { GateCutovers } from './gate-cutovers'
510
562
  export {
511
563
  hasObjectivesHeading,
512
564
  isIssueNotFoundError,
@@ -519,9 +571,12 @@ export {
519
571
  export type { Objective, ObjectivesSource, ParsedObjectives } from './objectives'
520
572
  export {
521
573
  assessRound,
574
+ concludedLoopRefusal,
522
575
  initialLoopState,
576
+ isConcludedJournal,
523
577
  isPublishedSummaryComment,
524
578
  nextRoundNumber,
579
+ parseSummaryConfidenceRows,
525
580
  reconstructRounds,
526
581
  renderSummary,
527
582
  SUMMARY_TABLE_HEADER
@@ -540,6 +595,7 @@ export type {
540
595
  PendingRound,
541
596
  ReconstructedJournal,
542
597
  ReconstructionInput,
598
+ ReviewGateFact,
543
599
  RoundOutcome,
544
600
  RoundRecord,
545
601
  RoundStats,