@webpieces/rules-config 0.4.537 → 0.4.539
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/package.json +1 -1
- package/src/checklist-instructions.js +9 -4
- package/src/checklist-instructions.js.map +1 -1
- package/src/index.d.ts +2 -1
- package/src/index.js +13 -3
- package/src/index.js.map +1 -1
- package/src/review-provenance.d.ts +133 -0
- package/src/review-provenance.js +319 -0
- package/src/review-provenance.js.map +1 -0
- package/src/reviewer-instructions.d.ts +87 -4
- package/src/reviewer-instructions.js +204 -30
- package/src/reviewer-instructions.js.map +1 -1
- package/src/subagent-provenance.d.ts +2 -1
- package/src/subagent-provenance.js +8 -2
- package/src/subagent-provenance.js.map +1 -1
- package/templates/webpieces.review-checklists.md +21 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReviewerInstructionsService = exports.ReviewerBriefing = exports.BriefedFile = exports.ContextEntry = void 0;
|
|
3
|
+
exports.ReviewerInstructionsService = exports.ALL_DIFF_ONE_READ_LINES = exports.READ_TRUNCATION_LINES = exports.ReviewerBriefing = exports.BriefedFile = exports.ContextEntry = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const path = tslib_1.__importStar(require("path"));
|
|
6
6
|
const inversify_1 = require("inversify");
|
|
@@ -17,13 +17,29 @@ class ContextEntry {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
exports.ContextEntry = ContextEntry;
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* One reviewer's matched file, the extracted diff for it, AND the absolute path of the file itself.
|
|
22
|
+
*
|
|
23
|
+
* `sourcePath` exists because of a measured 0/4: four reviewers on one PR read the diff and not one opened a
|
|
24
|
+
* single full source file. The instructions handed them an absolute path per diff and only a parent DIRECTORY
|
|
25
|
+
* per source, so reading the diff was a paste and reading the source was "join this dir to that filename
|
|
26
|
+
* yourself". Identical affordance, or the cheaper one wins every time. Data-only.
|
|
27
|
+
*/
|
|
21
28
|
class BriefedFile {
|
|
22
29
|
file; // repo-relative source path
|
|
23
30
|
diffPath; // ABSOLUTE path of the extracted .diff
|
|
24
|
-
|
|
31
|
+
sourcePath; // ABSOLUTE path of the file itself; '' for a deleted file, which has no after-state
|
|
32
|
+
status; // 'M' | 'A' | 'D' | 'U' (untracked) | 'X' (excluded by config)
|
|
33
|
+
diffBytes;
|
|
34
|
+
truncated;
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
36
|
+
constructor(file, diffPath, sourcePath = '', status = 'M', diffBytes = 0, truncated = false) {
|
|
25
37
|
this.file = file;
|
|
26
38
|
this.diffPath = diffPath;
|
|
39
|
+
this.sourcePath = sourcePath;
|
|
40
|
+
this.status = status;
|
|
41
|
+
this.diffBytes = diffBytes;
|
|
42
|
+
this.truncated = truncated;
|
|
27
43
|
}
|
|
28
44
|
}
|
|
29
45
|
exports.BriefedFile = BriefedFile;
|
|
@@ -49,6 +65,18 @@ class ReviewerBriefing {
|
|
|
49
65
|
checklistId;
|
|
50
66
|
fileDiffCommand;
|
|
51
67
|
dirty;
|
|
68
|
+
// Facts ABOUT the manifest, surfaced inline so a reviewer learns the diff is complete without opening it.
|
|
69
|
+
changedFileCount;
|
|
70
|
+
truncatedCount;
|
|
71
|
+
excludedCount;
|
|
72
|
+
allDiffLines;
|
|
73
|
+
allDiffBytes;
|
|
74
|
+
// The three shas, by the names DiffManifest already uses. Printing two bare shas told a reviewer nothing
|
|
75
|
+
// about WHAT the diff is taken against; C beside A makes "main has moved since the fork" self-evident.
|
|
76
|
+
hashForkPoint;
|
|
77
|
+
hashFeatureHead;
|
|
78
|
+
hashMainHead;
|
|
79
|
+
ownAgentFileInDiff; // ABSOLUTE path when this diff edits THIS reviewer's own agent file; '' otherwise
|
|
52
80
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
53
81
|
constructor(subagent, checklistId, repoRoot) {
|
|
54
82
|
this.subagent = subagent;
|
|
@@ -65,9 +93,25 @@ class ReviewerBriefing {
|
|
|
65
93
|
this.verdictPath = '';
|
|
66
94
|
this.fileDiffCommand = '';
|
|
67
95
|
this.dirty = false;
|
|
96
|
+
this.changedFileCount = 0;
|
|
97
|
+
this.truncatedCount = 0;
|
|
98
|
+
this.excludedCount = 0;
|
|
99
|
+
this.allDiffLines = 0;
|
|
100
|
+
this.allDiffBytes = 0;
|
|
101
|
+
this.hashForkPoint = '';
|
|
102
|
+
this.hashFeatureHead = '';
|
|
103
|
+
this.hashMainHead = '';
|
|
104
|
+
this.ownAgentFileInDiff = '';
|
|
68
105
|
}
|
|
69
106
|
}
|
|
70
107
|
exports.ReviewerBriefing = ReviewerBriefing;
|
|
108
|
+
/**
|
|
109
|
+
* The Read tool truncates at roughly this many lines, silently. Any path this file prints alongside a bigger
|
|
110
|
+
* line count has to say so, or a reviewer reviews a fraction of a change and reports on all of it.
|
|
111
|
+
*/
|
|
112
|
+
exports.READ_TRUNCATION_LINES = 2000;
|
|
113
|
+
/** Comfortably under {@link READ_TRUNCATION_LINES} — the size at which ALL.diff really is one clean Read. */
|
|
114
|
+
exports.ALL_DIFF_ONE_READ_LINES = 1500;
|
|
71
115
|
/**
|
|
72
116
|
* Renders the per-reviewer instructions file that `wp-review-upsert-pr` writes to
|
|
73
117
|
* `.webpieces/pr-review/<feature>/instructions/<subagent>.instructions.md`.
|
|
@@ -117,13 +161,32 @@ let ReviewerInstructionsService = class ReviewerInstructionsService {
|
|
|
117
161
|
`# You are \`${b.subagent}\``,
|
|
118
162
|
'',
|
|
119
163
|
'Review as YOURSELF, against your own checklist — not as a general code reviewer.',
|
|
120
|
-
'You may not
|
|
164
|
+
'You may not write another reviewer\'s verdict file.',
|
|
165
|
+
'',
|
|
166
|
+
'"You may not review your own authorship" means: you did not write this diff, so review it — but if',
|
|
167
|
+
'the diff CHANGES YOU, say so in `output` rather than pretending the conflict is not there.',
|
|
168
|
+
...this.selfEditWarning(b),
|
|
121
169
|
'',
|
|
122
170
|
'_Generated per run by `wp-review-upsert-pr`. Everything below is already resolved for you; the',
|
|
123
171
|
'paths are absolute because your working directory is not guaranteed to be the repo root._',
|
|
124
172
|
'',
|
|
125
173
|
];
|
|
126
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Every PR that edits the review gate hits this: on the measured run, 5 of 8 changed files were the
|
|
177
|
+
* reviewer agent files themselves, two reviewers reviewed their OWN definition, and neither flagged it —
|
|
178
|
+
* neither had any guidance to. Detected by the tooling rather than left to the reviewer to notice.
|
|
179
|
+
*/
|
|
180
|
+
selfEditWarning(b) {
|
|
181
|
+
if (b.ownAgentFileInDiff === '')
|
|
182
|
+
return [];
|
|
183
|
+
return [
|
|
184
|
+
'',
|
|
185
|
+
`⚠️ THIS DIFF MODIFIES YOUR OWN AGENT FILE: \`${b.ownAgentFileInDiff}\``,
|
|
186
|
+
'You are reviewing a change to your own definition. Review it anyway — and state that fact in',
|
|
187
|
+
'`output`, so a human reading your verdict knows the reviewer and the reviewed were the same thing.',
|
|
188
|
+
];
|
|
189
|
+
}
|
|
127
190
|
checklistSection(b) {
|
|
128
191
|
if (b.docPath === '') {
|
|
129
192
|
return ['## Your checklist', '', 'This checklist has no guidance doc — judge the diff on your own standards.', ''];
|
|
@@ -131,8 +194,14 @@ let ReviewerInstructionsService = class ReviewerInstructionsService {
|
|
|
131
194
|
return ['## Your checklist', '', `Read this FIRST: \`${b.docPath}\``, ''];
|
|
132
195
|
}
|
|
133
196
|
/**
|
|
134
|
-
* The change itself. The
|
|
135
|
-
*
|
|
197
|
+
* The change itself. The MANIFEST leads, and the per-file table with it; `ALL.diff` is demoted to one
|
|
198
|
+
* option among several, recommended only where it is actually the right read.
|
|
199
|
+
*
|
|
200
|
+
* That ordering is the fix for a measured 4/4 failure. `ALL.diff` used to be bolded, first, and framed as
|
|
201
|
+
* "everything", with the manifest one unbolded line below it called a "path map" — which reads like a
|
|
202
|
+
* lookup aid, not something to open. All four reviewers on that PR read `ALL.diff`, none opened the
|
|
203
|
+
* manifest, and none could therefore have established that the combined view was complete. Reviewers did
|
|
204
|
+
* exactly what the emphasis told them to; so the emphasis moved.
|
|
136
205
|
*/
|
|
137
206
|
diffSection(b) {
|
|
138
207
|
const lines = ['## The change you are reviewing', ''];
|
|
@@ -141,15 +210,7 @@ let ReviewerInstructionsService = class ReviewerInstructionsService {
|
|
|
141
210
|
lines.push('> commit-to-commit range would show. Judge it anyway — it is what your checklist matched.');
|
|
142
211
|
lines.push('');
|
|
143
212
|
}
|
|
144
|
-
|
|
145
|
-
lines.push(`**Everything on this branch, already extracted:** \`${b.allDiffPath}\``);
|
|
146
|
-
lines.push('');
|
|
147
|
-
}
|
|
148
|
-
lines.push(...this.myFilesTable(b));
|
|
149
|
-
if (b.manifestPath !== '') {
|
|
150
|
-
lines.push(`Path map (authoritative; records truncated + excluded files): \`${b.manifestPath}\``);
|
|
151
|
-
lines.push('');
|
|
152
|
-
}
|
|
213
|
+
lines.push(...this.manifestLines(b), ...this.basisLines(b), ...this.myFilesTable(b), ...this.allDiffLines(b));
|
|
153
214
|
if (b.fileDiffCommand !== '') {
|
|
154
215
|
lines.push(`Reproduce any single file: \`${b.fileDiffCommand}\``);
|
|
155
216
|
lines.push('');
|
|
@@ -159,26 +220,119 @@ let ReviewerInstructionsService = class ReviewerInstructionsService {
|
|
|
159
220
|
lines.push('');
|
|
160
221
|
return lines;
|
|
161
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* The manifest, named as the authority AND with its own headline facts inlined. Inlining them is the
|
|
225
|
+
* point: a reviewer that never opens the manifest still learns whether anything was truncated or
|
|
226
|
+
* excluded, which is the one thing it could not otherwise have known it was missing.
|
|
227
|
+
*/
|
|
228
|
+
manifestLines(b) {
|
|
229
|
+
if (b.manifestPath === '')
|
|
230
|
+
return [];
|
|
231
|
+
const warn = b.truncatedCount + b.excludedCount > 0 ? ' ⚠️ NOT everything is materialized — see the table.' : '';
|
|
232
|
+
return [
|
|
233
|
+
`**Path map — AUTHORITATIVE. Read this first:** \`${b.manifestPath}\``,
|
|
234
|
+
` ${b.changedFileCount} file(s) · ${b.truncatedCount} truncated · ${b.excludedCount} excluded${warn}`,
|
|
235
|
+
' Per file it carries: `status` (M/A/D/U/X), `bytes`, `file`/`fileAbs`, `diffFile`/`diffAbs`, and the',
|
|
236
|
+
' three shas below. It is the only place that records what was truncated or left out.',
|
|
237
|
+
'',
|
|
238
|
+
];
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* What the diff is taken AGAINST. Two bare shas in a `git diff` command said nothing about this, so a
|
|
242
|
+
* reviewer could not tell a fork-point diff from a diff against main's current tip — and therefore could
|
|
243
|
+
* not tell that anything merged to main since the fork is simply absent from what it is judging.
|
|
244
|
+
* Rendering C beside A makes "main has moved" self-evident exactly when it has.
|
|
245
|
+
*/
|
|
246
|
+
basisLines(b) {
|
|
247
|
+
if (b.hashForkPoint === '')
|
|
248
|
+
return [];
|
|
249
|
+
const sameAsFork = b.hashMainHead === b.hashForkPoint;
|
|
250
|
+
const cNote = b.hashMainHead === '' ? '(unresolved)'
|
|
251
|
+
: sameAsFork ? `${b.hashMainHead} ← same as A, so main has not moved since the fork`
|
|
252
|
+
: `${b.hashMainHead} ← main HAS MOVED since the fork`;
|
|
253
|
+
return [
|
|
254
|
+
'This diff is **fork-point → feature-head**, NOT a diff against main\'s current tip:',
|
|
255
|
+
'```',
|
|
256
|
+
`fork point (A) ${b.hashForkPoint}`,
|
|
257
|
+
`feature head (B) ${b.hashFeatureHead}`,
|
|
258
|
+
`main head (C) ${cNote}`,
|
|
259
|
+
'```',
|
|
260
|
+
'Anything merged to main after A is NOT in this diff.',
|
|
261
|
+
'',
|
|
262
|
+
];
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Source and diff get IDENTICAL affordance — an absolute path each, in adjacent columns. The previous
|
|
266
|
+
* table gave an absolute path for the diff and nothing for the source, and the source went unread 4/4.
|
|
267
|
+
*/
|
|
162
268
|
myFilesTable(b) {
|
|
163
269
|
if (b.myFiles.length === 0)
|
|
164
270
|
return ['_No files matched your patterns._', ''];
|
|
165
271
|
const why = b.matchedPatterns.length === 0
|
|
166
272
|
? `**In scope: ALL ${b.myFiles.length} changed file(s)** — your checklist has no \`patterns\`, so the whole diff is yours.`
|
|
167
273
|
: `**In scope: ${b.myFiles.length} file(s)** matching ${b.matchedPatterns.map((p) => `\`${p}\``).join(', ')}:`;
|
|
168
|
-
const rows = b.myFiles.map((f) =>
|
|
169
|
-
return [why, '', '| file | its diff |', '
|
|
274
|
+
const rows = b.myFiles.map((f) => this.fileRow(f));
|
|
275
|
+
return [why, '', '| file | status | its diff | full source |', '|---|---|---|---|', ...rows, ''];
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* One row. A truncated or excluded diff is flagged HERE, in the row, not left as a field inside a file the
|
|
279
|
+
* reviewer has to think to open — and an oversized diff states the line count that makes a single Read
|
|
280
|
+
* come back silently incomplete.
|
|
281
|
+
*/
|
|
282
|
+
fileRow(f) {
|
|
283
|
+
const flags = [];
|
|
284
|
+
if (f.truncated)
|
|
285
|
+
flags.push('⚠️ diff TRUNCATED — read the source');
|
|
286
|
+
if (f.status === 'X')
|
|
287
|
+
flags.push('⚠️ EXCLUDED, not materialized — read the source');
|
|
288
|
+
const status = [`\`${f.status}\``, ...flags].join(' ');
|
|
289
|
+
const source = f.sourcePath === '' ? '_deleted — no file on disk_' : `\`${f.sourcePath}\``;
|
|
290
|
+
return `| \`${f.file}\` | ${status} | \`${f.diffPath}\` (${f.diffBytes} bytes) | ${source} |`;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* `ALL.diff`, recommended ONLY where it is the right read. It is kept — for a patternless reviewer on a
|
|
294
|
+
* small diff it is genuinely one Read instead of N, which is why all four used it — but the blanket
|
|
295
|
+
* "everything on this branch" line was wrong in two different ways at once: it invited a pattern-scoped
|
|
296
|
+
* reviewer to spend its budget on files it was explicitly not asked about, and it pointed a reviewer on a
|
|
297
|
+
* large PR at a file that cannot survive one Read.
|
|
298
|
+
*/
|
|
299
|
+
allDiffLines(b) {
|
|
300
|
+
if (b.allDiffPath === '')
|
|
301
|
+
return [];
|
|
302
|
+
const size = b.allDiffLines === 0 ? '' : ` — ${b.allDiffLines} lines / ${b.allDiffBytes} bytes`;
|
|
303
|
+
if (b.matchedPatterns.length > 0) {
|
|
304
|
+
return [`The whole branch${size}, for CROSS-FILE CONTEXT if you need it: \`${b.allDiffPath}\``,
|
|
305
|
+
'Your own files above are what you are reviewing; the rest of the branch is someone else\'s checklist.', ''];
|
|
306
|
+
}
|
|
307
|
+
if (b.allDiffLines > exports.ALL_DIFF_ONE_READ_LINES) {
|
|
308
|
+
return [`⚠️ The combined diff is ${b.allDiffLines} lines and will NOT survive a single Read (the Read tool`,
|
|
309
|
+
`truncates at ~${exports.READ_TRUNCATION_LINES} lines, silently). Read the per-file diffs above instead, or page it:`,
|
|
310
|
+
`\`${b.allDiffPath}\``, ''];
|
|
311
|
+
}
|
|
312
|
+
return [`Whole-branch diff${size} — convenient at this size, but the per-file table above is authoritative:`,
|
|
313
|
+
`\`${b.allDiffPath}\``, ''];
|
|
170
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* The rule that used to say "when you need to", and lost 4/4 to the more emphatic budget section 40 lines
|
|
317
|
+
* later. "When you need to" delegates the judgment to a reviewer that, by construction, does not yet know
|
|
318
|
+
* what it is missing. It has no opt-out now.
|
|
319
|
+
*/
|
|
171
320
|
sourceSection(b) {
|
|
172
|
-
const lines = ['##
|
|
321
|
+
const lines = ['## Read the full source — every file, every time', '', `Repo root: \`${b.repoRoot}\``, ''];
|
|
322
|
+
lines.push('**READ THE FULL SOURCE OF EVERY FILE IN YOUR TABLE.** Not "if you need to" — every time.');
|
|
323
|
+
lines.push('A hunk shows what changed; only the whole file shows what it changed INTO, and a change that');
|
|
324
|
+
lines.push('looks fine in isolation can still be wrong in place.');
|
|
325
|
+
lines.push('');
|
|
326
|
+
lines.push('The `full source` column above is the path. For files marked `A` (added) you have already done');
|
|
327
|
+
lines.push('this: an add-diff IS the complete file, byte for byte, so its diff and its source are the same');
|
|
328
|
+
lines.push('text. For `M` (modified) and `D` (deleted) files the diff is a fragment — open the file.');
|
|
329
|
+
lines.push('');
|
|
173
330
|
if (b.sourceDirs.length > 0) {
|
|
174
|
-
lines.push('
|
|
331
|
+
lines.push('The neighbouring code lives under:');
|
|
175
332
|
for (const dir of b.sourceDirs)
|
|
176
333
|
lines.push(`- \`${dir}\``);
|
|
177
334
|
lines.push('');
|
|
178
335
|
}
|
|
179
|
-
lines.push('Read whole files around the diff when you need to. The diff is the SUBJECT; the surrounding');
|
|
180
|
-
lines.push('code is the CONTEXT — a change that looks fine in isolation can still be wrong in place.');
|
|
181
|
-
lines.push('');
|
|
182
336
|
return lines;
|
|
183
337
|
}
|
|
184
338
|
/**
|
|
@@ -187,8 +341,14 @@ let ReviewerInstructionsService = class ReviewerInstructionsService {
|
|
|
187
341
|
* installed to, and it must never drop an entry silently: a missing path is stated as missing.
|
|
188
342
|
*/
|
|
189
343
|
contextSection(b) {
|
|
190
|
-
|
|
191
|
-
|
|
344
|
+
// Emitting NOTHING made the section this class exists for look like a feature that does not exist.
|
|
345
|
+
// One line naming the config keys costs nothing and is the only hint a repo will ever get.
|
|
346
|
+
if (b.contextEntries.length === 0) {
|
|
347
|
+
return ['## Pre-resolved context', '',
|
|
348
|
+
'_None configured for this repo. If you find yourself hunting for the same path on every review,',
|
|
349
|
+
'it belongs in `pr-gate.reviewContext` / `pr-gate.reviewContextPackages` in `webpieces.config.json`._',
|
|
350
|
+
''];
|
|
351
|
+
}
|
|
192
352
|
const lines = ['## Pre-resolved context (do not go hunting for these)', ''];
|
|
193
353
|
for (const entry of b.contextEntries) {
|
|
194
354
|
const suffix = entry.note === '' ? '' : ` ${entry.note}`;
|
|
@@ -213,18 +373,32 @@ let ReviewerInstructionsService = class ReviewerInstructionsService {
|
|
|
213
373
|
'',
|
|
214
374
|
];
|
|
215
375
|
}
|
|
376
|
+
/**
|
|
377
|
+
* The anti-hunting rule, with the changed files carved out explicitly.
|
|
378
|
+
*
|
|
379
|
+
* It used to read as "stay inside what you were given" and, being the LAST thing in the file, it beat
|
|
380
|
+
* the source-reading instruction 4 times out of 4. It never distinguished HUNTING — greps into
|
|
381
|
+
* `node_modules`, re-deriving the dependency graph — from OPENING A FILE IT WAS EXPLICITLY HANDED. The
|
|
382
|
+
* distinction is now stated, because where two instructions conflict the later and more emphatic one wins.
|
|
383
|
+
*/
|
|
216
384
|
budgetSection() {
|
|
217
385
|
return [
|
|
218
386
|
'## Budget',
|
|
219
387
|
'',
|
|
220
|
-
'
|
|
221
|
-
'
|
|
222
|
-
'were not configured.
|
|
223
|
-
'
|
|
224
|
-
'
|
|
388
|
+
'Do NOT search `node_modules`, do NOT re-derive the dependency graph, and do NOT hunt the repo for',
|
|
389
|
+
'infrastructure config. That is hunting, and it is what wastes a review budget — those paths are',
|
|
390
|
+
'either given above or were not configured.',
|
|
391
|
+
'',
|
|
392
|
+
'Reading the full text of a file that is IN your table is NOT hunting — it is the review. Budget for',
|
|
393
|
+
'it: read the diff to see what changed, and the source to judge whether it is right in place.',
|
|
394
|
+
'',
|
|
395
|
+
'If something you genuinely need is missing, name it in `output` and give your verdict on what you',
|
|
396
|
+
'could actually see.',
|
|
225
397
|
'',
|
|
226
398
|
'Open your diff files before writing a verdict. `wp-finish-upsert-pr` reads your own transcript and',
|
|
227
|
-
'reports a verdict written without opening the diff.',
|
|
399
|
+
'reports a verdict written without opening the diff. It also records the path of that transcript,',
|
|
400
|
+
'beside what you were offered and what you read, in `provenance.json` next to your verdict file —',
|
|
401
|
+
'so the review is auditable after the fact. You do not write that file; the tooling does.',
|
|
228
402
|
];
|
|
229
403
|
}
|
|
230
404
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reviewer-instructions.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/reviewer-inst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D,KAAK,CAAC,IAAI,CAAC,OAAO,KAAK,CAAC,KAAK,UAAU,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAC9H,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;OAGG;IACK,cAAc,CAAC,CAAmB;QACtC,OAAO;YACH,uBAAuB;YACvB,EAAE;YACF,qDAAqD,CAAC,CAAC,WAAW,IAAI;YACtE,EAAE;YACF,KAAK;YACL,IAAI,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,EAAE,EAAE,CAAC;YAC9D,KAAK;YACL,EAAE;SACL,CAAC;IACN,CAAC;IAEO,aAAa;QACjB,OAAO;YACH,WAAW;YACX,EAAE;YACF,oGAAoG;YACpG,mGAAmG;YACnG,oGAAoG;YACpG,gGAAgG;YAChG,iDAAiD;YACjD,EAAE;YACF,oGAAoG;YACpG,qDAAqD;SACxD,CAAC;IACN,CAAC;CACJ,CAAA;AArJY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEW,+BAAiB;GADxD,2BAA2B,CAqJvC","sourcesContent":["import * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ReviewJsonService } from './review-json';\n\n/** One pre-resolved place a reviewer would otherwise have to go hunting for. Data-only (per CLAUDE.md). */\nexport class ContextEntry {\n label: string;\n path: string; // ABSOLUTE, or '' when it could not be resolved\n note: string; // '(not installed)' / '(configured but missing)' — never silently dropped\n\n constructor(label: string, entryPath: string, note = '') {\n this.label = label;\n this.path = entryPath;\n this.note = note;\n }\n}\n\n/** One reviewer's matched file and the extracted diff for it. Data-only. */\nexport class BriefedFile {\n file: string; // repo-relative source path\n diffPath: string; // ABSOLUTE path of the extracted .diff\n\n constructor(file: string, diffPath: string) {\n this.file = file;\n this.diffPath = diffPath;\n }\n}\n\n/**\n * Everything ONE reviewer needs, with every path already resolved to an ABSOLUTE one.\n *\n * Absolute is not fussiness: a subagent's working directory is not guaranteed to be the repo root, and a\n * relative path that fails to resolve turns into a search, which is the cost this whole class exists to\n * remove. Data-only.\n */\nexport class ReviewerBriefing {\n subagent: string;\n docPath: string; // the checklist's guidance doc ('' when the checklist has none)\n repoRoot: string;\n diffDir: string; // '' when nothing was materialized\n allDiffPath: string;\n manifestPath: string;\n myFiles: BriefedFile[]; // ONLY this reviewer's matched files\n matchedPatterns: string[]; // [] ⇒ patternless: the whole diff is in scope\n sourceDirs: string[]; // deduped ABSOLUTE parent dirs of myFiles\n contextEntries: ContextEntry[];\n verdictPath: string; // ABSOLUTE review-<id>.json\n checklistId: string;\n fileDiffCommand: string;\n dirty: boolean;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(subagent: string, checklistId: string, repoRoot: string) {\n this.subagent = subagent;\n this.checklistId = checklistId;\n this.repoRoot = repoRoot;\n this.docPath = '';\n this.diffDir = '';\n this.allDiffPath = '';\n this.manifestPath = '';\n this.myFiles = [];\n this.matchedPatterns = [];\n this.sourceDirs = [];\n this.contextEntries = [];\n this.verdictPath = '';\n this.fileDiffCommand = '';\n this.dirty = false;\n }\n}\n\n/**\n * Renders the per-reviewer instructions file that `wp-review-upsert-pr` writes to\n * `.webpieces/pr-review/<feature>/instructions/<subagent>.instructions.md`.\n *\n * WHY this file exists, measured rather than assumed: a reviewer subagent on monorepo-nx2 spent **14 of its\n * 26 tool calls** rediscovering context the tooling already had — three separate greps into\n * `node_modules/@webpieces` to locate a scanner, a hunt through terraform for queue names, and a\n * re-derivation of the dependency graph. It did not over-review; it was under-supplied. Everything below is\n * chosen to delete a specific one of those calls.\n *\n * It is GENERATED per run, and the registered `.claude/agents/<subagent>.md` is a thin stub that points\n * here, because content a human maintains goes stale and a reviewer follows the stale copy. The verdict\n * schema in particular comes from {@link ReviewJsonService.verdictSchemaFor}.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewerInstructionsService {\n constructor(private readonly reviewJsonService: ReviewJsonService) {}\n\n /** The dir holding this branch's generated instructions, beside its review.json. */\n instructionsDirFor(repoRoot: string, featureName: string): string {\n return path.join(this.reviewJsonService.prDirFor(repoRoot, featureName), 'instructions');\n }\n\n /** The file name for a reviewer's generated instructions. */\n fileNameFor(subagent: string): string {\n return `${subagent}.instructions.md`;\n }\n\n /** Absolute path of one reviewer's generated instructions file. */\n pathFor(repoRoot: string, featureName: string, subagent: string): string {\n return path.join(this.instructionsDirFor(repoRoot, featureName), this.fileNameFor(subagent));\n }\n\n render(briefing: ReviewerBriefing): string {\n return [\n ...this.identity(briefing),\n ...this.checklistSection(briefing),\n ...this.diffSection(briefing),\n ...this.sourceSection(briefing),\n ...this.contextSection(briefing),\n ...this.verdictSection(briefing),\n ...this.budgetSection(),\n ].join('\\n') + '\\n';\n }\n\n private identity(b: ReviewerBriefing): string[] {\n return [\n `# You are \\`${b.subagent}\\``,\n '',\n 'Review as YOURSELF, against your own checklist — not as a general code reviewer.',\n 'You may not review your own authorship, and you may not write another reviewer\\'s verdict file.',\n '',\n '_Generated per run by `wp-review-upsert-pr`. Everything below is already resolved for you; the',\n 'paths are absolute because your working directory is not guaranteed to be the repo root._',\n '',\n ];\n }\n\n private checklistSection(b: ReviewerBriefing): string[] {\n if (b.docPath === '') {\n return ['## Your checklist', '', 'This checklist has no guidance doc — judge the diff on your own standards.', ''];\n }\n return ['## Your checklist', '', `Read this FIRST: \\`${b.docPath}\\``, ''];\n }\n\n /**\n * The change itself. The materialized diff leads because it is ONE Read instead of a shell-out per file,\n * and because a hand-assembled range can come back empty (it did — see DiffBasis).\n */\n private diffSection(b: ReviewerBriefing): string[] {\n const lines = ['## The change you are reviewing', ''];\n if (b.dirty) {\n lines.push('> ⚠️ This diff INCLUDES uncommitted and untracked work, so it is not what a');\n lines.push('> commit-to-commit range would show. Judge it anyway — it is what your checklist matched.');\n lines.push('');\n }\n if (b.allDiffPath !== '') {\n lines.push(`**Everything on this branch, already extracted:** \\`${b.allDiffPath}\\``);\n lines.push('');\n }\n lines.push(...this.myFilesTable(b));\n if (b.manifestPath !== '') {\n lines.push(`Path map (authoritative; records truncated + excluded files): \\`${b.manifestPath}\\``);\n lines.push('');\n }\n if (b.fileDiffCommand !== '') {\n lines.push(`Reproduce any single file: \\`${b.fileDiffCommand}\\``);\n lines.push('');\n }\n lines.push('Path matching is COARSE. Judge the change, not the path — if a matched file turns out to be');\n lines.push('irrelevant to your checklist, say so in one sentence and move on.');\n lines.push('');\n return lines;\n }\n\n private myFilesTable(b: ReviewerBriefing): string[] {\n if (b.myFiles.length === 0) return ['_No files matched your patterns._', ''];\n const why = b.matchedPatterns.length === 0\n ? `**In scope: ALL ${b.myFiles.length} changed file(s)** — your checklist has no \\`patterns\\`, so the whole diff is yours.`\n : `**In scope: ${b.myFiles.length} file(s)** matching ${b.matchedPatterns.map((p: string): string => `\\`${p}\\``).join(', ')}:`;\n const rows = b.myFiles.map((f: BriefedFile): string => `| \\`${f.file}\\` | \\`${f.diffPath}\\` |`);\n return [why, '', '| file | its diff |', '|---|---|', ...rows, ''];\n }\n\n private sourceSection(b: ReviewerBriefing): string[] {\n const lines = ['## Where the source lives', '', `Repo root: \\`${b.repoRoot}\\``, ''];\n if (b.sourceDirs.length > 0) {\n lines.push('Your matched files live under:');\n for (const dir of b.sourceDirs) lines.push(`- \\`${dir}\\``);\n lines.push('');\n }\n lines.push('Read whole files around the diff when you need to. The diff is the SUBJECT; the surrounding');\n lines.push('code is the CONTEXT — a change that looks fine in isolation can still be wrong in place.');\n lines.push('');\n return lines;\n }\n\n /**\n * The section that deletes the `node_modules` greps. Entries come from config, because the tooling\n * cannot guess that a repo keeps its queue names in terraform — but it CAN resolve where a package\n * installed to, and it must never drop an entry silently: a missing path is stated as missing.\n */\n private contextSection(b: ReviewerBriefing): string[] {\n if (b.contextEntries.length === 0) return [];\n const lines = ['## Pre-resolved context (do not go hunting for these)', ''];\n for (const entry of b.contextEntries) {\n const suffix = entry.note === '' ? '' : ` ${entry.note}`;\n lines.push(`- **${entry.label}** — \\`${entry.path === '' ? entry.note : entry.path}\\`${entry.path === '' ? '' : suffix}`);\n }\n lines.push('');\n return lines;\n }\n\n /**\n * The verdict shape, GENERATED — never restated in a hand-maintained file. `id` is pre-filled with this\n * reviewer's own checklist id so there is nothing to substitute and nothing to get wrong.\n */\n private verdictSection(b: ReviewerBriefing): string[] {\n return [\n '## Write your verdict',\n '',\n `Write EXACTLY this shape, to EXACTLY this file: \\`${b.verdictPath}\\``,\n '',\n '```',\n this.reviewJsonService.verdictSchemaFor(b.checklistId, '', ''),\n '```',\n '',\n ];\n }\n\n private budgetSection(): string[] {\n return [\n '## Budget',\n '',\n 'Everything you need is listed above. Do NOT search `node_modules`, do NOT re-derive the dependency',\n 'graph, and do NOT hunt the repo for infrastructure config — those paths are either given above or',\n 'were not configured. If something you genuinely need is missing, name it in `output` and give your',\n 'verdict on what you could actually see. A reviewer that spends its budget searching produces a',\n 'thinner review than one that spends it reading.',\n '',\n 'Open your diff files before writing a verdict. `wp-finish-upsert-pr` reads your own transcript and',\n 'reports a verdict written without opening the diff.',\n ];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"reviewer-instructions.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/reviewer-instructions.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,yCAA2D;AAC3D,+CAAkD;AAElD,2GAA2G;AAC3G,MAAa,YAAY;IACrB,KAAK,CAAS;IACd,IAAI,CAAS,CAAK,gDAAgD;IAClE,IAAI,CAAS,CAAK,0EAA0E;IAE5F,YAAY,K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} from 'inversify';\nimport { ReviewJsonService } from './review-json';\n\n/** One pre-resolved place a reviewer would otherwise have to go hunting for. Data-only (per CLAUDE.md). */\nexport class ContextEntry {\n label: string;\n path: string; // ABSOLUTE, or '' when it could not be resolved\n note: string; // '(not installed)' / '(configured but missing)' — never silently dropped\n\n constructor(label: string, entryPath: string, note = '') {\n this.label = label;\n this.path = entryPath;\n this.note = note;\n }\n}\n\n/**\n * One reviewer's matched file, the extracted diff for it, AND the absolute path of the file itself.\n *\n * `sourcePath` exists because of a measured 0/4: four reviewers on one PR read the diff and not one opened a\n * single full source file. The instructions handed them an absolute path per diff and only a parent DIRECTORY\n * per source, so reading the diff was a paste and reading the source was \"join this dir to that filename\n * yourself\". Identical affordance, or the cheaper one wins every time. Data-only.\n */\nexport class BriefedFile {\n file: string; // repo-relative source path\n diffPath: string; // ABSOLUTE path of the extracted .diff\n sourcePath: string; // ABSOLUTE path of the file itself; '' for a deleted file, which has no after-state\n status: string; // 'M' | 'A' | 'D' | 'U' (untracked) | 'X' (excluded by config)\n diffBytes: number;\n truncated: boolean;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(file: string, diffPath: string, sourcePath = '', status = 'M', diffBytes = 0, truncated = false) {\n this.file = file;\n this.diffPath = diffPath;\n this.sourcePath = sourcePath;\n this.status = status;\n this.diffBytes = diffBytes;\n this.truncated = truncated;\n }\n}\n\n/**\n * Everything ONE reviewer needs, with every path already resolved to an ABSOLUTE one.\n *\n * Absolute is not fussiness: a subagent's working directory is not guaranteed to be the repo root, and a\n * relative path that fails to resolve turns into a search, which is the cost this whole class exists to\n * remove. Data-only.\n */\nexport class ReviewerBriefing {\n subagent: string;\n docPath: string; // the checklist's guidance doc ('' when the checklist has none)\n repoRoot: string;\n diffDir: string; // '' when nothing was materialized\n allDiffPath: string;\n manifestPath: string;\n myFiles: BriefedFile[]; // ONLY this reviewer's matched files\n matchedPatterns: string[]; // [] ⇒ patternless: the whole diff is in scope\n sourceDirs: string[]; // deduped ABSOLUTE parent dirs of myFiles\n contextEntries: ContextEntry[];\n verdictPath: string; // ABSOLUTE review-<id>.json\n checklistId: string;\n fileDiffCommand: string;\n dirty: boolean;\n // Facts ABOUT the manifest, surfaced inline so a reviewer learns the diff is complete without opening it.\n changedFileCount: number;\n truncatedCount: number;\n excludedCount: number;\n allDiffLines: number;\n allDiffBytes: number;\n // The three shas, by the names DiffManifest already uses. Printing two bare shas told a reviewer nothing\n // about WHAT the diff is taken against; C beside A makes \"main has moved since the fork\" self-evident.\n hashForkPoint: string;\n hashFeatureHead: string;\n hashMainHead: string;\n ownAgentFileInDiff: string; // ABSOLUTE path when this diff edits THIS reviewer's own agent file; '' otherwise\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(subagent: string, checklistId: string, repoRoot: string) {\n this.subagent = subagent;\n this.checklistId = checklistId;\n this.repoRoot = repoRoot;\n this.docPath = '';\n this.diffDir = '';\n this.allDiffPath = '';\n this.manifestPath = '';\n this.myFiles = [];\n this.matchedPatterns = [];\n this.sourceDirs = [];\n this.contextEntries = [];\n this.verdictPath = '';\n this.fileDiffCommand = '';\n this.dirty = false;\n this.changedFileCount = 0;\n this.truncatedCount = 0;\n this.excludedCount = 0;\n this.allDiffLines = 0;\n this.allDiffBytes = 0;\n this.hashForkPoint = '';\n this.hashFeatureHead = '';\n this.hashMainHead = '';\n this.ownAgentFileInDiff = '';\n }\n}\n\n/**\n * The Read tool truncates at roughly this many lines, silently. Any path this file prints alongside a bigger\n * line count has to say so, or a reviewer reviews a fraction of a change and reports on all of it.\n */\nexport const READ_TRUNCATION_LINES = 2000;\n\n/** Comfortably under {@link READ_TRUNCATION_LINES} — the size at which ALL.diff really is one clean Read. */\nexport const ALL_DIFF_ONE_READ_LINES = 1500;\n\n/**\n * Renders the per-reviewer instructions file that `wp-review-upsert-pr` writes to\n * `.webpieces/pr-review/<feature>/instructions/<subagent>.instructions.md`.\n *\n * WHY this file exists, measured rather than assumed: a reviewer subagent on monorepo-nx2 spent **14 of its\n * 26 tool calls** rediscovering context the tooling already had — three separate greps into\n * `node_modules/@webpieces` to locate a scanner, a hunt through terraform for queue names, and a\n * re-derivation of the dependency graph. It did not over-review; it was under-supplied. Everything below is\n * chosen to delete a specific one of those calls.\n *\n * It is GENERATED per run, and the registered `.claude/agents/<subagent>.md` is a thin stub that points\n * here, because content a human maintains goes stale and a reviewer follows the stale copy. The verdict\n * schema in particular comes from {@link ReviewJsonService.verdictSchemaFor}.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewerInstructionsService {\n constructor(private readonly reviewJsonService: ReviewJsonService) {}\n\n /** The dir holding this branch's generated instructions, beside its review.json. */\n instructionsDirFor(repoRoot: string, featureName: string): string {\n return path.join(this.reviewJsonService.prDirFor(repoRoot, featureName), 'instructions');\n }\n\n /** The file name for a reviewer's generated instructions. */\n fileNameFor(subagent: string): string {\n return `${subagent}.instructions.md`;\n }\n\n /** Absolute path of one reviewer's generated instructions file. */\n pathFor(repoRoot: string, featureName: string, subagent: string): string {\n return path.join(this.instructionsDirFor(repoRoot, featureName), this.fileNameFor(subagent));\n }\n\n render(briefing: ReviewerBriefing): string {\n return [\n ...this.identity(briefing),\n ...this.checklistSection(briefing),\n ...this.diffSection(briefing),\n ...this.sourceSection(briefing),\n ...this.contextSection(briefing),\n ...this.verdictSection(briefing),\n ...this.budgetSection(),\n ].join('\\n') + '\\n';\n }\n\n private identity(b: ReviewerBriefing): string[] {\n return [\n `# You are \\`${b.subagent}\\``,\n '',\n 'Review as YOURSELF, against your own checklist — not as a general code reviewer.',\n 'You may not write another reviewer\\'s verdict file.',\n '',\n '\"You may not review your own authorship\" means: you did not write this diff, so review it — but if',\n 'the diff CHANGES YOU, say so in `output` rather than pretending the conflict is not there.',\n ...this.selfEditWarning(b),\n '',\n '_Generated per run by `wp-review-upsert-pr`. Everything below is already resolved for you; the',\n 'paths are absolute because your working directory is not guaranteed to be the repo root._',\n '',\n ];\n }\n\n /**\n * Every PR that edits the review gate hits this: on the measured run, 5 of 8 changed files were the\n * reviewer agent files themselves, two reviewers reviewed their OWN definition, and neither flagged it —\n * neither had any guidance to. Detected by the tooling rather than left to the reviewer to notice.\n */\n private selfEditWarning(b: ReviewerBriefing): string[] {\n if (b.ownAgentFileInDiff === '') return [];\n return [\n '',\n `⚠️ THIS DIFF MODIFIES YOUR OWN AGENT FILE: \\`${b.ownAgentFileInDiff}\\``,\n 'You are reviewing a change to your own definition. Review it anyway — and state that fact in',\n '`output`, so a human reading your verdict knows the reviewer and the reviewed were the same thing.',\n ];\n }\n\n private checklistSection(b: ReviewerBriefing): string[] {\n if (b.docPath === '') {\n return ['## Your checklist', '', 'This checklist has no guidance doc — judge the diff on your own standards.', ''];\n }\n return ['## Your checklist', '', `Read this FIRST: \\`${b.docPath}\\``, ''];\n }\n\n /**\n * The change itself. The MANIFEST leads, and the per-file table with it; `ALL.diff` is demoted to one\n * option among several, recommended only where it is actually the right read.\n *\n * That ordering is the fix for a measured 4/4 failure. `ALL.diff` used to be bolded, first, and framed as\n * \"everything\", with the manifest one unbolded line below it called a \"path map\" — which reads like a\n * lookup aid, not something to open. All four reviewers on that PR read `ALL.diff`, none opened the\n * manifest, and none could therefore have established that the combined view was complete. Reviewers did\n * exactly what the emphasis told them to; so the emphasis moved.\n */\n private diffSection(b: ReviewerBriefing): string[] {\n const lines = ['## The change you are reviewing', ''];\n if (b.dirty) {\n lines.push('> ⚠️ This diff INCLUDES uncommitted and untracked work, so it is not what a');\n lines.push('> commit-to-commit range would show. Judge it anyway — it is what your checklist matched.');\n lines.push('');\n }\n lines.push(...this.manifestLines(b), ...this.basisLines(b), ...this.myFilesTable(b), ...this.allDiffLines(b));\n if (b.fileDiffCommand !== '') {\n lines.push(`Reproduce any single file: \\`${b.fileDiffCommand}\\``);\n lines.push('');\n }\n lines.push('Path matching is COARSE. Judge the change, not the path — if a matched file turns out to be');\n lines.push('irrelevant to your checklist, say so in one sentence and move on.');\n lines.push('');\n return lines;\n }\n\n /**\n * The manifest, named as the authority AND with its own headline facts inlined. Inlining them is the\n * point: a reviewer that never opens the manifest still learns whether anything was truncated or\n * excluded, which is the one thing it could not otherwise have known it was missing.\n */\n private manifestLines(b: ReviewerBriefing): string[] {\n if (b.manifestPath === '') return [];\n const warn = b.truncatedCount + b.excludedCount > 0 ? ' ⚠️ NOT everything is materialized — see the table.' : '';\n return [\n `**Path map — AUTHORITATIVE. Read this first:** \\`${b.manifestPath}\\``,\n ` ${b.changedFileCount} file(s) · ${b.truncatedCount} truncated · ${b.excludedCount} excluded${warn}`,\n ' Per file it carries: `status` (M/A/D/U/X), `bytes`, `file`/`fileAbs`, `diffFile`/`diffAbs`, and the',\n ' three shas below. It is the only place that records what was truncated or left out.',\n '',\n ];\n }\n\n /**\n * What the diff is taken AGAINST. Two bare shas in a `git diff` command said nothing about this, so a\n * reviewer could not tell a fork-point diff from a diff against main's current tip — and therefore could\n * not tell that anything merged to main since the fork is simply absent from what it is judging.\n * Rendering C beside A makes \"main has moved\" self-evident exactly when it has.\n */\n private basisLines(b: ReviewerBriefing): string[] {\n if (b.hashForkPoint === '') return [];\n const sameAsFork = b.hashMainHead === b.hashForkPoint;\n const cNote = b.hashMainHead === '' ? '(unresolved)'\n : sameAsFork ? `${b.hashMainHead} ← same as A, so main has not moved since the fork`\n : `${b.hashMainHead} ← main HAS MOVED since the fork`;\n return [\n 'This diff is **fork-point → feature-head**, NOT a diff against main\\'s current tip:',\n '```',\n `fork point (A) ${b.hashForkPoint}`,\n `feature head (B) ${b.hashFeatureHead}`,\n `main head (C) ${cNote}`,\n '```',\n 'Anything merged to main after A is NOT in this diff.',\n '',\n ];\n }\n\n /**\n * Source and diff get IDENTICAL affordance — an absolute path each, in adjacent columns. The previous\n * table gave an absolute path for the diff and nothing for the source, and the source went unread 4/4.\n */\n private myFilesTable(b: ReviewerBriefing): string[] {\n if (b.myFiles.length === 0) return ['_No files matched your patterns._', ''];\n const why = b.matchedPatterns.length === 0\n ? `**In scope: ALL ${b.myFiles.length} changed file(s)** — your checklist has no \\`patterns\\`, so the whole diff is yours.`\n : `**In scope: ${b.myFiles.length} file(s)** matching ${b.matchedPatterns.map((p: string): string => `\\`${p}\\``).join(', ')}:`;\n const rows = b.myFiles.map((f: BriefedFile): string => this.fileRow(f));\n return [why, '', '| file | status | its diff | full source |', '|---|---|---|---|', ...rows, ''];\n }\n\n /**\n * One row. A truncated or excluded diff is flagged HERE, in the row, not left as a field inside a file the\n * reviewer has to think to open — and an oversized diff states the line count that makes a single Read\n * come back silently incomplete.\n */\n private fileRow(f: BriefedFile): string {\n const flags: string[] = [];\n if (f.truncated) flags.push('⚠️ diff TRUNCATED — read the source');\n if (f.status === 'X') flags.push('⚠️ EXCLUDED, not materialized — read the source');\n const status = [`\\`${f.status}\\``, ...flags].join(' ');\n const source = f.sourcePath === '' ? '_deleted — no file on disk_' : `\\`${f.sourcePath}\\``;\n return `| \\`${f.file}\\` | ${status} | \\`${f.diffPath}\\` (${f.diffBytes} bytes) | ${source} |`;\n }\n\n /**\n * `ALL.diff`, recommended ONLY where it is the right read. It is kept — for a patternless reviewer on a\n * small diff it is genuinely one Read instead of N, which is why all four used it — but the blanket\n * \"everything on this branch\" line was wrong in two different ways at once: it invited a pattern-scoped\n * reviewer to spend its budget on files it was explicitly not asked about, and it pointed a reviewer on a\n * large PR at a file that cannot survive one Read.\n */\n private allDiffLines(b: ReviewerBriefing): string[] {\n if (b.allDiffPath === '') return [];\n const size = b.allDiffLines === 0 ? '' : ` — ${b.allDiffLines} lines / ${b.allDiffBytes} bytes`;\n if (b.matchedPatterns.length > 0) {\n return [`The whole branch${size}, for CROSS-FILE CONTEXT if you need it: \\`${b.allDiffPath}\\``,\n 'Your own files above are what you are reviewing; the rest of the branch is someone else\\'s checklist.', ''];\n }\n if (b.allDiffLines > ALL_DIFF_ONE_READ_LINES) {\n return [`⚠️ The combined diff is ${b.allDiffLines} lines and will NOT survive a single Read (the Read tool`,\n `truncates at ~${READ_TRUNCATION_LINES} lines, silently). Read the per-file diffs above instead, or page it:`,\n `\\`${b.allDiffPath}\\``, ''];\n }\n return [`Whole-branch diff${size} — convenient at this size, but the per-file table above is authoritative:`,\n `\\`${b.allDiffPath}\\``, ''];\n }\n\n /**\n * The rule that used to say \"when you need to\", and lost 4/4 to the more emphatic budget section 40 lines\n * later. \"When you need to\" delegates the judgment to a reviewer that, by construction, does not yet know\n * what it is missing. It has no opt-out now.\n */\n private sourceSection(b: ReviewerBriefing): string[] {\n const lines = ['## Read the full source — every file, every time', '', `Repo root: \\`${b.repoRoot}\\``, ''];\n lines.push('**READ THE FULL SOURCE OF EVERY FILE IN YOUR TABLE.** Not \"if you need to\" — every time.');\n lines.push('A hunk shows what changed; only the whole file shows what it changed INTO, and a change that');\n lines.push('looks fine in isolation can still be wrong in place.');\n lines.push('');\n lines.push('The `full source` column above is the path. For files marked `A` (added) you have already done');\n lines.push('this: an add-diff IS the complete file, byte for byte, so its diff and its source are the same');\n lines.push('text. For `M` (modified) and `D` (deleted) files the diff is a fragment — open the file.');\n lines.push('');\n if (b.sourceDirs.length > 0) {\n lines.push('The neighbouring code lives under:');\n for (const dir of b.sourceDirs) lines.push(`- \\`${dir}\\``);\n lines.push('');\n }\n return lines;\n }\n\n /**\n * The section that deletes the `node_modules` greps. Entries come from config, because the tooling\n * cannot guess that a repo keeps its queue names in terraform — but it CAN resolve where a package\n * installed to, and it must never drop an entry silently: a missing path is stated as missing.\n */\n private contextSection(b: ReviewerBriefing): string[] {\n // Emitting NOTHING made the section this class exists for look like a feature that does not exist.\n // One line naming the config keys costs nothing and is the only hint a repo will ever get.\n if (b.contextEntries.length === 0) {\n return ['## Pre-resolved context', '',\n '_None configured for this repo. If you find yourself hunting for the same path on every review,',\n 'it belongs in `pr-gate.reviewContext` / `pr-gate.reviewContextPackages` in `webpieces.config.json`._',\n ''];\n }\n const lines = ['## Pre-resolved context (do not go hunting for these)', ''];\n for (const entry of b.contextEntries) {\n const suffix = entry.note === '' ? '' : ` ${entry.note}`;\n lines.push(`- **${entry.label}** — \\`${entry.path === '' ? entry.note : entry.path}\\`${entry.path === '' ? '' : suffix}`);\n }\n lines.push('');\n return lines;\n }\n\n /**\n * The verdict shape, GENERATED — never restated in a hand-maintained file. `id` is pre-filled with this\n * reviewer's own checklist id so there is nothing to substitute and nothing to get wrong.\n */\n private verdictSection(b: ReviewerBriefing): string[] {\n return [\n '## Write your verdict',\n '',\n `Write EXACTLY this shape, to EXACTLY this file: \\`${b.verdictPath}\\``,\n '',\n '```',\n this.reviewJsonService.verdictSchemaFor(b.checklistId, '', ''),\n '```',\n '',\n ];\n }\n\n /**\n * The anti-hunting rule, with the changed files carved out explicitly.\n *\n * It used to read as \"stay inside what you were given\" and, being the LAST thing in the file, it beat\n * the source-reading instruction 4 times out of 4. It never distinguished HUNTING — greps into\n * `node_modules`, re-deriving the dependency graph — from OPENING A FILE IT WAS EXPLICITLY HANDED. The\n * distinction is now stated, because where two instructions conflict the later and more emphatic one wins.\n */\n private budgetSection(): string[] {\n return [\n '## Budget',\n '',\n 'Do NOT search `node_modules`, do NOT re-derive the dependency graph, and do NOT hunt the repo for',\n 'infrastructure config. That is hunting, and it is what wastes a review budget — those paths are',\n 'either given above or were not configured.',\n '',\n 'Reading the full text of a file that is IN your table is NOT hunting — it is the review. Budget for',\n 'it: read the diff to see what changed, and the source to judge whether it is right in place.',\n '',\n 'If something you genuinely need is missing, name it in `output` and give your verdict on what you',\n 'could actually see.',\n '',\n 'Open your diff files before writing a verdict. `wp-finish-upsert-pr` reads your own transcript and',\n 'reports a verdict written without opening the diff. It also records the path of that transcript,',\n 'beside what you were offered and what you read, in `provenance.json` next to your verdict file —',\n 'so the review is auditable after the fact. You do not write that file; the tooling does.',\n ];\n }\n}\n"]}
|
|
@@ -21,7 +21,8 @@ export declare class ReviewerEvidence {
|
|
|
21
21
|
readDoc: boolean;
|
|
22
22
|
toolCallCount: number;
|
|
23
23
|
offRepoSearches: number;
|
|
24
|
-
|
|
24
|
+
transcriptPath: string;
|
|
25
|
+
constructor(agentType: string, agentId: string, readDiff?: boolean, readDoc?: boolean, toolCallCount?: number, offRepoSearches?: number, transcriptPath?: string);
|
|
25
26
|
}
|
|
26
27
|
/** What to look for when reading reviewer transcripts. Data-only — avoids a 5-param method. */
|
|
27
28
|
export declare class EvidenceRequest {
|
|
@@ -37,14 +37,20 @@ class ReviewerEvidence {
|
|
|
37
37
|
readDoc; // opened its checklist's guidance doc
|
|
38
38
|
toolCallCount;
|
|
39
39
|
offRepoSearches; // tool calls that reached into node_modules — the archaeology signal
|
|
40
|
+
// Absolute path of the transcript these counters were read out of, '' when it could not be resolved.
|
|
41
|
+
// Carried out rather than recomputed because a reviewer subagent cannot learn its own transcript path
|
|
42
|
+
// (the environment exposes the PARENT session id and no agent id), so this is the only place it is
|
|
43
|
+
// known — see ReviewProvenanceService, which records it as the audit link for the verdict.
|
|
44
|
+
transcriptPath;
|
|
40
45
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
41
|
-
constructor(agentType, agentId, readDiff = false, readDoc = false, toolCallCount = 0, offRepoSearches = 0) {
|
|
46
|
+
constructor(agentType, agentId, readDiff = false, readDoc = false, toolCallCount = 0, offRepoSearches = 0, transcriptPath = '') {
|
|
42
47
|
this.agentType = agentType;
|
|
43
48
|
this.agentId = agentId;
|
|
44
49
|
this.readDiff = readDiff;
|
|
45
50
|
this.readDoc = readDoc;
|
|
46
51
|
this.toolCallCount = toolCallCount;
|
|
47
52
|
this.offRepoSearches = offRepoSearches;
|
|
53
|
+
this.transcriptPath = transcriptPath;
|
|
48
54
|
}
|
|
49
55
|
}
|
|
50
56
|
exports.ReviewerEvidence = ReviewerEvidence;
|
|
@@ -166,7 +172,7 @@ let SubagentProvenanceService = class SubagentProvenanceService {
|
|
|
166
172
|
// the reviewer is told to open first, and it inlines the diff paths. A reviewer that opened it and
|
|
167
173
|
// then its own diff files is the intended path; treating only the diff dir as proof would flag it.
|
|
168
174
|
const readDiff = request.diffDir !== '' && this.mentions(inputs, request.diffDir);
|
|
169
|
-
return new ReviewerEvidence(agentType, agentId, readDiff, docPath !== '' && this.mentions(inputs, docPath), inputs.length, inputs.filter((i) => i.includes('node_modules')).length);
|
|
175
|
+
return new ReviewerEvidence(agentType, agentId, readDiff, docPath !== '' && this.mentions(inputs, docPath), inputs.length, inputs.filter((i) => i.includes('node_modules')).length, jsonl);
|
|
170
176
|
}
|
|
171
177
|
// The absolute path of agent-<id>.jsonl across all session dirs, or '' if it is not there.
|
|
172
178
|
transcriptPath(dirs, agentId) {
|