@webpieces/pr-gate 0.4.826 → 0.4.827
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 +3 -3
- package/src/dashboard/checklist-comment-renderer.js +8 -6
- package/src/dashboard/checklist-comment-renderer.js.map +1 -1
- package/src/dashboard/checklist-comment-row.d.ts +6 -0
- package/src/dashboard/checklist-comment-row.js +6 -0
- package/src/dashboard/checklist-comment-row.js.map +1 -1
- package/src/dashboard/dashboard.d.ts +11 -0
- package/src/dashboard/dashboard.js +24 -6
- package/src/dashboard/dashboard.js.map +1 -1
- package/src/scripts/commands/await-reviews-command.d.ts +3 -3
- package/src/scripts/commands/await-reviews-command.js +24 -20
- package/src/scripts/commands/await-reviews-command.js.map +1 -1
- package/src/scripts/commands/finish-upsert-pr-command.js +27 -31
- package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/review-upsert-pr-command.d.ts +3 -8
- package/src/scripts/commands/review-upsert-pr-command.js +15 -17
- package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/write-review-command.d.ts +29 -15
- package/src/scripts/commands/write-review-command.js +62 -29
- package/src/scripts/commands/write-review-command.js.map +1 -1
- package/src/scripts/commands/write-review-fixes-command.d.ts +5 -1
- package/src/scripts/commands/write-review-fixes-command.js +6 -5
- package/src/scripts/commands/write-review-fixes-command.js.map +1 -1
- package/src/scripts/workflow/checklist-scanner.d.ts +47 -22
- package/src/scripts/workflow/checklist-scanner.js +77 -34
- package/src/scripts/workflow/checklist-scanner.js.map +1 -1
- package/src/scripts/workflow/provenance-enforcer.d.ts +2 -2
- package/src/scripts/workflow/provenance-enforcer.js +5 -5
- package/src/scripts/workflow/provenance-enforcer.js.map +1 -1
- package/src/scripts/workflow/review-report.d.ts +26 -8
- package/src/scripts/workflow/review-report.js +61 -39
- package/src/scripts/workflow/review-report.js.map +1 -1
- package/src/scripts/workflow/review-round-state.d.ts +87 -22
- package/src/scripts/workflow/review-round-state.js +252 -104
- package/src/scripts/workflow/review-round-state.js.map +1 -1
- package/src/scripts/workflow/review-round-text.d.ts +37 -0
- package/src/scripts/workflow/review-round-text.js +87 -0
- package/src/scripts/workflow/review-round-text.js.map +1 -0
- package/src/scripts/workflow/review-stage-receipt.d.ts +7 -19
- package/src/scripts/workflow/review-stage-receipt.js +7 -31
- package/src/scripts/workflow/review-stage-receipt.js.map +1 -1
- package/src/scripts/workflow/reviewer-briefing-builder.js +0 -1
- package/src/scripts/workflow/reviewer-briefing-builder.js.map +1 -1
- package/src/scripts/workflow/reviewer-verdict-gate.d.ts +14 -26
- package/src/scripts/workflow/reviewer-verdict-gate.js +38 -51
- package/src/scripts/workflow/reviewer-verdict-gate.js.map +1 -1
- package/src/scripts/workflow/verdict-provenance.d.ts +10 -10
- package/src/scripts/workflow/verdict-provenance.js +25 -23
- package/src/scripts/workflow/verdict-provenance.js.map +1 -1
|
@@ -30,9 +30,9 @@ export declare class ChecklistScanOptions {
|
|
|
30
30
|
*/
|
|
31
31
|
contextStage: string;
|
|
32
32
|
/**
|
|
33
|
-
* `commands.pr-gate.maxReviewerRounds`, as the caller's validated config states it. REQUIRED and first
|
|
34
|
-
*
|
|
35
|
-
*
|
|
33
|
+
* `commands.pr-gate.maxReviewerRounds`, as the caller's validated config states it. REQUIRED and first,
|
|
34
|
+
* so a scan always states the budget its CARRIED verdicts were judged under (issue #1053: a stale green
|
|
35
|
+
* or yellow is carried whatever round it came from, and the reason names the budget).
|
|
36
36
|
*/
|
|
37
37
|
maxReviewerRounds: number;
|
|
38
38
|
constructor(maxReviewerRounds: number, filterAlreadyReviewed?: boolean, contextStage?: string);
|
|
@@ -111,18 +111,36 @@ export declare class ChecklistScan {
|
|
|
111
111
|
suppressed: RequiredChecklist[];
|
|
112
112
|
/**
|
|
113
113
|
* How every EXISTING verdict file stands (issue #863): CURRENT (submitted through `wp-write-review` and
|
|
114
|
-
* its checklist's in-scope diff is unchanged
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* Empty under suppression.
|
|
114
|
+
* its checklist's in-scope diff is unchanged), CARRIED (its in-scope diff changed since, but it counts
|
|
115
|
+
* anyway — staleness never re-reviews, issue #1053, and a human override always wins, issue #1051),
|
|
116
|
+
* STALE (a red whose in-scope diff changed: it still refuses) or REJECTED (no bin provenance, or edited
|
|
117
|
+
* after submission — it is not a review, and is left OUT of `results` so it is owed like one that never
|
|
118
|
+
* ran). Empty under suppression.
|
|
120
119
|
*/
|
|
121
120
|
standings: VerdictStanding[];
|
|
122
121
|
/** checklist id → ChecklistScopeHasher's hash of its in-scope diff NOW. Recorded in the stage-② receipt. */
|
|
123
122
|
scopeHashes: Record<string, string>;
|
|
123
|
+
/**
|
|
124
|
+
* The checklists this diff matches NOW that were never briefed, because a review round had already
|
|
125
|
+
* started when a later commit first triggered them (issue #1053). The checklist set is FROZEN at the
|
|
126
|
+
* briefing, so these never block and are never owed a reviewer: the dashboard names them on one
|
|
127
|
+
* informational line. Empty before any round starts, and under suppression.
|
|
128
|
+
*/
|
|
129
|
+
notBriefed: RequiredChecklist[];
|
|
130
|
+
/**
|
|
131
|
+
* checklist id → the dashboard stamp of every ORANGE whose final-round fix the author recorded (issue
|
|
132
|
+
* #1053). Already folded into `results` (as `remediation`) — carried out so `wp-finish-upsert-pr` hands
|
|
133
|
+
* the identical stamps to its summary.json load, which reads the verdicts afresh.
|
|
134
|
+
*/
|
|
135
|
+
orangeFixes: Record<string, string>;
|
|
124
136
|
constructor(defined: ChecklistDefinition[], applicable: RequiredChecklist[], reviewed: RequiredChecklist[], outstanding: RequiredChecklist[], context: ChecklistReviewContext, summaryPath: string, forkPoint: string, roster: ChecklistRoster, formatErrors: string[], reviewersDisabled: boolean, suppressed: RequiredChecklist[], basis?: DiffBasis, changedFiles?: string[], results?: ChecklistResult[], optionalNotRun?: RequiredChecklist[]);
|
|
125
137
|
}
|
|
138
|
+
/** The checklists a scan JUDGES, and the ones the diff matches that it deliberately does not (#1053). Data-only. */
|
|
139
|
+
export declare class JudgedScope {
|
|
140
|
+
applicable: RequiredChecklist[];
|
|
141
|
+
notBriefed: RequiredChecklist[];
|
|
142
|
+
constructor(applicable: RequiredChecklist[], notBriefed: RequiredChecklist[]);
|
|
143
|
+
}
|
|
126
144
|
/**
|
|
127
145
|
* The ONE computation of which reviewer subagents a branch owes, shared by `wp-review-upsert-pr` (which lists) and
|
|
128
146
|
* `wp-finish-upsert-pr` (which blocks). They previously each assembled this from the same parts in slightly
|
|
@@ -165,30 +183,37 @@ export declare class ChecklistScanner {
|
|
|
165
183
|
* here leaves this a function of its inputs rather than of the filesystem.
|
|
166
184
|
*/
|
|
167
185
|
scan(repoRoot: string, defined: ChecklistDefinition[], opts: ChecklistScanOptions): ChecklistScan;
|
|
186
|
+
/**
|
|
187
|
+
* FROZEN at the briefing (issue #1053): once a review round has started, the checklists this branch owes
|
|
188
|
+
* are the ones that were briefed (still defined, with whatever the current diff matches for each) — never
|
|
189
|
+
* ones a later commit newly triggers, which no round will ever brief. Recomputing them from the current
|
|
190
|
+
* diff is exactly the deadlock that drove an agent to move the review directory aside to get unstuck.
|
|
191
|
+
* Before any round starts, the set is simply what the diff matches.
|
|
192
|
+
*/
|
|
193
|
+
private judgedScope;
|
|
168
194
|
/**
|
|
169
195
|
* Judge every READABLE verdict against its bin provenance and the in-scope diff as it is now. A file
|
|
170
196
|
* with a format problem is left to the format complaint, which names the fix; it is not assessed.
|
|
171
197
|
*/
|
|
172
198
|
private standingsOf;
|
|
173
199
|
/**
|
|
174
|
-
* A STALE
|
|
200
|
+
* A STALE verdict that must NOT be owed again, re-stood as CARRIED with the reason.
|
|
175
201
|
*
|
|
176
|
-
* 1. A human override for the checklist stands. Staleness is judged BEFORE the verdict is
|
|
177
|
-
* without this a stale verdict read as "never ran" and the override written for it was
|
|
178
|
-
* at — the human's in-session decision was shadowed by a hash comparison.
|
|
179
|
-
* 2.
|
|
180
|
-
*
|
|
181
|
-
*
|
|
202
|
+
* 1. A human override for the checklist stands (issue #1051). Staleness is judged BEFORE the verdict is
|
|
203
|
+
* resolved, so without this a stale verdict read as "never ran" and the override written for it was
|
|
204
|
+
* never looked at — the human's in-session decision was shadowed by a hash comparison.
|
|
205
|
+
* 2. Otherwise a green, yellow or orange ALWAYS carries (issue #1053): staleness never triggers a
|
|
206
|
+
* re-review. `maxReviewerRounds` is a hard ceiling, and the only thing that ever opens another round is
|
|
207
|
+
* a RED with a round left — a verdict that went stale because the author kept working is not one.
|
|
182
208
|
*
|
|
183
|
-
* A RED
|
|
184
|
-
*
|
|
209
|
+
* A RED stays STALE: it still refuses, and stage ② re-briefs it while a round remains. A REJECTED verdict
|
|
210
|
+
* is never carried: it is not a review.
|
|
185
211
|
*/
|
|
186
212
|
private carried;
|
|
187
213
|
/**
|
|
188
|
-
* The verdicts that still COUNT
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
* is red.
|
|
214
|
+
* The verdicts that still COUNT: every one except a REJECTED verdict, which is not a review. A stale
|
|
215
|
+
* verdict still counts (see {@link carried}): a stale green, yellow or orange stands, and a stale red
|
|
216
|
+
* still refuses — a refusal is not lifted by changing other code in its scope.
|
|
192
217
|
*/
|
|
193
218
|
private liveResults;
|
|
194
219
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ChecklistScanner = exports.ChecklistScan = exports.ChecklistScanOptions = void 0;
|
|
3
|
+
exports.ChecklistScanner = exports.JudgedScope = exports.ChecklistScan = exports.ChecklistScanOptions = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const rules_config_1 = require("@webpieces/rules-config");
|
|
6
6
|
const inversify_1 = require("inversify");
|
|
@@ -35,9 +35,9 @@ class ChecklistScanOptions {
|
|
|
35
35
|
*/
|
|
36
36
|
contextStage;
|
|
37
37
|
/**
|
|
38
|
-
* `commands.pr-gate.maxReviewerRounds`, as the caller's validated config states it. REQUIRED and first
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* `commands.pr-gate.maxReviewerRounds`, as the caller's validated config states it. REQUIRED and first,
|
|
39
|
+
* so a scan always states the budget its CARRIED verdicts were judged under (issue #1053: a stale green
|
|
40
|
+
* or yellow is carried whatever round it came from, and the reason names the budget).
|
|
41
41
|
*/
|
|
42
42
|
maxReviewerRounds;
|
|
43
43
|
constructor(maxReviewerRounds, filterAlreadyReviewed = false, contextStage = 'stage-scan') {
|
|
@@ -57,7 +57,7 @@ exports.ChecklistScanOptions = ChecklistScanOptions;
|
|
|
57
57
|
class ChecklistScan {
|
|
58
58
|
defined; // X
|
|
59
59
|
applicable; // N
|
|
60
|
-
reviewed; // N − Z: already have a passing/warned/overridden
|
|
60
|
+
reviewed; // N − Z: already have a passing/warned/overridden verdict
|
|
61
61
|
outstanding; // Z (== applicable when not filtering)
|
|
62
62
|
context; // fork-point sha + pr-context.json path
|
|
63
63
|
summaryPath; // the branch's summary.json; verdict files sit beside it
|
|
@@ -127,16 +127,28 @@ class ChecklistScan {
|
|
|
127
127
|
suppressed;
|
|
128
128
|
/**
|
|
129
129
|
* How every EXISTING verdict file stands (issue #863): CURRENT (submitted through `wp-write-review` and
|
|
130
|
-
* its checklist's in-scope diff is unchanged
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* Empty under suppression.
|
|
130
|
+
* its checklist's in-scope diff is unchanged), CARRIED (its in-scope diff changed since, but it counts
|
|
131
|
+
* anyway — staleness never re-reviews, issue #1053, and a human override always wins, issue #1051),
|
|
132
|
+
* STALE (a red whose in-scope diff changed: it still refuses) or REJECTED (no bin provenance, or edited
|
|
133
|
+
* after submission — it is not a review, and is left OUT of `results` so it is owed like one that never
|
|
134
|
+
* ran). Empty under suppression.
|
|
136
135
|
*/
|
|
137
136
|
standings;
|
|
138
137
|
/** checklist id → ChecklistScopeHasher's hash of its in-scope diff NOW. Recorded in the stage-② receipt. */
|
|
139
138
|
scopeHashes;
|
|
139
|
+
/**
|
|
140
|
+
* The checklists this diff matches NOW that were never briefed, because a review round had already
|
|
141
|
+
* started when a later commit first triggered them (issue #1053). The checklist set is FROZEN at the
|
|
142
|
+
* briefing, so these never block and are never owed a reviewer: the dashboard names them on one
|
|
143
|
+
* informational line. Empty before any round starts, and under suppression.
|
|
144
|
+
*/
|
|
145
|
+
notBriefed;
|
|
146
|
+
/**
|
|
147
|
+
* checklist id → the dashboard stamp of every ORANGE whose final-round fix the author recorded (issue
|
|
148
|
+
* #1053). Already folded into `results` (as `remediation`) — carried out so `wp-finish-upsert-pr` hands
|
|
149
|
+
* the identical stamps to its summary.json load, which reads the verdicts afresh.
|
|
150
|
+
*/
|
|
151
|
+
orangeFixes;
|
|
140
152
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
141
153
|
constructor(defined, applicable, reviewed, outstanding, context, summaryPath, forkPoint, roster, formatErrors,
|
|
142
154
|
// REQUIRED, and placed BEFORE the defaulted tail deliberately. A defaulted `reviewersDisabled =
|
|
@@ -164,9 +176,21 @@ class ChecklistScan {
|
|
|
164
176
|
this.optionalNotRun = optionalNotRun;
|
|
165
177
|
this.standings = [];
|
|
166
178
|
this.scopeHashes = {};
|
|
179
|
+
this.notBriefed = [];
|
|
180
|
+
this.orangeFixes = {};
|
|
167
181
|
}
|
|
168
182
|
}
|
|
169
183
|
exports.ChecklistScan = ChecklistScan;
|
|
184
|
+
/** The checklists a scan JUDGES, and the ones the diff matches that it deliberately does not (#1053). Data-only. */
|
|
185
|
+
class JudgedScope {
|
|
186
|
+
applicable;
|
|
187
|
+
notBriefed;
|
|
188
|
+
constructor(applicable, notBriefed) {
|
|
189
|
+
this.applicable = applicable;
|
|
190
|
+
this.notBriefed = notBriefed;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
exports.JudgedScope = JudgedScope;
|
|
170
194
|
/**
|
|
171
195
|
* The ONE computation of which reviewer subagents a branch owes, shared by `wp-review-upsert-pr` (which lists) and
|
|
172
196
|
* `wp-finish-upsert-pr` (which blocks). They previously each assembled this from the same parts in slightly
|
|
@@ -250,12 +274,15 @@ let ChecklistScanner = class ChecklistScanner {
|
|
|
250
274
|
// WHAT was suppressed, which is the difference between an honest record and a silent one.
|
|
251
275
|
return new ChecklistScan(defined, [], [], [], context, summaryPath, base, roster, [], true, matched, basis, changedFiles, [], []);
|
|
252
276
|
}
|
|
253
|
-
const
|
|
277
|
+
const judged = this.judgedScope(repoRoot, summaryPath, roster, matched);
|
|
278
|
+
const applicable = judged.applicable;
|
|
254
279
|
const scopeHashes = this.scopeHasher.hashes(repoRoot, basis, applicable);
|
|
255
280
|
const loaded = this.reviewJsonService.loadChecklistResults(summaryPath, applicable);
|
|
256
|
-
const
|
|
281
|
+
const orangeFixes = this.rounds.orangeFixes(repoRoot, summaryPath, loaded);
|
|
282
|
+
for (const result of loaded)
|
|
283
|
+
result.remediation = orangeFixes[result.id] ?? '';
|
|
257
284
|
const standings = this.standingsOf(summaryPath, loaded, scopeHashes)
|
|
258
|
-
.map((s) => this.carried(s, loaded,
|
|
285
|
+
.map((s) => this.carried(s, loaded, opts.maxReviewerRounds));
|
|
259
286
|
const results = this.liveResults(loaded, standings);
|
|
260
287
|
const stillOwed = this.reviewJsonService.pendingChecklists(applicable, results);
|
|
261
288
|
const owedIds = new Set(stillOwed.map((r) => r.id));
|
|
@@ -267,8 +294,26 @@ let ChecklistScanner = class ChecklistScanner {
|
|
|
267
294
|
const scan = new ChecklistScan(defined, applicable, reviewed, opts.filterAlreadyReviewed ? this.blocking(stillOwed, optionalNotRun) : applicable, context, summaryPath, base, roster, this.reviewJsonService.checklistFormatErrors(applicable, results), false, [], basis, changedFiles, results, optionalNotRun);
|
|
268
295
|
scan.standings = standings;
|
|
269
296
|
scan.scopeHashes = scopeHashes;
|
|
297
|
+
scan.notBriefed = judged.notBriefed;
|
|
298
|
+
scan.orangeFixes = orangeFixes;
|
|
270
299
|
return scan;
|
|
271
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* FROZEN at the briefing (issue #1053): once a review round has started, the checklists this branch owes
|
|
303
|
+
* are the ones that were briefed (still defined, with whatever the current diff matches for each) — never
|
|
304
|
+
* ones a later commit newly triggers, which no round will ever brief. Recomputing them from the current
|
|
305
|
+
* diff is exactly the deadlock that drove an agent to move the review directory aside to get unstuck.
|
|
306
|
+
* Before any round starts, the set is simply what the diff matches.
|
|
307
|
+
*/
|
|
308
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
309
|
+
judgedScope(repoRoot, summaryPath, roster, matched) {
|
|
310
|
+
const receipt = this.receipts.read(repoRoot, this.aiBranchName.getFeatureName());
|
|
311
|
+
if (!this.rounds.roundStarted(summaryPath, receipt))
|
|
312
|
+
return new JudgedScope(matched, []);
|
|
313
|
+
const briefedIds = new Set(this.rounds.briefedChecklistIds(summaryPath, receipt));
|
|
314
|
+
const briefed = roster.entries.filter((t) => briefedIds.has(t.def.id));
|
|
315
|
+
return new JudgedScope(this.checklistDetector.toRequired(briefed), matched.filter((r) => !briefedIds.has(r.id)));
|
|
316
|
+
}
|
|
272
317
|
/**
|
|
273
318
|
* Judge every READABLE verdict against its bin provenance and the in-scope diff as it is now. A file
|
|
274
319
|
* with a format problem is left to the format complaint, which names the fix; it is not assessed.
|
|
@@ -280,41 +325,39 @@ let ChecklistScanner = class ChecklistScanner {
|
|
|
280
325
|
.map((r) => this.verdictProvenance.assess(summaryPath, r, scopeHashes[r.id] ?? ''));
|
|
281
326
|
}
|
|
282
327
|
/**
|
|
283
|
-
* A STALE
|
|
328
|
+
* A STALE verdict that must NOT be owed again, re-stood as CARRIED with the reason.
|
|
284
329
|
*
|
|
285
|
-
* 1. A human override for the checklist stands. Staleness is judged BEFORE the verdict is
|
|
286
|
-
* without this a stale verdict read as "never ran" and the override written for it was
|
|
287
|
-
* at — the human's in-session decision was shadowed by a hash comparison.
|
|
288
|
-
* 2.
|
|
289
|
-
*
|
|
290
|
-
*
|
|
330
|
+
* 1. A human override for the checklist stands (issue #1051). Staleness is judged BEFORE the verdict is
|
|
331
|
+
* resolved, so without this a stale verdict read as "never ran" and the override written for it was
|
|
332
|
+
* never looked at — the human's in-session decision was shadowed by a hash comparison.
|
|
333
|
+
* 2. Otherwise a green, yellow or orange ALWAYS carries (issue #1053): staleness never triggers a
|
|
334
|
+
* re-review. `maxReviewerRounds` is a hard ceiling, and the only thing that ever opens another round is
|
|
335
|
+
* a RED with a round left — a verdict that went stale because the author kept working is not one.
|
|
291
336
|
*
|
|
292
|
-
* A RED
|
|
293
|
-
*
|
|
337
|
+
* A RED stays STALE: it still refuses, and stage ② re-briefs it while a round remains. A REJECTED verdict
|
|
338
|
+
* is never carried: it is not a review.
|
|
294
339
|
*/
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if (s.standing !== verdict_provenance_1.STANDING_STALE || s.status === rules_config_1.VERDICT_RED)
|
|
340
|
+
carried(s, loaded, maxRounds) {
|
|
341
|
+
if (s.standing !== verdict_provenance_1.STANDING_STALE)
|
|
298
342
|
return s;
|
|
299
343
|
const result = loaded.find((r) => r.id === s.checklistId);
|
|
300
344
|
const override = result?.override ?? null;
|
|
301
345
|
if (override !== null && override.problem === '') {
|
|
302
346
|
return new verdict_provenance_1.VerdictStanding(s.checklistId, verdict_provenance_1.STANDING_CARRIED, s.status, s.fromSha, `${s.reason}, but a human override (authorized by ${override.authorizedBy}) stands — the verdict counts`);
|
|
303
347
|
}
|
|
304
|
-
if (
|
|
348
|
+
if (s.status === rules_config_1.VERDICT_RED)
|
|
305
349
|
return s;
|
|
306
|
-
return new verdict_provenance_1.VerdictStanding(s.checklistId, verdict_provenance_1.STANDING_CARRIED, s.status, s.fromSha, `${s.reason}; CARRIED FORWARD without re-review —
|
|
307
|
-
+
|
|
350
|
+
return new verdict_provenance_1.VerdictStanding(s.checklistId, verdict_provenance_1.STANDING_CARRIED, s.status, s.fromSha, `${s.reason}; CARRIED FORWARD without re-review — a ${s.status} verdict stands whatever round it came from, `
|
|
351
|
+
+ `and only a red opens another of the ${maxRounds} allowed round(s)`);
|
|
308
352
|
}
|
|
309
353
|
/**
|
|
310
|
-
* The verdicts that still COUNT
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
* is red.
|
|
354
|
+
* The verdicts that still COUNT: every one except a REJECTED verdict, which is not a review. A stale
|
|
355
|
+
* verdict still counts (see {@link carried}): a stale green, yellow or orange stands, and a stale red
|
|
356
|
+
* still refuses — a refusal is not lifted by changing other code in its scope.
|
|
314
357
|
*/
|
|
315
358
|
liveResults(loaded, standings) {
|
|
316
359
|
const dropped = new Set(standings
|
|
317
|
-
.filter((s) => s.standing === verdict_provenance_1.STANDING_REJECTED
|
|
360
|
+
.filter((s) => s.standing === verdict_provenance_1.STANDING_REJECTED)
|
|
318
361
|
.map((s) => s.checklistId));
|
|
319
362
|
return loaded.filter((r) => !dropped.has(r.id));
|
|
320
363
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checklist-scanner.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/checklist-scanner.ts"],"names":[],"mappings":";;;;AAAA,0DAGiC;AACjC,yCAA2D;AAC3D,iEAAsD;AACtD,6DAA0E;AAC1E,6CAA4D;AAC5D,2DAAsD;AACtD,qEAAgE;AAChE,6DAE8B;AAC9B,iEAAmE;AACnE,6DAA+D;AAE/D,uEAAuE;AACvE,MAAa,oBAAoB;IAC7B;;;;OAIG;IACH,qBAAqB,CAAU;IAC/B;;;;;;;;;;;;OAYG;IACH,YAAY,CAAS;IACrB;;;;OAIG;IACH,iBAAiB,CAAS;IAE1B,YAAY,iBAAyB,EAAE,qBAAqB,GAAG,KAAK,EAAE,YAAY,GAAG,YAAY;QAC7F,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,YAAY,GAA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C,SAAS,CAAC;6CAGF,mCAAY;QACP,sCAAiB;QACzB,wBAAS;QACD,8BAAiB;QACnB,mCAAe;QACb,gCAAiB;QAGxB,gCAAiB;QAChB,6CAAoB;QACd,6CAAwB;QACjC,gDAAyB;QAC3B,4CAAuB;GAd3C,gBAAgB,CAkL5B","sourcesContent":["import {\n ChangedFilesOptions, ChecklistDefinition, ChecklistResult, ChecklistReviewContext, DiffScope,\n HomeConfigService, RequiredChecklist, ReviewJsonService, VERDICT_RED, summaryJsonPath,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from './git-readAiBranchName';\nimport { ChecklistDetector, ChecklistRoster } from './checklist-detector';\nimport { DiffBasis, DiffBasisResolver } from './diff-basis';\nimport { PrContextWriter } from './pr-context-writer';\nimport { ChecklistScopeHasher } from './checklist-scope-hasher';\nimport {\n STANDING_CARRIED, STANDING_REJECTED, STANDING_STALE, VerdictProvenanceService, VerdictStanding,\n} from './verdict-provenance';\nimport { ReviewStageReceiptService } from './review-stage-receipt';\nimport { ReviewRoundStateService } from './review-round-state';\n\n/** How a caller wants the scan filtered. Data-only (per CLAUDE.md). */\nexport class ChecklistScanOptions {\n /**\n * false — `outstanding` is every applicable checklist (what `wp-review-upsert-pr` LISTS).\n * true — `outstanding` drops the ones already carrying a passing/overridden verdict, leaving only what\n * still owes review (what `wp-finish-upsert-pr` BLOCKS on).\n */\n filterAlreadyReviewed: boolean;\n /**\n * Which per-stage snapshot this scan should persist ('stage3-finish', …), or '' for \"do not write\n * pr-context.json here\".\n *\n * '' exists for stage ②, which cannot write yet: the context records `diffDir`, and the diff has not\n * been materialized at scan time. Letting the scan write anyway meant stage ② wrote the file twice,\n * ~60 lines apart, the first time with an empty diffDir. Now it writes once, after materializing.\n *\n * The DEFAULT is deliberately non-empty, so writing is what you get by NOT thinking about it. A\n * reviewer block that lost its diff command because nobody had written pr-context.json is a bug this\n * codebase has already shipped once (see PrContextWriter's docstring); opting out must be an explicit,\n * visible act by a caller that takes responsibility for writing it later — not an omission.\n */\n contextStage: string;\n /**\n * `commands.pr-gate.maxReviewerRounds`, as the caller's validated config states it. REQUIRED and first:\n * once the budget is spent a STALE green or yellow is CARRIED rather than owed (issue #1051), so a scan\n * that did not know the budget would demand a review round the gate will never brief.\n */\n maxReviewerRounds: number;\n\n constructor(maxReviewerRounds: number, filterAlreadyReviewed = false, contextStage = 'stage-scan') {\n this.maxReviewerRounds = maxReviewerRounds;\n this.filterAlreadyReviewed = filterAlreadyReviewed;\n this.contextStage = contextStage;\n }\n}\n\n/**\n * The answer to \"what review does this branch owe?\", in the X → N → Z terms the commands report:\n * X = `defined` — every checklist in pr-gate.checklists\n * N = `applicable` — those whose patterns matched (or that have no patterns, so always run)\n * Z = `outstanding` — of N, those still owing a verdict (only when filterAlreadyReviewed)\n * Data-only.\n */\nexport class ChecklistScan {\n defined: ChecklistDefinition[]; // X\n applicable: RequiredChecklist[]; // N\n reviewed: RequiredChecklist[]; // N − Z: already have a passing/warned/overridden review-<id>.json\n outstanding: RequiredChecklist[]; // Z (== applicable when not filtering)\n context: ChecklistReviewContext; // fork-point sha + pr-context.json path\n summaryPath: string; // the branch's summary.json; verdict files sit beside it\n forkPoint: string; // '' when no fork point resolved\n // ALL X, matched or not, with why — what the PR comment publishes as its roster. Skipped checklists are\n // absent from `applicable` by construction, and recovering them downstream would mean a second\n // changed-file computation with different semantics (see the class comment).\n roster: ChecklistRoster;\n // Verdict files that exist but cannot be read as a verdict (e.g. still using the removed `success`).\n // Carried on the SCAN because wp-finish-upsert-pr refuses on missing reviewers before it ever parses\n // summary.json — a complaint raised only in there would never reach the AI.\n formatErrors: string[];\n /**\n * The basis the matching ACTUALLY ran against. Carried out so a caller that materializes the diff\n * (stage ②) reuses the identical range instead of resolving its own — two independent resolutions is\n * exactly how the changed-file set and the printed `git diff` command came to disagree.\n */\n basis: DiffBasis;\n changedFiles: string[]; // the full changed-file set the matching ran against\n /**\n * The verdict files the scan ALREADY read, carried out rather than dropped.\n *\n * `outstanding` answers \"who still owes a verdict?\" but not \"why\" — and the two reasons demand opposite\n * actions from the reader: a reviewer that never ran must be SPAWNED, a reviewer that ran and REFUSED\n * must not be (it will refuse again; the finding has to be fixed first). Telling them apart means\n * resolving each checklist's verdict, and without the results here every caller either re-reads the same\n * files off disk — a second read that can disagree with this one — or merges the two cases into one\n * message, which is exactly the loop this field exists to break.\n */\n results: ChecklistResult[];\n /**\n * The OPTIONAL (`required: false`) applicable checklists carrying no verdict file — i.e. nobody ran them.\n *\n * Deliberately NOT in `outstanding` when filtering: that is the exemption that makes `required: false`\n * mean something. Carried out as its own set rather than merely subtracted, because both readers need it\n * BY NAME and neither can recover it from what is left: stage ② offers exactly these to the human, and\n * the PR dashboard must publish them as \"not run\" rather than let a shorter roster imply everything\n * passed. An optional checklist that ran and went RED is absent from here and stays in `outstanding`.\n */\n optionalNotRun: RequiredChecklist[];\n /**\n * TRUE when either this machine's `experimental.turnOffAllReviewers` switch is on or the project sets\n * `commands.pr-gate.reviewerAgents: 0`, and therefore when `applicable`, `reviewed`,\n * `outstanding`, `results`, `optionalNotRun` and `formatErrors` above are ALL EMPTY BY DECREE rather\n * than because nothing matched. Those two states are indistinguishable from the empty lists alone,\n * and telling them apart is the entire reason this field exists: an unreviewed PR must never render\n * as a reviewed one.\n *\n * `defined`, `roster`, `basis`, `changedFiles` and `context` are deliberately left INTACT under\n * suppression, so every reader can still say WHAT was switched off — including which REQUIRED\n * checklists would otherwise have run.\n *\n * See `HOME_KEY_TURN_OFF_ALL_REVIEWERS` in rules-config for the flag's contract; it is an\n * `experimental.*` flag, so only a human ever ends it.\n */\n reviewersDisabled: boolean;\n /**\n * The checklists that WOULD have been `applicable` had the reviewers not been suppressed — required\n * ones included. EMPTY on every ordinary run, and empty is not ambiguous there because\n * `reviewersDisabled` is false.\n *\n * Carried by NAME and not as a count because every reader needs a different slice of it: stage ②\n * prints them so a human can see exactly which required reviewer was killed, the dashboard names them\n * in the 1st comment, and the compact PR body needs only `.length`. Recomputing any of that\n * downstream would mean a second changed-file computation that can disagree with this one.\n */\n suppressed: RequiredChecklist[];\n /**\n * How every EXISTING verdict file stands (issue #863): CURRENT (submitted through `wp-write-review` and\n * its checklist's in-scope diff is unchanged — it carries), STALE (in-scope diff changed since — re-brief)\n * or REJECTED (no bin provenance, or edited after submission — it is not a review). A REJECTED verdict,\n * and a STALE green or yellow one, is left OUT of `results`, so it is owed like one that never ran; a\n * stale RED stays in `results` and keeps refusing. CARRIED (issue #1051) is a green or yellow that would\n * be STALE but still counts — the reviewer-round budget is spent, or a human override for it stands.\n * Empty under suppression.\n */\n standings: VerdictStanding[];\n /** checklist id → ChecklistScopeHasher's hash of its in-scope diff NOW. Recorded in the stage-② receipt. */\n scopeHashes: Record<string, string>;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n defined: ChecklistDefinition[],\n applicable: RequiredChecklist[],\n reviewed: RequiredChecklist[],\n outstanding: RequiredChecklist[],\n context: ChecklistReviewContext,\n summaryPath: string,\n forkPoint: string,\n roster: ChecklistRoster,\n formatErrors: string[],\n // REQUIRED, and placed BEFORE the defaulted tail deliberately. A defaulted `reviewersDisabled =\n // false` would let every existing construction keep compiling while asserting, silently, that no\n // reviewer was switched off — the widening-by-omission `.claude/rules/no-backwards-compat.md`\n // rejects, and on the one field whose whole job is to stop an unreviewed PR reading as reviewed.\n reviewersDisabled: boolean,\n suppressed: RequiredChecklist[],\n basis: DiffBasis = new DiffBasis(),\n changedFiles: string[] = [],\n // Defaulted so a caller that only cares about the X/N/Z counts (and every existing test construction)\n // stays a one-liner; the scanner itself always passes the real set.\n results: ChecklistResult[] = [],\n optionalNotRun: RequiredChecklist[] = [],\n ) {\n this.defined = defined;\n this.applicable = applicable;\n this.reviewed = reviewed;\n this.outstanding = outstanding;\n this.context = context;\n this.summaryPath = summaryPath;\n this.forkPoint = forkPoint;\n this.roster = roster;\n this.formatErrors = formatErrors;\n this.reviewersDisabled = reviewersDisabled;\n this.suppressed = suppressed;\n this.basis = basis;\n this.changedFiles = changedFiles;\n this.results = results;\n this.optionalNotRun = optionalNotRun;\n this.standings = [];\n this.scopeHashes = {};\n }\n}\n\n/**\n * The ONE computation of which reviewer subagents a branch owes, shared by `wp-review-upsert-pr` (which lists) and\n * `wp-finish-upsert-pr` (which blocks). They previously each assembled this from the same parts in slightly\n * different ways, and any divergence means the command that reports and the command that gates disagree.\n *\n * Two properties are deliberate and load-bearing:\n *\n * 1. **The base is the FORK POINT of main, computed directly** — never `DiffScope.resolveBase`, which\n * overlays `NX_BASE`/`NX_HEAD` from the environment. That made review coverage depend on an env var.\n * It now arrives via {@link DiffBasisResolver}, which injects ForkPoint; same sha, one resolution.\n * 2. **UNCOMMITTED work counts.** `getChangedFiles` is called with NO head, which is the branch of it that\n * diffs base → WORKING TREE and unions in untracked files. Passing a head would diff commit-to-commit and\n * silently miss staged, unstaged and untracked changes — so a checklist matching only uncommitted files\n * would never fire and its reviewer would never be listed.\n * 3. **The range and the command it prints are the SAME basis.** Property 2 used to be true of the file set\n * only: reviewers were handed `git diff <base> HEAD`, which on a dirty tree covers a different range and\n * prints nothing. Both now derive from one {@link DiffBasis}, carried on the scan so a materializing\n * caller cannot re-resolve and drift.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ChecklistScanner {\n constructor(\n private readonly aiBranchName: AiBranchName,\n private readonly checklistDetector: ChecklistDetector,\n private readonly diffScope: DiffScope,\n private readonly diffBasisResolver: DiffBasisResolver,\n private readonly prContextWriter: PrContextWriter,\n private readonly reviewJsonService: ReviewJsonService,\n // Injected BY TYPE (no Symbol token, per CLAUDE.md) so the ONE reviewer kill switch is read in the\n // ONE place that computes what a branch owes — see the suppression note on `scan`.\n private readonly homeConfig: HomeConfigService,\n private readonly scopeHasher: ChecklistScopeHasher,\n private readonly verdictProvenance: VerdictProvenanceService,\n private readonly receipts: ReviewStageReceiptService,\n private readonly rounds: ReviewRoundStateService,\n ) {}\n\n /**\n * `defined` is the caller's ALREADY-VALIDATED `prGate.checklists`. The scanner deliberately does not load\n * config itself: `loadAndValidate` is the one gate on the checklist set (it rejects a non-array\n * `checklists`, including the removed `{ doc }` manifest shape, and verifies every guidance doc and\n * reviewer-agent file exists), both callers already run it for other fields, and keeping the read out of\n * here leaves this a function of its inputs rather than of the filesystem.\n */\n scan(repoRoot: string, defined: ChecklistDefinition[], opts: ChecklistScanOptions): ChecklistScan {\n const featureName = this.aiBranchName.getFeatureName();\n const summaryPath = summaryJsonPath(repoRoot, featureName);\n // ONE basis for the file set, the reproduce command and any downstream materialization. The fork\n // point still comes from ForkPoint (never DiffScope.resolveBase) — DiffBasisResolver injects it.\n const basis = this.diffBasisResolver.resolve(repoRoot);\n const base = basis.base;\n // ONE changed-file computation feeds both the roster (all X) and the applicable set (N). `detect` is\n // pure and defined as the roster minus its empty entries, so the two cannot disagree about a match.\n const changedFiles = this.changedFiles(repoRoot, base);\n const roster = new ChecklistRoster(\n this.checklistDetector.roster(defined, changedFiles), changedFiles.length, base !== '');\n const matched = this.checklistDetector.toRequired(this.checklistDetector.detect(defined, changedFiles));\n // THE ONE CHOKE POINT for both reviewer opt-outs. Suppressing HERE — rather than in\n // `wp-review-upsert-pr` and again in `wp-finish-upsert-pr` — is what keeps the command that LISTS\n // and the command that BLOCKS in agreement by construction, which is this class's whole reason for\n // existing. A second check in either command would be a second answer to one question.\n const context = opts.contextStage === ''\n ? this.prContextWriter.contextFor(repoRoot, featureName, basis)\n : this.prContextWriter.ensure(repoRoot, featureName, basis, opts.contextStage, changedFiles);\n const homeConfig = this.homeConfig.load();\n const projectDisabled = defined.some((d: ChecklistDefinition): boolean => d.reviewer.maxAgents === 0);\n if (homeConfig.turnOffAllReviewers || projectDisabled) {\n // EMPTY: applicable, reviewed, outstanding, formatErrors, results, optionalNotRun. INTACT:\n // defined, roster, basis, changedFiles, context — so every downstream reader can still say\n // WHAT was suppressed, which is the difference between an honest record and a silent one.\n return new ChecklistScan(\n defined, [], [], [], context, summaryPath, base, roster, [], true, matched, basis,\n changedFiles, [], []);\n }\n const applicable = matched;\n const scopeHashes = this.scopeHasher.hashes(repoRoot, basis, applicable);\n const loaded = this.reviewJsonService.loadChecklistResults(summaryPath, applicable);\n const capSpent = this.rounds.capSpent(summaryPath, this.receipts.read(repoRoot, featureName), opts.maxReviewerRounds);\n const standings = this.standingsOf(summaryPath, loaded, scopeHashes)\n .map((s: VerdictStanding): VerdictStanding => this.carried(s, loaded, capSpent, opts.maxReviewerRounds));\n const results = this.liveResults(loaded, standings);\n const stillOwed = this.reviewJsonService.pendingChecklists(applicable, results);\n const owedIds = new Set(stillOwed.map((r: RequiredChecklist): string => r.id));\n // NOT `!owedIds.has(...)`-with-the-optional-exemption-folded-in: an optional checklist nobody ran is\n // neither reviewed nor blocking, and calling it \"reviewed\" would put a ✓ on the dashboard for a review\n // that never happened.\n const reviewed = applicable.filter((r: RequiredChecklist): boolean => !owedIds.has(r.id));\n const optionalNotRun = this.reviewJsonService.optionalWithoutVerdict(applicable, results);\n const scan = new ChecklistScan(\n defined,\n applicable,\n reviewed,\n opts.filterAlreadyReviewed ? this.blocking(stillOwed, optionalNotRun) : applicable,\n context,\n summaryPath,\n base,\n roster,\n this.reviewJsonService.checklistFormatErrors(applicable, results),\n false,\n [],\n basis,\n changedFiles,\n results,\n optionalNotRun,\n );\n scan.standings = standings;\n scan.scopeHashes = scopeHashes;\n return scan;\n }\n\n /**\n * Judge every READABLE verdict against its bin provenance and the in-scope diff as it is now. A file\n * with a format problem is left to the format complaint, which names the fix; it is not assessed.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private standingsOf(\n summaryPath: string, loaded: readonly ChecklistResult[], scopeHashes: Record<string, string>,\n ): VerdictStanding[] {\n return loaded\n .filter((r: ChecklistResult): boolean => r.problem === '')\n .map((r: ChecklistResult): VerdictStanding =>\n this.verdictProvenance.assess(summaryPath, r, scopeHashes[r.id] ?? ''));\n }\n\n /**\n * A STALE green or yellow that must NOT be owed again (issue #1051), re-stood as CARRIED with the reason.\n *\n * 1. A human override for the checklist stands. Staleness is judged BEFORE the verdict is resolved, so\n * without this a stale verdict read as \"never ran\" and the override written for it was never looked\n * at — the human's in-session decision was shadowed by a hash comparison.\n * 2. The reviewer-round budget is spent. The round planner never briefs a reviewer again, so a stale\n * verdict demanded here is a review nobody can ever supply: with `maxReviewerRounds: 1`, the author's\n * remediation commit marked every OTHER checklist stale and the branch could not be finished.\n *\n * A RED is never carried here: it keeps refusing until a fresh verdict, a recorded author remediation\n * after the cap, or a human override clears it. A REJECTED verdict is never carried: it is not a review.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private carried(s: VerdictStanding, loaded: readonly ChecklistResult[], capSpent: boolean, maxRounds: number): VerdictStanding {\n if (s.standing !== STANDING_STALE || s.status === VERDICT_RED) return s;\n const result = loaded.find((r: ChecklistResult): boolean => r.id === s.checklistId);\n const override = result?.override ?? null;\n if (override !== null && override.problem === '') {\n return new VerdictStanding(s.checklistId, STANDING_CARRIED, s.status, s.fromSha,\n `${s.reason}, but a human override (authorized by ${override.authorizedBy}) stands — the verdict counts`);\n }\n if (!capSpent) return s;\n return new VerdictStanding(s.checklistId, STANDING_CARRIED, s.status, s.fromSha,\n `${s.reason}; CARRIED FORWARD without re-review — all ${maxRounds} reviewer round(s) are spent, `\n + 'so no further round runs on this branch');\n }\n\n /**\n * The verdicts that still COUNT. A rejected one never does. A stale green or yellow judged code that\n * has since changed, so it is owed again; a stale RED still refuses — a refusal is not lifted by\n * changing other code in its scope, only by a fresh verdict — and it is re-briefed anyway because it\n * is red.\n */\n private liveResults(loaded: readonly ChecklistResult[], standings: readonly VerdictStanding[]): ChecklistResult[] {\n const dropped = new Set(standings\n .filter((s: VerdictStanding): boolean =>\n s.standing === STANDING_REJECTED || (s.standing === STANDING_STALE && s.status !== VERDICT_RED))\n .map((s: VerdictStanding): string => s.checklistId));\n return loaded.filter((r: ChecklistResult): boolean => !dropped.has(r.id));\n }\n\n /**\n * What `wp-finish-upsert-pr` actually REFUSES on: everything still owing a verdict, minus the optional\n * checklists nobody ran.\n *\n * The subtraction happens HERE — in the one place `outstanding` is computed — and not in the gate, so\n * there is a single answer to \"does this branch owe review?\". When the gate did its own filtering, the\n * command that lists and the command that blocks were two implementations of the same question, which is\n * exactly the divergence this class's docstring exists to prevent.\n */\n private blocking(stillOwed: readonly RequiredChecklist[], optionalNotRun: readonly RequiredChecklist[]): RequiredChecklist[] {\n const skipped = new Set(optionalNotRun.map((r: RequiredChecklist): string => r.id));\n return stillOwed.filter((r: RequiredChecklist): boolean => !skipped.has(r.id));\n }\n\n /**\n * Every file changed since the fork point, INCLUDING uncommitted and untracked ones. Two non-default\n * options, both load-bearing:\n *\n * `tsOnly:false` — the default drops every *.sql / Dockerfile / .env* file a checklist most wants\n * to key on, which would silently shrink the set a reviewer is pointed at.\n * `includeDeletions:true` — the default is `--diff-filter=d`, so a DELETED file is invisible. A PR that\n * deletes a migration, an auth check or a terraform rule changed exactly what a\n * checklist exists to catch, and under the default no checklist fires at all.\n */\n private changedFiles(repoRoot: string, base: string): string[] {\n if (base === '') return [];\n const opts = new ChangedFilesOptions();\n opts.tsOnly = false;\n opts.includeDeletions = true;\n // No head argument — see the class comment. This is what includes the working tree.\n return this.diffScope.getChangedFiles(repoRoot, base, undefined, opts);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"checklist-scanner.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/checklist-scanner.ts"],"names":[],"mappings":";;;;AAAA,0DAGiC;AACjC,yCAA2D;AAC3D,iEAAsD;AACtD,6DAA8F;AAC9F,6CAA4D;AAC5D,2DAAsD;AACtD,qEAAgE;AAChE,6DAE8B;AAC9B,iEAAmE;AACnE,6DAA+D;AAE/D,uEAAuE;AACvE,MAAa,oBAAoB;IAC7B;;;;OAIG;IACH,qBAAqB,CAAU;IAC/B;;;;;;;;;;;;OAYG;IACH,YAAY,CAAS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YAAE,OAAO,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAI,kCAAmB,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,oFAAoF;QACpF,OAAO,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAC3E,CAAC;CACJ,CAAA;AArMY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGF,mCAAY;QACP,sCAAiB;QACzB,wBAAS;QACD,8BAAiB;QACnB,mCAAe;QACb,gCAAiB;QAGxB,gCAAiB;QAChB,6CAAoB;QACd,6CAAwB;QACjC,gDAAyB;QAC3B,4CAAuB;GAd3C,gBAAgB,CAqM5B","sourcesContent":["import {\n ChangedFilesOptions, ChecklistDefinition, ChecklistResult, ChecklistReviewContext, DiffScope,\n HomeConfigService, RequiredChecklist, ReviewJsonService, VERDICT_RED, summaryJsonPath,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from './git-readAiBranchName';\nimport { ChecklistDetector, ChecklistRoster, TriggeredChecklist } from './checklist-detector';\nimport { DiffBasis, DiffBasisResolver } from './diff-basis';\nimport { PrContextWriter } from './pr-context-writer';\nimport { ChecklistScopeHasher } from './checklist-scope-hasher';\nimport {\n STANDING_CARRIED, STANDING_REJECTED, STANDING_STALE, VerdictProvenanceService, VerdictStanding,\n} from './verdict-provenance';\nimport { ReviewStageReceiptService } from './review-stage-receipt';\nimport { ReviewRoundStateService } from './review-round-state';\n\n/** How a caller wants the scan filtered. Data-only (per CLAUDE.md). */\nexport class ChecklistScanOptions {\n /**\n * false — `outstanding` is every applicable checklist (what `wp-review-upsert-pr` LISTS).\n * true — `outstanding` drops the ones already carrying a passing/overridden verdict, leaving only what\n * still owes review (what `wp-finish-upsert-pr` BLOCKS on).\n */\n filterAlreadyReviewed: boolean;\n /**\n * Which per-stage snapshot this scan should persist ('stage3-finish', …), or '' for \"do not write\n * pr-context.json here\".\n *\n * '' exists for stage ②, which cannot write yet: the context records `diffDir`, and the diff has not\n * been materialized at scan time. Letting the scan write anyway meant stage ② wrote the file twice,\n * ~60 lines apart, the first time with an empty diffDir. Now it writes once, after materializing.\n *\n * The DEFAULT is deliberately non-empty, so writing is what you get by NOT thinking about it. A\n * reviewer block that lost its diff command because nobody had written pr-context.json is a bug this\n * codebase has already shipped once (see PrContextWriter's docstring); opting out must be an explicit,\n * visible act by a caller that takes responsibility for writing it later — not an omission.\n */\n contextStage: string;\n /**\n * `commands.pr-gate.maxReviewerRounds`, as the caller's validated config states it. REQUIRED and first,\n * so a scan always states the budget its CARRIED verdicts were judged under (issue #1053: a stale green\n * or yellow is carried whatever round it came from, and the reason names the budget).\n */\n maxReviewerRounds: number;\n\n constructor(maxReviewerRounds: number, filterAlreadyReviewed = false, contextStage = 'stage-scan') {\n this.maxReviewerRounds = maxReviewerRounds;\n this.filterAlreadyReviewed = filterAlreadyReviewed;\n this.contextStage = contextStage;\n }\n}\n\n/**\n * The answer to \"what review does this branch owe?\", in the X → N → Z terms the commands report:\n * X = `defined` — every checklist in pr-gate.checklists\n * N = `applicable` — those whose patterns matched (or that have no patterns, so always run)\n * Z = `outstanding` — of N, those still owing a verdict (only when filterAlreadyReviewed)\n * Data-only.\n */\nexport class ChecklistScan {\n defined: ChecklistDefinition[]; // X\n applicable: RequiredChecklist[]; // N\n reviewed: RequiredChecklist[]; // N − Z: already have a passing/warned/overridden verdict\n outstanding: RequiredChecklist[]; // Z (== applicable when not filtering)\n context: ChecklistReviewContext; // fork-point sha + pr-context.json path\n summaryPath: string; // the branch's summary.json; verdict files sit beside it\n forkPoint: string; // '' when no fork point resolved\n // ALL X, matched or not, with why — what the PR comment publishes as its roster. Skipped checklists are\n // absent from `applicable` by construction, and recovering them downstream would mean a second\n // changed-file computation with different semantics (see the class comment).\n roster: ChecklistRoster;\n // Verdict files that exist but cannot be read as a verdict (e.g. still using the removed `success`).\n // Carried on the SCAN because wp-finish-upsert-pr refuses on missing reviewers before it ever parses\n // summary.json — a complaint raised only in there would never reach the AI.\n formatErrors: string[];\n /**\n * The basis the matching ACTUALLY ran against. Carried out so a caller that materializes the diff\n * (stage ②) reuses the identical range instead of resolving its own — two independent resolutions is\n * exactly how the changed-file set and the printed `git diff` command came to disagree.\n */\n basis: DiffBasis;\n changedFiles: string[]; // the full changed-file set the matching ran against\n /**\n * The verdict files the scan ALREADY read, carried out rather than dropped.\n *\n * `outstanding` answers \"who still owes a verdict?\" but not \"why\" — and the two reasons demand opposite\n * actions from the reader: a reviewer that never ran must be SPAWNED, a reviewer that ran and REFUSED\n * must not be (it will refuse again; the finding has to be fixed first). Telling them apart means\n * resolving each checklist's verdict, and without the results here every caller either re-reads the same\n * files off disk — a second read that can disagree with this one — or merges the two cases into one\n * message, which is exactly the loop this field exists to break.\n */\n results: ChecklistResult[];\n /**\n * The OPTIONAL (`required: false`) applicable checklists carrying no verdict file — i.e. nobody ran them.\n *\n * Deliberately NOT in `outstanding` when filtering: that is the exemption that makes `required: false`\n * mean something. Carried out as its own set rather than merely subtracted, because both readers need it\n * BY NAME and neither can recover it from what is left: stage ② offers exactly these to the human, and\n * the PR dashboard must publish them as \"not run\" rather than let a shorter roster imply everything\n * passed. An optional checklist that ran and went RED is absent from here and stays in `outstanding`.\n */\n optionalNotRun: RequiredChecklist[];\n /**\n * TRUE when either this machine's `experimental.turnOffAllReviewers` switch is on or the project sets\n * `commands.pr-gate.reviewerAgents: 0`, and therefore when `applicable`, `reviewed`,\n * `outstanding`, `results`, `optionalNotRun` and `formatErrors` above are ALL EMPTY BY DECREE rather\n * than because nothing matched. Those two states are indistinguishable from the empty lists alone,\n * and telling them apart is the entire reason this field exists: an unreviewed PR must never render\n * as a reviewed one.\n *\n * `defined`, `roster`, `basis`, `changedFiles` and `context` are deliberately left INTACT under\n * suppression, so every reader can still say WHAT was switched off — including which REQUIRED\n * checklists would otherwise have run.\n *\n * See `HOME_KEY_TURN_OFF_ALL_REVIEWERS` in rules-config for the flag's contract; it is an\n * `experimental.*` flag, so only a human ever ends it.\n */\n reviewersDisabled: boolean;\n /**\n * The checklists that WOULD have been `applicable` had the reviewers not been suppressed — required\n * ones included. EMPTY on every ordinary run, and empty is not ambiguous there because\n * `reviewersDisabled` is false.\n *\n * Carried by NAME and not as a count because every reader needs a different slice of it: stage ②\n * prints them so a human can see exactly which required reviewer was killed, the dashboard names them\n * in the 1st comment, and the compact PR body needs only `.length`. Recomputing any of that\n * downstream would mean a second changed-file computation that can disagree with this one.\n */\n suppressed: RequiredChecklist[];\n /**\n * How every EXISTING verdict file stands (issue #863): CURRENT (submitted through `wp-write-review` and\n * its checklist's in-scope diff is unchanged), CARRIED (its in-scope diff changed since, but it counts\n * anyway — staleness never re-reviews, issue #1053, and a human override always wins, issue #1051),\n * STALE (a red whose in-scope diff changed: it still refuses) or REJECTED (no bin provenance, or edited\n * after submission — it is not a review, and is left OUT of `results` so it is owed like one that never\n * ran). Empty under suppression.\n */\n standings: VerdictStanding[];\n /** checklist id → ChecklistScopeHasher's hash of its in-scope diff NOW. Recorded in the stage-② receipt. */\n scopeHashes: Record<string, string>;\n /**\n * The checklists this diff matches NOW that were never briefed, because a review round had already\n * started when a later commit first triggered them (issue #1053). The checklist set is FROZEN at the\n * briefing, so these never block and are never owed a reviewer: the dashboard names them on one\n * informational line. Empty before any round starts, and under suppression.\n */\n notBriefed: RequiredChecklist[];\n /**\n * checklist id → the dashboard stamp of every ORANGE whose final-round fix the author recorded (issue\n * #1053). Already folded into `results` (as `remediation`) — carried out so `wp-finish-upsert-pr` hands\n * the identical stamps to its summary.json load, which reads the verdicts afresh.\n */\n orangeFixes: Record<string, string>;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n defined: ChecklistDefinition[],\n applicable: RequiredChecklist[],\n reviewed: RequiredChecklist[],\n outstanding: RequiredChecklist[],\n context: ChecklistReviewContext,\n summaryPath: string,\n forkPoint: string,\n roster: ChecklistRoster,\n formatErrors: string[],\n // REQUIRED, and placed BEFORE the defaulted tail deliberately. A defaulted `reviewersDisabled =\n // false` would let every existing construction keep compiling while asserting, silently, that no\n // reviewer was switched off — the widening-by-omission `.claude/rules/no-backwards-compat.md`\n // rejects, and on the one field whose whole job is to stop an unreviewed PR reading as reviewed.\n reviewersDisabled: boolean,\n suppressed: RequiredChecklist[],\n basis: DiffBasis = new DiffBasis(),\n changedFiles: string[] = [],\n // Defaulted so a caller that only cares about the X/N/Z counts (and every existing test construction)\n // stays a one-liner; the scanner itself always passes the real set.\n results: ChecklistResult[] = [],\n optionalNotRun: RequiredChecklist[] = [],\n ) {\n this.defined = defined;\n this.applicable = applicable;\n this.reviewed = reviewed;\n this.outstanding = outstanding;\n this.context = context;\n this.summaryPath = summaryPath;\n this.forkPoint = forkPoint;\n this.roster = roster;\n this.formatErrors = formatErrors;\n this.reviewersDisabled = reviewersDisabled;\n this.suppressed = suppressed;\n this.basis = basis;\n this.changedFiles = changedFiles;\n this.results = results;\n this.optionalNotRun = optionalNotRun;\n this.standings = [];\n this.scopeHashes = {};\n this.notBriefed = [];\n this.orangeFixes = {};\n }\n}\n\n/** The checklists a scan JUDGES, and the ones the diff matches that it deliberately does not (#1053). Data-only. */\nexport class JudgedScope {\n applicable: RequiredChecklist[];\n notBriefed: RequiredChecklist[];\n\n constructor(applicable: RequiredChecklist[], notBriefed: RequiredChecklist[]) {\n this.applicable = applicable;\n this.notBriefed = notBriefed;\n }\n}\n\n/**\n * The ONE computation of which reviewer subagents a branch owes, shared by `wp-review-upsert-pr` (which lists) and\n * `wp-finish-upsert-pr` (which blocks). They previously each assembled this from the same parts in slightly\n * different ways, and any divergence means the command that reports and the command that gates disagree.\n *\n * Two properties are deliberate and load-bearing:\n *\n * 1. **The base is the FORK POINT of main, computed directly** — never `DiffScope.resolveBase`, which\n * overlays `NX_BASE`/`NX_HEAD` from the environment. That made review coverage depend on an env var.\n * It now arrives via {@link DiffBasisResolver}, which injects ForkPoint; same sha, one resolution.\n * 2. **UNCOMMITTED work counts.** `getChangedFiles` is called with NO head, which is the branch of it that\n * diffs base → WORKING TREE and unions in untracked files. Passing a head would diff commit-to-commit and\n * silently miss staged, unstaged and untracked changes — so a checklist matching only uncommitted files\n * would never fire and its reviewer would never be listed.\n * 3. **The range and the command it prints are the SAME basis.** Property 2 used to be true of the file set\n * only: reviewers were handed `git diff <base> HEAD`, which on a dirty tree covers a different range and\n * prints nothing. Both now derive from one {@link DiffBasis}, carried on the scan so a materializing\n * caller cannot re-resolve and drift.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ChecklistScanner {\n constructor(\n private readonly aiBranchName: AiBranchName,\n private readonly checklistDetector: ChecklistDetector,\n private readonly diffScope: DiffScope,\n private readonly diffBasisResolver: DiffBasisResolver,\n private readonly prContextWriter: PrContextWriter,\n private readonly reviewJsonService: ReviewJsonService,\n // Injected BY TYPE (no Symbol token, per CLAUDE.md) so the ONE reviewer kill switch is read in the\n // ONE place that computes what a branch owes — see the suppression note on `scan`.\n private readonly homeConfig: HomeConfigService,\n private readonly scopeHasher: ChecklistScopeHasher,\n private readonly verdictProvenance: VerdictProvenanceService,\n private readonly receipts: ReviewStageReceiptService,\n private readonly rounds: ReviewRoundStateService,\n ) {}\n\n /**\n * `defined` is the caller's ALREADY-VALIDATED `prGate.checklists`. The scanner deliberately does not load\n * config itself: `loadAndValidate` is the one gate on the checklist set (it rejects a non-array\n * `checklists`, including the removed `{ doc }` manifest shape, and verifies every guidance doc and\n * reviewer-agent file exists), both callers already run it for other fields, and keeping the read out of\n * here leaves this a function of its inputs rather than of the filesystem.\n */\n scan(repoRoot: string, defined: ChecklistDefinition[], opts: ChecklistScanOptions): ChecklistScan {\n const featureName = this.aiBranchName.getFeatureName();\n const summaryPath = summaryJsonPath(repoRoot, featureName);\n // ONE basis for the file set, the reproduce command and any downstream materialization. The fork\n // point still comes from ForkPoint (never DiffScope.resolveBase) — DiffBasisResolver injects it.\n const basis = this.diffBasisResolver.resolve(repoRoot);\n const base = basis.base;\n // ONE changed-file computation feeds both the roster (all X) and the applicable set (N). `detect` is\n // pure and defined as the roster minus its empty entries, so the two cannot disagree about a match.\n const changedFiles = this.changedFiles(repoRoot, base);\n const roster = new ChecklistRoster(\n this.checklistDetector.roster(defined, changedFiles), changedFiles.length, base !== '');\n const matched = this.checklistDetector.toRequired(this.checklistDetector.detect(defined, changedFiles));\n // THE ONE CHOKE POINT for both reviewer opt-outs. Suppressing HERE — rather than in\n // `wp-review-upsert-pr` and again in `wp-finish-upsert-pr` — is what keeps the command that LISTS\n // and the command that BLOCKS in agreement by construction, which is this class's whole reason for\n // existing. A second check in either command would be a second answer to one question.\n const context = opts.contextStage === ''\n ? this.prContextWriter.contextFor(repoRoot, featureName, basis)\n : this.prContextWriter.ensure(repoRoot, featureName, basis, opts.contextStage, changedFiles);\n const homeConfig = this.homeConfig.load();\n const projectDisabled = defined.some((d: ChecklistDefinition): boolean => d.reviewer.maxAgents === 0);\n if (homeConfig.turnOffAllReviewers || projectDisabled) {\n // EMPTY: applicable, reviewed, outstanding, formatErrors, results, optionalNotRun. INTACT:\n // defined, roster, basis, changedFiles, context — so every downstream reader can still say\n // WHAT was suppressed, which is the difference between an honest record and a silent one.\n return new ChecklistScan(\n defined, [], [], [], context, summaryPath, base, roster, [], true, matched, basis,\n changedFiles, [], []);\n }\n const judged = this.judgedScope(repoRoot, summaryPath, roster, matched);\n const applicable = judged.applicable;\n const scopeHashes = this.scopeHasher.hashes(repoRoot, basis, applicable);\n const loaded = this.reviewJsonService.loadChecklistResults(summaryPath, applicable);\n const orangeFixes = this.rounds.orangeFixes(repoRoot, summaryPath, loaded);\n for (const result of loaded) result.remediation = orangeFixes[result.id] ?? '';\n const standings = this.standingsOf(summaryPath, loaded, scopeHashes)\n .map((s: VerdictStanding): VerdictStanding => this.carried(s, loaded, opts.maxReviewerRounds));\n const results = this.liveResults(loaded, standings);\n const stillOwed = this.reviewJsonService.pendingChecklists(applicable, results);\n const owedIds = new Set(stillOwed.map((r: RequiredChecklist): string => r.id));\n // NOT `!owedIds.has(...)`-with-the-optional-exemption-folded-in: an optional checklist nobody ran is\n // neither reviewed nor blocking, and calling it \"reviewed\" would put a ✓ on the dashboard for a review\n // that never happened.\n const reviewed = applicable.filter((r: RequiredChecklist): boolean => !owedIds.has(r.id));\n const optionalNotRun = this.reviewJsonService.optionalWithoutVerdict(applicable, results);\n const scan = new ChecklistScan(\n defined,\n applicable,\n reviewed,\n opts.filterAlreadyReviewed ? this.blocking(stillOwed, optionalNotRun) : applicable,\n context,\n summaryPath,\n base,\n roster,\n this.reviewJsonService.checklistFormatErrors(applicable, results),\n false,\n [],\n basis,\n changedFiles,\n results,\n optionalNotRun,\n );\n scan.standings = standings;\n scan.scopeHashes = scopeHashes;\n scan.notBriefed = judged.notBriefed;\n scan.orangeFixes = orangeFixes;\n return scan;\n }\n\n /**\n * FROZEN at the briefing (issue #1053): once a review round has started, the checklists this branch owes\n * are the ones that were briefed (still defined, with whatever the current diff matches for each) — never\n * ones a later commit newly triggers, which no round will ever brief. Recomputing them from the current\n * diff is exactly the deadlock that drove an agent to move the review directory aside to get unstuck.\n * Before any round starts, the set is simply what the diff matches.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private judgedScope(repoRoot: string, summaryPath: string, roster: ChecklistRoster, matched: RequiredChecklist[]): JudgedScope {\n const receipt = this.receipts.read(repoRoot, this.aiBranchName.getFeatureName());\n if (!this.rounds.roundStarted(summaryPath, receipt)) return new JudgedScope(matched, []);\n const briefedIds = new Set(this.rounds.briefedChecklistIds(summaryPath, receipt));\n const briefed = roster.entries.filter((t: TriggeredChecklist): boolean => briefedIds.has(t.def.id));\n return new JudgedScope(\n this.checklistDetector.toRequired(briefed),\n matched.filter((r: RequiredChecklist): boolean => !briefedIds.has(r.id)));\n }\n\n /**\n * Judge every READABLE verdict against its bin provenance and the in-scope diff as it is now. A file\n * with a format problem is left to the format complaint, which names the fix; it is not assessed.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private standingsOf(\n summaryPath: string, loaded: readonly ChecklistResult[], scopeHashes: Record<string, string>,\n ): VerdictStanding[] {\n return loaded\n .filter((r: ChecklistResult): boolean => r.problem === '')\n .map((r: ChecklistResult): VerdictStanding =>\n this.verdictProvenance.assess(summaryPath, r, scopeHashes[r.id] ?? ''));\n }\n\n /**\n * A STALE verdict that must NOT be owed again, re-stood as CARRIED with the reason.\n *\n * 1. A human override for the checklist stands (issue #1051). Staleness is judged BEFORE the verdict is\n * resolved, so without this a stale verdict read as \"never ran\" and the override written for it was\n * never looked at — the human's in-session decision was shadowed by a hash comparison.\n * 2. Otherwise a green, yellow or orange ALWAYS carries (issue #1053): staleness never triggers a\n * re-review. `maxReviewerRounds` is a hard ceiling, and the only thing that ever opens another round is\n * a RED with a round left — a verdict that went stale because the author kept working is not one.\n *\n * A RED stays STALE: it still refuses, and stage ② re-briefs it while a round remains. A REJECTED verdict\n * is never carried: it is not a review.\n */\n private carried(s: VerdictStanding, loaded: readonly ChecklistResult[], maxRounds: number): VerdictStanding {\n if (s.standing !== STANDING_STALE) return s;\n const result = loaded.find((r: ChecklistResult): boolean => r.id === s.checklistId);\n const override = result?.override ?? null;\n if (override !== null && override.problem === '') {\n return new VerdictStanding(s.checklistId, STANDING_CARRIED, s.status, s.fromSha,\n `${s.reason}, but a human override (authorized by ${override.authorizedBy}) stands — the verdict counts`);\n }\n if (s.status === VERDICT_RED) return s;\n return new VerdictStanding(s.checklistId, STANDING_CARRIED, s.status, s.fromSha,\n `${s.reason}; CARRIED FORWARD without re-review — a ${s.status} verdict stands whatever round it came from, `\n + `and only a red opens another of the ${maxRounds} allowed round(s)`);\n }\n\n /**\n * The verdicts that still COUNT: every one except a REJECTED verdict, which is not a review. A stale\n * verdict still counts (see {@link carried}): a stale green, yellow or orange stands, and a stale red\n * still refuses — a refusal is not lifted by changing other code in its scope.\n */\n private liveResults(loaded: readonly ChecklistResult[], standings: readonly VerdictStanding[]): ChecklistResult[] {\n const dropped = new Set(standings\n .filter((s: VerdictStanding): boolean => s.standing === STANDING_REJECTED)\n .map((s: VerdictStanding): string => s.checklistId));\n return loaded.filter((r: ChecklistResult): boolean => !dropped.has(r.id));\n }\n\n /**\n * What `wp-finish-upsert-pr` actually REFUSES on: everything still owing a verdict, minus the optional\n * checklists nobody ran.\n *\n * The subtraction happens HERE — in the one place `outstanding` is computed — and not in the gate, so\n * there is a single answer to \"does this branch owe review?\". When the gate did its own filtering, the\n * command that lists and the command that blocks were two implementations of the same question, which is\n * exactly the divergence this class's docstring exists to prevent.\n */\n private blocking(stillOwed: readonly RequiredChecklist[], optionalNotRun: readonly RequiredChecklist[]): RequiredChecklist[] {\n const skipped = new Set(optionalNotRun.map((r: RequiredChecklist): string => r.id));\n return stillOwed.filter((r: RequiredChecklist): boolean => !skipped.has(r.id));\n }\n\n /**\n * Every file changed since the fork point, INCLUDING uncommitted and untracked ones. Two non-default\n * options, both load-bearing:\n *\n * `tsOnly:false` — the default drops every *.sql / Dockerfile / .env* file a checklist most wants\n * to key on, which would silently shrink the set a reviewer is pointed at.\n * `includeDeletions:true` — the default is `--diff-filter=d`, so a DELETED file is invisible. A PR that\n * deletes a migration, an auth check or a terraform rule changed exactly what a\n * checklist exists to catch, and under the default no checklist fires at all.\n */\n private changedFiles(repoRoot: string, base: string): string[] {\n if (base === '') return [];\n const opts = new ChangedFilesOptions();\n opts.tsOnly = false;\n opts.includeDeletions = true;\n // No head argument — see the class comment. This is what includes the working tree.\n return this.diffScope.getChangedFiles(repoRoot, base, undefined, opts);\n }\n}\n"]}
|
|
@@ -41,7 +41,7 @@ export declare class ProvenanceEnforcer {
|
|
|
41
41
|
private gitOut;
|
|
42
42
|
enforce(required: readonly RequiredChecklist[], branch: string, repoRoot: string, config: PrGateConfig): ProvenanceReport;
|
|
43
43
|
/**
|
|
44
|
-
* Evidence from `review
|
|
44
|
+
* Evidence from `review-round<N>-<id>.provenance.json` when there are no Claude transcripts to read: the harness,
|
|
45
45
|
* session and agent `wp-write-review` recorded. Read-counters stay at zero — the bin cannot know them.
|
|
46
46
|
*/
|
|
47
47
|
private binEvidence;
|
|
@@ -108,7 +108,7 @@ export declare class ProvenanceEnforcer {
|
|
|
108
108
|
* must be comparing a dash-form name against a slash-form git branch — see
|
|
109
109
|
* ProvenanceWriteRequest.featureSlug, whose field carried the same mislabel.
|
|
110
110
|
*
|
|
111
|
-
* A SEPARATE file rather than a field inside summary.json / review
|
|
111
|
+
* A SEPARATE file rather than a field inside summary.json / review-round<N>-<id>.json, for two reasons. The
|
|
112
112
|
* reviewer cannot supply this itself — a subagent's environment exposes the PARENT session id and no
|
|
113
113
|
* agent id, so a self-reported transcript link would be invented — and keeping the AI-authored files
|
|
114
114
|
* byte-untouched means nothing in the record can be mistaken for something a reviewer claimed about
|
|
@@ -104,14 +104,14 @@ let ProvenanceEnforcer = class ProvenanceEnforcer {
|
|
|
104
104
|
return report;
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
|
-
* Evidence from `review
|
|
107
|
+
* Evidence from `review-round<N>-<id>.provenance.json` when there are no Claude transcripts to read: the harness,
|
|
108
108
|
* session and agent `wp-write-review` recorded. Read-counters stay at zero — the bin cannot know them.
|
|
109
109
|
*/
|
|
110
110
|
binEvidence(repoRoot, expected) {
|
|
111
111
|
const summaryPath = (0, rules_config_1.summaryJsonPath)(repoRoot, this.aiBranchName.getFeatureName());
|
|
112
112
|
const out = [];
|
|
113
113
|
for (const want of expected) {
|
|
114
|
-
const record = this.verdictProvenance.read(summaryPath, want.checklistId);
|
|
114
|
+
const record = this.verdictProvenance.read(summaryPath, want.checklistId, this.reviewJsonService.latestVerdictRound(summaryPath, want.checklistId));
|
|
115
115
|
if (record === null)
|
|
116
116
|
continue;
|
|
117
117
|
out.push(new rules_config_1.ReviewerEvidence(want.checklistId, record.agentType === '' ? want.agentType : record.agentType, record.agentId));
|
|
@@ -224,7 +224,7 @@ let ProvenanceEnforcer = class ProvenanceEnforcer {
|
|
|
224
224
|
const verdictPaths = {};
|
|
225
225
|
for (const req of required) {
|
|
226
226
|
docPaths[req.id] = req.doc.trim() === '' ? '' : path.resolve(repoRoot, req.doc);
|
|
227
|
-
verdictPaths[req.id] = this.reviewJsonService.
|
|
227
|
+
verdictPaths[req.id] = this.reviewJsonService.latestChecklistResultPath((0, rules_config_1.summaryJsonPath)(repoRoot, featureName), req.id);
|
|
228
228
|
}
|
|
229
229
|
return new rules_config_1.ReviewerContext(branch, path.join((0, rules_config_1.prDirFor)(repoRoot, featureName), 'diff'), docPaths, verdictPaths);
|
|
230
230
|
}
|
|
@@ -237,7 +237,7 @@ let ProvenanceEnforcer = class ProvenanceEnforcer {
|
|
|
237
237
|
* must be comparing a dash-form name against a slash-form git branch — see
|
|
238
238
|
* ProvenanceWriteRequest.featureSlug, whose field carried the same mislabel.
|
|
239
239
|
*
|
|
240
|
-
* A SEPARATE file rather than a field inside summary.json / review
|
|
240
|
+
* A SEPARATE file rather than a field inside summary.json / review-round<N>-<id>.json, for two reasons. The
|
|
241
241
|
* reviewer cannot supply this itself — a subagent's environment exposes the PARENT session id and no
|
|
242
242
|
* agent id, so a self-reported transcript link would be invented — and keeping the AI-authored files
|
|
243
243
|
* byte-untouched means nothing in the record can be mistaken for something a reviewer claimed about
|
|
@@ -262,7 +262,7 @@ let ProvenanceEnforcer = class ProvenanceEnforcer {
|
|
|
262
262
|
reviewerPathsFor(repoRoot, featureName, required, checklistId) {
|
|
263
263
|
const req = required.find((r) => r.id === checklistId);
|
|
264
264
|
const doc = req !== undefined && req.doc.trim() !== '' ? path.resolve(repoRoot, req.doc) : '';
|
|
265
|
-
return new rules_config_1.ReviewerPaths(this.reviewJsonService.
|
|
265
|
+
return new rules_config_1.ReviewerPaths(this.reviewJsonService.latestChecklistResultPath((0, rules_config_1.summaryJsonPath)(repoRoot, featureName), checklistId), this.reviewerInstructions.pathFor(repoRoot, featureName, checklistId), doc);
|
|
266
266
|
}
|
|
267
267
|
/**
|
|
268
268
|
* The reviewers that wrote a verdict without opening the diff — WARNED about (default) or returned for
|