@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
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { RepoRootFinder } from '@webpieces/rules-config';
|
|
1
|
+
import { RepoRootFinder, ReviewJsonService } from '@webpieces/rules-config';
|
|
2
2
|
import { AiBranchName } from '../workflow/git-readAiBranchName';
|
|
3
3
|
import { ReviewStageReceiptService } from '../workflow/review-stage-receipt';
|
|
4
4
|
import { ReviewerIdentityResolver } from '../workflow/reviewer-identity';
|
|
5
5
|
import { VerdictProvenanceService } from '../workflow/verdict-provenance';
|
|
6
|
-
import { ReviewRoundStateService } from '../workflow/review-round-state';
|
|
7
6
|
/** What `wp-write-review` was asked to do. Data-only. */
|
|
8
7
|
export declare class WriteReviewOptions {
|
|
9
8
|
checklistId: string;
|
|
@@ -11,6 +10,12 @@ export declare class WriteReviewOptions {
|
|
|
11
10
|
cwd: string;
|
|
12
11
|
constructor(checklistId: string, json: string, cwd: string);
|
|
13
12
|
}
|
|
13
|
+
/** What `wp-write-review --check` was asked: may this checklist still be reviewed? Data-only. */
|
|
14
|
+
export declare class ReviewBudgetCheckOptions {
|
|
15
|
+
checklistId: string;
|
|
16
|
+
cwd: string;
|
|
17
|
+
constructor(checklistId: string, cwd: string);
|
|
18
|
+
}
|
|
14
19
|
/**
|
|
15
20
|
* `wp-write-review` — the ONE way any reviewer, Claude or Codex, submits a checklist verdict (issue #863).
|
|
16
21
|
*
|
|
@@ -22,8 +27,15 @@ export declare class WriteReviewOptions {
|
|
|
22
27
|
* 2. the checklist must be one stage ② briefed this round (its receipt), so a carried verdict cannot be
|
|
23
28
|
* overwritten and a checklist that does not apply cannot be invented;
|
|
24
29
|
* 3. the verdict is validated strictly — the five fields, nothing else;
|
|
25
|
-
* 4. it is written WITH `review
|
|
26
|
-
* of the verdict. `wp-finish-upsert-pr` rejects a verdict
|
|
30
|
+
* 4. it is written as `review-round<N>-<id>.json` WITH `review-round<N>-<id>.provenance.json`: who, which
|
|
31
|
+
* commit, which in-scope diff, and a hash of the verdict. `wp-finish-upsert-pr` rejects a verdict
|
|
32
|
+
* without one, or one edited since;
|
|
33
|
+
* 5. the round must be inside the budget (issues #1051, #1053): a round above `maxReviewerRounds` records
|
|
34
|
+
* nothing, and a round's verdict is never overwritten, whoever spawned the reviewer. `--check` asks the
|
|
35
|
+
* same question BEFORE a reviewer spends a review on it;
|
|
36
|
+
* 6. the color must fit the round (issue #1053): the FINAL round has no red — its must-fix color is
|
|
37
|
+
* orange, never re-reviewed — and orange is refused before the final round, where red still means
|
|
38
|
+
* "fix it and it will be reviewed again".
|
|
27
39
|
*
|
|
28
40
|
* `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.
|
|
29
41
|
*/
|
|
@@ -33,13 +45,37 @@ export declare class WriteReviewCommand {
|
|
|
33
45
|
private readonly receipts;
|
|
34
46
|
private readonly identity;
|
|
35
47
|
private readonly provenance;
|
|
36
|
-
private readonly
|
|
37
|
-
constructor(repoRootFinder: RepoRootFinder, aiBranchName: AiBranchName, receipts: ReviewStageReceiptService, identity: ReviewerIdentityResolver, provenance: VerdictProvenanceService,
|
|
48
|
+
private readonly reviewJsonService;
|
|
49
|
+
constructor(repoRootFinder: RepoRootFinder, aiBranchName: AiBranchName, receipts: ReviewStageReceiptService, identity: ReviewerIdentityResolver, provenance: VerdictProvenanceService, reviewJsonService: ReviewJsonService);
|
|
38
50
|
run(opts: WriteReviewOptions): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* `wp-write-review --check`: the reviewer's FIRST step. Refuses exactly when {@link run} would refuse
|
|
53
|
+
* on the budget, so a reviewer past the budget learns it before it reviews rather than after.
|
|
54
|
+
*/
|
|
55
|
+
check(opts: ReviewBudgetCheckOptions): Promise<void>;
|
|
56
|
+
/** The last round `maxReviewerRounds` allows — the one with no red (issue #1053). */
|
|
57
|
+
private isFinalRound;
|
|
58
|
+
/**
|
|
59
|
+
* THE ROUND CAP, held by the reviewer's own submission path (issues #1051, #1053). The planner already
|
|
60
|
+
* never briefs past the cap, but an author agent could still spawn a reviewer from an old instructions
|
|
61
|
+
* file — the measured deadlock did exactly that. Two refusals make it mechanical: a round above
|
|
62
|
+
* `maxReviewerRounds` records nothing, and a checklist that already has a verdict in this round (or a
|
|
63
|
+
* later one) gets no second one — a round's verdict is never overwritten.
|
|
64
|
+
*/
|
|
65
|
+
private assertWithinBudget;
|
|
39
66
|
/** The stage-② receipt, provided it briefed THIS checklist this round. */
|
|
40
67
|
private briefedReceipt;
|
|
41
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Strict: an object with exactly the verdict's five fields, every one a string, and a status that fits
|
|
70
|
+
* the round — red only BEFORE the final round, orange only ON it (issue #1053).
|
|
71
|
+
*/
|
|
42
72
|
private parse;
|
|
73
|
+
/**
|
|
74
|
+
* The round decides which blocking color exists. The FINAL round's red would mean "fix it and it will be
|
|
75
|
+
* reviewed again", and there is no again — so it is refused and orange named. Orange before the final
|
|
76
|
+
* round would waive a re-review that the budget still pays for — so it is refused and red named.
|
|
77
|
+
*/
|
|
78
|
+
private colorForRound;
|
|
43
79
|
private text;
|
|
44
80
|
private parseObject;
|
|
45
81
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WriteReviewInput = exports.WriteReviewCommand = exports.WriteReviewOptions = void 0;
|
|
3
|
+
exports.WriteReviewInput = exports.WriteReviewCommand = exports.ReviewBudgetCheckOptions = exports.WriteReviewOptions = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fs = tslib_1.__importStar(require("fs"));
|
|
6
6
|
const rules_config_1 = require("@webpieces/rules-config");
|
|
@@ -9,7 +9,6 @@ const git_readAiBranchName_1 = require("../workflow/git-readAiBranchName");
|
|
|
9
9
|
const review_stage_receipt_1 = require("../workflow/review-stage-receipt");
|
|
10
10
|
const reviewer_identity_1 = require("../workflow/reviewer-identity");
|
|
11
11
|
const verdict_provenance_1 = require("../workflow/verdict-provenance");
|
|
12
|
-
const review_round_state_1 = require("../workflow/review-round-state");
|
|
13
12
|
/** The only keys a verdict may carry. Anything else is somebody's second schema. */
|
|
14
13
|
const VERDICT_KEYS = ['id', 'status', 'agent', 'model', 'output'];
|
|
15
14
|
/** What `wp-write-review` was asked to do. Data-only. */
|
|
@@ -28,6 +27,16 @@ class WriteReviewOptions {
|
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
exports.WriteReviewOptions = WriteReviewOptions;
|
|
30
|
+
/** What `wp-write-review --check` was asked: may this checklist still be reviewed? Data-only. */
|
|
31
|
+
class ReviewBudgetCheckOptions {
|
|
32
|
+
checklistId;
|
|
33
|
+
cwd;
|
|
34
|
+
constructor(checklistId, cwd) {
|
|
35
|
+
this.checklistId = checklistId;
|
|
36
|
+
this.cwd = cwd;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.ReviewBudgetCheckOptions = ReviewBudgetCheckOptions;
|
|
31
40
|
/**
|
|
32
41
|
* `wp-write-review` — the ONE way any reviewer, Claude or Codex, submits a checklist verdict (issue #863).
|
|
33
42
|
*
|
|
@@ -39,8 +48,15 @@ exports.WriteReviewOptions = WriteReviewOptions;
|
|
|
39
48
|
* 2. the checklist must be one stage ② briefed this round (its receipt), so a carried verdict cannot be
|
|
40
49
|
* overwritten and a checklist that does not apply cannot be invented;
|
|
41
50
|
* 3. the verdict is validated strictly — the five fields, nothing else;
|
|
42
|
-
* 4. it is written WITH `review
|
|
43
|
-
* of the verdict. `wp-finish-upsert-pr` rejects a verdict
|
|
51
|
+
* 4. it is written as `review-round<N>-<id>.json` WITH `review-round<N>-<id>.provenance.json`: who, which
|
|
52
|
+
* commit, which in-scope diff, and a hash of the verdict. `wp-finish-upsert-pr` rejects a verdict
|
|
53
|
+
* without one, or one edited since;
|
|
54
|
+
* 5. the round must be inside the budget (issues #1051, #1053): a round above `maxReviewerRounds` records
|
|
55
|
+
* nothing, and a round's verdict is never overwritten, whoever spawned the reviewer. `--check` asks the
|
|
56
|
+
* same question BEFORE a reviewer spends a review on it;
|
|
57
|
+
* 6. the color must fit the round (issue #1053): the FINAL round has no red — its must-fix color is
|
|
58
|
+
* orange, never re-reviewed — and orange is refused before the final round, where red still means
|
|
59
|
+
* "fix it and it will be reviewed again".
|
|
44
60
|
*
|
|
45
61
|
* `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.
|
|
46
62
|
*/
|
|
@@ -50,15 +66,15 @@ let WriteReviewCommand = class WriteReviewCommand {
|
|
|
50
66
|
receipts;
|
|
51
67
|
identity;
|
|
52
68
|
provenance;
|
|
53
|
-
|
|
69
|
+
reviewJsonService;
|
|
54
70
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
55
|
-
constructor(repoRootFinder, aiBranchName, receipts, identity, provenance,
|
|
71
|
+
constructor(repoRootFinder, aiBranchName, receipts, identity, provenance, reviewJsonService) {
|
|
56
72
|
this.repoRootFinder = repoRootFinder;
|
|
57
73
|
this.aiBranchName = aiBranchName;
|
|
58
74
|
this.receipts = receipts;
|
|
59
75
|
this.identity = identity;
|
|
60
76
|
this.provenance = provenance;
|
|
61
|
-
this.
|
|
77
|
+
this.reviewJsonService = reviewJsonService;
|
|
62
78
|
}
|
|
63
79
|
run(opts) {
|
|
64
80
|
const id = opts.checklistId.trim();
|
|
@@ -69,16 +85,57 @@ let WriteReviewCommand = class WriteReviewCommand {
|
|
|
69
85
|
// Identity BEFORE parsing: a coordinator is refused whatever it submitted, and the stamp it
|
|
70
86
|
// consumes must not survive to lend itself to a later call.
|
|
71
87
|
const who = this.identity.resolve(cwd, id);
|
|
72
|
-
|
|
88
|
+
this.assertWithinBudget((0, rules_config_1.summaryJsonPath)(repoRoot, featureName), receipt, id);
|
|
89
|
+
const verdict = this.parse(opts.json, id, receipt);
|
|
73
90
|
const record = new verdict_provenance_1.VerdictProvenance(id, who.harness, who.sessionId, who.agentId, who.agentType, receipt.headSha, receipt.scopeHashes[id] ?? '');
|
|
74
91
|
record.round = receipt.round;
|
|
75
92
|
const written = this.provenance.write((0, rules_config_1.summaryJsonPath)(repoRoot, featureName), verdict, record);
|
|
76
|
-
this.rounds.archiveVerdict((0, rules_config_1.summaryJsonPath)(repoRoot, featureName), id, receipt.round);
|
|
77
93
|
process.stdout.write(`✅ ${verdict.status.toUpperCase()} verdict for "${id}" submitted → ${written}\n`
|
|
78
94
|
+ ` provenance: ${who.harness}${who.agentId === '' ? '' : ` agent ${who.agentId}`}, `
|
|
79
95
|
+ `briefed at ${receipt.headSha.slice(0, 8)}, global round ${receipt.round} of ${receipt.maxReviewerRounds}\n`);
|
|
80
96
|
return Promise.resolve();
|
|
81
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* `wp-write-review --check`: the reviewer's FIRST step. Refuses exactly when {@link run} would refuse
|
|
100
|
+
* on the budget, so a reviewer past the budget learns it before it reviews rather than after.
|
|
101
|
+
*/
|
|
102
|
+
check(opts) {
|
|
103
|
+
const id = opts.checklistId.trim();
|
|
104
|
+
const repoRoot = this.repoRootFinder.resolveRepoRoot(opts.cwd);
|
|
105
|
+
const featureName = this.aiBranchName.getFeatureName();
|
|
106
|
+
const receipt = this.briefedReceipt(repoRoot, featureName, id);
|
|
107
|
+
this.assertWithinBudget((0, rules_config_1.summaryJsonPath)(repoRoot, featureName), receipt, id);
|
|
108
|
+
const final = this.isFinalRound(receipt)
|
|
109
|
+
? ` This is the FINAL round: there is no re-review, so you may NOT mark ${rules_config_1.VERDICT_RED} — mark every must-fix finding ${rules_config_1.VERDICT_ORANGE}.`
|
|
110
|
+
: '';
|
|
111
|
+
process.stdout.write(`✅ "${id}" may be reviewed: this is review round ${receipt.round} of at most ${receipt.maxReviewerRounds}.${final} `
|
|
112
|
+
+ `Review it, then submit with pnpm ${rules_config_1.WRITE_REVIEW_BIN} --checklist ${id}.\n`);
|
|
113
|
+
return Promise.resolve();
|
|
114
|
+
}
|
|
115
|
+
/** The last round `maxReviewerRounds` allows — the one with no red (issue #1053). */
|
|
116
|
+
isFinalRound(receipt) {
|
|
117
|
+
return receipt.round >= receipt.maxReviewerRounds;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* THE ROUND CAP, held by the reviewer's own submission path (issues #1051, #1053). The planner already
|
|
121
|
+
* never briefs past the cap, but an author agent could still spawn a reviewer from an old instructions
|
|
122
|
+
* file — the measured deadlock did exactly that. Two refusals make it mechanical: a round above
|
|
123
|
+
* `maxReviewerRounds` records nothing, and a checklist that already has a verdict in this round (or a
|
|
124
|
+
* later one) gets no second one — a round's verdict is never overwritten.
|
|
125
|
+
*/
|
|
126
|
+
assertWithinBudget(summaryPath, receipt, id) {
|
|
127
|
+
const max = receipt.maxReviewerRounds;
|
|
128
|
+
const latest = this.reviewJsonService.latestVerdictRound(summaryPath, id);
|
|
129
|
+
if (receipt.round <= max && latest < receipt.round)
|
|
130
|
+
return;
|
|
131
|
+
const why = receipt.round > max
|
|
132
|
+
? `this briefing is for review round ${receipt.round}, above maxReviewerRounds (${max})`
|
|
133
|
+
: `it already has a verdict for review round ${latest} (maxReviewerRounds is ${max}), and a round's verdict is never overwritten`;
|
|
134
|
+
throw new rules_config_1.InformAiError(`I am not allowed to review ${id}: ${why}.\n`
|
|
135
|
+
+ `Do not review it and submit nothing for it; report this refusal, verbatim, to the agent that spawned you. `
|
|
136
|
+
+ `The verdict already recorded for it stands (${this.reviewJsonService.latestChecklistResultPath(summaryPath, id) || 'none'}), and `
|
|
137
|
+
+ 'the author records any fix with pnpm wp-write-review-fixes.');
|
|
138
|
+
}
|
|
82
139
|
/** The stage-② receipt, provided it briefed THIS checklist this round. */
|
|
83
140
|
briefedReceipt(repoRoot, featureName, id) {
|
|
84
141
|
if (id === '')
|
|
@@ -96,8 +153,11 @@ let WriteReviewCommand = class WriteReviewCommand {
|
|
|
96
153
|
}
|
|
97
154
|
return receipt;
|
|
98
155
|
}
|
|
99
|
-
/**
|
|
100
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Strict: an object with exactly the verdict's five fields, every one a string, and a status that fits
|
|
158
|
+
* the round — red only BEFORE the final round, orange only ON it (issue #1053).
|
|
159
|
+
*/
|
|
160
|
+
parse(json, id, receipt) {
|
|
101
161
|
const raw = this.parseObject(json);
|
|
102
162
|
const problems = [];
|
|
103
163
|
const extra = Object.keys(raw).filter((k) => !VERDICT_KEYS.includes(k));
|
|
@@ -112,6 +172,7 @@ let WriteReviewCommand = class WriteReviewCommand {
|
|
|
112
172
|
// webpieces-disable no-any-unknown -- comparing against the readonly literal tuple of valid colors
|
|
113
173
|
if (!rules_config_1.VERDICT_STATUSES.includes(status))
|
|
114
174
|
problems.push(`"status" must be one of ${rules_config_1.VERDICT_STATUSES.join(', ')}`);
|
|
175
|
+
problems.push(...this.colorForRound(status, receipt));
|
|
115
176
|
for (const key of ['agent', 'model', 'output']) {
|
|
116
177
|
if (this.text(raw, key) === '')
|
|
117
178
|
problems.push(`"${key}" must be a non-empty string${key === 'output' ? '' : ' (use "unknown" when unavailable)'}`);
|
|
@@ -122,6 +183,24 @@ let WriteReviewCommand = class WriteReviewCommand {
|
|
|
122
183
|
}
|
|
123
184
|
return new verdict_provenance_1.SubmittedVerdict(id, status, this.text(raw, 'agent'), this.text(raw, 'model'), raw['output']);
|
|
124
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* The round decides which blocking color exists. The FINAL round's red would mean "fix it and it will be
|
|
188
|
+
* reviewed again", and there is no again — so it is refused and orange named. Orange before the final
|
|
189
|
+
* round would waive a re-review that the budget still pays for — so it is refused and red named.
|
|
190
|
+
*/
|
|
191
|
+
colorForRound(status, receipt) {
|
|
192
|
+
const round = `review round ${receipt.round} of ${receipt.maxReviewerRounds}`;
|
|
193
|
+
if (status === rules_config_1.VERDICT_RED && this.isFinalRound(receipt)) {
|
|
194
|
+
return [`"status": "${rules_config_1.VERDICT_RED}" is not allowed: ${round} is the FINAL round, and there is no re-review. `
|
|
195
|
+
+ `Mark anything that must be fixed "${rules_config_1.VERDICT_ORANGE}", with a concrete, actionable fix in "output" — the author applies it `
|
|
196
|
+
+ 'best effort and ships without another review.'];
|
|
197
|
+
}
|
|
198
|
+
if (status === rules_config_1.VERDICT_ORANGE && !this.isFinalRound(receipt)) {
|
|
199
|
+
return [`"status": "${rules_config_1.VERDICT_ORANGE}" is only for the FINAL review round, and ${round} is not it. `
|
|
200
|
+
+ `Use "${rules_config_1.VERDICT_RED}" for a must-fix finding: the author's fix will be reviewed again next round.`];
|
|
201
|
+
}
|
|
202
|
+
return [];
|
|
203
|
+
}
|
|
125
204
|
// webpieces-disable no-any-unknown -- one field of the opaque submitted object, narrowed to a trimmed string
|
|
126
205
|
text(raw, key) {
|
|
127
206
|
const value = raw[key];
|
|
@@ -155,7 +234,7 @@ exports.WriteReviewCommand = WriteReviewCommand = tslib_1.__decorate([
|
|
|
155
234
|
review_stage_receipt_1.ReviewStageReceiptService,
|
|
156
235
|
reviewer_identity_1.ReviewerIdentityResolver,
|
|
157
236
|
verdict_provenance_1.VerdictProvenanceService,
|
|
158
|
-
|
|
237
|
+
rules_config_1.ReviewJsonService])
|
|
159
238
|
], WriteReviewCommand);
|
|
160
239
|
/**
|
|
161
240
|
* Reads the verdict JSON for the composition root: `--file <path>`, else stdin. Separate from the command
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-review-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/write-review-command.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,0DAEiC;AACjC,yCAA2D;AAC3D,2EAAgE;AAChE,2EAAiG;AACjG,qEAA2F;AAC3F,uEAA+G;AAC/G,uEAAyE;AAEzE,oFAAoF;AACpF,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AAE3E,yDAAyD;AACzD,MAAa,kBAAkB;IAC3B,WAAW,CAAS;IACpB,sGAAsG;IACtG,iEAAiE;IACjE,IAAI,CAAS;IACb,kGAAkG;IAClG,8EAA8E;IAC9E,GAAG,CAAS;IAEZ,YAAY,WAAmB,EAAE,IAAY,EAAE,GAAW;QACtD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;CACJ;AAdD,gDAcC;AAED;;;;;;;;;;;;;;;GAeG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAGN;IACA;IACA;IACA;IACA;IACA;IAPrB,yDAAyD;IACzD,YACqB,cAA8B,EAC9B,YAA0B,EAC1B,QAAmC,EACnC,QAAkC,EAClC,UAAoC,EACpC,MA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,CAAC,CAAC;YACjH,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAC/B,MAAM,IAAI,4BAAa,CAAC,GAAG,+BAAgB,0CAA0C,+BAAgB,yDAAyD,CAAC,CAAC;QACpK,CAAC;QACD,OAAO,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;CACJ,CAAA;AAXY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,gBAAgB,CAW5B","sourcesContent":["import * as fs from 'fs';\nimport {\n InformAiError, RepoRootFinder, VERDICT_STATUSES, WRITE_REVIEW_BIN, checklistOverrideService, summaryJsonPath, toError,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { ReviewStageReceipt, ReviewStageReceiptService } from '../workflow/review-stage-receipt';\nimport { ReviewerIdentity, ReviewerIdentityResolver } from '../workflow/reviewer-identity';\nimport { SubmittedVerdict, VerdictProvenance, VerdictProvenanceService } from '../workflow/verdict-provenance';\nimport { ReviewRoundStateService } from '../workflow/review-round-state';\n\n/** The only keys a verdict may carry. Anything else is somebody's second schema. */\nconst VERDICT_KEYS = ['id', 'status', 'agent', 'model', 'output'] as const;\n\n/** What `wp-write-review` was asked to do. Data-only. */\nexport class WriteReviewOptions {\n checklistId: string;\n // The verdict JSON itself — read from `--file` or stdin by the composition root, so this command is a\n // function of its inputs and a spec can drive it without a pipe.\n json: string;\n // Where the caller stands — the tree whose review dir and hook stamp are used. Passed in (the bin\n // passes process.cwd()) rather than read here, for the same reason `json` is.\n cwd: string;\n\n constructor(checklistId: string, json: string, cwd: string) {\n this.checklistId = checklistId;\n this.json = json;\n this.cwd = cwd;\n }\n}\n\n/**\n * `wp-write-review` — the ONE way any reviewer, Claude or Codex, submits a checklist verdict (issue #863).\n *\n * Before it existed a verdict was \"a file with the right shape at the right path\", and that is exactly what\n * a Codex coordinator produced on two merged PRs: the shared-tree guard blocked its reviewer's write, the\n * guard's own cure said to hand the edit to the coordinator, the coordinator wrote all five verdicts, and\n * `wp-finish-upsert-pr` accepted them. Now:\n * 1. the caller is identified by the harness (ReviewerIdentityResolver) and the COORDINATOR is refused;\n * 2. the checklist must be one stage ② briefed this round (its receipt), so a carried verdict cannot be\n * overwritten and a checklist that does not apply cannot be invented;\n * 3. the verdict is validated strictly — the five fields, nothing else;\n * 4. it is written WITH `review-<id>.provenance.json`: who, which commit, which in-scope diff, and a hash\n * of the verdict. `wp-finish-upsert-pr` rejects a verdict without one, or one edited since.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewCommand {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly aiBranchName: AiBranchName,\n private readonly receipts: ReviewStageReceiptService,\n private readonly identity: ReviewerIdentityResolver,\n private readonly provenance: VerdictProvenanceService,\n private readonly rounds: ReviewRoundStateService,\n ) {}\n\n run(opts: WriteReviewOptions): Promise<void> {\n const id = opts.checklistId.trim();\n const cwd = opts.cwd;\n const repoRoot = this.repoRootFinder.resolveRepoRoot(cwd);\n const featureName = this.aiBranchName.getFeatureName();\n const receipt = this.briefedReceipt(repoRoot, featureName, id);\n // Identity BEFORE parsing: a coordinator is refused whatever it submitted, and the stamp it\n // consumes must not survive to lend itself to a later call.\n const who: ReviewerIdentity = this.identity.resolve(cwd, id);\n const verdict = this.parse(opts.json, id);\n const record = new VerdictProvenance(\n id, who.harness, who.sessionId, who.agentId, who.agentType, receipt.headSha, receipt.scopeHashes[id] ?? '');\n record.round = receipt.round;\n const written = this.provenance.write(summaryJsonPath(repoRoot, featureName), verdict, record);\n this.rounds.archiveVerdict(summaryJsonPath(repoRoot, featureName), id, receipt.round);\n process.stdout.write(\n `✅ ${verdict.status.toUpperCase()} verdict for \"${id}\" submitted → ${written}\\n`\n + ` provenance: ${who.harness}${who.agentId === '' ? '' : ` agent ${who.agentId}`}, `\n + `briefed at ${receipt.headSha.slice(0, 8)}, global round ${receipt.round} of ${receipt.maxReviewerRounds}\\n`);\n return Promise.resolve();\n }\n\n /** The stage-② receipt, provided it briefed THIS checklist this round. */\n private briefedReceipt(repoRoot: string, featureName: string, id: string): ReviewStageReceipt {\n if (id === '') throw new InformAiError(`${WRITE_REVIEW_BIN} needs the checklist id: pnpm ${WRITE_REVIEW_BIN} --checklist <id>`);\n const receipt = this.receipts.read(repoRoot, featureName);\n if (receipt === null) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: pnpm wp-review-upsert-pr has not briefed any reviewer on this branch yet, `\n + 'so there is nothing to submit a verdict against.');\n }\n if (!receipt.reviewersBriefed.includes(id) || (receipt.scopeHashes[id] ?? '') === '') {\n const briefed = receipt.reviewersBriefed.length === 0 ? '(none)' : receipt.reviewersBriefed.join(', ');\n throw new InformAiError(`${WRITE_REVIEW_BIN}: checklist \"${id}\" was not briefed by the last pnpm wp-review-upsert-pr `\n + `(briefed this round: ${briefed}). Submit only for a checklist whose instructions file you were handed — `\n + 'a checklist absent here either carries its earlier verdict or does not apply to this diff.');\n }\n return receipt;\n }\n\n /** Strict: an object with exactly the verdict's five fields, every one a string, status one of three. */\n private parse(json: string, id: string): SubmittedVerdict {\n const raw = this.parseObject(json);\n const problems: string[] = [];\n const extra = Object.keys(raw).filter((k: string): boolean => !(VERDICT_KEYS as readonly string[]).includes(k));\n if (extra.includes('override')) {\n problems.push(`\"override\" is not a verdict field — a ship-anyway decision is a HUMAN's, recorded by the coordinating agent in ${checklistOverrideService.overrideFileName(id)}`);\n }\n if (extra.length > 0) problems.push(`unknown field(s) ${extra.map((k: string): string => `\"${k}\"`).join(', ')} — a verdict has exactly: ${VERDICT_KEYS.join(', ')}`);\n if (raw['id'] !== undefined && this.text(raw, 'id') !== id) problems.push(`\"id\" is ${JSON.stringify(raw['id'])} but --checklist is \"${id}\"`);\n const status = this.text(raw, 'status').toLowerCase();\n // webpieces-disable no-any-unknown -- comparing against the readonly literal tuple of valid colors\n if (!(VERDICT_STATUSES as readonly string[]).includes(status)) problems.push(`\"status\" must be one of ${VERDICT_STATUSES.join(', ')}`);\n for (const key of ['agent', 'model', 'output']) {\n if (this.text(raw, key) === '') problems.push(`\"${key}\" must be a non-empty string${key === 'output' ? '' : ' (use \"unknown\" when unavailable)'}`);\n }\n if (problems.length > 0) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict for \"${id}\" was NOT submitted:\\n`\n + problems.map((p: string): string => ` • ${p}`).join('\\n'));\n }\n return new SubmittedVerdict(id, status, this.text(raw, 'agent'), this.text(raw, 'model'), raw['output'] as string);\n }\n\n // webpieces-disable no-any-unknown -- one field of the opaque submitted object, narrowed to a trimmed string\n private text(raw: Record<string, unknown>, key: string): string {\n const value = raw[key];\n return typeof value === 'string' ? value.trim() : '';\n }\n\n // webpieces-disable no-any-unknown -- the submitted JSON is opaque until parse() narrows every field\n private parseObject(json: string): Record<string, unknown> {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed\n let parsed: unknown = null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: a JSON syntax error becomes the AI-facing refusal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n parsed = JSON.parse(json);\n } catch (err: unknown) {\n const error = toError(err);\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict is not valid JSON.`, { cause: error });\n }\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict must be ONE JSON object.`);\n }\n // webpieces-disable no-any-unknown -- narrowed to a plain object just above\n return parsed as Record<string, unknown>;\n }\n}\n\n/**\n * Reads the verdict JSON for the composition root: `--file <path>`, else stdin. Separate from the command\n * so the command stays a function of its inputs.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewInput {\n read(filePath: string): string {\n if (filePath.trim() !== '') {\n if (!fs.existsSync(filePath)) throw new InformAiError(`${WRITE_REVIEW_BIN}: --file ${filePath} does not exist.`);\n return fs.readFileSync(filePath, 'utf8');\n }\n if (process.stdin.isTTY === true) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: pass the verdict JSON on stdin (pnpm ${WRITE_REVIEW_BIN} --checklist <id> <<'EOF' … EOF) or with --file <path>.`);\n }\n return fs.readFileSync(0, 'utf8');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"write-review-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/write-review-command.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,0DAGiC;AACjC,yCAA2D;AAC3D,2EAAgE;AAChE,2EAAiG;AACjG,qEAA2F;AAC3F,uEAA+G;AAE/G,oFAAoF;AACpF,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AAE3E,yDAAyD;AACzD,MAAa,kBAAkB;IAC3B,WAAW,CAAS;IACpB,sGAAsG;IACtG,iEAAiE;IACjE,IAAI,CAAS;IACb,kGAAkG;IAClG,8EAA8E;IAC9E,GAAG,CAAS;IAEZ,YAAY,WAAmB,EAAE,IAAY,EAAE,GAAW;QACtD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;CACJ;AAdD,gDAcC;AAED,iGAAiG;AACjG,MAAa,wBAAwB;IACjC,WAAW,CAAS;IACpB,GAAG,CAAS;IAEZ,YAAY,WAAmB,EAAE,GAAW;QACxC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B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,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACzB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;gBAAE,MAAM,IAAI,4BAAa,CAAC,GAAG,+BAAgB,YAAY,QAAQ,kBAAkB,CAAC,CAAC;YACjH,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAC/B,MAAM,IAAI,4BAAa,CAAC,GAAG,+BAAgB,0CAA0C,+BAAgB,yDAAyD,CAAC,CAAC;QACpK,CAAC;QACD,OAAO,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;CACJ,CAAA;AAXY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,gBAAgB,CAW5B","sourcesContent":["import * as fs from 'fs';\nimport {\n InformAiError, RepoRootFinder, ReviewJsonService, VERDICT_ORANGE, VERDICT_RED, VERDICT_STATUSES, WRITE_REVIEW_BIN, checklistOverrideService,\n summaryJsonPath, toError,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { ReviewStageReceipt, ReviewStageReceiptService } from '../workflow/review-stage-receipt';\nimport { ReviewerIdentity, ReviewerIdentityResolver } from '../workflow/reviewer-identity';\nimport { SubmittedVerdict, VerdictProvenance, VerdictProvenanceService } from '../workflow/verdict-provenance';\n\n/** The only keys a verdict may carry. Anything else is somebody's second schema. */\nconst VERDICT_KEYS = ['id', 'status', 'agent', 'model', 'output'] as const;\n\n/** What `wp-write-review` was asked to do. Data-only. */\nexport class WriteReviewOptions {\n checklistId: string;\n // The verdict JSON itself — read from `--file` or stdin by the composition root, so this command is a\n // function of its inputs and a spec can drive it without a pipe.\n json: string;\n // Where the caller stands — the tree whose review dir and hook stamp are used. Passed in (the bin\n // passes process.cwd()) rather than read here, for the same reason `json` is.\n cwd: string;\n\n constructor(checklistId: string, json: string, cwd: string) {\n this.checklistId = checklistId;\n this.json = json;\n this.cwd = cwd;\n }\n}\n\n/** What `wp-write-review --check` was asked: may this checklist still be reviewed? Data-only. */\nexport class ReviewBudgetCheckOptions {\n checklistId: string;\n cwd: string;\n\n constructor(checklistId: string, cwd: string) {\n this.checklistId = checklistId;\n this.cwd = cwd;\n }\n}\n\n/**\n * `wp-write-review` — the ONE way any reviewer, Claude or Codex, submits a checklist verdict (issue #863).\n *\n * Before it existed a verdict was \"a file with the right shape at the right path\", and that is exactly what\n * a Codex coordinator produced on two merged PRs: the shared-tree guard blocked its reviewer's write, the\n * guard's own cure said to hand the edit to the coordinator, the coordinator wrote all five verdicts, and\n * `wp-finish-upsert-pr` accepted them. Now:\n * 1. the caller is identified by the harness (ReviewerIdentityResolver) and the COORDINATOR is refused;\n * 2. the checklist must be one stage ② briefed this round (its receipt), so a carried verdict cannot be\n * overwritten and a checklist that does not apply cannot be invented;\n * 3. the verdict is validated strictly — the five fields, nothing else;\n * 4. it is written as `review-round<N>-<id>.json` WITH `review-round<N>-<id>.provenance.json`: who, which\n * commit, which in-scope diff, and a hash of the verdict. `wp-finish-upsert-pr` rejects a verdict\n * without one, or one edited since;\n * 5. the round must be inside the budget (issues #1051, #1053): a round above `maxReviewerRounds` records\n * nothing, and a round's verdict is never overwritten, whoever spawned the reviewer. `--check` asks the\n * same question BEFORE a reviewer spends a review on it;\n * 6. the color must fit the round (issue #1053): the FINAL round has no red — its must-fix color is\n * orange, never re-reviewed — and orange is refused before the final round, where red still means\n * \"fix it and it will be reviewed again\".\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewCommand {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly aiBranchName: AiBranchName,\n private readonly receipts: ReviewStageReceiptService,\n private readonly identity: ReviewerIdentityResolver,\n private readonly provenance: VerdictProvenanceService,\n private readonly reviewJsonService: ReviewJsonService,\n ) {}\n\n run(opts: WriteReviewOptions): Promise<void> {\n const id = opts.checklistId.trim();\n const cwd = opts.cwd;\n const repoRoot = this.repoRootFinder.resolveRepoRoot(cwd);\n const featureName = this.aiBranchName.getFeatureName();\n const receipt = this.briefedReceipt(repoRoot, featureName, id);\n // Identity BEFORE parsing: a coordinator is refused whatever it submitted, and the stamp it\n // consumes must not survive to lend itself to a later call.\n const who: ReviewerIdentity = this.identity.resolve(cwd, id);\n this.assertWithinBudget(summaryJsonPath(repoRoot, featureName), receipt, id);\n const verdict = this.parse(opts.json, id, receipt);\n const record = new VerdictProvenance(\n id, who.harness, who.sessionId, who.agentId, who.agentType, receipt.headSha, receipt.scopeHashes[id] ?? '');\n record.round = receipt.round;\n const written = this.provenance.write(summaryJsonPath(repoRoot, featureName), verdict, record);\n process.stdout.write(\n `✅ ${verdict.status.toUpperCase()} verdict for \"${id}\" submitted → ${written}\\n`\n + ` provenance: ${who.harness}${who.agentId === '' ? '' : ` agent ${who.agentId}`}, `\n + `briefed at ${receipt.headSha.slice(0, 8)}, global round ${receipt.round} of ${receipt.maxReviewerRounds}\\n`);\n return Promise.resolve();\n }\n\n /**\n * `wp-write-review --check`: the reviewer's FIRST step. Refuses exactly when {@link run} would refuse\n * on the budget, so a reviewer past the budget learns it before it reviews rather than after.\n */\n check(opts: ReviewBudgetCheckOptions): Promise<void> {\n const id = opts.checklistId.trim();\n const repoRoot = this.repoRootFinder.resolveRepoRoot(opts.cwd);\n const featureName = this.aiBranchName.getFeatureName();\n const receipt = this.briefedReceipt(repoRoot, featureName, id);\n this.assertWithinBudget(summaryJsonPath(repoRoot, featureName), receipt, id);\n const final = this.isFinalRound(receipt)\n ? ` This is the FINAL round: there is no re-review, so you may NOT mark ${VERDICT_RED} — mark every must-fix finding ${VERDICT_ORANGE}.`\n : '';\n process.stdout.write(\n `✅ \"${id}\" may be reviewed: this is review round ${receipt.round} of at most ${receipt.maxReviewerRounds}.${final} `\n + `Review it, then submit with pnpm ${WRITE_REVIEW_BIN} --checklist ${id}.\\n`);\n return Promise.resolve();\n }\n\n /** The last round `maxReviewerRounds` allows — the one with no red (issue #1053). */\n private isFinalRound(receipt: ReviewStageReceipt): boolean {\n return receipt.round >= receipt.maxReviewerRounds;\n }\n\n /**\n * THE ROUND CAP, held by the reviewer's own submission path (issues #1051, #1053). The planner already\n * never briefs past the cap, but an author agent could still spawn a reviewer from an old instructions\n * file — the measured deadlock did exactly that. Two refusals make it mechanical: a round above\n * `maxReviewerRounds` records nothing, and a checklist that already has a verdict in this round (or a\n * later one) gets no second one — a round's verdict is never overwritten.\n */\n private assertWithinBudget(summaryPath: string, receipt: ReviewStageReceipt, id: string): void {\n const max = receipt.maxReviewerRounds;\n const latest = this.reviewJsonService.latestVerdictRound(summaryPath, id);\n if (receipt.round <= max && latest < receipt.round) return;\n const why = receipt.round > max\n ? `this briefing is for review round ${receipt.round}, above maxReviewerRounds (${max})`\n : `it already has a verdict for review round ${latest} (maxReviewerRounds is ${max}), and a round's verdict is never overwritten`;\n throw new InformAiError(\n `I am not allowed to review ${id}: ${why}.\\n`\n + `Do not review it and submit nothing for it; report this refusal, verbatim, to the agent that spawned you. `\n + `The verdict already recorded for it stands (${this.reviewJsonService.latestChecklistResultPath(summaryPath, id) || 'none'}), and `\n + 'the author records any fix with pnpm wp-write-review-fixes.');\n }\n\n /** The stage-② receipt, provided it briefed THIS checklist this round. */\n private briefedReceipt(repoRoot: string, featureName: string, id: string): ReviewStageReceipt {\n if (id === '') throw new InformAiError(`${WRITE_REVIEW_BIN} needs the checklist id: pnpm ${WRITE_REVIEW_BIN} --checklist <id>`);\n const receipt = this.receipts.read(repoRoot, featureName);\n if (receipt === null) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: pnpm wp-review-upsert-pr has not briefed any reviewer on this branch yet, `\n + 'so there is nothing to submit a verdict against.');\n }\n if (!receipt.reviewersBriefed.includes(id) || (receipt.scopeHashes[id] ?? '') === '') {\n const briefed = receipt.reviewersBriefed.length === 0 ? '(none)' : receipt.reviewersBriefed.join(', ');\n throw new InformAiError(`${WRITE_REVIEW_BIN}: checklist \"${id}\" was not briefed by the last pnpm wp-review-upsert-pr `\n + `(briefed this round: ${briefed}). Submit only for a checklist whose instructions file you were handed — `\n + 'a checklist absent here either carries its earlier verdict or does not apply to this diff.');\n }\n return receipt;\n }\n\n /**\n * Strict: an object with exactly the verdict's five fields, every one a string, and a status that fits\n * the round — red only BEFORE the final round, orange only ON it (issue #1053).\n */\n private parse(json: string, id: string, receipt: ReviewStageReceipt): SubmittedVerdict {\n const raw = this.parseObject(json);\n const problems: string[] = [];\n const extra = Object.keys(raw).filter((k: string): boolean => !(VERDICT_KEYS as readonly string[]).includes(k));\n if (extra.includes('override')) {\n problems.push(`\"override\" is not a verdict field — a ship-anyway decision is a HUMAN's, recorded by the coordinating agent in ${checklistOverrideService.overrideFileName(id)}`);\n }\n if (extra.length > 0) problems.push(`unknown field(s) ${extra.map((k: string): string => `\"${k}\"`).join(', ')} — a verdict has exactly: ${VERDICT_KEYS.join(', ')}`);\n if (raw['id'] !== undefined && this.text(raw, 'id') !== id) problems.push(`\"id\" is ${JSON.stringify(raw['id'])} but --checklist is \"${id}\"`);\n const status = this.text(raw, 'status').toLowerCase();\n // webpieces-disable no-any-unknown -- comparing against the readonly literal tuple of valid colors\n if (!(VERDICT_STATUSES as readonly string[]).includes(status)) problems.push(`\"status\" must be one of ${VERDICT_STATUSES.join(', ')}`);\n problems.push(...this.colorForRound(status, receipt));\n for (const key of ['agent', 'model', 'output']) {\n if (this.text(raw, key) === '') problems.push(`\"${key}\" must be a non-empty string${key === 'output' ? '' : ' (use \"unknown\" when unavailable)'}`);\n }\n if (problems.length > 0) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict for \"${id}\" was NOT submitted:\\n`\n + problems.map((p: string): string => ` • ${p}`).join('\\n'));\n }\n return new SubmittedVerdict(id, status, this.text(raw, 'agent'), this.text(raw, 'model'), raw['output'] as string);\n }\n\n /**\n * The round decides which blocking color exists. The FINAL round's red would mean \"fix it and it will be\n * reviewed again\", and there is no again — so it is refused and orange named. Orange before the final\n * round would waive a re-review that the budget still pays for — so it is refused and red named.\n */\n private colorForRound(status: string, receipt: ReviewStageReceipt): string[] {\n const round = `review round ${receipt.round} of ${receipt.maxReviewerRounds}`;\n if (status === VERDICT_RED && this.isFinalRound(receipt)) {\n return [`\"status\": \"${VERDICT_RED}\" is not allowed: ${round} is the FINAL round, and there is no re-review. `\n + `Mark anything that must be fixed \"${VERDICT_ORANGE}\", with a concrete, actionable fix in \"output\" — the author applies it `\n + 'best effort and ships without another review.'];\n }\n if (status === VERDICT_ORANGE && !this.isFinalRound(receipt)) {\n return [`\"status\": \"${VERDICT_ORANGE}\" is only for the FINAL review round, and ${round} is not it. `\n + `Use \"${VERDICT_RED}\" for a must-fix finding: the author's fix will be reviewed again next round.`];\n }\n return [];\n }\n\n // webpieces-disable no-any-unknown -- one field of the opaque submitted object, narrowed to a trimmed string\n private text(raw: Record<string, unknown>, key: string): string {\n const value = raw[key];\n return typeof value === 'string' ? value.trim() : '';\n }\n\n // webpieces-disable no-any-unknown -- the submitted JSON is opaque until parse() narrows every field\n private parseObject(json: string): Record<string, unknown> {\n // webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed\n let parsed: unknown = null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: a JSON syntax error becomes the AI-facing refusal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n parsed = JSON.parse(json);\n } catch (err: unknown) {\n const error = toError(err);\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict is not valid JSON.`, { cause: error });\n }\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: the verdict must be ONE JSON object.`);\n }\n // webpieces-disable no-any-unknown -- narrowed to a plain object just above\n return parsed as Record<string, unknown>;\n }\n}\n\n/**\n * Reads the verdict JSON for the composition root: `--file <path>`, else stdin. Separate from the command\n * so the command stays a function of its inputs.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewInput {\n read(filePath: string): string {\n if (filePath.trim() !== '') {\n if (!fs.existsSync(filePath)) throw new InformAiError(`${WRITE_REVIEW_BIN}: --file ${filePath} does not exist.`);\n return fs.readFileSync(filePath, 'utf8');\n }\n if (process.stdin.isTTY === true) {\n throw new InformAiError(`${WRITE_REVIEW_BIN}: pass the verdict JSON on stdin (pnpm ${WRITE_REVIEW_BIN} --checklist <id> <<'EOF' … EOF) or with --file <path>.`);\n }\n return fs.readFileSync(0, 'utf8');\n }\n}\n"]}
|
|
@@ -7,7 +7,11 @@ export declare class WriteReviewFixesOptions {
|
|
|
7
7
|
cwd: string;
|
|
8
8
|
constructor(json: string, cwd: string);
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Coordinator-owned writer for the SHA-bound response to a completed reviewer round: one fix per RED (a round
|
|
12
|
+
* that is not the last, re-reviewed next round) or per ORANGE (the final round, never re-reviewed — finish
|
|
13
|
+
* stamps each on the dashboard with its resolution). Written as `review-round<N>-fixes.json`, once.
|
|
14
|
+
*/
|
|
11
15
|
export declare class WriteReviewFixesCommand {
|
|
12
16
|
private readonly repoRootFinder;
|
|
13
17
|
private readonly aiBranchName;
|
|
@@ -17,7 +17,11 @@ class WriteReviewFixesOptions {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
exports.WriteReviewFixesOptions = WriteReviewFixesOptions;
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Coordinator-owned writer for the SHA-bound response to a completed reviewer round: one fix per RED (a round
|
|
22
|
+
* that is not the last, re-reviewed next round) or per ORANGE (the final round, never re-reviewed — finish
|
|
23
|
+
* stamps each on the dashboard with its resolution). Written as `review-round<N>-fixes.json`, once.
|
|
24
|
+
*/
|
|
21
25
|
let WriteReviewFixesCommand = class WriteReviewFixesCommand {
|
|
22
26
|
repoRootFinder;
|
|
23
27
|
aiBranchName;
|
|
@@ -36,7 +40,7 @@ let WriteReviewFixesCommand = class WriteReviewFixesCommand {
|
|
|
36
40
|
if (receipt === null)
|
|
37
41
|
throw new rules_config_1.InformAiError('wp-write-review-fixes: no reviewer round has started on this branch.');
|
|
38
42
|
const written = this.rounds.writeRemediation(repoRoot, (0, rules_config_1.summaryJsonPath)(repoRoot, featureName), receipt, opts.json);
|
|
39
|
-
process.stdout.write(`✅ SHA-bound
|
|
43
|
+
process.stdout.write(`✅ SHA-bound fixes recorded → ${written}\n`);
|
|
40
44
|
return Promise.resolve();
|
|
41
45
|
}
|
|
42
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write-review-fixes-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/write-review-fixes-command.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,0DAAyF;AACzF,yCAA2D;AAC3D,2EAAgE;AAChE,uEAAyE;AACzE,2EAA6E;AAE7E,MAAa,uBAAuB;IAChC,IAAI,CAAS;IACb,GAAG,CAAS;IAEZ,YAAY,IAAY,EAAE,GAAW;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;CACJ;AARD,0DAQC;AAED
|
|
1
|
+
{"version":3,"file":"write-review-fixes-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/write-review-fixes-command.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,0DAAyF;AACzF,yCAA2D;AAC3D,2EAAgE;AAChE,uEAAyE;AACzE,2EAA6E;AAE7E,MAAa,uBAAuB;IAChC,IAAI,CAAS;IACb,GAAG,CAAS;IA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B,4CAAuB;GAL3C,uBAAuB,CAiBnC;AAGM,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAC9B,IAAI,CAAC,QAAgB;QACjB,IAAI,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACzB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC;gBAAE,MAAM,IAAI,4BAAa,CAAC,iCAAiC,QAAQ,kBAAkB,CAAC,CAAC;YACnH,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC7C,CAAC;QACD,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAC/B,MAAM,IAAI,4BAAa,CAAC,kEAAkE,CAAC,CAAC;QAChG,CAAC;QACD,OAAO,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;CACJ,CAAA;AAXY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,qBAAqB,CAWjC","sourcesContent":["import * as fs from 'fs';\nimport { RepoRootFinder, InformAiError, summaryJsonPath } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from '../workflow/git-readAiBranchName';\nimport { ReviewRoundStateService } from '../workflow/review-round-state';\nimport { ReviewStageReceiptService } from '../workflow/review-stage-receipt';\n\nexport class WriteReviewFixesOptions {\n json: string;\n cwd: string;\n\n constructor(json: string, cwd: string) {\n this.json = json;\n this.cwd = cwd;\n }\n}\n\n/**\n * Coordinator-owned writer for the SHA-bound response to a completed reviewer round: one fix per RED (a round\n * that is not the last, re-reviewed next round) or per ORANGE (the final round, never re-reviewed — finish\n * stamps each on the dashboard with its resolution). Written as `review-round<N>-fixes.json`, once.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewFixesCommand {\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly aiBranchName: AiBranchName,\n private readonly receipts: ReviewStageReceiptService,\n private readonly rounds: ReviewRoundStateService,\n ) {}\n\n run(opts: WriteReviewFixesOptions): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(opts.cwd);\n const featureName = this.aiBranchName.getFeatureName();\n const receipt = this.receipts.read(repoRoot, featureName);\n if (receipt === null) throw new InformAiError('wp-write-review-fixes: no reviewer round has started on this branch.');\n const written = this.rounds.writeRemediation(repoRoot, summaryJsonPath(repoRoot, featureName), receipt, opts.json);\n process.stdout.write(`✅ SHA-bound fixes recorded → ${written}\\n`);\n return Promise.resolve();\n }\n}\n\n@injectable(bindingScopeValues.Singleton)\nexport class WriteReviewFixesInput {\n read(filePath: string): string {\n if (filePath.trim() !== '') {\n if (!fs.existsSync(filePath)) throw new InformAiError(`wp-write-review-fixes: --file ${filePath} does not exist.`);\n return fs.readFileSync(filePath, 'utf8');\n }\n if (process.stdin.isTTY === true) {\n throw new InformAiError('wp-write-review-fixes: pass JSON on stdin or with --file <path>.');\n }\n return fs.readFileSync(0, 'utf8');\n }\n}\n"]}
|
|
@@ -11,7 +11,7 @@ import { ReviewUpsertPrCommand, ReviewUpsertPrOptions } from './commands/review-
|
|
|
11
11
|
import { ReapWorktreeCommand } from './commands/reap-worktree-command';
|
|
12
12
|
import { BuildCommand, BuildOptions } from './commands/build-command';
|
|
13
13
|
import { AwaitReviewsCommand } from './commands/await-reviews-command';
|
|
14
|
-
import { WriteReviewCommand, WriteReviewOptions } from './commands/write-review-command';
|
|
14
|
+
import { ReviewBudgetCheckOptions, WriteReviewCommand, WriteReviewOptions } from './commands/write-review-command';
|
|
15
15
|
import { WriteReviewFixesCommand, WriteReviewFixesOptions } from './commands/write-review-fixes-command';
|
|
16
16
|
import { AwaitChecksCommand, AwaitChecksOptions } from './commands/await-checks-command';
|
|
17
17
|
import { PushDevCommand, PushDevOptions } from './commands/push-dev-command';
|
|
@@ -82,6 +82,8 @@ export declare class PrGateApp {
|
|
|
82
82
|
* Not blocked during a `wp-push-dev --resolve`: it writes only this branch's review state.
|
|
83
83
|
*/
|
|
84
84
|
writeReview(opts: WriteReviewOptions): Promise<void>;
|
|
85
|
+
/** `wp-write-review --check`: may this checklist still be reviewed on this branch (issue #1051)? */
|
|
86
|
+
checkReviewBudget(opts: ReviewBudgetCheckOptions): Promise<void>;
|
|
85
87
|
/** `wp-write-review-fixes`: the coordinator records committed fixes without editing a reviewer verdict. */
|
|
86
88
|
writeReviewFixes(opts: WriteReviewFixesOptions): Promise<void>;
|
|
87
89
|
/**
|
|
@@ -124,6 +124,10 @@ let PrGateApp = class PrGateApp {
|
|
|
124
124
|
writeReview(opts) {
|
|
125
125
|
return this.writeReviewCommand.run(opts);
|
|
126
126
|
}
|
|
127
|
+
/** `wp-write-review --check`: may this checklist still be reviewed on this branch (issue #1051)? */
|
|
128
|
+
checkReviewBudget(opts) {
|
|
129
|
+
return this.writeReviewCommand.check(opts);
|
|
130
|
+
}
|
|
127
131
|
/** `wp-write-review-fixes`: the coordinator records committed fixes without editing a reviewer verdict. */
|
|
128
132
|
writeReviewFixes(opts) {
|
|
129
133
|
return this.writeReviewFixesCommand.run(opts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pr-gate-app.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/pr-gate-app.ts"],"names":[],"mappings":";;;;AAAA,0DAAyD;AACzD,yCAA2D;AAC3D,0EAAqE;AACrE,4EAAuE;AACvE,gFAA0E;AAC1E,kFAA4E;AAC5E,gEAA4D;AAE5D,oEAA+D;AAC/D,gEAA0E;AAC1E,kEAA6D;AAC7D,kFAAmG;AACnG,4EAAuE;AACvE,4DAAsE;AACtE,4EAAuE;AACvE,0EAAyF;AACzF,sFAAyG;AACzG,0EAAyF;AACzF,kEAA6E;AAC7E,gFAAgG;AAChG,4EAAsE;AACtE,8DAA8D;AAC9D,0DAAyD;AAEzD;;;;;GAKG;AAGI,IAAM,SA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CAAC,qBAAqB,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,+GAA+G;IAC/G,OAAO;QACH,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC;IACrC,CAAC;CACJ,CAAA;AA1KY,8BAAS;oBAAT,SAAS;IAFrB,IAAA,6BAAc,GAAE;IAChB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGI,yCAAkB;QACjB,2CAAmB;QAClB,8CAAoB;QACnB,gDAAqB;QAC5B,gCAAc;QACb,mCAAe;QACjB,+BAAa;QACZ,iCAAc;QACP,gDAAqB;QACvB,2CAAmB;QAC1B,4BAAY;QACL,2CAAmB;QACpB,yCAAkB;QACb,oDAAuB;QAC5B,yCAAkB;QACtB,iCAAc;QACR,8CAAoB;QACtB,0CAAkB;QACnB,kCAAiB;QACpB,6BAAc;GArB1C,SAAS,CA0KrB","sourcesContent":["import { DocumentDesign } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { StartUpdateCommand } from './commands/start-update-command';\nimport { FinishUpdateCommand } from './commands/finish-update-command';\nimport { StartUpsertPrCommand } from './commands/start-upsert-pr-command';\nimport { FinishUpsertPrCommand } from './commands/finish-upsert-pr-command';\nimport { CleanupCommand } from './commands/cleanup-command';\nimport { CleanupOptions } from './commands/cleanup-options';\nimport { SyncMainCommand } from './commands/sync-main-command';\nimport { LandPrCommand, LandPrRequest } from './commands/land-pr-command';\nimport { CheckPrCommand } from './commands/check-pr-command';\nimport { ReviewUpsertPrCommand, ReviewUpsertPrOptions } from './commands/review-upsert-pr-command';\nimport { ReapWorktreeCommand } from './commands/reap-worktree-command';\nimport { BuildCommand, BuildOptions } from './commands/build-command';\nimport { AwaitReviewsCommand } from './commands/await-reviews-command';\nimport { WriteReviewCommand, WriteReviewOptions } from './commands/write-review-command';\nimport { WriteReviewFixesCommand, WriteReviewFixesOptions } from './commands/write-review-fixes-command';\nimport { AwaitChecksCommand, AwaitChecksOptions } from './commands/await-checks-command';\nimport { PushDevCommand, PushDevOptions } from './commands/push-dev-command';\nimport { FinishPushDevCommand, FinishPushDevOptions } from './commands/finish-push-dev-command';\nimport { HumanPostPrCommand } from './commands/human-post-pr-command';\nimport { PushDevStateStore } from './workflow/push-dev-state';\nimport { RepoRootFinder } from '@webpieces/rules-config';\n\n/**\n * The pr-gate application root. `container.get(PrGateApp)` resolves the entire workflow DAG (the command\n * classes → the injected git/merge/dashboard services). `@DocumentDesign` marks it the\n * top-of-DAG the DI-design analyzer roots on, so `role:app` pr-gate draws its design. Each `bin/*`\n * entry resolves THIS and calls the matching command method.\n */\n@DocumentDesign()\n@injectable(bindingScopeValues.Singleton)\nexport class PrGateApp {\n constructor(\n private readonly startUpdateCommand: StartUpdateCommand,\n private readonly finishUpdateCommand: FinishUpdateCommand,\n private readonly startUpsertPrCommand: StartUpsertPrCommand,\n private readonly finishUpsertPrCommand: FinishUpsertPrCommand,\n private readonly cleanupCommand: CleanupCommand,\n private readonly syncMainCommand: SyncMainCommand,\n private readonly landPrCommand: LandPrCommand,\n private readonly checkPrCommand: CheckPrCommand,\n private readonly reviewUpsertPrCommand: ReviewUpsertPrCommand,\n private readonly reapWorktreeCommand: ReapWorktreeCommand,\n private readonly buildCommand: BuildCommand,\n private readonly awaitReviewsCommand: AwaitReviewsCommand,\n private readonly writeReviewCommand: WriteReviewCommand,\n private readonly writeReviewFixesCommand: WriteReviewFixesCommand,\n private readonly awaitChecksCommand: AwaitChecksCommand,\n private readonly pushDevCommand: PushDevCommand,\n private readonly finishPushDevCommand: FinishPushDevCommand,\n private readonly humanPostPrCommand: HumanPostPrCommand,\n private readonly pushDevStateStore: PushDevStateStore,\n private readonly repoRootFinder: RepoRootFinder,\n ) {}\n\n /**\n * Refuse `command` while a `wp-push-dev --resolve` is half-finished.\n *\n * Enforced HERE, at the one place every bin funnels through, rather than in each command: a resolve\n * parks the checkout on a throwaway branch, so every command below would act on a branch that is not\n * the one it thinks it is. Putting the check in nine constructors is nine chances to forget it in the\n * tenth. PushDevStateStore owns the blocked list AND renders the hint from it, so the two cannot drift.\n */\n private assertNoResolveInProgress(command: string): void {\n if (!this.pushDevStateStore.isBlockedDuringResolve(command)) return;\n this.pushDevStateStore.assertIdle(\n this.repoRootFinder.resolveRepoRoot(process.cwd()),\n command,\n );\n }\n\n /** `wp-push-dev`: publish a DISPOSABLE copy of this branch for the shared dev environment. No PR, no build. */\n pushDev(opts: PushDevOptions = new PushDevOptions()): Promise<void> {\n return this.pushDevCommand.run(opts);\n }\n\n /** `wp-finish-push-dev`: commit a resolved dev composition and publish it (conflict path only). */\n finishPushDev(opts: FinishPushDevOptions = new FinishPushDevOptions()): Promise<void> {\n return this.finishPushDevCommand.run(opts);\n }\n\n /**\n * INTERNAL (`wp-reap-worktree.js`, no `bin` entry): remove ONE named worktree and its branch.\n * `wp-land-pr` spawns it with cwd = the primary clone so the tree it just landed from can be\n * reaped by a process that is not standing in it.\n */\n reapWorktree(args: string[]): Promise<void> {\n return this.reapWorktreeCommand.run(args);\n }\n\n /**\n * `wp-build`: run this repo's ONE configured build (`commands.pr-gate.buildCommand`) — the same\n * command, resolved by the same resolver, that the PR gate's build stage runs. Not blocked during a\n * `wp-push-dev --resolve`: it mutates nothing and reads no branch state.\n */\n build(opts: BuildOptions): Promise<void> {\n return this.buildCommand.run(opts);\n }\n\n /**\n * `wp-await-reviews`: BLOCK until every reviewer verdict this branch owes has landed, then print\n * them. Not blocked during a `wp-push-dev --resolve`: it reads verdict files and mutates nothing.\n */\n awaitReviews(): Promise<void> {\n return this.awaitReviewsCommand.run();\n }\n\n /**\n * `wp-write-review`: a reviewer subagent submits ONE checklist verdict, with provenance (issue #863).\n * Not blocked during a `wp-push-dev --resolve`: it writes only this branch's review state.\n */\n writeReview(opts: WriteReviewOptions): Promise<void> {\n return this.writeReviewCommand.run(opts);\n }\n\n /** `wp-write-review-fixes`: the coordinator records committed fixes without editing a reviewer verdict. */\n writeReviewFixes(opts: WriteReviewFixesOptions): Promise<void> {\n return this.writeReviewFixesCommand.run(opts);\n }\n\n /**\n * `wp-await-checks --pr <n>`: BLOCK until that PR's checks stop running, then print where they\n * landed. Read-only against GitHub, so it too is allowed during a resolve.\n */\n awaitChecks(opts: AwaitChecksOptions): Promise<void> {\n return this.awaitChecksCommand.run(opts);\n }\n\n /** `wp-start-update`: 3-point squash-update from main (no PR). */\n startUpdate(): Promise<void> {\n this.assertNoResolveInProgress('wp-start-update');\n return this.startUpdateCommand.run();\n }\n\n /** `wp-finish-update`: validate + finalize a resolved 3-point merge (no PR). */\n finishUpdate(): Promise<void> {\n this.assertNoResolveInProgress('wp-finish-update');\n return this.finishUpdateCommand.run();\n }\n\n /** `wp-start-upsert-pr`: update from main (3-point merge), hand off summary.json. No build gate, no push. */\n startUpsertPr(): Promise<void> {\n this.assertNoResolveInProgress('wp-start-upsert-pr');\n return this.startUpsertPrCommand.run();\n }\n\n /** `wp-finish-upsert-pr`: finalize merge, authoritative build gate, dashboard, create/update PR. */\n finishUpsertPr(): Promise<void> {\n this.assertNoResolveInProgress('wp-finish-upsert-pr');\n return this.finishUpsertPrCommand.run();\n }\n\n /** `wp-human-post-pr`: human-attested post with optional local build and no automated review. */\n humanPostPr(): Promise<void> {\n this.assertNoResolveInProgress('wp-human-post-pr');\n return this.humanPostPrCommand.run();\n }\n\n /**\n * `wp-cleanup`: reap what is provably merged AND every zero-commit husk, then report the rest with\n * the exact flags that take it. `options` carries what argv said — see CleanupOptions.\n */\n cleanup(options: CleanupOptions): Promise<void> {\n this.assertNoResolveInProgress('wp-cleanup');\n return this.cleanupCommand.run(options);\n }\n\n /**\n * `wp-sync-main`: go to main, fast-forward it, reap dead worktrees and branches, and sweep\n * the orphan directories a project move leaves behind. Replaces `git checkout main && git pull\n * origin main` outright — see SyncMainCommand for why the old pair must stop being accepted\n * rather than surviving beside this.\n */\n syncMain(): Promise<void> {\n this.assertNoResolveInProgress('wp-sync-main');\n return this.syncMainCommand.run();\n }\n\n /**\n * `wp-land-pr`: squash-merge a PR into main with the compact commit body — this branch's by default,\n * or the one `--pr <n>` names, which is how a coordinator finishes a gone agent's work.\n */\n landPr(request: LandPrRequest): Promise<void> {\n this.assertNoResolveInProgress('wp-land-pr');\n return this.landPrCommand.run(request);\n }\n\n /**\n * `wp-review-upsert-pr`: STAGE ② — validate the 3-point merge, run the build gate, extract this\n * branch's diff, and brief the reviewer subagents. Unlike the report-only command it replaces, this CAN\n * fail — before any reviewer is spawned, so a broken branch costs no reviewer tokens.\n */\n reviewUpsertPr(opts: ReviewUpsertPrOptions = new ReviewUpsertPrOptions()): Promise<void> {\n this.assertNoResolveInProgress('wp-review-upsert-pr');\n return this.reviewUpsertPrCommand.run(opts);\n }\n\n /** `wp-check-pr`: READ-ONLY CI check — verify the PR body carries a valid HMAC gate token for its head sha. */\n checkPr(): Promise<void> {\n return this.checkPrCommand.run();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pr-gate-app.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/pr-gate-app.ts"],"names":[],"mappings":";;;;AAAA,0DAAyD;AACzD,yCAA2D;AAC3D,0EAAqE;AACrE,4EAAuE;AACvE,gFAA0E;AAC1E,kFAA4E;AAC5E,gEAA4D;AAE5D,oEAA+D;AAC/D,gEAA0E;AAC1E,kEAA6D;AAC7D,kFAAmG;AACnG,4EAAuE;AACvE,4DAAsE;AACtE,4EAAuE;AACvE,0EAAmH;AACnH,sFAAyG;AACzG,0EAAyF;AACzF,kEAA6E;AAC7E,gFAAgG;AAChG,4EAAsE;AACtE,8DAA8D;AAC9D,0DAAyD;AAEzD;;;;;GAKG;AAGI,IAAM,SAAS,GAAf,MAAM,SAAS;IAEG;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IApBrB,YACqB,kBAAsC,EACtC,mBAA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ACtD,OAAO,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,+GAA+G;IAC/G,OAAO;QACH,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC;IACrC,CAAC;CACJ,CAAA;AA/KY,8BAAS;oBAAT,SAAS;IAFrB,IAAA,6BAAc,GAAE;IAChB,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGI,yCAAkB;QACjB,2CAAmB;QAClB,8CAAoB;QACnB,gDAAqB;QAC5B,gCAAc;QACb,mCAAe;QACjB,+BAAa;QACZ,iCAAc;QACP,gDAAqB;QACvB,2CAAmB;QAC1B,4BAAY;QACL,2CAAmB;QACpB,yCAAkB;QACb,oDAAuB;QAC5B,yCAAkB;QACtB,iCAAc;QACR,8CAAoB;QACtB,0CAAkB;QACnB,kCAAiB;QACpB,6BAAc;GArB1C,SAAS,CA+KrB","sourcesContent":["import { DocumentDesign } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { StartUpdateCommand } from './commands/start-update-command';\nimport { FinishUpdateCommand } from './commands/finish-update-command';\nimport { StartUpsertPrCommand } from './commands/start-upsert-pr-command';\nimport { FinishUpsertPrCommand } from './commands/finish-upsert-pr-command';\nimport { CleanupCommand } from './commands/cleanup-command';\nimport { CleanupOptions } from './commands/cleanup-options';\nimport { SyncMainCommand } from './commands/sync-main-command';\nimport { LandPrCommand, LandPrRequest } from './commands/land-pr-command';\nimport { CheckPrCommand } from './commands/check-pr-command';\nimport { ReviewUpsertPrCommand, ReviewUpsertPrOptions } from './commands/review-upsert-pr-command';\nimport { ReapWorktreeCommand } from './commands/reap-worktree-command';\nimport { BuildCommand, BuildOptions } from './commands/build-command';\nimport { AwaitReviewsCommand } from './commands/await-reviews-command';\nimport { ReviewBudgetCheckOptions, WriteReviewCommand, WriteReviewOptions } from './commands/write-review-command';\nimport { WriteReviewFixesCommand, WriteReviewFixesOptions } from './commands/write-review-fixes-command';\nimport { AwaitChecksCommand, AwaitChecksOptions } from './commands/await-checks-command';\nimport { PushDevCommand, PushDevOptions } from './commands/push-dev-command';\nimport { FinishPushDevCommand, FinishPushDevOptions } from './commands/finish-push-dev-command';\nimport { HumanPostPrCommand } from './commands/human-post-pr-command';\nimport { PushDevStateStore } from './workflow/push-dev-state';\nimport { RepoRootFinder } from '@webpieces/rules-config';\n\n/**\n * The pr-gate application root. `container.get(PrGateApp)` resolves the entire workflow DAG (the command\n * classes → the injected git/merge/dashboard services). `@DocumentDesign` marks it the\n * top-of-DAG the DI-design analyzer roots on, so `role:app` pr-gate draws its design. Each `bin/*`\n * entry resolves THIS and calls the matching command method.\n */\n@DocumentDesign()\n@injectable(bindingScopeValues.Singleton)\nexport class PrGateApp {\n constructor(\n private readonly startUpdateCommand: StartUpdateCommand,\n private readonly finishUpdateCommand: FinishUpdateCommand,\n private readonly startUpsertPrCommand: StartUpsertPrCommand,\n private readonly finishUpsertPrCommand: FinishUpsertPrCommand,\n private readonly cleanupCommand: CleanupCommand,\n private readonly syncMainCommand: SyncMainCommand,\n private readonly landPrCommand: LandPrCommand,\n private readonly checkPrCommand: CheckPrCommand,\n private readonly reviewUpsertPrCommand: ReviewUpsertPrCommand,\n private readonly reapWorktreeCommand: ReapWorktreeCommand,\n private readonly buildCommand: BuildCommand,\n private readonly awaitReviewsCommand: AwaitReviewsCommand,\n private readonly writeReviewCommand: WriteReviewCommand,\n private readonly writeReviewFixesCommand: WriteReviewFixesCommand,\n private readonly awaitChecksCommand: AwaitChecksCommand,\n private readonly pushDevCommand: PushDevCommand,\n private readonly finishPushDevCommand: FinishPushDevCommand,\n private readonly humanPostPrCommand: HumanPostPrCommand,\n private readonly pushDevStateStore: PushDevStateStore,\n private readonly repoRootFinder: RepoRootFinder,\n ) {}\n\n /**\n * Refuse `command` while a `wp-push-dev --resolve` is half-finished.\n *\n * Enforced HERE, at the one place every bin funnels through, rather than in each command: a resolve\n * parks the checkout on a throwaway branch, so every command below would act on a branch that is not\n * the one it thinks it is. Putting the check in nine constructors is nine chances to forget it in the\n * tenth. PushDevStateStore owns the blocked list AND renders the hint from it, so the two cannot drift.\n */\n private assertNoResolveInProgress(command: string): void {\n if (!this.pushDevStateStore.isBlockedDuringResolve(command)) return;\n this.pushDevStateStore.assertIdle(\n this.repoRootFinder.resolveRepoRoot(process.cwd()),\n command,\n );\n }\n\n /** `wp-push-dev`: publish a DISPOSABLE copy of this branch for the shared dev environment. No PR, no build. */\n pushDev(opts: PushDevOptions = new PushDevOptions()): Promise<void> {\n return this.pushDevCommand.run(opts);\n }\n\n /** `wp-finish-push-dev`: commit a resolved dev composition and publish it (conflict path only). */\n finishPushDev(opts: FinishPushDevOptions = new FinishPushDevOptions()): Promise<void> {\n return this.finishPushDevCommand.run(opts);\n }\n\n /**\n * INTERNAL (`wp-reap-worktree.js`, no `bin` entry): remove ONE named worktree and its branch.\n * `wp-land-pr` spawns it with cwd = the primary clone so the tree it just landed from can be\n * reaped by a process that is not standing in it.\n */\n reapWorktree(args: string[]): Promise<void> {\n return this.reapWorktreeCommand.run(args);\n }\n\n /**\n * `wp-build`: run this repo's ONE configured build (`commands.pr-gate.buildCommand`) — the same\n * command, resolved by the same resolver, that the PR gate's build stage runs. Not blocked during a\n * `wp-push-dev --resolve`: it mutates nothing and reads no branch state.\n */\n build(opts: BuildOptions): Promise<void> {\n return this.buildCommand.run(opts);\n }\n\n /**\n * `wp-await-reviews`: BLOCK until every reviewer verdict this branch owes has landed, then print\n * them. Not blocked during a `wp-push-dev --resolve`: it reads verdict files and mutates nothing.\n */\n awaitReviews(): Promise<void> {\n return this.awaitReviewsCommand.run();\n }\n\n /**\n * `wp-write-review`: a reviewer subagent submits ONE checklist verdict, with provenance (issue #863).\n * Not blocked during a `wp-push-dev --resolve`: it writes only this branch's review state.\n */\n writeReview(opts: WriteReviewOptions): Promise<void> {\n return this.writeReviewCommand.run(opts);\n }\n\n /** `wp-write-review --check`: may this checklist still be reviewed on this branch (issue #1051)? */\n checkReviewBudget(opts: ReviewBudgetCheckOptions): Promise<void> {\n return this.writeReviewCommand.check(opts);\n }\n\n /** `wp-write-review-fixes`: the coordinator records committed fixes without editing a reviewer verdict. */\n writeReviewFixes(opts: WriteReviewFixesOptions): Promise<void> {\n return this.writeReviewFixesCommand.run(opts);\n }\n\n /**\n * `wp-await-checks --pr <n>`: BLOCK until that PR's checks stop running, then print where they\n * landed. Read-only against GitHub, so it too is allowed during a resolve.\n */\n awaitChecks(opts: AwaitChecksOptions): Promise<void> {\n return this.awaitChecksCommand.run(opts);\n }\n\n /** `wp-start-update`: 3-point squash-update from main (no PR). */\n startUpdate(): Promise<void> {\n this.assertNoResolveInProgress('wp-start-update');\n return this.startUpdateCommand.run();\n }\n\n /** `wp-finish-update`: validate + finalize a resolved 3-point merge (no PR). */\n finishUpdate(): Promise<void> {\n this.assertNoResolveInProgress('wp-finish-update');\n return this.finishUpdateCommand.run();\n }\n\n /** `wp-start-upsert-pr`: update from main (3-point merge), hand off summary.json. No build gate, no push. */\n startUpsertPr(): Promise<void> {\n this.assertNoResolveInProgress('wp-start-upsert-pr');\n return this.startUpsertPrCommand.run();\n }\n\n /** `wp-finish-upsert-pr`: finalize merge, authoritative build gate, dashboard, create/update PR. */\n finishUpsertPr(): Promise<void> {\n this.assertNoResolveInProgress('wp-finish-upsert-pr');\n return this.finishUpsertPrCommand.run();\n }\n\n /** `wp-human-post-pr`: human-attested post with optional local build and no automated review. */\n humanPostPr(): Promise<void> {\n this.assertNoResolveInProgress('wp-human-post-pr');\n return this.humanPostPrCommand.run();\n }\n\n /**\n * `wp-cleanup`: reap what is provably merged AND every zero-commit husk, then report the rest with\n * the exact flags that take it. `options` carries what argv said — see CleanupOptions.\n */\n cleanup(options: CleanupOptions): Promise<void> {\n this.assertNoResolveInProgress('wp-cleanup');\n return this.cleanupCommand.run(options);\n }\n\n /**\n * `wp-sync-main`: go to main, fast-forward it, reap dead worktrees and branches, and sweep\n * the orphan directories a project move leaves behind. Replaces `git checkout main && git pull\n * origin main` outright — see SyncMainCommand for why the old pair must stop being accepted\n * rather than surviving beside this.\n */\n syncMain(): Promise<void> {\n this.assertNoResolveInProgress('wp-sync-main');\n return this.syncMainCommand.run();\n }\n\n /**\n * `wp-land-pr`: squash-merge a PR into main with the compact commit body — this branch's by default,\n * or the one `--pr <n>` names, which is how a coordinator finishes a gone agent's work.\n */\n landPr(request: LandPrRequest): Promise<void> {\n this.assertNoResolveInProgress('wp-land-pr');\n return this.landPrCommand.run(request);\n }\n\n /**\n * `wp-review-upsert-pr`: STAGE ② — validate the 3-point merge, run the build gate, extract this\n * branch's diff, and brief the reviewer subagents. Unlike the report-only command it replaces, this CAN\n * fail — before any reviewer is spawned, so a broken branch costs no reviewer tokens.\n */\n reviewUpsertPr(opts: ReviewUpsertPrOptions = new ReviewUpsertPrOptions()): Promise<void> {\n this.assertNoResolveInProgress('wp-review-upsert-pr');\n return this.reviewUpsertPrCommand.run(opts);\n }\n\n /** `wp-check-pr`: READ-ONLY CI check — verify the PR body carries a valid HMAC gate token for its head sha. */\n checkPr(): Promise<void> {\n return this.checkPrCommand.run();\n }\n}\n"]}
|