@verevoir/review 0.0.0-stage → 0.3.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.
- package/LICENSE +201 -0
- package/README.md +437 -2
- package/dist/cli/bin.d.ts +2 -0
- package/dist/cli/bin.js +46 -0
- package/dist/cli/footer.d.ts +9 -0
- package/dist/cli/footer.js +59 -0
- package/dist/cli/review.d.ts +45 -0
- package/dist/cli/review.js +507 -0
- package/dist/context-assembler.d.ts +9 -0
- package/dist/context-assembler.js +118 -0
- package/dist/context-files.d.ts +33 -0
- package/dist/context-files.js +174 -0
- package/dist/context-types.d.ts +28 -0
- package/dist/context-types.js +5 -0
- package/dist/dedup.d.ts +40 -0
- package/dist/dedup.js +151 -0
- package/dist/diff-hunks.d.ts +17 -0
- package/dist/diff-hunks.js +73 -0
- package/dist/fs-source-access.d.ts +7 -0
- package/dist/fs-source-access.js +39 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +28 -0
- package/dist/lensSet.d.ts +20 -0
- package/dist/lensSet.js +91 -0
- package/dist/model.d.ts +2 -0
- package/dist/model.js +35 -0
- package/dist/panel.d.ts +123 -0
- package/dist/panel.js +127 -0
- package/dist/parseReply.d.ts +13 -0
- package/dist/parseReply.js +269 -0
- package/dist/practice-lenses.d.ts +69 -0
- package/dist/practice-lenses.js +218 -0
- package/dist/prompt.d.ts +149 -0
- package/dist/prompt.js +214 -0
- package/dist/raw-call.d.ts +26 -0
- package/dist/raw-call.js +11 -0
- package/dist/references.d.ts +44 -0
- package/dist/references.js +312 -0
- package/dist/replyContract.d.ts +22 -0
- package/dist/replyContract.js +124 -0
- package/dist/report.d.ts +31 -0
- package/dist/report.js +172 -0
- package/dist/review-account.d.ts +6 -0
- package/dist/review-account.js +12 -0
- package/dist/reviewer-anthropic.d.ts +48 -0
- package/dist/reviewer-anthropic.js +174 -0
- package/dist/reviewer-claude-cli.d.ts +49 -0
- package/dist/reviewer-claude-cli.js +181 -0
- package/dist/reviewer-selection.d.ts +41 -0
- package/dist/reviewer-selection.js +76 -0
- package/dist/run-review.d.ts +64 -0
- package/dist/run-review.js +148 -0
- package/dist/scope-contradiction.d.ts +22 -0
- package/dist/scope-contradiction.js +104 -0
- package/dist/source-access.d.ts +8 -0
- package/dist/source-access.js +1 -0
- package/dist/subject-context-render.d.ts +8 -0
- package/dist/subject-context-render.js +29 -0
- package/dist/tier.d.ts +20 -0
- package/dist/tier.js +88 -0
- package/dist/verdict.d.ts +96 -0
- package/dist/verdict.js +168 -0
- package/dist/warm-first.d.ts +2 -0
- package/dist/warm-first.js +21 -0
- package/lenses.default.json +30 -0
- package/package.json +53 -4
- package/src/cli/bin.ts +61 -0
- package/src/cli/footer.ts +78 -0
- package/src/cli/review.ts +647 -0
- package/src/context-files.ts +194 -0
- package/src/dedup.ts +187 -0
- package/src/index.ts +73 -0
- package/src/lensSet.ts +117 -0
- package/src/model.ts +35 -0
- package/src/panel.ts +251 -0
- package/src/parseReply.ts +331 -0
- package/src/practice-lenses.ts +265 -0
- package/src/prompt.ts +358 -0
- package/src/raw-call.ts +38 -0
- package/src/references.ts +381 -0
- package/src/replyContract.ts +129 -0
- package/src/report.ts +230 -0
- package/src/review-account.ts +14 -0
- package/src/reviewer-anthropic.ts +269 -0
- package/src/reviewer-claude-cli.ts +230 -0
- package/src/reviewer-selection.ts +110 -0
- package/src/run-review.ts +224 -0
- package/src/scope-contradiction.ts +125 -0
- package/src/tier.ts +103 -0
- package/src/verdict.ts +265 -0
- package/src/warm-first.ts +27 -0
- package/tsconfig.build.json +16 -0
- 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,438 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @verevoir/review
|
|
2
2
|
|
|
3
|
-
|
|
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
|
+
- The CLI (`aigency-review`, below) is a port of governance's; see "Command
|
|
23
|
+
line" for what was deliberately not ported.
|
|
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
|
+
## Command line
|
|
302
|
+
|
|
303
|
+
`aigency-review` runs the panel over a diff from any repository, including a
|
|
304
|
+
public one that cannot call governance's private reusable workflow:
|
|
305
|
+
|
|
306
|
+
```sh
|
|
307
|
+
npx -y @verevoir/review aigency-review --base origin/main --title "My change"
|
|
308
|
+
git diff origin/main...HEAD | npx -y @verevoir/review aigency-review
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
**Flags**
|
|
312
|
+
|
|
313
|
+
- `--base <ref>` -- review `git diff --merge-base <ref> HEAD` (run via
|
|
314
|
+
`execFile`, no shell). Needs full history. Without it, the diff is read from
|
|
315
|
+
stdin.
|
|
316
|
+
- `--title <text>` -- shown at the top of the report (default `this change`).
|
|
317
|
+
- `--lenses <path>` -- a lens set JSON file. Else `AIGENCY_REVIEW_LENSES`, else
|
|
318
|
+
the bundled default.
|
|
319
|
+
- `--description-file <path>` -- the PR description, shown under `## The change`.
|
|
320
|
+
Unreadable or blank is `could_not_run`. Without it the prompt says, in one
|
|
321
|
+
line, that no description was supplied and not to judge it.
|
|
322
|
+
- `--checks-file <path>` -- CI check results, rendered verbatim in the shared prompt under
|
|
323
|
+
`## Checks on this change` (after `## The change`, before `## The diff`). Unreadable or
|
|
324
|
+
blank is `could_not_run`. Without it the prompt says, in one line, that no check results
|
|
325
|
+
were supplied and not to assume the tests pass.
|
|
326
|
+
- References in added lines (automatic with a context root) -- ADR citations (`ADR 009`,
|
|
327
|
+
`ADR-009`, `ADR 9`) and repo-relative file paths in the diff's ADDED lines are resolved
|
|
328
|
+
deterministically (no model call) and rendered under `## References in added lines`, after
|
|
329
|
+
`## Changed files in full`. An ADR is looked up in directories named `adrs` or `adr` (depth
|
|
330
|
+
4, skipping `node_modules`, `.git`, `dist`) and shown with its path and first heading, or
|
|
331
|
+
"not found in this repository"; a path is reported as existing or not. At most 40 are
|
|
332
|
+
resolved. `..`, absolute paths and root-escaping symlinks are refused.
|
|
333
|
+
- With `--practices`, every lens also gets a tier anchor (tag `[blocking]` only when quoting
|
|
334
|
+
the signal failed) and is asked for a `REASON:` line; the report shows every lens as
|
|
335
|
+
`#### <lens>: <verdict>: <reason>`, approving lenses included.
|
|
336
|
+
- With `--practices`, the tier is enforced in code. After each lens's reply is parsed, every
|
|
337
|
+
`[blocking]` finding must contain a verbatim quote of one of THAT lens's practices'
|
|
338
|
+
`_Reject:_` / `_Expect:_` lines: after lower-casing and removing markdown emphasis, quote
|
|
339
|
+
marks and extra whitespace on both sides, a contiguous run of at least 24 characters of the
|
|
340
|
+
signal line (or all of a shorter line). Otherwise it becomes `[smell]` with
|
|
341
|
+
" (downgraded: no signal quoted)", and a lens left with no blocking finding counts as
|
|
342
|
+
approved. Bundled lenses are unchanged.
|
|
343
|
+
- De-duplication: after the panel, ONE extra call through the same reviewer asks which findings
|
|
344
|
+
(ids `lens:index`) describe the same defect. The reply must put every id in exactly one
|
|
345
|
+
group; otherwise (or if the call fails) the un-merged report is kept with a line saying
|
|
346
|
+
de-duplication was skipped and why. Each group is shown once, at its highest tier, with its
|
|
347
|
+
first member's text and `raised by: <lens> (<practices>), ...`. Per-lens verdict lines are
|
|
348
|
+
unchanged, and the call's usage appears in the footer as `dedup`. `--no-dedup` skips it. It is
|
|
349
|
+
also skipped when fewer than two findings were raised.
|
|
350
|
+
- With `--checks-file`, the checks section ends with: "If a check fails, report it once, then
|
|
351
|
+
review the rest of the change on its own merits, as if that failure were fixed."
|
|
352
|
+
- `--warm-first` / `--no-warm-first` -- run the first lens alone, then fan out
|
|
353
|
+
the rest, so they read the prompt cache the first wrote instead of every lens
|
|
354
|
+
writing the same prefix. On by default with 2 or more lenses; costs roughly one
|
|
355
|
+
extra lens-latency of wall time. A first lens that fails does not stop the rest.
|
|
356
|
+
- `--context-root <dir>` -- a tree at the change's head. Each file the diff
|
|
357
|
+
touches (paths from the `+++` headers) that still exists there is shown in
|
|
358
|
+
full, post-change, if it is 16 KB or smaller, in a shared
|
|
359
|
+
`## Changed files in full` section after `## The diff`; skipped files are listed with the reason
|
|
360
|
+
(too large, deleted, not present, binary). Paths with `..` or absolute paths
|
|
361
|
+
are refused, and so is any file whose resolved real path (symlinks followed)
|
|
362
|
+
leaves the root. With `--base` it defaults to the current directory (run from
|
|
363
|
+
the repo root); with stdin and no `--context-root` the prompt says in one line
|
|
364
|
+
that there is no file context.
|
|
365
|
+
- `-h`, `--help`.
|
|
366
|
+
|
|
367
|
+
**Environment**
|
|
368
|
+
|
|
369
|
+
- `ANTHROPIC_API_KEY` -- billed route. Else `ANTHROPIC_API_KEY_FILE`, else
|
|
370
|
+
`$XDG_CONFIG_HOME/verevoir/anthropic.key` (or `~/.config/verevoir/anthropic.key`).
|
|
371
|
+
With no key anywhere the logged-in `claude` CLI is used. A key file that is
|
|
372
|
+
unreadable or blank, or a named `ANTHROPIC_API_KEY_FILE` that does not exist,
|
|
373
|
+
blocks the run rather than silently falling back.
|
|
374
|
+
- `AIGENCY_REVIEW_LENSES` -- lens set path (see above).
|
|
375
|
+
- `AIGENCY_REVIEW_MODEL` -- default `claude-opus-5-5`.
|
|
376
|
+
- `AIGENCY_REVIEW_MAX_TOKENS` -- positive integer, default `65536`.
|
|
377
|
+
- `GITHUB_STEP_SUMMARY` -- when set, the report is appended to that file.
|
|
378
|
+
|
|
379
|
+
**Report footer.** The report ends with what judged it: the model (the id the
|
|
380
|
+
transport reported, else the requested one, said as such), the reviewer route by
|
|
381
|
+
name only (`env`, `key-file` or `claude-cli` -- never a key or a path), and one
|
|
382
|
+
per-lens line with input/output tokens (and cache tokens when non-zero) and wall
|
|
383
|
+
time. The same per-lens lines go to stderr. A route that reports no usage says
|
|
384
|
+
`usage not reported`.
|
|
385
|
+
|
|
386
|
+
**Output.** The markdown report goes to stdout; `RESULT: approved|out_of_scope|rejected|could_not_run`
|
|
387
|
+
goes to stderr.
|
|
388
|
+
|
|
389
|
+
**Exit codes** (from `exitCodeFor`, as in governance): `approved` and
|
|
390
|
+
`out_of_scope` exit `0`; `rejected` and `could_not_run` exit `1`. Anything
|
|
391
|
+
that stops a verdict (bad config, no diff, empty diff, unreadable lens set, a
|
|
392
|
+
bad flag) is `could_not_run`: red, never a pass.
|
|
393
|
+
|
|
394
|
+
**Bundled lenses.** `lenses.default.json` is a copy of
|
|
395
|
+
`verevoir/aigency-governance` `review/lenses.json` at commit `de238aa`. It is a
|
|
396
|
+
snapshot, refreshed deliberately.
|
|
397
|
+
|
|
398
|
+
**Not ported from governance's CLI**: fetching the lens set over HTTP
|
|
399
|
+
(`AIGENCY_REVIEW_LENSES_TOKEN`/`GITHUB_TOKEN`; paths only here), the
|
|
400
|
+
cited-file context built from the checkout (`citations`/`readers`), and
|
|
401
|
+
governance's `practices` fetch. The title is `--title`, not `argv[2]`.
|
|
402
|
+
|
|
403
|
+
**Derived lenses (trial, BL-424).** `--practices <dir>` reads the `*.md`
|
|
404
|
+
files directly under `<dir>` (a guardrails checkout's `corpus/practices`),
|
|
405
|
+
groups them by their front-matter `lens:` value, and makes one lens per value
|
|
406
|
+
(id and title are the value; focus is a fixed adversarial sentence plus the
|
|
407
|
+
group's `**Sensor**` / `**Look for**` text). Practices with no `lens:` are
|
|
408
|
+
warned about on stderr, reviewed by nothing, and counted in the report. A
|
|
409
|
+
tagged practice with no sensor text is `could_not_run`. It cannot be combined
|
|
410
|
+
with `--lenses`. `--print-lenses` (needs `--practices`) prints each lens's id,
|
|
411
|
+
practice ids and focus length as JSON and exits 0 with no diff and no model
|
|
412
|
+
call. `<dir>/README.md` must exist: its "Signals: reject / accept / expect" section and
|
|
413
|
+
the "keyed to different tiers" provenance paragraph are sent to every lens as the
|
|
414
|
+
bar (missing or without those headings is `could_not_run`). Each practice's sensor
|
|
415
|
+
is headed `### <id>: <title>`. `--print-prompt <lens-id>` prints the exact prompt
|
|
416
|
+
that lens would be sent for the diff and exits 0 with no model call.
|
|
417
|
+
Front-matter is parsed by a minimal reader (only the `lens:` line, as in
|
|
418
|
+
v2); no YAML library.
|
|
419
|
+
|
|
420
|
+
**GitHub Actions**
|
|
421
|
+
|
|
422
|
+
```yaml
|
|
423
|
+
- uses: actions/checkout@v4
|
|
424
|
+
with:
|
|
425
|
+
fetch-depth: 0
|
|
426
|
+
- run: npx -y @verevoir/review@<next> aigency-review --base origin/${{ github.base_ref }} --title "${{ github.event.pull_request.title }}"
|
|
427
|
+
env:
|
|
428
|
+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
## Merge policy
|
|
432
|
+
|
|
433
|
+
Merges on green, same as this organisation's other rebuild repos. "Green"
|
|
434
|
+
here means: typecheck, lint, the deterministic test suite, and the
|
|
435
|
+
forbidden-deps guard. The model-call ratchet (detection rate per sensor,
|
|
436
|
+
agreement) cannot run in CI -- it needs real model calls -- and runs
|
|
437
|
+
locally, on the operator's subscription, via the eval harness; its
|
|
438
|
+
results belong in the PR body of any PR touching review _behaviour_.
|