@webpieces/rules-config 0.4.915 → 0.4.917
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 +5 -5
- package/src/aged-tree-sweep.d.ts +2 -2
- package/src/aged-tree-sweep.js +2 -2
- package/src/aged-tree-sweep.js.map +1 -1
- package/src/build-log-doc.d.ts +1 -1
- package/src/build-log-doc.js +3 -3
- package/src/build-log-doc.js.map +1 -1
- package/src/builds-log.d.ts +2 -2
- package/src/builds-log.js +2 -2
- package/src/builds-log.js.map +1 -1
- package/src/checklist-override.d.ts +1 -1
- package/src/checklist-override.js +1 -1
- package/src/checklist-override.js.map +1 -1
- package/src/config-error-banner.js +1 -1
- package/src/config-error-banner.js.map +1 -1
- package/src/constants.js +3 -3
- package/src/constants.js.map +1 -1
- package/src/exclude-hook-paths.d.ts +5 -5
- package/src/exclude-hook-paths.js +5 -5
- package/src/exclude-hook-paths.js.map +1 -1
- package/src/exclude-paths.d.ts +1 -1
- package/src/exclude-paths.js +1 -1
- package/src/exclude-paths.js.map +1 -1
- package/src/hook-fault-codes.js.map +1 -1
- package/src/index.js +5 -5
- package/src/index.js.map +1 -1
- package/src/instruct-ai-docs.d.ts +3 -3
- package/src/instruct-ai-docs.js +3 -3
- package/src/instruct-ai-docs.js.map +1 -1
- package/src/legacy-config-upgrade.js +2 -2
- package/src/legacy-config-upgrade.js.map +1 -1
- package/src/load-template.d.ts +1 -1
- package/src/load-template.js +2 -2
- package/src/load-template.js.map +1 -1
- package/src/merge-process-doc.d.ts +1 -1
- package/src/merge-process-doc.js +2 -2
- package/src/merge-process-doc.js.map +1 -1
- package/src/migrate-dirs-cli.js +1 -1
- package/src/migrate-dirs-cli.js.map +1 -1
- package/src/orphan-dir-archive.d.ts +4 -4
- package/src/orphan-dir-archive.js +4 -4
- package/src/orphan-dir-archive.js.map +1 -1
- package/src/orphan-dir-scan.d.ts +1 -1
- package/src/orphan-dir-scan.js +1 -1
- package/src/orphan-dir-scan.js.map +1 -1
- package/src/orphan-dir-sweep.js +1 -1
- package/src/orphan-dir-sweep.js.map +1 -1
- package/src/policy-tracking.js +5 -8
- package/src/policy-tracking.js.map +1 -1
- package/src/pr-gate-config.d.ts +1 -1
- package/src/pr-gate-config.js +1 -1
- package/src/pr-gate-config.js.map +1 -1
- package/src/repo-root.d.ts +7 -7
- package/src/repo-root.js +8 -8
- package/src/repo-root.js.map +1 -1
- package/src/repo-scratch-dirs.d.ts +3 -3
- package/src/repo-scratch-dirs.js +5 -5
- package/src/repo-scratch-dirs.js.map +1 -1
- package/src/review-json-data.js +2 -2
- package/src/review-json-data.js.map +1 -1
- package/src/review-json.js +1 -1
- package/src/review-json.js.map +1 -1
- package/src/reviewer-instructions.d.ts +1 -1
- package/src/reviewer-instructions.js +1 -1
- package/src/reviewer-instructions.js.map +1 -1
- package/src/stale-bin-sweep.js +1 -1
- package/src/stale-bin-sweep.js.map +1 -1
- package/src/subagent-provenance.d.ts +6 -6
- package/src/subagent-provenance.js +6 -6
- package/src/subagent-provenance.js.map +1 -1
- package/src/sync-flow-guidance.js +1 -1
- package/src/sync-flow-guidance.js.map +1 -1
- package/templates/webpieces.branch-state-matrix.md +2 -2
- package/templates/webpieces.buildlog.md +3 -3
- package/templates/webpieces.ci-gate-setup.md +2 -2
- package/templates/webpieces.git-workflow.md +8 -9
- package/templates/webpieces.location-matrix.md +10 -10
- package/templates/webpieces.review-checklists.md +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reviewer-instructions.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/reviewer-instructions.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,yCAA2D;AAC3D,+CAAkD;AAClD,sEAAiE;AAEjE,2GAA2G;AAC3G,MAAa,YAAY;IACrB,KAAK,CAAS;IACd,IAAI,CAAS,CAAK,gDAAgD;IAClE,IAAI,CAAS,CAAK,0EAA0E;IAE5F,YAAY,KAAa,EAAE,SAAiB,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AAK;YACL,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YAC7D,KAAK;YACL,EAAE;SACL,CAAC;IACN,CAAC;IAED;;;;;;;OAOG;IACK,aAAa;QACjB,OAAO;YACH,WAAW;YACX,EAAE;YACF,mGAAmG;YACnG,iGAAiG;YACjG,4CAA4C;YAC5C,EAAE;YACF,qGAAqG;YACrG,8FAA8F;YAC9F,EAAE;YACF,mGAAmG;YACnG,qBAAqB;YACrB,EAAE;YACF,oGAAoG;YACpG,kGAAkG;YAClG,kGAAkG;YAClG,+EAA+E;YAC/E,sGAAsG;SACzG,CAAC;IACN,CAAC;CACJ,CAAA;AAtVY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEW,+BAAiB;GADxD,2BAA2B,CAsVvC","sourcesContent":["import * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ReviewJsonService } from './review-json';\nimport { WRITE_REVIEW_BIN } from '@webpieces/repo-workflow-core';\n\n/** One pre-resolved place a reviewer would otherwise have to go hunting for. Data-only (per CLAUDE.md). */\nexport class ContextEntry {\n label: string;\n path: string; // ABSOLUTE, or '' when it could not be resolved\n note: string; // '(not installed)' / '(configured but missing)' — never silently dropped\n\n constructor(label: string, entryPath: string, note = '') {\n this.label = label;\n this.path = entryPath;\n this.note = note;\n }\n}\n\n/**\n * One reviewer's matched file, the extracted diff for it, AND the absolute path of the file itself.\n *\n * `sourcePath` exists because of a measured 0/4: four reviewers on one PR read the diff and not one opened a\n * single full source file. The instructions handed them an absolute path per diff and only a parent DIRECTORY\n * per source, so reading the diff was a paste and reading the source was \"join this dir to that filename\n * yourself\". Identical affordance, or the cheaper one wins every time. Data-only.\n */\nexport class BriefedFile {\n file: string; // repo-relative source path\n diffPath: string; // ABSOLUTE path of the extracted .diff\n sourcePath: string; // ABSOLUTE path of the file itself; '' for a deleted file, which has no after-state\n status: string; // 'M' | 'A' | 'D' | 'U' (untracked) | 'X' (excluded by config)\n diffBytes: number;\n truncated: boolean;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(file: string, diffPath: string, sourcePath = '', status = 'M', diffBytes = 0, truncated = false) {\n this.file = file;\n this.diffPath = diffPath;\n this.sourcePath = sourcePath;\n this.status = status;\n this.diffBytes = diffBytes;\n this.truncated = truncated;\n }\n}\n\n/**\n * Everything ONE reviewer needs, with every path already resolved to an ABSOLUTE one.\n *\n * Absolute is not fussiness: a subagent's working directory is not guaranteed to be the repo root, and a\n * relative path that fails to resolve turns into a search, which is the cost this whole class exists to\n * remove. Data-only.\n */\nexport class ReviewerBriefing {\n agentName: string; // the agent type the subagent is spawned as (webpieces-reviewer, or the override)\n docPath: string; // the checklist's guidance doc ('' when the checklist has none)\n repoRoot: string;\n diffDir: string; // '' when nothing was materialized\n allDiffPath: string;\n manifestPath: string;\n myFiles: BriefedFile[]; // ONLY this reviewer's matched files\n matchedPatterns: string[]; // [] ⇒ patternless: the whole diff is in scope\n sourceDirs: string[]; // deduped ABSOLUTE parent dirs of myFiles\n contextEntries: ContextEntry[];\n verdictPath: string; // ABSOLUTE review-round<N>-<id>.json\n checklistId: string;\n fileDiffCommand: string;\n dirty: boolean;\n // Facts ABOUT the manifest, surfaced inline so a reviewer learns the diff is complete without opening it.\n changedFileCount: number;\n truncatedCount: number;\n excludedCount: number;\n allDiffLines: number;\n allDiffBytes: number;\n // The three shas, by the names DiffManifest already uses. Printing two bare shas told a reviewer nothing\n // about WHAT the diff is taken against; C beside A makes \"main has moved since the fork\" self-evident.\n hashForkPoint: string;\n hashFeatureHead: string;\n hashMainHead: string;\n ownAgentFileInDiff: string; // ABSOLUTE path when this diff edits the reviewer agent's own file; '' otherwise\n // From the checklist's config `required`. Carried so the stage-② report can group the spawn blocks\n // (must run) apart from the ones the human is merely OFFERED, without a second lookup that could\n // disagree with the scan. The reviewer's OWN instructions do not mention it: a reviewer that has been\n // spawned reviews the same way either way, and telling an optional one it was optional invites it to\n // grade itself softer.\n required: boolean;\n round: number;\n maxRounds: number;\n remediationOnly: boolean;\n previousVerdictPath: string;\n remediationPath: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(agentName: string, checklistId: string, repoRoot: string) {\n this.agentName = agentName;\n this.checklistId = checklistId;\n this.repoRoot = repoRoot;\n this.docPath = '';\n this.diffDir = '';\n this.allDiffPath = '';\n this.manifestPath = '';\n this.myFiles = [];\n this.matchedPatterns = [];\n this.sourceDirs = [];\n this.contextEntries = [];\n this.verdictPath = '';\n this.fileDiffCommand = '';\n this.dirty = false;\n this.changedFileCount = 0;\n this.truncatedCount = 0;\n this.excludedCount = 0;\n this.allDiffLines = 0;\n this.allDiffBytes = 0;\n this.hashForkPoint = '';\n this.hashFeatureHead = '';\n this.hashMainHead = '';\n this.ownAgentFileInDiff = '';\n // Fails CLOSED, like RequiredChecklist.required: a briefing built without the flag being copied is\n // treated as a blocking reviewer, never as a skippable one.\n this.required = true;\n this.round = 1;\n this.maxRounds = 1;\n this.remediationOnly = false;\n this.previousVerdictPath = '';\n this.remediationPath = '';\n }\n}\n\n/**\n * The Read tool truncates at roughly this many lines, silently. Any path this file prints alongside a bigger\n * line count has to say so, or a reviewer reviews a fraction of a change and reports on all of it.\n */\nexport const READ_TRUNCATION_LINES = 2000;\n\n/** Comfortably under {@link READ_TRUNCATION_LINES} — the size at which ALL.diff really is one clean Read. */\nexport const ALL_DIFF_ONE_READ_LINES = 1500;\n\n/**\n * Renders the per-reviewer instructions file that `wp-review-upsert-pr` writes to\n * `.webpieces-logs/pr-review/<feature>/instructions/<checklistId>.instructions.md` — ONE PER CHECKLIST, so a\n * subagent covering several checklists (`commands.pr-gate.reviewerAgents`) is simply handed several files.\n *\n * WHY this file exists, measured rather than assumed: a reviewer subagent on consumer-monorepo2 spent **14 of its\n * 26 tool calls** rediscovering context the tooling already had — three separate greps into\n * `node_modules/@webpieces` to locate a scanner, a hunt through terraform for queue names, and a\n * re-derivation of the dependency graph. It did not over-review; it was under-supplied. Everything below is\n * chosen to delete a specific one of those calls.\n *\n * It is GENERATED per run, and the reviewer agent (`.claude/agents/<name>.md`, by default the\n * webpieces-owned `webpieces-reviewer.md`) is checklist-agnostic and points here, because content a human\n * maintains goes stale and a reviewer follows the stale copy. The verdict\n * schema in particular comes from {@link ReviewJsonService.renderVerdictSchema}.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewerInstructionsService {\n constructor(private readonly reviewJsonService: ReviewJsonService) {}\n\n /** The dir holding this branch's generated instructions, beside its summary.json. */\n instructionsDirFor(repoRoot: string, featureName: string): string {\n return path.join(this.reviewJsonService.prDirFor(repoRoot, featureName), 'instructions');\n }\n\n /** The file name for one checklist's generated instructions. */\n fileNameFor(checklistId: string): string {\n return `${checklistId}.instructions.md`;\n }\n\n /** Absolute path of one checklist's generated instructions file. */\n pathFor(repoRoot: string, featureName: string, checklistId: string): string {\n return path.join(this.instructionsDirFor(repoRoot, featureName), this.fileNameFor(checklistId));\n }\n\n render(briefing: ReviewerBriefing): string {\n return [\n ...this.identity(briefing),\n ...this.checklistSection(briefing),\n ...this.diffSection(briefing),\n ...this.sourceSection(briefing),\n ...this.contextSection(briefing),\n ...this.verdictSection(briefing),\n ...this.budgetSection(),\n ].join('\\n') + '\\n';\n }\n\n private identity(b: ReviewerBriefing): string[] {\n return [\n ...this.finalRoundHeader(b),\n `# Checklist \\`${b.checklistId}\\` — reviewed by a \\`${b.agentName}\\` subagent`,\n '',\n `Global reviewer round ${b.round} of ${b.maxRounds}.`,\n '',\n ...this.budgetCheck(b),\n 'Review this diff against THIS checklist only — not as a general code reviewer — and only over the',\n 'files in scope below. If you were handed several of these files, review each checklist separately',\n 'and write each one its own verdict. Never write a verdict for a checklist you were not handed.',\n '',\n `Your agent definition is \\`${this.agentFileFor(b)}\\`. If your harness did not load it for you`,\n '(Codex spawns a generic subagent), read it before anything else — it is the one canonical',\n 'definition of how a reviewer works here.',\n '',\n '\"You may not review your own authorship\" means: you did not write this diff, so review it — but if',\n 'the diff CHANGES YOU, say so in `output` rather than pretending the conflict is not there.',\n ...this.selfEditWarning(b),\n '',\n '_Generated per run by `wp-review-upsert-pr`. Everything below is already resolved for you; the',\n 'paths are absolute because your working directory is not guaranteed to be the repo root._',\n '',\n ];\n }\n\n /**\n * The FINAL round's header (issue #1053), FIRST in the file so nothing above it can be read as the rule.\n * On the last round `wp-write-review` refuses red, so a reviewer that learned this only at submission time\n * would have written its findings for a re-review that never happens.\n */\n private finalRoundHeader(b: ReviewerBriefing): string[] {\n if (b.round < b.maxRounds) return [];\n return [\n 'THIS IS THE FINAL REVIEW ROUND. There is no re-review. You may NOT mark red.',\n 'Mark anything that must be fixed as ORANGE, with a concrete, actionable fix. The author will apply it',\n 'best effort and ship without another review, so put every finding in now.',\n '',\n ];\n }\n\n /**\n * The FIRST thing a reviewer does (issue #1051): ask the gate whether this checklist may still be\n * reviewed. An author agent can spawn a reviewer from this file long after the round budget is spent —\n * the measured deadlock did — so the file itself carries the check, and `wp-write-review` enforces it.\n */\n private budgetCheck(b: ReviewerBriefing): string[] {\n return [\n '## FIRST — confirm this review is within the round budget',\n '',\n `Before you read anything else, run: \\`pnpm ${WRITE_REVIEW_BIN} --checklist ${b.checklistId} --check\\``,\n '',\n `It confirms that round ${b.round} is within \\`maxReviewerRounds\\` (${b.maxRounds}) and that`,\n `\\`${b.checklistId}\\` has no verdict yet in this round. If it REFUSES, do not review this checklist and`,\n 'submit nothing for it: report its refusal verbatim to the agent that spawned you. `wp-write-review`',\n 'refuses an over-budget verdict anyway, so a review past the budget is wasted work that cannot be recorded.',\n '',\n ];\n }\n\n /** The absolute path of the reviewer agent's committed definition (`.claude/agents/<agentName>.md`). */\n agentFileFor(b: ReviewerBriefing): string {\n return path.join(b.repoRoot, '.claude', 'agents', `${b.agentName}.md`);\n }\n\n /**\n * Every PR that edits the review gate hits this: on the measured run, 5 of 8 changed files were the\n * reviewer agent files themselves, two reviewers reviewed their OWN definition, and neither flagged it —\n * neither had any guidance to. Detected by the tooling rather than left to the reviewer to notice.\n */\n private selfEditWarning(b: ReviewerBriefing): string[] {\n if (b.ownAgentFileInDiff === '') return [];\n return [\n '',\n `⚠️ THIS DIFF MODIFIES YOUR OWN AGENT FILE: \\`${b.ownAgentFileInDiff}\\``,\n 'You are reviewing a change to your own definition. Review it anyway — and state that fact in',\n '`output`, so a human reading your verdict knows the reviewer and the reviewed were the same thing.',\n ];\n }\n\n private checklistSection(b: ReviewerBriefing): string[] {\n if (b.docPath === '') {\n return ['## Your checklist', '', 'This checklist has no guidance doc — judge the diff on your own standards.', ''];\n }\n return ['## Your checklist', '', `Read this FIRST: \\`${b.docPath}\\``, ''];\n }\n\n /**\n * The change itself. The MANIFEST leads, and the per-file table with it; `ALL.diff` is demoted to one\n * option among several, recommended only where it is actually the right read.\n *\n * That ordering is the fix for a measured 4/4 failure. `ALL.diff` used to be bolded, first, and framed as\n * \"everything\", with the manifest one unbolded line below it called a \"path map\" — which reads like a\n * lookup aid, not something to open. All four reviewers on that PR read `ALL.diff`, none opened the\n * manifest, and none could therefore have established that the combined view was complete. Reviewers did\n * exactly what the emphasis told them to; so the emphasis moved.\n */\n private diffSection(b: ReviewerBriefing): string[] {\n const lines = ['## The change you are reviewing', ''];\n if (b.remediationOnly) {\n lines.push(\n 'This is a REMEDIATION-ONLY re-review. Verify the claimed fixes and inspect the remediation',\n 'delta for regressions; do not restart a full review of the original branch diff.',\n '',\n `Previous reviewer verdict (verbatim): \\`${b.previousVerdictPath}\\``,\n `Author remediation response: \\`${b.remediationPath}\\``,\n '',\n );\n }\n if (b.dirty) {\n lines.push('> ⚠️ This diff INCLUDES uncommitted and untracked work, so it is not what a');\n lines.push('> commit-to-commit range would show. Judge it anyway — it is what your checklist matched.');\n lines.push('');\n }\n lines.push(...this.manifestLines(b), ...this.basisLines(b), ...this.myFilesTable(b), ...this.allDiffLines(b));\n if (b.fileDiffCommand !== '') {\n lines.push(`Reproduce any single file: \\`${b.fileDiffCommand}\\``);\n lines.push('');\n }\n lines.push('Path matching is COARSE. Judge the change, not the path — if a matched file turns out to be');\n lines.push('irrelevant to your checklist, say so in one sentence and move on.');\n lines.push('');\n return lines;\n }\n\n /**\n * The manifest, named as the authority AND with its own headline facts inlined. Inlining them is the\n * point: a reviewer that never opens the manifest still learns whether anything was truncated or\n * excluded, which is the one thing it could not otherwise have known it was missing.\n */\n private manifestLines(b: ReviewerBriefing): string[] {\n if (b.manifestPath === '') return [];\n const warn = b.truncatedCount + b.excludedCount > 0 ? ' ⚠️ NOT everything is materialized — see the table.' : '';\n return [\n `**Path map — AUTHORITATIVE. Read this first:** \\`${b.manifestPath}\\``,\n ` ${b.changedFileCount} file(s) · ${b.truncatedCount} truncated · ${b.excludedCount} excluded${warn}`,\n ' Per file it carries: `status` (M/A/D/U/X), `bytes`, `file`/`fileAbs`, `diffFile`/`diffAbs`, and the',\n ' three shas below. It is the only place that records what was truncated or left out.',\n '',\n ];\n }\n\n /**\n * What the diff is taken AGAINST. Two bare shas in a `git diff` command said nothing about this, so a\n * reviewer could not tell a fork-point diff from a diff against main's current tip — and therefore could\n * not tell that anything merged to main since the fork is simply absent from what it is judging.\n * Rendering C beside A makes \"main has moved\" self-evident exactly when it has.\n */\n private basisLines(b: ReviewerBriefing): string[] {\n if (b.hashForkPoint === '') return [];\n const sameAsFork = b.hashMainHead === b.hashForkPoint;\n const cNote = b.hashMainHead === '' ? '(unresolved)'\n : sameAsFork ? `${b.hashMainHead} ← same as A, so main has not moved since the fork`\n : `${b.hashMainHead} ← main HAS MOVED since the fork`;\n return [\n 'This diff is **fork-point → feature-head**, NOT a diff against main\\'s current tip:',\n '```',\n `fork point (A) ${b.hashForkPoint}`,\n `feature head (B) ${b.hashFeatureHead}`,\n `main head (C) ${cNote}`,\n '```',\n 'Anything merged to main after A is NOT in this diff.',\n '',\n ];\n }\n\n /**\n * Source and diff get IDENTICAL affordance — an absolute path each, in adjacent columns. The previous\n * table gave an absolute path for the diff and nothing for the source, and the source went unread 4/4.\n */\n private myFilesTable(b: ReviewerBriefing): string[] {\n if (b.myFiles.length === 0) return ['_No files matched your patterns._', ''];\n const why = b.matchedPatterns.length === 0\n ? `**In scope: ALL ${b.myFiles.length} changed file(s)** — your checklist has no \\`patterns\\`, so the whole diff is yours.`\n : `**In scope: ${b.myFiles.length} file(s)** matching ${b.matchedPatterns.map((p: string): string => `\\`${p}\\``).join(', ')}:`;\n const rows = b.myFiles.map((f: BriefedFile): string => this.fileRow(f));\n return [why, '', '| file | status | its diff | full source |', '|---|---|---|---|', ...rows, ''];\n }\n\n /**\n * One row. A truncated or excluded diff is flagged HERE, in the row, not left as a field inside a file the\n * reviewer has to think to open — and an oversized diff states the line count that makes a single Read\n * come back silently incomplete.\n */\n private fileRow(f: BriefedFile): string {\n const flags: string[] = [];\n if (f.truncated) flags.push('⚠️ diff TRUNCATED — read the source');\n if (f.status === 'X') flags.push('⚠️ EXCLUDED, not materialized — read the source');\n const status = [`\\`${f.status}\\``, ...flags].join(' ');\n const source = f.sourcePath === '' ? '_deleted — no file on disk_' : `\\`${f.sourcePath}\\``;\n return `| \\`${f.file}\\` | ${status} | \\`${f.diffPath}\\` (${f.diffBytes} bytes) | ${source} |`;\n }\n\n /**\n * `ALL.diff`, recommended ONLY where it is the right read. It is kept — for a patternless reviewer on a\n * small diff it is genuinely one Read instead of N, which is why all four used it — but the blanket\n * \"everything on this branch\" line was wrong in two different ways at once: it invited a pattern-scoped\n * reviewer to spend its budget on files it was explicitly not asked about, and it pointed a reviewer on a\n * large PR at a file that cannot survive one Read.\n */\n private allDiffLines(b: ReviewerBriefing): string[] {\n if (b.allDiffPath === '') return [];\n const size = b.allDiffLines === 0 ? '' : ` — ${b.allDiffLines} lines / ${b.allDiffBytes} bytes`;\n if (b.matchedPatterns.length > 0) {\n return [`The whole branch${size}, for CROSS-FILE CONTEXT if you need it: \\`${b.allDiffPath}\\``,\n 'Your own files above are what you are reviewing; the rest of the branch is someone else\\'s checklist.', ''];\n }\n if (b.allDiffLines > ALL_DIFF_ONE_READ_LINES) {\n return [`⚠️ The combined diff is ${b.allDiffLines} lines and will NOT survive a single Read (the Read tool`,\n `truncates at ~${READ_TRUNCATION_LINES} lines, silently). Read the per-file diffs above instead, or page it:`,\n `\\`${b.allDiffPath}\\``, ''];\n }\n return [`Whole-branch diff${size} — convenient at this size, but the per-file table above is authoritative:`,\n `\\`${b.allDiffPath}\\``, ''];\n }\n\n /**\n * The rule that used to say \"when you need to\", and lost 4/4 to the more emphatic budget section 40 lines\n * later. \"When you need to\" delegates the judgment to a reviewer that, by construction, does not yet know\n * what it is missing. It has no opt-out now.\n */\n private sourceSection(b: ReviewerBriefing): string[] {\n const lines = ['## Read the full source — every file, every time', '', `Repo root: \\`${b.repoRoot}\\``, ''];\n lines.push('**READ THE FULL SOURCE OF EVERY FILE IN YOUR TABLE.** Not \"if you need to\" — every time.');\n lines.push('A hunk shows what changed; only the whole file shows what it changed INTO, and a change that');\n lines.push('looks fine in isolation can still be wrong in place.');\n lines.push('');\n lines.push('The `full source` column above is the path. For files marked `A` (added) you have already done');\n lines.push('this: an add-diff IS the complete file, byte for byte, so its diff and its source are the same');\n lines.push('text. For `M` (modified) and `D` (deleted) files the diff is a fragment — open the file.');\n lines.push('');\n if (b.sourceDirs.length > 0) {\n lines.push('The neighbouring code lives under:');\n for (const dir of b.sourceDirs) lines.push(`- \\`${dir}\\``);\n lines.push('');\n }\n return lines;\n }\n\n /**\n * The section that deletes the `node_modules` greps. Entries come from config, because the tooling\n * cannot guess that a repo keeps its queue names in terraform — but it CAN resolve where a package\n * installed to, and it must never drop an entry silently: a missing path is stated as missing.\n */\n private contextSection(b: ReviewerBriefing): string[] {\n // Emitting NOTHING made the section this class exists for look like a feature that does not exist.\n // One line naming the config keys costs nothing and is the only hint a repo will ever get.\n if (b.contextEntries.length === 0) {\n return ['## Pre-resolved context', '',\n '_None configured for this repo. If you find yourself hunting for the same path on every review,',\n 'it belongs in `pr-gate.reviewContext` / `pr-gate.reviewContextPackages` in `webpieces.config.json`._',\n ''];\n }\n const lines = ['## Pre-resolved context (do not go hunting for these)', ''];\n for (const entry of b.contextEntries) {\n const suffix = entry.note === '' ? '' : ` ${entry.note}`;\n lines.push(`- **${entry.label}** — \\`${entry.path === '' ? entry.note : entry.path}\\`${entry.path === '' ? '' : suffix}`);\n }\n lines.push('');\n return lines;\n }\n\n /**\n * The verdict shape, GENERATED — never restated in a hand-maintained file. `id` is pre-filled with this\n * reviewer's own checklist id so there is nothing to substitute and nothing to get wrong.\n */\n private verdictSection(b: ReviewerBriefing): string[] {\n return [\n '## Submit your verdict',\n '',\n `Submit EXACTLY this shape through \\`${this.reviewJsonService.submitCommand(b.checklistId)}\\` —`,\n 'the JSON on stdin (a heredoc is simplest), or `--file <path>` naming a scratch file. Do NOT write',\n `\\`${b.verdictPath}\\` yourself: the bin validates the verdict, writes that file, and records that YOU`,\n 'submitted it, and `wp-finish-upsert-pr` REJECTS a verdict file written any other way. The bin also',\n 'refuses the coordinating agent, so nobody can submit this on your behalf.',\n '',\n '```',\n this.reviewJsonService.renderVerdictSchema(b.checklistId, ''),\n '```',\n '',\n ];\n }\n\n /**\n * The anti-hunting rule, with the changed files carved out explicitly.\n *\n * It used to read as \"stay inside what you were given\" and, being the LAST thing in the file, it beat\n * the source-reading instruction 4 times out of 4. It never distinguished HUNTING — greps into\n * `node_modules`, re-deriving the dependency graph — from OPENING A FILE IT WAS EXPLICITLY HANDED. The\n * distinction is now stated, because where two instructions conflict the later and more emphatic one wins.\n */\n private budgetSection(): string[] {\n return [\n '## Budget',\n '',\n 'Do NOT search `node_modules`, do NOT re-derive the dependency graph, and do NOT hunt the repo for',\n 'infrastructure config. That is hunting, and it is what wastes a review budget — those paths are',\n 'either given above or were not configured.',\n '',\n 'Reading the full text of a file that is IN your table is NOT hunting — it is the review. Budget for',\n 'it: read the diff to see what changed, and the source to judge whether it is right in place.',\n '',\n 'If something you genuinely need is missing, name it in `output` and give your verdict on what you',\n 'could actually see.',\n '',\n 'Open your diff files before writing a verdict. `wp-finish-upsert-pr` reads your own transcript and',\n 'reports a verdict written without opening the diff. It also records the path of that transcript,',\n 'beside what you were offered and what you read, in `provenance.json` next to your verdict file —',\n 'so the review is auditable after the fact. You do not write that file, or the',\n '`review-round<N>-<id>.provenance.json` wp-write-review writes beside your verdict; the tooling does.',\n ];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"reviewer-instructions.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/reviewer-instructions.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,yCAA2D;AAC3D,+CAAkD;AAClD,sEAAiE;AAEjE,2GAA2G;AAC3G,MAAa,YAAY;IACrB,KAAK,CAAS;IACd,IAAI,CAAS,CAAK,gDAAgD;IAClE,IAAI,CAAS,CAAK,0EAA0E;IAE5F,YAAY,KAAa,EAAE,SAAiB,EAAE,IAAI,GAAG,EAAE;QACnD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACJ;AAVD,oCAUC;AAED;;;;;;;GAOG;AACH,MAAa,WAAW;IACpB,IAAI,CAAS,CAAQ,4BAA4B;IACjD,QAAQ,CAAS,CAAI,uCAAuC;IAC5D,UAAU,CAAS,CAAE,oFAAoF;IACzG,MAAM,CAAS,CAAM,+DAA+D;IACpF,SAAS,CAAS;IAClB,SAAS,CAAU;IAEnB,yDAAyD;IACzD,YAAY,IAAY,EAAE,QAAgB,EAAE,UAAU,GAAG,EAAE,EAAE,MAAM,GAAG,GAAG,EAAE,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,KAAK;QACvG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IA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K,CAAC,IAAI,CAAC,OAAO,KAAK,CAAC,KAAK,UAAU,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAC9H,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;OAGG;IACK,cAAc,CAAC,CAAmB;QACtC,OAAO;YACH,wBAAwB;YACxB,EAAE;YACF,uCAAuC,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM;YAChG,mGAAmG;YACnG,KAAK,CAAC,CAAC,WAAW,oFAAoF;YACtG,oGAAoG;YACpG,2EAA2E;YAC3E,EAAE;YACF,KAAK;YACL,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YAC7D,KAAK;YACL,EAAE;SACL,CAAC;IACN,CAAC;IAED;;;;;;;OAOG;IACK,aAAa;QACjB,OAAO;YACH,WAAW;YACX,EAAE;YACF,mGAAmG;YACnG,iGAAiG;YACjG,4CAA4C;YAC5C,EAAE;YACF,qGAAqG;YACrG,8FAA8F;YAC9F,EAAE;YACF,mGAAmG;YACnG,qBAAqB;YACrB,EAAE;YACF,oGAAoG;YACpG,kGAAkG;YAClG,kGAAkG;YAClG,+EAA+E;YAC/E,sGAAsG;SACzG,CAAC;IACN,CAAC;CACJ,CAAA;AAtVY,kEAA2B;sCAA3B,2BAA2B;IADvC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEW,+BAAiB;GADxD,2BAA2B,CAsVvC","sourcesContent":["import * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { ReviewJsonService } from './review-json';\nimport { WRITE_REVIEW_BIN } from '@webpieces/repo-workflow-core';\n\n/** One pre-resolved place a reviewer would otherwise have to go hunting for. Data-only (per CLAUDE.md). */\nexport class ContextEntry {\n label: string;\n path: string; // ABSOLUTE, or '' when it could not be resolved\n note: string; // '(not installed)' / '(configured but missing)' — never silently dropped\n\n constructor(label: string, entryPath: string, note = '') {\n this.label = label;\n this.path = entryPath;\n this.note = note;\n }\n}\n\n/**\n * One reviewer's matched file, the extracted diff for it, AND the absolute path of the file itself.\n *\n * `sourcePath` exists because of a measured 0/4: four reviewers on one PR read the diff and not one opened a\n * single full source file. The instructions handed them an absolute path per diff and only a parent DIRECTORY\n * per source, so reading the diff was a paste and reading the source was \"join this dir to that filename\n * yourself\". Identical affordance, or the cheaper one wins every time. Data-only.\n */\nexport class BriefedFile {\n file: string; // repo-relative source path\n diffPath: string; // ABSOLUTE path of the extracted .diff\n sourcePath: string; // ABSOLUTE path of the file itself; '' for a deleted file, which has no after-state\n status: string; // 'M' | 'A' | 'D' | 'U' (untracked) | 'X' (excluded by config)\n diffBytes: number;\n truncated: boolean;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(file: string, diffPath: string, sourcePath = '', status = 'M', diffBytes = 0, truncated = false) {\n this.file = file;\n this.diffPath = diffPath;\n this.sourcePath = sourcePath;\n this.status = status;\n this.diffBytes = diffBytes;\n this.truncated = truncated;\n }\n}\n\n/**\n * Everything ONE reviewer needs, with every path already resolved to an ABSOLUTE one.\n *\n * Absolute is not fussiness: a subagent's working directory is not guaranteed to be the repo root, and a\n * relative path that fails to resolve turns into a search, which is the cost this whole class exists to\n * remove. Data-only.\n */\nexport class ReviewerBriefing {\n agentName: string; // the agent type the subagent is spawned as (webpieces-reviewer, or the override)\n docPath: string; // the checklist's guidance doc ('' when the checklist has none)\n repoRoot: string;\n diffDir: string; // '' when nothing was materialized\n allDiffPath: string;\n manifestPath: string;\n myFiles: BriefedFile[]; // ONLY this reviewer's matched files\n matchedPatterns: string[]; // [] ⇒ patternless: the whole diff is in scope\n sourceDirs: string[]; // deduped ABSOLUTE parent dirs of myFiles\n contextEntries: ContextEntry[];\n verdictPath: string; // ABSOLUTE review-round<N>-<id>.json\n checklistId: string;\n fileDiffCommand: string;\n dirty: boolean;\n // Facts ABOUT the manifest, surfaced inline so a reviewer learns the diff is complete without opening it.\n changedFileCount: number;\n truncatedCount: number;\n excludedCount: number;\n allDiffLines: number;\n allDiffBytes: number;\n // The three shas, by the names DiffManifest already uses. Printing two bare shas told a reviewer nothing\n // about WHAT the diff is taken against; C beside A makes \"main has moved since the fork\" self-evident.\n hashForkPoint: string;\n hashFeatureHead: string;\n hashMainHead: string;\n ownAgentFileInDiff: string; // ABSOLUTE path when this diff edits the reviewer agent's own file; '' otherwise\n // From the checklist's config `required`. Carried so the stage-② report can group the spawn blocks\n // (must run) apart from the ones the human is merely OFFERED, without a second lookup that could\n // disagree with the scan. The reviewer's OWN instructions do not mention it: a reviewer that has been\n // spawned reviews the same way either way, and telling an optional one it was optional invites it to\n // grade itself softer.\n required: boolean;\n round: number;\n maxRounds: number;\n remediationOnly: boolean;\n previousVerdictPath: string;\n remediationPath: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(agentName: string, checklistId: string, repoRoot: string) {\n this.agentName = agentName;\n this.checklistId = checklistId;\n this.repoRoot = repoRoot;\n this.docPath = '';\n this.diffDir = '';\n this.allDiffPath = '';\n this.manifestPath = '';\n this.myFiles = [];\n this.matchedPatterns = [];\n this.sourceDirs = [];\n this.contextEntries = [];\n this.verdictPath = '';\n this.fileDiffCommand = '';\n this.dirty = false;\n this.changedFileCount = 0;\n this.truncatedCount = 0;\n this.excludedCount = 0;\n this.allDiffLines = 0;\n this.allDiffBytes = 0;\n this.hashForkPoint = '';\n this.hashFeatureHead = '';\n this.hashMainHead = '';\n this.ownAgentFileInDiff = '';\n // Fails CLOSED, like RequiredChecklist.required: a briefing built without the flag being copied is\n // treated as a blocking reviewer, never as a skippable one.\n this.required = true;\n this.round = 1;\n this.maxRounds = 1;\n this.remediationOnly = false;\n this.previousVerdictPath = '';\n this.remediationPath = '';\n }\n}\n\n/**\n * The Read tool truncates at roughly this many lines, silently. Any path this file prints alongside a bigger\n * line count has to say so, or a reviewer reviews a fraction of a change and reports on all of it.\n */\nexport const READ_TRUNCATION_LINES = 2000;\n\n/** Comfortably under {@link READ_TRUNCATION_LINES} — the size at which ALL.diff really is one clean Read. */\nexport const ALL_DIFF_ONE_READ_LINES = 1500;\n\n/**\n * Renders the per-reviewer instructions file that `wp-review-upsert-pr` writes to\n * `.webpieces/pr-review/<feature>/instructions/<checklistId>.instructions.md` — ONE PER CHECKLIST, so a\n * subagent covering several checklists (`commands.pr-gate.reviewerAgents`) is simply handed several files.\n *\n * WHY this file exists, measured rather than assumed: a reviewer subagent on consumer-monorepo2 spent **14 of its\n * 26 tool calls** rediscovering context the tooling already had — three separate greps into\n * `node_modules/@webpieces` to locate a scanner, a hunt through terraform for queue names, and a\n * re-derivation of the dependency graph. It did not over-review; it was under-supplied. Everything below is\n * chosen to delete a specific one of those calls.\n *\n * It is GENERATED per run, and the reviewer agent (`.claude/agents/<name>.md`, by default the\n * webpieces-owned `webpieces-reviewer.md`) is checklist-agnostic and points here, because content a human\n * maintains goes stale and a reviewer follows the stale copy. The verdict\n * schema in particular comes from {@link ReviewJsonService.renderVerdictSchema}.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ReviewerInstructionsService {\n constructor(private readonly reviewJsonService: ReviewJsonService) {}\n\n /** The dir holding this branch's generated instructions, beside its summary.json. */\n instructionsDirFor(repoRoot: string, featureName: string): string {\n return path.join(this.reviewJsonService.prDirFor(repoRoot, featureName), 'instructions');\n }\n\n /** The file name for one checklist's generated instructions. */\n fileNameFor(checklistId: string): string {\n return `${checklistId}.instructions.md`;\n }\n\n /** Absolute path of one checklist's generated instructions file. */\n pathFor(repoRoot: string, featureName: string, checklistId: string): string {\n return path.join(this.instructionsDirFor(repoRoot, featureName), this.fileNameFor(checklistId));\n }\n\n render(briefing: ReviewerBriefing): string {\n return [\n ...this.identity(briefing),\n ...this.checklistSection(briefing),\n ...this.diffSection(briefing),\n ...this.sourceSection(briefing),\n ...this.contextSection(briefing),\n ...this.verdictSection(briefing),\n ...this.budgetSection(),\n ].join('\\n') + '\\n';\n }\n\n private identity(b: ReviewerBriefing): string[] {\n return [\n ...this.finalRoundHeader(b),\n `# Checklist \\`${b.checklistId}\\` — reviewed by a \\`${b.agentName}\\` subagent`,\n '',\n `Global reviewer round ${b.round} of ${b.maxRounds}.`,\n '',\n ...this.budgetCheck(b),\n 'Review this diff against THIS checklist only — not as a general code reviewer — and only over the',\n 'files in scope below. If you were handed several of these files, review each checklist separately',\n 'and write each one its own verdict. Never write a verdict for a checklist you were not handed.',\n '',\n `Your agent definition is \\`${this.agentFileFor(b)}\\`. If your harness did not load it for you`,\n '(Codex spawns a generic subagent), read it before anything else — it is the one canonical',\n 'definition of how a reviewer works here.',\n '',\n '\"You may not review your own authorship\" means: you did not write this diff, so review it — but if',\n 'the diff CHANGES YOU, say so in `output` rather than pretending the conflict is not there.',\n ...this.selfEditWarning(b),\n '',\n '_Generated per run by `wp-review-upsert-pr`. Everything below is already resolved for you; the',\n 'paths are absolute because your working directory is not guaranteed to be the repo root._',\n '',\n ];\n }\n\n /**\n * The FINAL round's header (issue #1053), FIRST in the file so nothing above it can be read as the rule.\n * On the last round `wp-write-review` refuses red, so a reviewer that learned this only at submission time\n * would have written its findings for a re-review that never happens.\n */\n private finalRoundHeader(b: ReviewerBriefing): string[] {\n if (b.round < b.maxRounds) return [];\n return [\n 'THIS IS THE FINAL REVIEW ROUND. There is no re-review. You may NOT mark red.',\n 'Mark anything that must be fixed as ORANGE, with a concrete, actionable fix. The author will apply it',\n 'best effort and ship without another review, so put every finding in now.',\n '',\n ];\n }\n\n /**\n * The FIRST thing a reviewer does (issue #1051): ask the gate whether this checklist may still be\n * reviewed. An author agent can spawn a reviewer from this file long after the round budget is spent —\n * the measured deadlock did — so the file itself carries the check, and `wp-write-review` enforces it.\n */\n private budgetCheck(b: ReviewerBriefing): string[] {\n return [\n '## FIRST — confirm this review is within the round budget',\n '',\n `Before you read anything else, run: \\`pnpm ${WRITE_REVIEW_BIN} --checklist ${b.checklistId} --check\\``,\n '',\n `It confirms that round ${b.round} is within \\`maxReviewerRounds\\` (${b.maxRounds}) and that`,\n `\\`${b.checklistId}\\` has no verdict yet in this round. If it REFUSES, do not review this checklist and`,\n 'submit nothing for it: report its refusal verbatim to the agent that spawned you. `wp-write-review`',\n 'refuses an over-budget verdict anyway, so a review past the budget is wasted work that cannot be recorded.',\n '',\n ];\n }\n\n /** The absolute path of the reviewer agent's committed definition (`.claude/agents/<agentName>.md`). */\n agentFileFor(b: ReviewerBriefing): string {\n return path.join(b.repoRoot, '.claude', 'agents', `${b.agentName}.md`);\n }\n\n /**\n * Every PR that edits the review gate hits this: on the measured run, 5 of 8 changed files were the\n * reviewer agent files themselves, two reviewers reviewed their OWN definition, and neither flagged it —\n * neither had any guidance to. Detected by the tooling rather than left to the reviewer to notice.\n */\n private selfEditWarning(b: ReviewerBriefing): string[] {\n if (b.ownAgentFileInDiff === '') return [];\n return [\n '',\n `⚠️ THIS DIFF MODIFIES YOUR OWN AGENT FILE: \\`${b.ownAgentFileInDiff}\\``,\n 'You are reviewing a change to your own definition. Review it anyway — and state that fact in',\n '`output`, so a human reading your verdict knows the reviewer and the reviewed were the same thing.',\n ];\n }\n\n private checklistSection(b: ReviewerBriefing): string[] {\n if (b.docPath === '') {\n return ['## Your checklist', '', 'This checklist has no guidance doc — judge the diff on your own standards.', ''];\n }\n return ['## Your checklist', '', `Read this FIRST: \\`${b.docPath}\\``, ''];\n }\n\n /**\n * The change itself. The MANIFEST leads, and the per-file table with it; `ALL.diff` is demoted to one\n * option among several, recommended only where it is actually the right read.\n *\n * That ordering is the fix for a measured 4/4 failure. `ALL.diff` used to be bolded, first, and framed as\n * \"everything\", with the manifest one unbolded line below it called a \"path map\" — which reads like a\n * lookup aid, not something to open. All four reviewers on that PR read `ALL.diff`, none opened the\n * manifest, and none could therefore have established that the combined view was complete. Reviewers did\n * exactly what the emphasis told them to; so the emphasis moved.\n */\n private diffSection(b: ReviewerBriefing): string[] {\n const lines = ['## The change you are reviewing', ''];\n if (b.remediationOnly) {\n lines.push(\n 'This is a REMEDIATION-ONLY re-review. Verify the claimed fixes and inspect the remediation',\n 'delta for regressions; do not restart a full review of the original branch diff.',\n '',\n `Previous reviewer verdict (verbatim): \\`${b.previousVerdictPath}\\``,\n `Author remediation response: \\`${b.remediationPath}\\``,\n '',\n );\n }\n if (b.dirty) {\n lines.push('> ⚠️ This diff INCLUDES uncommitted and untracked work, so it is not what a');\n lines.push('> commit-to-commit range would show. Judge it anyway — it is what your checklist matched.');\n lines.push('');\n }\n lines.push(...this.manifestLines(b), ...this.basisLines(b), ...this.myFilesTable(b), ...this.allDiffLines(b));\n if (b.fileDiffCommand !== '') {\n lines.push(`Reproduce any single file: \\`${b.fileDiffCommand}\\``);\n lines.push('');\n }\n lines.push('Path matching is COARSE. Judge the change, not the path — if a matched file turns out to be');\n lines.push('irrelevant to your checklist, say so in one sentence and move on.');\n lines.push('');\n return lines;\n }\n\n /**\n * The manifest, named as the authority AND with its own headline facts inlined. Inlining them is the\n * point: a reviewer that never opens the manifest still learns whether anything was truncated or\n * excluded, which is the one thing it could not otherwise have known it was missing.\n */\n private manifestLines(b: ReviewerBriefing): string[] {\n if (b.manifestPath === '') return [];\n const warn = b.truncatedCount + b.excludedCount > 0 ? ' ⚠️ NOT everything is materialized — see the table.' : '';\n return [\n `**Path map — AUTHORITATIVE. Read this first:** \\`${b.manifestPath}\\``,\n ` ${b.changedFileCount} file(s) · ${b.truncatedCount} truncated · ${b.excludedCount} excluded${warn}`,\n ' Per file it carries: `status` (M/A/D/U/X), `bytes`, `file`/`fileAbs`, `diffFile`/`diffAbs`, and the',\n ' three shas below. It is the only place that records what was truncated or left out.',\n '',\n ];\n }\n\n /**\n * What the diff is taken AGAINST. Two bare shas in a `git diff` command said nothing about this, so a\n * reviewer could not tell a fork-point diff from a diff against main's current tip — and therefore could\n * not tell that anything merged to main since the fork is simply absent from what it is judging.\n * Rendering C beside A makes \"main has moved\" self-evident exactly when it has.\n */\n private basisLines(b: ReviewerBriefing): string[] {\n if (b.hashForkPoint === '') return [];\n const sameAsFork = b.hashMainHead === b.hashForkPoint;\n const cNote = b.hashMainHead === '' ? '(unresolved)'\n : sameAsFork ? `${b.hashMainHead} ← same as A, so main has not moved since the fork`\n : `${b.hashMainHead} ← main HAS MOVED since the fork`;\n return [\n 'This diff is **fork-point → feature-head**, NOT a diff against main\\'s current tip:',\n '```',\n `fork point (A) ${b.hashForkPoint}`,\n `feature head (B) ${b.hashFeatureHead}`,\n `main head (C) ${cNote}`,\n '```',\n 'Anything merged to main after A is NOT in this diff.',\n '',\n ];\n }\n\n /**\n * Source and diff get IDENTICAL affordance — an absolute path each, in adjacent columns. The previous\n * table gave an absolute path for the diff and nothing for the source, and the source went unread 4/4.\n */\n private myFilesTable(b: ReviewerBriefing): string[] {\n if (b.myFiles.length === 0) return ['_No files matched your patterns._', ''];\n const why = b.matchedPatterns.length === 0\n ? `**In scope: ALL ${b.myFiles.length} changed file(s)** — your checklist has no \\`patterns\\`, so the whole diff is yours.`\n : `**In scope: ${b.myFiles.length} file(s)** matching ${b.matchedPatterns.map((p: string): string => `\\`${p}\\``).join(', ')}:`;\n const rows = b.myFiles.map((f: BriefedFile): string => this.fileRow(f));\n return [why, '', '| file | status | its diff | full source |', '|---|---|---|---|', ...rows, ''];\n }\n\n /**\n * One row. A truncated or excluded diff is flagged HERE, in the row, not left as a field inside a file the\n * reviewer has to think to open — and an oversized diff states the line count that makes a single Read\n * come back silently incomplete.\n */\n private fileRow(f: BriefedFile): string {\n const flags: string[] = [];\n if (f.truncated) flags.push('⚠️ diff TRUNCATED — read the source');\n if (f.status === 'X') flags.push('⚠️ EXCLUDED, not materialized — read the source');\n const status = [`\\`${f.status}\\``, ...flags].join(' ');\n const source = f.sourcePath === '' ? '_deleted — no file on disk_' : `\\`${f.sourcePath}\\``;\n return `| \\`${f.file}\\` | ${status} | \\`${f.diffPath}\\` (${f.diffBytes} bytes) | ${source} |`;\n }\n\n /**\n * `ALL.diff`, recommended ONLY where it is the right read. It is kept — for a patternless reviewer on a\n * small diff it is genuinely one Read instead of N, which is why all four used it — but the blanket\n * \"everything on this branch\" line was wrong in two different ways at once: it invited a pattern-scoped\n * reviewer to spend its budget on files it was explicitly not asked about, and it pointed a reviewer on a\n * large PR at a file that cannot survive one Read.\n */\n private allDiffLines(b: ReviewerBriefing): string[] {\n if (b.allDiffPath === '') return [];\n const size = b.allDiffLines === 0 ? '' : ` — ${b.allDiffLines} lines / ${b.allDiffBytes} bytes`;\n if (b.matchedPatterns.length > 0) {\n return [`The whole branch${size}, for CROSS-FILE CONTEXT if you need it: \\`${b.allDiffPath}\\``,\n 'Your own files above are what you are reviewing; the rest of the branch is someone else\\'s checklist.', ''];\n }\n if (b.allDiffLines > ALL_DIFF_ONE_READ_LINES) {\n return [`⚠️ The combined diff is ${b.allDiffLines} lines and will NOT survive a single Read (the Read tool`,\n `truncates at ~${READ_TRUNCATION_LINES} lines, silently). Read the per-file diffs above instead, or page it:`,\n `\\`${b.allDiffPath}\\``, ''];\n }\n return [`Whole-branch diff${size} — convenient at this size, but the per-file table above is authoritative:`,\n `\\`${b.allDiffPath}\\``, ''];\n }\n\n /**\n * The rule that used to say \"when you need to\", and lost 4/4 to the more emphatic budget section 40 lines\n * later. \"When you need to\" delegates the judgment to a reviewer that, by construction, does not yet know\n * what it is missing. It has no opt-out now.\n */\n private sourceSection(b: ReviewerBriefing): string[] {\n const lines = ['## Read the full source — every file, every time', '', `Repo root: \\`${b.repoRoot}\\``, ''];\n lines.push('**READ THE FULL SOURCE OF EVERY FILE IN YOUR TABLE.** Not \"if you need to\" — every time.');\n lines.push('A hunk shows what changed; only the whole file shows what it changed INTO, and a change that');\n lines.push('looks fine in isolation can still be wrong in place.');\n lines.push('');\n lines.push('The `full source` column above is the path. For files marked `A` (added) you have already done');\n lines.push('this: an add-diff IS the complete file, byte for byte, so its diff and its source are the same');\n lines.push('text. For `M` (modified) and `D` (deleted) files the diff is a fragment — open the file.');\n lines.push('');\n if (b.sourceDirs.length > 0) {\n lines.push('The neighbouring code lives under:');\n for (const dir of b.sourceDirs) lines.push(`- \\`${dir}\\``);\n lines.push('');\n }\n return lines;\n }\n\n /**\n * The section that deletes the `node_modules` greps. Entries come from config, because the tooling\n * cannot guess that a repo keeps its queue names in terraform — but it CAN resolve where a package\n * installed to, and it must never drop an entry silently: a missing path is stated as missing.\n */\n private contextSection(b: ReviewerBriefing): string[] {\n // Emitting NOTHING made the section this class exists for look like a feature that does not exist.\n // One line naming the config keys costs nothing and is the only hint a repo will ever get.\n if (b.contextEntries.length === 0) {\n return ['## Pre-resolved context', '',\n '_None configured for this repo. If you find yourself hunting for the same path on every review,',\n 'it belongs in `pr-gate.reviewContext` / `pr-gate.reviewContextPackages` in `webpieces.config.json`._',\n ''];\n }\n const lines = ['## Pre-resolved context (do not go hunting for these)', ''];\n for (const entry of b.contextEntries) {\n const suffix = entry.note === '' ? '' : ` ${entry.note}`;\n lines.push(`- **${entry.label}** — \\`${entry.path === '' ? entry.note : entry.path}\\`${entry.path === '' ? '' : suffix}`);\n }\n lines.push('');\n return lines;\n }\n\n /**\n * The verdict shape, GENERATED — never restated in a hand-maintained file. `id` is pre-filled with this\n * reviewer's own checklist id so there is nothing to substitute and nothing to get wrong.\n */\n private verdictSection(b: ReviewerBriefing): string[] {\n return [\n '## Submit your verdict',\n '',\n `Submit EXACTLY this shape through \\`${this.reviewJsonService.submitCommand(b.checklistId)}\\` —`,\n 'the JSON on stdin (a heredoc is simplest), or `--file <path>` naming a scratch file. Do NOT write',\n `\\`${b.verdictPath}\\` yourself: the bin validates the verdict, writes that file, and records that YOU`,\n 'submitted it, and `wp-finish-upsert-pr` REJECTS a verdict file written any other way. The bin also',\n 'refuses the coordinating agent, so nobody can submit this on your behalf.',\n '',\n '```',\n this.reviewJsonService.renderVerdictSchema(b.checklistId, ''),\n '```',\n '',\n ];\n }\n\n /**\n * The anti-hunting rule, with the changed files carved out explicitly.\n *\n * It used to read as \"stay inside what you were given\" and, being the LAST thing in the file, it beat\n * the source-reading instruction 4 times out of 4. It never distinguished HUNTING — greps into\n * `node_modules`, re-deriving the dependency graph — from OPENING A FILE IT WAS EXPLICITLY HANDED. The\n * distinction is now stated, because where two instructions conflict the later and more emphatic one wins.\n */\n private budgetSection(): string[] {\n return [\n '## Budget',\n '',\n 'Do NOT search `node_modules`, do NOT re-derive the dependency graph, and do NOT hunt the repo for',\n 'infrastructure config. That is hunting, and it is what wastes a review budget — those paths are',\n 'either given above or were not configured.',\n '',\n 'Reading the full text of a file that is IN your table is NOT hunting — it is the review. Budget for',\n 'it: read the diff to see what changed, and the source to judge whether it is right in place.',\n '',\n 'If something you genuinely need is missing, name it in `output` and give your verdict on what you',\n 'could actually see.',\n '',\n 'Open your diff files before writing a verdict. `wp-finish-upsert-pr` reads your own transcript and',\n 'reports a verdict written without opening the diff. It also records the path of that transcript,',\n 'beside what you were offered and what you read, in `provenance.json` next to your verdict file —',\n 'so the review is auditable after the fact. You do not write that file, or the',\n '`review-round<N>-<id>.provenance.json` wp-write-review writes beside your verdict; the tooling does.',\n ];\n }\n}\n"]}
|
package/src/stale-bin-sweep.js
CHANGED
|
@@ -50,7 +50,7 @@ const to_error_1 = require("@webpieces/tooling-common/to-error");
|
|
|
50
50
|
// the whole safety story: another package's bins are never touched.
|
|
51
51
|
//
|
|
52
52
|
// WHY NOT A postinstall HOOK. `setupDebugging.md` records the postinstall approach as ABANDONED in this
|
|
53
|
-
// repo. The call site is the `wp-*` startup pass that regenerates `.webpieces
|
|
53
|
+
// repo. The call site is the `wp-*` startup pass that regenerates `.webpieces/instruct-ai/*` — see
|
|
54
54
|
// TemplateWriter — and that placement is the load-bearing half of the fix. This is not a tidy-up for one
|
|
55
55
|
// repo: every developer's machine has this graveyard, and a cure that only cleans the tree somebody happens
|
|
56
56
|
// to run it in is worthless. Riding the pass EVERY `wp-*` command takes is what makes the RELEASED sweep
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stale-bin-sweep.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/stale-bin-sweep.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,iEAA6D;AAE7D,8EAA8E;AAC9E,oDAAoD;AACpD,EAAE;AACF,0GAA0G;AAC1G,wGAAwG;AACxG,uGAAuG;AACvG,sGAAsG;AACtG,sFAAsF;AACtF,EAAE;AACF,kGAAkG;AAClG,2GAA2G;AAC3G,yGAAyG;AACzG,0GAA0G;AAC1G,2GAA2G;AAC3G,gGAAgG;AAChG,sGAAsG;AACtG,0GAA0G;AAC1G,wBAAwB;AACxB,EAAE;AACF,yGAAyG;AACzG,kGAAkG;AAClG,oGAAoG;AACpG,yGAAyG;AACzG,qGAAqG;AACrG,uGAAuG;AACvG,yGAAyG;AACzG,0GAA0G;AAC1G,iGAAiG;AACjG,EAAE;AACF,yGAAyG;AACzG,0GAA0G;AAC1G,wFAAwF;AACxF,0GAA0G;AAC1G,gGAAgG;AAChG,EAAE;AACF,wGAAwG;AACxG,yGAAyG;AACzG,wGAAwG;AACxG,yGAAyG;AACzG,mGAAmG;AACnG,kHAAkH;AAClH,0GAA0G;AAC1G,oEAAoE;AACpE,EAAE;AACF,wGAAwG;AACxG,wGAAwG;AACxG,yGAAyG;AACzG,4GAA4G;AAC5G,yGAAyG;AACzG,oGAAoG;AACpG,EAAE;AACF,2GAA2G;AAC3G,2GAA2G;AAC3G,wGAAwG;AACxG,2GAA2G;AAC3G,0GAA0G;AAC1G,yEAAyE;AACzE,EAAE;AACF,yGAAyG;AACzG,8FAA8F;AAC9F,8EAA8E;AAE9E,4FAA4F;AAC5F,MAAM,aA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AE;gBAAE,OAAO,IAAI,CAAC;YACtD,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;gBAAE,OAAO,IAAI,CAAC;YACrC,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,IAAA,kBAAO,EAAC,GAAG,CAAC,CAAC;YAC3B,KAAK,KAAK,CAAC,CAAC,gEAAgE;YAC5E,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;CACJ;AAzHD,0CAyHC;AAED,oGAAoG;AACvF,QAAA,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { toError } from '@webpieces/tooling-common/to-error';\n\n// ---------------------------------------------------------------------------\n// SWEEP DANGLING `node_modules/.bin/wp-*` SYMLINKS.\n//\n// THE DEFECT. pnpm's linker ADDS a link for every entry in the current manifest's `bin` map, but it never\n// sweeps `.bin` for orphans left behind by a PREVIOUS version of the SAME package. `@webpieces/pr-gate`\n// and `@webpieces/ai-hook-rules` are upgraded, never removed, so nothing ever triggers a delete: every\n// bin either package has EVER shipped stays linked forever, pointing at a script that is no longer on\n// disk. A scan of nine clones on ONE machine found 18 distinct dangling `wp-*` names.\n//\n// THE DEFECT IS ONGOING, AND A ROUTINE RENAME PRODUCES IT. Measured on this repo's own upgrade to\n// 0.4.728, DURING the session that wrote this file: PR #743 hard-renamed one `wp-*` command with no alias,\n// so the new manifest declares `wp-sync-main` and no longer declares its predecessor. One `pnpm install`\n// later, `.bin` held the NEW link created that minute AND the predecessor's link still sitting there from\n// the previous install, dangling — reproduced independently in two separate trees of this repo. So this is\n// not a historical mess left by a deleted feature that a one-time migration could mop up: it is\n// regenerated by the most ordinary change a package can make, on every clone, every time. That is the\n// argument for the call site below — the sweep has to ride a path that runs ROUTINELY, because the defect\n// is created routinely.\n//\n// The predecessor's NAME is deliberately not written here, and DO NOT WRITE IT BACK IN. Two reasons, and\n// the second is the one that matters. First, nothing in the code needs it: the predicate below is\n// STRUCTURAL — a `wp-*` entry whose link target does not resolve — so naming one particular retired\n// command would invite a reader to think the sweep is a list of known dead names somebody has to keep up\n// to date. Second, a retired command named in tracked source is exactly how a dead name outlives its\n// tooling: it gets copied into a cure string, and an agent reading that cure at the moment every other\n// route is closed is handed a command that does not exist. That is the very defect this module cleans up\n// one level out, and there is no longer an automated scan standing behind this paragraph — the reader is.\n// PR #743 and the issue this shipped under carry the literal name; nothing in the tree needs to.\n//\n// WHY IT MATTERS MORE THAN TIDINESS. `ls node_modules/.bin` lists them, so a dangling entry ADVERTISES a\n// capability that does not exist — a human and an AI were both misled by that listing before checking the\n// link target — and the failure it eventually produces is self-referential and useless:\n// `Command \"wp-authorize\" not found / Did you mean \"pnpm wp-authorize\"?`. This is `upgrade-shim.ts`'s own\n// governing principle one level out: an entry pointing at a missing file is WORSE than absence.\n//\n// WHY A PREFIX AND NOT A NAME LIST. A hardcoded list of retired bin names would go stale in exactly the\n// way the symlinks did — the list assembled from the two names that prompted this would have caught 2 of\n// the 18, and it would NOT have caught the rename above, which had not happened yet when the list would\n// have been written. That is the general case: the next orphan is always created by a release later than\n// any list. A name list is also unwriteable here on purpose — see the note above about naming dead\n// commands in source. The predicate is structural instead — a `wp-` prefixed entry that is a SYMLINK whose target\n// does not exist — so it needs no maintenance and cannot miss a name nobody has thought of. The prefix is\n// the whole safety story: another package's bins are never touched.\n//\n// WHY NOT A postinstall HOOK. `setupDebugging.md` records the postinstall approach as ABANDONED in this\n// repo. The call site is the `wp-*` startup pass that regenerates `.webpieces-logs/instruct-ai/*` — see\n// TemplateWriter — and that placement is the load-bearing half of the fix. This is not a tidy-up for one\n// repo: every developer's machine has this graveyard, and a cure that only cleans the tree somebody happens\n// to run it in is worthless. Riding the pass EVERY `wp-*` command takes is what makes the RELEASED sweep\n// reach every clone on every machine, healing each one the next time any `wp-*` command runs there.\n//\n// NOT ALSO CALLED FROM `wp-upgrade-shim`, though it would read naturally there (that bin already deletes a\n// retired FILE on the same principle). `upgrade-shim.ts` may import only `fs`/`path` so it still runs on a\n// tree too broken to load the rule engine: this package's barrel would pull in inversify and the config\n// loader, and a subpath import would resolve against the INSTALLED rules-config, which is a release behind\n// the local source — so a spawned `wp-upgrade-shim` would die on module resolution, in the one command an\n// L0-blocked session has left. Its header records that, and points here.\n//\n// DEPENDENCY-FREE ANYWAY: `fs`, `path` and `toError`. No inversify (see StaleBinSweeper), so this module\n// stays cheap for the startup path it runs on and importable by anything that later needs it.\n// ---------------------------------------------------------------------------\n\n// The one place the prefix is spelled. Everything outside it belongs to some other package.\nconst WP_BIN_PREFIX = 'wp-';\n\n/**\n * One dangling entry the sweep ACTED ON: what was linked, the target that was not there, and — when the\n * removal itself failed — why. Data-only (per CLAUDE.md).\n *\n * `failure` exists because the removal is an `fs.rmSync`, not just a probe: an unwritable `.bin` (EACCES,\n * a read-only mount) would otherwise heal silently-never while the tree kept advertising a command that\n * does not exist, which is the precise defect this module exists to remove. Not thrown — the sweep is a\n * courtesy and must never fail the `wp-*` command that called it — so the diagnostic rides back here and\n * {@link StaleBinSweeper.report} states both outcomes.\n */\nexport class StaleBinRemoval {\n name: string; // the bin name as it appeared in .bin (e.g. 'wp-authorize')\n target: string; // the link target that does not exist, as recorded in the symlink\n failure: string; // '' = removed; non-empty = still there, and this is why\n\n constructor(name: string, target: string, failure = '') {\n this.name = name;\n this.target = target;\n this.failure = failure;\n }\n}\n\n/**\n * Removes `node_modules/.bin/wp-*` entries whose symlink target is gone.\n *\n * Deliberately NOT `@injectable`: decorating it would import inversify, and this module must stay loadable\n * by `wp-upgrade-shim` on a tree that cannot build a DI container (see the header). Callers use the shared\n * {@link staleBinSweeper} instance, which is also what makes {@link sweepOnce}'s memo process-wide.\n */\nexport class StaleBinSweeper {\n // Roots already swept in THIS process. `writeTemplate` is called several times per `wp-*` command (once\n // per instruct-ai doc), and a sweep that reported per call would print the same removals repeatedly.\n private readonly swept = new Set<string>();\n\n /** Where the bins live for a tree. Public so a test can point at a fixture without guessing the layout. */\n binDir(repoRoot: string): string {\n return path.join(repoRoot, 'node_modules', '.bin');\n }\n\n /**\n * Sweep once per root per process, returning what was removed ([] on every later call for the same\n * root, and [] when there was nothing to remove — the two are indistinguishable to a caller ON PURPOSE,\n * because both mean \"say nothing\").\n */\n sweepOnce(repoRoot: string): StaleBinRemoval[] {\n if (this.swept.has(repoRoot)) return [];\n this.swept.add(repoRoot);\n return this.sweep(repoRoot);\n }\n\n /**\n * Remove every dangling `wp-*` symlink under the tree's `.bin`, returning what went. [] when the\n * directory does not exist (a linked worktree with no install of its own is the common case) or when\n * everything there resolves.\n *\n * BEST EFFORT, PER ENTRY. A `.bin` that cannot be read, or one entry that cannot be removed, must never\n * take down the `wp-*` command that called this — the sweep is a courtesy, not the command's job.\n */\n sweep(repoRoot: string): StaleBinRemoval[] {\n const dir = this.binDir(repoRoot);\n const removed: StaleBinRemoval[] = [];\n for (const name of this.entries(dir)) {\n if (!name.startsWith(WP_BIN_PREFIX)) continue;\n const removal = this.removeIfDangling(path.join(dir, name), name);\n if (removal !== null) removed.push(removal);\n }\n return removed;\n }\n\n /**\n * The lines a caller prints for a sweep. [] for an empty sweep, so REMOVING NOTHING IS SILENT — this\n * runs on every `wp-*` command and the common case must add no noise at all.\n *\n * Rendered here rather than at each call site so the two callers cannot describe the same act\n * differently; each still chooses its own output channel and its own leading icon convention.\n */\n report(removed: readonly StaleBinRemoval[]): string[] {\n if (removed.length === 0) return [];\n const gone = removed.filter((r: StaleBinRemoval): boolean => r.failure === '');\n const stuck = removed.filter((r: StaleBinRemoval): boolean => r.failure !== '');\n const lines: string[] = [];\n if (gone.length > 0) {\n lines.push(`✅ @webpieces: removed ${gone.length} dangling node_modules/.bin/wp-* symlink(s) left by an earlier release:`);\n for (const r of gone) lines.push(` ${r.name} -> ${r.target} (target missing)`);\n lines.push(' They pointed at scripts this release no longer ships, so they could only ever fail on execution.');\n }\n // A failed removal is STATED, never quietly dropped: the entry is still there, still advertising a\n // command that does not exist, and only a human can fix an unwritable .bin.\n if (stuck.length > 0) {\n lines.push(`⚠️ @webpieces: ${stuck.length} dangling node_modules/.bin/wp-* symlink(s) could NOT be removed:`);\n for (const r of stuck) lines.push(` ${r.name} -> ${r.target} (target missing; ${r.failure})`);\n lines.push(' They still advertise commands this release does not ship. Nothing else is affected — remove them by hand.');\n }\n return lines;\n }\n\n // The directory listing, or [] when there is no .bin (or it cannot be read).\n private entries(dir: string): string[] {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unreadable .bin means \"nothing to sweep\", never a failed wp-* command\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n if (!fs.existsSync(dir)) return [];\n return fs.readdirSync(dir);\n } catch (err: unknown) {\n const error = toError(err);\n void error; // best effort: no readable .bin means there is nothing to sweep\n return [];\n }\n }\n\n /**\n * Remove ONE entry if — and only if — it is a symlink whose target does not exist. Returns what was\n * acted on, with `failure` set when the entry was dangling but could not be removed; `null` when the\n * entry was not a dangling `wp-*` link at all.\n */\n private removeIfDangling(full: string, name: string): StaleBinRemoval | null {\n const target = this.danglingTarget(full);\n if (target === null) return null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unremovable entry is REPORTED, never fatal to the wp-* command that called the sweep\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n fs.rmSync(full, { force: true });\n return new StaleBinRemoval(name, target);\n } catch (err: unknown) {\n const error = toError(err);\n return new StaleBinRemoval(name, target, error.message);\n }\n }\n\n /**\n * The link target of a DANGLING symlink, or `null` when this entry is not one — a real file, a live\n * link, or something we cannot stat. `existsSync` FOLLOWS symlinks, so a false answer on a path `lstat`\n * calls a link is exactly the dangling case, with no need to resolve the target ourselves.\n *\n * Split from the removal so the two catches mean different things: an unreadable entry is simply not\n * ours to touch, while a failed REMOVAL is a fact worth printing.\n */\n private danglingTarget(full: string): string | null {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an entry we cannot stat is not ours to touch\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n if (!fs.lstatSync(full).isSymbolicLink()) return null;\n if (fs.existsSync(full)) return null;\n return fs.readlinkSync(full);\n } catch (err: unknown) {\n const error = toError(err);\n void error; // best effort: an entry we cannot read is left exactly as it is\n return null;\n }\n }\n}\n\n// The shared instance — the memo in `sweepOnce` is per-instance, so every caller must use this one.\nexport const staleBinSweeper = new StaleBinSweeper();\n"]}
|
|
1
|
+
{"version":3,"file":"stale-bin-sweep.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/stale-bin-sweep.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,iEAA6D;AAE7D,8EAA8E;AAC9E,oDAAoD;AACpD,EAAE;AACF,0GAA0G;AAC1G,wGAAwG;AACxG,uGAAuG;AACvG,sGAAsG;AACtG,sFAAsF;AACtF,EAAE;AACF,kGAAkG;AAClG,2GAA2G;AAC3G,yGAAyG;AACzG,0GAA0G;AAC1G,2GAA2G;AAC3G,gGAAgG;AAChG,sGAAsG;AACtG,0GAA0G;AAC1G,wBAAwB;AACxB,EAAE;AACF,yGAAyG;AACzG,kGAAkG;AAClG,oGAAoG;AACpG,yGAAyG;AACzG,qGAAqG;AACrG,uGAAuG;AACvG,yGAAyG;AACzG,0GAA0G;AAC1G,iGAAiG;AACjG,EAAE;AACF,yGAAyG;AACzG,0GAA0G;AAC1G,wFAAwF;AACxF,0GAA0G;AAC1G,gGAAgG;AAChG,EAAE;AACF,wGAAwG;AACxG,yGAAyG;AACzG,wGAAwG;AACxG,yGAAyG;AACzG,mGAAmG;AACnG,kHAAkH;AAClH,0GAA0G;AAC1G,oEAAoE;AACpE,EAAE;AACF,wGAAwG;AACxG,mGAAmG;AACnG,yGAAyG;AACzG,4GAA4G;AAC5G,yGAAyG;AACzG,oGAAoG;AACpG,EAAE;AACF,2GAA2G;AAC3G,2GAA2G;AAC3G,wGAAwG;AACxG,2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C,IAAY;QAC/B,wGAAwG;QACxG,8DAA8D;QAC9D,IAAI,CAAC;YACD,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE;gBAAE,OAAO,IAAI,CAAC;YACtD,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;gBAAE,OAAO,IAAI,CAAC;YACrC,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,IAAA,kBAAO,EAAC,GAAG,CAAC,CAAC;YAC3B,KAAK,KAAK,CAAC,CAAC,gEAAgE;YAC5E,OAAO,IAAI,CAAC;QAChB,CAAC;IACL,CAAC;CACJ;AAzHD,0CAyHC;AAED,oGAAoG;AACvF,QAAA,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { toError } from '@webpieces/tooling-common/to-error';\n\n// ---------------------------------------------------------------------------\n// SWEEP DANGLING `node_modules/.bin/wp-*` SYMLINKS.\n//\n// THE DEFECT. pnpm's linker ADDS a link for every entry in the current manifest's `bin` map, but it never\n// sweeps `.bin` for orphans left behind by a PREVIOUS version of the SAME package. `@webpieces/pr-gate`\n// and `@webpieces/ai-hook-rules` are upgraded, never removed, so nothing ever triggers a delete: every\n// bin either package has EVER shipped stays linked forever, pointing at a script that is no longer on\n// disk. A scan of nine clones on ONE machine found 18 distinct dangling `wp-*` names.\n//\n// THE DEFECT IS ONGOING, AND A ROUTINE RENAME PRODUCES IT. Measured on this repo's own upgrade to\n// 0.4.728, DURING the session that wrote this file: PR #743 hard-renamed one `wp-*` command with no alias,\n// so the new manifest declares `wp-sync-main` and no longer declares its predecessor. One `pnpm install`\n// later, `.bin` held the NEW link created that minute AND the predecessor's link still sitting there from\n// the previous install, dangling — reproduced independently in two separate trees of this repo. So this is\n// not a historical mess left by a deleted feature that a one-time migration could mop up: it is\n// regenerated by the most ordinary change a package can make, on every clone, every time. That is the\n// argument for the call site below — the sweep has to ride a path that runs ROUTINELY, because the defect\n// is created routinely.\n//\n// The predecessor's NAME is deliberately not written here, and DO NOT WRITE IT BACK IN. Two reasons, and\n// the second is the one that matters. First, nothing in the code needs it: the predicate below is\n// STRUCTURAL — a `wp-*` entry whose link target does not resolve — so naming one particular retired\n// command would invite a reader to think the sweep is a list of known dead names somebody has to keep up\n// to date. Second, a retired command named in tracked source is exactly how a dead name outlives its\n// tooling: it gets copied into a cure string, and an agent reading that cure at the moment every other\n// route is closed is handed a command that does not exist. That is the very defect this module cleans up\n// one level out, and there is no longer an automated scan standing behind this paragraph — the reader is.\n// PR #743 and the issue this shipped under carry the literal name; nothing in the tree needs to.\n//\n// WHY IT MATTERS MORE THAN TIDINESS. `ls node_modules/.bin` lists them, so a dangling entry ADVERTISES a\n// capability that does not exist — a human and an AI were both misled by that listing before checking the\n// link target — and the failure it eventually produces is self-referential and useless:\n// `Command \"wp-authorize\" not found / Did you mean \"pnpm wp-authorize\"?`. This is `upgrade-shim.ts`'s own\n// governing principle one level out: an entry pointing at a missing file is WORSE than absence.\n//\n// WHY A PREFIX AND NOT A NAME LIST. A hardcoded list of retired bin names would go stale in exactly the\n// way the symlinks did — the list assembled from the two names that prompted this would have caught 2 of\n// the 18, and it would NOT have caught the rename above, which had not happened yet when the list would\n// have been written. That is the general case: the next orphan is always created by a release later than\n// any list. A name list is also unwriteable here on purpose — see the note above about naming dead\n// commands in source. The predicate is structural instead — a `wp-` prefixed entry that is a SYMLINK whose target\n// does not exist — so it needs no maintenance and cannot miss a name nobody has thought of. The prefix is\n// the whole safety story: another package's bins are never touched.\n//\n// WHY NOT A postinstall HOOK. `setupDebugging.md` records the postinstall approach as ABANDONED in this\n// repo. The call site is the `wp-*` startup pass that regenerates `.webpieces/instruct-ai/*` — see\n// TemplateWriter — and that placement is the load-bearing half of the fix. This is not a tidy-up for one\n// repo: every developer's machine has this graveyard, and a cure that only cleans the tree somebody happens\n// to run it in is worthless. Riding the pass EVERY `wp-*` command takes is what makes the RELEASED sweep\n// reach every clone on every machine, healing each one the next time any `wp-*` command runs there.\n//\n// NOT ALSO CALLED FROM `wp-upgrade-shim`, though it would read naturally there (that bin already deletes a\n// retired FILE on the same principle). `upgrade-shim.ts` may import only `fs`/`path` so it still runs on a\n// tree too broken to load the rule engine: this package's barrel would pull in inversify and the config\n// loader, and a subpath import would resolve against the INSTALLED rules-config, which is a release behind\n// the local source — so a spawned `wp-upgrade-shim` would die on module resolution, in the one command an\n// L0-blocked session has left. Its header records that, and points here.\n//\n// DEPENDENCY-FREE ANYWAY: `fs`, `path` and `toError`. No inversify (see StaleBinSweeper), so this module\n// stays cheap for the startup path it runs on and importable by anything that later needs it.\n// ---------------------------------------------------------------------------\n\n// The one place the prefix is spelled. Everything outside it belongs to some other package.\nconst WP_BIN_PREFIX = 'wp-';\n\n/**\n * One dangling entry the sweep ACTED ON: what was linked, the target that was not there, and — when the\n * removal itself failed — why. Data-only (per CLAUDE.md).\n *\n * `failure` exists because the removal is an `fs.rmSync`, not just a probe: an unwritable `.bin` (EACCES,\n * a read-only mount) would otherwise heal silently-never while the tree kept advertising a command that\n * does not exist, which is the precise defect this module exists to remove. Not thrown — the sweep is a\n * courtesy and must never fail the `wp-*` command that called it — so the diagnostic rides back here and\n * {@link StaleBinSweeper.report} states both outcomes.\n */\nexport class StaleBinRemoval {\n name: string; // the bin name as it appeared in .bin (e.g. 'wp-authorize')\n target: string; // the link target that does not exist, as recorded in the symlink\n failure: string; // '' = removed; non-empty = still there, and this is why\n\n constructor(name: string, target: string, failure = '') {\n this.name = name;\n this.target = target;\n this.failure = failure;\n }\n}\n\n/**\n * Removes `node_modules/.bin/wp-*` entries whose symlink target is gone.\n *\n * Deliberately NOT `@injectable`: decorating it would import inversify, and this module must stay loadable\n * by `wp-upgrade-shim` on a tree that cannot build a DI container (see the header). Callers use the shared\n * {@link staleBinSweeper} instance, which is also what makes {@link sweepOnce}'s memo process-wide.\n */\nexport class StaleBinSweeper {\n // Roots already swept in THIS process. `writeTemplate` is called several times per `wp-*` command (once\n // per instruct-ai doc), and a sweep that reported per call would print the same removals repeatedly.\n private readonly swept = new Set<string>();\n\n /** Where the bins live for a tree. Public so a test can point at a fixture without guessing the layout. */\n binDir(repoRoot: string): string {\n return path.join(repoRoot, 'node_modules', '.bin');\n }\n\n /**\n * Sweep once per root per process, returning what was removed ([] on every later call for the same\n * root, and [] when there was nothing to remove — the two are indistinguishable to a caller ON PURPOSE,\n * because both mean \"say nothing\").\n */\n sweepOnce(repoRoot: string): StaleBinRemoval[] {\n if (this.swept.has(repoRoot)) return [];\n this.swept.add(repoRoot);\n return this.sweep(repoRoot);\n }\n\n /**\n * Remove every dangling `wp-*` symlink under the tree's `.bin`, returning what went. [] when the\n * directory does not exist (a linked worktree with no install of its own is the common case) or when\n * everything there resolves.\n *\n * BEST EFFORT, PER ENTRY. A `.bin` that cannot be read, or one entry that cannot be removed, must never\n * take down the `wp-*` command that called this — the sweep is a courtesy, not the command's job.\n */\n sweep(repoRoot: string): StaleBinRemoval[] {\n const dir = this.binDir(repoRoot);\n const removed: StaleBinRemoval[] = [];\n for (const name of this.entries(dir)) {\n if (!name.startsWith(WP_BIN_PREFIX)) continue;\n const removal = this.removeIfDangling(path.join(dir, name), name);\n if (removal !== null) removed.push(removal);\n }\n return removed;\n }\n\n /**\n * The lines a caller prints for a sweep. [] for an empty sweep, so REMOVING NOTHING IS SILENT — this\n * runs on every `wp-*` command and the common case must add no noise at all.\n *\n * Rendered here rather than at each call site so the two callers cannot describe the same act\n * differently; each still chooses its own output channel and its own leading icon convention.\n */\n report(removed: readonly StaleBinRemoval[]): string[] {\n if (removed.length === 0) return [];\n const gone = removed.filter((r: StaleBinRemoval): boolean => r.failure === '');\n const stuck = removed.filter((r: StaleBinRemoval): boolean => r.failure !== '');\n const lines: string[] = [];\n if (gone.length > 0) {\n lines.push(`✅ @webpieces: removed ${gone.length} dangling node_modules/.bin/wp-* symlink(s) left by an earlier release:`);\n for (const r of gone) lines.push(` ${r.name} -> ${r.target} (target missing)`);\n lines.push(' They pointed at scripts this release no longer ships, so they could only ever fail on execution.');\n }\n // A failed removal is STATED, never quietly dropped: the entry is still there, still advertising a\n // command that does not exist, and only a human can fix an unwritable .bin.\n if (stuck.length > 0) {\n lines.push(`⚠️ @webpieces: ${stuck.length} dangling node_modules/.bin/wp-* symlink(s) could NOT be removed:`);\n for (const r of stuck) lines.push(` ${r.name} -> ${r.target} (target missing; ${r.failure})`);\n lines.push(' They still advertise commands this release does not ship. Nothing else is affected — remove them by hand.');\n }\n return lines;\n }\n\n // The directory listing, or [] when there is no .bin (or it cannot be read).\n private entries(dir: string): string[] {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unreadable .bin means \"nothing to sweep\", never a failed wp-* command\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n if (!fs.existsSync(dir)) return [];\n return fs.readdirSync(dir);\n } catch (err: unknown) {\n const error = toError(err);\n void error; // best effort: no readable .bin means there is nothing to sweep\n return [];\n }\n }\n\n /**\n * Remove ONE entry if — and only if — it is a symlink whose target does not exist. Returns what was\n * acted on, with `failure` set when the entry was dangling but could not be removed; `null` when the\n * entry was not a dangling `wp-*` link at all.\n */\n private removeIfDangling(full: string, name: string): StaleBinRemoval | null {\n const target = this.danglingTarget(full);\n if (target === null) return null;\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an unremovable entry is REPORTED, never fatal to the wp-* command that called the sweep\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n fs.rmSync(full, { force: true });\n return new StaleBinRemoval(name, target);\n } catch (err: unknown) {\n const error = toError(err);\n return new StaleBinRemoval(name, target, error.message);\n }\n }\n\n /**\n * The link target of a DANGLING symlink, or `null` when this entry is not one — a real file, a live\n * link, or something we cannot stat. `existsSync` FOLLOWS symlinks, so a false answer on a path `lstat`\n * calls a link is exactly the dangling case, with no need to resolve the target ourselves.\n *\n * Split from the removal so the two catches mean different things: an unreadable entry is simply not\n * ours to touch, while a failed REMOVAL is a fact worth printing.\n */\n private danglingTarget(full: string): string | null {\n // webpieces-disable no-unmanaged-exceptions -- chokepoint: an entry we cannot stat is not ours to touch\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n if (!fs.lstatSync(full).isSymbolicLink()) return null;\n if (fs.existsSync(full)) return null;\n return fs.readlinkSync(full);\n } catch (err: unknown) {\n const error = toError(err);\n void error; // best effort: an entry we cannot read is left exactly as it is\n return null;\n }\n }\n}\n\n// The shared instance — the memo in `sweepOnce` is per-instance, so every caller must use this one.\nexport const staleBinSweeper = new StaleBinSweeper();\n"]}
|
|
@@ -41,7 +41,7 @@ export declare class ReviewerEvidence {
|
|
|
41
41
|
readDiff: boolean;
|
|
42
42
|
readDoc: boolean;
|
|
43
43
|
/**
|
|
44
|
-
* Named its own verdict file — `.webpieces
|
|
44
|
+
* Named its own verdict file — `.webpieces/pr-review/<featureSlug>/review-round<N>-<id>.json` — in a tool input.
|
|
45
45
|
*
|
|
46
46
|
* Recorded, not just consumed, because it is the field that answers "who wrote this verdict?" for an
|
|
47
47
|
* auditor reading provenance.json later. It is also a CREDIT channel: see
|
|
@@ -99,7 +99,7 @@ export declare class TranscriptScan {
|
|
|
99
99
|
*
|
|
100
100
|
* One class for BOTH passes — crediting (`verifyReviewers`) and evidence (`evidenceFor`) — because they
|
|
101
101
|
* ask their questions of the same paths. `diffDir` is the per-branch materialization
|
|
102
|
-
* (`.webpieces
|
|
102
|
+
* (`.webpieces/pr-review/<featureSlug>/diff`), which is what makes it usable as PROOF of which branch a
|
|
103
103
|
* reviewer looked at: the path names the branch, it is absolute, and stage ② recreates it per run.
|
|
104
104
|
*/
|
|
105
105
|
export declare class ReviewerContext {
|
|
@@ -108,7 +108,7 @@ export declare class ReviewerContext {
|
|
|
108
108
|
docPaths: Record<string, string>;
|
|
109
109
|
/**
|
|
110
110
|
* checklist id → the absolute path of the verdict file THAT checklist must write on THIS branch
|
|
111
|
-
* (`.webpieces
|
|
111
|
+
* (`.webpieces/pr-review/<featureSlug>/review-round<N>-<id>.json`). '' when unknown.
|
|
112
112
|
*
|
|
113
113
|
* The strongest attribution signal available, and stronger than `diffDir`: the path is
|
|
114
114
|
* worktree-absolute (naming the tree), per-branch (naming the featureSlug) AND per-checklist (naming
|
|
@@ -197,14 +197,14 @@ export declare class SubagentProvenanceService {
|
|
|
197
197
|
* Did a tool input name `absPath` — absolutely, or RELATIVE to the transcript's own recorded `cwd`?
|
|
198
198
|
*
|
|
199
199
|
* Relative because that is how a reviewer whose cwd IS the repo root naturally spells it. Measured
|
|
200
|
-
* (issue #1211): a reviewer read the diff forty times as `D=.webpieces
|
|
200
|
+
* (issue #1211): a reviewer read the diff forty times as `D=.webpieces/pr-review/<slug>/diff/files;
|
|
201
201
|
* cat $D/...` and was refused as never having opened it, because only the absolute spelling matched.
|
|
202
202
|
*
|
|
203
203
|
* Still branch-specific: the relative form is derived from `absPath` itself, so it carries the same
|
|
204
204
|
* `<featureSlug>`, and it is only tried when `absPath` lies UNDER the recorded cwd — i.e. when the
|
|
205
205
|
* relative spelling, resolved where the harness says the reviewer stood, IS this file. A reviewer of
|
|
206
206
|
* another branch names another slug; a reviewer standing in another tree resolves to another path.
|
|
207
|
-
* The relative needle must START a path token, so `/other/root/.webpieces
|
|
207
|
+
* The relative needle must START a path token, so `/other/root/.webpieces/...` cannot satisfy it as a
|
|
208
208
|
* mere substring.
|
|
209
209
|
*/
|
|
210
210
|
private namesPath;
|
|
@@ -335,7 +335,7 @@ export declare class SubagentProvenanceService {
|
|
|
335
335
|
* Credit a reviewer for WHAT IT TOUCHED when neither harness-stamped field can settle it.
|
|
336
336
|
*
|
|
337
337
|
* Both paths compared here are ABSOLUTE and BRANCH-SPECIFIC — they live under
|
|
338
|
-
* `<worktree>/.webpieces
|
|
338
|
+
* `<worktree>/.webpieces/pr-review/<featureSlug>/`, so the string names the tree AND the branch. A
|
|
339
339
|
* reviewer that worked on a different branch cannot have them in its transcript, and a reviewer of
|
|
340
340
|
* this branch that ran from a mis-stamped cwd cannot avoid having them. That is the property
|
|
341
341
|
* `gitBranch` lacks — this file's own sweep of 961 record-0s found the mis-stamp is the MAJORITY
|
|
@@ -63,7 +63,7 @@ class ReviewerEvidence {
|
|
|
63
63
|
readDiff; // opened the materialized diff dir (or its own instructions file)
|
|
64
64
|
readDoc; // opened its checklist's guidance doc
|
|
65
65
|
/**
|
|
66
|
-
* Named its own verdict file — `.webpieces
|
|
66
|
+
* Named its own verdict file — `.webpieces/pr-review/<featureSlug>/review-round<N>-<id>.json` — in a tool input.
|
|
67
67
|
*
|
|
68
68
|
* Recorded, not just consumed, because it is the field that answers "who wrote this verdict?" for an
|
|
69
69
|
* auditor reading provenance.json later. It is also a CREDIT channel: see
|
|
@@ -143,7 +143,7 @@ exports.TranscriptScan = TranscriptScan;
|
|
|
143
143
|
*
|
|
144
144
|
* One class for BOTH passes — crediting (`verifyReviewers`) and evidence (`evidenceFor`) — because they
|
|
145
145
|
* ask their questions of the same paths. `diffDir` is the per-branch materialization
|
|
146
|
-
* (`.webpieces
|
|
146
|
+
* (`.webpieces/pr-review/<featureSlug>/diff`), which is what makes it usable as PROOF of which branch a
|
|
147
147
|
* reviewer looked at: the path names the branch, it is absolute, and stage ② recreates it per run.
|
|
148
148
|
*/
|
|
149
149
|
class ReviewerContext {
|
|
@@ -152,7 +152,7 @@ class ReviewerContext {
|
|
|
152
152
|
docPaths; // checklist id → its checklist doc path ('' when none)
|
|
153
153
|
/**
|
|
154
154
|
* checklist id → the absolute path of the verdict file THAT checklist must write on THIS branch
|
|
155
|
-
* (`.webpieces
|
|
155
|
+
* (`.webpieces/pr-review/<featureSlug>/review-round<N>-<id>.json`). '' when unknown.
|
|
156
156
|
*
|
|
157
157
|
* The strongest attribution signal available, and stronger than `diffDir`: the path is
|
|
158
158
|
* worktree-absolute (naming the tree), per-branch (naming the featureSlug) AND per-checklist (naming
|
|
@@ -324,14 +324,14 @@ let SubagentProvenanceService = class SubagentProvenanceService {
|
|
|
324
324
|
* Did a tool input name `absPath` — absolutely, or RELATIVE to the transcript's own recorded `cwd`?
|
|
325
325
|
*
|
|
326
326
|
* Relative because that is how a reviewer whose cwd IS the repo root naturally spells it. Measured
|
|
327
|
-
* (issue #1211): a reviewer read the diff forty times as `D=.webpieces
|
|
327
|
+
* (issue #1211): a reviewer read the diff forty times as `D=.webpieces/pr-review/<slug>/diff/files;
|
|
328
328
|
* cat $D/...` and was refused as never having opened it, because only the absolute spelling matched.
|
|
329
329
|
*
|
|
330
330
|
* Still branch-specific: the relative form is derived from `absPath` itself, so it carries the same
|
|
331
331
|
* `<featureSlug>`, and it is only tried when `absPath` lies UNDER the recorded cwd — i.e. when the
|
|
332
332
|
* relative spelling, resolved where the harness says the reviewer stood, IS this file. A reviewer of
|
|
333
333
|
* another branch names another slug; a reviewer standing in another tree resolves to another path.
|
|
334
|
-
* The relative needle must START a path token, so `/other/root/.webpieces
|
|
334
|
+
* The relative needle must START a path token, so `/other/root/.webpieces/...` cannot satisfy it as a
|
|
335
335
|
* mere substring.
|
|
336
336
|
*/
|
|
337
337
|
namesPath(scan, absPath) {
|
|
@@ -623,7 +623,7 @@ let SubagentProvenanceService = class SubagentProvenanceService {
|
|
|
623
623
|
* Credit a reviewer for WHAT IT TOUCHED when neither harness-stamped field can settle it.
|
|
624
624
|
*
|
|
625
625
|
* Both paths compared here are ABSOLUTE and BRANCH-SPECIFIC — they live under
|
|
626
|
-
* `<worktree>/.webpieces
|
|
626
|
+
* `<worktree>/.webpieces/pr-review/<featureSlug>/`, so the string names the tree AND the branch. A
|
|
627
627
|
* reviewer that worked on a different branch cannot have them in its transcript, and a reviewer of
|
|
628
628
|
* this branch that ran from a mis-stamped cwd cannot avoid having them. That is the property
|
|
629
629
|
* `gitBranch` lacks — this file's own sweep of 961 record-0s found the mis-stamp is the MAJORITY
|