@webpieces/pr-gate 0.4.974 → 0.4.976
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -6
- package/src/scripts/commands/await-checks-command.d.ts +6 -3
- package/src/scripts/commands/await-checks-command.js +17 -12
- package/src/scripts/commands/await-checks-command.js.map +1 -1
- package/src/scripts/commands/await-reviews-command.d.ts +1 -1
- package/src/scripts/commands/await-reviews-command.js +3 -3
- package/src/scripts/commands/await-reviews-command.js.map +1 -1
- package/src/scripts/commands/check-pr-command.d.ts +3 -1
- package/src/scripts/commands/check-pr-command.js +12 -9
- package/src/scripts/commands/check-pr-command.js.map +1 -1
- package/src/scripts/commands/finish-push-dev-command.js +3 -4
- package/src/scripts/commands/finish-push-dev-command.js.map +1 -1
- package/src/scripts/commands/finish-update-command.js +1 -1
- package/src/scripts/commands/finish-update-command.js.map +1 -1
- package/src/scripts/commands/finish-upsert-pr-command.d.ts +4 -1
- package/src/scripts/commands/finish-upsert-pr-command.js +65 -62
- package/src/scripts/commands/finish-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/human-post-pr-command.d.ts +8 -6
- package/src/scripts/commands/human-post-pr-command.js +32 -31
- package/src/scripts/commands/human-post-pr-command.js.map +1 -1
- package/src/scripts/commands/land-pr-command.d.ts +5 -1
- package/src/scripts/commands/land-pr-command.js +36 -22
- package/src/scripts/commands/land-pr-command.js.map +1 -1
- package/src/scripts/commands/main-checkout.d.ts +4 -1
- package/src/scripts/commands/main-checkout.js +22 -22
- package/src/scripts/commands/main-checkout.js.map +1 -1
- package/src/scripts/commands/push-dev-command.js +28 -29
- package/src/scripts/commands/push-dev-command.js.map +1 -1
- package/src/scripts/commands/review-upsert-pr-command.js +9 -9
- package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/start-update-command.d.ts +1 -1
- package/src/scripts/commands/start-update-command.js +3 -3
- package/src/scripts/commands/start-update-command.js.map +1 -1
- package/src/scripts/commands/start-upsert-pr-command.js +4 -4
- package/src/scripts/commands/start-upsert-pr-command.js.map +1 -1
- package/src/scripts/commands/sync-main-command.js +2 -2
- package/src/scripts/commands/sync-main-command.js.map +1 -1
- package/src/scripts/commands/upsert-hotfix-pr-command.d.ts +6 -4
- package/src/scripts/commands/upsert-hotfix-pr-command.js +46 -43
- package/src/scripts/commands/upsert-hotfix-pr-command.js.map +1 -1
- package/src/scripts/commands/working-tree-gate.d.ts +4 -1
- package/src/scripts/commands/working-tree-gate.js +14 -11
- package/src/scripts/commands/working-tree-gate.js.map +1 -1
- package/src/scripts/commands/write-review-command.js +4 -6
- package/src/scripts/commands/write-review-command.js.map +1 -1
- package/src/scripts/commands/write-review-fixes-command.js +3 -4
- package/src/scripts/commands/write-review-fixes-command.js.map +1 -1
- package/src/scripts/git-finishUpsertPr.js +2 -2
- package/src/scripts/git-finishUpsertPr.js.map +1 -1
- package/src/scripts/git-gatherInfo.js +6 -7
- package/src/scripts/git-gatherInfo.js.map +1 -1
- package/src/scripts/pr-gate-container.d.ts +9 -0
- package/src/scripts/pr-gate-container.js +19 -0
- package/src/scripts/pr-gate-container.js.map +1 -0
- package/src/scripts/workflow/await-loop.d.ts +1 -1
- package/src/scripts/workflow/await-loop.js +1 -1
- package/src/scripts/workflow/await-loop.js.map +1 -1
- package/src/scripts/workflow/build-affected.js +1 -1
- package/src/scripts/workflow/build-affected.js.map +1 -1
- package/src/scripts/workflow/build-artifact-gate.d.ts +1 -1
- package/src/scripts/workflow/build-artifact-gate.js +3 -3
- package/src/scripts/workflow/build-artifact-gate.js.map +1 -1
- package/src/scripts/workflow/build-gate-log.d.ts +9 -6
- package/src/scripts/workflow/build-gate-log.js +34 -40
- package/src/scripts/workflow/build-gate-log.js.map +1 -1
- package/src/scripts/workflow/checklist-scanner.d.ts +1 -1
- package/src/scripts/workflow/checklist-scanner.js +8 -8
- package/src/scripts/workflow/checklist-scanner.js.map +1 -1
- package/src/scripts/workflow/checklist-scope-hasher.d.ts +1 -1
- package/src/scripts/workflow/checklist-scope-hasher.js +2 -2
- package/src/scripts/workflow/checklist-scope-hasher.js.map +1 -1
- package/src/scripts/workflow/dev-deploy-refs.d.ts +5 -5
- package/src/scripts/workflow/dev-deploy-refs.js +8 -8
- package/src/scripts/workflow/dev-deploy-refs.js.map +1 -1
- package/src/scripts/workflow/dev-resolve-runner.d.ts +3 -3
- package/src/scripts/workflow/dev-resolve-runner.js +30 -30
- package/src/scripts/workflow/dev-resolve-runner.js.map +1 -1
- package/src/scripts/workflow/diff-basis.d.ts +4 -2
- package/src/scripts/workflow/diff-basis.js +18 -15
- package/src/scripts/workflow/diff-basis.js.map +1 -1
- package/src/scripts/workflow/diff-materializer.d.ts +5 -3
- package/src/scripts/workflow/diff-materializer.js +18 -15
- package/src/scripts/workflow/diff-materializer.js.map +1 -1
- package/src/scripts/workflow/gated-pr-publisher.d.ts +8 -6
- package/src/scripts/workflow/gated-pr-publisher.js +23 -22
- package/src/scripts/workflow/gated-pr-publisher.js.map +1 -1
- package/src/scripts/workflow/generated-artifact-registry.d.ts +4 -2
- package/src/scripts/workflow/generated-artifact-registry.js +11 -8
- package/src/scripts/workflow/generated-artifact-registry.js.map +1 -1
- package/src/scripts/workflow/git-exec.d.ts +22 -12
- package/src/scripts/workflow/git-exec.js +45 -29
- package/src/scripts/workflow/git-exec.js.map +1 -1
- package/src/scripts/workflow/git-findForkPoint.d.ts +6 -2
- package/src/scripts/workflow/git-findForkPoint.js +31 -23
- package/src/scripts/workflow/git-findForkPoint.js.map +1 -1
- package/src/scripts/workflow/git-readAiBranchName.d.ts +4 -2
- package/src/scripts/workflow/git-readAiBranchName.js +8 -5
- package/src/scripts/workflow/git-readAiBranchName.js.map +1 -1
- package/src/scripts/workflow/hotfix-pr-publisher.d.ts +4 -3
- package/src/scripts/workflow/hotfix-pr-publisher.js +7 -6
- package/src/scripts/workflow/hotfix-pr-publisher.js.map +1 -1
- package/src/scripts/workflow/landed-tree-resolver.d.ts +4 -2
- package/src/scripts/workflow/landed-tree-resolver.js +11 -8
- package/src/scripts/workflow/landed-tree-resolver.js.map +1 -1
- package/src/scripts/workflow/landed-worktree-reaper.d.ts +4 -2
- package/src/scripts/workflow/landed-worktree-reaper.js +12 -9
- package/src/scripts/workflow/landed-worktree-reaper.js.map +1 -1
- package/src/scripts/workflow/merge-end.d.ts +2 -2
- package/src/scripts/workflow/merge-end.js +22 -24
- package/src/scripts/workflow/merge-end.js.map +1 -1
- package/src/scripts/workflow/merge-start.d.ts +5 -1
- package/src/scripts/workflow/merge-start.js +56 -49
- package/src/scripts/workflow/merge-start.js.map +1 -1
- package/src/scripts/workflow/open-pr-check.d.ts +4 -2
- package/src/scripts/workflow/open-pr-check.js +11 -8
- package/src/scripts/workflow/open-pr-check.js.map +1 -1
- package/src/scripts/workflow/pr-comment-upserter.d.ts +5 -3
- package/src/scripts/workflow/pr-comment-upserter.js +15 -14
- package/src/scripts/workflow/pr-comment-upserter.js.map +1 -1
- package/src/scripts/workflow/pr-merger.d.ts +8 -5
- package/src/scripts/workflow/pr-merger.js +32 -27
- package/src/scripts/workflow/pr-merger.js.map +1 -1
- package/src/scripts/workflow/provenance-enforcer.d.ts +4 -2
- package/src/scripts/workflow/provenance-enforcer.js +19 -17
- package/src/scripts/workflow/provenance-enforcer.js.map +1 -1
- package/src/scripts/workflow/review-round-state.d.ts +7 -6
- package/src/scripts/workflow/review-round-state.js +33 -38
- package/src/scripts/workflow/review-round-state.js.map +1 -1
- package/src/scripts/workflow/run-update.js +1 -1
- package/src/scripts/workflow/run-update.js.map +1 -1
- package/src/scripts/workflow/squash-settings-enforcer.d.ts +6 -3
- package/src/scripts/workflow/squash-settings-enforcer.js +19 -14
- package/src/scripts/workflow/squash-settings-enforcer.js.map +1 -1
- package/src/scripts/wp-await-checks.js +2 -2
- package/src/scripts/wp-await-checks.js.map +1 -1
- package/src/scripts/wp-await-reviews.js +2 -2
- package/src/scripts/wp-await-reviews.js.map +1 -1
- package/src/scripts/wp-build.js +2 -2
- package/src/scripts/wp-build.js.map +1 -1
- package/src/scripts/wp-check-pr.js +2 -2
- package/src/scripts/wp-check-pr.js.map +1 -1
- package/src/scripts/wp-cleanup.js +2 -2
- package/src/scripts/wp-cleanup.js.map +1 -1
- package/src/scripts/wp-finish-push-dev.js +2 -2
- package/src/scripts/wp-finish-push-dev.js.map +1 -1
- package/src/scripts/wp-finish-update.js +2 -2
- package/src/scripts/wp-finish-update.js.map +1 -1
- package/src/scripts/wp-human-post-pr.js +2 -2
- package/src/scripts/wp-human-post-pr.js.map +1 -1
- package/src/scripts/wp-land-pr.js +2 -2
- package/src/scripts/wp-land-pr.js.map +1 -1
- package/src/scripts/wp-push-dev.js +2 -2
- package/src/scripts/wp-push-dev.js.map +1 -1
- package/src/scripts/wp-reap-worktree.js +2 -2
- package/src/scripts/wp-reap-worktree.js.map +1 -1
- package/src/scripts/wp-review-upsert-pr.js +2 -2
- package/src/scripts/wp-review-upsert-pr.js.map +1 -1
- package/src/scripts/wp-start-update.js +2 -2
- package/src/scripts/wp-start-update.js.map +1 -1
- package/src/scripts/wp-start-upsert-pr.js +2 -2
- package/src/scripts/wp-start-upsert-pr.js.map +1 -1
- package/src/scripts/wp-sync-main.js +2 -2
- package/src/scripts/wp-sync-main.js.map +1 -1
- package/src/scripts/wp-upsert-hotfix-pr.js +2 -2
- package/src/scripts/wp-upsert-hotfix-pr.js.map +1 -1
- package/src/scripts/wp-write-review-fixes.js +2 -2
- package/src/scripts/wp-write-review-fixes.js.map +1 -1
- package/src/scripts/wp-write-review.js +2 -2
- package/src/scripts/wp-write-review.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provenance-enforcer.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/provenance-enforcer.ts"],"names":[],"mappings":";;;;AAAA,iDAA0C;AAC1C,+CAAyB;AACzB,mDAA6B;AAC7B,0DAAkZ;AAClZ,8DAAkG;AAClG,yCAA2D;AAC3D,iEA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OAAO,KAAK,CAAC;QAC7C,OAAO,CAAC,MAAM,CAAC,KAAK,CAChB,SAAS,KAAK,CAAC,MAAM,8EAA8E,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YACvH,yGAAyG,CAAC,CAAC;QAC/G,OAAO,EAAE,CAAC;IACd,CAAC;CACJ,CAAA;AA7QY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAIF,mCAAY;QACd,wCAAyB;QACnB,sCAAuB;QACnB,0CAA2B;QAC9B,gCAAiB;QACjB,6CAAwB;GARvD,kBAAkB,CA6Q9B","sourcesContent":["import { spawnSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { prDirFor, summaryJsonPath, RequiredChecklist, PrGateConfig, ReviewJsonService, SubagentProvenanceService, PROVENANCE_OK, PROVENANCE_MISSING, PROVENANCE_SKIPPED, ProvenanceResult, ReviewerEvidence, ReviewerContext, ExpectedReviewer, ReviewProvenanceService, ProvenanceWriteRequest, ReviewerTranscript, ReviewerPaths, OfferedContext, ReviewerInstructionsService } from '@webpieces/rules-config';\nimport { InformAiError, claudeConfigDir, CLAUDE_CONFIG_DIR_ENV } from '@webpieces/tooling-common';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from './git-readAiBranchName';\nimport { VerdictProvenanceService } from './verdict-provenance';\n\n/**\n * The provenance outcome: whether each reviewer was VERIFIED to have run (the integrity check, which\n * blocks) plus what each one actually read (the quality signal, which is published). Data-only.\n */\nexport class ProvenanceReport {\n verified: boolean;\n evidence: ReviewerEvidence[];\n\n constructor(verified: boolean, evidence: ReviewerEvidence[]) {\n this.verified = verified;\n this.evidence = evidence;\n }\n}\n\n/**\n * Proves each checklist verdict came from an independently-run reviewer subagent, and records what\n * each one read.\n *\n * Split out of FinishUpsertPrCommand when that file crossed the 700-line cap, and it is the right seam\n * twice over: this is a self-contained integrity check with its own spec\n * (`finish-provenance-record.spec.ts`), and that spec previously had to reach through\n * `command as unknown as { enforceProvenance(...) }` to get at it. Now `enforce` is simply public.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is drawn in the DI design and injected by type.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ProvenanceEnforcer {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n private readonly aiBranchName: AiBranchName,\n private readonly provenance: SubagentProvenanceService,\n private readonly provenanceRecord: ReviewProvenanceService,\n private readonly reviewerInstructions: ReviewerInstructionsService,\n private readonly reviewJsonService: ReviewJsonService,\n private readonly verdictProvenance: VerdictProvenanceService,\n ) {}\n\n /**\n * Archive this round's provenance.json alongside the archived summary.json, so an archived review keeps\n * the transcript links belonging to the round that produced it — a record overwritten by the NEXT\n * round audits nothing.\n *\n * Here rather than in the command because this class owns the record; the command only knows WHEN to\n * archive, not what the record is.\n */\n archiveRecord(prDir: string): void {\n this.provenanceRecord.archive(prDir);\n }\n\n // HEAD sha for the audit record. Failure-tolerant ('' rather than a throw): a missing sha degrades\n // the audit trail, and refusing a PR over it would be the wrong trade — see writeProvenanceRecord.\n private gitOut(args: string[]): string {\n const result = spawnSync('git', args, { encoding: 'utf8' });\n return result.status === 0 ? (result.stdout ?? '').trim() : '';\n }\n\n // Enforce that EACH matched checklist was reviewed by a real reviewer SUBAGENT — the coding agent may\n // not self-certify. Not by one of a particular NAME: see SubagentProvenanceService.isReviewerRun. One run may cover several checklists, because `reviewerAgents` is a\n // required CAP and grouping under it is what the repo configured. A verified set passes silently; any\n // missing reviewer throws so the PR does not open.\n //\n // No Claude session id (Codex, a plain terminal) is NOT a pass on integrity any more (issue #863): by\n // the time this runs the checklist scan has already REJECTED every verdict that `wp-write-review` did\n // not write for a reviewer subagent. What is skipped is only the transcript evidence, and the audit\n // record is filled from the bin's provenance instead — so a Codex reviewer's identity is recorded too.\n // eslint-disable-next-line @typescript-eslint/max-params\n enforce(required: readonly RequiredChecklist[], branch: string, repoRoot: string, config: PrGateConfig): ProvenanceReport {\n const report = new ProvenanceReport(true, []); // no reviewers to verify ⇒ vacuously verified\n // Defense in depth: the scanner normally hands finish an empty set under this project policy, but\n // provenance must never resurrect a reviewer requirement if a caller still passes matched checklists.\n const enforced = config.reviewer.maxAgents === 0 ? [] : required;\n const expected = enforced\n .filter((r: RequiredChecklist): boolean => r.reviewer.agentName.trim() !== '')\n .map((r: RequiredChecklist): ExpectedReviewer => new ExpectedReviewer(r.id, r.reviewer.agentName.trim()));\n const context = this.contextFor(repoRoot, enforced, branch);\n // verifyReviewers short-circuits to OK on an empty set, so this runs unconditionally: a repo with no\n // checklists still gets a provenance record naming the session and the main agent's own transcript.\n const result = this.provenance.verifyReviewers(expected, context);\n report.verified = result.status === PROVENANCE_OK;\n if (result.status === PROVENANCE_SKIPPED) process.stderr.write(`⚠️ ${result.detail}\\n`);\n const skipped = result.status === PROVENANCE_SKIPPED;\n report.evidence = skipped\n ? this.binEvidence(repoRoot, expected)\n : this.provenance.evidenceFor(context, expected, result.agentIds);\n // Bin evidence says WHO submitted, not what they read, so it cannot be judged blind.\n const blind = skipped ? [] : this.blindReviewers(report.evidence, config);\n // BEFORE the throw below, deliberately. A refused round is the one most worth auditing, and a record\n // that only ever appeared on success could not answer what the reviewers did the time it was refused.\n this.writeProvenanceRecord(repoRoot, enforced, result, report.evidence);\n this.refuse(result, blind, context);\n return report;\n }\n\n /**\n * Evidence from `review-round<N>-<id>.provenance.json` when there are no Claude transcripts to read: the harness,\n * session and agent `wp-write-review` recorded. Read-counters stay at zero — the bin cannot know them.\n */\n private binEvidence(repoRoot: string, expected: readonly ExpectedReviewer[]): ReviewerEvidence[] {\n const summaryPath = summaryJsonPath(repoRoot, this.aiBranchName.getFeatureName());\n const out: ReviewerEvidence[] = [];\n for (const want of expected) {\n const record = this.verdictProvenance.read(summaryPath, want.checklistId, this.reviewJsonService.latestVerdictRound(summaryPath, want.checklistId));\n if (record === null) continue;\n out.push(new ReviewerEvidence(\n want.checklistId, record.agentType === '' ? want.agentType : record.agentType, record.agentId));\n }\n return out;\n }\n\n /**\n * Refuse — with an instruction that matches WHICH failure this is.\n *\n * The count is the number of CHECKLISTS at fault, not the number of message paragraphs. It used to be\n * `errors.length`, which printed \"1 checklist(s) require …\" above a list of seven names.\n *\n * The split matters more than the count. A checklist with no verdict file needs a reviewer spawned. A\n * checklist WITH one needs the opposite: the reviewer already ran, the verdict is on disk, and only the\n * attribution failed — so telling an agent to \"spawn each as its OWN subagent\" makes it overwrite seven\n * verdicts with runs that are stamped identically and refused identically. That is a loop that destroys\n * evidence on every iteration, and it is what the previous single message guaranteed.\n *\n * The BLOCK decision is the STATUS, not the length of `missing`. Those agree today — but a\n * `PROVENANCE_MISSING` that arrived carrying no names would otherwise be a silent pass: reported\n * unverified and refused by nothing. Refusing on the status makes the unverified verdict block whatever\n * else is true, and `detail` carries the wording when there are no names to word it from.\n */\n private refuse(result: ProvenanceResult, blind: readonly string[], context: ReviewerContext): void {\n const missing = result.missing;\n const neverRan = missing.filter((t: string): boolean => !fs.existsSync(context.verdictPaths[t] ?? ''));\n const unattributed = missing.filter((t: string): boolean => fs.existsSync(context.verdictPaths[t] ?? ''));\n const paragraphs: string[] = [];\n if (result.status === PROVENANCE_MISSING && missing.length === 0) paragraphs.push(result.detail);\n if (neverRan.length > 0) {\n paragraphs.push(\n 'no reviewer subagent ran on this branch for these checklists (spawn the reviewer agent that ' +\n `pnpm wp-review-upsert-pr names — do not self-certify): ${neverRan.join(', ')}`);\n }\n if (unattributed.length > 0) paragraphs.push(this.unattributedMessage(unattributed, context));\n if (blind.length > 0) {\n paragraphs.push(`these reviewers wrote a verdict without opening the diff (pr-gate.requireDiffEvidence is on): ${blind.join(', ')}`);\n }\n if (paragraphs.length === 0) return;\n // The UNION, because one checklist can be both unattributed and blind, and counting the paragraphs\n // is what printed \"1 checklist(s) require …\" above a list of seven names. Floored at 1 so the\n // nameless-MISSING case above cannot announce \"0 checklist(s) failed\" and then refuse.\n const atFault = Math.max(new Set([...missing, ...blind]).size, 1);\n throw new InformAiError(\n `${atFault} checklist(s) failed the reviewer-provenance check — fix, then re-run pnpm wp-finish-upsert-pr:\\n\\n` +\n paragraphs.map((e: string): string => ` • ${e}`).join('\\n\\n'));\n }\n\n /**\n * The verdict exists but nothing can prove WHICH branch its reviewer looked at — or, in the one case\n * below, provenance never found the session's transcripts AT ALL and this is not about reviewers.\n *\n * The re-spawn warning stays, scoped to what is TRUE: a round's verdict is never overwritten\n * (wp-write-review refuses a second one), so a re-spawn into this round records nothing. What the\n * message no longer says is that the reviewer is unrecoverable (issue #1211). It used to, and that was\n * false for the case that hit it: the reviewer HAD read the diff (relative to its repo-root cwd) and HAD\n * submitted through wp-write-review — provenance just did not look at either. Both are credit channels\n * now, so when this prints, the message names exactly which proofs were missing, and that a reviewer\n * which reads the diff dir or submits through wp-write-review in a later round IS credited.\n *\n * The cwd option stays too: a reviewer stamped with a pinned worktree cwd on this branch is credited\n * on the stamp alone. It is GATED on having found the session, because it was printed for a completely\n * different fault and sent two debugging rounds in the wrong direction: see {@link transcriptRootProblem}.\n */\n private unattributedMessage(unattributed: readonly string[], context: ReviewerContext): string {\n const head = `these reviewers WROTE a verdict for this branch that provenance cannot attribute to them: ${unattributed.join(', ')}\\n` +\n ` Do NOT re-spawn them into this round: a round's verdict is never overwritten (wp-write-review refuses\\n` +\n ` a second one), so a re-spawn records nothing and cannot change the outcome.\\n`;\n const rootProblem = this.transcriptRootProblem();\n if (rootProblem !== '') return head + rootProblem;\n return head +\n ` WHY: each one's harness branch stamp is not ${context.branch}, and its transcript holds none of the\\n` +\n ` three branch-specific proofs — it never named its verdict (${context.verdictPaths[unattributed[0]] ?? '<verdict path>'}),\\n` +\n ` never read the extracted diff (${context.diffDir}, absolute or relative to its own cwd),\\n` +\n ` and no pnpm wp-write-review call of its own matches the agent this branch's verdict provenance records.\\n` +\n ` It is not unrecoverable: a reviewer in a later round that reads that diff dir or submits through\\n` +\n ` pnpm wp-write-review IS credited wherever it was spawned from, and so is one spawned by a Claude Code\\n` +\n ` session whose cwd IS the worktree holding ${context.branch}.`;\n }\n\n /**\n * The transcript ROOT is wrong — said so, instead of blaming the reviewers. '' when it is not.\n *\n * The test is exact rather than heuristic: the main agent's transcript is located by SESSION ID alone,\n * with no cwd, branch or stamping involved, so a known session id with no transcript anywhere can only\n * mean nothing was searched in the right place. That is a transcript-location problem, and it is not\n * something a reviewer did.\n *\n * It happened, and the cost was the whole point of gating the other message: on a machine with\n * `$CLAUDE_CONFIG_DIR` relocated, provenance searched a hardcoded `~/.claude`, found neither the\n * reviewers' transcripts nor the main agent's, and refused every PR with advice about cwd stamping,\n * worktrees and primary clones — none of which was involved. Two debugging rounds went into that\n * before `provenance.json`'s empty `mainTranscript` settled it.\n */\n private transcriptRootProblem(): string {\n const session = this.provenanceRecord.sessionId();\n if (session === '' || this.provenanceRecord.mainTranscript() !== '') return '';\n const configured = claudeConfigDir.configuredDir();\n return ` Provenance found NO transcripts at all for session ${session} — not even the main agent's own — under:\\n` +\n claudeConfigDir.projectsRoots().map((root: string): string => ` ${root}\\n`).join('') +\n ` $${CLAUDE_CONFIG_DIR_ENV}=${configured === '' ? '<unset>' : configured}. This is a transcript-LOCATION problem, not a\\n` +\n ` reviewer problem — your reviewers' verdicts are intact and must not be re-run. Point this command at the\\n` +\n ` config dir that session wrote to.`;\n }\n\n /**\n * WHERE this branch's review materials live — the paths BOTH provenance passes compare against.\n *\n * One object for crediting and for evidence: they ask different questions of the same files, and\n * building the paths twice is how the two could drift apart.\n */\n private contextFor(repoRoot: string, required: readonly RequiredChecklist[], branch: string): ReviewerContext {\n const featureName = this.aiBranchName.getFeatureName();\n const summaryPath = summaryJsonPath(repoRoot, featureName);\n const docPaths: Record<string, string> = {};\n const verdictPaths: Record<string, string> = {};\n const submittedBy: Record<string, string> = {};\n for (const req of required) {\n docPaths[req.id] = req.doc.trim() === '' ? '' : path.resolve(repoRoot, req.doc);\n verdictPaths[req.id] = this.reviewJsonService.latestChecklistResultPath(summaryPath, req.id);\n // WHO wp-write-review recorded as this branch's submitter — what ties a transcript's\n // `wp-write-review --checklist <id>` call to THIS branch (see ReviewerContext.submittedBy).\n const record = this.verdictProvenance.read(summaryPath, req.id, this.reviewJsonService.latestVerdictRound(summaryPath, req.id));\n if (record !== null && record.agentId.trim() !== '') submittedBy[req.id] = record.agentId;\n }\n return new ReviewerContext(branch, path.join(prDirFor(repoRoot, featureName), 'diff'), docPaths, verdictPaths, submittedBy);\n }\n\n /**\n * Write this round's audit record: `.webpieces/pr-review/<featureSlug>/provenance.json`, linking each\n * verdict to the transcript of the subagent that produced it.\n *\n * `<featureSlug>`, not `<branch>`: the dir is named by `AiBranchName.getFeatureName()`, which\n * dash-sanitizes the branch. Calling it `<branch>` is what led a bug reporter to conclude the gate\n * must be comparing a dash-form name against a slash-form git branch — see\n * ProvenanceWriteRequest.featureSlug, whose field carried the same mislabel.\n *\n * A SEPARATE file rather than a field inside summary.json / review-round<N>-<id>.json, for two reasons. The\n * reviewer cannot supply this itself — a subagent's environment exposes the PARENT session id and no\n * agent id, so a self-reported transcript link would be invented — and keeping the AI-authored files\n * byte-untouched means nothing in the record can be mistaken for something a reviewer claimed about\n * itself. Every path here is derived by the tooling from the harness's own artifacts.\n *\n * Never fatal: an unwritable record is a lost audit trail, not a reason to refuse a PR.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private writeProvenanceRecord(repoRoot: string, required: readonly RequiredChecklist[], result: ProvenanceResult, evidence: readonly ReviewerEvidence[]): void {\n const featureName = this.aiBranchName.getFeatureName();\n const prDir = prDirFor(repoRoot, featureName);\n const request = new ProvenanceWriteRequest(prDir, featureName, this.gitOut(['rev-parse', 'HEAD']), result.status);\n request.offered = new OfferedContext(\n path.join(prDir, 'diff'), this.reviewerInstructions.instructionsDirFor(repoRoot, featureName));\n request.reviewers = evidence.map((e: ReviewerEvidence): ReviewerTranscript =>\n new ReviewerTranscript(e, this.reviewerPathsFor(repoRoot, featureName, required, e.checklistId)));\n const written = this.provenanceRecord.write(request);\n if (written !== '') process.stdout.write(` transcript provenance → ${written}\\n`);\n }\n\n // Where ONE checklist's verdict, instructions and doc live — keyed by the checklist id, never by the\n // agent type, which every checklist now shares.\n // eslint-disable-next-line @typescript-eslint/max-params\n private reviewerPathsFor(repoRoot: string, featureName: string, required: readonly RequiredChecklist[], checklistId: string): ReviewerPaths {\n const req = required.find((r: RequiredChecklist): boolean => r.id === checklistId);\n const doc = req !== undefined && req.doc.trim() !== '' ? path.resolve(repoRoot, req.doc) : '';\n return new ReviewerPaths(\n this.reviewJsonService.latestChecklistResultPath(summaryJsonPath(repoRoot, featureName), checklistId),\n this.reviewerInstructions.pathFor(repoRoot, featureName, checklistId),\n doc,\n );\n }\n\n /**\n * The reviewers that wrote a verdict without opening the diff — WARNED about (default) or returned for\n * {@link refuse} to block on (opt-in).\n *\n * Default-warn because the signal is derived from undocumented Claude Code transcript internals: if the\n * format shifts, a blocking check wedges every PR in every consumer repo with no self-service recovery.\n * `requireDiffEvidence` lets a repo that has watched the warning promote it deliberately.\n *\n * Returns the checklist ids rather than a finished sentence so the caller can count CHECKLISTS at fault —\n * a name can appear in this list and in `missing`, and it must be one checklist in the total, not two.\n */\n private blindReviewers(evidence: readonly ReviewerEvidence[], config: PrGateConfig): string[] {\n const blind = evidence.filter((e: ReviewerEvidence): boolean => !e.readDiff);\n if (blind.length === 0) return [];\n const names = blind.map((e: ReviewerEvidence): string => e.checklistId);\n if (config.requireDiffEvidence) return names;\n process.stderr.write(\n `\\n⚠️ ${blind.length} reviewer(s) wrote a verdict with no record of opening the extracted diff: ${names.join(', ')}\\n` +\n ' Published on the PR as a note. Not blocking — set pr-gate.requireDiffEvidence:true to make it one.\\n');\n return [];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"provenance-enforcer.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/provenance-enforcer.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,0DAAkZ;AAClZ,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G,KAAK,CAAC,GAAG,CAAC,CAAC,CAAmB,EAAU,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QACxE,IAAI,MAAM,CAAC,mBAAmB;YAAE,OAAO,KAAK,CAAC;QAC7C,OAAO,CAAC,MAAM,CAAC,KAAK,CAChB,SAAS,KAAK,CAAC,MAAM,8EAA8E,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YACvH,yGAAyG,CAAC,CAAC;QAC/G,OAAO,EAAE,CAAC;IACd,CAAC;CACJ,CAAA;AA9QY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAIF,mCAAY;QACd,wCAAyB;QACnB,sCAAuB;QACnB,0CAA2B;QAC9B,gCAAiB;QACjB,6CAAwB;QACtC,8BAAa;GAT9B,kBAAkB,CA8Q9B","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { prDirFor, summaryJsonPath, RequiredChecklist, PrGateConfig, ReviewJsonService, SubagentProvenanceService, PROVENANCE_OK, PROVENANCE_MISSING, PROVENANCE_SKIPPED, ProvenanceResult, ReviewerEvidence, ReviewerContext, ExpectedReviewer, ReviewProvenanceService, ProvenanceWriteRequest, ReviewerTranscript, ReviewerPaths, OfferedContext, ReviewerInstructionsService } from '@webpieces/rules-config';\nimport { InformAiError, claudeConfigDir, CLAUDE_CONFIG_DIR_ENV, GitProcessApi } from '@webpieces/tooling-common';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from './git-readAiBranchName';\nimport { VerdictProvenanceService } from './verdict-provenance';\n\n/**\n * The provenance outcome: whether each reviewer was VERIFIED to have run (the integrity check, which\n * blocks) plus what each one actually read (the quality signal, which is published). Data-only.\n */\nexport class ProvenanceReport {\n verified: boolean;\n evidence: ReviewerEvidence[];\n\n constructor(verified: boolean, evidence: ReviewerEvidence[]) {\n this.verified = verified;\n this.evidence = evidence;\n }\n}\n\n/**\n * Proves each checklist verdict came from an independently-run reviewer subagent, and records what\n * each one read.\n *\n * Split out of FinishUpsertPrCommand when that file crossed the 700-line cap, and it is the right seam\n * twice over: this is a self-contained integrity check with its own spec\n * (`finish-provenance-record.spec.ts`), and that spec previously had to reach through\n * `command as unknown as { enforceProvenance(...) }` to get at it. Now `enforce` is simply public.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is drawn in the DI design and injected by type.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ProvenanceEnforcer {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n private readonly aiBranchName: AiBranchName,\n private readonly provenance: SubagentProvenanceService,\n private readonly provenanceRecord: ReviewProvenanceService,\n private readonly reviewerInstructions: ReviewerInstructionsService,\n private readonly reviewJsonService: ReviewJsonService,\n private readonly verdictProvenance: VerdictProvenanceService,\n private readonly git: GitProcessApi,\n ) {}\n\n /**\n * Archive this round's provenance.json alongside the archived summary.json, so an archived review keeps\n * the transcript links belonging to the round that produced it — a record overwritten by the NEXT\n * round audits nothing.\n *\n * Here rather than in the command because this class owns the record; the command only knows WHEN to\n * archive, not what the record is.\n */\n archiveRecord(prDir: string): void {\n this.provenanceRecord.archive(prDir);\n }\n\n // HEAD sha for the audit record. Failure-tolerant ('' rather than a throw): a missing sha degrades\n // the audit trail, and refusing a PR over it would be the wrong trade — see writeProvenanceRecord.\n private async gitOut(args: string[]): Promise<string> {\n const result = await this.git.run(args);\n return result.ok ? result.stdout.trim() : '';\n }\n\n // Enforce that EACH matched checklist was reviewed by a real reviewer SUBAGENT — the coding agent may\n // not self-certify. Not by one of a particular NAME: see SubagentProvenanceService.isReviewerRun. One run may cover several checklists, because `reviewerAgents` is a\n // required CAP and grouping under it is what the repo configured. A verified set passes silently; any\n // missing reviewer throws so the PR does not open.\n //\n // No Claude session id (Codex, a plain terminal) is NOT a pass on integrity any more (issue #863): by\n // the time this runs the checklist scan has already REJECTED every verdict that `wp-write-review` did\n // not write for a reviewer subagent. What is skipped is only the transcript evidence, and the audit\n // record is filled from the bin's provenance instead — so a Codex reviewer's identity is recorded too.\n // eslint-disable-next-line @typescript-eslint/max-params\n async enforce(required: readonly RequiredChecklist[], branch: string, repoRoot: string, config: PrGateConfig): Promise<ProvenanceReport> {\n const report = new ProvenanceReport(true, []); // no reviewers to verify ⇒ vacuously verified\n // Defense in depth: the scanner normally hands finish an empty set under this project policy, but\n // provenance must never resurrect a reviewer requirement if a caller still passes matched checklists.\n const enforced = config.reviewer.maxAgents === 0 ? [] : required;\n const expected = enforced\n .filter((r: RequiredChecklist): boolean => r.reviewer.agentName.trim() !== '')\n .map((r: RequiredChecklist): ExpectedReviewer => new ExpectedReviewer(r.id, r.reviewer.agentName.trim()));\n const context = await this.contextFor(repoRoot, enforced, branch);\n // verifyReviewers short-circuits to OK on an empty set, so this runs unconditionally: a repo with no\n // checklists still gets a provenance record naming the session and the main agent's own transcript.\n const result = this.provenance.verifyReviewers(expected, context);\n report.verified = result.status === PROVENANCE_OK;\n if (result.status === PROVENANCE_SKIPPED) process.stderr.write(`⚠️ ${result.detail}\\n`);\n const skipped = result.status === PROVENANCE_SKIPPED;\n report.evidence = skipped\n ? await this.binEvidence(repoRoot, expected)\n : this.provenance.evidenceFor(context, expected, result.agentIds);\n // Bin evidence says WHO submitted, not what they read, so it cannot be judged blind.\n const blind = skipped ? [] : this.blindReviewers(report.evidence, config);\n // BEFORE the throw below, deliberately. A refused round is the one most worth auditing, and a record\n // that only ever appeared on success could not answer what the reviewers did the time it was refused.\n await this.writeProvenanceRecord(repoRoot, enforced, result, report.evidence);\n this.refuse(result, blind, context);\n return report;\n }\n\n /**\n * Evidence from `review-round<N>-<id>.provenance.json` when there are no Claude transcripts to read: the harness,\n * session and agent `wp-write-review` recorded. Read-counters stay at zero — the bin cannot know them.\n */\n private async binEvidence(repoRoot: string, expected: readonly ExpectedReviewer[]): Promise<ReviewerEvidence[]> {\n const summaryPath = summaryJsonPath(repoRoot, await this.aiBranchName.getFeatureName());\n const out: ReviewerEvidence[] = [];\n for (const want of expected) {\n const record = this.verdictProvenance.read(summaryPath, want.checklistId, this.reviewJsonService.latestVerdictRound(summaryPath, want.checklistId));\n if (record === null) continue;\n out.push(new ReviewerEvidence(\n want.checklistId, record.agentType === '' ? want.agentType : record.agentType, record.agentId));\n }\n return out;\n }\n\n /**\n * Refuse — with an instruction that matches WHICH failure this is.\n *\n * The count is the number of CHECKLISTS at fault, not the number of message paragraphs. It used to be\n * `errors.length`, which printed \"1 checklist(s) require …\" above a list of seven names.\n *\n * The split matters more than the count. A checklist with no verdict file needs a reviewer spawned. A\n * checklist WITH one needs the opposite: the reviewer already ran, the verdict is on disk, and only the\n * attribution failed — so telling an agent to \"spawn each as its OWN subagent\" makes it overwrite seven\n * verdicts with runs that are stamped identically and refused identically. That is a loop that destroys\n * evidence on every iteration, and it is what the previous single message guaranteed.\n *\n * The BLOCK decision is the STATUS, not the length of `missing`. Those agree today — but a\n * `PROVENANCE_MISSING` that arrived carrying no names would otherwise be a silent pass: reported\n * unverified and refused by nothing. Refusing on the status makes the unverified verdict block whatever\n * else is true, and `detail` carries the wording when there are no names to word it from.\n */\n private refuse(result: ProvenanceResult, blind: readonly string[], context: ReviewerContext): void {\n const missing = result.missing;\n const neverRan = missing.filter((t: string): boolean => !fs.existsSync(context.verdictPaths[t] ?? ''));\n const unattributed = missing.filter((t: string): boolean => fs.existsSync(context.verdictPaths[t] ?? ''));\n const paragraphs: string[] = [];\n if (result.status === PROVENANCE_MISSING && missing.length === 0) paragraphs.push(result.detail);\n if (neverRan.length > 0) {\n paragraphs.push(\n 'no reviewer subagent ran on this branch for these checklists (spawn the reviewer agent that ' +\n `pnpm wp-review-upsert-pr names — do not self-certify): ${neverRan.join(', ')}`);\n }\n if (unattributed.length > 0) paragraphs.push(this.unattributedMessage(unattributed, context));\n if (blind.length > 0) {\n paragraphs.push(`these reviewers wrote a verdict without opening the diff (pr-gate.requireDiffEvidence is on): ${blind.join(', ')}`);\n }\n if (paragraphs.length === 0) return;\n // The UNION, because one checklist can be both unattributed and blind, and counting the paragraphs\n // is what printed \"1 checklist(s) require …\" above a list of seven names. Floored at 1 so the\n // nameless-MISSING case above cannot announce \"0 checklist(s) failed\" and then refuse.\n const atFault = Math.max(new Set([...missing, ...blind]).size, 1);\n throw new InformAiError(\n `${atFault} checklist(s) failed the reviewer-provenance check — fix, then re-run pnpm wp-finish-upsert-pr:\\n\\n` +\n paragraphs.map((e: string): string => ` • ${e}`).join('\\n\\n'));\n }\n\n /**\n * The verdict exists but nothing can prove WHICH branch its reviewer looked at — or, in the one case\n * below, provenance never found the session's transcripts AT ALL and this is not about reviewers.\n *\n * The re-spawn warning stays, scoped to what is TRUE: a round's verdict is never overwritten\n * (wp-write-review refuses a second one), so a re-spawn into this round records nothing. What the\n * message no longer says is that the reviewer is unrecoverable (issue #1211). It used to, and that was\n * false for the case that hit it: the reviewer HAD read the diff (relative to its repo-root cwd) and HAD\n * submitted through wp-write-review — provenance just did not look at either. Both are credit channels\n * now, so when this prints, the message names exactly which proofs were missing, and that a reviewer\n * which reads the diff dir or submits through wp-write-review in a later round IS credited.\n *\n * The cwd option stays too: a reviewer stamped with a pinned worktree cwd on this branch is credited\n * on the stamp alone. It is GATED on having found the session, because it was printed for a completely\n * different fault and sent two debugging rounds in the wrong direction: see {@link transcriptRootProblem}.\n */\n private unattributedMessage(unattributed: readonly string[], context: ReviewerContext): string {\n const head = `these reviewers WROTE a verdict for this branch that provenance cannot attribute to them: ${unattributed.join(', ')}\\n` +\n ` Do NOT re-spawn them into this round: a round's verdict is never overwritten (wp-write-review refuses\\n` +\n ` a second one), so a re-spawn records nothing and cannot change the outcome.\\n`;\n const rootProblem = this.transcriptRootProblem();\n if (rootProblem !== '') return head + rootProblem;\n return head +\n ` WHY: each one's harness branch stamp is not ${context.branch}, and its transcript holds none of the\\n` +\n ` three branch-specific proofs — it never named its verdict (${context.verdictPaths[unattributed[0]] ?? '<verdict path>'}),\\n` +\n ` never read the extracted diff (${context.diffDir}, absolute or relative to its own cwd),\\n` +\n ` and no pnpm wp-write-review call of its own matches the agent this branch's verdict provenance records.\\n` +\n ` It is not unrecoverable: a reviewer in a later round that reads that diff dir or submits through\\n` +\n ` pnpm wp-write-review IS credited wherever it was spawned from, and so is one spawned by a Claude Code\\n` +\n ` session whose cwd IS the worktree holding ${context.branch}.`;\n }\n\n /**\n * The transcript ROOT is wrong — said so, instead of blaming the reviewers. '' when it is not.\n *\n * The test is exact rather than heuristic: the main agent's transcript is located by SESSION ID alone,\n * with no cwd, branch or stamping involved, so a known session id with no transcript anywhere can only\n * mean nothing was searched in the right place. That is a transcript-location problem, and it is not\n * something a reviewer did.\n *\n * It happened, and the cost was the whole point of gating the other message: on a machine with\n * `$CLAUDE_CONFIG_DIR` relocated, provenance searched a hardcoded `~/.claude`, found neither the\n * reviewers' transcripts nor the main agent's, and refused every PR with advice about cwd stamping,\n * worktrees and primary clones — none of which was involved. Two debugging rounds went into that\n * before `provenance.json`'s empty `mainTranscript` settled it.\n */\n private transcriptRootProblem(): string {\n const session = this.provenanceRecord.sessionId();\n if (session === '' || this.provenanceRecord.mainTranscript() !== '') return '';\n const configured = claudeConfigDir.configuredDir();\n return ` Provenance found NO transcripts at all for session ${session} — not even the main agent's own — under:\\n` +\n claudeConfigDir.projectsRoots().map((root: string): string => ` ${root}\\n`).join('') +\n ` $${CLAUDE_CONFIG_DIR_ENV}=${configured === '' ? '<unset>' : configured}. This is a transcript-LOCATION problem, not a\\n` +\n ` reviewer problem — your reviewers' verdicts are intact and must not be re-run. Point this command at the\\n` +\n ` config dir that session wrote to.`;\n }\n\n /**\n * WHERE this branch's review materials live — the paths BOTH provenance passes compare against.\n *\n * One object for crediting and for evidence: they ask different questions of the same files, and\n * building the paths twice is how the two could drift apart.\n */\n private async contextFor(repoRoot: string, required: readonly RequiredChecklist[], branch: string): Promise<ReviewerContext> {\n const featureName = await this.aiBranchName.getFeatureName();\n const summaryPath = summaryJsonPath(repoRoot, featureName);\n const docPaths: Record<string, string> = {};\n const verdictPaths: Record<string, string> = {};\n const submittedBy: Record<string, string> = {};\n for (const req of required) {\n docPaths[req.id] = req.doc.trim() === '' ? '' : path.resolve(repoRoot, req.doc);\n verdictPaths[req.id] = this.reviewJsonService.latestChecklistResultPath(summaryPath, req.id);\n // WHO wp-write-review recorded as this branch's submitter — what ties a transcript's\n // `wp-write-review --checklist <id>` call to THIS branch (see ReviewerContext.submittedBy).\n const record = this.verdictProvenance.read(summaryPath, req.id, this.reviewJsonService.latestVerdictRound(summaryPath, req.id));\n if (record !== null && record.agentId.trim() !== '') submittedBy[req.id] = record.agentId;\n }\n return new ReviewerContext(branch, path.join(prDirFor(repoRoot, featureName), 'diff'), docPaths, verdictPaths, submittedBy);\n }\n\n /**\n * Write this round's audit record: `.webpieces/pr-review/<featureSlug>/provenance.json`, linking each\n * verdict to the transcript of the subagent that produced it.\n *\n * `<featureSlug>`, not `<branch>`: the dir is named by `AiBranchName.getFeatureName()`, which\n * dash-sanitizes the branch. Calling it `<branch>` is what led a bug reporter to conclude the gate\n * must be comparing a dash-form name against a slash-form git branch — see\n * ProvenanceWriteRequest.featureSlug, whose field carried the same mislabel.\n *\n * A SEPARATE file rather than a field inside summary.json / review-round<N>-<id>.json, for two reasons. The\n * reviewer cannot supply this itself — a subagent's environment exposes the PARENT session id and no\n * agent id, so a self-reported transcript link would be invented — and keeping the AI-authored files\n * byte-untouched means nothing in the record can be mistaken for something a reviewer claimed about\n * itself. Every path here is derived by the tooling from the harness's own artifacts.\n *\n * Never fatal: an unwritable record is a lost audit trail, not a reason to refuse a PR.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private async writeProvenanceRecord(repoRoot: string, required: readonly RequiredChecklist[], result: ProvenanceResult, evidence: readonly ReviewerEvidence[]): Promise<void> {\n const featureName = await this.aiBranchName.getFeatureName();\n const prDir = prDirFor(repoRoot, featureName);\n const request = new ProvenanceWriteRequest(prDir, featureName, await this.gitOut(['rev-parse', 'HEAD']), result.status);\n request.offered = new OfferedContext(\n path.join(prDir, 'diff'), this.reviewerInstructions.instructionsDirFor(repoRoot, featureName));\n request.reviewers = evidence.map((e: ReviewerEvidence): ReviewerTranscript =>\n new ReviewerTranscript(e, this.reviewerPathsFor(repoRoot, featureName, required, e.checklistId)));\n const written = this.provenanceRecord.write(request);\n if (written !== '') process.stdout.write(` transcript provenance → ${written}\\n`);\n }\n\n // Where ONE checklist's verdict, instructions and doc live — keyed by the checklist id, never by the\n // agent type, which every checklist now shares.\n // eslint-disable-next-line @typescript-eslint/max-params\n private reviewerPathsFor(repoRoot: string, featureName: string, required: readonly RequiredChecklist[], checklistId: string): ReviewerPaths {\n const req = required.find((r: RequiredChecklist): boolean => r.id === checklistId);\n const doc = req !== undefined && req.doc.trim() !== '' ? path.resolve(repoRoot, req.doc) : '';\n return new ReviewerPaths(\n this.reviewJsonService.latestChecklistResultPath(summaryJsonPath(repoRoot, featureName), checklistId),\n this.reviewerInstructions.pathFor(repoRoot, featureName, checklistId),\n doc,\n );\n }\n\n /**\n * The reviewers that wrote a verdict without opening the diff — WARNED about (default) or returned for\n * {@link refuse} to block on (opt-in).\n *\n * Default-warn because the signal is derived from undocumented Claude Code transcript internals: if the\n * format shifts, a blocking check wedges every PR in every consumer repo with no self-service recovery.\n * `requireDiffEvidence` lets a repo that has watched the warning promote it deliberately.\n *\n * Returns the checklist ids rather than a finished sentence so the caller can count CHECKLISTS at fault —\n * a name can appear in this list and in `missing`, and it must be one checklist in the total, not two.\n */\n private blindReviewers(evidence: readonly ReviewerEvidence[], config: PrGateConfig): string[] {\n const blind = evidence.filter((e: ReviewerEvidence): boolean => !e.readDiff);\n if (blind.length === 0) return [];\n const names = blind.map((e: ReviewerEvidence): string => e.checklistId);\n if (config.requireDiffEvidence) return names;\n process.stderr.write(\n `\\n⚠️ ${blind.length} reviewer(s) wrote a verdict with no record of opening the extracted diff: ${names.join(', ')}\\n` +\n ' Published on the PR as a note. Not blocking — set pr-gate.requireDiffEvidence:true to make it one.\\n');\n return [];\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AtomicFile } from '@webpieces/tooling-common';
|
|
1
|
+
import { AtomicFile, GitProcessApi } from '@webpieces/tooling-common';
|
|
2
2
|
import { ChecklistResult, ReviewJsonService } from '@webpieces/rules-config';
|
|
3
3
|
import { ReviewStageReceipt } from './review-stage-receipt';
|
|
4
4
|
import { VerdictProvenanceService } from './verdict-provenance';
|
|
@@ -65,7 +65,8 @@ export declare class ReviewRoundStateService {
|
|
|
65
65
|
private readonly reviewJson;
|
|
66
66
|
private readonly provenance;
|
|
67
67
|
private readonly atomicFile;
|
|
68
|
-
|
|
68
|
+
private readonly gitProcess;
|
|
69
|
+
constructor(reviewJson: ReviewJsonService, provenance: VerdictProvenanceService, atomicFile: AtomicFile, gitProcess: GitProcessApi);
|
|
69
70
|
/** The author's recorded fixes for one round: `review-round<N>-fixes.json`, beside summary.json. */
|
|
70
71
|
fixesPath(summaryPath: string, round: number): string;
|
|
71
72
|
/** The highest round any round-numbered file names, or 0. */
|
|
@@ -90,7 +91,7 @@ export declare class ReviewRoundStateService {
|
|
|
90
91
|
/** The roster checklists whose verdict in the snapshot's round is `status`. */
|
|
91
92
|
checklistIdsWithStatus(summaryPath: string, snap: RoundSnapshot, status: string): string[];
|
|
92
93
|
/** What stage ② does next. See the class comment for the three rules it holds. */
|
|
93
|
-
plan(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number, fullBasis: DiffBasis): ReviewRoundPlan
|
|
94
|
+
plan(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number, fullBasis: DiffBasis): Promise<ReviewRoundPlan>;
|
|
94
95
|
/**
|
|
95
96
|
* Record the author's fixes for the latest completed round — one response per RED (a round that is not
|
|
96
97
|
* the last) or ORANGE (the final round) — as `review-round<N>-fixes.json`.
|
|
@@ -100,7 +101,7 @@ export declare class ReviewRoundStateService {
|
|
|
100
101
|
* `review-round<N>-fixes.json.superseded-<k>` and a fresh record is written, so re-recording is always
|
|
101
102
|
* the way past a stale record and nothing is ever lost.
|
|
102
103
|
*/
|
|
103
|
-
writeRemediation(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt, json: string): string
|
|
104
|
+
writeRemediation(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt, json: string): Promise<string>;
|
|
104
105
|
/**
|
|
105
106
|
* Keep a record that no longer holds beside the new one, as `<file>.superseded-<k>` — a name no round
|
|
106
107
|
* scan reads, so it is history and never a live record.
|
|
@@ -110,13 +111,13 @@ export declare class ReviewRoundStateService {
|
|
|
110
111
|
* The round's recorded fixes, or null when there are none that still hold: written from the reviewed
|
|
111
112
|
* HEAD, to a later commit that is still in HEAD's history, covering exactly the round's red/orange set.
|
|
112
113
|
*/
|
|
113
|
-
validFixes(repoRoot: string, summaryPath: string, snap: RoundSnapshot): ReviewRemediation | null
|
|
114
|
+
validFixes(repoRoot: string, summaryPath: string, snap: RoundSnapshot): Promise<ReviewRemediation | null>;
|
|
114
115
|
/**
|
|
115
116
|
* checklist id → the dashboard stamp for every ORANGE whose fix the author recorded (issue #1053):
|
|
116
117
|
* "orange at <fromHead>, author-fixed in <toHead>, not re-reviewed: <resolution>". An orange with no
|
|
117
118
|
* valid record is absent, and so still blocks.
|
|
118
119
|
*/
|
|
119
|
-
orangeFixes(repoRoot: string, summaryPath: string, results: readonly ChecklistResult[]): Record<string, string
|
|
120
|
+
orangeFixes(repoRoot: string, summaryPath: string, results: readonly ChecklistResult[]): Promise<Record<string, string>>;
|
|
120
121
|
auditTrail(summaryPath: string, checklistId: string, maxRounds: number): string;
|
|
121
122
|
private blockingIds;
|
|
122
123
|
/** A round's fix record, provided its `toHead` is still in HEAD's history; else null. */
|
|
@@ -4,7 +4,6 @@ exports.ReviewRoundStateService = exports.ReviewRemediation = exports.Remediatio
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fs = tslib_1.__importStar(require("fs"));
|
|
6
6
|
const path = tslib_1.__importStar(require("path"));
|
|
7
|
-
const child_process_1 = require("child_process");
|
|
8
7
|
const tooling_common_1 = require("@webpieces/tooling-common");
|
|
9
8
|
const to_error_1 = require("@webpieces/tooling-common/to-error");
|
|
10
9
|
const rules_config_1 = require("@webpieces/rules-config");
|
|
@@ -107,10 +106,12 @@ let ReviewRoundStateService = class ReviewRoundStateService {
|
|
|
107
106
|
reviewJson;
|
|
108
107
|
provenance;
|
|
109
108
|
atomicFile;
|
|
110
|
-
|
|
109
|
+
gitProcess;
|
|
110
|
+
constructor(reviewJson, provenance, atomicFile, gitProcess) {
|
|
111
111
|
this.reviewJson = reviewJson;
|
|
112
112
|
this.provenance = provenance;
|
|
113
113
|
this.atomicFile = atomicFile;
|
|
114
|
+
this.gitProcess = gitProcess;
|
|
114
115
|
}
|
|
115
116
|
/** The author's recorded fixes for one round: `review-round<N>-fixes.json`, beside summary.json. */
|
|
116
117
|
fixesPath(summaryPath, round) {
|
|
@@ -194,7 +195,7 @@ let ReviewRoundStateService = class ReviewRoundStateService {
|
|
|
194
195
|
});
|
|
195
196
|
}
|
|
196
197
|
/** What stage ② does next. See the class comment for the three rules it holds. */
|
|
197
|
-
plan(repoRoot, summaryPath, receipt, maxRounds, fullBasis) {
|
|
198
|
+
async plan(repoRoot, summaryPath, receipt, maxRounds, fullBasis) {
|
|
198
199
|
const snap = this.snapshot(summaryPath, receipt);
|
|
199
200
|
if (snap.round < 1)
|
|
200
201
|
return new ReviewRoundPlan(exports.ROUND_ACTION_REVIEW, 1, maxRounds, fullBasis);
|
|
@@ -212,11 +213,11 @@ let ReviewRoundStateService = class ReviewRoundStateService {
|
|
|
212
213
|
if (snap.headSha === fullBasis.headSha) {
|
|
213
214
|
return new ReviewRoundPlan(exports.ROUND_ACTION_FIX, snap.round, maxRounds, fullBasis, [], reds, oranges);
|
|
214
215
|
}
|
|
215
|
-
if (this.validFixes(repoRoot, summaryPath, snap) === null) {
|
|
216
|
+
if (await this.validFixes(repoRoot, summaryPath, snap) === null) {
|
|
216
217
|
return new ReviewRoundPlan(exports.ROUND_ACTION_RECORD, snap.round, maxRounds, fullBasis, [], reds, oranges);
|
|
217
218
|
}
|
|
218
219
|
const basis = new diff_basis_1.DiffBasis(snap.headSha, fullBasis.headSha, false, [], `git diff ${snap.headSha} ${fullBasis.headSha}`, `git diff ${snap.headSha} ${fullBasis.headSha} -- <file>`, fullBasis.hashMainHead);
|
|
219
|
-
const changed = this.git(repoRoot, ['diff', '--name-only', snap.headSha, fullBasis.headSha])
|
|
220
|
+
const changed = (await this.git(repoRoot, ['diff', '--name-only', snap.headSha, fullBasis.headSha]))
|
|
220
221
|
.split('\n').filter((f) => f.trim() !== '');
|
|
221
222
|
return new ReviewRoundPlan(exports.ROUND_ACTION_REVIEW, snap.round + 1, maxRounds, basis, changed, reds, oranges);
|
|
222
223
|
}
|
|
@@ -229,7 +230,7 @@ let ReviewRoundStateService = class ReviewRoundStateService {
|
|
|
229
230
|
* `review-round<N>-fixes.json.superseded-<k>` and a fresh record is written, so re-recording is always
|
|
230
231
|
* the way past a stale record and nothing is ever lost.
|
|
231
232
|
*/
|
|
232
|
-
writeRemediation(repoRoot, summaryPath, receipt, json) {
|
|
233
|
+
async writeRemediation(repoRoot, summaryPath, receipt, json) {
|
|
233
234
|
const snap = this.snapshot(summaryPath, receipt);
|
|
234
235
|
if (!snap.complete) {
|
|
235
236
|
throw new tooling_common_1.InformAiError('wp-write-review-fixes: the active reviewer round is not complete yet.');
|
|
@@ -239,15 +240,15 @@ let ReviewRoundStateService = class ReviewRoundStateService {
|
|
|
239
240
|
throw new tooling_common_1.InformAiError(`wp-write-review-fixes: round ${snap.round} has no red or orange verdict to fix.`);
|
|
240
241
|
}
|
|
241
242
|
const out = this.fixesPath(summaryPath, snap.round);
|
|
242
|
-
const holding = this.validFixes(repoRoot, summaryPath, snap);
|
|
243
|
+
const holding = await this.validFixes(repoRoot, summaryPath, snap);
|
|
243
244
|
if (holding !== null) {
|
|
244
245
|
throw new tooling_common_1.InformAiError(`wp-write-review-fixes: the fixes for round ${snap.round} are already recorded in ${out}, and `
|
|
245
246
|
+ `that record still holds (its fixed commit ${holding.toHead.slice(0, 8)} is in HEAD's history), so it is not `
|
|
246
247
|
+ 'overwritten. Nothing more to record: re-run pnpm wp-review-upsert-pr, or pnpm wp-finish-upsert-pr after the last round.');
|
|
247
248
|
}
|
|
248
|
-
this.assertClean(repoRoot);
|
|
249
|
-
const currentHead = this.git(repoRoot, ['rev-parse', 'HEAD']);
|
|
250
|
-
if (currentHead === snap.headSha || this.git(repoRoot, ['diff', '--name-only', snap.headSha, currentHead]) === '') {
|
|
249
|
+
await this.assertClean(repoRoot);
|
|
250
|
+
const currentHead = await this.git(repoRoot, ['rev-parse', 'HEAD']);
|
|
251
|
+
if (currentHead === snap.headSha || await this.git(repoRoot, ['diff', '--name-only', snap.headSha, currentHead]) === '') {
|
|
251
252
|
throw new tooling_common_1.InformAiError('wp-write-review-fixes: remediation must contain a committed, non-empty delta after the reviewed HEAD.');
|
|
252
253
|
}
|
|
253
254
|
const raw = this.parseObject(json, 'wp-write-review-fixes: input must be one JSON object.');
|
|
@@ -281,8 +282,8 @@ let ReviewRoundStateService = class ReviewRoundStateService {
|
|
|
281
282
|
* The round's recorded fixes, or null when there are none that still hold: written from the reviewed
|
|
282
283
|
* HEAD, to a later commit that is still in HEAD's history, covering exactly the round's red/orange set.
|
|
283
284
|
*/
|
|
284
|
-
validFixes(repoRoot, summaryPath, snap) {
|
|
285
|
-
const record = this.readFixes(repoRoot, summaryPath, snap.round);
|
|
285
|
+
async validFixes(repoRoot, summaryPath, snap) {
|
|
286
|
+
const record = await this.readFixes(repoRoot, summaryPath, snap.round);
|
|
286
287
|
if (record === null || record.fromHead !== snap.headSha)
|
|
287
288
|
return null;
|
|
288
289
|
const blocking = this.blockingIds(summaryPath, snap);
|
|
@@ -296,12 +297,12 @@ let ReviewRoundStateService = class ReviewRoundStateService {
|
|
|
296
297
|
* "orange at <fromHead>, author-fixed in <toHead>, not re-reviewed: <resolution>". An orange with no
|
|
297
298
|
* valid record is absent, and so still blocks.
|
|
298
299
|
*/
|
|
299
|
-
orangeFixes(repoRoot, summaryPath, results) {
|
|
300
|
+
async orangeFixes(repoRoot, summaryPath, results) {
|
|
300
301
|
const out = {};
|
|
301
302
|
for (const result of results) {
|
|
302
303
|
if (result.status !== rules_config_1.VERDICT_ORANGE || result.problem !== '')
|
|
303
304
|
continue;
|
|
304
|
-
const record = this.readFixes(repoRoot, summaryPath, result.round);
|
|
305
|
+
const record = await this.readFixes(repoRoot, summaryPath, result.round);
|
|
305
306
|
const response = record?.responses.find((r) => r.checklistId === result.id);
|
|
306
307
|
if (record === null || response === undefined)
|
|
307
308
|
continue;
|
|
@@ -342,7 +343,7 @@ let ReviewRoundStateService = class ReviewRoundStateService {
|
|
|
342
343
|
];
|
|
343
344
|
}
|
|
344
345
|
/** A round's fix record, provided its `toHead` is still in HEAD's history; else null. */
|
|
345
|
-
readFixes(repoRoot, summaryPath, round) {
|
|
346
|
+
async readFixes(repoRoot, summaryPath, round) {
|
|
346
347
|
const raw = this.readObject(this.fixesPath(summaryPath, round));
|
|
347
348
|
if (raw === null)
|
|
348
349
|
return null;
|
|
@@ -350,7 +351,7 @@ let ReviewRoundStateService = class ReviewRoundStateService {
|
|
|
350
351
|
const fromHead = this.text(raw['fromHead']);
|
|
351
352
|
const toHead = this.text(raw['toHead']);
|
|
352
353
|
if (this.text(raw['agent']) === '' || this.text(raw['model']) === '' || responses.length === 0
|
|
353
|
-
|| fromHead === '' || toHead === '' || fromHead === toHead || !this.isAncestorOfHead(repoRoot, toHead))
|
|
354
|
+
|| fromHead === '' || toHead === '' || fromHead === toHead || !(await this.isAncestorOfHead(repoRoot, toHead)))
|
|
354
355
|
return null;
|
|
355
356
|
return new ReviewRemediation(this.text(raw['agent']), this.text(raw['model']), fromHead, toHead, responses);
|
|
356
357
|
}
|
|
@@ -437,8 +438,8 @@ let ReviewRoundStateService = class ReviewRoundStateService {
|
|
|
437
438
|
throw new tooling_common_1.InformAiError(`Could not read review state file ${file}: ${error.message}`, { cause: error });
|
|
438
439
|
}
|
|
439
440
|
}
|
|
440
|
-
assertClean(repoRoot) {
|
|
441
|
-
const status = this.git(repoRoot, ['status', '--porcelain', '--untracked-files=all']);
|
|
441
|
+
async assertClean(repoRoot) {
|
|
442
|
+
const status = await this.git(repoRoot, ['status', '--porcelain', '--untracked-files=all']);
|
|
442
443
|
if (status !== '')
|
|
443
444
|
throw new tooling_common_1.InformAiError('wp-write-review-fixes: commit every remediation and leave no staged, unstaged, or untracked files first.');
|
|
444
445
|
}
|
|
@@ -447,28 +448,21 @@ let ReviewRoundStateService = class ReviewRoundStateService {
|
|
|
447
448
|
* "Not a valid commit name") is also no — the commit is gone from this clone, so it is not in HEAD's
|
|
448
449
|
* history. Anything else is a real failure and refuses.
|
|
449
450
|
*/
|
|
450
|
-
isAncestorOfHead(repoRoot, sha) {
|
|
451
|
-
const result =
|
|
452
|
-
if (result.
|
|
451
|
+
async isAncestorOfHead(repoRoot, sha) {
|
|
452
|
+
const result = await this.gitProcess.run(['merge-base', '--is-ancestor', sha, 'HEAD'], repoRoot);
|
|
453
|
+
if (result.code === 0)
|
|
453
454
|
return true;
|
|
454
|
-
if (result.
|
|
455
|
+
if (result.code === 1 || /not a valid (commit|object) name/i.test(result.stderr))
|
|
455
456
|
return false;
|
|
456
|
-
const detail =
|
|
457
|
-
|
|
458
|
-
if (result.error !== undefined)
|
|
459
|
-
throw new tooling_common_1.InformAiError(message, { cause: result.error });
|
|
460
|
-
throw new tooling_common_1.InformAiError(message);
|
|
457
|
+
const detail = result.stderr.trim() || `exit ${result.code}`;
|
|
458
|
+
throw new tooling_common_1.InformAiError(`Review-round Git command failed: git merge-base --is-ancestor ${sha} HEAD\n${detail}`);
|
|
461
459
|
}
|
|
462
|
-
git(repoRoot, args) {
|
|
463
|
-
const result =
|
|
464
|
-
if (result.
|
|
465
|
-
return
|
|
466
|
-
const
|
|
467
|
-
|
|
468
|
-
const message = `Review-round Git command failed: ${command}\n${detail}`;
|
|
469
|
-
if (result.error !== undefined)
|
|
470
|
-
throw new tooling_common_1.InformAiError(message, { cause: result.error });
|
|
471
|
-
throw new tooling_common_1.InformAiError(message);
|
|
460
|
+
async git(repoRoot, args) {
|
|
461
|
+
const result = await this.gitProcess.run(args, repoRoot);
|
|
462
|
+
if (result.ok)
|
|
463
|
+
return result.stdout.trim();
|
|
464
|
+
const detail = result.stderr.trim() || `exit ${result.code}`;
|
|
465
|
+
throw new tooling_common_1.InformAiError(`Review-round Git command failed: git ${args.join(' ')}\n${detail}`);
|
|
472
466
|
}
|
|
473
467
|
};
|
|
474
468
|
exports.ReviewRoundStateService = ReviewRoundStateService;
|
|
@@ -476,6 +470,7 @@ exports.ReviewRoundStateService = ReviewRoundStateService = tslib_1.__decorate([
|
|
|
476
470
|
(0, inversify_1.injectable)(inversify_1.bindingScopeValues.Singleton),
|
|
477
471
|
tslib_1.__metadata("design:paramtypes", [rules_config_1.ReviewJsonService,
|
|
478
472
|
verdict_provenance_1.VerdictProvenanceService,
|
|
479
|
-
tooling_common_1.AtomicFile
|
|
473
|
+
tooling_common_1.AtomicFile,
|
|
474
|
+
tooling_common_1.GitProcessApi])
|
|
480
475
|
], ReviewRoundStateService);
|
|
481
476
|
//# sourceMappingURL=review-round-state.js.map
|
|
@@ -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,8DAAsE;AACtE,iEAA6D;AAC7D,0DAA0G;AAC1G,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,QA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6CAAwB;QACxB,2BAAU;GAJlC,uBAAuB,CA2WnC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { spawnSync } from 'child_process';\nimport { AtomicFile, InformAiError } from '@webpieces/tooling-common';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { ChecklistResult, ReviewJsonService, VERDICT_ORANGE, VERDICT_RED } 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 REQUIRED checklists briefed in `round`, plus the optional ones that submitted in it\n headSha: string; // the commit `round` was briefed on\n complete: boolean; // every REQUIRED checklist briefed in `round` has a verdict in it (issue #1062)\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 // Only a REQUIRED checklist holds the round open (issue #1062). An optional one counts only if it\n // actually ran — a red from it still opens the next round — and one nobody chose to run is not\n // waited on, so an all-optional briefing nobody ran is complete with an empty roster.\n const optional = new Set<string>(receipt.optionalBriefed);\n const required = receipt.reviewersBriefed.filter((id: string): boolean => !optional.has(id));\n const roster = receipt.reviewersBriefed.filter((id: string): boolean =>\n !optional.has(id) || this.hasVerdict(summaryPath, id, round));\n return new RoundSnapshot(round, roster, receipt.headSha, this.everyVerdictIn(summaryPath, required, 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 /**\n * The frozen checklist set: every checklist briefed in any round — see {@link roundStarted}. It keeps an\n * optional checklist that was offered but never run, so its dashboard row reads \"optional, not run\"\n * rather than \"not briefed\"; it never holds a round open (see {@link snapshot}).\n */\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 // A sanctioned update changes the build basis, never the fixed roster or its historical\n // briefing. Resume that roster without charging another round (issue #1087).\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.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"]}
|
|
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,8DAAqF;AACrF,iEAA6D;AAC7D,0DA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AAE,GAAG,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;QACjG,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QACnC,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,mCAAmC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;YAAE,OAAO,KAAK,CAAC;QAC/F,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QAC7D,MAAM,IAAI,8BAAa,CAAC,iEAAiE,GAAG,UAAU,MAAM,EAAE,CAAC,CAAC;IACpH,CAAC;IAEO,KAAK,CAAC,GAAG,CAAC,QAAgB,EAAE,IAAc;QAC9C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACzD,IAAI,MAAM,CAAC,EAAE;YAAE,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC3C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QAC7D,MAAM,IAAI,8BAAa,CAAC,wCAAwC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC;IACjG,CAAC;CACJ,CAAA;AAvWY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGJ,gCAAiB;QACjB,6CAAwB;QACxB,2BAAU;QACV,8BAAa;GALrC,uBAAuB,CAuWnC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { AtomicFile, GitProcessApi, InformAiError } from '@webpieces/tooling-common';\nimport { toError } from '@webpieces/tooling-common/to-error';\nimport { ChecklistResult, ReviewJsonService, VERDICT_ORANGE, VERDICT_RED } 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 REQUIRED checklists briefed in `round`, plus the optional ones that submitted in it\n headSha: string; // the commit `round` was briefed on\n complete: boolean; // every REQUIRED checklist briefed in `round` has a verdict in it (issue #1062)\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 private readonly gitProcess: GitProcessApi,\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 // Only a REQUIRED checklist holds the round open (issue #1062). An optional one counts only if it\n // actually ran — a red from it still opens the next round — and one nobody chose to run is not\n // waited on, so an all-optional briefing nobody ran is complete with an empty roster.\n const optional = new Set<string>(receipt.optionalBriefed);\n const required = receipt.reviewersBriefed.filter((id: string): boolean => !optional.has(id));\n const roster = receipt.reviewersBriefed.filter((id: string): boolean =>\n !optional.has(id) || this.hasVerdict(summaryPath, id, round));\n return new RoundSnapshot(round, roster, receipt.headSha, this.everyVerdictIn(summaryPath, required, 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 /**\n * The frozen checklist set: every checklist briefed in any round — see {@link roundStarted}. It keeps an\n * optional checklist that was offered but never run, so its dashboard row reads \"optional, not run\"\n * rather than \"not briefed\"; it never holds a round open (see {@link snapshot}).\n */\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 async plan(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt | null, maxRounds: number, fullBasis: DiffBasis): Promise<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 // A sanctioned update changes the build basis, never the fixed roster or its historical\n // briefing. Resume that roster without charging another round (issue #1087).\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 (await 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 = (await 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 async writeRemediation(repoRoot: string, summaryPath: string, receipt: ReviewStageReceipt, json: string): Promise<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 = await 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 await this.assertClean(repoRoot);\n const currentHead = await this.git(repoRoot, ['rev-parse', 'HEAD']);\n if (currentHead === snap.headSha || await 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 async validFixes(repoRoot: string, summaryPath: string, snap: RoundSnapshot): Promise<ReviewRemediation | null> {\n const record = await 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 async orangeFixes(repoRoot: string, summaryPath: string, results: readonly ChecklistResult[]): Promise<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 = await 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 async readFixes(repoRoot: string, summaryPath: string, round: number): Promise<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 || !(await 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.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 async assertClean(repoRoot: string): Promise<void> {\n const status = await 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 async isAncestorOfHead(repoRoot: string, sha: string): Promise<boolean> {\n const result = await this.gitProcess.run(['merge-base', '--is-ancestor', sha, 'HEAD'], repoRoot);\n if (result.code === 0) return true;\n if (result.code === 1 || /not a valid (commit|object) name/i.test(result.stderr)) return false;\n const detail = result.stderr.trim() || `exit ${result.code}`;\n throw new InformAiError(`Review-round Git command failed: git merge-base --is-ancestor ${sha} HEAD\\n${detail}`);\n }\n\n private async git(repoRoot: string, args: string[]): Promise<string> {\n const result = await this.gitProcess.run(args, repoRoot);\n if (result.ok) return result.stdout.trim();\n const detail = result.stderr.trim() || `exit ${result.code}`;\n throw new InformAiError(`Review-round Git command failed: git ${args.join(' ')}\\n${detail}`);\n }\n}\n"]}
|
|
@@ -39,7 +39,7 @@ let RunUpdate = class RunUpdate {
|
|
|
39
39
|
}
|
|
40
40
|
// eslint-disable-next-line @typescript-eslint/max-params
|
|
41
41
|
async runUpdate(repoRoot, verb, finishCommand, pushRemote) {
|
|
42
|
-
const home = this.mergeState.mergeDirFor(repoRoot, this.aiBranchName.getFeatureName());
|
|
42
|
+
const home = this.mergeState.mergeDirFor(repoRoot, await this.aiBranchName.getFeatureName());
|
|
43
43
|
// Resume path: an in-progress merge is the `merge-<n>/` run dir that holds a marker.
|
|
44
44
|
const activeDir = this.mergeState.findActiveMergeRunDir(home);
|
|
45
45
|
if (activeDir) {
|