@verevoir/review 0.0.0-stage → 0.2.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 (53) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +307 -2
  3. package/dist/index.d.ts +25 -0
  4. package/dist/index.js +28 -0
  5. package/dist/lensSet.d.ts +20 -0
  6. package/dist/lensSet.js +91 -0
  7. package/dist/model.d.ts +2 -0
  8. package/dist/model.js +35 -0
  9. package/dist/panel.d.ts +123 -0
  10. package/dist/panel.js +127 -0
  11. package/dist/parseReply.d.ts +13 -0
  12. package/dist/parseReply.js +218 -0
  13. package/dist/prompt.d.ts +126 -0
  14. package/dist/prompt.js +196 -0
  15. package/dist/raw-call.d.ts +26 -0
  16. package/dist/raw-call.js +11 -0
  17. package/dist/replyContract.d.ts +22 -0
  18. package/dist/replyContract.js +124 -0
  19. package/dist/report.d.ts +15 -0
  20. package/dist/report.js +119 -0
  21. package/dist/review-account.d.ts +6 -0
  22. package/dist/review-account.js +12 -0
  23. package/dist/reviewer-anthropic.d.ts +48 -0
  24. package/dist/reviewer-anthropic.js +174 -0
  25. package/dist/reviewer-claude-cli.d.ts +49 -0
  26. package/dist/reviewer-claude-cli.js +181 -0
  27. package/dist/reviewer-selection.d.ts +41 -0
  28. package/dist/reviewer-selection.js +76 -0
  29. package/dist/run-review.d.ts +48 -0
  30. package/dist/run-review.js +113 -0
  31. package/dist/scope-contradiction.d.ts +22 -0
  32. package/dist/scope-contradiction.js +104 -0
  33. package/dist/verdict.d.ts +96 -0
  34. package/dist/verdict.js +168 -0
  35. package/package.json +49 -4
  36. package/src/index.ts +73 -0
  37. package/src/lensSet.ts +117 -0
  38. package/src/model.ts +35 -0
  39. package/src/panel.ts +251 -0
  40. package/src/parseReply.ts +280 -0
  41. package/src/prompt.ts +314 -0
  42. package/src/raw-call.ts +38 -0
  43. package/src/replyContract.ts +129 -0
  44. package/src/report.ts +162 -0
  45. package/src/review-account.ts +14 -0
  46. package/src/reviewer-anthropic.ts +269 -0
  47. package/src/reviewer-claude-cli.ts +230 -0
  48. package/src/reviewer-selection.ts +110 -0
  49. package/src/run-review.ts +176 -0
  50. package/src/scope-contradiction.ts +125 -0
  51. package/src/verdict.ts +265 -0
  52. package/tsconfig.build.json +16 -0
  53. package/tsconfig.json +16 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,308 @@
1
- # Temporary Holding Version
1
+ # @verevoir/review
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The review panel: lens-based diff review, fanned out across every declared
4
+ lens with a shared cached prefix, aggregated into one verdict with a
5
+ fail-closed outcome rule. One implementation, consumed by pump-internal
6
+ review, the local preflight gate, eval-review, and CI -- rather than four
7
+ independent reviewers drifting apart.
8
+
9
+ ## Status: PR 1 (the seed)
10
+
11
+ This is a **behaviour-preserving move** of aigency-runtime-v2's reviewer
12
+ (`src/review-node.ts` + `src/review/*.ts`) into this standalone library,
13
+ as-is: same exported names (`runReviewNode`, `ReviewNodeInput`,
14
+ `ReviewNodeResult`), same logic, same fail-closed rules. Import paths were
15
+ flattened (no `src/review/` subdirectory -- this package has nothing to
16
+ separate the reviewer from), and two v5-only imports were replaced with
17
+ small library-owned shims (`model.ts`, `raw-call.ts`) -- see each file's
18
+ own header, and the seed commit message, for exactly what moved and why.
19
+
20
+ **Known gaps in this PR**, named rather than silently absorbed:
21
+
22
+ - No CLI bin yet (no consumer needs it until the preflight/eval-review/CI
23
+ Action cutover PRs).
24
+
25
+ All nine of v5's review test suites are ported (see "Tests" below, not
26
+ two), and the ported-file doc debt (stale README/ownership references) is
27
+ fixed as of this commit.
28
+
29
+ ## Roadmap (confirmed sequence)
30
+
31
+ 1. **This PR** -- the seed. No ratchet run is needed for this PR itself:
32
+ it is a mechanical, behaviour-preserving move, proven by v5's own nine
33
+ test suites passing unchanged against the moved code (see "Tests"
34
+ below). The ratchet equivalence check (detection + agreement, same
35
+ harness and fixtures, v5's ports vs. this library) is the acceptance
36
+ test of the CONSUMER CUTOVER PR in runtime-v2 instead: run `eval-review`
37
+ on `main` (v5's ports), cut over to `@verevoir/review`, run
38
+ `eval-review` again on the cutover branch, and record both runs'
39
+ numbers in that PR's body.
40
+ 2. The change-context assembler (tree-sitter via `@verevoir/context`),
41
+ with the two-channel API (`guardrails` vs `subjectContext`).
42
+ 3. Diff anchors (every finding must cite a diff hunk) and the
43
+ `PRE_EXISTING` channel.
44
+ 4. Relational finding kinds (`breaks` / `duplicates` / `deviates`).
45
+ 5. Bounded read-only tools (`find_symbol`/`read_range`/`find_references`/
46
+ `list`), behind a flag, off by default until the ratchet measures
47
+ tools-on vs tools-off.
48
+
49
+ Each of 2-5 lands as its own PR, measured with the ratchet before vs
50
+ after, numbers recorded in that PR's body.
51
+
52
+ ## Tests
53
+
54
+ All nine of v5's review test suites, ported verbatim (import paths only
55
+ adjusted for this package's flat layout):
56
+
57
+ | Suite | Cases |
58
+ | ------------------------------------ | ------ |
59
+ | `review-conformance.test.ts` | 14 |
60
+ | `review-node-planted-defect.test.ts` | 1 |
61
+ | `reviewer-selection.test.ts` | 10 |
62
+ | `review-scope-contradiction.test.ts` | 9 |
63
+ | `reviewer-anthropic.test.ts` | 15 |
64
+ | `reviewer-claude-cli.test.ts` | 18 |
65
+ | `review-prompt-requirement.test.ts` | 7 |
66
+ | `verdict-precedence-bl144.test.ts` | 4 |
67
+ | `review-shared-prefix.test.ts` | 7 |
68
+ | `model-resolution-real.test.ts` | 4 |
69
+ | **Total** | **89** |
70
+
71
+ These passing unchanged against the moved code is the proof that this
72
+ extraction changed nothing -- not a separate acceptance step.
73
+ `model-resolution-real.test.ts` is the one exception: it is NEW, added
74
+ after the seed, to close a governance finding -- see "Dependency surface"
75
+ below and `src/model.ts`'s own header.
76
+
77
+ ## Dependency surface
78
+
79
+ `@verevoir/llm` plus `@anthropic-ai/sdk`, plus node built-ins. Enforced by
80
+ `scripts/check-deps.mjs`, run in CI on every PR. Any addition needs a
81
+ justification paragraph in that PR's description.
82
+
83
+ `@anthropic-ai/sdk` was added after the seed: `@verevoir/llm`'s own
84
+ MODEL_CATALOG starts empty and is populated only as the import side
85
+ effect of its `./anthropic` subpath -- without importing it, this
86
+ library's `resolvedModelId('opus')` silently returned the bare, unresolved
87
+ alias instead of the catalog's current id, a governance finding fixed in
88
+ `src/model.ts`. That subpath imports `@anthropic-ai/sdk` at module scope,
89
+ and `@verevoir/llm` declares it only as an optional peer -- npm does not
90
+ install an optional peer automatically, so it is declared here directly.
91
+ Proven by `tests/model-resolution-real.test.ts`, the one test in this
92
+ suite that mocks nothing.
93
+
94
+ ## Claude CLI reviewer: idle timeout
95
+
96
+ `reviewer-claude-cli.ts`'s `chat()` call carries `@verevoir/llm` 0.35.0's
97
+ idle-output timeout (`ClaudeCliChatOptions.idleTimeoutMs`): an explicit
98
+ `ClaudeCliReviewerOptions.idleTimeoutMs` on this reviewer wins when set;
99
+ otherwise llm's own `CLAUDE_CLI_IDLE_TIMEOUT_MS` env var and its built-in
100
+ default apply. A `claude -p` child killed for going idle is reported as
101
+ that lens's own named `could_not_run` outcome -- never an approval, and
102
+ never folded into a generic failure.
103
+
104
+ ## Consuming this library
105
+
106
+ This is a **private** repository, consumed as a pinned git dependency --
107
+ never via npm's registry, and never floating on a branch or tag.
108
+
109
+ 1. **Pin the full commit sha**, in `git+https://` form, never the
110
+ `github:owner/repo#sha` shorthand (npm's resolution of that
111
+ shorthand's own transport -- ssh vs https -- isn't guaranteed, and
112
+ the CI step below only works if npm goes over https):
113
+
114
+ ```json
115
+ "@verevoir/review": "git+https://github.com/verevoir/review.git#<full-sha>"
116
+ ```
117
+
118
+ A branch or tag is never acceptable here: this repo merges on green
119
+ (see "Merge policy" below), with no human gate between a PR and
120
+ `main` moving -- a consumer floating on `main` would pick up a change
121
+ with no review of its own on this side of the boundary. Pin the exact
122
+ sha you have actually run the ratchet against (or, for a mechanical
123
+ bump with no behaviour change, the exact sha you have confirmed
124
+ carries one).
125
+
126
+ 2. **Add `REVIEW_READ_TOKEN` as a repository secret** in the consumer's
127
+ own CI -- a fine-grained PAT scoped to `contents: read` on
128
+ `verevoir/review` ONLY. This repository is private, and a consumer's
129
+ ambient `GITHUB_TOKEN` cannot see a different private repository.
130
+ `REVIEW_READ_TOKEN` is the operator's standing secret name for every
131
+ consumer of this library -- used for nothing else, so it can stay
132
+ scoped this narrowly without colliding with any other credential a
133
+ consumer's CI might hold.
134
+
135
+ 3. **Before `npm ci` (or equivalent), rewrite git URLs for this
136
+ dependency's exact URL only** -- never every `https://github.com/`
137
+ URL -- then run the install with NO lifecycle scripts, remove the
138
+ rewrite immediately, and only then run the scripts that were skipped:
139
+
140
+ ```yaml
141
+ - run: |
142
+ if [ -z "${{ secrets.REVIEW_READ_TOKEN }}" ]; then
143
+ echo "::error::REVIEW_READ_TOKEN is not set (or is blank) -- required to install the private @verevoir/review git dependency over https."
144
+ exit 1
145
+ fi
146
+ - run: git config --global url."https://x-access-token:${{ secrets.REVIEW_READ_TOKEN }}@github.com/verevoir/review.git".insteadOf "https://github.com/verevoir/review.git"
147
+ - run: npm ci --ignore-scripts
148
+ - run: git config --global --unset url."https://x-access-token:${{ secrets.REVIEW_READ_TOKEN }}@github.com/verevoir/review.git".insteadOf
149
+ if: always()
150
+ - run: npm rebuild
151
+ - run: npm run build --prefix node_modules/@verevoir/review
152
+ ```
153
+
154
+ **Why `--ignore-scripts` plus the two steps after, not just the scoped
155
+ rewrite and an unset** -- an earlier version of this guidance claimed
156
+ scoping the rewrite to one URL meant the token was never exposed to
157
+ "any other dependency's install script". That was wrong, caught by a
158
+ lens-review round on a real consumer's cutover branch, scored
159
+ blocking: URL scoping only limits which git operations the rewrite
160
+ applies to. It does nothing to stop a DIFFERENT package's own
161
+ install/postinstall script from reading `~/.gitconfig` directly, as a
162
+ file -- any process in the job can do that regardless of which URL
163
+ the rewrite names. `--ignore-scripts` is what actually closes this:
164
+ no package's lifecycle script runs while the token is present. The
165
+ rewrite is then unset (`if: always()`, so a failed `npm ci` does not
166
+ leave it behind either), and only then do the deferred scripts run --
167
+ `npm rebuild` for every other dependency's own install/postinstall
168
+ (native modules among them, if your consumer has any), and an
169
+ explicit build of **this package's own** `dist/` specifically,
170
+ because it is gitignored here and normally produced by this
171
+ package's `prepare` script -- which `--ignore-scripts` also skipped,
172
+ and which `npm rebuild` does not run (rebuild covers preinstall/
173
+ install/postinstall only, never prepare).
174
+
175
+ **The precise claim this now supports**: the token exists in
176
+ `~/.gitconfig` only across the url.insteadOf write and
177
+ `npm ci --ignore-scripts` itself -- an install that runs no package
178
+ script. Nothing after that point can read it. The one residual,
179
+ accepted exposure is whatever npm does internally to fetch the git
180
+ dependency during that one command -- unavoidable, since that is the
181
+ minimum npm needs to resolve a private git dependency at all.
182
+
183
+ Run this on every CI leg/matrix entry that installs dependencies -- a
184
+ leg that skips it fails `npm ci` outright and loudly (a missing
185
+ credential), never silently.
186
+
187
+ This is the exact mechanism in place on `aigency-runtime-v2`'s own
188
+ `verify.yml`, on its consumer-cutover branch (held for operator review,
189
+ per that repository's own protected-paths rule).
190
+
191
+ ## Round-aware review (opt-in)
192
+
193
+ A stateless reviewer re-reviews the whole cumulative diff every round with
194
+ no memory of what it found last time, and that can lose a real finding: a
195
+ finding round 1 raised can simply go unmentioned in round 2's reply and
196
+ vanish, unresolved, with nobody having ruled on it. Round-aware review
197
+ fixes this without changing anything for a caller that does not ask for
198
+ it.
199
+
200
+ **Opt in** by setting `Subject.priorFindings` -- absent, or an empty
201
+ array, is "no prior round" and this library behaves exactly as it always
202
+ has; every prompt it builds and every reply it parses is byte-identical
203
+ to before this feature existed (pinned in
204
+ `tests/review-round-aware.test.ts`, which independently reconstructs the
205
+ pre-feature `buildPrompt` template and asserts equality against it).
206
+
207
+ ```ts
208
+ interface PriorFinding {
209
+ id: string;
210
+ lens: string;
211
+ severity: 'blocking'; // only a blocking finding is worth carrying forward
212
+ summary: string;
213
+ round: number;
214
+ }
215
+
216
+ interface Subject {
217
+ // ...title, description, diff, citedContext, requirement, as before...
218
+ priorFindings?: ReadonlyArray<PriorFinding>;
219
+ }
220
+ ```
221
+
222
+ **What a lens is shown.** When `priorFindings` is non-empty, every lens's
223
+ prompt gains a `## Prior round` section in its own `perLens` half (never
224
+ in the shared, cached prefix -- which findings a lens rules on differs by
225
+ lens, so it cannot live in the block that must stay byte-identical across
226
+ all of them), split into two clearly separated parts:
227
+
228
+ - **Part A -- rule on each prior blocking finding for this lens.** Only
229
+ the findings whose own `lens` field names this lens are listed. The
230
+ lens is asked to judge each one against the **current** diff -- never
231
+ against whether it was ever a valid finding -- and answer with
232
+ `RULING: <id> resolved -- <reason>` or
233
+ `RULING: <id> unresolved -- <reason>`.
234
+ - **Part B -- independent review.** The lens reviews the change as it
235
+ would today, in full. New blocking findings are explicitly allowed
236
+ anywhere a real defect exists -- Part A is never phrased as a ceiling on
237
+ what else may be reported, and the prompt says plainly that a real
238
+ defect must never be suppressed to avoid reopening old ground. For every
239
+ new blocking finding, the lens is asked to say whether it sits in code
240
+ changed since the prior round, is a regression, or -- if neither -- why
241
+ it wasn't raised in the prior round. This is anchoring protection, not
242
+ suppression: it exists to stop the SAME old findings being the only
243
+ thing found round after round, never to cap what a lens may raise.
244
+
245
+ **The verdict gains `priorRulings`**, per lens:
246
+
247
+ ```ts
248
+ interface PriorRuling {
249
+ priorId: string;
250
+ ruling: 'resolved' | 'unresolved';
251
+ reason: string;
252
+ }
253
+
254
+ interface Verdict {
255
+ // ...outcome, results, findings, unran, outOfScope, as before...
256
+ priorRulings?: ReadonlyArray<{ lens: string; rulings: ReadonlyArray<PriorRuling> }>;
257
+ }
258
+ ```
259
+
260
+ `priorRulings` is **optional, never `[]`**: it is a new field on an
261
+ already-exported interface, so a `Verdict` literal a consumer already
262
+ builds by hand (a test fake, a fixture) must keep compiling against a new
263
+ version of this library without it. `aggregate` omits the field entirely
264
+ -- never sets it to an empty array -- whenever nothing round-aware
265
+ happened in this run; it is present only when at least one lens actually
266
+ carried a ruling.
267
+
268
+ **The outcome rules:**
269
+
270
+ - Any prior blocking finding ruled `unresolved` sinks the verdict to
271
+ `rejected` -- it stays blocking, exactly as a brand-new blocking finding
272
+ would.
273
+ - A prior finding the reply never mentions at all is treated as
274
+ `unresolved` and named `'no ruling returned'` -- fail-safe, never
275
+ silently dropped the way a stateless re-review could lose it.
276
+ - All prior findings resolved, and no new blocking finding anywhere in
277
+ the panel, is `approved`.
278
+ - A malformed `RULING:` line -- the wrong shape, a ruling for an id this
279
+ lens was never asked about, two rulings for the same id -- makes that
280
+ lens's own result `could_not_run`, the same fail-closed treatment every
281
+ other unreadable reply gets in this library.
282
+ - A lens whose own reply is unreadable at the base level (empty, no
283
+ `VERDICT:` line, two of them) never gets a prior ruling attached at
284
+ all, even if it was owed one -- that lens's result stays `could_not_run`
285
+ (an unran lens), never a substantiated rejection manufactured out of
286
+ its silence.
287
+ - A prior finding whose own `lens` field names a lens that is not on the
288
+ panel at all (a stale or mistyped id, or a lens dropped between rounds)
289
+ is folded in as unresolved and named `'lens not on panel'` -- it can
290
+ never simply vanish just because no lens was ever asked to rule on it.
291
+ - The `RULING:` separator accepts an em dash (`—`) or en dash (`–`) as
292
+ well as the literal `--` the prompt itself always demonstrates, in case
293
+ a model's own formatting substitutes one.
294
+
295
+ **Who sets this.** This library only reads `priorFindings`; nothing here
296
+ computes it. A caller carrying its own round history (e.g.
297
+ aigency-runtime-v2, from round 2 of an implement↔review loop onward) is
298
+ responsible for assembling the array from its own prior verdict's
299
+ blocking findings before calling `runPanel`/`runReviewNode` again.
300
+
301
+ ## Merge policy
302
+
303
+ Merges on green, same as this organisation's other rebuild repos. "Green"
304
+ here means: typecheck, lint, the deterministic test suite, and the
305
+ forbidden-deps guard. The model-call ratchet (detection rate per sensor,
306
+ agreement) cannot run in CI -- it needs real model calls -- and runs
307
+ locally, on the operator's subscription, via the eval harness; its
308
+ results belong in the PR body of any PR touching review _behaviour_.
@@ -0,0 +1,25 @@
1
+ export type { Lens, LensSet } from './lensSet.js';
2
+ export { LensSetError, SUPPORTED_VERSION, parseLensSet } from './lensSet.js';
3
+ export type { Prompt, PriorFinding, Subject } from './prompt.js';
4
+ export { buildPrompt, renderPrompt, NO_PRACTICES_NOTICE, NO_REQUIREMENT_NOTICE, PRIOR_FINDINGS_HEADING, NO_PRIOR_FINDINGS_FOR_LENS_NOTICE, } from './prompt.js';
5
+ export * from './replyContract.js';
6
+ export type { Reviewer, ReviewerReply, ReviewerUsage, PanelRun, Practices } from './panel.js';
7
+ export { IdleTimeoutError, NoRoomToAnswerError, normaliseReviewerReply, runPanel, } from './panel.js';
8
+ export { parseReply } from './parseReply.js';
9
+ export type { Outcome, Finding, LensResult, PriorRuling, Verdict } from './verdict.js';
10
+ export { PanelMismatchError, aggregate } from './verdict.js';
11
+ export type { ReportContext } from './report.js';
12
+ export { renderReport, exitCodeFor } from './report.js';
13
+ export type { ReviewAccount } from './review-account.js';
14
+ export type { HttpPost, AnthropicReviewerConfig } from './reviewer-anthropic.js';
15
+ export { anthropicReviewer, redact } from './reviewer-anthropic.js';
16
+ export type { ClaudeCliReviewerOptions } from './reviewer-claude-cli.js';
17
+ export { claudeCliReviewer, augmentBareExit } from './reviewer-claude-cli.js';
18
+ export type { ReviewRoute, ReviewRouteRunners, SelectReviewerOptions, } from './reviewer-selection.js';
19
+ export { decideReviewRoute, selectForRoute, selectReviewer } from './reviewer-selection.js';
20
+ export { isScopeContradiction, reclassifyScopeContradictions, reconcileScopeContradictions, } from './scope-contradiction.js';
21
+ export { resolvedModelId } from './model.js';
22
+ export type { RawCall, RawCallFailure } from './raw-call.js';
23
+ export { describeThrown } from './raw-call.js';
24
+ export type { ReviewNodeInput, ReviewNodeResult, ReviewSubject } from './run-review.js';
25
+ export { runReviewNode } from './run-review.js';
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ // @verevoir/review -- public entry point.
2
+ //
3
+ // PR 1 (the seed) is a behaviour-preserving move of aigency-runtime-v2's
4
+ // reviewer into its own library, verbatim bar import-path changes (see
5
+ // each file's own header) and two small shims (model.ts, raw-call.ts)
6
+ // that replace imports of v5-only modules this library does not carry.
7
+ // The public API below is UNCHANGED from v5's own shape; the two-channel
8
+ // API, anchors, PRE_EXISTING, relational kinds and bounded tools are
9
+ // later PRs (2 through 5), not this one -- see README.md's roadmap.
10
+ //
11
+ // Round-aware review (opt-in, additive) adds `Subject.priorFindings`,
12
+ // `PriorFinding`, `PriorRuling`, `Verdict.priorRulings` and the
13
+ // `RULING_*` reply-contract constants below -- every one of them new,
14
+ // none of them replacing or renaming anything this file already exported.
15
+ export { LensSetError, SUPPORTED_VERSION, parseLensSet } from './lensSet.js';
16
+ export { buildPrompt, renderPrompt, NO_PRACTICES_NOTICE, NO_REQUIREMENT_NOTICE, PRIOR_FINDINGS_HEADING, NO_PRIOR_FINDINGS_FOR_LENS_NOTICE, } from './prompt.js';
17
+ export * from './replyContract.js';
18
+ export { IdleTimeoutError, NoRoomToAnswerError, normaliseReviewerReply, runPanel, } from './panel.js';
19
+ export { parseReply } from './parseReply.js';
20
+ export { PanelMismatchError, aggregate } from './verdict.js';
21
+ export { renderReport, exitCodeFor } from './report.js';
22
+ export { anthropicReviewer, redact } from './reviewer-anthropic.js';
23
+ export { claudeCliReviewer, augmentBareExit } from './reviewer-claude-cli.js';
24
+ export { decideReviewRoute, selectForRoute, selectReviewer } from './reviewer-selection.js';
25
+ export { isScopeContradiction, reclassifyScopeContradictions, reconcileScopeContradictions, } from './scope-contradiction.js';
26
+ export { resolvedModelId } from './model.js';
27
+ export { describeThrown } from './raw-call.js';
28
+ export { runReviewNode } from './run-review.js';
@@ -0,0 +1,20 @@
1
+ export interface Lens {
2
+ readonly id: string;
3
+ readonly title: string;
4
+ readonly focus: string;
5
+ }
6
+ export interface LensSet {
7
+ readonly version: number;
8
+ readonly lenses: readonly Lens[];
9
+ }
10
+ /** Thrown for any definition that cannot be trusted to describe a panel. */
11
+ export declare class LensSetError extends Error {
12
+ readonly name = "LensSetError";
13
+ }
14
+ export declare const SUPPORTED_VERSION = 1;
15
+ /**
16
+ * Parse and validate a lens set. Malformed input is refused, never read as
17
+ * declaring no lenses — the two look identical downstream and only one of them
18
+ * is safe.
19
+ */
20
+ export declare function parseLensSet(text: string): LensSet;