@webpieces/pr-gate 0.4.801 → 0.4.803
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 +4 -3
- package/src/scripts/commands/await-reviews-command.d.ts +8 -2
- package/src/scripts/commands/await-reviews-command.js +27 -5
- package/src/scripts/commands/await-reviews-command.js.map +1 -1
- package/src/scripts/commands/review-upsert-pr-command.js +12 -2
- package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/write-review-command.d.ts +50 -0
- package/src/scripts/commands/write-review-command.js +175 -0
- package/src/scripts/commands/write-review-command.js.map +1 -0
- package/src/scripts/pr-gate-app.d.ts +8 -1
- package/src/scripts/pr-gate-app.js +12 -1
- package/src/scripts/pr-gate-app.js.map +1 -1
- package/src/scripts/workflow/checklist-scanner.d.ts +27 -1
- package/src/scripts/workflow/checklist-scanner.js +52 -4
- package/src/scripts/workflow/checklist-scanner.js.map +1 -1
- package/src/scripts/workflow/checklist-scope-hasher.d.ts +34 -0
- package/src/scripts/workflow/checklist-scope-hasher.js +67 -0
- package/src/scripts/workflow/checklist-scope-hasher.js.map +1 -0
- package/src/scripts/workflow/diff-materializer.d.ts +1 -1
- package/src/scripts/workflow/diff-materializer.js +2 -2
- package/src/scripts/workflow/diff-materializer.js.map +1 -1
- package/src/scripts/workflow/provenance-enforcer.d.ts +8 -1
- package/src/scripts/workflow/provenance-enforcer.js +34 -7
- package/src/scripts/workflow/provenance-enforcer.js.map +1 -1
- package/src/scripts/workflow/review-report.d.ts +19 -0
- package/src/scripts/workflow/review-report.js +58 -12
- package/src/scripts/workflow/review-report.js.map +1 -1
- package/src/scripts/workflow/review-stage-receipt.d.ts +9 -0
- package/src/scripts/workflow/review-stage-receipt.js +29 -1
- package/src/scripts/workflow/review-stage-receipt.js.map +1 -1
- package/src/scripts/workflow/reviewer-briefing-builder.d.ts +3 -2
- package/src/scripts/workflow/reviewer-briefing-builder.js +4 -2
- package/src/scripts/workflow/reviewer-briefing-builder.js.map +1 -1
- package/src/scripts/workflow/reviewer-identity.d.ts +39 -0
- package/src/scripts/workflow/reviewer-identity.js +90 -0
- package/src/scripts/workflow/reviewer-identity.js.map +1 -0
- package/src/scripts/workflow/reviewer-verdict-gate.d.ts +8 -0
- package/src/scripts/workflow/reviewer-verdict-gate.js +21 -1
- package/src/scripts/workflow/reviewer-verdict-gate.js.map +1 -1
- package/src/scripts/workflow/verdict-provenance.d.ts +90 -0
- package/src/scripts/workflow/verdict-provenance.js +214 -0
- package/src/scripts/workflow/verdict-provenance.js.map +1 -0
- package/src/scripts/wp-write-review.d.ts +2 -0
- package/src/scripts/wp-write-review.js +25 -0
- package/src/scripts/wp-write-review.js.map +1 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteReviewInput = exports.WriteReviewCommand = exports.WriteReviewOptions = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
+
const rules_config_1 = require("@webpieces/rules-config");
|
|
7
|
+
const inversify_1 = require("inversify");
|
|
8
|
+
const git_readAiBranchName_1 = require("../workflow/git-readAiBranchName");
|
|
9
|
+
const review_stage_receipt_1 = require("../workflow/review-stage-receipt");
|
|
10
|
+
const reviewer_identity_1 = require("../workflow/reviewer-identity");
|
|
11
|
+
const verdict_provenance_1 = require("../workflow/verdict-provenance");
|
|
12
|
+
/** The only keys a verdict may carry. Anything else is somebody's second schema. */
|
|
13
|
+
const VERDICT_KEYS = ['id', 'status', 'agent', 'model', 'output'];
|
|
14
|
+
/** What `wp-write-review` was asked to do. Data-only. */
|
|
15
|
+
class WriteReviewOptions {
|
|
16
|
+
checklistId;
|
|
17
|
+
// The verdict JSON itself — read from `--file` or stdin by the composition root, so this command is a
|
|
18
|
+
// function of its inputs and a spec can drive it without a pipe.
|
|
19
|
+
json;
|
|
20
|
+
// Where the caller stands — the tree whose review dir and hook stamp are used. Passed in (the bin
|
|
21
|
+
// passes process.cwd()) rather than read here, for the same reason `json` is.
|
|
22
|
+
cwd;
|
|
23
|
+
constructor(checklistId, json, cwd) {
|
|
24
|
+
this.checklistId = checklistId;
|
|
25
|
+
this.json = json;
|
|
26
|
+
this.cwd = cwd;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.WriteReviewOptions = WriteReviewOptions;
|
|
30
|
+
/**
|
|
31
|
+
* `wp-write-review` — the ONE way any reviewer, Claude or Codex, submits a checklist verdict (issue #863).
|
|
32
|
+
*
|
|
33
|
+
* Before it existed a verdict was "a file with the right shape at the right path", and that is exactly what
|
|
34
|
+
* a Codex coordinator produced on two merged PRs: the shared-tree guard blocked its reviewer's write, the
|
|
35
|
+
* guard's own cure said to hand the edit to the coordinator, the coordinator wrote all five verdicts, and
|
|
36
|
+
* `wp-finish-upsert-pr` accepted them. Now:
|
|
37
|
+
* 1. the caller is identified by the harness (ReviewerIdentityResolver) and the COORDINATOR is refused;
|
|
38
|
+
* 2. the checklist must be one stage ② briefed this round (its receipt), so a carried verdict cannot be
|
|
39
|
+
* overwritten and a checklist that does not apply cannot be invented;
|
|
40
|
+
* 3. the verdict is validated strictly — the five fields, nothing else;
|
|
41
|
+
* 4. it is written WITH `review-<id>.provenance.json`: who, which commit, which in-scope diff, and a hash
|
|
42
|
+
* of the verdict. `wp-finish-upsert-pr` rejects a verdict without one, or one edited since.
|
|
43
|
+
*
|
|
44
|
+
* `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.
|
|
45
|
+
*/
|
|
46
|
+
let WriteReviewCommand = class WriteReviewCommand {
|
|
47
|
+
repoRootFinder;
|
|
48
|
+
aiBranchName;
|
|
49
|
+
receipts;
|
|
50
|
+
identity;
|
|
51
|
+
provenance;
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
53
|
+
constructor(repoRootFinder, aiBranchName, receipts, identity, provenance) {
|
|
54
|
+
this.repoRootFinder = repoRootFinder;
|
|
55
|
+
this.aiBranchName = aiBranchName;
|
|
56
|
+
this.receipts = receipts;
|
|
57
|
+
this.identity = identity;
|
|
58
|
+
this.provenance = provenance;
|
|
59
|
+
}
|
|
60
|
+
run(opts) {
|
|
61
|
+
const id = opts.checklistId.trim();
|
|
62
|
+
const cwd = opts.cwd;
|
|
63
|
+
const repoRoot = this.repoRootFinder.resolveRepoRoot(cwd);
|
|
64
|
+
const featureName = this.aiBranchName.getFeatureName();
|
|
65
|
+
const receipt = this.briefedReceipt(repoRoot, featureName, id);
|
|
66
|
+
// Identity BEFORE parsing: a coordinator is refused whatever it submitted, and the stamp it
|
|
67
|
+
// consumes must not survive to lend itself to a later call.
|
|
68
|
+
const who = this.identity.resolve(cwd, id);
|
|
69
|
+
const verdict = this.parse(opts.json, id);
|
|
70
|
+
const record = new verdict_provenance_1.VerdictProvenance(id, who.harness, who.sessionId, who.agentId, who.agentType, receipt.headSha, receipt.scopeHashes[id] ?? '');
|
|
71
|
+
const written = this.provenance.write((0, rules_config_1.reviewJsonPath)(repoRoot, featureName), verdict, record);
|
|
72
|
+
process.stdout.write(`✅ ${verdict.status.toUpperCase()} verdict for "${id}" submitted → ${written}\n`
|
|
73
|
+
+ ` provenance: ${who.harness}${who.agentId === '' ? '' : ` agent ${who.agentId}`}, `
|
|
74
|
+
+ `briefed at ${receipt.headSha.slice(0, 8)}\n`);
|
|
75
|
+
return Promise.resolve();
|
|
76
|
+
}
|
|
77
|
+
/** The stage-② receipt, provided it briefed THIS checklist this round. */
|
|
78
|
+
briefedReceipt(repoRoot, featureName, id) {
|
|
79
|
+
if (id === '')
|
|
80
|
+
throw new rules_config_1.InformAiError(`${rules_config_1.WRITE_REVIEW_BIN} needs the checklist id: pnpm ${rules_config_1.WRITE_REVIEW_BIN} --checklist <id>`);
|
|
81
|
+
const receipt = this.receipts.read(repoRoot, featureName);
|
|
82
|
+
if (receipt === null) {
|
|
83
|
+
throw new rules_config_1.InformAiError(`${rules_config_1.WRITE_REVIEW_BIN}: pnpm wp-review-upsert-pr has not briefed any reviewer on this branch yet, `
|
|
84
|
+
+ 'so there is nothing to submit a verdict against.');
|
|
85
|
+
}
|
|
86
|
+
if (!receipt.reviewersBriefed.includes(id) || (receipt.scopeHashes[id] ?? '') === '') {
|
|
87
|
+
const briefed = receipt.reviewersBriefed.length === 0 ? '(none)' : receipt.reviewersBriefed.join(', ');
|
|
88
|
+
throw new rules_config_1.InformAiError(`${rules_config_1.WRITE_REVIEW_BIN}: checklist "${id}" was not briefed by the last pnpm wp-review-upsert-pr `
|
|
89
|
+
+ `(briefed this round: ${briefed}). Submit only for a checklist whose instructions file you were handed — `
|
|
90
|
+
+ 'a checklist absent here either carries its earlier verdict or does not apply to this diff.');
|
|
91
|
+
}
|
|
92
|
+
return receipt;
|
|
93
|
+
}
|
|
94
|
+
/** Strict: an object with exactly the verdict's five fields, every one a string, status one of three. */
|
|
95
|
+
parse(json, id) {
|
|
96
|
+
const raw = this.parseObject(json);
|
|
97
|
+
const problems = [];
|
|
98
|
+
const extra = Object.keys(raw).filter((k) => !VERDICT_KEYS.includes(k));
|
|
99
|
+
if (extra.includes('override')) {
|
|
100
|
+
problems.push(`"override" is not a verdict field — a ship-anyway decision is a HUMAN's, recorded by the coordinating agent in ${rules_config_1.checklistOverrideService.overrideFileName(id)}`);
|
|
101
|
+
}
|
|
102
|
+
if (extra.length > 0)
|
|
103
|
+
problems.push(`unknown field(s) ${extra.map((k) => `"${k}"`).join(', ')} — a verdict has exactly: ${VERDICT_KEYS.join(', ')}`);
|
|
104
|
+
if (raw['id'] !== undefined && this.text(raw, 'id') !== id)
|
|
105
|
+
problems.push(`"id" is ${JSON.stringify(raw['id'])} but --checklist is "${id}"`);
|
|
106
|
+
const status = this.text(raw, 'status').toLowerCase();
|
|
107
|
+
// webpieces-disable no-any-unknown -- comparing against the readonly literal tuple of valid colors
|
|
108
|
+
if (!rules_config_1.VERDICT_STATUSES.includes(status))
|
|
109
|
+
problems.push(`"status" must be one of ${rules_config_1.VERDICT_STATUSES.join(', ')}`);
|
|
110
|
+
for (const key of ['agent', 'model', 'output']) {
|
|
111
|
+
if (this.text(raw, key) === '')
|
|
112
|
+
problems.push(`"${key}" must be a non-empty string${key === 'output' ? '' : ' (use "unknown" when unavailable)'}`);
|
|
113
|
+
}
|
|
114
|
+
if (problems.length > 0) {
|
|
115
|
+
throw new rules_config_1.InformAiError(`${rules_config_1.WRITE_REVIEW_BIN}: the verdict for "${id}" was NOT submitted:\n`
|
|
116
|
+
+ problems.map((p) => ` • ${p}`).join('\n'));
|
|
117
|
+
}
|
|
118
|
+
return new verdict_provenance_1.SubmittedVerdict(id, status, this.text(raw, 'agent'), this.text(raw, 'model'), raw['output']);
|
|
119
|
+
}
|
|
120
|
+
// webpieces-disable no-any-unknown -- one field of the opaque submitted object, narrowed to a trimmed string
|
|
121
|
+
text(raw, key) {
|
|
122
|
+
const value = raw[key];
|
|
123
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
124
|
+
}
|
|
125
|
+
// webpieces-disable no-any-unknown -- the submitted JSON is opaque until parse() narrows every field
|
|
126
|
+
parseObject(json) {
|
|
127
|
+
// webpieces-disable no-any-unknown -- parsed JSON is opaque until narrowed
|
|
128
|
+
let parsed = null;
|
|
129
|
+
// webpieces-disable no-unmanaged-exceptions -- chokepoint: a JSON syntax error becomes the AI-facing refusal
|
|
130
|
+
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
131
|
+
try {
|
|
132
|
+
parsed = JSON.parse(json);
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
const error = (0, rules_config_1.toError)(err);
|
|
136
|
+
throw new rules_config_1.InformAiError(`${rules_config_1.WRITE_REVIEW_BIN}: the verdict is not valid JSON.`, { cause: error });
|
|
137
|
+
}
|
|
138
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
139
|
+
throw new rules_config_1.InformAiError(`${rules_config_1.WRITE_REVIEW_BIN}: the verdict must be ONE JSON object.`);
|
|
140
|
+
}
|
|
141
|
+
// webpieces-disable no-any-unknown -- narrowed to a plain object just above
|
|
142
|
+
return parsed;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
exports.WriteReviewCommand = WriteReviewCommand;
|
|
146
|
+
exports.WriteReviewCommand = WriteReviewCommand = tslib_1.__decorate([
|
|
147
|
+
(0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
|
|
148
|
+
tslib_1.__metadata("design:paramtypes", [rules_config_1.RepoRootFinder,
|
|
149
|
+
git_readAiBranchName_1.AiBranchName,
|
|
150
|
+
review_stage_receipt_1.ReviewStageReceiptService,
|
|
151
|
+
reviewer_identity_1.ReviewerIdentityResolver,
|
|
152
|
+
verdict_provenance_1.VerdictProvenanceService])
|
|
153
|
+
], WriteReviewCommand);
|
|
154
|
+
/**
|
|
155
|
+
* Reads the verdict JSON for the composition root: `--file <path>`, else stdin. Separate from the command
|
|
156
|
+
* so the command stays a function of its inputs.
|
|
157
|
+
*/
|
|
158
|
+
let WriteReviewInput = class WriteReviewInput {
|
|
159
|
+
read(filePath) {
|
|
160
|
+
if (filePath.trim() !== '') {
|
|
161
|
+
if (!fs.existsSync(filePath))
|
|
162
|
+
throw new rules_config_1.InformAiError(`${rules_config_1.WRITE_REVIEW_BIN}: --file ${filePath} does not exist.`);
|
|
163
|
+
return fs.readFileSync(filePath, 'utf8');
|
|
164
|
+
}
|
|
165
|
+
if (process.stdin.isTTY === true) {
|
|
166
|
+
throw new rules_config_1.InformAiError(`${rules_config_1.WRITE_REVIEW_BIN}: pass the verdict JSON on stdin (pnpm ${rules_config_1.WRITE_REVIEW_BIN} --checklist <id> <<'EOF' … EOF) or with --file <path>.`);
|
|
167
|
+
}
|
|
168
|
+
return fs.readFileSync(0, 'utf8');
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
exports.WriteReviewInput = WriteReviewInput;
|
|
172
|
+
exports.WriteReviewInput = WriteReviewInput = tslib_1.__decorate([
|
|
173
|
+
(0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton)
|
|
174
|
+
], WriteReviewInput);
|
|
175
|
+
//# sourceMappingURL=write-review-command.js.map
|
|
@@ -0,0 +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;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;;;;;;;;;;;;;;;GAeG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAGN;IACA;IACA;IACA;IACA;IANrB,yDAAyD;IACzD,YACqB,cAA8B,EAC9B,YAA0B,EAC1B,QAAmC,EACnC,QAAkC,EAClC,UAAoC;QAJpC,mBAAc,GAAd,cAAc,CAAgB;QAC9B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,aAAQ,GAAR,QAAQ,CAA2B;QACnC,aAAQ,GAAR,QAAQ,CAA0B;QAClC,eAAU,GAAV,UAAU,CAA0B;IACtD,CAAC;IAEJ,GAAG,CAAC,IA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Finder, VERDICT_STATUSES, WRITE_REVIEW_BIN, checklistOverrideService, reviewJsonPath, 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/**\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 ) {}\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 const written = this.provenance.write(reviewJsonPath(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)}\\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"]}
|
|
@@ -11,6 +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
15
|
import { AwaitChecksCommand, AwaitChecksOptions } from './commands/await-checks-command';
|
|
15
16
|
import { PushDevCommand, PushDevOptions } from './commands/push-dev-command';
|
|
16
17
|
import { FinishPushDevCommand, FinishPushDevOptions } from './commands/finish-push-dev-command';
|
|
@@ -35,12 +36,13 @@ export declare class PrGateApp {
|
|
|
35
36
|
private readonly reapWorktreeCommand;
|
|
36
37
|
private readonly buildCommand;
|
|
37
38
|
private readonly awaitReviewsCommand;
|
|
39
|
+
private readonly writeReviewCommand;
|
|
38
40
|
private readonly awaitChecksCommand;
|
|
39
41
|
private readonly pushDevCommand;
|
|
40
42
|
private readonly finishPushDevCommand;
|
|
41
43
|
private readonly pushDevStateStore;
|
|
42
44
|
private readonly repoRootFinder;
|
|
43
|
-
constructor(startUpdateCommand: StartUpdateCommand, finishUpdateCommand: FinishUpdateCommand, startUpsertPrCommand: StartUpsertPrCommand, finishUpsertPrCommand: FinishUpsertPrCommand, cleanupCommand: CleanupCommand, syncMainCommand: SyncMainCommand, landPrCommand: LandPrCommand, checkPrCommand: CheckPrCommand, reviewUpsertPrCommand: ReviewUpsertPrCommand, reapWorktreeCommand: ReapWorktreeCommand, buildCommand: BuildCommand, awaitReviewsCommand: AwaitReviewsCommand, awaitChecksCommand: AwaitChecksCommand, pushDevCommand: PushDevCommand, finishPushDevCommand: FinishPushDevCommand, pushDevStateStore: PushDevStateStore, repoRootFinder: RepoRootFinder);
|
|
45
|
+
constructor(startUpdateCommand: StartUpdateCommand, finishUpdateCommand: FinishUpdateCommand, startUpsertPrCommand: StartUpsertPrCommand, finishUpsertPrCommand: FinishUpsertPrCommand, cleanupCommand: CleanupCommand, syncMainCommand: SyncMainCommand, landPrCommand: LandPrCommand, checkPrCommand: CheckPrCommand, reviewUpsertPrCommand: ReviewUpsertPrCommand, reapWorktreeCommand: ReapWorktreeCommand, buildCommand: BuildCommand, awaitReviewsCommand: AwaitReviewsCommand, writeReviewCommand: WriteReviewCommand, awaitChecksCommand: AwaitChecksCommand, pushDevCommand: PushDevCommand, finishPushDevCommand: FinishPushDevCommand, pushDevStateStore: PushDevStateStore, repoRootFinder: RepoRootFinder);
|
|
44
46
|
/**
|
|
45
47
|
* Refuse `command` while a `wp-push-dev --resolve` is half-finished.
|
|
46
48
|
*
|
|
@@ -71,6 +73,11 @@ export declare class PrGateApp {
|
|
|
71
73
|
* them. Not blocked during a `wp-push-dev --resolve`: it reads verdict files and mutates nothing.
|
|
72
74
|
*/
|
|
73
75
|
awaitReviews(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* `wp-write-review`: a reviewer subagent submits ONE checklist verdict, with provenance (issue #863).
|
|
78
|
+
* Not blocked during a `wp-push-dev --resolve`: it writes only this branch's review state.
|
|
79
|
+
*/
|
|
80
|
+
writeReview(opts: WriteReviewOptions): Promise<void>;
|
|
74
81
|
/**
|
|
75
82
|
* `wp-await-checks --pr <n>`: BLOCK until that PR's checks stop running, then print where they
|
|
76
83
|
* landed. Read-only against GitHub, so it too is allowed during a resolve.
|
|
@@ -16,6 +16,7 @@ const review_upsert_pr_command_1 = require("./commands/review-upsert-pr-command"
|
|
|
16
16
|
const reap_worktree_command_1 = require("./commands/reap-worktree-command");
|
|
17
17
|
const build_command_1 = require("./commands/build-command");
|
|
18
18
|
const await_reviews_command_1 = require("./commands/await-reviews-command");
|
|
19
|
+
const write_review_command_1 = require("./commands/write-review-command");
|
|
19
20
|
const await_checks_command_1 = require("./commands/await-checks-command");
|
|
20
21
|
const push_dev_command_1 = require("./commands/push-dev-command");
|
|
21
22
|
const finish_push_dev_command_1 = require("./commands/finish-push-dev-command");
|
|
@@ -40,12 +41,13 @@ let PrGateApp = class PrGateApp {
|
|
|
40
41
|
reapWorktreeCommand;
|
|
41
42
|
buildCommand;
|
|
42
43
|
awaitReviewsCommand;
|
|
44
|
+
writeReviewCommand;
|
|
43
45
|
awaitChecksCommand;
|
|
44
46
|
pushDevCommand;
|
|
45
47
|
finishPushDevCommand;
|
|
46
48
|
pushDevStateStore;
|
|
47
49
|
repoRootFinder;
|
|
48
|
-
constructor(startUpdateCommand, finishUpdateCommand, startUpsertPrCommand, finishUpsertPrCommand, cleanupCommand, syncMainCommand, landPrCommand, checkPrCommand, reviewUpsertPrCommand, reapWorktreeCommand, buildCommand, awaitReviewsCommand, awaitChecksCommand, pushDevCommand, finishPushDevCommand, pushDevStateStore, repoRootFinder) {
|
|
50
|
+
constructor(startUpdateCommand, finishUpdateCommand, startUpsertPrCommand, finishUpsertPrCommand, cleanupCommand, syncMainCommand, landPrCommand, checkPrCommand, reviewUpsertPrCommand, reapWorktreeCommand, buildCommand, awaitReviewsCommand, writeReviewCommand, awaitChecksCommand, pushDevCommand, finishPushDevCommand, pushDevStateStore, repoRootFinder) {
|
|
49
51
|
this.startUpdateCommand = startUpdateCommand;
|
|
50
52
|
this.finishUpdateCommand = finishUpdateCommand;
|
|
51
53
|
this.startUpsertPrCommand = startUpsertPrCommand;
|
|
@@ -58,6 +60,7 @@ let PrGateApp = class PrGateApp {
|
|
|
58
60
|
this.reapWorktreeCommand = reapWorktreeCommand;
|
|
59
61
|
this.buildCommand = buildCommand;
|
|
60
62
|
this.awaitReviewsCommand = awaitReviewsCommand;
|
|
63
|
+
this.writeReviewCommand = writeReviewCommand;
|
|
61
64
|
this.awaitChecksCommand = awaitChecksCommand;
|
|
62
65
|
this.pushDevCommand = pushDevCommand;
|
|
63
66
|
this.finishPushDevCommand = finishPushDevCommand;
|
|
@@ -108,6 +111,13 @@ let PrGateApp = class PrGateApp {
|
|
|
108
111
|
awaitReviews() {
|
|
109
112
|
return this.awaitReviewsCommand.run();
|
|
110
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* `wp-write-review`: a reviewer subagent submits ONE checklist verdict, with provenance (issue #863).
|
|
116
|
+
* Not blocked during a `wp-push-dev --resolve`: it writes only this branch's review state.
|
|
117
|
+
*/
|
|
118
|
+
writeReview(opts) {
|
|
119
|
+
return this.writeReviewCommand.run(opts);
|
|
120
|
+
}
|
|
111
121
|
/**
|
|
112
122
|
* `wp-await-checks --pr <n>`: BLOCK until that PR's checks stop running, then print where they
|
|
113
123
|
* landed. Read-only against GitHub, so it too is allowed during a resolve.
|
|
@@ -191,6 +201,7 @@ exports.PrGateApp = PrGateApp = tslib_1.__decorate([
|
|
|
191
201
|
reap_worktree_command_1.ReapWorktreeCommand,
|
|
192
202
|
build_command_1.BuildCommand,
|
|
193
203
|
await_reviews_command_1.AwaitReviewsCommand,
|
|
204
|
+
write_review_command_1.WriteReviewCommand,
|
|
194
205
|
await_checks_command_1.AwaitChecksCommand,
|
|
195
206
|
push_dev_command_1.PushDevCommand,
|
|
196
207
|
finish_push_dev_command_1.FinishPushDevCommand,
|
|
@@ -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,kEAA6E;AAC7E,gFAAgG;AAChG,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;IAjBrB,YACqB,kBAAsC,EACtC,mBAAwC,EACxC,oBAA0C,EAC1C,qBAA4C,EAC5C,cAA8B,EAC9B,eAAgC,EAChC,aAA4B,EAC5B,cAA8B,EAC9B,qBAA4C,EAC5C,mBAAwC,EACxC,YAA0B,EAC1B,mBAAwC,EACxC,kBAAsC,EACtC,cAA8B,EAC9B,oBAA0C,EAC1C,iBAAoC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C,CAAC;QAC/C,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,OAAsB;QACzB,IAAI,CAAC,yBAAyB,CAAC,YAAY,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,OAA8B,IAAI,gDAAqB,EAAE;QACpE,IAAI,CAAC,yBAAyB,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;AAjJY,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;QACtB,iCAAc;QACR,8CAAoB;QACvB,kCAAiB;QACpB,6BAAc;GAlB1C,SAAS,CAiJrB","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 { 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 { 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 awaitChecksCommand: AwaitChecksCommand,\n private readonly pushDevCommand: PushDevCommand,\n private readonly finishPushDevCommand: FinishPushDevCommand,\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(this.repoRootFinder.resolveRepoRoot(process.cwd()), command);\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-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 review.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 /**\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,0EAAyF;AACzF,0EAAyF;AACzF,kEAA6E;AAC7E,gFAAgG;AAChG,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;IAlBrB,YACqB,kBAAsC,EACtC,mBAAwC,EACxC,oBAA0C,EAC1C,qBAA4C,EAC5C,cAA8B,EAC9B,eAAgC,EAChC,aAA4B,EAC5B,cAA8B,EAC9B,qBAA4C,EAC5C,mBAAwC,EACxC,YAA0B,EAC1B,mBAAwC,EACxC,kBAAsC,EACtC,kBAAsC,EACtC,cAA8B,EAC9B,oBAA0C,EAC1C,iBAAoC,EACpC,cAA8B;QAjB9B,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,wBAAmB,GAAnB,mBAAmB,CAAqB;QACxC,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,mB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AO,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,OAAsB;QACzB,IAAI,CAAC,yBAAyB,CAAC,YAAY,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,OAA8B,IAAI,gDAAqB,EAAE;QACpE,IAAI,CAAC,yBAAyB,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;AA1JY,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;QAClB,yCAAkB;QACtB,iCAAc;QACR,8CAAoB;QACvB,kCAAiB;QACpB,6BAAc;GAnB1C,SAAS,CA0JrB","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 { 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 { 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 awaitChecksCommand: AwaitChecksCommand,\n private readonly pushDevCommand: PushDevCommand,\n private readonly finishPushDevCommand: FinishPushDevCommand,\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(this.repoRootFinder.resolveRepoRoot(process.cwd()), command);\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 /**\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 review.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 /**\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"]}
|
|
@@ -3,6 +3,8 @@ import { AiBranchName } from './git-readAiBranchName';
|
|
|
3
3
|
import { ChecklistDetector, ChecklistRoster } from './checklist-detector';
|
|
4
4
|
import { DiffBasis, DiffBasisResolver } from './diff-basis';
|
|
5
5
|
import { PrContextWriter } from './pr-context-writer';
|
|
6
|
+
import { ChecklistScopeHasher } from './checklist-scope-hasher';
|
|
7
|
+
import { VerdictProvenanceService, VerdictStanding } from './verdict-provenance';
|
|
6
8
|
/** How a caller wants the scan filtered. Data-only (per CLAUDE.md). */
|
|
7
9
|
export declare class ChecklistScanOptions {
|
|
8
10
|
/**
|
|
@@ -101,6 +103,16 @@ export declare class ChecklistScan {
|
|
|
101
103
|
suppressed: RequiredChecklist[];
|
|
102
104
|
/** TRUE only for the top-level `singleRoundReview` machine opt-in. */
|
|
103
105
|
singleRoundReview: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* How every EXISTING verdict file stands (issue #863): CURRENT (submitted through `wp-write-review` and
|
|
108
|
+
* its checklist's in-scope diff is unchanged — it carries), STALE (in-scope diff changed since — re-brief)
|
|
109
|
+
* or REJECTED (no bin provenance, or edited after submission — it is not a review). A REJECTED verdict,
|
|
110
|
+
* and a STALE green or yellow one, is left OUT of `results`, so it is owed like one that never ran; a
|
|
111
|
+
* stale RED stays in `results` and keeps refusing. Empty under suppression.
|
|
112
|
+
*/
|
|
113
|
+
standings: VerdictStanding[];
|
|
114
|
+
/** checklist id → ChecklistScopeHasher's hash of its in-scope diff NOW. Recorded in the stage-② receipt. */
|
|
115
|
+
scopeHashes: Record<string, string>;
|
|
104
116
|
constructor(defined: ChecklistDefinition[], applicable: RequiredChecklist[], reviewed: RequiredChecklist[], outstanding: RequiredChecklist[], context: ChecklistReviewContext, reviewPath: string, forkPoint: string, roster: ChecklistRoster, formatErrors: string[], reviewersDisabled: boolean, suppressed: RequiredChecklist[], basis?: DiffBasis, changedFiles?: string[], results?: ChecklistResult[], optionalNotRun?: RequiredChecklist[], singleRoundReview?: boolean);
|
|
105
117
|
}
|
|
106
118
|
/**
|
|
@@ -132,7 +144,9 @@ export declare class ChecklistScanner {
|
|
|
132
144
|
private readonly prContextWriter;
|
|
133
145
|
private readonly reviewJsonService;
|
|
134
146
|
private readonly homeConfig;
|
|
135
|
-
|
|
147
|
+
private readonly scopeHasher;
|
|
148
|
+
private readonly verdictProvenance;
|
|
149
|
+
constructor(aiBranchName: AiBranchName, checklistDetector: ChecklistDetector, diffScope: DiffScope, diffBasisResolver: DiffBasisResolver, prContextWriter: PrContextWriter, reviewJsonService: ReviewJsonService, homeConfig: HomeConfigService, scopeHasher: ChecklistScopeHasher, verdictProvenance: VerdictProvenanceService);
|
|
136
150
|
/**
|
|
137
151
|
* `defined` is the caller's ALREADY-VALIDATED `prGate.checklists`. The scanner deliberately does not load
|
|
138
152
|
* config itself: `loadAndValidate` is the one gate on the checklist set (it rejects a non-array
|
|
@@ -141,6 +155,18 @@ export declare class ChecklistScanner {
|
|
|
141
155
|
* here leaves this a function of its inputs rather than of the filesystem.
|
|
142
156
|
*/
|
|
143
157
|
scan(repoRoot: string, defined: ChecklistDefinition[], opts: ChecklistScanOptions): ChecklistScan;
|
|
158
|
+
/**
|
|
159
|
+
* Judge every READABLE verdict against its bin provenance and the in-scope diff as it is now. A file
|
|
160
|
+
* with a format problem is left to the format complaint, which names the fix; it is not assessed.
|
|
161
|
+
*/
|
|
162
|
+
private standingsOf;
|
|
163
|
+
/**
|
|
164
|
+
* The verdicts that still COUNT. A rejected one never does. A stale green or yellow judged code that
|
|
165
|
+
* has since changed, so it is owed again; a stale RED still refuses — a refusal is not lifted by
|
|
166
|
+
* changing other code in its scope, only by a fresh verdict — and it is re-briefed anyway because it
|
|
167
|
+
* is red.
|
|
168
|
+
*/
|
|
169
|
+
private liveResults;
|
|
144
170
|
/**
|
|
145
171
|
* What `wp-finish-upsert-pr` actually REFUSES on: everything still owing a verdict, minus the optional
|
|
146
172
|
* checklists nobody ran.
|
|
@@ -8,6 +8,8 @@ const git_readAiBranchName_1 = require("./git-readAiBranchName");
|
|
|
8
8
|
const checklist_detector_1 = require("./checklist-detector");
|
|
9
9
|
const diff_basis_1 = require("./diff-basis");
|
|
10
10
|
const pr_context_writer_1 = require("./pr-context-writer");
|
|
11
|
+
const checklist_scope_hasher_1 = require("./checklist-scope-hasher");
|
|
12
|
+
const verdict_provenance_1 = require("./verdict-provenance");
|
|
11
13
|
/** How a caller wants the scan filtered. Data-only (per CLAUDE.md). */
|
|
12
14
|
class ChecklistScanOptions {
|
|
13
15
|
/**
|
|
@@ -116,6 +118,16 @@ class ChecklistScan {
|
|
|
116
118
|
suppressed;
|
|
117
119
|
/** TRUE only for the top-level `singleRoundReview` machine opt-in. */
|
|
118
120
|
singleRoundReview;
|
|
121
|
+
/**
|
|
122
|
+
* How every EXISTING verdict file stands (issue #863): CURRENT (submitted through `wp-write-review` and
|
|
123
|
+
* its checklist's in-scope diff is unchanged — it carries), STALE (in-scope diff changed since — re-brief)
|
|
124
|
+
* or REJECTED (no bin provenance, or edited after submission — it is not a review). A REJECTED verdict,
|
|
125
|
+
* and a STALE green or yellow one, is left OUT of `results`, so it is owed like one that never ran; a
|
|
126
|
+
* stale RED stays in `results` and keeps refusing. Empty under suppression.
|
|
127
|
+
*/
|
|
128
|
+
standings;
|
|
129
|
+
/** checklist id → ChecklistScopeHasher's hash of its in-scope diff NOW. Recorded in the stage-② receipt. */
|
|
130
|
+
scopeHashes;
|
|
119
131
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
120
132
|
constructor(defined, applicable, reviewed, outstanding, context, reviewPath, forkPoint, roster, formatErrors,
|
|
121
133
|
// REQUIRED, and placed BEFORE the defaulted tail deliberately. A defaulted `reviewersDisabled =
|
|
@@ -142,6 +154,8 @@ class ChecklistScan {
|
|
|
142
154
|
this.results = results;
|
|
143
155
|
this.optionalNotRun = optionalNotRun;
|
|
144
156
|
this.singleRoundReview = singleRoundReview;
|
|
157
|
+
this.standings = [];
|
|
158
|
+
this.scopeHashes = {};
|
|
145
159
|
}
|
|
146
160
|
}
|
|
147
161
|
exports.ChecklistScan = ChecklistScan;
|
|
@@ -174,10 +188,12 @@ let ChecklistScanner = class ChecklistScanner {
|
|
|
174
188
|
prContextWriter;
|
|
175
189
|
reviewJsonService;
|
|
176
190
|
homeConfig;
|
|
191
|
+
scopeHasher;
|
|
192
|
+
verdictProvenance;
|
|
177
193
|
constructor(aiBranchName, checklistDetector, diffScope, diffBasisResolver, prContextWriter, reviewJsonService,
|
|
178
194
|
// Injected BY TYPE (no Symbol token, per CLAUDE.md) so the ONE reviewer kill switch is read in the
|
|
179
195
|
// ONE place that computes what a branch owes — see the suppression note on `scan`.
|
|
180
|
-
homeConfig) {
|
|
196
|
+
homeConfig, scopeHasher, verdictProvenance) {
|
|
181
197
|
this.aiBranchName = aiBranchName;
|
|
182
198
|
this.checklistDetector = checklistDetector;
|
|
183
199
|
this.diffScope = diffScope;
|
|
@@ -185,6 +201,8 @@ let ChecklistScanner = class ChecklistScanner {
|
|
|
185
201
|
this.prContextWriter = prContextWriter;
|
|
186
202
|
this.reviewJsonService = reviewJsonService;
|
|
187
203
|
this.homeConfig = homeConfig;
|
|
204
|
+
this.scopeHasher = scopeHasher;
|
|
205
|
+
this.verdictProvenance = verdictProvenance;
|
|
188
206
|
}
|
|
189
207
|
/**
|
|
190
208
|
* `defined` is the caller's ALREADY-VALIDATED `prGate.checklists`. The scanner deliberately does not load
|
|
@@ -221,7 +239,10 @@ let ChecklistScanner = class ChecklistScanner {
|
|
|
221
239
|
return new ChecklistScan(defined, [], [], [], context, reviewPath, base, roster, [], true, matched, basis, changedFiles, [], [], homeConfig.singleRoundReview);
|
|
222
240
|
}
|
|
223
241
|
const applicable = matched;
|
|
224
|
-
const
|
|
242
|
+
const scopeHashes = this.scopeHasher.hashes(repoRoot, basis, applicable);
|
|
243
|
+
const loaded = this.reviewJsonService.loadChecklistResults(reviewPath, applicable);
|
|
244
|
+
const standings = this.standingsOf(reviewPath, loaded, scopeHashes, homeConfig.singleRoundReview);
|
|
245
|
+
const results = this.liveResults(loaded, standings);
|
|
225
246
|
const stillOwed = this.reviewJsonService.pendingChecklists(applicable, results);
|
|
226
247
|
const owedIds = new Set(stillOwed.map((r) => r.id));
|
|
227
248
|
// NOT `!owedIds.has(...)`-with-the-optional-exemption-folded-in: an optional checklist nobody ran is
|
|
@@ -229,7 +250,32 @@ let ChecklistScanner = class ChecklistScanner {
|
|
|
229
250
|
// that never happened.
|
|
230
251
|
const reviewed = applicable.filter((r) => !owedIds.has(r.id));
|
|
231
252
|
const optionalNotRun = this.reviewJsonService.optionalWithoutVerdict(applicable, results);
|
|
232
|
-
|
|
253
|
+
const scan = new ChecklistScan(defined, applicable, reviewed, opts.filterAlreadyReviewed ? this.blocking(stillOwed, optionalNotRun) : applicable, context, reviewPath, base, roster, this.reviewJsonService.checklistFormatErrors(applicable, results), false, [], basis, changedFiles, results, optionalNotRun, homeConfig.singleRoundReview);
|
|
254
|
+
scan.standings = standings;
|
|
255
|
+
scan.scopeHashes = scopeHashes;
|
|
256
|
+
return scan;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Judge every READABLE verdict against its bin provenance and the in-scope diff as it is now. A file
|
|
260
|
+
* with a format problem is left to the format complaint, which names the fix; it is not assessed.
|
|
261
|
+
*/
|
|
262
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
263
|
+
standingsOf(reviewPath, loaded, scopeHashes, singleRound) {
|
|
264
|
+
return loaded
|
|
265
|
+
.filter((r) => r.problem === '')
|
|
266
|
+
.map((r) => this.verdictProvenance.assess(reviewPath, r, scopeHashes[r.id] ?? '', singleRound));
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* The verdicts that still COUNT. A rejected one never does. A stale green or yellow judged code that
|
|
270
|
+
* has since changed, so it is owed again; a stale RED still refuses — a refusal is not lifted by
|
|
271
|
+
* changing other code in its scope, only by a fresh verdict — and it is re-briefed anyway because it
|
|
272
|
+
* is red.
|
|
273
|
+
*/
|
|
274
|
+
liveResults(loaded, standings) {
|
|
275
|
+
const dropped = new Set(standings
|
|
276
|
+
.filter((s) => s.standing === verdict_provenance_1.STANDING_REJECTED || (s.standing === verdict_provenance_1.STANDING_STALE && s.status !== rules_config_1.VERDICT_RED))
|
|
277
|
+
.map((s) => s.checklistId));
|
|
278
|
+
return loaded.filter((r) => !dropped.has(r.id));
|
|
233
279
|
}
|
|
234
280
|
/**
|
|
235
281
|
* What `wp-finish-upsert-pr` actually REFUSES on: everything still owing a verdict, minus the optional
|
|
@@ -273,6 +319,8 @@ exports.ChecklistScanner = ChecklistScanner = tslib_1.__decorate([
|
|
|
273
319
|
diff_basis_1.DiffBasisResolver,
|
|
274
320
|
pr_context_writer_1.PrContextWriter,
|
|
275
321
|
rules_config_1.ReviewJsonService,
|
|
276
|
-
rules_config_1.HomeConfigService
|
|
322
|
+
rules_config_1.HomeConfigService,
|
|
323
|
+
checklist_scope_hasher_1.ChecklistScopeHasher,
|
|
324
|
+
verdict_provenance_1.VerdictProvenanceService])
|
|
277
325
|
], ChecklistScanner);
|
|
278
326
|
//# sourceMappingURL=checklist-scanner.js.map
|