@webpieces/rules-config 0.4.910 → 0.4.911

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/package.json +7 -6
  2. package/src/aged-tree-sweep.d.ts +2 -2
  3. package/src/aged-tree-sweep.js +2 -2
  4. package/src/aged-tree-sweep.js.map +1 -1
  5. package/src/build-log-doc.d.ts +1 -1
  6. package/src/build-log-doc.js +3 -3
  7. package/src/build-log-doc.js.map +1 -1
  8. package/src/builds-log.d.ts +2 -2
  9. package/src/builds-log.js +2 -2
  10. package/src/builds-log.js.map +1 -1
  11. package/src/checklist-override.d.ts +1 -1
  12. package/src/checklist-override.js +1 -1
  13. package/src/checklist-override.js.map +1 -1
  14. package/src/config-error-banner.js +1 -1
  15. package/src/config-error-banner.js.map +1 -1
  16. package/src/config-repair-bootstrap-source.d.ts +1 -1
  17. package/src/config-repair-bootstrap-source.js +1 -1
  18. package/src/config-repair-bootstrap-source.js.map +1 -1
  19. package/src/config-repair-probe.js +3 -3
  20. package/src/config-repair-probe.js.map +1 -1
  21. package/src/constants.js +3 -3
  22. package/src/constants.js.map +1 -1
  23. package/src/exclude-hook-paths.d.ts +5 -5
  24. package/src/exclude-hook-paths.js +5 -5
  25. package/src/exclude-hook-paths.js.map +1 -1
  26. package/src/exclude-paths.d.ts +1 -1
  27. package/src/exclude-paths.js +1 -1
  28. package/src/exclude-paths.js.map +1 -1
  29. package/src/hook-fault-codes.js.map +1 -1
  30. package/src/index.js +5 -5
  31. package/src/index.js.map +1 -1
  32. package/src/instruct-ai-docs.d.ts +3 -3
  33. package/src/instruct-ai-docs.js +3 -3
  34. package/src/instruct-ai-docs.js.map +1 -1
  35. package/src/legacy-config-upgrade.js +2 -2
  36. package/src/legacy-config-upgrade.js.map +1 -1
  37. package/src/load-config.js +3 -0
  38. package/src/load-config.js.map +1 -1
  39. package/src/load-template.d.ts +1 -1
  40. package/src/load-template.js +2 -2
  41. package/src/load-template.js.map +1 -1
  42. package/src/merge-process-doc.d.ts +1 -1
  43. package/src/merge-process-doc.js +2 -2
  44. package/src/merge-process-doc.js.map +1 -1
  45. package/src/migrate-dirs-cli.d.ts +4 -0
  46. package/src/migrate-dirs-cli.js +32 -0
  47. package/src/migrate-dirs-cli.js.map +1 -0
  48. package/src/orphan-dir-archive.d.ts +4 -4
  49. package/src/orphan-dir-archive.js +4 -4
  50. package/src/orphan-dir-archive.js.map +1 -1
  51. package/src/orphan-dir-scan.d.ts +1 -1
  52. package/src/orphan-dir-scan.js +1 -1
  53. package/src/orphan-dir-scan.js.map +1 -1
  54. package/src/orphan-dir-sweep.js +1 -1
  55. package/src/orphan-dir-sweep.js.map +1 -1
  56. package/src/pack-policy-files.js +4 -3
  57. package/src/pack-policy-files.js.map +1 -1
  58. package/src/policy-tracking.d.ts +7 -0
  59. package/src/policy-tracking.js +68 -0
  60. package/src/policy-tracking.js.map +1 -0
  61. package/src/pr-gate-config.d.ts +1 -1
  62. package/src/pr-gate-config.js +1 -1
  63. package/src/pr-gate-config.js.map +1 -1
  64. package/src/repo-root.d.ts +7 -7
  65. package/src/repo-root.js +8 -8
  66. package/src/repo-root.js.map +1 -1
  67. package/src/repo-scratch-dirs.d.ts +3 -3
  68. package/src/repo-scratch-dirs.js +5 -5
  69. package/src/repo-scratch-dirs.js.map +1 -1
  70. package/src/review-json-data.js +2 -2
  71. package/src/review-json-data.js.map +1 -1
  72. package/src/review-json.js +1 -1
  73. package/src/review-json.js.map +1 -1
  74. package/src/reviewer-instructions.d.ts +1 -1
  75. package/src/reviewer-instructions.js +1 -1
  76. package/src/reviewer-instructions.js.map +1 -1
  77. package/src/rule-pack-artifacts.d.ts +2 -2
  78. package/src/rule-pack-artifacts.js +2 -2
  79. package/src/rule-pack-artifacts.js.map +1 -1
  80. package/src/rule-pack-sync.js +5 -4
  81. package/src/rule-pack-sync.js.map +1 -1
  82. package/src/stale-bin-sweep.js +1 -1
  83. package/src/stale-bin-sweep.js.map +1 -1
  84. package/src/subagent-provenance.d.ts +6 -6
  85. package/src/subagent-provenance.js +6 -6
  86. package/src/subagent-provenance.js.map +1 -1
  87. package/src/sync-flow-guidance.js +1 -1
  88. package/src/sync-flow-guidance.js.map +1 -1
  89. package/templates/webpieces.branch-state-matrix.md +2 -2
  90. package/templates/webpieces.buildlog.md +3 -3
  91. package/templates/webpieces.ci-gate-setup.md +2 -2
  92. package/templates/webpieces.git-workflow.md +9 -9
  93. package/templates/webpieces.guard-matrix.md +6 -5
  94. package/templates/webpieces.location-matrix.md +9 -9
  95. package/templates/webpieces.review-checklists.md +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"pr-gate-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/pr-gate-config.ts"],"names":[],"mappings":";;;AA2FA,kDAEC;AAgDD,wDAEC;AAwID,oCAmBC;AAED,kDAGC;AA4DD,8CAgEC;AAQD,oDAYC;AAQD,8CAMC;AA7cD,sEAAgG;AAChG,yDAO4B;AAE5B,2FAA2F;AAC3F,2FAA2F;AAC3F,iFAAiF;AACjF,iGAAiG;AAEjG;;;;;;;;;;;GAWG;AACU,QAAA,qBAAqB,GAC9B,wEAAwE,CAAC;AAE7E,MAAa,cAAc;IACvB,IAAI,CAAS;IACb,QAAQ,CAAW;IACnB,iGAAiG;IACjG,8FAA8F;IAC9F,+FAA+F;IAC/F,gGAAgG;IAChG,YAAY,CAAS,CAAC,mBAAmB;IACzC,2FAA2F;IAC3F,yFAAyF;IACzF,QAAQ,CAAU;IAElB,YAAY,IAAY,EAAE,QAAkB,EAAE,YAAoB,EAAE,QAAQ,GAAG,KAAK;QAChF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;CACJ;AAlBD,wCAkBC;AAED,qGAAqG;AACrG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AAC,CAAC;AACvC,CAAC","sourcesContent":["import { BRANCH_RETENTION_ARCHIVE_TAG, BRANCH_RETENTIONS } from '@webpieces/repo-workflow-core';\nimport {\n ChecklistDefinition,\n DEFAULT_REVIEWER_AGENT_NAME,\n RawChecklistItem,\n REVIEWER_AGENTS_PLACEHOLDER,\n ReviewerAgentPolicy,\n toChecklist,\n} from './checklist-config';\n\n// PrGateConfig is the \"special section\" for the pr-gate dashboard. It does NOT live in the\n// validated `rules` map (the FieldDef schema can't express nested object arrays), but as a\n// top-level `pr-gate` key in webpieces.config.json. It is built and validated by\n// loadAndValidate (load-config.ts); this module holds only the data classes + defaults + toGate.\n\n/**\n * The build the pr-gate runs when a repo configures no `commands.pr-gate.buildCommand` — and the ONE\n * definition of it, because two things now need it: the gate that RUNS it (pr-gate's BuildAffected)\n * and the guard that REFUSES a whole-monorepo build and prints it instead (ai-hook-rules'\n * whole-repo-build-guard). A second copy in either package is a message that can teach a command the\n * gate does not run.\n *\n * `--base=$(git merge-base origin/main HEAD)` — the FORK POINT, not `origin/main`: basing on\n * origin/main marks projects touched by other people's already-merged PRs as affected. The `$(…)`\n * resolves because the gate spawns with `shell: true`; the guard resolves it itself before printing,\n * so the AI is never handed a template it might paste somewhere without a shell.\n */\nexport const DEFAULT_BUILD_COMMAND =\n 'pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)';\n\nexport class GateDefinition {\n name: string;\n patterns: string[];\n // The warning color shown on the dashboard WHEN this gate's patterns match a changed file. Green\n // is implicit (shown when nothing matched), so it is never configured. warningColor is purely\n // visual — even 'red' never fails/blocks the PR (only the build gate can). 'yellow' = caution,\n // 'red' = louder \"look here\" flag (e.g. DB schema / migration changes). REQUIRED on every gate.\n warningColor: string; // 'yellow' | 'red'\n // Example/inactive gate: parsed and kept in the file (JSON has no comments) but skipped at\n // compute/render time. Other projects flip this to false and tune patterns/warningColor.\n disabled: boolean;\n\n constructor(name: string, patterns: string[], warningColor: string, disabled = false) {\n this.name = name;\n this.patterns = patterns;\n this.warningColor = warningColor;\n this.disabled = disabled;\n }\n}\n\n// How wp-finish-upsert-pr should try to LAND the PR once it has posted it. GitHub's auto-merge queue\n// is a REPO-level setting (`allow_auto_merge`) that many orgs turn OFF as a policy control, and it\n// CANNOT be forced from the client: `gh pr merge --auto` calls the enablePullRequestAutoMerge GraphQL\n// mutation, which hard-errors with \"Auto merge is not allowed for this repository\" when the repo says\n// no. So the only lever a config knob has is WHICH PATHS WE ATTEMPT — never whether the queue exists.\nexport const MERGE_MODE_AUTO = 'AUTO';\nexport const MERGE_MODE_NONE = 'NONE';\nexport const MERGE_MODES = [MERGE_MODE_AUTO, MERGE_MODE_NONE];\n\n/**\n * `pr-gate.landPr` — what happens to the LOCAL branch once its PR has landed.\n *\n * A rich object rather than a bare string (the `commands.pr-gate` precedent) so the next knob about\n * landing has a home, and so the rationale can sit beside the setting as a `*Why` sibling: JSON has no\n * comments, and `<key>Why` is how this repo documents non-obvious config.\n */\n/**\n * One `pr-gate.reviewContext` entry: a human label and a repo-relative path a reviewer is handed instead of\n * having to find it. Data-only (per CLAUDE.md).\n */\nexport class ReviewContextEntry {\n label: string;\n path: string; // repo-relative in config; resolved to absolute when written into an instructions file\n\n constructor(label: string, entryPath: string) {\n this.label = label;\n this.path = entryPath;\n }\n}\n\nexport class LandPrConfig {\n // One of BRANCH_RETENTIONS. Defaults to 'archive-tag' — see BranchArchiver for why a tag beats\n // keeping the branch, storing a patch, or trusting the reflog.\n branchRetention: string;\n\n constructor(branchRetention: string = BRANCH_RETENTION_ARCHIVE_TAG) {\n this.branchRetention = branchRetention;\n }\n}\n\n// webpieces-disable no-function-outside-class -- module-level config default, matches defaultGates/defaultPrGateConfig in this file\nexport function defaultLandPrConfig(): LandPrConfig {\n return new LandPrConfig(BRANCH_RETENTION_ARCHIVE_TAG);\n}\n\n// The two literal ref names the dev-deploy flow derives everything else from. Defaults, not policy —\n// `pr-gate.devDeploy` overrides both, because a consumer whose shared environment is called `staging`\n// must not be forced onto webpieces' vocabulary.\nexport const DEFAULT_DEV_BRANCH_NAMESPACE = 'dev-include';\nexport const DEFAULT_DEV_BRANCH = 'dev';\n\n/**\n * `pr-gate.devDeploy` — where `wp-push-dev` publishes the throwaway copy of a feature branch, and which\n * ref is the shared dev branch itself.\n *\n * WHY A NAMESPACE AT ALL, i.e. why the copy is not just the feature branch: the feature branch is the PR\n * head, and landing that PR ships whatever is on it. The moment a conflict between two devs has to be\n * resolved SOMEWHERE for the shared environment to build, that resolution needs a home that is not the PR\n * branch — otherwise \"test it in dev\" silently ships another dev's unreviewed work to production. The\n * `<branchNamespace>/<feature>` copy is that home, and it is disposable by construction.\n *\n * `devBranch` is REFUSED as a source branch (you never push the composed branch back into itself); it is\n * written by the consumer's CI only, which recomputes it from `origin/main` on every run.\n */\nexport class DevDeployConfig {\n // Literal prefix on the feature branch name: `dev-include/dean/ONE-2275`. Git refs allow slashes, and\n // nobody ever types this — the command derives it.\n branchNamespace: string;\n // The composed, CI-owned branch that actually deploys. Never a source, never pushed to by this flow.\n devBranch: string;\n\n constructor(\n branchNamespace: string = DEFAULT_DEV_BRANCH_NAMESPACE,\n devBranch: string = DEFAULT_DEV_BRANCH,\n ) {\n this.branchNamespace = branchNamespace;\n this.devBranch = devBranch;\n }\n\n /** `<branchNamespace>/<branch>` — the remote ref holding the disposable copy of `branch`. */\n copyRefFor(branch: string): string {\n return `${this.branchNamespace}/${branch}`;\n }\n\n /** The `git ls-remote --heads origin <pattern>` pattern matching every live copy. */\n copyRefGlob(): string {\n return `${this.branchNamespace}/*`;\n }\n}\n\n// webpieces-disable no-function-outside-class -- module-level config default, matches defaultGates/defaultPrGateConfig in this file\nexport function defaultDevDeployConfig(): DevDeployConfig {\n return new DevDeployConfig(DEFAULT_DEV_BRANCH_NAMESPACE, DEFAULT_DEV_BRANCH);\n}\n\nexport class PrGateConfig {\n mode: string;\n /**\n * The nx-affected build gate command, shared by the two commands that can run it.\n *\n * It is NOT finish-only any more, and the change is the point. It used to run once, in\n * wp-finish-upsert-pr, which meant reviewers were spawned against a branch nobody had built — they could\n * spend a full review on code that does not compile, or on an unresolved 3-point merge.\n *\n * Now `wp-review-upsert-pr` finalizes the merge and runs this gate BEFORE briefing any reviewer, and\n * records the passing HEAD sha in the stage receipt. `wp-finish-upsert-pr` re-runs it only when HEAD has\n * moved since — so the flow gained a gate where it mattered without paying for two full builds.\n *\n * Empty string => BuildAffected falls back to DEFAULT_BUILD_COMMAND.\n */\n buildCommand: string;\n gates: GateDefinition[];\n /**\n * REQUIRED — every repo must state its policy; there is deliberately no default, because the two\n * answers are a real policy decision and guessing it either merges when a team did not want that,\n * or silently stops landing PRs on a team that relied on it.\n *\n * AUTO — wp-finish-upsert-pr LANDS the PR: squash-merge it right away when it is mergeable, else\n * enable GitHub auto-merge so it lands when the checks pass. Both carry an explicit --subject /\n * --body-file, which is the ONLY way main's history gets the PR title plus the compact\n * risk/flags body — no repo setting can produce that. Requires allow_auto_merge on the repo.\n * NONE — wp-finish-upsert-pr only opens/updates the PR and stops; a human merges. NOTE the cost:\n * a UI merge cannot use the compact body, so main's commit falls back to the repo's\n * squash_merge_commit_title/message settings. Set squash_merge_commit_title=PR_TITLE there, or\n * commits land as the internal \"Squash merge of <branch>\" subject.\n */\n mergeMode: string;\n // This repo's review checklists, straight from the `pr-gate.checklists` ARRAY in webpieces.config.json —\n // the ONLY accepted shape (`patterns` is a path-glob dispatch table and `id` the checklist's name, so both\n // are config). Every def carries {@link reviewer}. [] = no checklists. The removed `{ doc }` manifest\n // form is a hard config error; see validateChecklistsSection.\n checklists: ChecklistDefinition[];\n /**\n * The ONE agent type every checklist is reviewed by — `webpieces-reviewer` unless\n * `overrideReviewerAgent` is true, in which case `reviewerAgentName` — and `reviewerAgents`, the most such\n * subagents a round may use. The same instance is bound into every {@link checklists} entry, so a caller\n * holding only a checklist still knows what to spawn. Field-with-default because the constructor is at\n * max-params; the agent name defaults to the webpieces reviewer, exactly what a config that says nothing\n * gets, while the CAP is a required field, so the placeholder here is only ever overwritten by the real\n * number buildPrGateConfig reads.\n */\n reviewer: ReviewerAgentPolicy = new ReviewerAgentPolicy(DEFAULT_REVIEWER_AGENT_NAME, REVIEWER_AGENTS_PLACEHOLDER);\n /**\n * REQUIRED positive integer: the maximum number of complete global reviewer rounds a PR review state\n * may start. This is deliberately repository policy rather than a machine-local preference.\n */\n maxReviewerRounds!: number;\n // Whether wp-finish-upsert-pr publishes each reviewer's full `output` as ONE combined PR comment\n // (idempotently updated on every push). Defaults to true. Set false to keep the PR body-only.\n checklistComments: boolean;\n /**\n * Shared secret used to mint the server-verifiable gate token. `wp-finish-upsert-pr` writes it after\n * the automated gate passes; `wp-human-post-pr` writes the same token after explicit human attestation\n * and visibly labels review as skipped plus whether its optional local build ran. A CI check\n * recomputes it from the PR head + salt.\n *\n * Optional, defaults to '' — empty means \"no token minted, no CI enforcement\" (byte-identical to\n * before this field existed). This is COMMITTED, obscurity-grade: it stops unhooked teammates who\n * push + open a PR in the web UI, but is readable in-repo and therefore forgeable by a determined\n * reader. It is deliberately NOT cryptographically sound; nothing local can stop a filesystem-reading\n * agent. See RESPONSE-pr-gate-ci-enforcement / the design memo for the full tradeoff.\n */\n gateSalt: string;\n /**\n * What `wp-land-pr` (and `wp-cleanup`, which reaps the same branches) does with the LOCAL branch\n * once its PR is in main. Field-with-default rather than another positional constructor param —\n * this constructor is already at the max-params limit, and every existing `new PrGateConfig(...)`\n * call site correctly wants the default.\n */\n landPr: LandPrConfig = defaultLandPrConfig();\n /**\n * Globs whose diffs are NOT extracted into `.webpieces/pr-review/<feature>/diff/` — regenerated noise a\n * reviewer should not spend context reading (lockfiles, generated graphs). Default [].\n *\n * They are still MATCHED against checklists and still listed in the manifest, with a stub naming the\n * command that gets the real diff. Removing them from the changed-file set would read as \"this file did\n * not change\", which is a different and false claim.\n *\n * Fields-with-defaults rather than constructor params: that constructor is already at max-params, and\n * every existing `new PrGateConfig(...)` correctly wants the defaults.\n */\n reviewDiffExclude: string[] = [];\n /**\n * Repo-specific places a reviewer would otherwise hunt for, as `{label, path}` — e.g.\n * `{\"label\":\"Cloud Tasks queue names\",\"path\":\"terraform/services/\"}`. Resolved to absolute paths in each\n * generated instructions file; a configured-but-missing path is printed as missing, never dropped.\n */\n reviewContext: ReviewContextEntry[] = [];\n /**\n * Installed packages to resolve and hand reviewers by absolute directory. This is the knob aimed at a\n * measured failure: one reviewer burned three separate greps into `node_modules/@webpieces` looking for\n * a scanner the tooling could have pointed at directly.\n */\n reviewContextPackages: string[] = [];\n /**\n * Promote \"this reviewer wrote a verdict without ever opening the diff\" from a warning to a refusal.\n * Default false, and it should stay false until a repo has watched the warning for a while: the signal\n * is derived from undocumented Claude Code transcript internals, so a format change would otherwise\n * wedge every PR in the repo with no self-service way out.\n */\n requireDiffEvidence = false;\n /**\n * Where `wp-push-dev` publishes the disposable copy. Omitted ⇒ `dev-include` / `dev`, which is what\n * makes the whole flow work with NO config edit at all.\n */\n devDeploy: DevDeployConfig = defaultDevDeployConfig();\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n mode: string,\n buildCommand: string,\n gates: GateDefinition[],\n mergeMode: string,\n checklists: ChecklistDefinition[] = [],\n gateSalt = '',\n checklistComments = true,\n ) {\n this.mode = mode;\n this.buildCommand = buildCommand;\n this.gates = gates;\n this.mergeMode = mergeMode;\n this.checklists = checklists;\n this.gateSalt = gateSalt;\n this.checklistComments = checklistComments;\n }\n}\n\n// Default infra gates — path-pattern based, tuned for this monorepo. Clients override the\n// whole list via the `pr-gate.gates` array in webpieces.config.json.\nexport function defaultGates(): GateDefinition[] {\n return [\n new GateDefinition('API Changed', ['libraries/apis/**', '**/*Api.ts'], 'yellow'),\n new GateDefinition(\n 'Config Files Changed',\n ['**/package.json', '**/tsconfig*.json', 'nx.json', '**/*.config.*'],\n 'yellow',\n ),\n new GateDefinition(\n 'Dependency Graph Changed',\n ['architecture/dependencies.json'],\n 'yellow',\n ),\n new GateDefinition(\n 'Claude / Rules Changed',\n ['**/CLAUDE.md', '**/claude.*.md', '.claude/**', 'webpieces.config.json'],\n 'yellow',\n ),\n ];\n}\n\nexport function defaultPrGateConfig(): PrGateConfig {\n // No default checklists — the extension point is opt-in; the default monorepo ships none.\n return new PrGateConfig('ON', '', defaultGates(), MERGE_MODE_AUTO, []);\n}\n\ninterface RawGate {\n name?: string;\n patterns?: string[];\n warningColor?: string;\n disabled?: boolean;\n}\n\ninterface RawPrGateSection {\n mode?: string;\n buildCommand?: string;\n gates?: RawGate[];\n mergeMode?: string;\n // An ARRAY, always. validateChecklistsSection rejects every other shape (including the removed { doc }).\n checklists?: RawChecklistItem[];\n overrideReviewerAgent?: boolean;\n reviewerAgentName?: string;\n reviewerAgents?: number;\n maxReviewerRounds?: number;\n gateSalt?: string;\n checklistComments?: boolean;\n landPr?: RawLandPr;\n reviewDiffExclude?: string[];\n reviewContext?: RawReviewContext[];\n reviewContextPackages?: string[];\n requireDiffEvidence?: boolean;\n devDeploy?: RawDevDeploy;\n}\n\ninterface RawDevDeploy {\n branchNamespace?: string;\n devBranch?: string;\n}\n\ninterface RawLandPr {\n branchRetention?: string;\n}\n\ninterface RawReviewContext {\n label?: string;\n path?: string;\n}\n\nfunction toGate(raw: RawGate): GateDefinition {\n return new GateDefinition(\n raw.name ?? '',\n raw.patterns ?? [],\n raw.warningColor ?? 'yellow',\n raw.disabled ?? false,\n );\n}\n\n/**\n * Build a PrGateConfig from the already-parsed top-level `pr-gate` section, falling back to defaults\n * for any field the consumer omits. Pure transform — the file read + structural validation happen in\n * loadAndValidate (load-config.ts) so every consumer goes through one validated path. Pass undefined\n * (no `pr-gate` key / no config file) to get full defaults.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed here\nexport function buildPrGateConfig(section: unknown): PrGateConfig {\n const defaults = defaultPrGateConfig();\n if (section === undefined || section === null || typeof section !== 'object') return defaults;\n\n const raw = section as RawPrGateSection;\n const mode = raw.mode ?? defaults.mode;\n const buildCommand = raw.buildCommand ?? defaults.buildCommand;\n const gates = raw.gates !== undefined ? raw.gates.map(toGate) : defaults.gates;\n // REQUIRED — validatePrGateSection rejects an omitted/unknown value, so this fallback only ever\n // applies to the no-config-file path that defaultPrGateConfig() serves.\n const mergeMode = raw.mergeMode ?? defaults.mergeMode;\n // Optional extension point — omitted ⇒ [] ⇒ no checklists computed anywhere downstream. A non-array here\n // cannot reach us: validateChecklistsSection has already failed the load.\n // The webpieces reviewer unless `overrideReviewerAgent` is true, in which case `reviewerAgentName` names the\n // agent (validatePrGateSection rejects a name without the override, and the override without a name).\n // Required nonnegative integer: 0 disables reviewer-agent reviews; positive values cap the round.\n const agentName =\n raw.overrideReviewerAgent === true\n ? (raw.reviewerAgentName ?? '').trim()\n : DEFAULT_REVIEWER_AGENT_NAME;\n // `reviewerAgents` is REQUIRED and validated as a nonnegative integer before this runs, so the fallback is\n // unreachable in a loaded config and exists only to keep this total for a structure-only caller.\n const reviewer = new ReviewerAgentPolicy(\n agentName,\n typeof raw.reviewerAgents === 'number' ? raw.reviewerAgents : REVIEWER_AGENTS_PLACEHOLDER,\n );\n const checklists = Array.isArray(raw.checklists)\n ? raw.checklists.map(\n (item: RawChecklistItem): ChecklistDefinition => toChecklist(item, reviewer),\n )\n : defaults.checklists;\n // Optional — omitted ⇒ '' ⇒ no gate token minted and CI enforcement is a no-op (back-compat).\n const gateSalt = raw.gateSalt ?? defaults.gateSalt;\n // Optional — omitted ⇒ true ⇒ reviewer output published as a PR comment.\n const checklistComments = raw.checklistComments ?? defaults.checklistComments;\n const built = new PrGateConfig(\n mode,\n buildCommand,\n gates,\n mergeMode,\n checklists,\n gateSalt,\n checklistComments,\n );\n built.landPr = buildLandPrConfig(raw.landPr);\n built.reviewer = reviewer;\n built.maxReviewerRounds = raw.maxReviewerRounds as number;\n // Review-context knobs. All optional and all defaulted, so a config that omits every one of them (which\n // is every consumer's config today) behaves exactly as it did before they existed.\n built.reviewDiffExclude = Array.isArray(raw.reviewDiffExclude)\n ? raw.reviewDiffExclude\n : defaults.reviewDiffExclude;\n built.reviewContextPackages = Array.isArray(raw.reviewContextPackages)\n ? raw.reviewContextPackages\n : defaults.reviewContextPackages;\n built.reviewContext = Array.isArray(raw.reviewContext)\n ? raw.reviewContext.map(\n (e: RawReviewContext): ReviewContextEntry =>\n new ReviewContextEntry(e.label ?? '', e.path ?? ''),\n )\n : defaults.reviewContext;\n built.requireDiffEvidence = raw.requireDiffEvidence ?? defaults.requireDiffEvidence;\n built.devDeploy = buildDevDeployConfig(raw.devDeploy);\n return built;\n}\n\n/**\n * Build the `pr-gate.devDeploy` block. Omitted (the state of every consumer config today) ⇒ the\n * `dev-include` / `dev` defaults. An invalid value cannot reach here — validateDevDeploySection has\n * already failed the load.\n */\n// webpieces-disable no-function-outside-class -- module-level config transform, matches buildPrGateConfig above\nexport function buildDevDeployConfig(raw: RawDevDeploy | undefined): DevDeployConfig {\n const defaults = defaultDevDeployConfig();\n if (raw === undefined || raw === null || typeof raw !== 'object') return defaults;\n const namespace =\n typeof raw.branchNamespace === 'string' && raw.branchNamespace.trim() !== ''\n ? raw.branchNamespace.trim()\n : defaults.branchNamespace;\n const devBranch =\n typeof raw.devBranch === 'string' && raw.devBranch.trim() !== ''\n ? raw.devBranch.trim()\n : defaults.devBranch;\n return new DevDeployConfig(namespace, devBranch);\n}\n\n/**\n * Build the `pr-gate.landPr` block. Omitted (the current state of every consumer's config) ⇒ the\n * 'archive-tag' default, which is what makes this feature work with NO config edit at all. An invalid\n * value cannot reach here — validatePrGateSection has already failed the load.\n */\n// webpieces-disable no-function-outside-class -- module-level config transform, matches buildPrGateConfig above\nexport function buildLandPrConfig(raw: RawLandPr | undefined): LandPrConfig {\n const defaults = defaultLandPrConfig();\n if (raw === undefined || raw === null || typeof raw !== 'object') return defaults;\n const retention = raw.branchRetention;\n if (typeof retention !== 'string' || !BRANCH_RETENTIONS.includes(retention)) return defaults;\n return new LandPrConfig(retention);\n}\n"]}
1
+ {"version":3,"file":"pr-gate-config.js","sourceRoot":"","sources":["../../../../../packages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CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE;QAC5B,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC;IACnC,MAAM,SAAS,GACX,OAAO,GAAG,CAAC,SAAS,KAAK,QAAQ,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE;QAC5D,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE;QACtB,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;IAC7B,OAAO,IAAI,eAAe,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AACrD,CAAC;AAED;;;;GAIG;AACH,gHAAgH;AAChH,SAAgB,iBAAiB,CAAC,GAA0B;IACxD,MAAM,QAAQ,GAAG,mBAAmB,EAAE,CAAC;IACvC,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAClF,MAAM,SAAS,GAAG,GAAG,CAAC,eAAe,CAAC;IACtC,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,CAAC,sCAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC7F,OAAO,IAAI,YAAY,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC","sourcesContent":["import { BRANCH_RETENTION_ARCHIVE_TAG, BRANCH_RETENTIONS } from '@webpieces/repo-workflow-core';\nimport {\n ChecklistDefinition,\n DEFAULT_REVIEWER_AGENT_NAME,\n RawChecklistItem,\n REVIEWER_AGENTS_PLACEHOLDER,\n ReviewerAgentPolicy,\n toChecklist,\n} from './checklist-config';\n\n// PrGateConfig is the \"special section\" for the pr-gate dashboard. It does NOT live in the\n// validated `rules` map (the FieldDef schema can't express nested object arrays), but as a\n// top-level `pr-gate` key in webpieces.config.json. It is built and validated by\n// loadAndValidate (load-config.ts); this module holds only the data classes + defaults + toGate.\n\n/**\n * The build the pr-gate runs when a repo configures no `commands.pr-gate.buildCommand` — and the ONE\n * definition of it, because two things now need it: the gate that RUNS it (pr-gate's BuildAffected)\n * and the guard that REFUSES a whole-monorepo build and prints it instead (ai-hook-rules'\n * whole-repo-build-guard). A second copy in either package is a message that can teach a command the\n * gate does not run.\n *\n * `--base=$(git merge-base origin/main HEAD)` — the FORK POINT, not `origin/main`: basing on\n * origin/main marks projects touched by other people's already-merged PRs as affected. The `$(…)`\n * resolves because the gate spawns with `shell: true`; the guard resolves it itself before printing,\n * so the AI is never handed a template it might paste somewhere without a shell.\n */\nexport const DEFAULT_BUILD_COMMAND =\n 'pnpm nx affected --target=ci --base=$(git merge-base origin/main HEAD)';\n\nexport class GateDefinition {\n name: string;\n patterns: string[];\n // The warning color shown on the dashboard WHEN this gate's patterns match a changed file. Green\n // is implicit (shown when nothing matched), so it is never configured. warningColor is purely\n // visual — even 'red' never fails/blocks the PR (only the build gate can). 'yellow' = caution,\n // 'red' = louder \"look here\" flag (e.g. DB schema / migration changes). REQUIRED on every gate.\n warningColor: string; // 'yellow' | 'red'\n // Example/inactive gate: parsed and kept in the file (JSON has no comments) but skipped at\n // compute/render time. Other projects flip this to false and tune patterns/warningColor.\n disabled: boolean;\n\n constructor(name: string, patterns: string[], warningColor: string, disabled = false) {\n this.name = name;\n this.patterns = patterns;\n this.warningColor = warningColor;\n this.disabled = disabled;\n }\n}\n\n// How wp-finish-upsert-pr should try to LAND the PR once it has posted it. GitHub's auto-merge queue\n// is a REPO-level setting (`allow_auto_merge`) that many orgs turn OFF as a policy control, and it\n// CANNOT be forced from the client: `gh pr merge --auto` calls the enablePullRequestAutoMerge GraphQL\n// mutation, which hard-errors with \"Auto merge is not allowed for this repository\" when the repo says\n// no. So the only lever a config knob has is WHICH PATHS WE ATTEMPT — never whether the queue exists.\nexport const MERGE_MODE_AUTO = 'AUTO';\nexport const MERGE_MODE_NONE = 'NONE';\nexport const MERGE_MODES = [MERGE_MODE_AUTO, MERGE_MODE_NONE];\n\n/**\n * `pr-gate.landPr` — what happens to the LOCAL branch once its PR has landed.\n *\n * A rich object rather than a bare string (the `commands.pr-gate` precedent) so the next knob about\n * landing has a home, and so the rationale can sit beside the setting as a `*Why` sibling: JSON has no\n * comments, and `<key>Why` is how this repo documents non-obvious config.\n */\n/**\n * One `pr-gate.reviewContext` entry: a human label and a repo-relative path a reviewer is handed instead of\n * having to find it. Data-only (per CLAUDE.md).\n */\nexport class ReviewContextEntry {\n label: string;\n path: string; // repo-relative in config; resolved to absolute when written into an instructions file\n\n constructor(label: string, entryPath: string) {\n this.label = label;\n this.path = entryPath;\n }\n}\n\nexport class LandPrConfig {\n // One of BRANCH_RETENTIONS. Defaults to 'archive-tag' — see BranchArchiver for why a tag beats\n // keeping the branch, storing a patch, or trusting the reflog.\n branchRetention: string;\n\n constructor(branchRetention: string = BRANCH_RETENTION_ARCHIVE_TAG) {\n this.branchRetention = branchRetention;\n }\n}\n\n// webpieces-disable no-function-outside-class -- module-level config default, matches defaultGates/defaultPrGateConfig in this file\nexport function defaultLandPrConfig(): LandPrConfig {\n return new LandPrConfig(BRANCH_RETENTION_ARCHIVE_TAG);\n}\n\n// The two literal ref names the dev-deploy flow derives everything else from. Defaults, not policy —\n// `pr-gate.devDeploy` overrides both, because a consumer whose shared environment is called `staging`\n// must not be forced onto webpieces' vocabulary.\nexport const DEFAULT_DEV_BRANCH_NAMESPACE = 'dev-include';\nexport const DEFAULT_DEV_BRANCH = 'dev';\n\n/**\n * `pr-gate.devDeploy` — where `wp-push-dev` publishes the throwaway copy of a feature branch, and which\n * ref is the shared dev branch itself.\n *\n * WHY A NAMESPACE AT ALL, i.e. why the copy is not just the feature branch: the feature branch is the PR\n * head, and landing that PR ships whatever is on it. The moment a conflict between two devs has to be\n * resolved SOMEWHERE for the shared environment to build, that resolution needs a home that is not the PR\n * branch — otherwise \"test it in dev\" silently ships another dev's unreviewed work to production. The\n * `<branchNamespace>/<feature>` copy is that home, and it is disposable by construction.\n *\n * `devBranch` is REFUSED as a source branch (you never push the composed branch back into itself); it is\n * written by the consumer's CI only, which recomputes it from `origin/main` on every run.\n */\nexport class DevDeployConfig {\n // Literal prefix on the feature branch name: `dev-include/dean/ONE-2275`. Git refs allow slashes, and\n // nobody ever types this — the command derives it.\n branchNamespace: string;\n // The composed, CI-owned branch that actually deploys. Never a source, never pushed to by this flow.\n devBranch: string;\n\n constructor(\n branchNamespace: string = DEFAULT_DEV_BRANCH_NAMESPACE,\n devBranch: string = DEFAULT_DEV_BRANCH,\n ) {\n this.branchNamespace = branchNamespace;\n this.devBranch = devBranch;\n }\n\n /** `<branchNamespace>/<branch>` — the remote ref holding the disposable copy of `branch`. */\n copyRefFor(branch: string): string {\n return `${this.branchNamespace}/${branch}`;\n }\n\n /** The `git ls-remote --heads origin <pattern>` pattern matching every live copy. */\n copyRefGlob(): string {\n return `${this.branchNamespace}/*`;\n }\n}\n\n// webpieces-disable no-function-outside-class -- module-level config default, matches defaultGates/defaultPrGateConfig in this file\nexport function defaultDevDeployConfig(): DevDeployConfig {\n return new DevDeployConfig(DEFAULT_DEV_BRANCH_NAMESPACE, DEFAULT_DEV_BRANCH);\n}\n\nexport class PrGateConfig {\n mode: string;\n /**\n * The nx-affected build gate command, shared by the two commands that can run it.\n *\n * It is NOT finish-only any more, and the change is the point. It used to run once, in\n * wp-finish-upsert-pr, which meant reviewers were spawned against a branch nobody had built — they could\n * spend a full review on code that does not compile, or on an unresolved 3-point merge.\n *\n * Now `wp-review-upsert-pr` finalizes the merge and runs this gate BEFORE briefing any reviewer, and\n * records the passing HEAD sha in the stage receipt. `wp-finish-upsert-pr` re-runs it only when HEAD has\n * moved since — so the flow gained a gate where it mattered without paying for two full builds.\n *\n * Empty string => BuildAffected falls back to DEFAULT_BUILD_COMMAND.\n */\n buildCommand: string;\n gates: GateDefinition[];\n /**\n * REQUIRED — every repo must state its policy; there is deliberately no default, because the two\n * answers are a real policy decision and guessing it either merges when a team did not want that,\n * or silently stops landing PRs on a team that relied on it.\n *\n * AUTO — wp-finish-upsert-pr LANDS the PR: squash-merge it right away when it is mergeable, else\n * enable GitHub auto-merge so it lands when the checks pass. Both carry an explicit --subject /\n * --body-file, which is the ONLY way main's history gets the PR title plus the compact\n * risk/flags body — no repo setting can produce that. Requires allow_auto_merge on the repo.\n * NONE — wp-finish-upsert-pr only opens/updates the PR and stops; a human merges. NOTE the cost:\n * a UI merge cannot use the compact body, so main's commit falls back to the repo's\n * squash_merge_commit_title/message settings. Set squash_merge_commit_title=PR_TITLE there, or\n * commits land as the internal \"Squash merge of <branch>\" subject.\n */\n mergeMode: string;\n // This repo's review checklists, straight from the `pr-gate.checklists` ARRAY in webpieces.config.json —\n // the ONLY accepted shape (`patterns` is a path-glob dispatch table and `id` the checklist's name, so both\n // are config). Every def carries {@link reviewer}. [] = no checklists. The removed `{ doc }` manifest\n // form is a hard config error; see validateChecklistsSection.\n checklists: ChecklistDefinition[];\n /**\n * The ONE agent type every checklist is reviewed by — `webpieces-reviewer` unless\n * `overrideReviewerAgent` is true, in which case `reviewerAgentName` — and `reviewerAgents`, the most such\n * subagents a round may use. The same instance is bound into every {@link checklists} entry, so a caller\n * holding only a checklist still knows what to spawn. Field-with-default because the constructor is at\n * max-params; the agent name defaults to the webpieces reviewer, exactly what a config that says nothing\n * gets, while the CAP is a required field, so the placeholder here is only ever overwritten by the real\n * number buildPrGateConfig reads.\n */\n reviewer: ReviewerAgentPolicy = new ReviewerAgentPolicy(DEFAULT_REVIEWER_AGENT_NAME, REVIEWER_AGENTS_PLACEHOLDER);\n /**\n * REQUIRED positive integer: the maximum number of complete global reviewer rounds a PR review state\n * may start. This is deliberately repository policy rather than a machine-local preference.\n */\n maxReviewerRounds!: number;\n // Whether wp-finish-upsert-pr publishes each reviewer's full `output` as ONE combined PR comment\n // (idempotently updated on every push). Defaults to true. Set false to keep the PR body-only.\n checklistComments: boolean;\n /**\n * Shared secret used to mint the server-verifiable gate token. `wp-finish-upsert-pr` writes it after\n * the automated gate passes; `wp-human-post-pr` writes the same token after explicit human attestation\n * and visibly labels review as skipped plus whether its optional local build ran. A CI check\n * recomputes it from the PR head + salt.\n *\n * Optional, defaults to '' — empty means \"no token minted, no CI enforcement\" (byte-identical to\n * before this field existed). This is COMMITTED, obscurity-grade: it stops unhooked teammates who\n * push + open a PR in the web UI, but is readable in-repo and therefore forgeable by a determined\n * reader. It is deliberately NOT cryptographically sound; nothing local can stop a filesystem-reading\n * agent. See RESPONSE-pr-gate-ci-enforcement / the design memo for the full tradeoff.\n */\n gateSalt: string;\n /**\n * What `wp-land-pr` (and `wp-cleanup`, which reaps the same branches) does with the LOCAL branch\n * once its PR is in main. Field-with-default rather than another positional constructor param —\n * this constructor is already at the max-params limit, and every existing `new PrGateConfig(...)`\n * call site correctly wants the default.\n */\n landPr: LandPrConfig = defaultLandPrConfig();\n /**\n * Globs whose diffs are NOT extracted into `.webpieces-logs/pr-review/<feature>/diff/` — regenerated noise a\n * reviewer should not spend context reading (lockfiles, generated graphs). Default [].\n *\n * They are still MATCHED against checklists and still listed in the manifest, with a stub naming the\n * command that gets the real diff. Removing them from the changed-file set would read as \"this file did\n * not change\", which is a different and false claim.\n *\n * Fields-with-defaults rather than constructor params: that constructor is already at max-params, and\n * every existing `new PrGateConfig(...)` correctly wants the defaults.\n */\n reviewDiffExclude: string[] = [];\n /**\n * Repo-specific places a reviewer would otherwise hunt for, as `{label, path}` — e.g.\n * `{\"label\":\"Cloud Tasks queue names\",\"path\":\"terraform/services/\"}`. Resolved to absolute paths in each\n * generated instructions file; a configured-but-missing path is printed as missing, never dropped.\n */\n reviewContext: ReviewContextEntry[] = [];\n /**\n * Installed packages to resolve and hand reviewers by absolute directory. This is the knob aimed at a\n * measured failure: one reviewer burned three separate greps into `node_modules/@webpieces` looking for\n * a scanner the tooling could have pointed at directly.\n */\n reviewContextPackages: string[] = [];\n /**\n * Promote \"this reviewer wrote a verdict without ever opening the diff\" from a warning to a refusal.\n * Default false, and it should stay false until a repo has watched the warning for a while: the signal\n * is derived from undocumented Claude Code transcript internals, so a format change would otherwise\n * wedge every PR in the repo with no self-service way out.\n */\n requireDiffEvidence = false;\n /**\n * Where `wp-push-dev` publishes the disposable copy. Omitted ⇒ `dev-include` / `dev`, which is what\n * makes the whole flow work with NO config edit at all.\n */\n devDeploy: DevDeployConfig = defaultDevDeployConfig();\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n mode: string,\n buildCommand: string,\n gates: GateDefinition[],\n mergeMode: string,\n checklists: ChecklistDefinition[] = [],\n gateSalt = '',\n checklistComments = true,\n ) {\n this.mode = mode;\n this.buildCommand = buildCommand;\n this.gates = gates;\n this.mergeMode = mergeMode;\n this.checklists = checklists;\n this.gateSalt = gateSalt;\n this.checklistComments = checklistComments;\n }\n}\n\n// Default infra gates — path-pattern based, tuned for this monorepo. Clients override the\n// whole list via the `pr-gate.gates` array in webpieces.config.json.\nexport function defaultGates(): GateDefinition[] {\n return [\n new GateDefinition('API Changed', ['libraries/apis/**', '**/*Api.ts'], 'yellow'),\n new GateDefinition(\n 'Config Files Changed',\n ['**/package.json', '**/tsconfig*.json', 'nx.json', '**/*.config.*'],\n 'yellow',\n ),\n new GateDefinition(\n 'Dependency Graph Changed',\n ['architecture/dependencies.json'],\n 'yellow',\n ),\n new GateDefinition(\n 'Claude / Rules Changed',\n ['**/CLAUDE.md', '**/claude.*.md', '.claude/**', 'webpieces.config.json'],\n 'yellow',\n ),\n ];\n}\n\nexport function defaultPrGateConfig(): PrGateConfig {\n // No default checklists — the extension point is opt-in; the default monorepo ships none.\n return new PrGateConfig('ON', '', defaultGates(), MERGE_MODE_AUTO, []);\n}\n\ninterface RawGate {\n name?: string;\n patterns?: string[];\n warningColor?: string;\n disabled?: boolean;\n}\n\ninterface RawPrGateSection {\n mode?: string;\n buildCommand?: string;\n gates?: RawGate[];\n mergeMode?: string;\n // An ARRAY, always. validateChecklistsSection rejects every other shape (including the removed { doc }).\n checklists?: RawChecklistItem[];\n overrideReviewerAgent?: boolean;\n reviewerAgentName?: string;\n reviewerAgents?: number;\n maxReviewerRounds?: number;\n gateSalt?: string;\n checklistComments?: boolean;\n landPr?: RawLandPr;\n reviewDiffExclude?: string[];\n reviewContext?: RawReviewContext[];\n reviewContextPackages?: string[];\n requireDiffEvidence?: boolean;\n devDeploy?: RawDevDeploy;\n}\n\ninterface RawDevDeploy {\n branchNamespace?: string;\n devBranch?: string;\n}\n\ninterface RawLandPr {\n branchRetention?: string;\n}\n\ninterface RawReviewContext {\n label?: string;\n path?: string;\n}\n\nfunction toGate(raw: RawGate): GateDefinition {\n return new GateDefinition(\n raw.name ?? '',\n raw.patterns ?? [],\n raw.warningColor ?? 'yellow',\n raw.disabled ?? false,\n );\n}\n\n/**\n * Build a PrGateConfig from the already-parsed top-level `pr-gate` section, falling back to defaults\n * for any field the consumer omits. Pure transform — the file read + structural validation happen in\n * loadAndValidate (load-config.ts) so every consumer goes through one validated path. Pass undefined\n * (no `pr-gate` key / no config file) to get full defaults.\n */\n// webpieces-disable no-any-unknown -- `section` is opaque consumer JSON until narrowed here\nexport function buildPrGateConfig(section: unknown): PrGateConfig {\n const defaults = defaultPrGateConfig();\n if (section === undefined || section === null || typeof section !== 'object') return defaults;\n\n const raw = section as RawPrGateSection;\n const mode = raw.mode ?? defaults.mode;\n const buildCommand = raw.buildCommand ?? defaults.buildCommand;\n const gates = raw.gates !== undefined ? raw.gates.map(toGate) : defaults.gates;\n // REQUIRED — validatePrGateSection rejects an omitted/unknown value, so this fallback only ever\n // applies to the no-config-file path that defaultPrGateConfig() serves.\n const mergeMode = raw.mergeMode ?? defaults.mergeMode;\n // Optional extension point — omitted ⇒ [] ⇒ no checklists computed anywhere downstream. A non-array here\n // cannot reach us: validateChecklistsSection has already failed the load.\n // The webpieces reviewer unless `overrideReviewerAgent` is true, in which case `reviewerAgentName` names the\n // agent (validatePrGateSection rejects a name without the override, and the override without a name).\n // Required nonnegative integer: 0 disables reviewer-agent reviews; positive values cap the round.\n const agentName =\n raw.overrideReviewerAgent === true\n ? (raw.reviewerAgentName ?? '').trim()\n : DEFAULT_REVIEWER_AGENT_NAME;\n // `reviewerAgents` is REQUIRED and validated as a nonnegative integer before this runs, so the fallback is\n // unreachable in a loaded config and exists only to keep this total for a structure-only caller.\n const reviewer = new ReviewerAgentPolicy(\n agentName,\n typeof raw.reviewerAgents === 'number' ? raw.reviewerAgents : REVIEWER_AGENTS_PLACEHOLDER,\n );\n const checklists = Array.isArray(raw.checklists)\n ? raw.checklists.map(\n (item: RawChecklistItem): ChecklistDefinition => toChecklist(item, reviewer),\n )\n : defaults.checklists;\n // Optional — omitted ⇒ '' ⇒ no gate token minted and CI enforcement is a no-op (back-compat).\n const gateSalt = raw.gateSalt ?? defaults.gateSalt;\n // Optional — omitted ⇒ true ⇒ reviewer output published as a PR comment.\n const checklistComments = raw.checklistComments ?? defaults.checklistComments;\n const built = new PrGateConfig(\n mode,\n buildCommand,\n gates,\n mergeMode,\n checklists,\n gateSalt,\n checklistComments,\n );\n built.landPr = buildLandPrConfig(raw.landPr);\n built.reviewer = reviewer;\n built.maxReviewerRounds = raw.maxReviewerRounds as number;\n // Review-context knobs. All optional and all defaulted, so a config that omits every one of them (which\n // is every consumer's config today) behaves exactly as it did before they existed.\n built.reviewDiffExclude = Array.isArray(raw.reviewDiffExclude)\n ? raw.reviewDiffExclude\n : defaults.reviewDiffExclude;\n built.reviewContextPackages = Array.isArray(raw.reviewContextPackages)\n ? raw.reviewContextPackages\n : defaults.reviewContextPackages;\n built.reviewContext = Array.isArray(raw.reviewContext)\n ? raw.reviewContext.map(\n (e: RawReviewContext): ReviewContextEntry =>\n new ReviewContextEntry(e.label ?? '', e.path ?? ''),\n )\n : defaults.reviewContext;\n built.requireDiffEvidence = raw.requireDiffEvidence ?? defaults.requireDiffEvidence;\n built.devDeploy = buildDevDeployConfig(raw.devDeploy);\n return built;\n}\n\n/**\n * Build the `pr-gate.devDeploy` block. Omitted (the state of every consumer config today) ⇒ the\n * `dev-include` / `dev` defaults. An invalid value cannot reach here — validateDevDeploySection has\n * already failed the load.\n */\n// webpieces-disable no-function-outside-class -- module-level config transform, matches buildPrGateConfig above\nexport function buildDevDeployConfig(raw: RawDevDeploy | undefined): DevDeployConfig {\n const defaults = defaultDevDeployConfig();\n if (raw === undefined || raw === null || typeof raw !== 'object') return defaults;\n const namespace =\n typeof raw.branchNamespace === 'string' && raw.branchNamespace.trim() !== ''\n ? raw.branchNamespace.trim()\n : defaults.branchNamespace;\n const devBranch =\n typeof raw.devBranch === 'string' && raw.devBranch.trim() !== ''\n ? raw.devBranch.trim()\n : defaults.devBranch;\n return new DevDeployConfig(namespace, devBranch);\n}\n\n/**\n * Build the `pr-gate.landPr` block. Omitted (the current state of every consumer's config) ⇒ the\n * 'archive-tag' default, which is what makes this feature work with NO config edit at all. An invalid\n * value cannot reach here — validatePrGateSection has already failed the load.\n */\n// webpieces-disable no-function-outside-class -- module-level config transform, matches buildPrGateConfig above\nexport function buildLandPrConfig(raw: RawLandPr | undefined): LandPrConfig {\n const defaults = defaultLandPrConfig();\n if (raw === undefined || raw === null || typeof raw !== 'object') return defaults;\n const retention = raw.branchRetention;\n if (typeof retention !== 'string' || !BRANCH_RETENTIONS.includes(retention)) return defaults;\n return new LandPrConfig(retention);\n}\n"]}
@@ -1,14 +1,14 @@
1
1
  import { DotWebpieces } from '@webpieces/tooling-common';
2
- export declare const INSTRUCT_AI_DIR = ".webpieces/instruct-ai";
2
+ export declare const INSTRUCT_AI_DIR = ".webpieces-logs/instruct-ai";
3
3
  export declare const INSTRUCT_AI_LEAF = "instruct-ai";
4
4
  /**
5
- * Resolves the single repo root that owns the `.webpieces/` tree, and renders absolute paths beneath
5
+ * Resolves the single repo root that owns the `.webpieces-logs/` tree, and renders absolute paths beneath
6
6
  * it.
7
7
  *
8
- * `.webpieces/` MUST live at the repo root — never in a CWD-dependent subdirectory. A tool invoked
9
- * from a subdir (a nested package, a `services/*` app) that naively joined `.webpieces` onto its own
10
- * cwd would scatter stray `.webpieces` trees across the tree — the exact bug this prevents. Every
11
- * writer of `.webpieces/...` (logs, instruct-ai docs, sync cache, merge/pr state) MUST anchor its
8
+ * `.webpieces-logs/` MUST live at the repo root — never in a CWD-dependent subdirectory. A tool invoked
9
+ * from a subdir (a nested package, a `services/*` app) that naively joined `.webpieces-logs` onto its own
10
+ * cwd would scatter stray `.webpieces-logs` trees across the tree — the exact bug this prevents. Every
11
+ * writer of `.webpieces-logs/...` (logs, instruct-ai docs, sync cache, merge/pr state) MUST anchor its
12
12
  * path here rather than at `process.cwd()`.
13
13
  */
14
14
  export declare class RepoRootFinder {
@@ -36,7 +36,7 @@ export declare class RepoRootFinder {
36
36
  resolveRepoRoot(startDir: string): string;
37
37
  /**
38
38
  * Absolute path to an instruct-ai doc. Hand THIS to the AI in a violation/fix message — never a
39
- * bare `.webpieces/instruct-ai/...` relative path, which an AI whose cwd is a subdirectory would
39
+ * bare `.webpieces-logs/instruct-ai/...` relative path, which an AI whose cwd is a subdirectory would
40
40
  * resolve against the wrong directory and fail to open.
41
41
  *
42
42
  * LOCAL scope: these docs are regenerated by every `wp-*` command, so under a shared path seven
package/src/repo-root.js CHANGED
@@ -7,19 +7,19 @@ const inversify_1 = require("inversify");
7
7
  const config_file_1 = require("./config-file");
8
8
  const tooling_common_1 = require("@webpieces/tooling-common");
9
9
  const tooling_common_2 = require("@webpieces/tooling-common");
10
- // The single instruct-ai home under `.webpieces/`. Kept here (not just in load-template) so callers
10
+ // The single instruct-ai home under `.webpieces-logs/`. Kept here (not just in load-template) so callers
11
11
  // building AI-facing messages can render the ABSOLUTE doc path from a resolved repo root.
12
12
  exports.INSTRUCT_AI_DIR = `${tooling_common_1.WEBPIECES_TMP_DIR}/instruct-ai`;
13
- // The instruct-ai leaf under a resolved `.webpieces` dir. LOCAL scope — see instructAiDocPath.
13
+ // The instruct-ai leaf under a resolved `.webpieces-logs` dir. LOCAL scope — see instructAiDocPath.
14
14
  exports.INSTRUCT_AI_LEAF = 'instruct-ai';
15
15
  /**
16
- * Resolves the single repo root that owns the `.webpieces/` tree, and renders absolute paths beneath
16
+ * Resolves the single repo root that owns the `.webpieces-logs/` tree, and renders absolute paths beneath
17
17
  * it.
18
18
  *
19
- * `.webpieces/` MUST live at the repo root — never in a CWD-dependent subdirectory. A tool invoked
20
- * from a subdir (a nested package, a `services/*` app) that naively joined `.webpieces` onto its own
21
- * cwd would scatter stray `.webpieces` trees across the tree — the exact bug this prevents. Every
22
- * writer of `.webpieces/...` (logs, instruct-ai docs, sync cache, merge/pr state) MUST anchor its
19
+ * `.webpieces-logs/` MUST live at the repo root — never in a CWD-dependent subdirectory. A tool invoked
20
+ * from a subdir (a nested package, a `services/*` app) that naively joined `.webpieces-logs` onto its own
21
+ * cwd would scatter stray `.webpieces-logs` trees across the tree — the exact bug this prevents. Every
22
+ * writer of `.webpieces-logs/...` (logs, instruct-ai docs, sync cache, merge/pr state) MUST anchor its
23
23
  * path here rather than at `process.cwd()`.
24
24
  */
25
25
  let RepoRootFinder = class RepoRootFinder {
@@ -57,7 +57,7 @@ let RepoRootFinder = class RepoRootFinder {
57
57
  }
58
58
  /**
59
59
  * Absolute path to an instruct-ai doc. Hand THIS to the AI in a violation/fix message — never a
60
- * bare `.webpieces/instruct-ai/...` relative path, which an AI whose cwd is a subdirectory would
60
+ * bare `.webpieces-logs/instruct-ai/...` relative path, which an AI whose cwd is a subdirectory would
61
61
  * resolve against the wrong directory and fail to open.
62
62
  *
63
63
  * LOCAL scope: these docs are regenerated by every `wp-*` command, so under a shared path seven
@@ -1 +1 @@
1
- {"version":3,"file":"repo-root.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/repo-root.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,yCAA2D;AAE3D,+CAA+C;AAC/C,8DAA8D;AAC9D,8DAAuE;AAEvE,oGAAoG;AACpG,0FAA0F;AAC7E,QAAA,eAAe,GAAG,GAAG,kCAAiB,cAAc,CAAC;AAClE,+FAA+F;AAClF,QAAA,gBAAgB,GAAG,aAAa,CAAC;AAE9C;;;;;;;;;GASG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;IACM;IAA7B,YAA6B,SAAuB,6BAAY;QAAnC,WAAM,GAAN,MAAM,CAA6B;IAAG,CAAC;IAEpE;;;;;;;;;;;;;;;;;;OAkBG;IACH,eAAe,CAAC,QAAgB;QAC5B,MAAM,UAAU,GAAG,IAAA,4BAAc,EAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,UAAU,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC/C,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,OAAO,CAAC;QACrC,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED;;;;;;;;;;OAUG;IACH,iBAAiB,CAAC,QAAgB,EAAE,OAAe;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,wBAAgB,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;IAED,gGAAgG;IAChG,WAAW,CAAC,QAAgB,EAAE,OAAe;QACzC,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;CAEJ,CAAA;AAlDY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEA,6BAAY;GADxC,cAAc,CAkD1B","sourcesContent":["import * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { findConfigFile } from './config-file';\nimport { WEBPIECES_TMP_DIR } from '@webpieces/tooling-common';\nimport { DotWebpieces, dotWebpieces } from '@webpieces/tooling-common';\n\n// The single instruct-ai home under `.webpieces/`. Kept here (not just in load-template) so callers\n// building AI-facing messages can render the ABSOLUTE doc path from a resolved repo root.\nexport const INSTRUCT_AI_DIR = `${WEBPIECES_TMP_DIR}/instruct-ai`;\n// The instruct-ai leaf under a resolved `.webpieces` dir. LOCAL scope — see instructAiDocPath.\nexport const INSTRUCT_AI_LEAF = 'instruct-ai';\n\n/**\n * Resolves the single repo root that owns the `.webpieces/` tree, and renders absolute paths beneath\n * it.\n *\n * `.webpieces/` MUST live at the repo root — never in a CWD-dependent subdirectory. A tool invoked\n * from a subdir (a nested package, a `services/*` app) that naively joined `.webpieces` onto its own\n * cwd would scatter stray `.webpieces` trees across the tree — the exact bug this prevents. Every\n * writer of `.webpieces/...` (logs, instruct-ai docs, sync cache, merge/pr state) MUST anchor its\n * path here rather than at `process.cwd()`.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class RepoRootFinder {\n constructor(private readonly dotDir: DotWebpieces = dotWebpieces) {}\n\n /**\n * The repo root for `startDir`. Resolution order (first hit wins):\n * 1. Directory holding webpieces.config.json — the webpieces workspace root, and the exact\n * anchor the hook runner already uses. Walks UP from startDir, so a subdir resolves to root.\n * 2. git toplevel — the repo root when no config is present yet (e.g. the installer runs before\n * webpieces.config.json exists). Asked via `DotWebpieces.treeRoot`, which is the ONE\n * `git rev-parse` tree-root resolver in this repo (memoized, fails closed). This class used to\n * carry its own byte-identical `spawnSync` copy, with a comment claiming to \"mirror\"\n * runner.ts's — a mirror that had already drifted, since runner.ts had moved the call to\n * effective-tree.ts. There is one implementation now, so a mirror cannot drift.\n * 3. `startDir` — last resort (git unavailable / not a repo / no config). Best-effort only.\n *\n * Step 1 is deliberately FIRST and deliberately not identity: config walk-up climbs PAST a nested\n * clone's `.git` to the outer webpieces root (repo-root.spec.ts pins that), and in a linked worktree\n * it answers with the WORKTREE, because `webpieces.config.json` is TRACKED IN GIT and therefore part\n * of the BRANCH — a branch may change its own rules. See state-dir.ts for that boundary, and\n * `EffectiveTreeResolver` for the different question (\"which tree is this, and is it ours\") that\n * must NOT be answered from the config file.\n */\n resolveRepoRoot(startDir: string): string {\n const configPath = findConfigFile(startDir);\n if (configPath !== null) return path.dirname(configPath);\n const gitRoot = this.dotDir.treeRoot(startDir);\n if (gitRoot !== null) return gitRoot;\n return startDir;\n }\n\n /**\n * Absolute path to an instruct-ai doc. Hand THIS to the AI in a violation/fix message — never a\n * bare `.webpieces/instruct-ai/...` relative path, which an AI whose cwd is a subdirectory would\n * resolve against the wrong directory and fail to open.\n *\n * LOCAL scope: these docs are regenerated by every `wp-*` command, so under a shared path seven\n * agents would rewrite one file concurrently for no benefit — the content is version-scoped and\n * identical, and a doc the AI is told to open must never be mid-truncation. Per-worktree it has one\n * writer. TemplateWriter additionally writes it atomically and skips the write entirely when the\n * bytes already match.\n */\n instructAiDocPath(repoRoot: string, docName: string): string {\n return this.dotDir.localFile(repoRoot, INSTRUCT_AI_LEAF, docName);\n }\n\n /** Absolute instruct-ai doc path resolved directly from `startDir` (resolveRepoRoot + join). */\n docPathFrom(startDir: string, docName: string): string {\n return this.instructAiDocPath(this.resolveRepoRoot(startDir), docName);\n }\n\n}\n"]}
1
+ {"version":3,"file":"repo-root.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/repo-root.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAC7B,yCAA2D;AAE3D,+CAA+C;AAC/C,8DAA8D;AAC9D,8DAAuE;AAEvE,yGAAyG;AACzG,0FAA0F;AAC7E,QAAA,eAAe,GAAG,GAAG,kCAAiB,cAAc,CAAC;AAClE,oGAAoG;AACvF,QAAA,gBAAgB,GAAG,aAAa,CAAC;AAE9C;;;;;;;;;GASG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;IACM;IAA7B,YAA6B,SAAuB,6BAAY;QAAnC,WAAM,GAAN,MAAM,CAA6B;IAAG,CAAC;IAEpE;;;;;;;;;;;;;;;;;;OAkBG;IACH,eAAe,CAAC,QAAgB;QAC5B,MAAM,UAAU,GAAG,IAAA,4BAAc,EAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,UAAU,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC/C,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,OAAO,CAAC;QACrC,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED;;;;;;;;;;OAUG;IACH,iBAAiB,CAAC,QAAgB,EAAE,OAAe;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,wBAAgB,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;IAED,gGAAgG;IAChG,WAAW,CAAC,QAAgB,EAAE,OAAe;QACzC,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;CAEJ,CAAA;AAlDY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEA,6BAAY;GADxC,cAAc,CAkD1B","sourcesContent":["import * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { findConfigFile } from './config-file';\nimport { WEBPIECES_TMP_DIR } from '@webpieces/tooling-common';\nimport { DotWebpieces, dotWebpieces } from '@webpieces/tooling-common';\n\n// The single instruct-ai home under `.webpieces-logs/`. Kept here (not just in load-template) so callers\n// building AI-facing messages can render the ABSOLUTE doc path from a resolved repo root.\nexport const INSTRUCT_AI_DIR = `${WEBPIECES_TMP_DIR}/instruct-ai`;\n// The instruct-ai leaf under a resolved `.webpieces-logs` dir. LOCAL scope — see instructAiDocPath.\nexport const INSTRUCT_AI_LEAF = 'instruct-ai';\n\n/**\n * Resolves the single repo root that owns the `.webpieces-logs/` tree, and renders absolute paths beneath\n * it.\n *\n * `.webpieces-logs/` MUST live at the repo root — never in a CWD-dependent subdirectory. A tool invoked\n * from a subdir (a nested package, a `services/*` app) that naively joined `.webpieces-logs` onto its own\n * cwd would scatter stray `.webpieces-logs` trees across the tree — the exact bug this prevents. Every\n * writer of `.webpieces-logs/...` (logs, instruct-ai docs, sync cache, merge/pr state) MUST anchor its\n * path here rather than at `process.cwd()`.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class RepoRootFinder {\n constructor(private readonly dotDir: DotWebpieces = dotWebpieces) {}\n\n /**\n * The repo root for `startDir`. Resolution order (first hit wins):\n * 1. Directory holding webpieces.config.json — the webpieces workspace root, and the exact\n * anchor the hook runner already uses. Walks UP from startDir, so a subdir resolves to root.\n * 2. git toplevel — the repo root when no config is present yet (e.g. the installer runs before\n * webpieces.config.json exists). Asked via `DotWebpieces.treeRoot`, which is the ONE\n * `git rev-parse` tree-root resolver in this repo (memoized, fails closed). This class used to\n * carry its own byte-identical `spawnSync` copy, with a comment claiming to \"mirror\"\n * runner.ts's — a mirror that had already drifted, since runner.ts had moved the call to\n * effective-tree.ts. There is one implementation now, so a mirror cannot drift.\n * 3. `startDir` — last resort (git unavailable / not a repo / no config). Best-effort only.\n *\n * Step 1 is deliberately FIRST and deliberately not identity: config walk-up climbs PAST a nested\n * clone's `.git` to the outer webpieces root (repo-root.spec.ts pins that), and in a linked worktree\n * it answers with the WORKTREE, because `webpieces.config.json` is TRACKED IN GIT and therefore part\n * of the BRANCH — a branch may change its own rules. See state-dir.ts for that boundary, and\n * `EffectiveTreeResolver` for the different question (\"which tree is this, and is it ours\") that\n * must NOT be answered from the config file.\n */\n resolveRepoRoot(startDir: string): string {\n const configPath = findConfigFile(startDir);\n if (configPath !== null) return path.dirname(configPath);\n const gitRoot = this.dotDir.treeRoot(startDir);\n if (gitRoot !== null) return gitRoot;\n return startDir;\n }\n\n /**\n * Absolute path to an instruct-ai doc. Hand THIS to the AI in a violation/fix message — never a\n * bare `.webpieces-logs/instruct-ai/...` relative path, which an AI whose cwd is a subdirectory would\n * resolve against the wrong directory and fail to open.\n *\n * LOCAL scope: these docs are regenerated by every `wp-*` command, so under a shared path seven\n * agents would rewrite one file concurrently for no benefit — the content is version-scoped and\n * identical, and a doc the AI is told to open must never be mid-truncation. Per-worktree it has one\n * writer. TemplateWriter additionally writes it atomically and skips the write entirely when the\n * bytes already match.\n */\n instructAiDocPath(repoRoot: string, docName: string): string {\n return this.dotDir.localFile(repoRoot, INSTRUCT_AI_LEAF, docName);\n }\n\n /** Absolute instruct-ai doc path resolved directly from `startDir` (resolveRepoRoot + join). */\n docPathFrom(startDir: string, docName: string): string {\n return this.instructAiDocPath(this.resolveRepoRoot(startDir), docName);\n }\n\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  import { DotWebpieces } from '@webpieces/tooling-common';
2
- /** The subdirectory of the per-worktree `.webpieces` scope that holds throwaway runtime files. */
2
+ /** The subdirectory of the per-worktree `.webpieces-logs` scope that holds throwaway runtime files. */
3
3
  export declare const SCRATCH_DIR_NAME = "scratch";
4
4
  /**
5
- * Creates short-lived scratch directories under this worktree's `.webpieces/` scope.
5
+ * Creates short-lived scratch directories under this worktree's `.webpieces-logs/` scope.
6
6
  *
7
7
  * `local()` (not `aiWritable()`) is the right scope: these files are written by the TOOLING, never by an
8
8
  * agent, and `local()` keeps them under the primary clone so they outlive a reaped worktree exactly like
@@ -12,7 +12,7 @@ export declare class RepoScratchDirs {
12
12
  private readonly dotDir;
13
13
  constructor(dotDir?: DotWebpieces);
14
14
  /**
15
- * `fs.mkdtempSync` under `<.webpieces scope>/scratch/`, creating the parent if this is the first call.
15
+ * `fs.mkdtempSync` under `<.webpieces-logs scope>/scratch/`, creating the parent if this is the first call.
16
16
  *
17
17
  * `prefix` keeps the `wp-<area>-` convention, so a leftover names the code path that wrote it.
18
18
  */
@@ -7,13 +7,13 @@ const path = tslib_1.__importStar(require("path"));
7
7
  const inversify_1 = require("inversify");
8
8
  const tooling_common_1 = require("@webpieces/tooling-common");
9
9
  // ---------------------------------------------------------------------------
10
- // SHORT-LIVED RUNTIME SCRATCH FILES BELONG IN `.webpieces/`, NOT IN `$TMPDIR`.
10
+ // SHORT-LIVED RUNTIME SCRATCH FILES BELONG IN `.webpieces-logs/`, NOT IN `$TMPDIR`.
11
11
  //
12
12
  // Two `wp-*` code paths needed a path on disk for the length of one subprocess call — the squash body for
13
13
  // `gh pr merge --body-file`, and the nx graph dump — and both reached for `os.tmpdir()`. Neither has the
14
14
  // reason that justifies `$TMPDIR` for a SPEC fixture (see `spec-temp-dirs.ts`): they are not isolating
15
15
  // themselves from the developer's `$HOME`, and they do not `git init` inside themselves. They are
16
- // ordinary gate state, and every other piece of gate state lives under `.webpieces/`.
16
+ // ordinary gate state, and every other piece of gate state lives under `.webpieces-logs/`.
17
17
  //
18
18
  // Putting them there is not tidiness — it is what gives them an OWNER. `CleanTmp` already sweeps
19
19
  // `DotWebpieces.local()` on a 30-day retention at the end of every merge/PR flow, so a scratch file
@@ -21,10 +21,10 @@ const tooling_common_1 = require("@webpieces/tooling-common");
21
21
  // `$TMPDIR` had no owner at all, which is how 4,222 `wp-merge-body-` directories accumulated on one
22
22
  // machine.
23
23
  // ---------------------------------------------------------------------------
24
- /** The subdirectory of the per-worktree `.webpieces` scope that holds throwaway runtime files. */
24
+ /** The subdirectory of the per-worktree `.webpieces-logs` scope that holds throwaway runtime files. */
25
25
  exports.SCRATCH_DIR_NAME = 'scratch';
26
26
  /**
27
- * Creates short-lived scratch directories under this worktree's `.webpieces/` scope.
27
+ * Creates short-lived scratch directories under this worktree's `.webpieces-logs/` scope.
28
28
  *
29
29
  * `local()` (not `aiWritable()`) is the right scope: these files are written by the TOOLING, never by an
30
30
  * agent, and `local()` keeps them under the primary clone so they outlive a reaped worktree exactly like
@@ -36,7 +36,7 @@ let RepoScratchDirs = class RepoScratchDirs {
36
36
  this.dotDir = dotDir;
37
37
  }
38
38
  /**
39
- * `fs.mkdtempSync` under `<.webpieces scope>/scratch/`, creating the parent if this is the first call.
39
+ * `fs.mkdtempSync` under `<.webpieces-logs scope>/scratch/`, creating the parent if this is the first call.
40
40
  *
41
41
  * `prefix` keeps the `wp-<area>-` convention, so a leftover names the code path that wrote it.
42
42
  */
@@ -1 +1 @@
1
- {"version":3,"file":"repo-scratch-dirs.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/repo-scratch-dirs.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAC3D,8DAAuE;AAEvE,8EAA8E;AAC9E,+EAA+E;AAC/E,EAAE;AACF,0GAA0G;AAC1G,yGAAyG;AACzG,uGAAuG;AACvG,kGAAkG;AAClG,sFAAsF;AACtF,EAAE;AACF,iGAAiG;AACjG,oGAAoG;AACpG,oGAAoG;AACpG,oGAAoG;AACpG,WAAW;AACX,8EAA8E;AAE9E,kGAAkG;AACrF,QAAA,gBAAgB,GAAG,SAAS,CAAC;AAE1C;;;;;;GAMG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IACK;IAA7B,YAA6B,SAAuB,6BAAY;QAAnC,WAAM,GAAN,MAAM,CAA6B;IAAG,CAAC;IAEpE;;;;OAIG;IACH,IAAI,CAAC,QAAgB,EAAE,MAAc;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,wBAAgB,CAAC,CAAC;QACtE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACxC,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,CAAC;CACJ,CAAA;AAbY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEA,6BAAY;GADxC,eAAe,CAa3B","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { DotWebpieces, dotWebpieces } from '@webpieces/tooling-common';\n\n// ---------------------------------------------------------------------------\n// SHORT-LIVED RUNTIME SCRATCH FILES BELONG IN `.webpieces/`, NOT IN `$TMPDIR`.\n//\n// Two `wp-*` code paths needed a path on disk for the length of one subprocess call — the squash body for\n// `gh pr merge --body-file`, and the nx graph dump — and both reached for `os.tmpdir()`. Neither has the\n// reason that justifies `$TMPDIR` for a SPEC fixture (see `spec-temp-dirs.ts`): they are not isolating\n// themselves from the developer's `$HOME`, and they do not `git init` inside themselves. They are\n// ordinary gate state, and every other piece of gate state lives under `.webpieces/`.\n//\n// Putting them there is not tidiness — it is what gives them an OWNER. `CleanTmp` already sweeps\n// `DotWebpieces.local()` on a 30-day retention at the end of every merge/PR flow, so a scratch file\n// written here is reaped by a mechanism that already exists and is already tested. The same file in\n// `$TMPDIR` had no owner at all, which is how 4,222 `wp-merge-body-` directories accumulated on one\n// machine.\n// ---------------------------------------------------------------------------\n\n/** The subdirectory of the per-worktree `.webpieces` scope that holds throwaway runtime files. */\nexport const SCRATCH_DIR_NAME = 'scratch';\n\n/**\n * Creates short-lived scratch directories under this worktree's `.webpieces/` scope.\n *\n * `local()` (not `aiWritable()`) is the right scope: these files are written by the TOOLING, never by an\n * agent, and `local()` keeps them under the primary clone so they outlive a reaped worktree exactly like\n * the gate logs beside them.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class RepoScratchDirs {\n constructor(private readonly dotDir: DotWebpieces = dotWebpieces) {}\n\n /**\n * `fs.mkdtempSync` under `<.webpieces scope>/scratch/`, creating the parent if this is the first call.\n *\n * `prefix` keeps the `wp-<area>-` convention, so a leftover names the code path that wrote it.\n */\n make(repoRoot: string, prefix: string): string {\n const base = path.join(this.dotDir.local(repoRoot), SCRATCH_DIR_NAME);\n fs.mkdirSync(base, { recursive: true });\n return fs.mkdtempSync(path.join(base, prefix));\n }\n}\n"]}
1
+ {"version":3,"file":"repo-scratch-dirs.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/repo-scratch-dirs.ts"],"names":[],"mappings":";;;;AAAA,+CAAyB;AACzB,mDAA6B;AAC7B,yCAA2D;AAC3D,8DAAuE;AAEvE,8EAA8E;AAC9E,oFAAoF;AACpF,EAAE;AACF,0GAA0G;AAC1G,yGAAyG;AACzG,uGAAuG;AACvG,kGAAkG;AAClG,2FAA2F;AAC3F,EAAE;AACF,iGAAiG;AACjG,oGAAoG;AACpG,oGAAoG;AACpG,oGAAoG;AACpG,WAAW;AACX,8EAA8E;AAE9E,uGAAuG;AAC1F,QAAA,gBAAgB,GAAG,SAAS,CAAC;AAE1C;;;;;;GAMG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAe;IACK;IAA7B,YAA6B,SAAuB,6BAAY;QAAnC,WAAM,GAAN,MAAM,CAA6B;IAAG,CAAC;IAEpE;;;;OAIG;IACH,IAAI,CAAC,QAAgB,EAAE,MAAc;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,wBAAgB,CAAC,CAAC;QACtE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACxC,OAAO,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,CAAC;CACJ,CAAA;AAbY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEA,6BAAY;GADxC,eAAe,CAa3B","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { DotWebpieces, dotWebpieces } from '@webpieces/tooling-common';\n\n// ---------------------------------------------------------------------------\n// SHORT-LIVED RUNTIME SCRATCH FILES BELONG IN `.webpieces-logs/`, NOT IN `$TMPDIR`.\n//\n// Two `wp-*` code paths needed a path on disk for the length of one subprocess call — the squash body for\n// `gh pr merge --body-file`, and the nx graph dump — and both reached for `os.tmpdir()`. Neither has the\n// reason that justifies `$TMPDIR` for a SPEC fixture (see `spec-temp-dirs.ts`): they are not isolating\n// themselves from the developer's `$HOME`, and they do not `git init` inside themselves. They are\n// ordinary gate state, and every other piece of gate state lives under `.webpieces-logs/`.\n//\n// Putting them there is not tidiness — it is what gives them an OWNER. `CleanTmp` already sweeps\n// `DotWebpieces.local()` on a 30-day retention at the end of every merge/PR flow, so a scratch file\n// written here is reaped by a mechanism that already exists and is already tested. The same file in\n// `$TMPDIR` had no owner at all, which is how 4,222 `wp-merge-body-` directories accumulated on one\n// machine.\n// ---------------------------------------------------------------------------\n\n/** The subdirectory of the per-worktree `.webpieces-logs` scope that holds throwaway runtime files. */\nexport const SCRATCH_DIR_NAME = 'scratch';\n\n/**\n * Creates short-lived scratch directories under this worktree's `.webpieces-logs/` scope.\n *\n * `local()` (not `aiWritable()`) is the right scope: these files are written by the TOOLING, never by an\n * agent, and `local()` keeps them under the primary clone so they outlive a reaped worktree exactly like\n * the gate logs beside them.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class RepoScratchDirs {\n constructor(private readonly dotDir: DotWebpieces = dotWebpieces) {}\n\n /**\n * `fs.mkdtempSync` under `<.webpieces-logs scope>/scratch/`, creating the parent if this is the first call.\n *\n * `prefix` keeps the `wp-<area>-` convention, so a leftover names the code path that wrote it.\n */\n make(repoRoot: string, prefix: string): string {\n const base = path.join(this.dotDir.local(repoRoot), SCRATCH_DIR_NAME);\n fs.mkdirSync(base, { recursive: true });\n return fs.mkdtempSync(path.join(base, prefix));\n }\n}\n"]}
@@ -25,7 +25,7 @@ exports.VERDICT_YELLOW = 'yellow';
25
25
  exports.VERDICT_ORANGE = 'orange';
26
26
  exports.VERDICT_RED = 'red';
27
27
  exports.VERDICT_STATUSES = [exports.VERDICT_GREEN, exports.VERDICT_YELLOW, exports.VERDICT_ORANGE, exports.VERDICT_RED];
28
- // The verdict a reviewer SUBAGENT submits into `.webpieces/pr-review/<featureSlug>/review-round<N>-<id>.json`,
28
+ // The verdict a reviewer SUBAGENT submits into `.webpieces-logs/pr-review/<featureSlug>/review-round<N>-<id>.json`,
29
29
  // one per briefed checklist per round. One file per checklist per ROUND, so N concurrent reviewer subagents
30
30
  // never clobber a shared file and no round's verdict is ever overwritten by a later one (issue #1053): the
31
31
  // gate reads the HIGHEST round per checklist, and the earlier rounds stay on disk as the audit trail. It
@@ -198,7 +198,7 @@ class ChecklistVerdict {
198
198
  }
199
199
  }
200
200
  exports.ChecklistVerdict = ChecklistVerdict;
201
- // The PR's diff context, written by wp-start-upsert-pr into `.webpieces/pr-review/<featureSlug>/pr-context.json`
201
+ // The PR's diff context, written by wp-start-upsert-pr into `.webpieces-logs/pr-review/<featureSlug>/pr-context.json`
202
202
  // so a reviewer subagent knows the exact 3-point base the gate used and the full changed-file set — then
203
203
  // reads any file's actual diff with `git diff <base> HEAD -- <file>`. This is what lets a checklist match
204
204
  // coarsely by path (in the config) while the subagent makes the fine, content-level judgment. Data-only.
@@ -1 +1 @@
1
- {"version":3,"file":"review-json-data.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/review-json-data.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAKH,uGAAuG;AACvG,2GAA2G;AAC3G,mGAAmG;AACnG,qEAAqE;AACrE,EAAE;AACF,uGAAuG;AACvG,0GAA0G;AAC1G,0GAA0G;AAC1G,2GAA2G;AAC3G,4GAA4G;AAC5G,0GAA0G;AAC7F,QAAA,aAAa,GAAG,OAAO,CAAC;AACxB,QAAA,cAAc,GAAG,QAAQ,CAAC;AAC1B,QAAA,cAAc,GAAG,QAAQ,CAAC;AAC1B,QAAA,WAAW,GAAG,KAAK,CAAC;AACpB,QAAA,gBAAgB,GAAG,CAAC,qBAAa,EAAE,sBAAc,EAAE,sBAAc,EAAE,mBAAW,CAAU,CAAC;AAEtG,+GAA+G;AAC/G,4GAA4G;AAC5G,2GAA2G;AAC3G,yGAAyG;AACzG,uBAAuB;AACvB,gDAAgD;AAChD,iHAAiH;AAC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CAAC;QACjB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;CACJ;AA/CD,8BA+CC","sourcesContent":["/**\n * The DATA-ONLY classes and status constants of the PR review system — the verdict a reviewer writes, the\n * checklist that demanded it, the resolved outcome, and the diff context handed to reviewers.\n *\n * Split out of review-json.ts, which holds the SERVICE that reads and writes them. The split is purely by\n * kind (data vs behaviour): review-json.ts re-exports every name below, so `from './review-json'` and\n * `from '@webpieces/rules-config'` keep resolving exactly as before and no consumer changes.\n */\n\nimport { ReviewerAgentPolicy } from './checklist-config';\nimport { ChecklistOverride } from './checklist-override';\n\n// The colors a reviewer subagent may report in `review-round<N>-<id>.json`. Not a boolean, because the\n// boolean it replaced gave a reviewer no way to say \"this passes, but a human should look at X\" — the only\n// way to raise a concern was to FAIL the PR and then override your own failure, which reads on the\n// dashboard as a deliberately-accepted defect rather than as a note.\n//\n// RED and ORANGE are the two blocking colors, and WHICH one a reviewer may use is decided by the round\n// (issue #1053). `commands.pr-gate.maxReviewerRounds` is a hard ceiling: red means \"fix it and it will be\n// reviewed again\", which is only true while a round remains. On the FINAL round `wp-write-review` refuses\n// red and the reviewer marks the finding ORANGE instead — \"must fix, and nobody re-reviews it\". The author\n// fixes it best effort, records the fix with `wp-write-review-fixes`, and the PR ships with the finding and\n// its claimed fix stamped on the dashboard. Before the final round orange is refused the other way round.\nexport const VERDICT_GREEN = 'green';\nexport const VERDICT_YELLOW = 'yellow';\nexport const VERDICT_ORANGE = 'orange';\nexport const VERDICT_RED = 'red';\nexport const VERDICT_STATUSES = [VERDICT_GREEN, VERDICT_YELLOW, VERDICT_ORANGE, VERDICT_RED] as const;\n\n// The verdict a reviewer SUBAGENT submits into `.webpieces/pr-review/<featureSlug>/review-round<N>-<id>.json`,\n// one per briefed checklist per round. One file per checklist per ROUND, so N concurrent reviewer subagents\n// never clobber a shared file and no round's verdict is ever overwritten by a later one (issue #1053): the\n// gate reads the HIGHEST round per checklist, and the earlier rounds stay on disk as the audit trail. It\n// records the OUTCOME:\n// status:'green' → PASS\n// status:'yellow' → WARN (passes; the concern is published on the PR, nothing is blocked)\n// status:'orange' + a recorded fix → ORANGE_FIXED (ships, stamped \"author-fixed, not re-reviewed\")\n// status:'orange' + no recorded fix → ORANGE (refuse until the author records a fix)\n// status:'red' + an override-<id>.json → OVERRIDDEN (pass; the human's stated reason reaches the PR)\n// status:'red' + no override file → FAIL (refuse; `output` is printed verbatim)\n//\n// THE `override` FIELD IS GONE FROM THIS FILE, and there is no compatibility mode. The ship-anyway\n// justification used to live here as free text, which made the ONE participant who hears the human — the\n// coordinating agent — the one participant that could not record it, because editing a reviewer's verdict\n// file is (correctly) refused by the harness. It now lives in its own `override-<id>.json`; see\n// ChecklistOverride. A verdict file still carrying an `override` key is reported through `problem` with the\n// destination named, exactly as the removed `success` field is. Data-only (per CLAUDE.md).\nexport class ChecklistResult {\n agent: string;\n model: string;\n id: string;\n status: string; // one of VERDICT_STATUSES; anything else is reported via `problem`\n output: string; // what the reviewer found; printed verbatim when the checklist fails\n // The HUMAN's authorization loaded from `override-<id>.json` beside this verdict, or null when there is\n // none. Loaded alongside the verdict so `resolveVerdict` needs no second read of disk and every command\n // resolves the same outcome from the same bytes.\n override: ChecklistOverride | null;\n // '' = a well-formed verdict. Non-empty = the file exists and parses but its verdict cannot be READ\n // (most often: it still uses the removed `success` field, or the moved `override` field). Carried as\n // data rather than thrown so the complaint can be reported by BOTH wp-review-upsert-pr and\n // wp-finish-upsert-pr in identical words, and so a legacy file is never silently mistaken for a missing one.\n problem: string;\n /**\n * Non-empty only for an ORANGE whose final-round fix the author recorded with `wp-write-review-fixes`:\n * the dashboard line \"orange at <fromHead>, author-fixed in <toHead>, not re-reviewed: <resolution>\".\n */\n remediation: string;\n /** The review round this verdict was submitted in — the N of `review-round<N>-<id>.json`. */\n round: number;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n agent: string,\n model: string,\n id: string,\n status: string,\n output: string,\n override: ChecklistOverride | null,\n problem = '',\n ) {\n this.agent = agent;\n this.model = model;\n this.id = id;\n this.status = status;\n this.output = output;\n this.override = override;\n this.problem = problem;\n this.remediation = '';\n this.round = 0;\n }\n}\n\n/**\n * What the pr-gate command computed from the diff: a checklist this branch MATCHED (its patterns hit the\n * diff, so its reviewer subagent is in scope). Drives review-round<N>-<id>.json enforcement, provenance, the schema\n * hint, and the dashboard. Data-only.\n *\n * NAME NOTE: \"Required\" here means MATCHED, not mandatory — it predates `required` by a long way and is\n * the shared shape across review-json, the detector, the briefing builder, provenance and the dashboard.\n * Whether the reviewer must actually run is the {@link RequiredChecklist.required} field below.\n */\nexport class RequiredChecklist {\n id: string; // the checklist's name; keys review-round<N>-<id>.json and its instructions file\n reviewer: ReviewerAgentPolicy; // the agent type to spawn (agentType the harness stamps) + the round cap\n doc: string; // REPO-RELATIVE guidance doc the reviewer reads ('' → it just reads the diff)\n matchedFiles: string[]; // the changed files that matched it (for the dashboard + hint)\n // Which of the checklist's OWN globs actually fired. Printed so a reviewer can judge how coarse the\n // match was — a precise `db/migrations/**` hit means something different from a blanket `**` — and the\n // template tells reviewers that matching IS deliberately coarse. [] = no patterns (matches every PR).\n matchedPatterns: string[];\n // Straight from the checklist's config `required`. true = blocking; false = the human is offered it and\n // may decline. Carried on the MATCH rather than looked up from config downstream so the set that gates\n // and the set that is reported cannot disagree about which of the two a checklist is.\n required: boolean;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n id: string,\n reviewer: ReviewerAgentPolicy,\n doc: string,\n matchedFiles: string[],\n matchedPatterns: string[] = [],\n // Defaulted to the BLOCKING value so any construction that forgets it fails closed — a test or a\n // future call site that silently produced an optional checklist would be a hole in the gate.\n required = true,\n ) {\n this.id = id;\n this.reviewer = reviewer;\n this.doc = doc;\n this.matchedFiles = matchedFiles;\n this.matchedPatterns = matchedPatterns;\n this.required = required;\n }\n}\n\n/**\n * The per-PR facts every reviewer subagent needs GIVEN to it, alongside its own checklist: the exact base\n * sha the gate diffs against and the file holding the complete changed-file set. Both used to live only in\n * a doc the printed instruction told the AI to go read, one indirection away from the instruction to hand\n * them over — so the printed block could not stand on its own. Data-only; empty = omit those lines.\n */\nexport class ChecklistReviewContext {\n baseSha: string; // the 3-point merge-base sha\n prContextPath: string; // path of pr-context.json — the AUTHORITATIVE full changed-file set\n /**\n * The exact command that reproduces ONE file's diff, with a `-- <file>` tail — NOT assembled by the\n * caller. This used to be hardcoded as `git diff <baseSha> HEAD -- <file>`, which returns NOTHING on a\n * dirty tree because the changed-file set is computed base→working-tree. See DiffBasis, which derives\n * this string from the same range the file set came from.\n */\n fileDiffCommand: string;\n diffDir: string; // dir of the MATERIALIZED diff (diff/ALL.diff + diff/files/…); '' when not written\n dirty: boolean; // true ⇒ the range includes uncommitted + untracked work, and must be said out loud\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n baseSha = '',\n prContextPath = '',\n fileDiffCommand = '',\n diffDir = '',\n dirty = false,\n ) {\n this.baseSha = baseSha;\n this.prContextPath = prContextPath;\n this.fileDiffCommand = fileDiffCommand;\n this.diffDir = diffDir;\n this.dirty = dirty;\n }\n}\n\n// The AI-authored PR summary (title, risk, summary). Normally the AI writes summary.json between\n// `wp-start-upsert-pr` (which prints the schema) and `wp-finish-upsert-pr` (which reads it), while reviewer\n// subagents write review-round<N>-<id>.json. The human-only `wp-human-post-pr` escape hatch also requires and reads\n// this same summary shape, but deliberately skips reviewer verdicts. Data-only (per CLAUDE.md).\nexport class PrSummary {\n agent: string;\n model: string;\n title: string; // human PR title describing the change; used as the `gh pr` title (empty → caller falls back)\n riskScore: number; // 0–100, drives the risk bar\n riskLevel: string; // 'green' | 'yellow' | 'red'\n riskEmoji: string; // '🟢' | '🟡' | '🔴' — derived from riskLevel when omitted\n summary: string; // rendered in the dashboard Summary section\n violations: string[]; // pattern/architecture violations; length = the Pattern Violations count\n risks: string[];\n filesToReview: string[];\n results: ChecklistResult[]; // resolved per-checklist verdicts (from review-round<N>-<id>.json); [] when none\n mainAgentInstructions: string; // non-empty only for the opt-in single-round experiment\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n agent: string,\n model: string,\n title: string,\n riskScore: number,\n riskLevel: string,\n riskEmoji: string,\n summary: string,\n violations: string[],\n risks: string[],\n filesToReview: string[],\n results: ChecklistResult[] = [],\n mainAgentInstructions = '',\n ) {\n this.agent = agent;\n this.model = model;\n this.title = title;\n this.riskScore = riskScore;\n this.riskLevel = riskLevel;\n this.riskEmoji = riskEmoji;\n this.summary = summary;\n this.violations = violations;\n this.risks = risks;\n this.filesToReview = filesToReview;\n this.results = results;\n this.mainAgentInstructions = mainAgentInstructions;\n }\n}\n\n// A checklist's resolved outcome, shared by summary.json enforcement and the dashboard so both agree.\n// PASS, WARN, ORANGE_FIXED and OVERRIDDEN all ship; ORANGE, FAIL, MISSING and BAD_FORMAT all refuse the PR.\nexport const CK_PASS = 'pass'; // latest verdict status:'green'\nexport const CK_WARN = 'warn'; // latest verdict status:'yellow' → 🟡 passes WITH concerns\nexport const CK_ORANGE_FIXED = 'orange-fixed'; // status:'orange' + a recorded author fix → 🟠 ships, NOT re-reviewed\nexport const CK_ORANGE = 'orange'; // status:'orange' + no recorded fix → refuse until one is recorded\nexport const CK_OVERRIDDEN = 'overridden'; // status:'red' + a human's override-<id>.json → 🟠\nexport const CK_FAIL = 'fail'; // latest verdict status:'red' + no override → refuse\nexport const CK_MISSING = 'missing'; // no verdict submitted → refuse\nexport const CK_BAD_FORMAT = 'bad-format'; // written, but its verdict is unreadable (e.g. legacy `success`)\n\nexport class ChecklistVerdict {\n id: string;\n status: string; // one of CK_PASS | CK_WARN | CK_ORANGE_FIXED | CK_ORANGE | CK_OVERRIDDEN | CK_FAIL | CK_MISSING | CK_BAD_FORMAT\n detail: string; // reviewer output / override justification / format complaint (dashboard + errors)\n\n constructor(id: string, status: string, detail: string) {\n this.id = id;\n this.status = status;\n this.detail = detail;\n }\n}\n\n// The PR's diff context, written by wp-start-upsert-pr into `.webpieces/pr-review/<featureSlug>/pr-context.json`\n// so a reviewer subagent knows the exact 3-point base the gate used and the full changed-file set — then\n// reads any file's actual diff with `git diff <base> HEAD -- <file>`. This is what lets a checklist match\n// coarsely by path (in the config) while the subagent makes the fine, content-level judgment. Data-only.\nexport class PrContext {\n base: string; // the 3-point merge-base sha the gate diffs against\n /**\n * The real HEAD sha. This was once the literal string 'HEAD', which is not a fact — it cannot be\n * compared later to detect that the tree moved under a review, and it reads as a range that was never\n * actually diffed. Its only reader (reviewContextFor) takes `base`, so recording the sha is free.\n */\n head: string;\n changedFiles: string[]; // every file changed in the range (NOT tsOnly — includes .sql/.gql/Dockerfile/…)\n dirty: boolean; // true ⇒ changedFiles includes uncommitted + untracked work\n dirtyFiles: string[]; // exactly which paths are uncommitted/untracked — why `dirty` is true\n diffCommand: string; // the command that reproduces the WHOLE diff (see DiffBasis; correct when dirty)\n diffDir: string; // dir holding the materialized per-file diffs + ALL.diff; '' when not materialized\n generatedAt: string; // ISO timestamp, so a stale context is detectable rather than silently trusted\n /**\n * Main's head as this clone last saw it — the THIRD hash point, matching the trio the 3-point merge\n * records in `merge-info/<branch>/updatemain-hashes.json`. `base`/`head` above are points A and B\n * under the review side's older names.\n *\n * The review side used to record only A and B, so nothing could answer \"did main move while this was\n * under review?\" — the question you most want answered when a review looks stale. '' when origin/main\n * is unresolvable. Purely informational; nothing gates on it.\n */\n hashMainHead: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n base: string,\n head: string,\n changedFiles: string[],\n dirty = false,\n dirtyFiles: string[] = [],\n diffCommand = '',\n diffDir = '',\n generatedAt = '',\n hashMainHead = '',\n ) {\n this.hashMainHead = hashMainHead;\n this.base = base;\n this.head = head;\n this.changedFiles = changedFiles;\n this.dirty = dirty;\n this.dirtyFiles = dirtyFiles;\n this.diffCommand = diffCommand;\n this.diffDir = diffDir;\n this.generatedAt = generatedAt;\n }\n}\n"]}
1
+ {"version":3,"file":"review-json-data.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-config/src/review-json-data.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAKH,uGAAuG;AACvG,2GAA2G;AAC3G,mGAAmG;AACnG,qEAAqE;AACrE,EAAE;AACF,uGAAuG;AACvG,0GAA0G;AAC1G,0GAA0G;AAC1G,2GAA2G;AAC3G,4GAA4G;AAC5G,0GAA0G;AAC7F,QAAA,aAAa,GAAG,OAAO,CAAC;AACxB,QAAA,cAAc,GAAG,QAAQ,CAAC;AAC1B,QAAA,cAAc,GAAG,QAAQ,CAAC;AAC1B,QAAA,WAAW,GAAG,KAAK,CAAC;AACpB,QAAA,gBAAgB,GAAG,CAAC,qBAAa,EAAE,sBAAc,EAAE,sBAAc,EAAE,mBAAW,CAAU,CAAC;AAEtG,oHAAoH;AACpH,4GAA4G;AAC5G,2GAA2G;AAC3G,yGAAyG;AACzG,uBAAuB;AACvB,gDAAgD;AAChD,iHAAiH;AACjH,yGAAyG;AACzG,0FAA0F;AAC1F,uGAAuG;AACvG,uFAAuF;AACvF,EAAE;AACF,mGAAmG;AACnG,yGAAyG;AACzG,0GAA0G;AAC1G,gGAAgG;AAChG,4GAA4G;AAC5G,2FAA2F;AAC3F,MAAa,eAAe;IACxB,KAAK,CAAS;IACd,KAAK,CAAS;IACd,EAAE,CAAS;IACX,MAAM,CAAS,CAAC,mEAAmE;IACnF,MAAM,CAAS,CAAC,qEAAqE;IACrF,wGAAwG;IACxG,wGAAwG;IACxG,iDAAiD;IACjD,QAAQ,CAA2B;IACnC,oGAAoG;IACpG,qGAAqG;IACrG,2FAA2F;IAC3F,6GAA6G;IAC7G,OAAO,CAAS;IAChB;;;OAGG;IACH,W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G,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;CACJ;AAVD,4CAUC;AAED,sHAAsH;AACtH,yGAAyG;AACzG,0GAA0G;AAC1G,yGAAyG;AACzG,MAAa,SAAS;IAClB,IAAI,CAAS,CAAC,oDAAoD;IAClE;;;;OAIG;IACH,IAAI,CAAS;IACb,YAAY,CAAW,CAAC,iFAAiF;IACzG,KAAK,CAAU,CAAC,4DAA4D;IAC5E,UAAU,CAAW,CAAC,sEAAsE;IAC5F,WAAW,CAAS,CAAC,iFAAiF;IACtG,OAAO,CAAS,CAAC,mFAAmF;IACpG,WAAW,CAAS,CAAC,+EAA+E;IACpG;;;;;;;;OAQG;IACH,YAAY,CAAS;IAErB,yDAAyD;IACzD,YACI,IAAY,EACZ,IAAY,EACZ,YAAsB,EACtB,KAAK,GAAG,KAAK,EACb,aAAuB,EAAE,EACzB,WAAW,GAAG,EAAE,EAChB,OAAO,GAAG,EAAE,EACZ,WAAW,GAAG,EAAE,EAChB,YAAY,GAAG,EAAE;QAEjB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;CACJ;AA/CD,8BA+CC","sourcesContent":["/**\n * The DATA-ONLY classes and status constants of the PR review system — the verdict a reviewer writes, the\n * checklist that demanded it, the resolved outcome, and the diff context handed to reviewers.\n *\n * Split out of review-json.ts, which holds the SERVICE that reads and writes them. The split is purely by\n * kind (data vs behaviour): review-json.ts re-exports every name below, so `from './review-json'` and\n * `from '@webpieces/rules-config'` keep resolving exactly as before and no consumer changes.\n */\n\nimport { ReviewerAgentPolicy } from './checklist-config';\nimport { ChecklistOverride } from './checklist-override';\n\n// The colors a reviewer subagent may report in `review-round<N>-<id>.json`. Not a boolean, because the\n// boolean it replaced gave a reviewer no way to say \"this passes, but a human should look at X\" — the only\n// way to raise a concern was to FAIL the PR and then override your own failure, which reads on the\n// dashboard as a deliberately-accepted defect rather than as a note.\n//\n// RED and ORANGE are the two blocking colors, and WHICH one a reviewer may use is decided by the round\n// (issue #1053). `commands.pr-gate.maxReviewerRounds` is a hard ceiling: red means \"fix it and it will be\n// reviewed again\", which is only true while a round remains. On the FINAL round `wp-write-review` refuses\n// red and the reviewer marks the finding ORANGE instead — \"must fix, and nobody re-reviews it\". The author\n// fixes it best effort, records the fix with `wp-write-review-fixes`, and the PR ships with the finding and\n// its claimed fix stamped on the dashboard. Before the final round orange is refused the other way round.\nexport const VERDICT_GREEN = 'green';\nexport const VERDICT_YELLOW = 'yellow';\nexport const VERDICT_ORANGE = 'orange';\nexport const VERDICT_RED = 'red';\nexport const VERDICT_STATUSES = [VERDICT_GREEN, VERDICT_YELLOW, VERDICT_ORANGE, VERDICT_RED] as const;\n\n// The verdict a reviewer SUBAGENT submits into `.webpieces-logs/pr-review/<featureSlug>/review-round<N>-<id>.json`,\n// one per briefed checklist per round. One file per checklist per ROUND, so N concurrent reviewer subagents\n// never clobber a shared file and no round's verdict is ever overwritten by a later one (issue #1053): the\n// gate reads the HIGHEST round per checklist, and the earlier rounds stay on disk as the audit trail. It\n// records the OUTCOME:\n// status:'green' → PASS\n// status:'yellow' → WARN (passes; the concern is published on the PR, nothing is blocked)\n// status:'orange' + a recorded fix → ORANGE_FIXED (ships, stamped \"author-fixed, not re-reviewed\")\n// status:'orange' + no recorded fix → ORANGE (refuse until the author records a fix)\n// status:'red' + an override-<id>.json → OVERRIDDEN (pass; the human's stated reason reaches the PR)\n// status:'red' + no override file → FAIL (refuse; `output` is printed verbatim)\n//\n// THE `override` FIELD IS GONE FROM THIS FILE, and there is no compatibility mode. The ship-anyway\n// justification used to live here as free text, which made the ONE participant who hears the human — the\n// coordinating agent — the one participant that could not record it, because editing a reviewer's verdict\n// file is (correctly) refused by the harness. It now lives in its own `override-<id>.json`; see\n// ChecklistOverride. A verdict file still carrying an `override` key is reported through `problem` with the\n// destination named, exactly as the removed `success` field is. Data-only (per CLAUDE.md).\nexport class ChecklistResult {\n agent: string;\n model: string;\n id: string;\n status: string; // one of VERDICT_STATUSES; anything else is reported via `problem`\n output: string; // what the reviewer found; printed verbatim when the checklist fails\n // The HUMAN's authorization loaded from `override-<id>.json` beside this verdict, or null when there is\n // none. Loaded alongside the verdict so `resolveVerdict` needs no second read of disk and every command\n // resolves the same outcome from the same bytes.\n override: ChecklistOverride | null;\n // '' = a well-formed verdict. Non-empty = the file exists and parses but its verdict cannot be READ\n // (most often: it still uses the removed `success` field, or the moved `override` field). Carried as\n // data rather than thrown so the complaint can be reported by BOTH wp-review-upsert-pr and\n // wp-finish-upsert-pr in identical words, and so a legacy file is never silently mistaken for a missing one.\n problem: string;\n /**\n * Non-empty only for an ORANGE whose final-round fix the author recorded with `wp-write-review-fixes`:\n * the dashboard line \"orange at <fromHead>, author-fixed in <toHead>, not re-reviewed: <resolution>\".\n */\n remediation: string;\n /** The review round this verdict was submitted in — the N of `review-round<N>-<id>.json`. */\n round: number;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n agent: string,\n model: string,\n id: string,\n status: string,\n output: string,\n override: ChecklistOverride | null,\n problem = '',\n ) {\n this.agent = agent;\n this.model = model;\n this.id = id;\n this.status = status;\n this.output = output;\n this.override = override;\n this.problem = problem;\n this.remediation = '';\n this.round = 0;\n }\n}\n\n/**\n * What the pr-gate command computed from the diff: a checklist this branch MATCHED (its patterns hit the\n * diff, so its reviewer subagent is in scope). Drives review-round<N>-<id>.json enforcement, provenance, the schema\n * hint, and the dashboard. Data-only.\n *\n * NAME NOTE: \"Required\" here means MATCHED, not mandatory — it predates `required` by a long way and is\n * the shared shape across review-json, the detector, the briefing builder, provenance and the dashboard.\n * Whether the reviewer must actually run is the {@link RequiredChecklist.required} field below.\n */\nexport class RequiredChecklist {\n id: string; // the checklist's name; keys review-round<N>-<id>.json and its instructions file\n reviewer: ReviewerAgentPolicy; // the agent type to spawn (agentType the harness stamps) + the round cap\n doc: string; // REPO-RELATIVE guidance doc the reviewer reads ('' → it just reads the diff)\n matchedFiles: string[]; // the changed files that matched it (for the dashboard + hint)\n // Which of the checklist's OWN globs actually fired. Printed so a reviewer can judge how coarse the\n // match was — a precise `db/migrations/**` hit means something different from a blanket `**` — and the\n // template tells reviewers that matching IS deliberately coarse. [] = no patterns (matches every PR).\n matchedPatterns: string[];\n // Straight from the checklist's config `required`. true = blocking; false = the human is offered it and\n // may decline. Carried on the MATCH rather than looked up from config downstream so the set that gates\n // and the set that is reported cannot disagree about which of the two a checklist is.\n required: boolean;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n id: string,\n reviewer: ReviewerAgentPolicy,\n doc: string,\n matchedFiles: string[],\n matchedPatterns: string[] = [],\n // Defaulted to the BLOCKING value so any construction that forgets it fails closed — a test or a\n // future call site that silently produced an optional checklist would be a hole in the gate.\n required = true,\n ) {\n this.id = id;\n this.reviewer = reviewer;\n this.doc = doc;\n this.matchedFiles = matchedFiles;\n this.matchedPatterns = matchedPatterns;\n this.required = required;\n }\n}\n\n/**\n * The per-PR facts every reviewer subagent needs GIVEN to it, alongside its own checklist: the exact base\n * sha the gate diffs against and the file holding the complete changed-file set. Both used to live only in\n * a doc the printed instruction told the AI to go read, one indirection away from the instruction to hand\n * them over — so the printed block could not stand on its own. Data-only; empty = omit those lines.\n */\nexport class ChecklistReviewContext {\n baseSha: string; // the 3-point merge-base sha\n prContextPath: string; // path of pr-context.json — the AUTHORITATIVE full changed-file set\n /**\n * The exact command that reproduces ONE file's diff, with a `-- <file>` tail — NOT assembled by the\n * caller. This used to be hardcoded as `git diff <baseSha> HEAD -- <file>`, which returns NOTHING on a\n * dirty tree because the changed-file set is computed base→working-tree. See DiffBasis, which derives\n * this string from the same range the file set came from.\n */\n fileDiffCommand: string;\n diffDir: string; // dir of the MATERIALIZED diff (diff/ALL.diff + diff/files/…); '' when not written\n dirty: boolean; // true ⇒ the range includes uncommitted + untracked work, and must be said out loud\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n baseSha = '',\n prContextPath = '',\n fileDiffCommand = '',\n diffDir = '',\n dirty = false,\n ) {\n this.baseSha = baseSha;\n this.prContextPath = prContextPath;\n this.fileDiffCommand = fileDiffCommand;\n this.diffDir = diffDir;\n this.dirty = dirty;\n }\n}\n\n// The AI-authored PR summary (title, risk, summary). Normally the AI writes summary.json between\n// `wp-start-upsert-pr` (which prints the schema) and `wp-finish-upsert-pr` (which reads it), while reviewer\n// subagents write review-round<N>-<id>.json. The human-only `wp-human-post-pr` escape hatch also requires and reads\n// this same summary shape, but deliberately skips reviewer verdicts. Data-only (per CLAUDE.md).\nexport class PrSummary {\n agent: string;\n model: string;\n title: string; // human PR title describing the change; used as the `gh pr` title (empty → caller falls back)\n riskScore: number; // 0–100, drives the risk bar\n riskLevel: string; // 'green' | 'yellow' | 'red'\n riskEmoji: string; // '🟢' | '🟡' | '🔴' — derived from riskLevel when omitted\n summary: string; // rendered in the dashboard Summary section\n violations: string[]; // pattern/architecture violations; length = the Pattern Violations count\n risks: string[];\n filesToReview: string[];\n results: ChecklistResult[]; // resolved per-checklist verdicts (from review-round<N>-<id>.json); [] when none\n mainAgentInstructions: string; // non-empty only for the opt-in single-round experiment\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n agent: string,\n model: string,\n title: string,\n riskScore: number,\n riskLevel: string,\n riskEmoji: string,\n summary: string,\n violations: string[],\n risks: string[],\n filesToReview: string[],\n results: ChecklistResult[] = [],\n mainAgentInstructions = '',\n ) {\n this.agent = agent;\n this.model = model;\n this.title = title;\n this.riskScore = riskScore;\n this.riskLevel = riskLevel;\n this.riskEmoji = riskEmoji;\n this.summary = summary;\n this.violations = violations;\n this.risks = risks;\n this.filesToReview = filesToReview;\n this.results = results;\n this.mainAgentInstructions = mainAgentInstructions;\n }\n}\n\n// A checklist's resolved outcome, shared by summary.json enforcement and the dashboard so both agree.\n// PASS, WARN, ORANGE_FIXED and OVERRIDDEN all ship; ORANGE, FAIL, MISSING and BAD_FORMAT all refuse the PR.\nexport const CK_PASS = 'pass'; // latest verdict status:'green'\nexport const CK_WARN = 'warn'; // latest verdict status:'yellow' → 🟡 passes WITH concerns\nexport const CK_ORANGE_FIXED = 'orange-fixed'; // status:'orange' + a recorded author fix → 🟠 ships, NOT re-reviewed\nexport const CK_ORANGE = 'orange'; // status:'orange' + no recorded fix → refuse until one is recorded\nexport const CK_OVERRIDDEN = 'overridden'; // status:'red' + a human's override-<id>.json → 🟠\nexport const CK_FAIL = 'fail'; // latest verdict status:'red' + no override → refuse\nexport const CK_MISSING = 'missing'; // no verdict submitted → refuse\nexport const CK_BAD_FORMAT = 'bad-format'; // written, but its verdict is unreadable (e.g. legacy `success`)\n\nexport class ChecklistVerdict {\n id: string;\n status: string; // one of CK_PASS | CK_WARN | CK_ORANGE_FIXED | CK_ORANGE | CK_OVERRIDDEN | CK_FAIL | CK_MISSING | CK_BAD_FORMAT\n detail: string; // reviewer output / override justification / format complaint (dashboard + errors)\n\n constructor(id: string, status: string, detail: string) {\n this.id = id;\n this.status = status;\n this.detail = detail;\n }\n}\n\n// The PR's diff context, written by wp-start-upsert-pr into `.webpieces-logs/pr-review/<featureSlug>/pr-context.json`\n// so a reviewer subagent knows the exact 3-point base the gate used and the full changed-file set — then\n// reads any file's actual diff with `git diff <base> HEAD -- <file>`. This is what lets a checklist match\n// coarsely by path (in the config) while the subagent makes the fine, content-level judgment. Data-only.\nexport class PrContext {\n base: string; // the 3-point merge-base sha the gate diffs against\n /**\n * The real HEAD sha. This was once the literal string 'HEAD', which is not a fact — it cannot be\n * compared later to detect that the tree moved under a review, and it reads as a range that was never\n * actually diffed. Its only reader (reviewContextFor) takes `base`, so recording the sha is free.\n */\n head: string;\n changedFiles: string[]; // every file changed in the range (NOT tsOnly — includes .sql/.gql/Dockerfile/…)\n dirty: boolean; // true ⇒ changedFiles includes uncommitted + untracked work\n dirtyFiles: string[]; // exactly which paths are uncommitted/untracked — why `dirty` is true\n diffCommand: string; // the command that reproduces the WHOLE diff (see DiffBasis; correct when dirty)\n diffDir: string; // dir holding the materialized per-file diffs + ALL.diff; '' when not materialized\n generatedAt: string; // ISO timestamp, so a stale context is detectable rather than silently trusted\n /**\n * Main's head as this clone last saw it — the THIRD hash point, matching the trio the 3-point merge\n * records in `merge-info/<branch>/updatemain-hashes.json`. `base`/`head` above are points A and B\n * under the review side's older names.\n *\n * The review side used to record only A and B, so nothing could answer \"did main move while this was\n * under review?\" — the question you most want answered when a review looks stale. '' when origin/main\n * is unresolvable. Purely informational; nothing gates on it.\n */\n hashMainHead: string;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n base: string,\n head: string,\n changedFiles: string[],\n dirty = false,\n dirtyFiles: string[] = [],\n diffCommand = '',\n diffDir = '',\n generatedAt = '',\n hashMainHead = '',\n ) {\n this.hashMainHead = hashMainHead;\n this.base = base;\n this.head = head;\n this.changedFiles = changedFiles;\n this.dirty = dirty;\n this.dirtyFiles = dirtyFiles;\n this.diffCommand = diffCommand;\n this.diffDir = diffDir;\n this.generatedAt = generatedAt;\n }\n}\n"]}
@@ -63,7 +63,7 @@ let ReviewJsonService = class ReviewJsonService {
63
63
  this.dotDir = dotDir;
64
64
  this.overrides = overrides;
65
65
  }
66
- // The per-feature PR working dir: `<worktree>/.webpieces/pr-review/<feature>`. AI-WRITABLE scope,
66
+ // The per-feature PR working dir: `<worktree>/.webpieces-logs/pr-review/<feature>`. AI-WRITABLE scope,
67
67
  // not local() — an agent AUTHORS summary.json here, and each reviewer subagent authors its own
68
68
  // review-round<N>-<id>.json beside it. A worktree-isolated agent's Write is refused for any path under the
69
69
  // shared checkout, which is where local() puts this, so local() made both files unwritable by the