@webpieces/pr-gate 0.4.826 → 0.4.828

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 (49) hide show
  1. package/package.json +3 -3
  2. package/src/dashboard/checklist-comment-renderer.js +8 -6
  3. package/src/dashboard/checklist-comment-renderer.js.map +1 -1
  4. package/src/dashboard/checklist-comment-row.d.ts +6 -0
  5. package/src/dashboard/checklist-comment-row.js +6 -0
  6. package/src/dashboard/checklist-comment-row.js.map +1 -1
  7. package/src/dashboard/dashboard.d.ts +11 -0
  8. package/src/dashboard/dashboard.js +24 -6
  9. package/src/dashboard/dashboard.js.map +1 -1
  10. package/src/scripts/commands/await-reviews-command.d.ts +3 -3
  11. package/src/scripts/commands/await-reviews-command.js +24 -20
  12. package/src/scripts/commands/await-reviews-command.js.map +1 -1
  13. package/src/scripts/commands/finish-upsert-pr-command.js +27 -31
  14. package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -1
  15. package/src/scripts/commands/review-upsert-pr-command.d.ts +3 -8
  16. package/src/scripts/commands/review-upsert-pr-command.js +15 -17
  17. package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
  18. package/src/scripts/commands/write-review-command.d.ts +29 -15
  19. package/src/scripts/commands/write-review-command.js +62 -29
  20. package/src/scripts/commands/write-review-command.js.map +1 -1
  21. package/src/scripts/commands/write-review-fixes-command.d.ts +5 -1
  22. package/src/scripts/commands/write-review-fixes-command.js +6 -5
  23. package/src/scripts/commands/write-review-fixes-command.js.map +1 -1
  24. package/src/scripts/workflow/checklist-scanner.d.ts +47 -22
  25. package/src/scripts/workflow/checklist-scanner.js +77 -34
  26. package/src/scripts/workflow/checklist-scanner.js.map +1 -1
  27. package/src/scripts/workflow/provenance-enforcer.d.ts +2 -2
  28. package/src/scripts/workflow/provenance-enforcer.js +5 -5
  29. package/src/scripts/workflow/provenance-enforcer.js.map +1 -1
  30. package/src/scripts/workflow/review-report.d.ts +26 -8
  31. package/src/scripts/workflow/review-report.js +61 -39
  32. package/src/scripts/workflow/review-report.js.map +1 -1
  33. package/src/scripts/workflow/review-round-state.d.ts +87 -22
  34. package/src/scripts/workflow/review-round-state.js +252 -104
  35. package/src/scripts/workflow/review-round-state.js.map +1 -1
  36. package/src/scripts/workflow/review-round-text.d.ts +37 -0
  37. package/src/scripts/workflow/review-round-text.js +87 -0
  38. package/src/scripts/workflow/review-round-text.js.map +1 -0
  39. package/src/scripts/workflow/review-stage-receipt.d.ts +7 -19
  40. package/src/scripts/workflow/review-stage-receipt.js +7 -31
  41. package/src/scripts/workflow/review-stage-receipt.js.map +1 -1
  42. package/src/scripts/workflow/reviewer-briefing-builder.js +0 -1
  43. package/src/scripts/workflow/reviewer-briefing-builder.js.map +1 -1
  44. package/src/scripts/workflow/reviewer-verdict-gate.d.ts +14 -26
  45. package/src/scripts/workflow/reviewer-verdict-gate.js +38 -51
  46. package/src/scripts/workflow/reviewer-verdict-gate.js.map +1 -1
  47. package/src/scripts/workflow/verdict-provenance.d.ts +10 -10
  48. package/src/scripts/workflow/verdict-provenance.js +25 -23
  49. package/src/scripts/workflow/verdict-provenance.js.map +1 -1
@@ -1 +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;I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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;AA1PY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGJ,gCAAiB;QACjB,6CAAwB;QACxB,yBAAU;GAJlC,uBAAuB,CA0PnC","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 /**\n * TRUE once the repository's reviewer-round budget is SPENT: the latest global round is complete and it\n * was the last one `maxReviewerRounds` allows. From then on {@link plan} never briefs a reviewer again,\n * so nothing downstream may demand one either (issue #1051) — with `maxReviewerRounds: 1` that is what\n * \"review → fix → submit\" means. The scan uses it to CARRY every non-red verdict forward instead of\n * marking it STALE, whatever changes afterwards (remediation commits, summary edits, gate re-runs).\n */\n capSpent(summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number): boolean {\n return receipt !== null && receipt.round >= maxRounds && this.roundComplete(summaryPath, receipt);\n }\n\n /**\n * How many times ONE checklist has been reviewed on this branch: the global rounds 1..`throughRound` whose\n * immutable snapshot holds a verdict for it (`wp-write-review` archives every submission there). A\n * re-submission inside one round overwrites that round's snapshot, so it is one review, not two.\n */\n reviewCount(summaryPath: string, checklistId: string, throughRound: number): number {\n let count = 0;\n for (let round = 1; round <= throughRound; round++) {\n if (fs.existsSync(path.join(this.roundDir(summaryPath, round), `review-${checklistId}.json`))) count++;\n }\n return count;\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 || !this.capSpent(summaryPath, receipt, 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"]}
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,0DAEiC;AACjC,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,gHAAgH;AAChH,MAAM,UAAU,GAAG,gCAAgC,CAAC;AACpD,MAAM,QAAQ,GAAG,OAAO,CAAC;AACzB,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAExC,MAAa,eAAe;IACxB,MAAM,CAAS;IACf,KAAK,CAAS;IACd,SAAS,CAAS;IAClB,KAAK,CAAY;IACjB,YAAY,CAAW;IACvB,eAAe,CAAW;IAC1B,uFAAuF;IACvF,kBAAkB,CAAW;IAE7B,yDAAyD;IACzD,YACI,MAAc,EAAE,KAAa,EAAE,SAAiB,EAAE,KAAgB,EAAE,eAAyB,EAAE,EAC/F,kBAA4B,EAAE,EAAE,qBAA+B,EAAE;QAEjE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,eAAe,GAAG,eAAe,CA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O,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;AAnWY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGJ,gCAAiB;QACjB,6CAAwB;QACxB,yBAAU;GAJlC,uBAAuB,CAmWnC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { spawnSync } from 'child_process';\nimport {\n AtomicFile, ChecklistResult, InformAiError, ReviewJsonService, VERDICT_ORANGE, VERDICT_RED, toError,\n} 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\n/** Every round-numbered file of a branch's review lives beside summary.json under this prefix (issue #1053). */\nconst ROUND_FILE = /^review-round(\\d+)-(.+)\\.json$/;\nconst FIXES_ID = 'fixes';\nconst PROVENANCE_SUFFIX = '.provenance';\n\nexport class ReviewRoundPlan {\n action: string;\n round: number;\n maxRounds: number;\n basis: DiffBasis;\n changedFiles: string[];\n redChecklistIds: string[];\n /** The final round's ORANGE checklists — must-fix, never re-reviewed (issue #1053). */\n orangeChecklistIds: string[];\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n action: string, round: number, maxRounds: number, basis: DiffBasis, changedFiles: string[] = [],\n redChecklistIds: string[] = [], orangeChecklistIds: string[] = [],\n ) {\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 this.orangeChecklistIds = orangeChecklistIds;\n }\n}\n\n/**\n * Where a branch's review stands, DERIVED from the round-numbered files on disk plus the stage-② receipt\n * (issue #1053). There is no separate round counter: `round` is the highest round any file or briefing\n * names. Data-only.\n */\nexport class RoundSnapshot {\n round: number; // 0 = no round has started\n roster: string[]; // the checklists briefed in `round`\n headSha: string; // the commit `round` was briefed on\n complete: boolean; // every checklist on the roster has a verdict in `round`\n\n constructor(round: number, roster: string[], headSha: string, complete: boolean) {\n this.round = round;\n this.roster = roster;\n this.headSha = headSha;\n this.complete = complete;\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\n/** The author's recorded fixes for one completed round: `review-round<N>-fixes.json`. Data-only. */\nexport class ReviewRemediation {\n agent: string;\n model: string;\n fromHead: string;\n toHead: string;\n responses: RemediationResponse[];\n writtenAt: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\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/**\n * The reviewer rounds of one branch, read from their round-numbered files (issue #1053).\n *\n * `commands.pr-gate.maxReviewerRounds` is a HARD CEILING, not a quota: 1 round means 1 round. Three rules\n * follow from it, and everything here exists to hold them:\n *\n * 1. Every verdict is `review-round<N>-<id>.json` (+ `.provenance.json`), every author fix record is\n * `review-round<N>-fixes.json`, and nothing is ever overwritten. The live verdict of a checklist is its\n * highest round; the round the branch is on is the highest round any file names.\n * 2. A new round starts ONLY when the previous round has a RED and rounds remain, and it re-briefs only\n * those reds. A green or yellow stands whatever changes afterwards — staleness never re-reviews.\n * 3. The final round has no red. Its blocking color is ORANGE: the author fixes it best effort, records the\n * fix, and ships with the finding and its claimed fix stamped on the dashboard.\n */\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 /** The author's recorded fixes for one round: `review-round<N>-fixes.json`, beside summary.json. */\n fixesPath(summaryPath: string, round: number): string {\n return path.join(path.dirname(summaryPath), `review-round${round}-${FIXES_ID}.json`);\n }\n\n /** The highest round any round-numbered file names, or 0. */\n highestRound(summaryPath: string): number {\n let highest = 0;\n for (const name of this.roundFiles(summaryPath)) {\n const match = ROUND_FILE.exec(name);\n if (match !== null) highest = Math.max(highest, Number(match[1]));\n }\n return highest;\n }\n\n /** Every checklist that has a verdict in ANY round on this branch. */\n verdictChecklistIds(summaryPath: string): string[] {\n const ids = new Set<string>();\n for (const name of this.roundFiles(summaryPath)) {\n const id = this.verdictIdOf(name);\n if (id !== '') ids.add(id);\n }\n return [...ids].sort();\n }\n\n /** Where the branch's review stands — see {@link RoundSnapshot}. */\n snapshot(summaryPath: string, receipt: ReviewStageReceipt | null): RoundSnapshot {\n const briefed = receipt !== null && receipt.reviewersBriefed.length > 0 ? receipt.round : 0;\n const round = Math.max(this.highestRound(summaryPath), briefed);\n if (round < 1) return new RoundSnapshot(0, [], '', false);\n if (receipt !== null && receipt.round === round) {\n return new RoundSnapshot(round, receipt.reviewersBriefed.slice(), receipt.headSha,\n this.everyVerdictIn(summaryPath, receipt.reviewersBriefed, round));\n }\n // The receipt names an older round (or is gone): the files are the record, so the roster is exactly\n // the checklists that have a verdict in this round, and the reviewed HEAD is what their provenance says.\n const roster = this.roundFiles(summaryPath)\n .filter((name: string): boolean => name.startsWith(`review-round${round}-`))\n .map((name: string): string => this.verdictIdOf(name))\n .filter((id: string): boolean => id !== '')\n .sort();\n const headSha = roster.length === 0 ? '' : this.provenance.read(summaryPath, roster[0], round)?.headSha ?? '';\n return new RoundSnapshot(round, roster, headSha, roster.length > 0);\n }\n\n /**\n * TRUE once a review round has started on this branch. From then on the checklist set is FROZEN (issue\n * #1053): finish judges only the checklists that were briefed, never ones a later commit newly triggers.\n */\n roundStarted(summaryPath: string, receipt: ReviewStageReceipt | null): boolean {\n return this.snapshot(summaryPath, receipt).round >= 1;\n }\n\n /** The frozen checklist set: every checklist briefed in any round — see {@link roundStarted}. */\n briefedChecklistIds(summaryPath: string, receipt: ReviewStageReceipt | null): string[] {\n const ids = new Set<string>(this.verdictChecklistIds(summaryPath));\n if (receipt !== null && receipt.round >= 1) for (const id of receipt.reviewersBriefed) ids.add(id);\n return [...ids].sort();\n }\n\n /** Does `checklistId` already have a verdict in `round`? A round's verdict is never overwritten. */\n hasVerdict(summaryPath: string, checklistId: string, round: number): boolean {\n return fs.existsSync(this.reviewJson.checklistResultPath(summaryPath, checklistId, round));\n }\n\n /** The roster checklists whose verdict in the snapshot's round is `status`. */\n checklistIdsWithStatus(summaryPath: string, snap: RoundSnapshot, status: string): string[] {\n if (!snap.complete) return [];\n return snap.roster.filter((id: string): boolean => {\n const raw = this.readObject(this.reviewJson.checklistResultPath(summaryPath, id, snap.round));\n return raw !== null && raw['status'] === status;\n });\n }\n\n /** What stage ② does next. See the class comment for the three rules it holds. */\n plan(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number, fullBasis: DiffBasis): ReviewRoundPlan {\n const snap = this.snapshot(summaryPath, receipt);\n if (snap.round < 1) return new ReviewRoundPlan(ROUND_ACTION_REVIEW, 1, maxRounds, fullBasis);\n if (!snap.complete) {\n if (snap.headSha !== fullBasis.headSha) {\n throw new InformAiError(`Reviewer round ${snap.round} of ${maxRounds} is still active at `\n + `${snap.headSha.slice(0, 8)}. Finish that fixed roster before changing the reviewed HEAD.`);\n }\n return new ReviewRoundPlan(ROUND_ACTION_RESUME, snap.round, maxRounds, fullBasis);\n }\n const reds = this.checklistIdsWithStatus(summaryPath, snap, VERDICT_RED);\n const oranges = this.checklistIdsWithStatus(summaryPath, snap, VERDICT_ORANGE);\n // No red, or no round left: nothing is ever re-reviewed. Oranges are the author's to fix and record.\n if (reds.length === 0 || snap.round >= maxRounds) {\n return new ReviewRoundPlan(ROUND_ACTION_FINISH, snap.round, maxRounds, fullBasis, [], reds, oranges);\n }\n if (snap.headSha === fullBasis.headSha) {\n return new ReviewRoundPlan(ROUND_ACTION_FIX, snap.round, maxRounds, fullBasis, [], reds, oranges);\n }\n if (this.validFixes(repoRoot, summaryPath, snap) === null) {\n return new ReviewRoundPlan(ROUND_ACTION_RECORD, snap.round, maxRounds, fullBasis, [], reds, oranges);\n }\n const basis = new DiffBasis(\n snap.headSha, fullBasis.headSha, false, [],\n `git diff ${snap.headSha} ${fullBasis.headSha}`,\n `git diff ${snap.headSha} ${fullBasis.headSha} -- <file>`, fullBasis.hashMainHead);\n const changed = this.git(repoRoot, ['diff', '--name-only', snap.headSha, fullBasis.headSha])\n .split('\\n').filter((f: string): boolean => f.trim() !== '');\n return new ReviewRoundPlan(ROUND_ACTION_REVIEW, snap.round + 1, maxRounds, basis, changed, reds, oranges);\n }\n\n /**\n * Record the author's fixes for the latest completed round — one response per RED (a round that is not\n * the last) or ORANGE (the final round) — as `review-round<N>-fixes.json`.\n *\n * A record that still HOLDS is never overwritten. One that no longer holds — its `toHead` left HEAD's\n * history, which every `wp-start-upsert-pr` squash-update does — is kept beside it as\n * `review-round<N>-fixes.json.superseded-<k>` and a fresh record is written, so re-recording is always\n * the way past a stale record and nothing is ever lost.\n */\n writeRemediation(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt, json: string): string {\n const snap = this.snapshot(summaryPath, receipt);\n if (!snap.complete) {\n throw new InformAiError('wp-write-review-fixes: the active reviewer round is not complete yet.');\n }\n const blocking = this.blockingIds(summaryPath, snap);\n if (blocking.length === 0) {\n throw new InformAiError(`wp-write-review-fixes: round ${snap.round} has no red or orange verdict to fix.`);\n }\n const out = this.fixesPath(summaryPath, snap.round);\n const holding = this.validFixes(repoRoot, summaryPath, snap);\n if (holding !== null) {\n throw new InformAiError(`wp-write-review-fixes: the fixes for round ${snap.round} are already recorded in ${out}, and `\n + `that record still holds (its fixed commit ${holding.toHead.slice(0, 8)} is in HEAD's history), so it is not `\n + 'overwritten. Nothing more to record: re-run pnpm wp-review-upsert-pr, or pnpm wp-finish-upsert-pr after the last round.');\n }\n this.assertClean(repoRoot);\n const currentHead = this.git(repoRoot, ['rev-parse', 'HEAD']);\n if (currentHead === snap.headSha || this.git(repoRoot, ['diff', '--name-only', snap.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 => !blocking.includes(id));\n const missing = blocking.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/orange checklist(s) of round ${snap.round}. `\n + `Unknown: ${unknown.join(', ') || '(none)'}. Missing: ${missing.join(', ') || '(none)'}.`);\n }\n this.supersede(out);\n this.atomicFile.writeJsonAtomic(out, new ReviewRemediation(agent, model, snap.headSha, currentHead, responses));\n return out;\n }\n\n /**\n * Keep a record that no longer holds beside the new one, as `<file>.superseded-<k>` — a name no round\n * scan reads, so it is history and never a live record.\n */\n private supersede(file: string): void {\n if (!fs.existsSync(file)) return;\n let k = 1;\n while (fs.existsSync(`${file}.superseded-${k}`)) k++;\n fs.renameSync(file, `${file}.superseded-${k}`);\n }\n\n /**\n * The round's recorded fixes, or null when there are none that still hold: written from the reviewed\n * HEAD, to a later commit that is still in HEAD's history, covering exactly the round's red/orange set.\n */\n validFixes(repoRoot: string, summaryPath: string, snap: RoundSnapshot): ReviewRemediation | null {\n const record = this.readFixes(repoRoot, summaryPath, snap.round);\n if (record === null || record.fromHead !== snap.headSha) return null;\n const blocking = this.blockingIds(summaryPath, snap);\n const ids = record.responses.map((r: RemediationResponse): string => r.checklistId);\n if (blocking.some((id: string): boolean => !ids.includes(id)) || ids.some((id: string): boolean => !blocking.includes(id))) return null;\n return record;\n }\n\n /**\n * checklist id → the dashboard stamp for every ORANGE whose fix the author recorded (issue #1053):\n * \"orange at <fromHead>, author-fixed in <toHead>, not re-reviewed: <resolution>\". An orange with no\n * valid record is absent, and so still blocks.\n */\n orangeFixes(repoRoot: string, summaryPath: string, results: readonly ChecklistResult[]): Record<string, string> {\n const out: Record<string, string> = {};\n for (const result of results) {\n if (result.status !== VERDICT_ORANGE || result.problem !== '') continue;\n const record = this.readFixes(repoRoot, summaryPath, result.round);\n const response = record?.responses.find((r: RemediationResponse): boolean => r.checklistId === result.id);\n if (record === null || response === undefined) continue;\n out[result.id] = `orange at ${record.fromHead.slice(0, 8)}, author-fixed in ${record.toHead.slice(0, 8)}, `\n + `not re-reviewed: ${response.resolution}`;\n }\n return out;\n }\n\n auditTrail(summaryPath: string, checklistId: string, maxRounds: number): string {\n const lines: string[] = [];\n const highest = this.highestRound(summaryPath);\n for (let round = 1; round <= highest; round++) {\n const verdict = this.readObject(this.reviewJson.checklistResultPath(summaryPath, checklistId, round));\n if (verdict !== null) {\n lines.push(`#### Reviewer round ${round} of ${maxRounds}`);\n lines.push(`Reviewed SHA: ${this.provenance.read(summaryPath, checklistId, round)?.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.fixesPath(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 fix 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 blockingIds(summaryPath: string, snap: RoundSnapshot): string[] {\n return [\n ...this.checklistIdsWithStatus(summaryPath, snap, VERDICT_RED),\n ...this.checklistIdsWithStatus(summaryPath, snap, VERDICT_ORANGE),\n ];\n }\n\n /** A round's fix record, provided its `toHead` is still in HEAD's history; else null. */\n private readFixes(repoRoot: string, summaryPath: string, round: number): ReviewRemediation | null {\n const raw = this.readObject(this.fixesPath(summaryPath, round));\n if (raw === null) return null;\n const responses = this.responsesOrEmpty(raw['responses']);\n const fromHead = this.text(raw['fromHead']);\n const toHead = this.text(raw['toHead']);\n if (this.text(raw['agent']) === '' || this.text(raw['model']) === '' || responses.length === 0\n || fromHead === '' || toHead === '' || fromHead === toHead || !this.isAncestorOfHead(repoRoot, toHead)) return null;\n return new ReviewRemediation(this.text(raw['agent']), this.text(raw['model']), fromHead, toHead, responses);\n }\n\n private everyVerdictIn(summaryPath: string, roster: readonly string[], round: number): boolean {\n return roster.length > 0 && roster.every((id: string): boolean => this.hasVerdict(summaryPath, id, round));\n }\n\n /** `review-round<N>-<id>.json` → `<id>`; '' for the fixes record, a provenance file, or anything else. */\n private verdictIdOf(name: string): string {\n const match = ROUND_FILE.exec(name);\n if (match === null) return '';\n const id = match[2];\n return id === FIXES_ID || id.endsWith(PROVENANCE_SUFFIX) ? '' : id;\n }\n\n private roundFiles(summaryPath: string): string[] {\n const dir = path.dirname(summaryPath);\n if (!fs.existsSync(dir)) return [];\n return fs.readdirSync(dir).filter((name: string): boolean => ROUND_FILE.test(name));\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 /**\n * `git merge-base --is-ancestor`: exit 0 = yes, 1 = no. A `sha` git does not know (exit 128 with\n * \"Not a valid commit name\") is also no — the commit is gone from this clone, so it is not in HEAD's\n * history. Anything else is a real failure and refuses.\n */\n private isAncestorOfHead(repoRoot: string, sha: string): boolean {\n const result = spawnSync('git', ['merge-base', '--is-ancestor', sha, 'HEAD'], { cwd: repoRoot, encoding: 'utf8' });\n if (result.status === 0) return true;\n if (result.status === 1 || /not a valid (commit|object) name/i.test(result.stderr ?? '')) return false;\n const detail = (result.stderr ?? '').trim() || result.error?.message || `exit ${result.status ?? 'unknown'}`;\n const message = `Review-round Git command failed: git merge-base --is-ancestor ${sha} HEAD\\n${detail}`;\n if (result.error !== undefined) throw new InformAiError(message, { cause: result.error });\n throw new InformAiError(message);\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"]}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The review-ROUND half of what `wp-review-upsert-pr` prints (issue #1053): the final round's banner, the
3
+ * red-remediation steps between rounds, the orange fix step after the last one, and the line naming
4
+ * checklists a later commit triggered after the briefing. `ReviewReport` composes these into its one
5
+ * "what to do next" block; they live here so that file stays one file.
6
+ *
7
+ * `maxReviewerRounds` is a HARD ceiling, and every string here says so in the one way that changes what an
8
+ * agent does next: which color means what, and what it may never do to get another round. None of them
9
+ * says anything about ending a turn (see `.claude/rules/never-tell-an-ai-to-end-its-turn.md`);
10
+ * `no-turn-ending-instructions.spec.ts` renders them.
11
+ *
12
+ * Pure string building. `@injectable(bindingScopeValues.Singleton)` so it is injected by type.
13
+ */
14
+ export declare class ReviewRoundText {
15
+ /**
16
+ * Printed BEFORE anything else when stage ② briefs the LAST allowed round. On ctoteachings/monorepo#1355
17
+ * the agent had been told the cap was 1 and still moved the review directory aside — twice — to get
18
+ * "round 1" again; every earlier word about the cap was a line among many. This one is the first thing
19
+ * printed, and says the whole contract: spawn once, what each color means, and what is forbidden.
20
+ */
21
+ finalRoundBanner(round: number, maxRounds: number): string;
22
+ /** A round came back RED with HEAD unchanged: fix, commit, record — the next round re-reviews it. */
23
+ fixStep(round: number, maxRounds: number, redIds: readonly string[]): string;
24
+ /** The fixes are committed but not yet recorded. */
25
+ recordStep(round: number, maxRounds: number): string;
26
+ /**
27
+ * The final round came back ORANGE: its step comes FIRST in the finish block, because finish refuses
28
+ * until each orange has a recorded fix — and it names no reviewer, because none may be spawned for it.
29
+ */
30
+ orangeFixStep(step: number, round: number, maxRounds: number, orangeIds: readonly string[]): string;
31
+ /**
32
+ * The checklists a later commit newly triggered after the briefing — named, never owed. The checklist set
33
+ * is frozen at the briefing, so no round will brief them and finish does not wait on them; saying so is
34
+ * what keeps an agent from "helpfully" spawning a reviewer the gate never asked for.
35
+ */
36
+ notBriefedLines(ids: readonly string[]): string[];
37
+ }
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReviewRoundText = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const inversify_1 = require("inversify");
6
+ const SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n';
7
+ /**
8
+ * The review-ROUND half of what `wp-review-upsert-pr` prints (issue #1053): the final round's banner, the
9
+ * red-remediation steps between rounds, the orange fix step after the last one, and the line naming
10
+ * checklists a later commit triggered after the briefing. `ReviewReport` composes these into its one
11
+ * "what to do next" block; they live here so that file stays one file.
12
+ *
13
+ * `maxReviewerRounds` is a HARD ceiling, and every string here says so in the one way that changes what an
14
+ * agent does next: which color means what, and what it may never do to get another round. None of them
15
+ * says anything about ending a turn (see `.claude/rules/never-tell-an-ai-to-end-its-turn.md`);
16
+ * `no-turn-ending-instructions.spec.ts` renders them.
17
+ *
18
+ * Pure string building. `@injectable(bindingScopeValues.Singleton)` so it is injected by type.
19
+ */
20
+ let ReviewRoundText = class ReviewRoundText {
21
+ /**
22
+ * Printed BEFORE anything else when stage ② briefs the LAST allowed round. On ctoteachings/monorepo#1355
23
+ * the agent had been told the cap was 1 and still moved the review directory aside — twice — to get
24
+ * "round 1" again; every earlier word about the cap was a line among many. This one is the first thing
25
+ * printed, and says the whole contract: spawn once, what each color means, and what is forbidden.
26
+ */
27
+ finalRoundBanner(round, maxRounds) {
28
+ return [
29
+ '',
30
+ `‼️ REVIEW ROUND ${round} OF ${maxRounds} — THIS IS THE LAST REVIEW THIS PR WILL EVER GET (maxReviewerRounds = ${maxRounds}).`,
31
+ ' Spawn the reviewers ONCE. When verdicts come back:',
32
+ ' green / yellow → finish.',
33
+ ' orange → FIX the code best effort, record it with `pnpm wp-write-review-fixes`, then finish.',
34
+ ' You may NOT spawn a reviewer again, re-brief one, ask for an override, or move/delete/edit anything',
35
+ ' under .webpieces/pr-review/* to get another round. If the gate ever asks for another review after',
36
+ ' this, do not spawn a reviewer; report it as a webpieces bug.',
37
+ '',
38
+ ].join('\n');
39
+ }
40
+ /** A round came back RED with HEAD unchanged: fix, commit, record — the next round re-reviews it. */
41
+ fixStep(round, maxRounds, redIds) {
42
+ return '\n' + SEP + `▶ NEXT — fix every finding from round ${round} of ${maxRounds}\n` + SEP + '\n'
43
+ + ` Red checklist(s): ${redIds.join(', ')}\n`
44
+ + ' Commit every fix and leave the tree clean, then record one response per checklist with:\n'
45
+ + ' pnpm wp-write-review-fixes\n'
46
+ + ' Re-run pnpm wp-review-upsert-pr after that. It starts a focused round that re-reviews ONLY\n'
47
+ + ' those red checklists, because the configured round budget still has room.\n';
48
+ }
49
+ /** The fixes are committed but not yet recorded. */
50
+ recordStep(round, maxRounds) {
51
+ return '\n' + SEP + `▶ NEXT — record the committed fixes for round ${round} of ${maxRounds}\n` + SEP + '\n'
52
+ + ' pnpm wp-write-review-fixes\n\n'
53
+ + ' The command stamps the reviewed HEAD and current clean HEAD itself. Then re-run\n'
54
+ + ' pnpm wp-review-upsert-pr; do not edit or recolor the reviewer verdict.\n';
55
+ }
56
+ /**
57
+ * The final round came back ORANGE: its step comes FIRST in the finish block, because finish refuses
58
+ * until each orange has a recorded fix — and it names no reviewer, because none may be spawned for it.
59
+ */
60
+ orangeFixStep(step, round, maxRounds, orangeIds) {
61
+ return `STEP ${step} — FIX every ORANGE finding, best effort: ${orangeIds.join(', ')}.\n`
62
+ + ` Round ${round} of ${maxRounds} was the LAST review: do NOT spawn a reviewer for these.\n`
63
+ + ' Commit every fix, leave the tree clean, then record one response per orange checklist with:\n'
64
+ + ' pnpm wp-write-review-fixes\n'
65
+ + ' The PR ships with each finding and your recorded fix stamped on its dashboard.\n\n';
66
+ }
67
+ /**
68
+ * The checklists a later commit newly triggered after the briefing — named, never owed. The checklist set
69
+ * is frozen at the briefing, so no round will brief them and finish does not wait on them; saying so is
70
+ * what keeps an agent from "helpfully" spawning a reviewer the gate never asked for.
71
+ */
72
+ notBriefedLines(ids) {
73
+ if (ids.length === 0)
74
+ return [];
75
+ return [
76
+ '',
77
+ ` ⚪ Not reviewed, NOT blocking: ${ids.join(', ')} — first triggered by a commit after the review was`,
78
+ ' briefed. The checklist set is frozen at the briefing: do NOT spawn a reviewer for these. The PR',
79
+ ' dashboard names them on an informational line.',
80
+ ];
81
+ }
82
+ };
83
+ exports.ReviewRoundText = ReviewRoundText;
84
+ exports.ReviewRoundText = ReviewRoundText = tslib_1.__decorate([
85
+ (0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton)
86
+ ], ReviewRoundText);
87
+ //# sourceMappingURL=review-round-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-round-text.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/review-round-text.ts"],"names":[],"mappings":";;;;AAAA,yCAA2D;AAE3D,MAAM,GAAG,GAAG,4DAA4D,CAAC;AAEzE;;;;;;;;;;;;GAYG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IACxB;;;;;OAKG;IACH,gBAAgB,CAAC,KAAa,EAAE,SAAiB;QAC7C,OAAO;YACH,EAAE;YACF,mBAAmB,KAAK,OAAO,SAAS,yEAAyE,SAAS,IAAI;YAC9H,uDAAuD;YACvD,+BAA+B;YAC/B,2GAA2G;YAC3G,wGAAwG;YACxG,sGAAsG;YACtG,iEAAiE;YACjE,EAAE;SACL,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IAED,qGAAqG;IACrG,OAAO,CAAC,KAAa,EAAE,SAAiB,EAAE,MAAyB;QAC/D,OAAO,IAAI,GAAG,GAAG,GAAG,yCAAyC,KAAK,OAAO,SAAS,IAAI,GAAG,GAAG,GAAG,IAAI;cAC7F,wBAAwB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;cAC7C,8FAA8F;cAC9F,uCAAuC;cACvC,iGAAiG;cACjG,gFAAgF,CAAC;IAC3F,CAAC;IAED,oDAAoD;IACpD,UAAU,CAAC,KAAa,EAAE,SAAiB;QACvC,OAAO,IAAI,GAAG,GAAG,GAAG,iDAAiD,KAAK,OAAO,SAAS,IAAI,GAAG,GAAG,GAAG,IAAI;cACrG,yCAAyC;cACzC,sFAAsF;cACtF,6EAA6E,CAAC;IACxF,CAAC;IAED;;;OAGG;IACH,aAAa,CAAC,IAAY,EAAE,KAAa,EAAE,SAAiB,EAAE,SAA4B;QACtF,OAAO,QAAQ,IAAI,6CAA6C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK;cACnF,kBAAkB,KAAK,OAAO,SAAS,4DAA4D;cACnG,wGAAwG;cACxG,2CAA2C;cAC3C,6FAA6F,CAAC;IACxG,CAAC;IAED;;;;OAIG;IACH,eAAe,CAAC,GAAsB;QAClC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAChC,OAAO;YACH,EAAE;YACF,mCAAmC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,qDAAqD;YACtG,sGAAsG;YACtG,qDAAqD;SACxD,CAAC;IACN,CAAC;CACJ,CAAA;AAjEY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;GAC5B,eAAe,CAiE3B","sourcesContent":["import { injectable, bindingScopeValues } from 'inversify';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * The review-ROUND half of what `wp-review-upsert-pr` prints (issue #1053): the final round's banner, the\n * red-remediation steps between rounds, the orange fix step after the last one, and the line naming\n * checklists a later commit triggered after the briefing. `ReviewReport` composes these into its one\n * \"what to do next\" block; they live here so that file stays one file.\n *\n * `maxReviewerRounds` is a HARD ceiling, and every string here says so in the one way that changes what an\n * agent does next: which color means what, and what it may never do to get another round. None of them\n * says anything about ending a turn (see `.claude/rules/never-tell-an-ai-to-end-its-turn.md`);\n * `no-turn-ending-instructions.spec.ts` renders them.\n *\n * Pure string building. `@injectable(bindingScopeValues.Singleton)` so it is injected by type.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewRoundText {\n /**\n * Printed BEFORE anything else when stage ② briefs the LAST allowed round. On ctoteachings/monorepo#1355\n * the agent had been told the cap was 1 and still moved the review directory aside — twice — to get\n * \"round 1\" again; every earlier word about the cap was a line among many. This one is the first thing\n * printed, and says the whole contract: spawn once, what each color means, and what is forbidden.\n */\n finalRoundBanner(round: number, maxRounds: number): string {\n return [\n '',\n `‼️ REVIEW ROUND ${round} OF ${maxRounds} — THIS IS THE LAST REVIEW THIS PR WILL EVER GET (maxReviewerRounds = ${maxRounds}).`,\n ' Spawn the reviewers ONCE. When verdicts come back:',\n ' green / yellow → finish.',\n ' orange → FIX the code best effort, record it with `pnpm wp-write-review-fixes`, then finish.',\n ' You may NOT spawn a reviewer again, re-brief one, ask for an override, or move/delete/edit anything',\n ' under .webpieces/pr-review/* to get another round. If the gate ever asks for another review after',\n ' this, do not spawn a reviewer; report it as a webpieces bug.',\n '',\n ].join('\\n');\n }\n\n /** A round came back RED with HEAD unchanged: fix, commit, record — the next round re-reviews it. */\n fixStep(round: number, maxRounds: number, redIds: readonly string[]): string {\n return '\\n' + SEP + `▶ NEXT — fix every finding from round ${round} of ${maxRounds}\\n` + SEP + '\\n'\n + ` Red checklist(s): ${redIds.join(', ')}\\n`\n + ' Commit every fix and leave the tree clean, then record one response per checklist with:\\n'\n + ' pnpm wp-write-review-fixes\\n'\n + ' Re-run pnpm wp-review-upsert-pr after that. It starts a focused round that re-reviews ONLY\\n'\n + ' those red checklists, because the configured round budget still has room.\\n';\n }\n\n /** The fixes are committed but not yet recorded. */\n recordStep(round: number, maxRounds: number): string {\n return '\\n' + SEP + `▶ NEXT — record the committed fixes for round ${round} of ${maxRounds}\\n` + SEP + '\\n'\n + ' pnpm wp-write-review-fixes\\n\\n'\n + ' The command stamps the reviewed HEAD and current clean HEAD itself. Then re-run\\n'\n + ' pnpm wp-review-upsert-pr; do not edit or recolor the reviewer verdict.\\n';\n }\n\n /**\n * The final round came back ORANGE: its step comes FIRST in the finish block, because finish refuses\n * until each orange has a recorded fix — and it names no reviewer, because none may be spawned for it.\n */\n orangeFixStep(step: number, round: number, maxRounds: number, orangeIds: readonly string[]): string {\n return `STEP ${step} — FIX every ORANGE finding, best effort: ${orangeIds.join(', ')}.\\n`\n + ` Round ${round} of ${maxRounds} was the LAST review: do NOT spawn a reviewer for these.\\n`\n + ' Commit every fix, leave the tree clean, then record one response per orange checklist with:\\n'\n + ' pnpm wp-write-review-fixes\\n'\n + ' The PR ships with each finding and your recorded fix stamped on its dashboard.\\n\\n';\n }\n\n /**\n * The checklists a later commit newly triggered after the briefing — named, never owed. The checklist set\n * is frozen at the briefing, so no round will brief them and finish does not wait on them; saying so is\n * what keeps an agent from \"helpfully\" spawning a reviewer the gate never asked for.\n */\n notBriefedLines(ids: readonly string[]): string[] {\n if (ids.length === 0) return [];\n return [\n '',\n ` ⚪ Not reviewed, NOT blocking: ${ids.join(', ')} — first triggered by a commit after the review was`,\n ' briefed. The checklist set is frozen at the briefing: do NOT spawn a reviewer for these. The PR',\n ' dashboard names them on an informational line.',\n ];\n }\n}\n"]}
@@ -15,17 +15,15 @@ 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
18
  /**
23
- * The reviewed HEAD the latest recorded author remediation starts from: stamped by stage ② when it opens
24
- * a remediation-only round (the prior round's HEAD), and by `wp-write-review-fixes` the moment it accepts
25
- * a remediation — including the one after the round cap, where no further round is ever opened to stamp
26
- * it (issue #1051: it used to stay '' there). Empty while no remediation exists.
19
+ * The round stage ② BRIEFED `reviewersBriefed` for, and so the N every verdict submitted against this
20
+ * receipt is written as (`review-round<N>-<id>.json`). Zero means no reviewer round has started. The
21
+ * round the branch is on is DERIVED from the round-numbered files (issue #1053); this only says which
22
+ * round the latest briefing opened.
27
23
  */
28
- remediationFromHead: string;
24
+ round: number;
25
+ /** Repository-owned cap copied from config, so `wp-write-review` refuses a round above it. */
26
+ maxReviewerRounds: number;
29
27
  constructor(headSha?: string, mergeValidated?: boolean, buildCommand?: string, buildPassedAt?: string, reviewersBriefed?: string[]);
30
28
  }
31
29
  /**
@@ -48,17 +46,7 @@ export declare class ReviewStageReceiptService {
48
46
  constructor(reviewJsonService: ReviewJsonService);
49
47
  receiptPath(repoRoot: string, featureName: string): string;
50
48
  write(repoRoot: string, featureName: string, receipt: ReviewStageReceipt): string;
51
- /**
52
- * Stamp an ACCEPTED author remediation onto the receipt (issue #1051), keeping the file's mtime.
53
- *
54
- * The mtime is kept deliberately: {@link writtenAtMs} answers "when did stage ② last brief anyone?",
55
- * and recording a remediation briefs nobody. Moving it would make `wp-await-reviews` discount every
56
- * verdict submitted before the remediation as though a new briefing had superseded it.
57
- */
58
- recordRemediation(repoRoot: string, featureName: string, receipt: ReviewStageReceipt): string;
59
49
  /** The receipt, or null when stage ② never ran (or left something unreadable behind). */
60
50
  read(repoRoot: string, featureName: string): ReviewStageReceipt | null;
61
- /** The receipt file's mtime in epoch ms, or 0 when there is none — when stage ② last briefed anyone. */
62
- writtenAtMs(repoRoot: string, featureName: string): number;
63
51
  private stringMap;
64
52
  }
@@ -22,17 +22,15 @@ 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
25
  /**
30
- * The reviewed HEAD the latest recorded author remediation starts from: stamped by stage ② when it opens
31
- * a remediation-only round (the prior round's HEAD), and by `wp-write-review-fixes` the moment it accepts
32
- * a remediation — including the one after the round cap, where no further round is ever opened to stamp
33
- * it (issue #1051: it used to stay '' there). Empty while no remediation exists.
26
+ * The round stage ② BRIEFED `reviewersBriefed` for, and so the N every verdict submitted against this
27
+ * receipt is written as (`review-round<N>-<id>.json`). Zero means no reviewer round has started. The
28
+ * round the branch is on is DERIVED from the round-numbered files (issue #1053); this only says which
29
+ * round the latest briefing opened.
34
30
  */
35
- remediationFromHead;
31
+ round;
32
+ /** Repository-owned cap copied from config, so `wp-write-review` refuses a round above it. */
33
+ maxReviewerRounds;
36
34
  // eslint-disable-next-line @typescript-eslint/max-params
37
35
  constructor(headSha = '', mergeValidated = false, buildCommand = '', buildPassedAt = '', reviewersBriefed = []) {
38
36
  this.headSha = headSha;
@@ -43,7 +41,6 @@ class ReviewStageReceipt {
43
41
  this.scopeHashes = {};
44
42
  this.round = 0;
45
43
  this.maxReviewerRounds = 0;
46
- this.remediationFromHead = '';
47
44
  }
48
45
  }
49
46
  exports.ReviewStageReceipt = ReviewStageReceipt;
@@ -76,21 +73,6 @@ let ReviewStageReceiptService = class ReviewStageReceiptService {
76
73
  fs.writeFileSync(p, JSON.stringify(receipt, null, 2) + '\n');
77
74
  return p;
78
75
  }
79
- /**
80
- * Stamp an ACCEPTED author remediation onto the receipt (issue #1051), keeping the file's mtime.
81
- *
82
- * The mtime is kept deliberately: {@link writtenAtMs} answers "when did stage ② last brief anyone?",
83
- * and recording a remediation briefs nobody. Moving it would make `wp-await-reviews` discount every
84
- * verdict submitted before the remediation as though a new briefing had superseded it.
85
- */
86
- recordRemediation(repoRoot, featureName, receipt) {
87
- const p = this.receiptPath(repoRoot, featureName);
88
- const before = fs.statSync(p);
89
- receipt.remediationFromHead = receipt.headSha;
90
- this.write(repoRoot, featureName, receipt);
91
- fs.utimesSync(p, before.atime, before.mtime);
92
- return p;
93
- }
94
76
  /** The receipt, or null when stage ② never ran (or left something unreadable behind). */
95
77
  read(repoRoot, featureName) {
96
78
  const p = this.receiptPath(repoRoot, featureName);
@@ -106,7 +88,6 @@ let ReviewStageReceiptService = class ReviewStageReceiptService {
106
88
  receipt.round = typeof raw['round'] === 'number' && Number.isInteger(raw['round']) ? raw['round'] : 0;
107
89
  receipt.maxReviewerRounds = typeof raw['maxReviewerRounds'] === 'number' && Number.isInteger(raw['maxReviewerRounds'])
108
90
  ? raw['maxReviewerRounds'] : 0;
109
- receipt.remediationFromHead = typeof raw['remediationFromHead'] === 'string' ? raw['remediationFromHead'] : '';
110
91
  return receipt;
111
92
  }
112
93
  catch (err) {
@@ -115,11 +96,6 @@ let ReviewStageReceiptService = class ReviewStageReceiptService {
115
96
  return null;
116
97
  }
117
98
  }
118
- /** The receipt file's mtime in epoch ms, or 0 when there is none — when stage ② last briefed anyone. */
119
- writtenAtMs(repoRoot, featureName) {
120
- const p = this.receiptPath(repoRoot, featureName);
121
- return fs.existsSync(p) ? fs.statSync(p).mtimeMs : 0;
122
- }
123
99
  // webpieces-disable no-any-unknown -- one opaque JSON value, narrowed to string→string
124
100
  stringMap(value) {
125
101
  const out = {};
@@ -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;IACpC,yFAAyF;IACzF,KAAK,CAAS;IACd,iGAAiG;IACjG,iBAAiB,CAAS;IAC1B;;;;;OAKG;IACH,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,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,Y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;QAC5B,MAAM,GAAG,GAA2B,EAAE,CAAC;QACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,GAAG,CAAC;QACpF,4FAA4F;QAC5F,MAAM,GAAG,GAAG,KAAgC,CAAC;QAC7C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,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;AA7EY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEW,gCAAiB;GADxD,yBAAyB,CA6ErC","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 /**\n * The reviewed HEAD the latest recorded author remediation starts from: stamped by stage ② when it opens\n * a remediation-only round (the prior round's HEAD), and by `wp-write-review-fixes` the moment it accepts\n * a remediation — including the one after the round cap, where no further round is ever opened to stamp\n * it (issue #1051: it used to stay '' there). Empty while no remediation exists.\n */\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 /**\n * Stamp an ACCEPTED author remediation onto the receipt (issue #1051), keeping the file's mtime.\n *\n * The mtime is kept deliberately: {@link writtenAtMs} answers \"when did stage ② last brief anyone?\",\n * and recording a remediation briefs nobody. Moving it would make `wp-await-reviews` discount every\n * verdict submitted before the remediation as though a new briefing had superseded it.\n */\n recordRemediation(repoRoot: string, featureName: string, receipt: ReviewStageReceipt): string {\n const p = this.receiptPath(repoRoot, featureName);\n const before = fs.statSync(p);\n receipt.remediationFromHead = receipt.headSha;\n this.write(repoRoot, featureName, receipt);\n fs.utimesSync(p, before.atime, before.mtime);\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"]}
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;;;;;OAKG;IACH,KAAK,CAAS;IACd,8FAA8F;IAC9F,iBAAiB,CAAS;IAE1B,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,CA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AW,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7C,OAAO,OAAO,CAAC;QACnB,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,IAAA,sBAAO,EAAC,GAAG,CAAC,CAAC;YAC3B,KAAK,KAAK,CAAC,CAAC,6EAA6E;YACzF,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;IAED,uFAAuF;IAC/E,SAAS,CAAC,KAAc;QAC5B,MAAM,GAAG,GAA2B,EAAE,CAAC;QACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,GAAG,CAAC;QACpF,4FAA4F;QAC5F,MAAM,GAAG,GAAG,KAAgC,CAAC;QAC7C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACjC,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;AAtDY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEW,gCAAiB;GADxD,yBAAyB,CAsDrC","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 * The round stage ② BRIEFED `reviewersBriefed` for, and so the N every verdict submitted against this\n * receipt is written as (`review-round<N>-<id>.json`). Zero means no reviewer round has started. The\n * round the branch is on is DERIVED from the round-numbered files (issue #1053); this only says which\n * round the latest briefing opened.\n */\n round: number;\n /** Repository-owned cap copied from config, so `wp-write-review` refuses a round above it. */\n maxReviewerRounds: number;\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 }\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 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 // 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"]}
@@ -41,7 +41,6 @@ let ReviewerBriefingBuilder = class ReviewerBriefingBuilder {
41
41
  b.required = req.required;
42
42
  b.sourceDirs = this.sourceDirsFor(repoRoot, req.matchedFiles);
43
43
  b.contextEntries = shared;
44
- b.verdictPath = this.reviewJsonService.checklistResultPath(scan.summaryPath, req.id);
45
44
  b.fileDiffCommand = scan.context.fileDiffCommand;
46
45
  b.dirty = scan.basis.dirty;
47
46
  b.ownAgentFileInDiff = this.ownAgentFileIn(manifest, req.reviewer.agentName);
@@ -1 +1 @@
1
- {"version":3,"file":"reviewer-briefing-builder.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/reviewer-briefing-builder.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,0DAEiC;AACjC,yCAA2D;AAI3D;;;;;;GAMG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IACH;IAA7B,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAG,CAAC;IAErE,uGAAuG;IACvG,yDAAyD;IACzD,KAAK,CACD,QAAgB,EAAE,IAAmB,EAAE,UAAwC,EAAE,QAAsB,EACvG,OAAe,EAAE,MAAoB;QAErC,oGAAoG;QACpG,kEAAkE;QAClE,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACrD,MAAM,WAAW,GAAG,IAAI,GAAG,EAA6B,CAAC;QACzD,KAAK,MAAM,CAAC,IAAI,QAAQ,CAAC,OAAO;YAAE,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAC7D,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,GAAsB,EAAoB,EAAE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MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAE,IAAI,CAAC,aAAa,CAAY,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5F,OAAO,IAAI,2BAAY,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;QACzE,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,IAAA,sBAAO,EAAC,GAAG,CAAC,CAAC;YAC3B,KAAK,KAAK,CAAC,CAAC,yDAAyD;YACrE,OAAO,IAAI,2BAAY,CAAC,GAAG,EAAE,EAAE,EAAE,+DAA+D,CAAC,CAAC;QACtG,CAAC;IACL,CAAC;CACJ,CAAA;AAlIY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEW,gCAAiB;GADxD,uBAAuB,CAkInC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport {\n BriefedFile, ContextEntry, PrGateConfig, RequiredChecklist, ReviewerBriefing, ReviewJsonService, toError,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { DiffManifest, DiffManifestEntry } from './diff-materializer';\nimport { ChecklistScan } from './checklist-scanner';\n\n/**\n * Turns a {@link ChecklistScan} plus the materialized {@link DiffManifest} into one {@link ReviewerBriefing}\n * per reviewer — resolving every path to an absolute one, because a reviewer that has to resolve a path\n * ends up searching, and searching is the cost this whole feature exists to remove.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewerBriefingBuilder {\n constructor(private readonly reviewJsonService: ReviewJsonService) {}\n\n /** One briefing per checklist in `checklists` — the OWED ones; a carried verdict is not re-briefed. */\n // eslint-disable-next-line @typescript-eslint/max-params\n build(\n repoRoot: string, scan: ChecklistScan, checklists: readonly RequiredChecklist[], manifest: DiffManifest,\n diffDir: string, config: PrGateConfig,\n ): ReviewerBriefing[] {\n // Resolved ONCE for the whole run, not per reviewer: `require.resolve` hits the filesystem, and the\n // answer cannot differ between two reviewers in the same process.\n const shared = this.contextEntries(repoRoot, config);\n const entryByFile = new Map<string, DiffManifestEntry>();\n for (const e of manifest.entries) entryByFile.set(e.file, e);\n return checklists.map((req: RequiredChecklist): ReviewerBriefing =>\n this.one(repoRoot, req, scan, entryByFile, diffDir, shared, manifest));\n }\n\n // eslint-disable-next-line @typescript-eslint/max-params\n private one(\n repoRoot: string, req: RequiredChecklist, scan: ChecklistScan,\n entryByFile: Map<string, DiffManifestEntry>, diffDir: string, shared: ContextEntry[], manifest: DiffManifest,\n ): ReviewerBriefing {\n const b = new ReviewerBriefing(req.reviewer.agentName, req.id, repoRoot);\n b.docPath = req.doc.trim() === '' ? '' : path.resolve(repoRoot, req.doc);\n b.diffDir = diffDir;\n b.allDiffPath = diffDir === '' ? '' : path.join(diffDir, 'ALL.diff');\n b.manifestPath = diffDir === '' ? '' : path.join(diffDir, 'manifest.json');\n b.myFiles = req.matchedFiles.map((f: string): BriefedFile => this.briefedFile(repoRoot, f, entryByFile));\n b.matchedPatterns = req.matchedPatterns;\n b.required = req.required;\n b.sourceDirs = this.sourceDirsFor(repoRoot, req.matchedFiles);\n b.contextEntries = shared;\n b.verdictPath = this.reviewJsonService.checklistResultPath(scan.summaryPath, req.id);\n b.fileDiffCommand = scan.context.fileDiffCommand;\n b.dirty = scan.basis.dirty;\n b.ownAgentFileInDiff = this.ownAgentFileIn(manifest, req.reviewer.agentName);\n this.copyManifestFacts(b, manifest);\n return b;\n }\n\n /**\n * One row of the reviewer's table. The SOURCE path comes over with the diff path because the two need\n * identical affordance: when the diff was an absolute path and the source was a parent directory, four of\n * four reviewers read the diff and none opened a source file.\n */\n private briefedFile(repoRoot: string, file: string, entryByFile: Map<string, DiffManifestEntry>): BriefedFile {\n const e = entryByFile.get(file);\n if (e === undefined) return new BriefedFile(file, '', path.resolve(repoRoot, file));\n return new BriefedFile(file, e.diffAbs, e.fileAbs, e.status, e.bytes, e.truncated);\n }\n\n /**\n * Manifest headline facts, copied onto the briefing so the instructions can state them INLINE. A reviewer\n * that never opens the manifest still has to learn whether anything was truncated or excluded — that is\n * precisely the thing it could not otherwise know it was missing.\n */\n private copyManifestFacts(b: ReviewerBriefing, manifest: DiffManifest): void {\n b.changedFileCount = manifest.entries.length;\n b.truncatedCount = manifest.entries.filter((e: DiffManifestEntry): boolean => e.truncated).length;\n b.excludedCount = manifest.excluded.length;\n b.allDiffLines = manifest.allDiffLines;\n b.allDiffBytes = manifest.allDiffBytes;\n b.hashForkPoint = manifest.hashForkPoint;\n b.hashFeatureHead = manifest.hashFeatureHead;\n b.hashMainHead = manifest.hashMainHead;\n }\n\n /**\n * The reviewer agent's own `.claude/agents/<agentName>.md`, when THIS diff changes it. Detected here rather than\n * left to the reviewer to notice: on the measured run two reviewers reviewed their own definition and\n * neither mentioned it, and every PR that edits the review gate reproduces that.\n */\n private ownAgentFileIn(manifest: DiffManifest, agentName: string): string {\n const suffix = path.join('.claude', 'agents', `${agentName}.md`);\n const hit = manifest.entries.find((e: DiffManifestEntry): boolean => e.file.split('/').join(path.sep).endsWith(suffix));\n return hit === undefined ? '' : (hit.fileAbs === '' ? hit.file : hit.fileAbs);\n }\n\n /**\n * Deduped absolute parent dirs of the matched files. Dirs rather than files because the point is to say\n * \"the neighbourhood is here\" — a reviewer already has the file list; what it lacks is where to look for\n * the code AROUND the change.\n */\n private sourceDirsFor(repoRoot: string, files: readonly string[]): string[] {\n const dirs = new Set<string>();\n for (const f of files) dirs.add(path.resolve(repoRoot, path.dirname(f)));\n return [...dirs].sort();\n }\n\n /**\n * The pre-resolved context list, from two config keys with deliberately different jobs:\n *\n * `reviewContextPackages` — installed packages, resolved to their real on-disk dir. This is what deletes\n * the repeated `node_modules/@webpieces` greps: the tooling knows where a package resolved to, and the\n * reviewer does not.\n * `reviewContext` — the repo-specific escape hatch (`{label, path}`) for what tooling cannot possibly\n * guess, e.g. \"queue names live in terraform/services/\".\n *\n * Neither ever drops an entry: an unresolvable package or a missing path is LISTED, with the reason. A\n * silently shorter list is indistinguishable from a complete one.\n */\n private contextEntries(repoRoot: string, config: PrGateConfig): ContextEntry[] {\n const entries: ContextEntry[] = [];\n for (const pkg of config.reviewContextPackages) entries.push(this.resolvePackage(repoRoot, pkg));\n for (const item of config.reviewContext) {\n const abs = path.resolve(repoRoot, item.path);\n entries.push(fs.existsSync(abs)\n ? new ContextEntry(item.label, abs)\n : new ContextEntry(item.label, '', `(configured as \"${item.path}\" but missing)`));\n }\n return entries;\n }\n\n private resolvePackage(repoRoot: string, pkg: string): ContextEntry {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unresolvable package is REPORTED as such, never fatal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const manifestPath = require.resolve(`${pkg}/package.json`, { paths: [repoRoot] });\n const dir = path.dirname(manifestPath);\n // webpieces-disable no-any-unknown -- opaque package.json, only `description` is read\n const meta = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as Record<string, unknown>;\n const desc = typeof meta['description'] === 'string' ? (meta['description'] as string) : '';\n return new ContextEntry(desc === '' ? pkg : `${pkg} — ${desc}`, dir);\n } catch (err: unknown) {\n const error = toError(err);\n void error; // an unresolvable package is REPORTED below, never fatal\n return new ContextEntry(pkg, '', '(not installed — configured in pr-gate.reviewContextPackages)');\n }\n }\n}\n"]}
1
+ {"version":3,"file":"reviewer-briefing-builder.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/reviewer-briefing-builder.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,0DAEiC;AACjC,yCAA2D;AAI3D;;;;;;GAMG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IACH;IAA7B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Ac,CAAC,QAAgB,EAAE,GAAW;QAChD,oHAAoH;QACpH,8DAA8D;QAC9D,IAAI,CAAC;YACD,MAAM,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,GAAG,eAAe,EAAE,EAAE,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YACnF,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YACvC,sFAAsF;YACtF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAA4B,CAAC;YAC1F,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAE,IAAI,CAAC,aAAa,CAAY,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5F,OAAO,IAAI,2BAAY,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,MAAM,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;QACzE,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,IAAA,sBAAO,EAAC,GAAG,CAAC,CAAC;YAC3B,KAAK,KAAK,CAAC,CAAC,yDAAyD;YACrE,OAAO,IAAI,2BAAY,CAAC,GAAG,EAAE,EAAE,EAAE,+DAA+D,CAAC,CAAC;QACtG,CAAC;IACL,CAAC;CACJ,CAAA;AAjIY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEW,gCAAiB;GADxD,uBAAuB,CAiInC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport {\n BriefedFile, ContextEntry, PrGateConfig, RequiredChecklist, ReviewerBriefing, ReviewJsonService, toError,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { DiffManifest, DiffManifestEntry } from './diff-materializer';\nimport { ChecklistScan } from './checklist-scanner';\n\n/**\n * Turns a {@link ChecklistScan} plus the materialized {@link DiffManifest} into one {@link ReviewerBriefing}\n * per reviewer — resolving every path to an absolute one, because a reviewer that has to resolve a path\n * ends up searching, and searching is the cost this whole feature exists to remove.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewerBriefingBuilder {\n constructor(private readonly reviewJsonService: ReviewJsonService) {}\n\n /** One briefing per checklist in `checklists` — the OWED ones; a carried verdict is not re-briefed. */\n // eslint-disable-next-line @typescript-eslint/max-params\n build(\n repoRoot: string, scan: ChecklistScan, checklists: readonly RequiredChecklist[], manifest: DiffManifest,\n diffDir: string, config: PrGateConfig,\n ): ReviewerBriefing[] {\n // Resolved ONCE for the whole run, not per reviewer: `require.resolve` hits the filesystem, and the\n // answer cannot differ between two reviewers in the same process.\n const shared = this.contextEntries(repoRoot, config);\n const entryByFile = new Map<string, DiffManifestEntry>();\n for (const e of manifest.entries) entryByFile.set(e.file, e);\n return checklists.map((req: RequiredChecklist): ReviewerBriefing =>\n this.one(repoRoot, req, scan, entryByFile, diffDir, shared, manifest));\n }\n\n // eslint-disable-next-line @typescript-eslint/max-params\n private one(\n repoRoot: string, req: RequiredChecklist, scan: ChecklistScan,\n entryByFile: Map<string, DiffManifestEntry>, diffDir: string, shared: ContextEntry[], manifest: DiffManifest,\n ): ReviewerBriefing {\n const b = new ReviewerBriefing(req.reviewer.agentName, req.id, repoRoot);\n b.docPath = req.doc.trim() === '' ? '' : path.resolve(repoRoot, req.doc);\n b.diffDir = diffDir;\n b.allDiffPath = diffDir === '' ? '' : path.join(diffDir, 'ALL.diff');\n b.manifestPath = diffDir === '' ? '' : path.join(diffDir, 'manifest.json');\n b.myFiles = req.matchedFiles.map((f: string): BriefedFile => this.briefedFile(repoRoot, f, entryByFile));\n b.matchedPatterns = req.matchedPatterns;\n b.required = req.required;\n b.sourceDirs = this.sourceDirsFor(repoRoot, req.matchedFiles);\n b.contextEntries = shared;\n b.fileDiffCommand = scan.context.fileDiffCommand;\n b.dirty = scan.basis.dirty;\n b.ownAgentFileInDiff = this.ownAgentFileIn(manifest, req.reviewer.agentName);\n this.copyManifestFacts(b, manifest);\n return b;\n }\n\n /**\n * One row of the reviewer's table. The SOURCE path comes over with the diff path because the two need\n * identical affordance: when the diff was an absolute path and the source was a parent directory, four of\n * four reviewers read the diff and none opened a source file.\n */\n private briefedFile(repoRoot: string, file: string, entryByFile: Map<string, DiffManifestEntry>): BriefedFile {\n const e = entryByFile.get(file);\n if (e === undefined) return new BriefedFile(file, '', path.resolve(repoRoot, file));\n return new BriefedFile(file, e.diffAbs, e.fileAbs, e.status, e.bytes, e.truncated);\n }\n\n /**\n * Manifest headline facts, copied onto the briefing so the instructions can state them INLINE. A reviewer\n * that never opens the manifest still has to learn whether anything was truncated or excluded — that is\n * precisely the thing it could not otherwise know it was missing.\n */\n private copyManifestFacts(b: ReviewerBriefing, manifest: DiffManifest): void {\n b.changedFileCount = manifest.entries.length;\n b.truncatedCount = manifest.entries.filter((e: DiffManifestEntry): boolean => e.truncated).length;\n b.excludedCount = manifest.excluded.length;\n b.allDiffLines = manifest.allDiffLines;\n b.allDiffBytes = manifest.allDiffBytes;\n b.hashForkPoint = manifest.hashForkPoint;\n b.hashFeatureHead = manifest.hashFeatureHead;\n b.hashMainHead = manifest.hashMainHead;\n }\n\n /**\n * The reviewer agent's own `.claude/agents/<agentName>.md`, when THIS diff changes it. Detected here rather than\n * left to the reviewer to notice: on the measured run two reviewers reviewed their own definition and\n * neither mentioned it, and every PR that edits the review gate reproduces that.\n */\n private ownAgentFileIn(manifest: DiffManifest, agentName: string): string {\n const suffix = path.join('.claude', 'agents', `${agentName}.md`);\n const hit = manifest.entries.find((e: DiffManifestEntry): boolean => e.file.split('/').join(path.sep).endsWith(suffix));\n return hit === undefined ? '' : (hit.fileAbs === '' ? hit.file : hit.fileAbs);\n }\n\n /**\n * Deduped absolute parent dirs of the matched files. Dirs rather than files because the point is to say\n * \"the neighbourhood is here\" — a reviewer already has the file list; what it lacks is where to look for\n * the code AROUND the change.\n */\n private sourceDirsFor(repoRoot: string, files: readonly string[]): string[] {\n const dirs = new Set<string>();\n for (const f of files) dirs.add(path.resolve(repoRoot, path.dirname(f)));\n return [...dirs].sort();\n }\n\n /**\n * The pre-resolved context list, from two config keys with deliberately different jobs:\n *\n * `reviewContextPackages` — installed packages, resolved to their real on-disk dir. This is what deletes\n * the repeated `node_modules/@webpieces` greps: the tooling knows where a package resolved to, and the\n * reviewer does not.\n * `reviewContext` — the repo-specific escape hatch (`{label, path}`) for what tooling cannot possibly\n * guess, e.g. \"queue names live in terraform/services/\".\n *\n * Neither ever drops an entry: an unresolvable package or a missing path is LISTED, with the reason. A\n * silently shorter list is indistinguishable from a complete one.\n */\n private contextEntries(repoRoot: string, config: PrGateConfig): ContextEntry[] {\n const entries: ContextEntry[] = [];\n for (const pkg of config.reviewContextPackages) entries.push(this.resolvePackage(repoRoot, pkg));\n for (const item of config.reviewContext) {\n const abs = path.resolve(repoRoot, item.path);\n entries.push(fs.existsSync(abs)\n ? new ContextEntry(item.label, abs)\n : new ContextEntry(item.label, '', `(configured as \"${item.path}\" but missing)`));\n }\n return entries;\n }\n\n private resolvePackage(repoRoot: string, pkg: string): ContextEntry {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unresolvable package is REPORTED as such, never fatal\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const manifestPath = require.resolve(`${pkg}/package.json`, { paths: [repoRoot] });\n const dir = path.dirname(manifestPath);\n // webpieces-disable no-any-unknown -- opaque package.json, only `description` is read\n const meta = JSON.parse(fs.readFileSync(manifestPath, 'utf8')) as Record<string, unknown>;\n const desc = typeof meta['description'] === 'string' ? (meta['description'] as string) : '';\n return new ContextEntry(desc === '' ? pkg : `${pkg} — ${desc}`, dir);\n } catch (err: unknown) {\n const error = toError(err);\n void error; // an unresolvable package is REPORTED below, never fatal\n return new ContextEntry(pkg, '', '(not installed — configured in pr-gate.reviewContextPackages)');\n }\n }\n}\n"]}