@webpieces/pr-gate 0.4.825 → 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 +25 -21
- package/src/scripts/commands/await-reviews-command.js.map +1 -1
- package/src/scripts/commands/finish-upsert-pr-command.js +26 -21
- 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 +16 -18
- package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/write-review-command.d.ts +43 -7
- package/src/scripts/commands/write-review-command.js +91 -12
- 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 -2
- package/src/scripts/commands/write-review-fixes-command.js.map +1 -1
- package/src/scripts/pr-gate-app.d.ts +3 -1
- package/src/scripts/pr-gate-app.js +4 -0
- package/src/scripts/pr-gate-app.js.map +1 -1
- package/src/scripts/workflow/checklist-scanner.d.ts +61 -10
- package/src/scripts/workflow/checklist-scanner.js +105 -16
- package/src/scripts/workflow/checklist-scanner.js.map +1 -1
- package/src/scripts/workflow/hotfix-finish-preparer.js +1 -1
- package/src/scripts/workflow/hotfix-finish-preparer.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 +65 -39
- package/src/scripts/workflow/review-report.js.map +1 -1
- package/src/scripts/workflow/review-round-state.d.ts +90 -11
- package/src/scripts/workflow/review-round-state.js +256 -85
- 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 -6
- package/src/scripts/workflow/review-stage-receipt.js +7 -11
- 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 +13 -7
- package/src/scripts/workflow/verdict-provenance.js +30 -22
- package/src/scripts/workflow/verdict-provenance.js.map +1 -1
- package/src/scripts/wp-write-review.js +7 -0
- package/src/scripts/wp-write-review.js.map +1 -1
|
@@ -5,6 +5,8 @@ import { DiffBasis, DiffBasisResolver } from './diff-basis';
|
|
|
5
5
|
import { PrContextWriter } from './pr-context-writer';
|
|
6
6
|
import { ChecklistScopeHasher } from './checklist-scope-hasher';
|
|
7
7
|
import { VerdictProvenanceService, VerdictStanding } from './verdict-provenance';
|
|
8
|
+
import { ReviewStageReceiptService } from './review-stage-receipt';
|
|
9
|
+
import { ReviewRoundStateService } from './review-round-state';
|
|
8
10
|
/** How a caller wants the scan filtered. Data-only (per CLAUDE.md). */
|
|
9
11
|
export declare class ChecklistScanOptions {
|
|
10
12
|
/**
|
|
@@ -27,7 +29,13 @@ export declare class ChecklistScanOptions {
|
|
|
27
29
|
* visible act by a caller that takes responsibility for writing it later — not an omission.
|
|
28
30
|
*/
|
|
29
31
|
contextStage: string;
|
|
30
|
-
|
|
32
|
+
/**
|
|
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
|
+
*/
|
|
37
|
+
maxReviewerRounds: number;
|
|
38
|
+
constructor(maxReviewerRounds: number, filterAlreadyReviewed?: boolean, contextStage?: string);
|
|
31
39
|
}
|
|
32
40
|
/**
|
|
33
41
|
* The answer to "what review does this branch owe?", in the X → N → Z terms the commands report:
|
|
@@ -103,16 +111,36 @@ export declare class ChecklistScan {
|
|
|
103
111
|
suppressed: RequiredChecklist[];
|
|
104
112
|
/**
|
|
105
113
|
* How every EXISTING verdict file stands (issue #863): CURRENT (submitted through `wp-write-review` and
|
|
106
|
-
* its checklist's in-scope diff is unchanged
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
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.
|
|
110
119
|
*/
|
|
111
120
|
standings: VerdictStanding[];
|
|
112
121
|
/** checklist id → ChecklistScopeHasher's hash of its in-scope diff NOW. Recorded in the stage-② receipt. */
|
|
113
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>;
|
|
114
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[]);
|
|
115
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
|
+
}
|
|
116
144
|
/**
|
|
117
145
|
* The ONE computation of which reviewer subagents a branch owes, shared by `wp-review-upsert-pr` (which lists) and
|
|
118
146
|
* `wp-finish-upsert-pr` (which blocks). They previously each assembled this from the same parts in slightly
|
|
@@ -144,7 +172,9 @@ export declare class ChecklistScanner {
|
|
|
144
172
|
private readonly homeConfig;
|
|
145
173
|
private readonly scopeHasher;
|
|
146
174
|
private readonly verdictProvenance;
|
|
147
|
-
|
|
175
|
+
private readonly receipts;
|
|
176
|
+
private readonly rounds;
|
|
177
|
+
constructor(aiBranchName: AiBranchName, checklistDetector: ChecklistDetector, diffScope: DiffScope, diffBasisResolver: DiffBasisResolver, prContextWriter: PrContextWriter, reviewJsonService: ReviewJsonService, homeConfig: HomeConfigService, scopeHasher: ChecklistScopeHasher, verdictProvenance: VerdictProvenanceService, receipts: ReviewStageReceiptService, rounds: ReviewRoundStateService);
|
|
148
178
|
/**
|
|
149
179
|
* `defined` is the caller's ALREADY-VALIDATED `prGate.checklists`. The scanner deliberately does not load
|
|
150
180
|
* config itself: `loadAndValidate` is the one gate on the checklist set (it rejects a non-array
|
|
@@ -153,16 +183,37 @@ export declare class ChecklistScanner {
|
|
|
153
183
|
* here leaves this a function of its inputs rather than of the filesystem.
|
|
154
184
|
*/
|
|
155
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;
|
|
156
194
|
/**
|
|
157
195
|
* Judge every READABLE verdict against its bin provenance and the in-scope diff as it is now. A file
|
|
158
196
|
* with a format problem is left to the format complaint, which names the fix; it is not assessed.
|
|
159
197
|
*/
|
|
160
198
|
private standingsOf;
|
|
161
199
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
200
|
+
* A STALE verdict that must NOT be owed again, re-stood as CARRIED with the reason.
|
|
201
|
+
*
|
|
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.
|
|
208
|
+
*
|
|
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.
|
|
211
|
+
*/
|
|
212
|
+
private carried;
|
|
213
|
+
/**
|
|
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.
|
|
166
217
|
*/
|
|
167
218
|
private liveResults;
|
|
168
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");
|
|
@@ -10,6 +10,8 @@ const diff_basis_1 = require("./diff-basis");
|
|
|
10
10
|
const pr_context_writer_1 = require("./pr-context-writer");
|
|
11
11
|
const checklist_scope_hasher_1 = require("./checklist-scope-hasher");
|
|
12
12
|
const verdict_provenance_1 = require("./verdict-provenance");
|
|
13
|
+
const review_stage_receipt_1 = require("./review-stage-receipt");
|
|
14
|
+
const review_round_state_1 = require("./review-round-state");
|
|
13
15
|
/** How a caller wants the scan filtered. Data-only (per CLAUDE.md). */
|
|
14
16
|
class ChecklistScanOptions {
|
|
15
17
|
/**
|
|
@@ -32,7 +34,14 @@ class ChecklistScanOptions {
|
|
|
32
34
|
* visible act by a caller that takes responsibility for writing it later — not an omission.
|
|
33
35
|
*/
|
|
34
36
|
contextStage;
|
|
35
|
-
|
|
37
|
+
/**
|
|
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
|
+
*/
|
|
42
|
+
maxReviewerRounds;
|
|
43
|
+
constructor(maxReviewerRounds, filterAlreadyReviewed = false, contextStage = 'stage-scan') {
|
|
44
|
+
this.maxReviewerRounds = maxReviewerRounds;
|
|
36
45
|
this.filterAlreadyReviewed = filterAlreadyReviewed;
|
|
37
46
|
this.contextStage = contextStage;
|
|
38
47
|
}
|
|
@@ -48,7 +57,7 @@ exports.ChecklistScanOptions = ChecklistScanOptions;
|
|
|
48
57
|
class ChecklistScan {
|
|
49
58
|
defined; // X
|
|
50
59
|
applicable; // N
|
|
51
|
-
reviewed; // N − Z: already have a passing/warned/overridden
|
|
60
|
+
reviewed; // N − Z: already have a passing/warned/overridden verdict
|
|
52
61
|
outstanding; // Z (== applicable when not filtering)
|
|
53
62
|
context; // fork-point sha + pr-context.json path
|
|
54
63
|
summaryPath; // the branch's summary.json; verdict files sit beside it
|
|
@@ -118,14 +127,28 @@ class ChecklistScan {
|
|
|
118
127
|
suppressed;
|
|
119
128
|
/**
|
|
120
129
|
* How every EXISTING verdict file stands (issue #863): CURRENT (submitted through `wp-write-review` and
|
|
121
|
-
* its checklist's in-scope diff is unchanged
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
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.
|
|
125
135
|
*/
|
|
126
136
|
standings;
|
|
127
137
|
/** checklist id → ChecklistScopeHasher's hash of its in-scope diff NOW. Recorded in the stage-② receipt. */
|
|
128
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;
|
|
129
152
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
130
153
|
constructor(defined, applicable, reviewed, outstanding, context, summaryPath, forkPoint, roster, formatErrors,
|
|
131
154
|
// REQUIRED, and placed BEFORE the defaulted tail deliberately. A defaulted `reviewersDisabled =
|
|
@@ -153,9 +176,21 @@ class ChecklistScan {
|
|
|
153
176
|
this.optionalNotRun = optionalNotRun;
|
|
154
177
|
this.standings = [];
|
|
155
178
|
this.scopeHashes = {};
|
|
179
|
+
this.notBriefed = [];
|
|
180
|
+
this.orangeFixes = {};
|
|
156
181
|
}
|
|
157
182
|
}
|
|
158
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;
|
|
159
194
|
/**
|
|
160
195
|
* The ONE computation of which reviewer subagents a branch owes, shared by `wp-review-upsert-pr` (which lists) and
|
|
161
196
|
* `wp-finish-upsert-pr` (which blocks). They previously each assembled this from the same parts in slightly
|
|
@@ -187,10 +222,12 @@ let ChecklistScanner = class ChecklistScanner {
|
|
|
187
222
|
homeConfig;
|
|
188
223
|
scopeHasher;
|
|
189
224
|
verdictProvenance;
|
|
225
|
+
receipts;
|
|
226
|
+
rounds;
|
|
190
227
|
constructor(aiBranchName, checklistDetector, diffScope, diffBasisResolver, prContextWriter, reviewJsonService,
|
|
191
228
|
// Injected BY TYPE (no Symbol token, per CLAUDE.md) so the ONE reviewer kill switch is read in the
|
|
192
229
|
// ONE place that computes what a branch owes — see the suppression note on `scan`.
|
|
193
|
-
homeConfig, scopeHasher, verdictProvenance) {
|
|
230
|
+
homeConfig, scopeHasher, verdictProvenance, receipts, rounds) {
|
|
194
231
|
this.aiBranchName = aiBranchName;
|
|
195
232
|
this.checklistDetector = checklistDetector;
|
|
196
233
|
this.diffScope = diffScope;
|
|
@@ -200,6 +237,8 @@ let ChecklistScanner = class ChecklistScanner {
|
|
|
200
237
|
this.homeConfig = homeConfig;
|
|
201
238
|
this.scopeHasher = scopeHasher;
|
|
202
239
|
this.verdictProvenance = verdictProvenance;
|
|
240
|
+
this.receipts = receipts;
|
|
241
|
+
this.rounds = rounds;
|
|
203
242
|
}
|
|
204
243
|
/**
|
|
205
244
|
* `defined` is the caller's ALREADY-VALIDATED `prGate.checklists`. The scanner deliberately does not load
|
|
@@ -235,10 +274,15 @@ let ChecklistScanner = class ChecklistScanner {
|
|
|
235
274
|
// WHAT was suppressed, which is the difference between an honest record and a silent one.
|
|
236
275
|
return new ChecklistScan(defined, [], [], [], context, summaryPath, base, roster, [], true, matched, basis, changedFiles, [], []);
|
|
237
276
|
}
|
|
238
|
-
const
|
|
277
|
+
const judged = this.judgedScope(repoRoot, summaryPath, roster, matched);
|
|
278
|
+
const applicable = judged.applicable;
|
|
239
279
|
const scopeHashes = this.scopeHasher.hashes(repoRoot, basis, applicable);
|
|
240
280
|
const loaded = this.reviewJsonService.loadChecklistResults(summaryPath, applicable);
|
|
241
|
-
const
|
|
281
|
+
const orangeFixes = this.rounds.orangeFixes(repoRoot, summaryPath, loaded);
|
|
282
|
+
for (const result of loaded)
|
|
283
|
+
result.remediation = orangeFixes[result.id] ?? '';
|
|
284
|
+
const standings = this.standingsOf(summaryPath, loaded, scopeHashes)
|
|
285
|
+
.map((s) => this.carried(s, loaded, opts.maxReviewerRounds));
|
|
242
286
|
const results = this.liveResults(loaded, standings);
|
|
243
287
|
const stillOwed = this.reviewJsonService.pendingChecklists(applicable, results);
|
|
244
288
|
const owedIds = new Set(stillOwed.map((r) => r.id));
|
|
@@ -250,8 +294,26 @@ let ChecklistScanner = class ChecklistScanner {
|
|
|
250
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);
|
|
251
295
|
scan.standings = standings;
|
|
252
296
|
scan.scopeHashes = scopeHashes;
|
|
297
|
+
scan.notBriefed = judged.notBriefed;
|
|
298
|
+
scan.orangeFixes = orangeFixes;
|
|
253
299
|
return scan;
|
|
254
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
|
+
}
|
|
255
317
|
/**
|
|
256
318
|
* Judge every READABLE verdict against its bin provenance and the in-scope diff as it is now. A file
|
|
257
319
|
* with a format problem is left to the format complaint, which names the fix; it is not assessed.
|
|
@@ -263,14 +325,39 @@ let ChecklistScanner = class ChecklistScanner {
|
|
|
263
325
|
.map((r) => this.verdictProvenance.assess(summaryPath, r, scopeHashes[r.id] ?? ''));
|
|
264
326
|
}
|
|
265
327
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
328
|
+
* A STALE verdict that must NOT be owed again, re-stood as CARRIED with the reason.
|
|
329
|
+
*
|
|
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.
|
|
336
|
+
*
|
|
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.
|
|
339
|
+
*/
|
|
340
|
+
carried(s, loaded, maxRounds) {
|
|
341
|
+
if (s.standing !== verdict_provenance_1.STANDING_STALE)
|
|
342
|
+
return s;
|
|
343
|
+
const result = loaded.find((r) => r.id === s.checklistId);
|
|
344
|
+
const override = result?.override ?? null;
|
|
345
|
+
if (override !== null && override.problem === '') {
|
|
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`);
|
|
347
|
+
}
|
|
348
|
+
if (s.status === rules_config_1.VERDICT_RED)
|
|
349
|
+
return s;
|
|
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)`);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
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.
|
|
270
357
|
*/
|
|
271
358
|
liveResults(loaded, standings) {
|
|
272
359
|
const dropped = new Set(standings
|
|
273
|
-
.filter((s) => s.standing === verdict_provenance_1.STANDING_REJECTED
|
|
360
|
+
.filter((s) => s.standing === verdict_provenance_1.STANDING_REJECTED)
|
|
274
361
|
.map((s) => s.checklistId));
|
|
275
362
|
return loaded.filter((r) => !dropped.has(r.id));
|
|
276
363
|
}
|
|
@@ -318,6 +405,8 @@ exports.ChecklistScanner = ChecklistScanner = tslib_1.__decorate([
|
|
|
318
405
|
rules_config_1.ReviewJsonService,
|
|
319
406
|
rules_config_1.HomeConfigService,
|
|
320
407
|
checklist_scope_hasher_1.ChecklistScopeHasher,
|
|
321
|
-
verdict_provenance_1.VerdictProvenanceService
|
|
408
|
+
verdict_provenance_1.VerdictProvenanceService,
|
|
409
|
+
review_stage_receipt_1.ReviewStageReceiptService,
|
|
410
|
+
review_round_state_1.ReviewRoundStateService])
|
|
322
411
|
], ChecklistScanner);
|
|
323
412
|
//# sourceMappingURL=checklist-scanner.js.map
|
|
@@ -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;AAE9B,uEAAuE;AACvE,MAAa,oBAAoB;IAC7B;;;;OAIG;IACH,qBAAqB,CAAU;IAC/B;;;;;;;;;;;;OAYG;IACH,YAAY,CAAS;IAErB,YAAY,qBAAqB,GAAG,KAAK,EAAE,YAAY,GAAG,YAAY;QAClE,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;CACJ;AA1BD,oDA0BC;AAED;;;;;;GAMG;AACH,MAAa,aAAa;IACtB,OAAO,CAAwB,CAAM,IAAI;IACzC,UAAU,CAAsB,CAAK,IAAI;IACzC,QAAQ,CAAsB,CAAO,mEAAmE;IACxG,WAAW,CAAsB,CAAI,uCAAuC;IAC5E,OAAO,CAAyB,CAAK,wCAAwC;IAC7E,WAAW,CAAS,CAAkB,yDAAyD;IAC/F,SAAS,CAAS,CAAmB,iCAAiC;IACtE,wGAAwG;IACxG,+FAA+F;IAC/F,6EAA6E;IAC7E,MAAM,CAAkB;IACxB,qGAAqG;IACrG,qGAAqG;IACrG,4EAA4E;IAC5E,YAAY,CAAW;IACvB;;;;OAIG;IACH,KAAK,CAAY;IACjB,YAAY,CAAW,CAAc,qDAAqD;IAC1F;;;;;;;;;OASG;IACH,OAAO,CAAoB;IAC3B;;;;;;;;OAQG;IACH,cAAc,CAAsB;IACpC;;;;;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C,CAAC,CAAC;IACnF,CAAC;IAED;;;;;;;;;OASG;IACK,YAAY,CAAC,QAAgB,EAAE,IAAY;QAC/C,IAAI,IAAI,KAAK,EAAE;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;AAlJY,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;GAZvD,gBAAgB,CAkJ5B","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_REJECTED, STANDING_STALE, VerdictProvenanceService, VerdictStanding,\n} from './verdict-provenance';\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 constructor(filterAlreadyReviewed = false, contextStage = 'stage-scan') {\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. 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 ) {}\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 standings = this.standingsOf(summaryPath, loaded, scopeHashes);\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 * 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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C,CAAoB,EAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACpF,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAoB,EAAW,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnF,CAAC;IAED;;;;;;;;;OASG;IACK,YAAY,CAAC,QAAgB,EAAE,IAAY;QAC/C,IAAI,IAAI,KAAK,EAAE;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"]}
|
|
@@ -73,7 +73,7 @@ let HotfixFinishPreparer = class HotfixFinishPreparer {
|
|
|
73
73
|
throw new rules_config_1.InformAiError('Hotfix HEAD changed while compilation/tests were running. Re-run pnpm wp-finish-upsert-pr so the build receipt covers the exact commit pushed.');
|
|
74
74
|
}
|
|
75
75
|
const config = (0, rules_config_1.loadAndValidate)(repoRoot).prGate;
|
|
76
|
-
const scan = this.checklistScanner.scan(repoRoot, config.checklists, new checklist_scanner_1.ChecklistScanOptions(false, ''));
|
|
76
|
+
const scan = this.checklistScanner.scan(repoRoot, config.checklists, new checklist_scanner_1.ChecklistScanOptions(config.maxReviewerRounds, false, ''));
|
|
77
77
|
if (!scan.basis.unresolved) {
|
|
78
78
|
this.materializer.materialize(repoRoot, featureName, scan.basis, scan.changedFiles, config.reviewDiffExclude);
|
|
79
79
|
this.prContextWriter.ensure(repoRoot, featureName, scan.basis, 'stage3-hotfix', scan.changedFiles, this.materializer.diffDirFor(repoRoot, featureName));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hotfix-finish-preparer.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/hotfix-finish-preparer.ts"],"names":[],"mappings":";;;;AAAA,iDAA0C;AAC1C,0DAAwI;AACxI,yCAA2D;AAC3D,iEAAsD;AACtD,qDAAmE;AACnE,+DAA0D;AAC1D,qDAAgD;AAChD,2DAA4F;AAC5F,2DAAuD;AACvD,yCAAqC;AACrC,+CAA6C;AAC7C,2CAAwD;AACxD,+CAA2C;AAC3C,2DAAsD;AACtD,+DAA6E;AAE7E,MAAa,iBAAiB;IAEb;IACA;IACA;IACA;IACA;IALb,YACa,WAAmB,EACnB,aAAqB,EACrB,MAAiB,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AAQ,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC;QAClG,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;QAChE,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,iCAAgB,CAAC,4CAA4C,EAAE,0BAA0B,EAAE,8CAA8C,EAAE,6BAAY,CAAC,CAAC,CAAC;QAC9M,IAAI,CAAC,iBAAiB,CAAC,iCAAiC,CAAC,QAAQ,CAAC,CAAC;QACnE,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,UAAU,KAAK,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,KAAK,UAAU,EAAE,CAAC;YACnF,MAAM,IAAI,4BAAa,CAAC,gJAAgJ,CAAC,CAAC;QAC9K,CAAC;QACD,MAAM,MAAM,GAAG,IAAA,8BAAe,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;QAChD,MAAM,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,wCAAoB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"hotfix-finish-preparer.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/hotfix-finish-preparer.ts"],"names":[],"mappings":";;;;AAAA,iDAA0C;AAC1C,0DAAwI;AACxI,yCAA2D;AAC3D,iEAAsD;AACtD,qDAAmE;AACnE,+DAA0D;AAC1D,qDAAgD;AAChD,2DAA4F;AAC5F,2DAAuD;AACvD,yCAAqC;AACrC,+CAA6C;AAC7C,2CAAwD;AACxD,+CAA2C;AAC3C,2DAAsD;AACtD,+DAA6E;AAE7E,MAAa,iBAA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,MAAM,GAAG,IAAA,yBAAS,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QAC3E,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACnE,CAAC;CACJ,CAAA;AAnDY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGA,6BAAc;QAChB,mCAAY;QACjB,kBAAO;QACG,gCAAiB;QACrB,8BAAa;QACT,uCAAiB;QACxB,wBAAU;QACZ,oBAAQ;QACA,oCAAgB;QACpB,oCAAgB;QACb,mCAAe;QACZ,wCAAkB;GAblD,oBAAoB,CAmDhC","sourcesContent":["import { spawnSync } from 'child_process';\nimport { BranchIdentity, InformAiError, PrSummary, ReviewJsonService, loadAndValidate, summaryJsonPath } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from './git-readAiBranchName';\nimport { BuildAffected, BuildGateOptions } from './build-affected';\nimport { BuildArtifactGate } from './build-artifact-gate';\nimport { FINISH_STAGE } from './build-gate-log';\nimport { ChecklistScan, ChecklistScanOptions, ChecklistScanner } from './checklist-scanner';\nimport { DiffMaterializer } from './diff-materializer';\nimport { GitExec } from './git-exec';\nimport { MergeContext } from './merge-start';\nimport { MergeEnd, MergeEndOptions } from './merge-end';\nimport { MergeState } from './merge-state';\nimport { PrContextWriter } from './pr-context-writer';\nimport { ProvenanceEnforcer, ProvenanceReport } from './provenance-enforcer';\n\nexport class HotfixFinishState {\n constructor(\n readonly featureName: string,\n readonly currentBranch: string,\n readonly review: PrSummary,\n readonly scan: ChecklistScan,\n readonly provenance: ProvenanceReport,\n ) {}\n}\n\n/** Validates and builds the emergency flow before FinishUpsertPrCommand publishes anything. */\n@injectable(bindingScopeValues.Singleton)\nexport class HotfixFinishPreparer {\n constructor(\n private readonly branchIdentity: BranchIdentity,\n private readonly aiBranchName: AiBranchName,\n private readonly gitExec: GitExec,\n private readonly reviewJsonService: ReviewJsonService,\n private readonly buildAffected: BuildAffected,\n private readonly buildArtifactGate: BuildArtifactGate,\n private readonly mergeState: MergeState,\n private readonly mergeEnd: MergeEnd,\n private readonly checklistScanner: ChecklistScanner,\n private readonly materializer: DiffMaterializer,\n private readonly prContextWriter: PrContextWriter,\n private readonly provenanceEnforcer: ProvenanceEnforcer,\n ) {}\n\n async prepare(repoRoot: string): Promise<HotfixFinishState> {\n await this.finalizeMerge(repoRoot);\n this.gitExec.assertCleanTree(repoRoot);\n const featureName = this.aiBranchName.getFeatureName();\n const review = this.reviewJsonService.loadSummaryJson(summaryJsonPath(repoRoot, featureName), []);\n const headBefore = this.gitOut(repoRoot, ['rev-parse', 'HEAD']);\n await this.buildAffected.runBuildGate(repoRoot, new BuildGateOptions('🛠️ Hotfix build gate (build + test only)', 'pnpm wp-finish-upsert-pr', 'Hotfix build failed — no PR created/updated.', FINISH_STAGE));\n this.buildArtifactGate.assertBuildLeftNothingUncommitted(repoRoot);\n this.gitExec.assertCleanTree(repoRoot);\n if (headBefore === '' || this.gitOut(repoRoot, ['rev-parse', 'HEAD']) !== headBefore) {\n throw new InformAiError('Hotfix HEAD changed while compilation/tests were running. Re-run pnpm wp-finish-upsert-pr so the build receipt covers the exact commit pushed.');\n }\n const config = loadAndValidate(repoRoot).prGate;\n const scan = this.checklistScanner.scan(repoRoot, config.checklists, new ChecklistScanOptions(config.maxReviewerRounds, false, ''));\n if (!scan.basis.unresolved) {\n this.materializer.materialize(repoRoot, featureName, scan.basis, scan.changedFiles, config.reviewDiffExclude);\n this.prContextWriter.ensure(repoRoot, featureName, scan.basis, 'stage3-hotfix', scan.changedFiles, this.materializer.diffDirFor(repoRoot, featureName));\n }\n const currentBranch = this.branchIdentity.current();\n const provenance = this.provenanceEnforcer.enforce([], currentBranch, repoRoot, config);\n return new HotfixFinishState(featureName, currentBranch, review, scan, provenance);\n }\n\n private async finalizeMerge(repoRoot: string): Promise<void> {\n const home = this.mergeState.mergeDirFor(repoRoot, this.aiBranchName.getFeatureName());\n const activeDir = this.mergeState.findActiveMergeRunDir(home);\n const marker = activeDir ? this.mergeState.readMergeMarker(activeDir) : null;\n if (!activeDir || !marker || marker.validated) return;\n await this.mergeEnd.mergeEnd(repoRoot, 'wp-finish-upsert-pr', activeDir, new MergeContext(marker.currentBranch, marker.squashBranch, marker.backupBranch, marker.prNumber), new MergeEndOptions(marker.conflictedFiles, false));\n }\n\n private gitOut(repoRoot: string, args: string[]): string {\n const result = spawnSync('git', args, { cwd: repoRoot, encoding: 'utf8' });\n return result.status === 0 ? (result.stdout ?? '').trim() : '';\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
|