@webpieces/pr-gate 0.4.821 → 0.4.823

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.
Files changed (42) hide show
  1. package/package.json +4 -3
  2. package/src/dashboard/checklist-comment-renderer.js +6 -4
  3. package/src/dashboard/checklist-comment-renderer.js.map +1 -1
  4. package/src/dashboard/dashboard.js +6 -1
  5. package/src/dashboard/dashboard.js.map +1 -1
  6. package/src/scripts/commands/finish-upsert-pr-command.d.ts +4 -1
  7. package/src/scripts/commands/finish-upsert-pr-command.js +26 -5
  8. package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -1
  9. package/src/scripts/commands/review-upsert-pr-command.d.ts +3 -1
  10. package/src/scripts/commands/review-upsert-pr-command.js +40 -23
  11. package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
  12. package/src/scripts/commands/write-review-command.d.ts +3 -1
  13. package/src/scripts/commands/write-review-command.js +9 -3
  14. package/src/scripts/commands/write-review-command.js.map +1 -1
  15. package/src/scripts/commands/write-review-fixes-command.d.ts +21 -0
  16. package/src/scripts/commands/write-review-fixes-command.js +68 -0
  17. package/src/scripts/commands/write-review-fixes-command.js.map +1 -0
  18. package/src/scripts/pr-gate-app.d.ts +5 -1
  19. package/src/scripts/pr-gate-app.js +9 -1
  20. package/src/scripts/pr-gate-app.js.map +1 -1
  21. package/src/scripts/workflow/checklist-scanner.d.ts +1 -3
  22. package/src/scripts/workflow/checklist-scanner.js +6 -9
  23. package/src/scripts/workflow/checklist-scanner.js.map +1 -1
  24. package/src/scripts/workflow/repo-config-testkit.js +2 -0
  25. package/src/scripts/workflow/repo-config-testkit.js.map +1 -1
  26. package/src/scripts/workflow/review-report.d.ts +7 -4
  27. package/src/scripts/workflow/review-report.js +44 -24
  28. package/src/scripts/workflow/review-report.js.map +1 -1
  29. package/src/scripts/workflow/review-round-state.d.ts +58 -0
  30. package/src/scripts/workflow/review-round-state.js +300 -0
  31. package/src/scripts/workflow/review-round-state.js.map +1 -0
  32. package/src/scripts/workflow/review-stage-receipt.d.ts +6 -0
  33. package/src/scripts/workflow/review-stage-receipt.js +13 -0
  34. package/src/scripts/workflow/review-stage-receipt.js.map +1 -1
  35. package/src/scripts/workflow/reviewer-verdict-gate.js +6 -24
  36. package/src/scripts/workflow/reviewer-verdict-gate.js.map +1 -1
  37. package/src/scripts/workflow/verdict-provenance.d.ts +3 -8
  38. package/src/scripts/workflow/verdict-provenance.js +7 -17
  39. package/src/scripts/workflow/verdict-provenance.js.map +1 -1
  40. package/src/scripts/wp-write-review-fixes.d.ts +2 -0
  41. package/src/scripts/wp-write-review-fixes.js +16 -0
  42. package/src/scripts/wp-write-review-fixes.js.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-round-state.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/review-round-state.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,iDAA0C;AAC1C,0DAA6G;AAC7G,yCAA2D;AAE3D,6DAAgE;AAChE,6CAAyC;AAM5B,QAAA,mBAAmB,GAAG,QAAQ,CAAC;AAC/B,QAAA,mBAAmB,GAAG,QAAQ,CAAC;AAC/B,QAAA,gBAAgB,GAAG,KAAK,CAAC;AACzB,QAAA,mBAAmB,GAAG,QAAQ,CAAC;AAC/B,QAAA,mBAAmB,GAAG,QAAQ,CAAC;AAE5C,MAAa,eAAe;IACxB,MAAM,CAAS;IACf,KAAK,CAAS;IACd,SAAS,CAAS;IAClB,KAAK,CAAY;IACjB,YAAY,CAAW;IACvB,eAAe,CAAW;IAE1B,YAAY,MAAc,EAAE,KAAa,EAAE,SAAiB,EAAE,KAAgB,EAAE,eAAyB,EAAE,EAAE,kBAA4B,EAAE;QACvI,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAA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AM,IAAI,4BAAa,CAAC,0GAA0G,CAAC,CAAC;IAC3J,CAAC;IAEO,GAAG,CAAC,QAAgB,EAAE,IAAc;QACxC,MAAM,MAAM,GAAG,IAAA,yBAAS,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QAC3E,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7D,MAAM,OAAO,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACxC,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,MAAM,CAAC,KAAK,EAAE,OAAO,IAAI,QAAQ,MAAM,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC7G,MAAM,OAAO,GAAG,oCAAoC,OAAO,KAAK,MAAM,EAAE,CAAC;QACzE,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS;YAAE,MAAM,IAAI,4BAAa,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QAC1F,MAAM,IAAI,4BAAa,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACJ,CAAA;AAlOY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGJ,gCAAiB;QACjB,6CAAwB;QACxB,yBAAU;GAJlC,uBAAuB,CAkOnC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { spawnSync } from 'child_process';\nimport { AtomicFile, InformAiError, ReviewJsonService, VERDICT_RED, toError } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ReviewStageReceipt } from './review-stage-receipt';\nimport { VerdictProvenanceService } from './verdict-provenance';\nimport { DiffBasis } from './diff-basis';\n\ntype JsonPrimitive = string | number | boolean | null;\ntype JsonValue = JsonPrimitive | JsonValue[] | JsonObject;\ninterface JsonObject { [key: string]: JsonValue }\n\nexport const ROUND_ACTION_REVIEW = 'review';\nexport const ROUND_ACTION_RESUME = 'resume';\nexport const ROUND_ACTION_FIX = 'fix';\nexport const ROUND_ACTION_RECORD = 'record';\nexport const ROUND_ACTION_FINISH = 'finish';\n\nexport class ReviewRoundPlan {\n action: string;\n round: number;\n maxRounds: number;\n basis: DiffBasis;\n changedFiles: string[];\n redChecklistIds: string[];\n\n constructor(action: string, round: number, maxRounds: number, basis: DiffBasis, changedFiles: string[] = [], redChecklistIds: string[] = []) {\n this.action = action;\n this.round = round;\n this.maxRounds = maxRounds;\n this.basis = basis;\n this.changedFiles = changedFiles;\n this.redChecklistIds = redChecklistIds;\n }\n}\n\nexport class RemediationResponse {\n checklistId: string;\n resolution: string;\n files: string[];\n\n constructor(checklistId: string, resolution: string, files: string[]) {\n this.checklistId = checklistId;\n this.resolution = resolution;\n this.files = files;\n }\n}\n\nexport class ReviewRemediation {\n agent: string;\n model: string;\n fromHead: string;\n toHead: string;\n responses: RemediationResponse[];\n writtenAt: string;\n\n constructor(agent: string, model: string, fromHead: string, toHead: string, responses: RemediationResponse[]) {\n this.agent = agent;\n this.model = model;\n this.fromHead = fromHead;\n this.toHead = toHead;\n this.responses = responses;\n this.writtenAt = new Date().toISOString();\n }\n}\n\n/** Immutable per-round verdict history plus the author-remediation records between rounds. */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewRoundStateService {\n constructor(\n private readonly reviewJson: ReviewJsonService,\n private readonly provenance: VerdictProvenanceService,\n private readonly atomicFile: AtomicFile,\n ) {}\n\n roundDir(summaryPath: string, round: number): string {\n return path.join(path.dirname(summaryPath), 'rounds', String(round));\n }\n\n archiveVerdict(summaryPath: string, checklistId: string, round: number): void {\n const dir = this.roundDir(summaryPath, round);\n fs.mkdirSync(dir, { recursive: true });\n fs.copyFileSync(this.reviewJson.checklistResultPath(summaryPath, checklistId), path.join(dir, `review-${checklistId}.json`));\n fs.copyFileSync(this.provenance.provenancePath(summaryPath, checklistId), path.join(dir, `review-${checklistId}.provenance.json`));\n }\n\n roundComplete(summaryPath: string, receipt: ReviewStageReceipt): boolean {\n if (receipt.round < 1 || receipt.reviewersBriefed.length === 0) return false;\n return receipt.reviewersBriefed.every((id: string): boolean =>\n fs.existsSync(path.join(this.roundDir(summaryPath, receipt.round), `review-${id}.json`)));\n }\n\n redChecklistIds(summaryPath: string, receipt: ReviewStageReceipt): string[] {\n if (!this.roundComplete(summaryPath, receipt)) return [];\n return receipt.reviewersBriefed.filter((id: string): boolean => {\n const raw = this.readObject(path.join(this.roundDir(summaryPath, receipt.round), `review-${id}.json`));\n return raw !== null && raw['status'] === VERDICT_RED;\n });\n }\n\n remediationPath(summaryPath: string, round: number): string {\n return path.join(this.roundDir(summaryPath, round), 'review-fixes.json');\n }\n\n plan(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number, fullBasis: DiffBasis): ReviewRoundPlan {\n if (receipt === null || receipt.round < 1) {\n return new ReviewRoundPlan(ROUND_ACTION_REVIEW, 1, maxRounds, fullBasis);\n }\n if (!this.roundComplete(summaryPath, receipt)) {\n if (receipt.headSha !== fullBasis.headSha) {\n throw new InformAiError(`Global reviewer round ${receipt.round} of ${maxRounds} is still active at `\n + `${receipt.headSha.slice(0, 8)}. Finish that fixed roster before changing the reviewed HEAD.`);\n }\n return new ReviewRoundPlan(ROUND_ACTION_RESUME, receipt.round, maxRounds, fullBasis);\n }\n const reds = this.redChecklistIds(summaryPath, receipt);\n if (reds.length === 0) return new ReviewRoundPlan(ROUND_ACTION_FINISH, receipt.round, maxRounds, fullBasis);\n if (receipt.headSha === fullBasis.headSha) {\n return new ReviewRoundPlan(ROUND_ACTION_FIX, receipt.round, maxRounds, fullBasis, [], reds);\n }\n const remediation = this.validRemediation(repoRoot, summaryPath, receipt);\n if (remediation === null) {\n return new ReviewRoundPlan(ROUND_ACTION_RECORD, receipt.round, maxRounds, fullBasis, [], reds);\n }\n if (receipt.round >= maxRounds) {\n return new ReviewRoundPlan(ROUND_ACTION_FINISH, receipt.round, maxRounds, fullBasis, [], reds);\n }\n const basis = new DiffBasis(\n receipt.headSha, fullBasis.headSha, false, [],\n `git diff ${receipt.headSha} ${fullBasis.headSha}`,\n `git diff ${receipt.headSha} ${fullBasis.headSha} -- <file>`, fullBasis.hashMainHead);\n const changed = this.git(repoRoot, ['diff', '--name-only', receipt.headSha, fullBasis.headSha])\n .split('\\n').filter((f: string): boolean => f.trim() !== '');\n return new ReviewRoundPlan(ROUND_ACTION_REVIEW, receipt.round + 1, maxRounds, basis, changed, reds);\n }\n\n writeRemediation(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt, json: string): string {\n if (!this.roundComplete(summaryPath, receipt)) {\n throw new InformAiError('wp-write-review-fixes: the active reviewer round is not complete yet.');\n }\n this.assertClean(repoRoot);\n const currentHead = this.git(repoRoot, ['rev-parse', 'HEAD']);\n const reds = this.redChecklistIds(summaryPath, receipt);\n if (reds.length === 0) throw new InformAiError('wp-write-review-fixes: the completed round has no red verdict to remediate.');\n if (currentHead === receipt.headSha || this.git(repoRoot, ['diff', '--name-only', receipt.headSha, currentHead]) === '') {\n throw new InformAiError('wp-write-review-fixes: remediation must contain a committed, non-empty delta after the reviewed HEAD.');\n }\n const raw = this.parseObject(json, 'wp-write-review-fixes: input must be one JSON object.');\n const agent = this.requiredText(raw, 'agent');\n const model = this.requiredText(raw, 'model');\n const responses = this.responses(raw['responses']);\n const ids = responses.map((r: RemediationResponse): string => r.checklistId);\n const unknown = ids.filter((id: string): boolean => !reds.includes(id));\n const missing = reds.filter((id: string): boolean => !ids.includes(id));\n if (unknown.length > 0 || missing.length > 0) {\n throw new InformAiError(`wp-write-review-fixes: responses must cover exactly the red checklist(s). `\n + `Unknown: ${unknown.join(', ') || '(none)'}. Missing: ${missing.join(', ') || '(none)'}.`);\n }\n const record = new ReviewRemediation(agent, model, receipt.headSha, currentHead, responses);\n const out = this.remediationPath(summaryPath, receipt.round);\n this.atomicFile.writeJsonAtomic(out, record);\n return out;\n }\n\n validRemediation(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt): ReviewRemediation | null {\n const raw = this.readObject(this.remediationPath(summaryPath, receipt.round));\n if (raw === null) return null;\n const currentHead = this.git(repoRoot, ['rev-parse', 'HEAD']);\n const responses = this.responsesOrEmpty(raw['responses']);\n const reds = this.redChecklistIds(summaryPath, receipt);\n const ids = responses.map((r: RemediationResponse): string => r.checklistId);\n if (this.text(raw['agent']) === '' || this.text(raw['model']) === ''\n || raw['fromHead'] !== receipt.headSha || raw['toHead'] !== currentHead\n || currentHead === receipt.headSha || reds.some((id: string): boolean => !ids.includes(id))\n || ids.some((id: string): boolean => !reds.includes(id))) return null;\n return new ReviewRemediation(this.text(raw['agent']), this.text(raw['model']), receipt.headSha, currentHead, responses);\n }\n\n capRemediations(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number): Record<string, string> {\n const out: Record<string, string> = {};\n if (receipt === null || receipt.round < maxRounds) return out;\n const remediation = this.validRemediation(repoRoot, summaryPath, receipt);\n if (remediation === null) return out;\n for (const response of remediation.responses) {\n out[response.checklistId] = `Author-remediated after review cap; NOT re-reviewed. ${response.resolution} `\n + `(${remediation.fromHead.slice(0, 8)}..${remediation.toHead.slice(0, 8)})`;\n }\n return out;\n }\n\n auditTrail(summaryPath: string, checklistId: string, receipt: ReviewStageReceipt | null): string {\n if (receipt === null || receipt.round < 1) return '';\n const lines: string[] = [];\n for (let round = 1; round <= receipt.round; round++) {\n const dir = this.roundDir(summaryPath, round);\n const verdict = this.readObject(path.join(dir, `review-${checklistId}.json`));\n const record = this.readObject(path.join(dir, `review-${checklistId}.provenance.json`));\n if (verdict !== null) {\n lines.push(`#### Reviewer round ${round} of ${receipt.maxReviewerRounds}`);\n lines.push(`Reviewed SHA: ${this.text(record?.['headSha']) || '(unknown)'}`);\n lines.push(`Status: ${this.text(verdict['status']).toUpperCase()}`);\n lines.push('', this.text(verdict['output']), '');\n }\n const remediation = this.readObject(this.remediationPath(summaryPath, round));\n if (remediation !== null && Array.isArray(remediation['responses'])) {\n const response = (remediation['responses'] as JsonValue[]).find((entry: JsonValue): boolean =>\n typeof entry === 'object' && entry !== null && !Array.isArray(entry)\n && (entry as JsonObject)['checklistId'] === checklistId);\n if (typeof response === 'object' && response !== null && !Array.isArray(response)) {\n const raw = response as JsonObject;\n lines.push(`#### Author remediation after round ${round}`);\n lines.push(`Range: ${this.text(remediation['fromHead'])}..${this.text(remediation['toHead'])}`);\n lines.push('', this.text(raw['resolution']), '');\n }\n }\n }\n return lines.join('\\n').trim();\n }\n\n private responses(value: JsonValue | undefined): RemediationResponse[] {\n const responses = this.responsesOrEmpty(value);\n if (responses.length === 0) throw new InformAiError('wp-write-review-fixes: \"responses\" must be a non-empty array.');\n return responses;\n }\n\n private responsesOrEmpty(value: JsonValue | undefined): RemediationResponse[] {\n if (!Array.isArray(value)) return [];\n const out: RemediationResponse[] = [];\n for (const entry of value) {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return [];\n const raw = entry as JsonObject;\n const id = this.text(raw['checklistId']);\n const resolution = this.text(raw['resolution']);\n const files = Array.isArray(raw['files']) ? raw['files'].filter((f: JsonValue): f is string => typeof f === 'string' && f.trim() !== '') : [];\n if (id === '' || resolution === '' || files.length === 0) return [];\n out.push(new RemediationResponse(id, resolution, files));\n }\n return out;\n }\n\n private requiredText(raw: JsonObject, key: string): string {\n const value = this.text(raw[key]);\n if (value === '') throw new InformAiError(`wp-write-review-fixes: \"${key}\" must be a non-empty string.`);\n return value;\n }\n\n private text(value: JsonValue | undefined): string {\n return typeof value === 'string' ? value.trim() : '';\n }\n\n private parseObject(json: string, message: string): JsonObject {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: malformed author JSON becomes an actionable refusal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const value = JSON.parse(json) as JsonValue;\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) return value;\n // webpieces-disable no-any-unknown -- the language types caught JavaScript values as unknown\n } catch (err: unknown) {\n const error = toError(err);\n void error;\n }\n throw new InformAiError(message);\n }\n\n private readObject(file: string): JsonObject | null {\n if (!fs.existsSync(file)) return null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: unreadable durable state becomes an actionable refusal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const value = JSON.parse(fs.readFileSync(file, 'utf8')) as JsonValue;\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) return value;\n throw new InformAiError(`Review state file must contain one JSON object: ${file}`);\n // webpieces-disable no-any-unknown -- the language types caught JavaScript values as unknown\n } catch (err: unknown) {\n const error = toError(err);\n if (error instanceof InformAiError) throw error;\n throw new InformAiError(`Could not read review state file ${file}: ${error.message}`, { cause: error });\n }\n }\n\n private assertClean(repoRoot: string): void {\n const status = this.git(repoRoot, ['status', '--porcelain', '--untracked-files=all']);\n if (status !== '') throw new InformAiError('wp-write-review-fixes: commit every remediation and leave no staged, unstaged, or untracked files first.');\n }\n\n private git(repoRoot: string, args: string[]): string {\n const result = spawnSync('git', args, { cwd: repoRoot, encoding: 'utf8' });\n if (result.status === 0) return (result.stdout ?? '').trim();\n const command = `git ${args.join(' ')}`;\n const detail = (result.stderr ?? '').trim() || result.error?.message || `exit ${result.status ?? 'unknown'}`;\n const message = `Review-round Git command failed: ${command}\\n${detail}`;\n if (result.error !== undefined) throw new InformAiError(message, { cause: result.error });\n throw new InformAiError(message);\n }\n}\n"]}
@@ -15,6 +15,12 @@ export declare class ReviewStageReceipt {
15
15
  * a green/yellow forward only while that hash is unchanged (issue #863). Assigned after construction.
16
16
  */
17
17
  scopeHashes: Record<string, string>;
18
+ /** Global reviewer round, owned by stage ②. Zero means no reviewer round has started. */
19
+ round: number;
20
+ /** Repository-owned cap copied from config so verdict provenance can audit the active budget. */
21
+ maxReviewerRounds: number;
22
+ /** Prior reviewed HEAD for remediation-only rounds; empty for the initial full review. */
23
+ remediationFromHead: string;
18
24
  constructor(headSha?: string, mergeValidated?: boolean, buildCommand?: string, buildPassedAt?: string, reviewersBriefed?: string[]);
19
25
  }
20
26
  /**
@@ -22,6 +22,12 @@ class ReviewStageReceipt {
22
22
  * a green/yellow forward only while that hash is unchanged (issue #863). Assigned after construction.
23
23
  */
24
24
  scopeHashes;
25
+ /** Global reviewer round, owned by stage ②. Zero means no reviewer round has started. */
26
+ round;
27
+ /** Repository-owned cap copied from config so verdict provenance can audit the active budget. */
28
+ maxReviewerRounds;
29
+ /** Prior reviewed HEAD for remediation-only rounds; empty for the initial full review. */
30
+ remediationFromHead;
25
31
  // eslint-disable-next-line @typescript-eslint/max-params
26
32
  constructor(headSha = '', mergeValidated = false, buildCommand = '', buildPassedAt = '', reviewersBriefed = []) {
27
33
  this.headSha = headSha;
@@ -30,6 +36,9 @@ class ReviewStageReceipt {
30
36
  this.buildPassedAt = buildPassedAt;
31
37
  this.reviewersBriefed = reviewersBriefed;
32
38
  this.scopeHashes = {};
39
+ this.round = 0;
40
+ this.maxReviewerRounds = 0;
41
+ this.remediationFromHead = '';
33
42
  }
34
43
  }
35
44
  exports.ReviewStageReceipt = ReviewStageReceipt;
@@ -74,6 +83,10 @@ let ReviewStageReceiptService = class ReviewStageReceiptService {
74
83
  const raw = JSON.parse(fs.readFileSync(p, 'utf8'));
75
84
  const receipt = new ReviewStageReceipt(typeof raw['headSha'] === 'string' ? raw['headSha'] : '', raw['mergeValidated'] === true, typeof raw['buildCommand'] === 'string' ? raw['buildCommand'] : '', typeof raw['buildPassedAt'] === 'string' ? raw['buildPassedAt'] : '', Array.isArray(raw['reviewersBriefed']) ? raw['reviewersBriefed'] : []);
76
85
  receipt.scopeHashes = this.stringMap(raw['scopeHashes']);
86
+ receipt.round = typeof raw['round'] === 'number' && Number.isInteger(raw['round']) ? raw['round'] : 0;
87
+ receipt.maxReviewerRounds = typeof raw['maxReviewerRounds'] === 'number' && Number.isInteger(raw['maxReviewerRounds'])
88
+ ? raw['maxReviewerRounds'] : 0;
89
+ receipt.remediationFromHead = typeof raw['remediationFromHead'] === 'string' ? raw['remediationFromHead'] : '';
77
90
  return receipt;
78
91
  }
79
92
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"review-stage-receipt.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/review-stage-receipt.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,0DAAqE;AACrE,yCAA2D;AAE9C,QAAA,YAAY,GAAG,mBAAmB,CAAC;AAEhD;;GAEG;AACH,MAAa,kBAAkB;IAC3B,OAAO,CAAS,CAAU,gEAAgE;IAC1F,cAAc,CAAU,CAAE,oEAAoE;IAC9F,YAAY,CAAS;IACrB,aAAa,CAAS,CAAI,4DAA4D;IACtF,gBAAgB,CAAW;IAC3B;;;;OAIG;IACH,WAAW,CAAyB;IAEpC,yDAAyD;IACzD,YAAY,OAAO,GAAG,EAAE,EAAE,cAAc,GAAG,KAAK,EAAE,YAAY,GAAG,EAAE,EAAE,aAAa,GAAG,EAAE,EAAE,mBAA6B,EAAE;QACpH,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IAC1B,CAAC;CACJ;AAtBD,gDAsBC;AAED;;;;;;;;;;;;;;GAcG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IACL;IAA7B,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAG,CAAC;IAErE,WAAW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ACjC,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACnB,IAAI,OAAO,CAAC,KAAK,QAAQ;gBAAE,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAA;AAzDY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEW,gCAAiB;GADxD,yBAAyB,CAyDrC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { ReviewJsonService, toError } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nexport const RECEIPT_FILE = 'review-stage.json';\n\n/**\n * Proof that stage ② (`wp-review-upsert-pr`) actually ran, and on WHICH commit. Data-only (per CLAUDE.md).\n */\nexport class ReviewStageReceipt {\n headSha: string; // the sha the merge was validated and the build was run against\n mergeValidated: boolean; // a 3-point merge was finalized here, or there was none to finalize\n buildCommand: string;\n buildPassedAt: string; // ISO; '' when the gate was skipped (mode OFF / no command)\n reviewersBriefed: string[];\n /**\n * checklist id → the hash of its in-scope diff at `headSha` (ChecklistScopeHasher). `wp-write-review`\n * stamps a verdict's provenance with the hash its reviewer was BRIEFED on, and the next stage ② carries\n * a green/yellow forward only while that hash is unchanged (issue #863). Assigned after construction.\n */\n scopeHashes: Record<string, string>;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(headSha = '', mergeValidated = false, buildCommand = '', buildPassedAt = '', reviewersBriefed: string[] = []) {\n this.headSha = headSha;\n this.mergeValidated = mergeValidated;\n this.buildCommand = buildCommand;\n this.buildPassedAt = buildPassedAt;\n this.reviewersBriefed = reviewersBriefed;\n this.scopeHashes = {};\n }\n}\n\n/**\n * Reads/writes the stage-② receipt.\n *\n * WHY a receipt rather than relying on the artifacts that already exist: `wp-finish-upsert-pr` already\n * refuses when a reviewer has no verdict and when summary.json is absent, so a repo WITH checklists is\n * mostly interlocked already. A repo with NO checklists is not — summary.json is the only thing standing\n * between it and a PR, and the AI writes summary.json itself. Nothing stopped it from writing that file and\n * going straight to finish, skipping the merge validation and the build entirely.\n *\n * The receipt also pays for itself in the other direction: because it records the sha the build passed on,\n * finish can SKIP its own build when HEAD has not moved, so adding a gate in the middle did not cost a\n * second full `nx affected` run.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewStageReceiptService {\n constructor(private readonly reviewJsonService: ReviewJsonService) {}\n\n receiptPath(repoRoot: string, featureName: string): string {\n return path.join(this.reviewJsonService.prDirFor(repoRoot, featureName), RECEIPT_FILE);\n }\n\n write(repoRoot: string, featureName: string, receipt: ReviewStageReceipt): string {\n const p = this.receiptPath(repoRoot, featureName);\n fs.mkdirSync(path.dirname(p), { recursive: true });\n fs.writeFileSync(p, JSON.stringify(receipt, null, 2) + '\\n');\n return p;\n }\n\n /** The receipt, or null when stage ② never ran (or left something unreadable behind). */\n read(repoRoot: string, featureName: string): ReviewStageReceipt | null {\n const p = this.receiptPath(repoRoot, featureName);\n if (!fs.existsSync(p)) return null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unreadable receipt is treated as absent, which re-runs stage ②\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(p, 'utf8')) as Record<string, unknown>;\n const receipt = new ReviewStageReceipt(\n typeof raw['headSha'] === 'string' ? (raw['headSha'] as string) : '',\n raw['mergeValidated'] === true,\n typeof raw['buildCommand'] === 'string' ? (raw['buildCommand'] as string) : '',\n typeof raw['buildPassedAt'] === 'string' ? (raw['buildPassedAt'] as string) : '',\n Array.isArray(raw['reviewersBriefed']) ? (raw['reviewersBriefed'] as string[]) : [],\n );\n receipt.scopeHashes = this.stringMap(raw['scopeHashes']);\n return receipt;\n } catch (err: unknown) {\n const error = toError(err);\n void error; // unreadable ⇒ treated as absent, which re-runs stage ② (the safe direction)\n return null;\n }\n }\n\n /** The receipt file's mtime in epoch ms, or 0 when there is none — when stage ② last briefed anyone. */\n writtenAtMs(repoRoot: string, featureName: string): number {\n const p = this.receiptPath(repoRoot, featureName);\n return fs.existsSync(p) ? fs.statSync(p).mtimeMs : 0;\n }\n\n // webpieces-disable no-any-unknown -- one opaque JSON value, narrowed to string→string\n private stringMap(value: unknown): Record<string, string> {\n const out: Record<string, string> = {};\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return out;\n // webpieces-disable no-any-unknown -- entries of an opaque JSON object, each narrowed below\n const obj = value as Record<string, unknown>;\n for (const key of Object.keys(obj)) {\n const v = obj[key];\n if (typeof v === 'string') out[key] = v;\n }\n return out;\n }\n}\n"]}
1
+ {"version":3,"file":"review-stage-receipt.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/review-stage-receipt.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,0DAAqE;AACrE,yCAA2D;AAE9C,QAAA,YAAY,GAAG,mBAAmB,CAAC;AAEhD;;GAEG;AACH,MAAa,kBAAkB;IAC3B,OAAO,CAAS,CAAU,gEAAgE;IAC1F,cAAc,CAAU,CAAE,oEAAoE;IAC9F,YAAY,CAAS;IACrB,aAAa,CAAS,CAAI,4DAA4D;IACtF,gBAAgB,CAAW;IAC3B;;;;OAIG;IACH,WAAW,CAAyB;IACpC,yFAAyF;IACzF,KAAK,CAAS;IACd,iGAAiG;IACjG,iBAAiB,CAAS;IAC1B,0FAA0F;IAC1F,mBAAmB,CAAS;IAE5B,yDAAyD;IACzD,YAAY,OAAO,GAAG,EAAE,EAAE,cAAc,GAAG,KAAK,EAAE,YAAY,GAAG,EAAE,EAAE,aAAa,GAAG,EAAE,EAAE,mBAA6B,EAAE;QACpH,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,cA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QAC5C,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAA;AA7DY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEW,gCAAiB;GADxD,yBAAyB,CA6DrC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { ReviewJsonService, toError } from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nexport const RECEIPT_FILE = 'review-stage.json';\n\n/**\n * Proof that stage ② (`wp-review-upsert-pr`) actually ran, and on WHICH commit. Data-only (per CLAUDE.md).\n */\nexport class ReviewStageReceipt {\n headSha: string; // the sha the merge was validated and the build was run against\n mergeValidated: boolean; // a 3-point merge was finalized here, or there was none to finalize\n buildCommand: string;\n buildPassedAt: string; // ISO; '' when the gate was skipped (mode OFF / no command)\n reviewersBriefed: string[];\n /**\n * checklist id → the hash of its in-scope diff at `headSha` (ChecklistScopeHasher). `wp-write-review`\n * stamps a verdict's provenance with the hash its reviewer was BRIEFED on, and the next stage ② carries\n * a green/yellow forward only while that hash is unchanged (issue #863). Assigned after construction.\n */\n scopeHashes: Record<string, string>;\n /** Global reviewer round, owned by stage ②. Zero means no reviewer round has started. */\n round: number;\n /** Repository-owned cap copied from config so verdict provenance can audit the active budget. */\n maxReviewerRounds: number;\n /** Prior reviewed HEAD for remediation-only rounds; empty for the initial full review. */\n remediationFromHead: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(headSha = '', mergeValidated = false, buildCommand = '', buildPassedAt = '', reviewersBriefed: string[] = []) {\n this.headSha = headSha;\n this.mergeValidated = mergeValidated;\n this.buildCommand = buildCommand;\n this.buildPassedAt = buildPassedAt;\n this.reviewersBriefed = reviewersBriefed;\n this.scopeHashes = {};\n this.round = 0;\n this.maxReviewerRounds = 0;\n this.remediationFromHead = '';\n }\n}\n\n/**\n * Reads/writes the stage-② receipt.\n *\n * WHY a receipt rather than relying on the artifacts that already exist: `wp-finish-upsert-pr` already\n * refuses when a reviewer has no verdict and when summary.json is absent, so a repo WITH checklists is\n * mostly interlocked already. A repo with NO checklists is not — summary.json is the only thing standing\n * between it and a PR, and the AI writes summary.json itself. Nothing stopped it from writing that file and\n * going straight to finish, skipping the merge validation and the build entirely.\n *\n * The receipt also pays for itself in the other direction: because it records the sha the build passed on,\n * finish can SKIP its own build when HEAD has not moved, so adding a gate in the middle did not cost a\n * second full `nx affected` run.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewStageReceiptService {\n constructor(private readonly reviewJsonService: ReviewJsonService) {}\n\n receiptPath(repoRoot: string, featureName: string): string {\n return path.join(this.reviewJsonService.prDirFor(repoRoot, featureName), RECEIPT_FILE);\n }\n\n write(repoRoot: string, featureName: string, receipt: ReviewStageReceipt): string {\n const p = this.receiptPath(repoRoot, featureName);\n fs.mkdirSync(path.dirname(p), { recursive: true });\n fs.writeFileSync(p, JSON.stringify(receipt, null, 2) + '\\n');\n return p;\n }\n\n /** The receipt, or null when stage ② never ran (or left something unreadable behind). */\n read(repoRoot: string, featureName: string): ReviewStageReceipt | null {\n const p = this.receiptPath(repoRoot, featureName);\n if (!fs.existsSync(p)) return null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unreadable receipt is treated as absent, which re-runs stage ②\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(p, 'utf8')) as Record<string, unknown>;\n const receipt = new ReviewStageReceipt(\n typeof raw['headSha'] === 'string' ? (raw['headSha'] as string) : '',\n raw['mergeValidated'] === true,\n typeof raw['buildCommand'] === 'string' ? (raw['buildCommand'] as string) : '',\n typeof raw['buildPassedAt'] === 'string' ? (raw['buildPassedAt'] as string) : '',\n Array.isArray(raw['reviewersBriefed']) ? (raw['reviewersBriefed'] as string[]) : [],\n );\n receipt.scopeHashes = this.stringMap(raw['scopeHashes']);\n receipt.round = typeof raw['round'] === 'number' && Number.isInteger(raw['round']) ? raw['round'] as number : 0;\n receipt.maxReviewerRounds = typeof raw['maxReviewerRounds'] === 'number' && Number.isInteger(raw['maxReviewerRounds'])\n ? raw['maxReviewerRounds'] as number : 0;\n receipt.remediationFromHead = typeof raw['remediationFromHead'] === 'string' ? raw['remediationFromHead'] as string : '';\n return receipt;\n } catch (err: unknown) {\n const error = toError(err);\n void error; // unreadable ⇒ treated as absent, which re-runs stage ② (the safe direction)\n return null;\n }\n }\n\n /** The receipt file's mtime in epoch ms, or 0 when there is none — when stage ② last briefed anyone. */\n writtenAtMs(repoRoot: string, featureName: string): number {\n const p = this.receiptPath(repoRoot, featureName);\n return fs.existsSync(p) ? fs.statSync(p).mtimeMs : 0;\n }\n\n // webpieces-disable no-any-unknown -- one opaque JSON value, narrowed to string→string\n private stringMap(value: unknown): Record<string, string> {\n const out: Record<string, string> = {};\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return out;\n // webpieces-disable no-any-unknown -- entries of an opaque JSON object, each narrowed below\n const obj = value as Record<string, unknown>;\n for (const key of Object.keys(obj)) {\n const v = obj[key];\n if (typeof v === 'string') out[key] = v;\n }\n return out;\n }\n}\n"]}
@@ -55,10 +55,10 @@ let ReviewerVerdictGate = class ReviewerVerdictGate {
55
55
  const refusals = refused.map((req) => this.retireAndReport(scan, req));
56
56
  throw new rules_config_1.InformAiError(this.headline(scan, refused, neverRan)
57
57
  + this.unreadableSection(scan)
58
- + this.refusedSection(refusals, scan.singleRoundReview)
58
+ + this.refusedSection(refusals)
59
59
  + this.discountedSection(scan, neverRan)
60
60
  + this.neverRanSection(scan, neverRan)
61
- + this.footer(refused.length > 0, scan.singleRoundReview));
61
+ + this.footer(refused.length > 0));
62
62
  }
63
63
  /**
64
64
  * Say plainly how many REFUSED and how many never ran.
@@ -107,14 +107,9 @@ let ReviewerVerdictGate = class ReviewerVerdictGate {
107
107
  * The refusals — SECOND, above anything that says to spawn a subagent, because a spawn instruction is the
108
108
  * one line an agent acts on first, and acting on it here IS the loop.
109
109
  */
110
- refusedSection(refusals, singleRoundReview) {
110
+ refusedSection(refusals) {
111
111
  if (refusals.length === 0)
112
112
  return '';
113
- if (singleRoundReview) {
114
- return '⛔ REFUSED — SINGLE-ROUND MODE. These reviewers ALREADY ANSWERED and MUST NOT be rerun.\n\n'
115
- + refusals.map((r) => ` • ${r}`).join('\n\n') + '\n\n'
116
- + ` main_agent_instructions: ${rules_config_1.SINGLE_ROUND_MAIN_AGENT_INSTRUCTIONS}\n\n`;
117
- }
118
113
  return '⛔ REFUSED — these reviewers ALREADY ANSWERED. Re-spawning one against unchanged code only buys\n'
119
114
  + ' the same answer: fix what it found (or get a HUMAN to authorize an override), THEN review again.\n\n'
120
115
  + refusals.map((r) => ` • ${r}`).join('\n\n') + '\n\n';
@@ -163,14 +158,6 @@ let ReviewerVerdictGate = class ReviewerVerdictGate {
163
158
  */
164
159
  retireAndReport(scan, req) {
165
160
  const verdict = this.reviewJsonService.resolveVerdict(req, scan.results);
166
- if (scan.singleRoundReview) {
167
- const live = this.reviewJsonService.checklistResultPath(scan.summaryPath, req.id);
168
- return `Checklist "${req.id}" FAILED review (status:"red"). The reviewer wrote:\n`
169
- + ` ${verdict.detail}\n`
170
- + ` DO NOT RERUN this reviewer. After fixing every finding, edit ${live}.\n`
171
- + ' Change its addressed red status to "yellow". Yellow is accepted by the gate. If you genuinely\n'
172
- + ' disagree, leave it red and flag the human BEFORE posting the PR; red remains blocking.';
173
- }
174
161
  return this.reviewJsonService.refusalError(req, verdict, scan.summaryPath, this.archiveOrWarn(scan.summaryPath, req.id));
175
162
  }
176
163
  // The archive path, or '' when there was nothing to move or the move failed (see retireAndReport).
@@ -190,15 +177,10 @@ let ReviewerVerdictGate = class ReviewerVerdictGate {
190
177
  // Re-running stage 2 is normally optional. It stops being optional after a refusal, because the only way
191
178
  // past one is to CHANGE the code — which is exactly the condition that makes the extracted diff and every
192
179
  // reviewer briefing stale.
193
- footer(anyRefused, singleRoundReview) {
180
+ footer(anyRefused) {
194
181
  if (anyRefused) {
195
- if (singleRoundReview) {
196
- return 'Do NOT run pnpm wp-review-upsert-pr and do NOT re-run a reviewer. Fix the findings, change\n'
197
- + 'addressed red verdicts to yellow, then run: pnpm wp-finish-upsert-pr\n'
198
- + 'If any red remains because you disagree, STOP and ask the human before posting the PR.';
199
- }
200
- return 'Then re-run: pnpm wp-review-upsert-pr (the code changed, so the extracted diff and the reviewer\n'
201
- + 'briefings are stale), re-run the reviewer(s) above, and finally: pnpm wp-finish-upsert-pr';
182
+ return 'Fix every finding, commit the remediation, record it with pnpm wp-write-review-fixes, then re-run:\n'
183
+ + 'pnpm wp-review-upsert-pr. The repository round budget decides whether a focused re-review remains.';
202
184
  }
203
185
  return 'Then re-run: pnpm wp-finish-upsert-pr\n'
204
186
  + '(Each reviewer\'s generated instructions file is already written — re-running pnpm wp-review-upsert-pr\n'
@@ -1 +1 @@
1
- {"version":3,"file":"reviewer-verdict-gate.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/reviewer-verdict-gate.ts"],"names":[],"mappings":";;;;AAAA,0DAGiC;AACjC,yCAA2D;AAE3D,6DAA0F;AAE1F;;;;;;;;;;;;;;;;;;;;GAoBG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAEP;IACA;IAFrB,YACqB,iBAAoC,EACpC,YAA0C;QAD1C,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,iBAAY,GAAZ,YAAY,CAA8B;IAC5D,CAAC;IAEJ;;;;;;;OAOG;IACH,sBAAsB,CAAC,IAAmB;QACtC,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAC1C,qGAAqG;QACrG,kGAAkG;QAClG,gGAAgG;QAChG,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,IAAI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ChG,oBAAoB,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;YAC7C,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;IAED,yGAAyG;IACzG,0GAA0G;IAC1G,2BAA2B;IACnB,MAAM,CAAC,UAAmB,EAAE,iBAA0B;QAC1D,IAAI,UAAU,EAAE,CAAC;YACb,IAAI,iBAAiB,EAAE,CAAC;gBACpB,OAAO,8FAA8F;sBAC/F,wEAAwE;sBACxE,wFAAwF,CAAC;YACnG,CAAC;YACD,OAAO,mGAAmG;kBACpG,2FAA2F,CAAC;QACtG,CAAC;QACD,OAAO,yCAAyC;cAC1C,0GAA0G;cAC1G,oDAAoD,CAAC;IAC/D,CAAC;CACJ,CAAA;AAvLY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGG,gCAAiB;QACtB,2CAA4B;GAHtD,mBAAmB,CAuL/B","sourcesContent":["import {\n ChecklistInstructionsService, InformAiError, RequiredChecklist, ReviewJsonService,\n SINGLE_ROUND_MAIN_AGENT_INSTRUCTIONS, toError,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ChecklistScan } from './checklist-scanner';\nimport { STANDING_REJECTED, STANDING_STALE, VerdictStanding } from './verdict-provenance';\n\n/**\n * The gate `wp-finish-upsert-pr` runs before it parses summary.json: REFUSE the PR while any applicable\n * checklist is not clear, and say — per checklist — which of three different things went wrong.\n *\n * It is its own class, not a private method on the command, for two reasons. It is the one piece of finish\n * that both MUTATES the branch (it retires red verdicts) and produces the text an AI acts on, so it is the\n * piece most worth asserting on directly; and the command it came out of is already the largest file in this\n * package, against a hard `@webpieces/max-file-lines` limit.\n *\n * THE BUG THIS EXISTS TO FIX. The message used to be one bucket and one imperative — \"You MUST run these N\n * reviewer subagent(s)\" — for three unrelated states. Handed to an agent, the literal, obedient response for\n * a checklist that had ALREADY REFUSED was to spawn the reviewer again; it re-read the same unchanged code,\n * refused again, and the loop cost a full subagent run per pass while the reviewer's actual finding was\n * never printed at all. Three states, three actions, in this order:\n *\n * 1. UNREADABLE (`scan.formatErrors`) -> fix four characters of JSON. Not a reviewer problem.\n * 2. REFUSED (CK_FAIL) -> fix the finding (or get a HUMAN override). Not a missing step.\n * 3. NEVER RAN (the rest) -> spawn the subagent. The ONLY case where that is the right move.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewerVerdictGate {\n constructor(\n private readonly reviewJsonService: ReviewJsonService,\n private readonly instructions: ChecklistInstructionsService,\n ) {}\n\n /**\n * Refuse the PR while ANY applicable checklist still owes a passing verdict — naming exactly what each\n * one needs. No-op for a repo with no applicable checklists.\n *\n * SIDE EFFECT, deliberately: every REFUSED checklist's verdict file is RETIRED to review-<id>.json.old on\n * the way out (see {@link retireAndReport}). Only red verdicts are ever moved — a green, yellow or\n * overridden one is reused across finish attempts and retiring it would force a needless subagent re-run.\n */\n assertEveryReviewerRan(scan: ChecklistScan): void {\n if (scan.outstanding.length === 0) return;\n // The split is computed from the verdicts the SCAN already loaded, never from a second read of disk:\n // a re-read here could disagree with the set that produced `outstanding`, and a checklist that is\n // \"outstanding\" per one read and \"clear\" per another belongs to neither section of the message.\n const refused = this.reviewJsonService.refusedChecklists(scan.outstanding, scan.results);\n const refusedIds = new Set(refused.map((r: RequiredChecklist): string => r.id));\n const neverRan = scan.outstanding.filter((r: RequiredChecklist): boolean => !refusedIds.has(r.id));\n // Rendered BEFORE the throw and, per checklist, with the verdict resolved before its file is moved —\n // the message quotes the reviewer's own words, so losing them to the move would defeat the point.\n const refusals = refused.map((req: RequiredChecklist): string => this.retireAndReport(scan, req));\n throw new InformAiError(\n this.headline(scan, refused, neverRan)\n + this.unreadableSection(scan)\n + this.refusedSection(refusals, scan.singleRoundReview)\n + this.discountedSection(scan, neverRan)\n + this.neverRanSection(scan, neverRan)\n + this.footer(refused.length > 0, scan.singleRoundReview),\n );\n }\n\n /**\n * Say plainly how many REFUSED and how many never ran.\n *\n * The old headline said all of them \"have no passing verdict yet\", which is technically true of a refusal\n * and reads as though nobody had looked. It is the sentence that framed a decision as an omission.\n */\n private headline(scan: ChecklistScan, refused: readonly RequiredChecklist[], neverRan: readonly RequiredChecklist[]): string {\n const lines = [\n `⛔ NO PR — ${scan.outstanding.length} of ${scan.applicable.length} review checklist(s) that apply to this branch are not clear:`,\n ];\n if (refused.length > 0) {\n lines.push(` • ${refused.length} REFUSED — a reviewer ran, judged this change, and said no: ${this.instructions.names(refused)}`);\n }\n if (neverRan.length > 0) {\n lines.push(` • ${neverRan.length} never ran — no verdict has been written yet: ${this.instructions.names(neverRan)}`);\n }\n return lines.join('\\n') + this.skippedNote(scan) + '\\n\\n';\n }\n\n /**\n * The optional checklists nobody ran, stated OUT LOUD on the refusal.\n *\n * They are not why the PR is being refused and this block says so — but a message that lists only what\n * blocked reads as \"everything else was reviewed\", and here that is false: those reviews were declined,\n * not passed. The one moment a human is looking at the review state is the moment to be honest about\n * which reviews did not happen, and it is also the prompt an AI needs to offer them again if the human\n * has changed their mind now that something else came back red.\n */\n private skippedNote(scan: ChecklistScan): string {\n if (scan.optionalNotRun.length === 0) return '';\n return `\\n (Not blocking: ${scan.optionalNotRun.length} OPTIONAL checklist(s) were not run — `\n + `${this.instructions.names(scan.optionalNotRun)}. They do not have to run; re-run\\n`\n + ' pnpm wp-review-upsert-pr if you now want to offer them.)';\n }\n\n // Unreadable verdict files come FIRST. A reviewer that wrote its verdict in the removed `success` format\n // is otherwise indistinguishable from one that never ran, and the AI would go re-run a subagent instead\n // of correcting four characters of JSON.\n private unreadableSection(scan: ChecklistScan): string {\n if (scan.formatErrors.length === 0) return '';\n return `${scan.formatErrors.length} verdict file(s) are in an UNREADABLE format:\\n\\n`\n + scan.formatErrors.map((e: string): string => ` • ${e}`).join('\\n') + '\\n\\n';\n }\n\n /**\n * The refusals — SECOND, above anything that says to spawn a subagent, because a spawn instruction is the\n * one line an agent acts on first, and acting on it here IS the loop.\n */\n private refusedSection(refusals: readonly string[], singleRoundReview: boolean): string {\n if (refusals.length === 0) return '';\n if (singleRoundReview) {\n return '⛔ REFUSED — SINGLE-ROUND MODE. These reviewers ALREADY ANSWERED and MUST NOT be rerun.\\n\\n'\n + refusals.map((r: string): string => ` • ${r}`).join('\\n\\n') + '\\n\\n'\n + ` main_agent_instructions: ${SINGLE_ROUND_MAIN_AGENT_INSTRUCTIONS}\\n\\n`;\n }\n return '⛔ REFUSED — these reviewers ALREADY ANSWERED. Re-spawning one against unchanged code only buys\\n'\n + ' the same answer: fix what it found (or get a HUMAN to authorize an override), THEN review again.\\n\\n'\n + refusals.map((r: string): string => ` • ${r}`).join('\\n\\n') + '\\n\\n';\n }\n\n /**\n * Verdict files that EXIST but do not count (issue #863), each with why — printed before the spawn\n * list so the reader does not mistake them for reviewers that never ran, and so a hand-written verdict\n * is named as what it is. REJECTED: no `wp-write-review` provenance, or edited after submission — a\n * coordinator writing a reviewer's verdict lands here, and that is the forgery this gate exists to\n * refuse. STALE: the checklist's in-scope files changed since it was submitted.\n */\n private discountedSection(scan: ChecklistScan, neverRan: readonly RequiredChecklist[]): string {\n const owed = new Set(neverRan.map((r: RequiredChecklist): string => r.id));\n const discounted = scan.standings.filter((s: VerdictStanding): boolean => owed.has(s.checklistId)\n && (s.standing === STANDING_REJECTED || s.standing === STANDING_STALE));\n if (discounted.length === 0) return '';\n return '🚫 NOT COUNTED — these verdict files exist, but they are not a current review:\\n\\n'\n + discounted.map((s: VerdictStanding): string => ` • ${s.checklistId} — ${s.standing.toUpperCase()}: ${s.reason}`).join('\\n')\n + '\\n A reviewer SUBAGENT must submit a fresh verdict with pnpm wp-write-review. Do NOT write or copy the\\n'\n + ' file yourself: the bin refuses the coordinating agent, and this gate rejects a verdict it did not write.\\n\\n';\n }\n\n /**\n * The reviewers that genuinely never ran — LAST, and listing ONLY these. When there are none this block\n * is absent entirely, which is the whole point: the \"You MUST run these N reviewer subagent(s)\"\n * imperative must not appear at all on a run whose only problem is a refusal.\n */\n private neverRanSection(scan: ChecklistScan, neverRan: readonly RequiredChecklist[]): string {\n if (neverRan.length === 0) return '';\n return '❓ NO VERDICT YET — nothing that counts has been submitted for these, so they must actually be run:\\n\\n'\n + `${this.instructions.render(neverRan, scan.summaryPath, scan.context)}\\n\\n`;\n }\n\n /**\n * Retire ONE refused checklist's verdict and render the refusal that reports it.\n *\n * ORDER IS LOAD-BEARING. The verdict is resolved from the already-loaded results, so the finding is in\n * hand before the file moves; the move then happens; and only then is the message rendered, because it\n * names the archive path and must not claim a move that did not happen.\n *\n * The move is NON-FATAL. A finish that died after retiring a verdict would leave the AI with a red\n * verdict gone from the live path and no message saying where it went or why the PR was refused — a\n * silent gap, and the worst possible outcome for a feature whose entire purpose is a durable record. So a\n * failed move warns and the refusal is reported without an archive path (the file is then still live,\n * which the un-archived wording of `refusalError` describes correctly).\n */\n private retireAndReport(scan: ChecklistScan, req: RequiredChecklist): string {\n const verdict = this.reviewJsonService.resolveVerdict(req, scan.results);\n if (scan.singleRoundReview) {\n const live = this.reviewJsonService.checklistResultPath(scan.summaryPath, req.id);\n return `Checklist \"${req.id}\" FAILED review (status:\"red\"). The reviewer wrote:\\n`\n + ` ${verdict.detail}\\n`\n + ` DO NOT RERUN this reviewer. After fixing every finding, edit ${live}.\\n`\n + ' Change its addressed red status to \"yellow\". Yellow is accepted by the gate. If you genuinely\\n'\n + ' disagree, leave it red and flag the human BEFORE posting the PR; red remains blocking.';\n }\n return this.reviewJsonService.refusalError(\n req, verdict, scan.summaryPath, this.archiveOrWarn(scan.summaryPath, req.id));\n }\n\n // The archive path, or '' when there was nothing to move or the move failed (see retireAndReport).\n private archiveOrWarn(summaryPath: string, checklistId: string): string {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: a failed archive must never swallow the refusal it belongs to\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n return this.reviewJsonService.archiveChecklistResult(summaryPath, checklistId);\n } catch (err: unknown) {\n const error = toError(err);\n process.stderr.write(\n `⚠️ Could not retire the refused verdict for \"${checklistId}\" (non-fatal — the refusal is still `\n + `reported below): ${error.message}\\n`);\n return '';\n }\n }\n\n // Re-running stage 2 is normally optional. It stops being optional after a refusal, because the only way\n // past one is to CHANGE the code — which is exactly the condition that makes the extracted diff and every\n // reviewer briefing stale.\n private footer(anyRefused: boolean, singleRoundReview: boolean): string {\n if (anyRefused) {\n if (singleRoundReview) {\n return 'Do NOT run pnpm wp-review-upsert-pr and do NOT re-run a reviewer. Fix the findings, change\\n'\n + 'addressed red verdicts to yellow, then run: pnpm wp-finish-upsert-pr\\n'\n + 'If any red remains because you disagree, STOP and ask the human before posting the PR.';\n }\n return 'Then re-run: pnpm wp-review-upsert-pr (the code changed, so the extracted diff and the reviewer\\n'\n + 'briefings are stale), re-run the reviewer(s) above, and finally: pnpm wp-finish-upsert-pr';\n }\n return 'Then re-run: pnpm wp-finish-upsert-pr\\n'\n + '(Each reviewer\\'s generated instructions file is already written — re-running pnpm wp-review-upsert-pr\\n'\n + ' is only needed if the code changed since it ran.)';\n }\n}\n"]}
1
+ {"version":3,"file":"reviewer-verdict-gate.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/reviewer-verdict-gate.ts"],"names":[],"mappings":";;;;AAAA,0DAGiC;AACjC,yCAA2D;AAE3D,6DAA0F;AAE1F;;;;;;;;;;;;;;;;;;;;GAoBG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAEP;IACA;IAFrB,YACqB,iBAAoC,EACpC,YAA0C;QAD1C,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,iBAAY,GAAZ,YAAY,CAA8B;IAC5D,CAAC;IAEJ;;;;;;;OAOG;IACH,sBAAsB,CAAC,IAAmB;QACtC,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAC1C,qGAAqG;QACrG,kGAAkG;QAClG,gGA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ules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ChecklistScan } from './checklist-scanner';\nimport { STANDING_REJECTED, STANDING_STALE, VerdictStanding } from './verdict-provenance';\n\n/**\n * The gate `wp-finish-upsert-pr` runs before it parses summary.json: REFUSE the PR while any applicable\n * checklist is not clear, and say — per checklist — which of three different things went wrong.\n *\n * It is its own class, not a private method on the command, for two reasons. It is the one piece of finish\n * that both MUTATES the branch (it retires red verdicts) and produces the text an AI acts on, so it is the\n * piece most worth asserting on directly; and the command it came out of is already the largest file in this\n * package, against a hard `@webpieces/max-file-lines` limit.\n *\n * THE BUG THIS EXISTS TO FIX. The message used to be one bucket and one imperative — \"You MUST run these N\n * reviewer subagent(s)\" — for three unrelated states. Handed to an agent, the literal, obedient response for\n * a checklist that had ALREADY REFUSED was to spawn the reviewer again; it re-read the same unchanged code,\n * refused again, and the loop cost a full subagent run per pass while the reviewer's actual finding was\n * never printed at all. Three states, three actions, in this order:\n *\n * 1. UNREADABLE (`scan.formatErrors`) -> fix four characters of JSON. Not a reviewer problem.\n * 2. REFUSED (CK_FAIL) -> fix the finding (or get a HUMAN override). Not a missing step.\n * 3. NEVER RAN (the rest) -> spawn the subagent. The ONLY case where that is the right move.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewerVerdictGate {\n constructor(\n private readonly reviewJsonService: ReviewJsonService,\n private readonly instructions: ChecklistInstructionsService,\n ) {}\n\n /**\n * Refuse the PR while ANY applicable checklist still owes a passing verdict — naming exactly what each\n * one needs. No-op for a repo with no applicable checklists.\n *\n * SIDE EFFECT, deliberately: every REFUSED checklist's verdict file is RETIRED to review-<id>.json.old on\n * the way out (see {@link retireAndReport}). Only red verdicts are ever moved — a green, yellow or\n * overridden one is reused across finish attempts and retiring it would force a needless subagent re-run.\n */\n assertEveryReviewerRan(scan: ChecklistScan): void {\n if (scan.outstanding.length === 0) return;\n // The split is computed from the verdicts the SCAN already loaded, never from a second read of disk:\n // a re-read here could disagree with the set that produced `outstanding`, and a checklist that is\n // \"outstanding\" per one read and \"clear\" per another belongs to neither section of the message.\n const refused = this.reviewJsonService.refusedChecklists(scan.outstanding, scan.results);\n const refusedIds = new Set(refused.map((r: RequiredChecklist): string => r.id));\n const neverRan = scan.outstanding.filter((r: RequiredChecklist): boolean => !refusedIds.has(r.id));\n // Rendered BEFORE the throw and, per checklist, with the verdict resolved before its file is moved —\n // the message quotes the reviewer's own words, so losing them to the move would defeat the point.\n const refusals = refused.map((req: RequiredChecklist): string => this.retireAndReport(scan, req));\n throw new InformAiError(\n this.headline(scan, refused, neverRan)\n + this.unreadableSection(scan)\n + this.refusedSection(refusals)\n + this.discountedSection(scan, neverRan)\n + this.neverRanSection(scan, neverRan)\n + this.footer(refused.length > 0),\n );\n }\n\n /**\n * Say plainly how many REFUSED and how many never ran.\n *\n * The old headline said all of them \"have no passing verdict yet\", which is technically true of a refusal\n * and reads as though nobody had looked. It is the sentence that framed a decision as an omission.\n */\n private headline(scan: ChecklistScan, refused: readonly RequiredChecklist[], neverRan: readonly RequiredChecklist[]): string {\n const lines = [\n `⛔ NO PR — ${scan.outstanding.length} of ${scan.applicable.length} review checklist(s) that apply to this branch are not clear:`,\n ];\n if (refused.length > 0) {\n lines.push(` • ${refused.length} REFUSED — a reviewer ran, judged this change, and said no: ${this.instructions.names(refused)}`);\n }\n if (neverRan.length > 0) {\n lines.push(` • ${neverRan.length} never ran — no verdict has been written yet: ${this.instructions.names(neverRan)}`);\n }\n return lines.join('\\n') + this.skippedNote(scan) + '\\n\\n';\n }\n\n /**\n * The optional checklists nobody ran, stated OUT LOUD on the refusal.\n *\n * They are not why the PR is being refused and this block says so — but a message that lists only what\n * blocked reads as \"everything else was reviewed\", and here that is false: those reviews were declined,\n * not passed. The one moment a human is looking at the review state is the moment to be honest about\n * which reviews did not happen, and it is also the prompt an AI needs to offer them again if the human\n * has changed their mind now that something else came back red.\n */\n private skippedNote(scan: ChecklistScan): string {\n if (scan.optionalNotRun.length === 0) return '';\n return `\\n (Not blocking: ${scan.optionalNotRun.length} OPTIONAL checklist(s) were not run — `\n + `${this.instructions.names(scan.optionalNotRun)}. They do not have to run; re-run\\n`\n + ' pnpm wp-review-upsert-pr if you now want to offer them.)';\n }\n\n // Unreadable verdict files come FIRST. A reviewer that wrote its verdict in the removed `success` format\n // is otherwise indistinguishable from one that never ran, and the AI would go re-run a subagent instead\n // of correcting four characters of JSON.\n private unreadableSection(scan: ChecklistScan): string {\n if (scan.formatErrors.length === 0) return '';\n return `${scan.formatErrors.length} verdict file(s) are in an UNREADABLE format:\\n\\n`\n + scan.formatErrors.map((e: string): string => ` • ${e}`).join('\\n') + '\\n\\n';\n }\n\n /**\n * The refusals — SECOND, above anything that says to spawn a subagent, because a spawn instruction is the\n * one line an agent acts on first, and acting on it here IS the loop.\n */\n private refusedSection(refusals: readonly string[]): string {\n if (refusals.length === 0) return '';\n return '⛔ REFUSED — these reviewers ALREADY ANSWERED. Re-spawning one against unchanged code only buys\\n'\n + ' the same answer: fix what it found (or get a HUMAN to authorize an override), THEN review again.\\n\\n'\n + refusals.map((r: string): string => ` • ${r}`).join('\\n\\n') + '\\n\\n';\n }\n\n /**\n * Verdict files that EXIST but do not count (issue #863), each with why — printed before the spawn\n * list so the reader does not mistake them for reviewers that never ran, and so a hand-written verdict\n * is named as what it is. REJECTED: no `wp-write-review` provenance, or edited after submission — a\n * coordinator writing a reviewer's verdict lands here, and that is the forgery this gate exists to\n * refuse. STALE: the checklist's in-scope files changed since it was submitted.\n */\n private discountedSection(scan: ChecklistScan, neverRan: readonly RequiredChecklist[]): string {\n const owed = new Set(neverRan.map((r: RequiredChecklist): string => r.id));\n const discounted = scan.standings.filter((s: VerdictStanding): boolean => owed.has(s.checklistId)\n && (s.standing === STANDING_REJECTED || s.standing === STANDING_STALE));\n if (discounted.length === 0) return '';\n return '🚫 NOT COUNTED — these verdict files exist, but they are not a current review:\\n\\n'\n + discounted.map((s: VerdictStanding): string => ` • ${s.checklistId} — ${s.standing.toUpperCase()}: ${s.reason}`).join('\\n')\n + '\\n A reviewer SUBAGENT must submit a fresh verdict with pnpm wp-write-review. Do NOT write or copy the\\n'\n + ' file yourself: the bin refuses the coordinating agent, and this gate rejects a verdict it did not write.\\n\\n';\n }\n\n /**\n * The reviewers that genuinely never ran — LAST, and listing ONLY these. When there are none this block\n * is absent entirely, which is the whole point: the \"You MUST run these N reviewer subagent(s)\"\n * imperative must not appear at all on a run whose only problem is a refusal.\n */\n private neverRanSection(scan: ChecklistScan, neverRan: readonly RequiredChecklist[]): string {\n if (neverRan.length === 0) return '';\n return '❓ NO VERDICT YET — nothing that counts has been submitted for these, so they must actually be run:\\n\\n'\n + `${this.instructions.render(neverRan, scan.summaryPath, scan.context)}\\n\\n`;\n }\n\n /**\n * Retire ONE refused checklist's verdict and render the refusal that reports it.\n *\n * ORDER IS LOAD-BEARING. The verdict is resolved from the already-loaded results, so the finding is in\n * hand before the file moves; the move then happens; and only then is the message rendered, because it\n * names the archive path and must not claim a move that did not happen.\n *\n * The move is NON-FATAL. A finish that died after retiring a verdict would leave the AI with a red\n * verdict gone from the live path and no message saying where it went or why the PR was refused — a\n * silent gap, and the worst possible outcome for a feature whose entire purpose is a durable record. So a\n * failed move warns and the refusal is reported without an archive path (the file is then still live,\n * which the un-archived wording of `refusalError` describes correctly).\n */\n private retireAndReport(scan: ChecklistScan, req: RequiredChecklist): string {\n const verdict = this.reviewJsonService.resolveVerdict(req, scan.results);\n return this.reviewJsonService.refusalError(\n req, verdict, scan.summaryPath, this.archiveOrWarn(scan.summaryPath, req.id));\n }\n\n // The archive path, or '' when there was nothing to move or the move failed (see retireAndReport).\n private archiveOrWarn(summaryPath: string, checklistId: string): string {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: a failed archive must never swallow the refusal it belongs to\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n return this.reviewJsonService.archiveChecklistResult(summaryPath, checklistId);\n } catch (err: unknown) {\n const error = toError(err);\n process.stderr.write(\n `⚠️ Could not retire the refused verdict for \"${checklistId}\" (non-fatal — the refusal is still `\n + `reported below): ${error.message}\\n`);\n return '';\n }\n }\n\n // Re-running stage 2 is normally optional. It stops being optional after a refusal, because the only way\n // past one is to CHANGE the code — which is exactly the condition that makes the extracted diff and every\n // reviewer briefing stale.\n private footer(anyRefused: boolean): string {\n if (anyRefused) {\n return 'Fix every finding, commit the remediation, record it with pnpm wp-write-review-fixes, then re-run:\\n'\n + 'pnpm wp-review-upsert-pr. The repository round budget decides whether a focused re-review remains.';\n }\n return 'Then re-run: pnpm wp-finish-upsert-pr\\n'\n + '(Each reviewer\\'s generated instructions file is already written — re-running pnpm wp-review-upsert-pr\\n'\n + ' is only needed if the code changed since it ran.)';\n }\n}\n"]}
@@ -27,6 +27,7 @@ export declare class VerdictProvenance {
27
27
  status: string;
28
28
  verdictHash: string;
29
29
  writtenAt: string;
30
+ round: number;
30
31
  constructor(checklistId: string, harness: string, sessionId: string, agentId: string, agentType: string, headSha: string, scopeHash: string);
31
32
  }
32
33
  /** A live verdict that stands: submitted through the bin and judged the in-scope diff as it is NOW. */
@@ -75,16 +76,10 @@ export declare class VerdictProvenanceService {
75
76
  read(summaryPath: string, checklistId: string): VerdictProvenance | null;
76
77
  /**
77
78
  * How one parsed verdict stands. `currentScopeHash` is this checklist's scope hash NOW ('' when it
78
- * could not be computed, which never marks anything stale). `singleRound` is the machine's
79
- * `singleRoundReview` opt-in, and it changes two things — both so that this check does not narrow what
80
- * that experimental flag already promises:
81
- * - scope never goes STALE: one round means one round, and its verdicts are the review record;
82
- * - the one edit that mode tells the COORDINATOR to make — an addressed red changed to yellow in
83
- * place — is accepted, and nothing else is.
79
+ * could not be computed, which never marks anything stale).
84
80
  */
85
- assess(summaryPath: string, result: ChecklistResult, currentScopeHash: string, singleRound: boolean): VerdictStanding;
81
+ assess(summaryPath: string, result: ChecklistResult, currentScopeHash: string): VerdictStanding;
86
82
  /** The first 8 characters of a sha, the way every banner line prints one. */
87
83
  short(sha: string): string;
88
- private matchesSubmission;
89
84
  private str;
90
85
  }
@@ -49,6 +49,7 @@ class VerdictProvenance {
49
49
  status; // the status as submitted
50
50
  verdictHash; // VerdictProvenanceService.canonicalHash of the verdict as submitted
51
51
  writtenAt;
52
+ round;
52
53
  // eslint-disable-next-line @typescript-eslint/max-params
53
54
  constructor(checklistId, harness, sessionId, agentId, agentType, headSha, scopeHash) {
54
55
  this.writer = rules_config_1.WRITE_REVIEW_BIN;
@@ -62,6 +63,7 @@ class VerdictProvenance {
62
63
  this.status = '';
63
64
  this.verdictHash = '';
64
65
  this.writtenAt = '';
66
+ this.round = 0;
65
67
  }
66
68
  }
67
69
  exports.VerdictProvenance = VerdictProvenance;
@@ -146,6 +148,7 @@ let VerdictProvenanceService = class VerdictProvenanceService {
146
148
  record.status = this.str(raw['status']);
147
149
  record.verdictHash = this.str(raw['verdictHash']);
148
150
  record.writtenAt = this.str(raw['writtenAt']);
151
+ record.round = typeof raw['round'] === 'number' && Number.isInteger(raw['round']) ? raw['round'] : 0;
149
152
  return record;
150
153
  }
151
154
  catch (err) {
@@ -156,15 +159,10 @@ let VerdictProvenanceService = class VerdictProvenanceService {
156
159
  }
157
160
  /**
158
161
  * 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.
162
+ * could not be computed, which never marks anything stale).
165
163
  */
166
164
  // eslint-disable-next-line @typescript-eslint/max-params
167
- assess(summaryPath, result, currentScopeHash, singleRound) {
165
+ assess(summaryPath, result, currentScopeHash) {
168
166
  const id = result.id;
169
167
  const record = this.read(summaryPath, id);
170
168
  const reject = (reason) => new VerdictStanding(id, exports.STANDING_REJECTED, result.status, '', reason);
@@ -180,10 +178,10 @@ let VerdictProvenanceService = class VerdictProvenanceService {
180
178
  return reject(`review-${id}.json was submitted by the coordinating agent, not a reviewer subagent`);
181
179
  }
182
180
  const submitted = new SubmittedVerdict(id, result.status, result.agent, result.model, result.output);
183
- if (!this.matchesSubmission(submitted, record, singleRound)) {
181
+ if (this.canonicalHash(submitted) !== record.verdictHash) {
184
182
  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
183
  }
186
- if (!singleRound && currentScopeHash !== '' && record.scopeHash !== currentScopeHash) {
184
+ if (currentScopeHash !== '' && record.scopeHash !== currentScopeHash) {
187
185
  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
186
  }
189
187
  return new VerdictStanding(id, exports.STANDING_CURRENT, result.status, record.headSha, `in-scope files unchanged since ${this.short(record.headSha)}`);
@@ -192,14 +190,6 @@ let VerdictProvenanceService = class VerdictProvenanceService {
192
190
  short(sha) {
193
191
  return sha === '' ? '(unknown sha)' : sha.slice(0, 8);
194
192
  }
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
193
  // webpieces-disable no-any-unknown -- one opaque JSON value, narrowed to a string
204
194
  str(value) {
205
195
  return typeof value === 'string' ? value : '';
@@ -1 +1 @@
1
- {"version":3,"file":"verdict-provenance.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/verdict-provenance.ts"],"names":[],"mappings":";;;;AA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I,CAAC,WAAW,IAAI,MAAM,CAAC,MAAM,KAAK,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(summaryPath: string, checklistId: string): string {\n return path.join(path.dirname(summaryPath), `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(summaryPath: string, verdict: SubmittedVerdict, provenance: VerdictProvenance): string {\n const verdictPath = this.reviewJsonService.checklistResultPath(summaryPath, 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(summaryPath, 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(summaryPath: string, checklistId: string): VerdictProvenance | null {\n const file = this.provenancePath(summaryPath, 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(summaryPath: string, result: ChecklistResult, currentScopeHash: string, singleRound: boolean): VerdictStanding {\n const id = result.id;\n const record = this.read(summaryPath, id);\n const reject = (reason: string): VerdictStanding => new VerdictStanding(id, STANDING_REJECTED, result.status, '', reason);\n if (record === null) {\n const file = this.provenancePath(summaryPath, 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"]}
1
+ {"version":3,"file":"verdict-provenance.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/verdict-provenance.ts"],"names":[],"mapp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,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1D,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;AAjGY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGG,gCAAiB;QACxB,yBAAU;GAHlC,wBAAwB,CAiGpC","sourcesContent":["import * as crypto from 'crypto';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport {\n AtomicFile, ChecklistResult, ReviewJsonService, 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 round: number;\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 this.round = 0;\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(summaryPath: string, checklistId: string): string {\n return path.join(path.dirname(summaryPath), `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(summaryPath: string, verdict: SubmittedVerdict, provenance: VerdictProvenance): string {\n const verdictPath = this.reviewJsonService.checklistResultPath(summaryPath, 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(summaryPath, 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(summaryPath: string, checklistId: string): VerdictProvenance | null {\n const file = this.provenancePath(summaryPath, 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 record.round = typeof raw['round'] === 'number' && Number.isInteger(raw['round']) ? raw['round'] as number : 0;\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).\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n assess(summaryPath: string, result: ChecklistResult, currentScopeHash: string): VerdictStanding {\n const id = result.id;\n const record = this.read(summaryPath, id);\n const reject = (reason: string): VerdictStanding => new VerdictStanding(id, STANDING_REJECTED, result.status, '', reason);\n if (record === null) {\n const file = this.provenancePath(summaryPath, 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.canonicalHash(submitted) !== record.verdictHash) {\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 (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 // 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,2 @@
1
+ #!/usr/bin/env node
2
+ import 'reflect-metadata';
@@ -0,0 +1,16 @@
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_fixes_command_1 = require("./commands/write-review-fixes-command");
9
+ const FILE = '--file';
10
+ (0, rules_config_1.runMain)(async () => {
11
+ const container = new inversify_1.Container({ autobind: true });
12
+ const args = container.get(rules_config_1.CliArgs).parse(new rules_config_1.CliUsage('wp-write-review-fixes', 'Record the coordinating agent response to every red finding in the completed reviewer round.', [new rules_config_1.CliFlag(FILE, 'JSON file. Omit to pass JSON on stdin.', true)]));
13
+ const json = container.get(write_review_fixes_command_1.WriteReviewFixesInput).read(args.value(FILE));
14
+ await container.get(pr_gate_app_1.PrGateApp).writeReviewFixes(new write_review_fixes_command_1.WriteReviewFixesOptions(json, process.cwd()));
15
+ });
16
+ //# sourceMappingURL=wp-write-review-fixes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wp-write-review-fixes.js","sourceRoot":"","sources":["../../../../../../packages/tooling/pr-gate/src/scripts/wp-write-review-fixes.ts"],"names":[],"mappings":";;;AACA,4BAA0B;AAC1B,yCAAsC;AACtC,0DAA8E;AAC9E,+CAA0C;AAC1C,sFAAuG;AAEvG,MAAM,IAAI,GAAG,QAAQ,CAAC;AAEtB,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,uBAAuB,EACvB,8FAA8F,EAC9F,CAAC,IAAI,sBAAO,CAAC,IAAI,EAAE,wCAAwC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,kDAAqB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACzE,MAAM,SAAS,CAAC,GAAG,CAAC,uBAAS,CAAC,CAAC,gBAAgB,CAAC,IAAI,oDAAuB,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AACtG,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport 'reflect-metadata';\nimport { Container } from 'inversify';\nimport { CliArgs, CliFlag, CliUsage, runMain } from '@webpieces/rules-config';\nimport { PrGateApp } from './pr-gate-app';\nimport { WriteReviewFixesInput, WriteReviewFixesOptions } from './commands/write-review-fixes-command';\n\nconst FILE = '--file';\n\nrunMain(async (): Promise<void> => {\n const container = new Container({ autobind: true });\n const args = container.get(CliArgs).parse(new CliUsage(\n 'wp-write-review-fixes',\n 'Record the coordinating agent response to every red finding in the completed reviewer round.',\n [new CliFlag(FILE, 'JSON file. Omit to pass JSON on stdin.', true)]));\n const json = container.get(WriteReviewFixesInput).read(args.value(FILE));\n await container.get(PrGateApp).writeReviewFixes(new WriteReviewFixesOptions(json, process.cwd()));\n});\n"]}