@webpieces/pr-gate 0.4.801 → 0.4.802
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,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VerdictProvenanceService = exports.VerdictStanding = exports.STANDING_REJECTED = exports.STANDING_STALE = exports.STANDING_CURRENT = exports.VerdictProvenance = exports.SubmittedVerdict = exports.HARNESS_TERMINAL = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const crypto = tslib_1.__importStar(require("crypto"));
|
|
6
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
7
|
+
const path = tslib_1.__importStar(require("path"));
|
|
8
|
+
const rules_config_1 = require("@webpieces/rules-config");
|
|
9
|
+
const inversify_1 = require("inversify");
|
|
10
|
+
/** `harness` for a verdict submitted from a plain terminal — a HUMAN reviewer, with no AI harness at all. */
|
|
11
|
+
exports.HARNESS_TERMINAL = 'terminal';
|
|
12
|
+
const WHAT_THIS_IS = 'PROVENANCE — written by pnpm wp-write-review beside the verdict it submitted, never by an AI. It records ' +
|
|
13
|
+
'WHO submitted that verdict (harness, session, agent — as the harness reported them to the PreToolUse ' +
|
|
14
|
+
'hook), WHICH commit and in-scope diff the reviewer was briefed on, and a hash of the verdict itself. ' +
|
|
15
|
+
'wp-finish-upsert-pr rejects a verdict with no provenance, or one edited after submission. Do not ' +
|
|
16
|
+
'hand-edit or copy it: that is forging a review.';
|
|
17
|
+
/** A verdict exactly as `wp-write-review` accepts it — the five fields and nothing else. Data-only. */
|
|
18
|
+
class SubmittedVerdict {
|
|
19
|
+
id;
|
|
20
|
+
status;
|
|
21
|
+
agent;
|
|
22
|
+
model;
|
|
23
|
+
output;
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
25
|
+
constructor(id, status, agent, model, output) {
|
|
26
|
+
this.id = id;
|
|
27
|
+
this.status = status;
|
|
28
|
+
this.agent = agent;
|
|
29
|
+
this.model = model;
|
|
30
|
+
this.output = output;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.SubmittedVerdict = SubmittedVerdict;
|
|
34
|
+
/**
|
|
35
|
+
* The record `wp-write-review` writes to `review-<id>.provenance.json`. Data-only; field names are the JSON
|
|
36
|
+
* keys, `_WHAT_THIS_IS` first so a reader learns what the file is before anything it might act on.
|
|
37
|
+
*/
|
|
38
|
+
class VerdictProvenance {
|
|
39
|
+
// webpieces-disable naming-convention -- the leading underscore marks a note-to-the-reader key, not data
|
|
40
|
+
_WHAT_THIS_IS = WHAT_THIS_IS;
|
|
41
|
+
writer; // always WRITE_REVIEW_BIN — a record naming anything else was not written by it
|
|
42
|
+
checklistId;
|
|
43
|
+
harness; // 'claude-code' | 'codex' | HARNESS_TERMINAL
|
|
44
|
+
sessionId;
|
|
45
|
+
agentId; // the SUBAGENT that submitted; '' only for HARNESS_TERMINAL
|
|
46
|
+
agentType;
|
|
47
|
+
headSha; // the commit stage ② briefed this reviewer on
|
|
48
|
+
scopeHash; // ChecklistScopeHasher's hash of this checklist's in-scope diff at that commit
|
|
49
|
+
status; // the status as submitted
|
|
50
|
+
verdictHash; // VerdictProvenanceService.canonicalHash of the verdict as submitted
|
|
51
|
+
writtenAt;
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
53
|
+
constructor(checklistId, harness, sessionId, agentId, agentType, headSha, scopeHash) {
|
|
54
|
+
this.writer = rules_config_1.WRITE_REVIEW_BIN;
|
|
55
|
+
this.checklistId = checklistId;
|
|
56
|
+
this.harness = harness;
|
|
57
|
+
this.sessionId = sessionId;
|
|
58
|
+
this.agentId = agentId;
|
|
59
|
+
this.agentType = agentType;
|
|
60
|
+
this.headSha = headSha;
|
|
61
|
+
this.scopeHash = scopeHash;
|
|
62
|
+
this.status = '';
|
|
63
|
+
this.verdictHash = '';
|
|
64
|
+
this.writtenAt = '';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.VerdictProvenance = VerdictProvenance;
|
|
68
|
+
/** A live verdict that stands: submitted through the bin and judged the in-scope diff as it is NOW. */
|
|
69
|
+
exports.STANDING_CURRENT = 'current';
|
|
70
|
+
/** Submitted through the bin, but the checklist's in-scope diff has changed since — it judged other code. */
|
|
71
|
+
exports.STANDING_STALE = 'stale';
|
|
72
|
+
/** No bin provenance, or edited after submission: not a reviewer's verdict at all. */
|
|
73
|
+
exports.STANDING_REJECTED = 'rejected';
|
|
74
|
+
/**
|
|
75
|
+
* How ONE existing verdict file stands against the branch as it is now. Data-only. Carried on the
|
|
76
|
+
* checklist scan so stage ② (which briefs) and stage ③ (which blocks) read one answer.
|
|
77
|
+
*/
|
|
78
|
+
class VerdictStanding {
|
|
79
|
+
checklistId;
|
|
80
|
+
standing; // STANDING_CURRENT | STANDING_STALE | STANDING_REJECTED
|
|
81
|
+
status; // the verdict's own green | yellow | red
|
|
82
|
+
fromSha; // the commit it was briefed on ('' when rejected)
|
|
83
|
+
reason; // why — printed verbatim
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
85
|
+
constructor(checklistId, standing, status, fromSha, reason) {
|
|
86
|
+
this.checklistId = checklistId;
|
|
87
|
+
this.standing = standing;
|
|
88
|
+
this.status = status;
|
|
89
|
+
this.fromSha = fromSha;
|
|
90
|
+
this.reason = reason;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.VerdictStanding = VerdictStanding;
|
|
94
|
+
/**
|
|
95
|
+
* Writes a submitted verdict WITH its provenance, and judges an existing verdict against it (issue #863).
|
|
96
|
+
*
|
|
97
|
+
* This is what closes the forgery the issue measured: a Codex coordinator wrote five `review-<id>.json`
|
|
98
|
+
* files itself and the gate accepted them, because nothing distinguished a reviewer's verdict from a file
|
|
99
|
+
* that merely had the right shape. Now a verdict counts only when `wp-write-review` wrote it — which it does
|
|
100
|
+
* only for a caller the harness identified as a subagent — and only while it still says exactly what was
|
|
101
|
+
* submitted.
|
|
102
|
+
*
|
|
103
|
+
* `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.
|
|
104
|
+
*/
|
|
105
|
+
let VerdictProvenanceService = class VerdictProvenanceService {
|
|
106
|
+
reviewJsonService;
|
|
107
|
+
atomicFile;
|
|
108
|
+
constructor(reviewJsonService, atomicFile) {
|
|
109
|
+
this.reviewJsonService = reviewJsonService;
|
|
110
|
+
this.atomicFile = atomicFile;
|
|
111
|
+
}
|
|
112
|
+
/** `review-<id>.provenance.json`, beside the verdict. */
|
|
113
|
+
provenancePath(reviewPath, checklistId) {
|
|
114
|
+
return path.join(path.dirname(reviewPath), `review-${checklistId}.provenance.json`);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* sha256 over the five fields in a FIXED order, so formatting, key order and whitespace outside the
|
|
118
|
+
* values cannot move it — only a change to what the verdict SAYS can.
|
|
119
|
+
*/
|
|
120
|
+
canonicalHash(verdict) {
|
|
121
|
+
const canonical = JSON.stringify([verdict.id, verdict.status, verdict.agent, verdict.model, verdict.output]);
|
|
122
|
+
return crypto.createHash('sha256').update(canonical).digest('hex');
|
|
123
|
+
}
|
|
124
|
+
/** Write the verdict, then its provenance. Returns the verdict path. */
|
|
125
|
+
write(reviewPath, verdict, provenance) {
|
|
126
|
+
const verdictPath = this.reviewJsonService.checklistResultPath(reviewPath, verdict.id);
|
|
127
|
+
provenance.status = verdict.status;
|
|
128
|
+
provenance.verdictHash = this.canonicalHash(verdict);
|
|
129
|
+
provenance.writtenAt = new Date().toISOString();
|
|
130
|
+
this.atomicFile.writeJsonAtomic(verdictPath, verdict);
|
|
131
|
+
this.atomicFile.writeJsonAtomic(this.provenancePath(reviewPath, verdict.id), provenance);
|
|
132
|
+
return verdictPath;
|
|
133
|
+
}
|
|
134
|
+
/** The provenance for one checklist, or null when there is none (or it is unreadable). */
|
|
135
|
+
read(reviewPath, checklistId) {
|
|
136
|
+
const file = this.provenancePath(reviewPath, checklistId);
|
|
137
|
+
if (!fs.existsSync(file))
|
|
138
|
+
return null;
|
|
139
|
+
// webpieces-disable no-unmanaged-exceptions -- chokepoint: an unreadable record is treated as no record, which REJECTS the verdict
|
|
140
|
+
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
141
|
+
try {
|
|
142
|
+
// webpieces-disable no-any-unknown -- opaque parsed JSON, narrowed field-by-field below
|
|
143
|
+
const raw = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
144
|
+
const record = new VerdictProvenance(this.str(raw['checklistId']), this.str(raw['harness']), this.str(raw['sessionId']), this.str(raw['agentId']), this.str(raw['agentType']), this.str(raw['headSha']), this.str(raw['scopeHash']));
|
|
145
|
+
record.writer = this.str(raw['writer']);
|
|
146
|
+
record.status = this.str(raw['status']);
|
|
147
|
+
record.verdictHash = this.str(raw['verdictHash']);
|
|
148
|
+
record.writtenAt = this.str(raw['writtenAt']);
|
|
149
|
+
return record;
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
const error = (0, rules_config_1.toError)(err);
|
|
153
|
+
void error;
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* How one parsed verdict stands. `currentScopeHash` is this checklist's scope hash NOW ('' when it
|
|
159
|
+
* could not be computed, which never marks anything stale). `singleRound` is the machine's
|
|
160
|
+
* `singleRoundReview` opt-in, and it changes two things — both so that this check does not narrow what
|
|
161
|
+
* that experimental flag already promises:
|
|
162
|
+
* - scope never goes STALE: one round means one round, and its verdicts are the review record;
|
|
163
|
+
* - the one edit that mode tells the COORDINATOR to make — an addressed red changed to yellow in
|
|
164
|
+
* place — is accepted, and nothing else is.
|
|
165
|
+
*/
|
|
166
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
167
|
+
assess(reviewPath, result, currentScopeHash, singleRound) {
|
|
168
|
+
const id = result.id;
|
|
169
|
+
const record = this.read(reviewPath, id);
|
|
170
|
+
const reject = (reason) => new VerdictStanding(id, exports.STANDING_REJECTED, result.status, '', reason);
|
|
171
|
+
if (record === null) {
|
|
172
|
+
const file = this.provenancePath(reviewPath, id);
|
|
173
|
+
const why = fs.existsSync(file) ? `${path.basename(file)} is unreadable` : `no ${path.basename(file)}`;
|
|
174
|
+
return reject(`review-${id}.json was not submitted through pnpm ${rules_config_1.WRITE_REVIEW_BIN} (${why}) — a hand-written verdict is not a review`);
|
|
175
|
+
}
|
|
176
|
+
if (record.writer !== rules_config_1.WRITE_REVIEW_BIN || record.checklistId !== id) {
|
|
177
|
+
return reject(`review-${id}.provenance.json was not written by ${rules_config_1.WRITE_REVIEW_BIN} for this checklist`);
|
|
178
|
+
}
|
|
179
|
+
if (record.agentId.trim() === '' && record.harness !== exports.HARNESS_TERMINAL) {
|
|
180
|
+
return reject(`review-${id}.json was submitted by the coordinating agent, not a reviewer subagent`);
|
|
181
|
+
}
|
|
182
|
+
const submitted = new SubmittedVerdict(id, result.status, result.agent, result.model, result.output);
|
|
183
|
+
if (!this.matchesSubmission(submitted, record, singleRound)) {
|
|
184
|
+
return reject(`review-${id}.json was EDITED after ${rules_config_1.WRITE_REVIEW_BIN} wrote it — a verdict is the reviewer's words, not a draft`);
|
|
185
|
+
}
|
|
186
|
+
if (!singleRound && currentScopeHash !== '' && record.scopeHash !== currentScopeHash) {
|
|
187
|
+
return new VerdictStanding(id, exports.STANDING_STALE, result.status, record.headSha, `in-scope files CHANGED since the verdict was written at ${this.short(record.headSha)}`);
|
|
188
|
+
}
|
|
189
|
+
return new VerdictStanding(id, exports.STANDING_CURRENT, result.status, record.headSha, `in-scope files unchanged since ${this.short(record.headSha)}`);
|
|
190
|
+
}
|
|
191
|
+
/** The first 8 characters of a sha, the way every banner line prints one. */
|
|
192
|
+
short(sha) {
|
|
193
|
+
return sha === '' ? '(unknown sha)' : sha.slice(0, 8);
|
|
194
|
+
}
|
|
195
|
+
matchesSubmission(submitted, record, singleRound) {
|
|
196
|
+
if (this.canonicalHash(submitted) === record.verdictHash)
|
|
197
|
+
return true;
|
|
198
|
+
if (!singleRound || record.status !== rules_config_1.VERDICT_RED || submitted.status !== rules_config_1.VERDICT_YELLOW)
|
|
199
|
+
return false;
|
|
200
|
+
const asSubmitted = new SubmittedVerdict(submitted.id, rules_config_1.VERDICT_RED, submitted.agent, submitted.model, submitted.output);
|
|
201
|
+
return this.canonicalHash(asSubmitted) === record.verdictHash;
|
|
202
|
+
}
|
|
203
|
+
// webpieces-disable no-any-unknown -- one opaque JSON value, narrowed to a string
|
|
204
|
+
str(value) {
|
|
205
|
+
return typeof value === 'string' ? value : '';
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
exports.VerdictProvenanceService = VerdictProvenanceService;
|
|
209
|
+
exports.VerdictProvenanceService = VerdictProvenanceService = tslib_1.__decorate([
|
|
210
|
+
(0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
|
|
211
|
+
tslib_1.__metadata("design:paramtypes", [rules_config_1.ReviewJsonService,
|
|
212
|
+
rules_config_1.AtomicFile])
|
|
213
|
+
], VerdictProvenanceService);
|
|
214
|
+
//# sourceMappingURL=verdict-provenance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verdict-provenance.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/verdict-provenance.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,+CAAyB;AACzB,mDAA6B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K,0BAAW,IAAI,SAAS,CAAC,MAAM,KAAK,6BAAc;YAAE,OAAO,KAAK,CAAC;QACvG,MAAM,WAAW,GAAG,IAAI,gBAAgB,CAAC,SAAS,CAAC,EAAE,EAAE,0BAAW,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;QACxH,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,MAAM,CAAC,WAAW,CAAC;IAClE,CAAC;IAED,kFAAkF;IAC1E,GAAG,CAAC,KAAc;QACtB,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAClD,CAAC;CACJ,CAAA;AA5GY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGG,gCAAiB;QACxB,yBAAU;GAHlC,wBAAwB,CA4GpC","sourcesContent":["import * as crypto from 'crypto';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport {\n AtomicFile, ChecklistResult, ReviewJsonService, VERDICT_RED, VERDICT_YELLOW, WRITE_REVIEW_BIN, toError,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\n/** `harness` for a verdict submitted from a plain terminal — a HUMAN reviewer, with no AI harness at all. */\nexport const HARNESS_TERMINAL = 'terminal';\n\nconst WHAT_THIS_IS =\n 'PROVENANCE — written by pnpm wp-write-review beside the verdict it submitted, never by an AI. It records ' +\n 'WHO submitted that verdict (harness, session, agent — as the harness reported them to the PreToolUse ' +\n 'hook), WHICH commit and in-scope diff the reviewer was briefed on, and a hash of the verdict itself. ' +\n 'wp-finish-upsert-pr rejects a verdict with no provenance, or one edited after submission. Do not ' +\n 'hand-edit or copy it: that is forging a review.';\n\n/** A verdict exactly as `wp-write-review` accepts it — the five fields and nothing else. Data-only. */\nexport class SubmittedVerdict {\n id: string;\n status: string;\n agent: string;\n model: string;\n output: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(id: string, status: string, agent: string, model: string, output: string) {\n this.id = id;\n this.status = status;\n this.agent = agent;\n this.model = model;\n this.output = output;\n }\n}\n\n/**\n * The record `wp-write-review` writes to `review-<id>.provenance.json`. Data-only; field names are the JSON\n * keys, `_WHAT_THIS_IS` first so a reader learns what the file is before anything it might act on.\n */\nexport class VerdictProvenance {\n // webpieces-disable naming-convention -- the leading underscore marks a note-to-the-reader key, not data\n _WHAT_THIS_IS = WHAT_THIS_IS;\n writer: string; // always WRITE_REVIEW_BIN — a record naming anything else was not written by it\n checklistId: string;\n harness: string; // 'claude-code' | 'codex' | HARNESS_TERMINAL\n sessionId: string;\n agentId: string; // the SUBAGENT that submitted; '' only for HARNESS_TERMINAL\n agentType: string;\n headSha: string; // the commit stage ② briefed this reviewer on\n scopeHash: string; // ChecklistScopeHasher's hash of this checklist's in-scope diff at that commit\n status: string; // the status as submitted\n verdictHash: string; // VerdictProvenanceService.canonicalHash of the verdict as submitted\n writtenAt: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(checklistId: string, harness: string, sessionId: string, agentId: string, agentType: string, headSha: string, scopeHash: string) {\n this.writer = WRITE_REVIEW_BIN;\n this.checklistId = checklistId;\n this.harness = harness;\n this.sessionId = sessionId;\n this.agentId = agentId;\n this.agentType = agentType;\n this.headSha = headSha;\n this.scopeHash = scopeHash;\n this.status = '';\n this.verdictHash = '';\n this.writtenAt = '';\n }\n}\n\n/** A live verdict that stands: submitted through the bin and judged the in-scope diff as it is NOW. */\nexport const STANDING_CURRENT = 'current';\n/** Submitted through the bin, but the checklist's in-scope diff has changed since — it judged other code. */\nexport const STANDING_STALE = 'stale';\n/** No bin provenance, or edited after submission: not a reviewer's verdict at all. */\nexport const STANDING_REJECTED = 'rejected';\n\n/**\n * How ONE existing verdict file stands against the branch as it is now. Data-only. Carried on the\n * checklist scan so stage ② (which briefs) and stage ③ (which blocks) read one answer.\n */\nexport class VerdictStanding {\n checklistId: string;\n standing: string; // STANDING_CURRENT | STANDING_STALE | STANDING_REJECTED\n status: string; // the verdict's own green | yellow | red\n fromSha: string; // the commit it was briefed on ('' when rejected)\n reason: string; // why — printed verbatim\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(checklistId: string, standing: string, status: string, fromSha: string, reason: string) {\n this.checklistId = checklistId;\n this.standing = standing;\n this.status = status;\n this.fromSha = fromSha;\n this.reason = reason;\n }\n}\n\n/**\n * Writes a submitted verdict WITH its provenance, and judges an existing verdict against it (issue #863).\n *\n * This is what closes the forgery the issue measured: a Codex coordinator wrote five `review-<id>.json`\n * files itself and the gate accepted them, because nothing distinguished a reviewer's verdict from a file\n * that merely had the right shape. Now a verdict counts only when `wp-write-review` wrote it — which it does\n * only for a caller the harness identified as a subagent — and only while it still says exactly what was\n * submitted.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class VerdictProvenanceService {\n constructor(\n private readonly reviewJsonService: ReviewJsonService,\n private readonly atomicFile: AtomicFile,\n ) {}\n\n /** `review-<id>.provenance.json`, beside the verdict. */\n provenancePath(reviewPath: string, checklistId: string): string {\n return path.join(path.dirname(reviewPath), `review-${checklistId}.provenance.json`);\n }\n\n /**\n * sha256 over the five fields in a FIXED order, so formatting, key order and whitespace outside the\n * values cannot move it — only a change to what the verdict SAYS can.\n */\n canonicalHash(verdict: SubmittedVerdict): string {\n const canonical = JSON.stringify([verdict.id, verdict.status, verdict.agent, verdict.model, verdict.output]);\n return crypto.createHash('sha256').update(canonical).digest('hex');\n }\n\n /** Write the verdict, then its provenance. Returns the verdict path. */\n write(reviewPath: string, verdict: SubmittedVerdict, provenance: VerdictProvenance): string {\n const verdictPath = this.reviewJsonService.checklistResultPath(reviewPath, verdict.id);\n provenance.status = verdict.status;\n provenance.verdictHash = this.canonicalHash(verdict);\n provenance.writtenAt = new Date().toISOString();\n this.atomicFile.writeJsonAtomic(verdictPath, verdict);\n this.atomicFile.writeJsonAtomic(this.provenancePath(reviewPath, verdict.id), provenance);\n return verdictPath;\n }\n\n /** The provenance for one checklist, or null when there is none (or it is unreadable). */\n read(reviewPath: string, checklistId: string): VerdictProvenance | null {\n const file = this.provenancePath(reviewPath, checklistId);\n if (!fs.existsSync(file)) return null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unreadable record is treated as no record, which REJECTS the verdict\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n // webpieces-disable no-any-unknown -- opaque parsed JSON, narrowed field-by-field below\n const raw = JSON.parse(fs.readFileSync(file, 'utf8')) as Record<string, unknown>;\n const record = new VerdictProvenance(\n this.str(raw['checklistId']), this.str(raw['harness']), this.str(raw['sessionId']),\n this.str(raw['agentId']), this.str(raw['agentType']), this.str(raw['headSha']), this.str(raw['scopeHash']));\n record.writer = this.str(raw['writer']);\n record.status = this.str(raw['status']);\n record.verdictHash = this.str(raw['verdictHash']);\n record.writtenAt = this.str(raw['writtenAt']);\n return record;\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n return null;\n }\n }\n\n /**\n * How one parsed verdict stands. `currentScopeHash` is this checklist's scope hash NOW ('' when it\n * could not be computed, which never marks anything stale). `singleRound` is the machine's\n * `singleRoundReview` opt-in, and it changes two things — both so that this check does not narrow what\n * that experimental flag already promises:\n * - scope never goes STALE: one round means one round, and its verdicts are the review record;\n * - the one edit that mode tells the COORDINATOR to make — an addressed red changed to yellow in\n * place — is accepted, and nothing else is.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n assess(reviewPath: string, result: ChecklistResult, currentScopeHash: string, singleRound: boolean): VerdictStanding {\n const id = result.id;\n const record = this.read(reviewPath, id);\n const reject = (reason: string): VerdictStanding => new VerdictStanding(id, STANDING_REJECTED, result.status, '', reason);\n if (record === null) {\n const file = this.provenancePath(reviewPath, id);\n const why = fs.existsSync(file) ? `${path.basename(file)} is unreadable` : `no ${path.basename(file)}`;\n return reject(`review-${id}.json was not submitted through pnpm ${WRITE_REVIEW_BIN} (${why}) — a hand-written verdict is not a review`);\n }\n if (record.writer !== WRITE_REVIEW_BIN || record.checklistId !== id) {\n return reject(`review-${id}.provenance.json was not written by ${WRITE_REVIEW_BIN} for this checklist`);\n }\n if (record.agentId.trim() === '' && record.harness !== HARNESS_TERMINAL) {\n return reject(`review-${id}.json was submitted by the coordinating agent, not a reviewer subagent`);\n }\n const submitted = new SubmittedVerdict(id, result.status, result.agent, result.model, result.output);\n if (!this.matchesSubmission(submitted, record, singleRound)) {\n return reject(`review-${id}.json was EDITED after ${WRITE_REVIEW_BIN} wrote it — a verdict is the reviewer's words, not a draft`);\n }\n if (!singleRound && currentScopeHash !== '' && record.scopeHash !== currentScopeHash) {\n return new VerdictStanding(id, STANDING_STALE, result.status, record.headSha,\n `in-scope files CHANGED since the verdict was written at ${this.short(record.headSha)}`);\n }\n return new VerdictStanding(id, STANDING_CURRENT, result.status, record.headSha,\n `in-scope files unchanged since ${this.short(record.headSha)}`);\n }\n\n /** The first 8 characters of a sha, the way every banner line prints one. */\n short(sha: string): string {\n return sha === '' ? '(unknown sha)' : sha.slice(0, 8);\n }\n\n private matchesSubmission(submitted: SubmittedVerdict, record: VerdictProvenance, singleRound: boolean): boolean {\n if (this.canonicalHash(submitted) === record.verdictHash) return true;\n if (!singleRound || record.status !== VERDICT_RED || submitted.status !== VERDICT_YELLOW) return false;\n const asSubmitted = new SubmittedVerdict(submitted.id, VERDICT_RED, submitted.agent, submitted.model, submitted.output);\n return this.canonicalHash(asSubmitted) === record.verdictHash;\n }\n\n // webpieces-disable no-any-unknown -- one opaque JSON value, narrowed to a string\n private str(value: unknown): string {\n return typeof value === 'string' ? value : '';\n }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const inversify_1 = require("inversify");
|
|
6
|
+
const rules_config_1 = require("@webpieces/rules-config");
|
|
7
|
+
const pr_gate_app_1 = require("./pr-gate-app");
|
|
8
|
+
const write_review_command_1 = require("./commands/write-review-command");
|
|
9
|
+
const CHECKLIST = '--checklist';
|
|
10
|
+
const FILE = '--file';
|
|
11
|
+
// Composition root for `wp-write-review`: the ONE way a reviewer subagent submits a checklist verdict
|
|
12
|
+
// (issue #863). The command an agent types stays PLAIN — `pnpm wp-write-review --checklist <id>` with the
|
|
13
|
+
// JSON on stdin — because the PreToolUse hook reads that literal command to stamp WHO is running it, and a
|
|
14
|
+
// worktree-isolated subagent's harness only runs commands it can see stay inside the worktree.
|
|
15
|
+
(0, rules_config_1.runMain)(async () => {
|
|
16
|
+
const container = new inversify_1.Container({ autobind: true });
|
|
17
|
+
const args = container.get(rules_config_1.CliArgs).parse(new rules_config_1.CliUsage('wp-write-review', 'Submit ONE reviewer verdict for ONE checklist. Reviewer subagents only — the coordinating agent is refused.', [
|
|
18
|
+
new rules_config_1.CliFlag(CHECKLIST, 'REQUIRED. The checklist id your instructions file names, e.g. --checklist security.', true),
|
|
19
|
+
new rules_config_1.CliFlag(FILE, 'The verdict JSON file. Omit it to pass the JSON on stdin:\n'
|
|
20
|
+
+ " pnpm wp-write-review --checklist <id> <<'EOF' … EOF", true),
|
|
21
|
+
]));
|
|
22
|
+
const json = container.get(write_review_command_1.WriteReviewInput).read(args.value(FILE));
|
|
23
|
+
await container.get(pr_gate_app_1.PrGateApp).writeReview(new write_review_command_1.WriteReviewOptions(args.value(CHECKLIST), json, process.cwd()));
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=wp-write-review.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wp-write-review.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/wp-write-review.ts"],"names":[],"mappings":";;;AACA,4BAA0B;AAC1B,yCAAsC;AACtC,0DAA8E;AAC9E,+CAA0C;AAC1C,0EAAuF;AAEvF,MAAM,SAAS,GAAG,aAAa,CAAC;AAChC,MAAM,IAAI,GAAG,QAAQ,CAAC;AAEtB,sGAAsG;AACtG,0GAA0G;AAC1G,2GAA2G;AAC3G,+FAA+F;AAC/F,IAAA,sBAAO,EAAC,KAAK,IAAmB,EAAE;IAC9B,MAAM,SAAS,GAAG,IAAI,qBAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,sBAAO,CAAC,CAAC,KAAK,CAAC,IAAI,uBAAQ,CAClD,iBAAiB,EACjB,6GAA6G,EAC7G;QACI,IAAI,sBAAO,CAAC,SAAS,EAAE,qFAAqF,EAAE,IAAI,CAAC;QACnH,IAAI,sBAAO,CAAC,IAAI,EACZ,6DAA6D;cAC3D,qEAAqE,EAAE,IAAI,CAAC;KACrF,CAAC,CAAC,CAAC;IACR,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,uCAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACpE,MAAM,SAAS,CAAC,GAAG,CAAC,uBAAS,CAAC,CAAC,WAAW,CAAC,IAAI,yCAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AACnH,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport 'reflect-metadata';\nimport { Container } from 'inversify';\nimport { runMain, CliArgs, CliFlag, CliUsage } from '@webpieces/rules-config';\nimport { PrGateApp } from './pr-gate-app';\nimport { WriteReviewInput, WriteReviewOptions } from './commands/write-review-command';\n\nconst CHECKLIST = '--checklist';\nconst FILE = '--file';\n\n// Composition root for `wp-write-review`: the ONE way a reviewer subagent submits a checklist verdict\n// (issue #863). The command an agent types stays PLAIN — `pnpm wp-write-review --checklist <id>` with the\n// JSON on stdin — because the PreToolUse hook reads that literal command to stamp WHO is running it, and a\n// worktree-isolated subagent's harness only runs commands it can see stay inside the worktree.\nrunMain(async (): Promise<void> => {\n const container = new Container({ autobind: true });\n const args = container.get(CliArgs).parse(new CliUsage(\n 'wp-write-review',\n 'Submit ONE reviewer verdict for ONE checklist. Reviewer subagents only — the coordinating agent is refused.',\n [\n new CliFlag(CHECKLIST, 'REQUIRED. The checklist id your instructions file names, e.g. --checklist security.', true),\n new CliFlag(FILE,\n 'The verdict JSON file. Omit it to pass the JSON on stdin:\\n'\n + \" pnpm wp-write-review --checklist <id> <<'EOF' … EOF\", true),\n ]));\n const json = container.get(WriteReviewInput).read(args.value(FILE));\n await container.get(PrGateApp).writeReview(new WriteReviewOptions(args.value(CHECKLIST), json, process.cwd()));\n});\n"]}
|