@webpieces/pr-gate 0.4.976 → 0.4.978

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 (29) hide show
  1. package/package.json +6 -6
  2. package/src/scripts/commands/cleanup-command.js +12 -12
  3. package/src/scripts/commands/cleanup-command.js.map +1 -1
  4. package/src/scripts/commands/human-post-pr-command.js +1 -1
  5. package/src/scripts/commands/human-post-pr-command.js.map +1 -1
  6. package/src/scripts/commands/land-pr-command.js +1 -1
  7. package/src/scripts/commands/land-pr-command.js.map +1 -1
  8. package/src/scripts/commands/reap-worktree-command.js +4 -5
  9. package/src/scripts/commands/reap-worktree-command.js.map +1 -1
  10. package/src/scripts/commands/review-upsert-pr-command.js +1 -1
  11. package/src/scripts/commands/review-upsert-pr-command.js.map +1 -1
  12. package/src/scripts/commands/start-upsert-pr-command.js +1 -1
  13. package/src/scripts/commands/start-upsert-pr-command.js.map +1 -1
  14. package/src/scripts/commands/sync-main-command.js +4 -4
  15. package/src/scripts/commands/sync-main-command.js.map +1 -1
  16. package/src/scripts/commands/worktree-cleanup.d.ts +4 -4
  17. package/src/scripts/commands/worktree-cleanup.js +4 -4
  18. package/src/scripts/commands/worktree-cleanup.js.map +1 -1
  19. package/src/scripts/workflow/checklist-detector.d.ts +2 -2
  20. package/src/scripts/workflow/checklist-detector.js +4 -4
  21. package/src/scripts/workflow/checklist-detector.js.map +1 -1
  22. package/src/scripts/workflow/checklist-scanner.js +3 -3
  23. package/src/scripts/workflow/checklist-scanner.js.map +1 -1
  24. package/src/scripts/workflow/merge-end.d.ts +3 -2
  25. package/src/scripts/workflow/merge-end.js +6 -3
  26. package/src/scripts/workflow/merge-end.js.map +1 -1
  27. package/src/scripts/workflow/pr-context-writer.d.ts +1 -1
  28. package/src/scripts/workflow/pr-context-writer.js +3 -3
  29. package/src/scripts/workflow/pr-context-writer.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"sync-main-command.js","sourceRoot":"","s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AI,QAAQ,KAAK,EAAE;YAAE,OAAO;QAC5B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,QAAQ,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACK,KAAK,CAAC,QAAgB;QAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;QACjE,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QACjC,IAAI,QAAQ,KAAK,EAAE;YAAE,OAAO;QAC5B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,QAAQ,EAAE,CAAC,CAAC;IAC1C,CAAC;CACJ,CAAA;AA1FY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGA,6BAAc;QACd,gCAAc;QACZ,+BAAgB;QACjB,mCAAe;QAClB,4BAAY;GANtC,eAAe,CA0F3B","sourcesContent":["import { injectable, bindingScopeValues } from 'inversify';\nimport { OrphanDirSweeper, RepoRootFinder } from '@webpieces/rules-config';\nimport { dotWebpieces } from '@webpieces/tooling-common';\n\nimport { CleanupCommand } from './cleanup-command';\nimport {\n CleanupOptions,\n DeleteSelection,\n FLAG_DELETE_BRANCHES,\n FLAG_DELETE_WORKTREES,\n} from './cleanup-options';\nimport { MainCheckout, StashedFiles } from './main-checkout';\nimport { WorkingTreeGate, UntrackedFiles } from './working-tree-gate';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * `wp-sync-main` — go to main, get main, and take out the trash. ONE command, because the three\n * are one intention and splitting them is what let the third never happen.\n *\n * ─── ITS RELATIONSHIP TO `git checkout main && git pull origin main` (READ BEFORE \"DELETING\" THAT) ────\n * That pair was already the enforced spelling: bare `git checkout main` is blocked precisely so the pull\n * rides along. This command is the same pairing with cleanup and the sweep welded on, and the WORKFLOW\n * messages now prescribe this instead — two spellings where one sweeps and one does not is shim shape\n * #1, an agent types whichever is accepted and the corpses accumulate forever.\n *\n * The raw pair is NOT deleted, and the reason is a constraint that outranks the shim rule: it is a\n * TERMINAL ENTRY ON THE L0 ALLOWLIST (`CHECKOUT_MAIN_PULL_CMD` in ai-hook-rules\n * `src/bin/l0-allowlist.ts`, consumed as an L0 cure in `src/core/l0-matrix.ts`) — one of\n * the few commands still permitted while an L0 block denies every other tool call. In exactly that\n * state, `node_modules` is the thing that is untrustworthy, so a `pnpm wp-*` bin is the one kind of cure\n * that cannot be relied on to run. The same reasoning covers the L0 shim's own fix option in\n * `templates/ai-hook.sh` (rendered from `src/bin/shim-drift-fix.ts`).\n *\n * So the end state is TWO LAYERS, not a deletion, and it is now in place:\n * • L0 recovery (l0-allowlist, shim-drift-fix, l0-matrix) → keeps the raw pair. It is not a shim\n * there; it is the only thing that works when the package manager's output is what is in doubt.\n * • the WORKFLOW layer (stale-main-bash-guard's preferred cure, merged-branch-message/-bash-guard,\n * TreeRecovery's cleanupSteps and updateMainSteps, the L2 rows/doc, CLAUDE.md's \"Finishing a\n * Feature\") → prescribes `pnpm wp-sync-main`, and no longer prints the pair.\n *\n * The pair remains ALLOWED as a Bash command in both layers — this changed what the guards TEACH, not\n * what they permit. Blocking it would have deleted the L0 escape along with the shim.\n *\n * ─── WHY GOING TO MAIN IS THE RIGHT MOMENT TO SWEEP ───────────────────────────────────────────────────\n * The corpses appear when git moves the working tree onto a base where the tracked files under some\n * directory are gone. Landing a PR and returning to main is when every developer does that, on every\n * clone, roughly once per merged PR — so a sweep bolted here converges the whole team's machines with no\n * new trigger, no git hook to distribute, and no background daemon. It is also the quietest moment in the\n * day to move directories: nothing is building, no dev server is watching files.\n *\n * ─── WHY THE ORDER IS FIXED AND NOT PARALLEL ──────────────────────────────────────────────────────────\n * Cleanup runs BEFORE the sweep and not beside it. `wp-cleanup` removes dead worktrees, which changes\n * what is on disk, and a scan racing that would be reading a tree mid-demolition. The scan is one\n * ignore-walk and costs about a second; there is no wall-clock worth buying with that race.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class SyncMainCommand {\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly cleanupCommand: CleanupCommand,\n private readonly orphanDirSweeper: OrphanDirSweeper,\n private readonly workingTreeGate: WorkingTreeGate,\n private readonly mainCheckout: MainCheckout,\n ) {}\n\n async run(): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());\n process.stdout.write(`${SEP}🧹 Checkout main, pull, clean\\n${SEP}\\n`);\n if (this.isLinkedWorktree(repoRoot)) {\n await this.sweepOnly(repoRoot);\n return;\n }\n const untracked = await this.workingTreeGate.assertNoTrackedChanges(repoRoot);\n const stashed = await this.mainCheckout.goToMain(repoRoot, untracked);\n this.reportUntracked(untracked, stashed);\n // No flags: this is the \"go to main and take out the trash\" path, so cleanup behaves exactly as a\n // bare `pnpm wp-cleanup` does here — reap what is provably dead and every zero-commit husk, ask\n // (or report) about the rest. Spelled out rather than defaulted so that if CleanupOptions ever\n // grows a field, this call site is a compile error instead of a silent old behaviour.\n await this.cleanupCommand.run(new CleanupOptions(\n new DeleteSelection(FLAG_DELETE_BRANCHES, false, ''),\n new DeleteSelection(FLAG_DELETE_WORKTREES, false, ''),\n false, false, false));\n this.sweep(repoRoot);\n this.reportStashed(stashed);\n }\n\n /**\n * A linked worktree has no main to check out — `git checkout main` FATALS there with \"main is already\n * checked out at <primary clone>\", which is a footgun `.claude/rules/finishing-a-feature.md`\n * currently has to warn about in prose.\n * So the command does the half that IS meaningful here (worktrees accumulate corpses too, if a\n * long-lived one keeps merging main in) and says plainly where the other half lives.\n */\n private async sweepOnly(repoRoot: string): Promise<void> {\n process.stdout.write(\n 'This is a linked WORKTREE. main is checked out in the primary clone, so there is nothing\\n'\n + 'here to check out or pull — sweeping this tree only.\\n\\n'\n + 'Most worktrees never need this: `wp-cleanup` removes the whole directory once its branch\\n'\n + 'lands, which takes any orphan directories inside it along. Run this command again from the\\n'\n + 'primary clone to go to main there.\\n\\n');\n this.sweep(repoRoot);\n return Promise.resolve();\n }\n\n private isLinkedWorktree(repoRoot: string): boolean {\n const dirs = dotWebpieces.gitDirs(repoRoot);\n return dirs !== null && dirs.isLinkedWorktree;\n }\n\n /**\n * Say which untracked files were let through, AFTER the move — so nobody has to wonder whether the\n * files still sitting in their tree came along for the ride. Printed rather than refused on: see\n * `WorkingTreeGate` for why an untracked file is not the hazard a tracked one is.\n *\n * Silent when the checkout had to stash: those files are NOT sitting in the tree any more, and\n * \"nothing about them changed\" would be a lie. `reportStashed` speaks for that case instead.\n */\n private reportUntracked(untracked: UntrackedFiles, stashed: StashedFiles): void {\n if (!stashed.isEmpty()) return;\n const rendered = untracked.render();\n if (rendered === '') return;\n process.stdout.write(`\\n${rendered}`);\n }\n\n /**\n * The stash banner goes LAST, on purpose. It is the one thing in this command's output a reader\n * must not miss — their files left the working tree — and the cleanup and sweep that follow the\n * checkout print enough to scroll it away if it were emitted where it happened.\n */\n private reportStashed(stashed: StashedFiles): void {\n const rendered = stashed.render();\n if (rendered === '') return;\n process.stdout.write(`\\n${rendered}`);\n }\n\n /**\n * Sweep, then print. Never throws: the checkout and pull above already succeeded, and a tidier is not\n * permitted to turn somebody's completed sync into a failed command.\n */\n private sweep(repoRoot: string): void {\n const report = this.orphanDirSweeper.sweep(repoRoot, new Date());\n const rendered = report.render();\n if (rendered === '') return;\n process.stdout.write(`\\n${rendered}`);\n }\n}\n"]}
1
+ {"version":3,"file":"sync-main-command.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/sync-main-command.ts"],"names":[],"mappings":";;;;AAAA,yCAA2D;AAC3D,0DAA2E;AAC3E,8DAAyD;AAEzD,uDAAmD;AACnD,uDAK2B;AAC3B,mDAA6D;AAC7D,2DAAsE;AAEtE,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;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AAK,CAAC,QAAQ,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;QACvE,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;QACjC,IAAI,QAAQ,KAAK,EAAE;YAAE,OAAO;QAC5B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,QAAQ,EAAE,CAAC,CAAC;IAC1C,CAAC;CACJ,CAAA;AA1FY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGA,6BAAc;QACd,gCAAc;QACZ,+BAAgB;QACjB,mCAAe;QAClB,4BAAY;GANtC,eAAe,CA0F3B","sourcesContent":["import { injectable, bindingScopeValues } from 'inversify';\nimport { OrphanDirSweeper, RepoRootFinder } from '@webpieces/rules-config';\nimport { dotWebpieces } from '@webpieces/tooling-common';\n\nimport { CleanupCommand } from './cleanup-command';\nimport {\n CleanupOptions,\n DeleteSelection,\n FLAG_DELETE_BRANCHES,\n FLAG_DELETE_WORKTREES,\n} from './cleanup-options';\nimport { MainCheckout, StashedFiles } from './main-checkout';\nimport { WorkingTreeGate, UntrackedFiles } from './working-tree-gate';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * `wp-sync-main` — go to main, get main, and take out the trash. ONE command, because the three\n * are one intention and splitting them is what let the third never happen.\n *\n * ─── ITS RELATIONSHIP TO `git checkout main && git pull origin main` (READ BEFORE \"DELETING\" THAT) ────\n * That pair was already the enforced spelling: bare `git checkout main` is blocked precisely so the pull\n * rides along. This command is the same pairing with cleanup and the sweep welded on, and the WORKFLOW\n * messages now prescribe this instead — two spellings where one sweeps and one does not is shim shape\n * #1, an agent types whichever is accepted and the corpses accumulate forever.\n *\n * The raw pair is NOT deleted, and the reason is a constraint that outranks the shim rule: it is a\n * TERMINAL ENTRY ON THE L0 ALLOWLIST (`CHECKOUT_MAIN_PULL_CMD` in ai-hook-rules\n * `src/bin/l0-allowlist.ts`, consumed as an L0 cure in `src/core/l0-matrix.ts`) — one of\n * the few commands still permitted while an L0 block denies every other tool call. In exactly that\n * state, `node_modules` is the thing that is untrustworthy, so a `pnpm wp-*` bin is the one kind of cure\n * that cannot be relied on to run. The same reasoning covers the L0 shim's own fix option in\n * `templates/ai-hook.sh` (rendered from `src/bin/shim-drift-fix.ts`).\n *\n * So the end state is TWO LAYERS, not a deletion, and it is now in place:\n * • L0 recovery (l0-allowlist, shim-drift-fix, l0-matrix) → keeps the raw pair. It is not a shim\n * there; it is the only thing that works when the package manager's output is what is in doubt.\n * • the WORKFLOW layer (stale-main-bash-guard's preferred cure, merged-branch-message/-bash-guard,\n * TreeRecovery's cleanupSteps and updateMainSteps, the L2 rows/doc, CLAUDE.md's \"Finishing a\n * Feature\") → prescribes `pnpm wp-sync-main`, and no longer prints the pair.\n *\n * The pair remains ALLOWED as a Bash command in both layers — this changed what the guards TEACH, not\n * what they permit. Blocking it would have deleted the L0 escape along with the shim.\n *\n * ─── WHY GOING TO MAIN IS THE RIGHT MOMENT TO SWEEP ───────────────────────────────────────────────────\n * The corpses appear when git moves the working tree onto a base where the tracked files under some\n * directory are gone. Landing a PR and returning to main is when every developer does that, on every\n * clone, roughly once per merged PR — so a sweep bolted here converges the whole team's machines with no\n * new trigger, no git hook to distribute, and no background daemon. It is also the quietest moment in the\n * day to move directories: nothing is building, no dev server is watching files.\n *\n * ─── WHY THE ORDER IS FIXED AND NOT PARALLEL ──────────────────────────────────────────────────────────\n * Cleanup runs BEFORE the sweep and not beside it. `wp-cleanup` removes dead worktrees, which changes\n * what is on disk, and a scan racing that would be reading a tree mid-demolition. The scan is one\n * ignore-walk and costs about a second; there is no wall-clock worth buying with that race.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class SyncMainCommand {\n constructor(\n private readonly repoRootFinder: RepoRootFinder,\n private readonly cleanupCommand: CleanupCommand,\n private readonly orphanDirSweeper: OrphanDirSweeper,\n private readonly workingTreeGate: WorkingTreeGate,\n private readonly mainCheckout: MainCheckout,\n ) {}\n\n async run(): Promise<void> {\n const repoRoot = this.repoRootFinder.resolveRepoRoot(process.cwd());\n process.stdout.write(`${SEP}🧹 Checkout main, pull, clean\\n${SEP}\\n`);\n if (this.isLinkedWorktree(repoRoot)) {\n await this.sweepOnly(repoRoot);\n return;\n }\n const untracked = await this.workingTreeGate.assertNoTrackedChanges(repoRoot);\n const stashed = await this.mainCheckout.goToMain(repoRoot, untracked);\n this.reportUntracked(untracked, stashed);\n // No flags: this is the \"go to main and take out the trash\" path, so cleanup behaves exactly as a\n // bare `pnpm wp-cleanup` does here — reap what is provably dead and every zero-commit husk, ask\n // (or report) about the rest. Spelled out rather than defaulted so that if CleanupOptions ever\n // grows a field, this call site is a compile error instead of a silent old behaviour.\n await this.cleanupCommand.run(new CleanupOptions(\n new DeleteSelection(FLAG_DELETE_BRANCHES, false, ''),\n new DeleteSelection(FLAG_DELETE_WORKTREES, false, ''),\n false, false, false));\n await this.sweep(repoRoot);\n this.reportStashed(stashed);\n }\n\n /**\n * A linked worktree has no main to check out — `git checkout main` FATALS there with \"main is already\n * checked out at <primary clone>\", which is a footgun `.claude/rules/finishing-a-feature.md`\n * currently has to warn about in prose.\n * So the command does the half that IS meaningful here (worktrees accumulate corpses too, if a\n * long-lived one keeps merging main in) and says plainly where the other half lives.\n */\n private async sweepOnly(repoRoot: string): Promise<void> {\n process.stdout.write(\n 'This is a linked WORKTREE. main is checked out in the primary clone, so there is nothing\\n'\n + 'here to check out or pull — sweeping this tree only.\\n\\n'\n + 'Most worktrees never need this: `wp-cleanup` removes the whole directory once its branch\\n'\n + 'lands, which takes any orphan directories inside it along. Run this command again from the\\n'\n + 'primary clone to go to main there.\\n\\n');\n await this.sweep(repoRoot);\n return Promise.resolve();\n }\n\n private isLinkedWorktree(repoRoot: string): boolean {\n const dirs = dotWebpieces.gitDirs(repoRoot);\n return dirs !== null && dirs.isLinkedWorktree;\n }\n\n /**\n * Say which untracked files were let through, AFTER the move — so nobody has to wonder whether the\n * files still sitting in their tree came along for the ride. Printed rather than refused on: see\n * `WorkingTreeGate` for why an untracked file is not the hazard a tracked one is.\n *\n * Silent when the checkout had to stash: those files are NOT sitting in the tree any more, and\n * \"nothing about them changed\" would be a lie. `reportStashed` speaks for that case instead.\n */\n private reportUntracked(untracked: UntrackedFiles, stashed: StashedFiles): void {\n if (!stashed.isEmpty()) return;\n const rendered = untracked.render();\n if (rendered === '') return;\n process.stdout.write(`\\n${rendered}`);\n }\n\n /**\n * The stash banner goes LAST, on purpose. It is the one thing in this command's output a reader\n * must not miss — their files left the working tree — and the cleanup and sweep that follow the\n * checkout print enough to scroll it away if it were emitted where it happened.\n */\n private reportStashed(stashed: StashedFiles): void {\n const rendered = stashed.render();\n if (rendered === '') return;\n process.stdout.write(`\\n${rendered}`);\n }\n\n /**\n * Sweep, then print. Never throws: the checkout and pull above already succeeded, and a tidier is not\n * permitted to turn somebody's completed sync into a failed command.\n */\n private async sweep(repoRoot: string): Promise<void> {\n const report = await this.orphanDirSweeper.sweep(repoRoot, new Date());\n const rendered = report.render();\n if (rendered === '') return;\n process.stdout.write(`\\n${rendered}`);\n }\n}\n"]}
@@ -25,7 +25,7 @@ export declare class WorktreeCleanupSection {
25
25
  * deliberately allowed to go stale, which is fine for BLOCKING a `git worktree add` and never fine
26
26
  * for removing a directory, since the tree may have gained uncommitted work since it was written.
27
27
  */
28
- verdicts(repoRoot: string, ignoreStaleLocks: boolean): DeletableWorktree[];
28
+ verdicts(repoRoot: string, ignoreStaleLocks: boolean): Promise<DeletableWorktree[]>;
29
29
  provablyDead(verdicts: DeletableWorktree[]): DeletableWorktree[];
30
30
  /**
31
31
  * The spared worktrees a human can meaningfully rule on, grouped most-safe first — the same
@@ -51,9 +51,9 @@ export declare class WorktreeCleanupSection {
51
51
  * backstop there — but a backstop that reports a FAILURE is not good enough for a delete nobody
52
52
  * was asked about, which is why the husk path states the spare instead of tripping over it.
53
53
  */
54
- withoutUncommitted(husks: DeletableWorktree[]): DeletableWorktree[];
55
- protected workInFlight(worktreePath: string): WorktreeWorkInFlight;
56
- reap(repoRoot: string, verb: MutationVerb, targets: DeletableWorktree[], retention: string): WorktreeReapResult;
54
+ withoutUncommitted(husks: DeletableWorktree[]): Promise<DeletableWorktree[]>;
55
+ protected workInFlight(worktreePath: string): Promise<WorktreeWorkInFlight>;
56
+ reap(repoRoot: string, verb: MutationVerb, targets: DeletableWorktree[], retention: string): Promise<WorktreeReapResult>;
57
57
  report(repoRoot: string, result: WorktreeReapResult): string;
58
58
  private reapedLine;
59
59
  /**
@@ -40,8 +40,8 @@ let WorktreeCleanupSection = class WorktreeCleanupSection {
40
40
  * deliberately allowed to go stale, which is fine for BLOCKING a `git worktree add` and never fine
41
41
  * for removing a directory, since the tree may have gained uncommitted work since it was written.
42
42
  */
43
- verdicts(repoRoot, ignoreStaleLocks) {
44
- return this.mergedBranches.computeMergedBranches(repoRoot, ignoreStaleLocks).worktrees;
43
+ async verdicts(repoRoot, ignoreStaleLocks) {
44
+ return (await this.mergedBranches.computeMergedBranches(repoRoot, ignoreStaleLocks)).worktrees;
45
45
  }
46
46
  provablyDead(verdicts) {
47
47
  return verdicts.filter((tree) => tree.deletable);
@@ -79,11 +79,11 @@ let WorktreeCleanupSection = class WorktreeCleanupSection {
79
79
  * backstop there — but a backstop that reports a FAILURE is not good enough for a delete nobody
80
80
  * was asked about, which is why the husk path states the spare instead of tripping over it.
81
81
  */
82
- withoutUncommitted(husks) {
82
+ async withoutUncommitted(husks) {
83
83
  const clean = [];
84
84
  let spared = '';
85
85
  for (const tree of husks) {
86
- const held = this.workInFlight(tree.path);
86
+ const held = await this.workInFlight(tree.path);
87
87
  if (held.held) {
88
88
  // The REASON is printed verbatim, because "it has uncommitted files" and "git would
89
89
  // not tell me" send an operator to two different places.
@@ -1 +1 @@
1
- {"version":3,"file":"worktree-cleanup.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/worktree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;cAC1F,6FAA6F;cAC7F,8FAA8F;cAC9F,oFAAoF,CAAC;QAC3F,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5C,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YAC3B,GAAG,IAAI,MAAM,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,cAAc,IAAI,CAAC,MAAM,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC;QAC5F,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAA;AA1KY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGA,0CAAqB;QAC7B,mCAAc;QACL,oCAAe;QAGnB,sCAAiB;GAP1C,sBAAsB,CA0KlC","sourcesContent":["import { BranchMutationLog, MutationVerb, DeletableWorktree, MergedBranchesService, ReapedWorktree, WorktreeReapResult, WorktreeReaper, WorktreeService, WorktreeWorkInFlight, CLASSIFICATION_LOCKED, CLASSIFICATION_CURRENT, CLASSIFICATION_DETACHED, CLASSIFICATION_PRUNABLE, ADJUDICATED_CLASSIFICATIONS, LOCK_LIVENESS_UNVERIFIABLE } from '@webpieces/repo-workflow-core';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { FLAG_IGNORE_STALE_LOCKS } from './cleanup-options';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * The WORKTREE half of `wp-cleanup` — the verdicts, the reap and the human-facing text.\n *\n * Split out of CleanupCommand rather than bolted onto it because the two halves answer different\n * questions: a branch is a ref, a worktree is a DIRECTORY OF FILES, and the second one needs its own\n * report (paths, not just names), its own restore command (`git worktree add`, not `git checkout -b`)\n * and its own spared vocabulary (locked, detached, \"you are standing in it\"). Keeping them in one class\n * meant every string had to hedge about which kind of thing it was talking about.\n *\n * WHY worktrees are reaped BEFORE branches in wp-cleanup: a worktree HOLDS its branch, so that branch\n * is spared as `in-use` with \"remove that worktree before deleting the branch\". Reaping the worktree\n * first is what makes the branch reapable — the reap takes the branch with it, and the branch pass that\n * follows recomputes its verdicts against the post-removal truth. Run the other way round, every\n * worktree-held branch survives forever, which is exactly the deadlock this change exists to break.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WorktreeCleanupSection {\n constructor(\n private readonly mergedBranches: MergedBranchesService,\n private readonly reaper: WorktreeReaper,\n private readonly worktreeService: WorktreeService,\n // COMPUTED, not restated: the branch-mutation log is per-worktree, so the relative literal this\n // message used to carry named a file that does not exist in a linked worktree.\n private readonly mutationLog: BranchMutationLog,\n ) {}\n\n /**\n * FRESH verdicts — never the cache on disk. Same rule the branch half follows: the cached file is\n * deliberately allowed to go stale, which is fine for BLOCKING a `git worktree add` and never fine\n * for removing a directory, since the tree may have gained uncommitted work since it was written.\n */\n verdicts(repoRoot: string, ignoreStaleLocks: boolean): DeletableWorktree[] {\n return this.mergedBranches.computeMergedBranches(repoRoot, ignoreStaleLocks).worktrees;\n }\n\n provablyDead(verdicts: DeletableWorktree[]): DeletableWorktree[] {\n return verdicts.filter((tree: DeletableWorktree): boolean => tree.deletable);\n }\n\n /**\n * The spared worktrees a human can meaningfully rule on, grouped most-safe first — the same\n * classification order the branch prompt uses, because it is literally the same verdict on the\n * branch the worktree holds.\n *\n * Deliberately excluded: LOCKED (a lock is standing and we cannot say whose), CURRENT (removing your own cwd\n * is not a thing to offer), DETACHED (no branch, so nothing to archive and nothing to judge) and\n * PRUNABLE (already provably dead — it is in the auto-reap list, not this one).\n */\n promptable(verdicts: DeletableWorktree[]): DeletableWorktree[] {\n const out: DeletableWorktree[] = [];\n for (const classification of ADJUDICATED_CLASSIFICATIONS) {\n for (const tree of verdicts) {\n if (!tree.deletable && tree.classification === classification) out.push(tree);\n }\n }\n return out;\n }\n\n /**\n * The zero-commit worktrees that are genuinely husks — the ones holding no uncommitted or\n * untracked work — with a printed line for each one that is spared.\n *\n * THIS IS THE ONE CHECK THAT MAKES REAPING A ZERO-COMMIT WORKTREE SAFE. A branch with no commits\n * of its own can lose nothing; a DIRECTORY with no commits can lose everything an agent has typed\n * in the last twenty minutes, and the two are indistinguishable by ref alone. `git status\n * --porcelain` is the difference, it is one local spawn, and it fails safe to \"dirty\".\n *\n * It is applied ONLY to the husks. Anything with unique commits is decided by flag or prompt, and\n * git's own refusal to remove a dirty worktree (WorktreeReaper never passes `--force`) is the\n * backstop there — but a backstop that reports a FAILURE is not good enough for a delete nobody\n * was asked about, which is why the husk path states the spare instead of tripping over it.\n */\n withoutUncommitted(husks: DeletableWorktree[]): DeletableWorktree[] {\n const clean: DeletableWorktree[] = [];\n let spared = '';\n for (const tree of husks) {\n const held = this.workInFlight(tree.path);\n if (held.held) {\n // The REASON is printed verbatim, because \"it has uncommitted files\" and \"git would\n // not tell me\" send an operator to two different places.\n spared += ` · ${tree.path} [${tree.branch}] — ${held.reason};\\n`\n + ' nothing archives that, so it is left exactly where it is\\n';\n continue;\n }\n clean.push(tree);\n }\n if (spared !== '') {\n process.stdout.write('\\nZero-commit worktrees SPARED because work may be in flight in them:\\n' + spared);\n }\n return clean;\n }\n\n // Seam: one git spawn per candidate, overridden in the spec so the decision is testable with no\n // real worktrees on disk.\n protected workInFlight(worktreePath: string): WorktreeWorkInFlight {\n return this.worktreeService.workInFlight(worktreePath);\n }\n\n reap(\n repoRoot: string,\n verb: MutationVerb,\n targets: DeletableWorktree[],\n retention: string,\n ): WorktreeReapResult {\n return this.reaper.reapWorktrees(repoRoot, process.cwd(), verb, targets, retention);\n }\n\n report(repoRoot: string, result: WorktreeReapResult): string {\n if (result.reaped.length === 0 && result.failed.length === 0) return '';\n\n let out = '\\n' + SEP + `🌲 Removed ${String(result.reaped.length)} dead worktree(s)\\n` + SEP + '\\n';\n for (const entry of result.reaped) out += this.reapedLine(entry);\n\n if (result.failed.length > 0) {\n out += `\\n⚠️ ${String(result.failed.length)} worktree(s) could not be removed:\\n`;\n for (const entry of result.failed) out += ` ✗ ${entry.path} — ${entry.error}\\n`;\n }\n // Printed on success too: removing a worktree deletes real files, and a human who cannot see\n // how to undo that has to take it on trust — which is precisely what nobody should have to do.\n out += `\\nEvery removal is logged (phase REAP_WORKTREE) in\\n${this.mutationLog.branchMutationLogPath(repoRoot)}\\n`\n + 'with the `recover=` command that brings back both the directory and its branch.\\n';\n return out;\n }\n\n private reapedLine(entry: ReapedWorktree): string {\n const branch = entry.branch !== '' ? ` [${entry.branch}]` : ' [detached]';\n // The restore command is printed inline for the same reason the branch half prints the archive\n // tag: it is the one thing that makes this reversible without going and digging in a log.\n const restore = `\\n restore: ${this.reaper.restoreCommand(entry)}`;\n // A directory that went while its branch survived is a real half-state and must not read as done.\n const partial = entry.branch !== '' && !entry.branchDeleted\n ? `\\n ⚠️ the branch '${entry.branch}' was NOT deleted — git refused it`\n : '';\n return ` ✓ ${entry.path}${branch} — ${entry.reason}${restore}${partial}\\n`;\n }\n\n /**\n * The spared worktrees, with WHY — including the ones nobody will ever be asked about.\n *\n * When any of them is a claude-agent lock whose agent could not be verified either way, the block\n * ends with the flag that judges it on its branch instead. That hint lives HERE and not in the\n * verdict's own reason for one reason: the flag is wp-cleanup's, its spelling is one constant in\n * this package, and a rules-config message naming it would be a second copy of that spelling free\n * to drift. The reason says what is KNOWN; this says what you can DO about it.\n */\n sparedBlock(verdicts: DeletableWorktree[], removed: DeletableWorktree[]): string {\n const gone = new Set(removed.map((tree: DeletableWorktree): string => tree.path));\n const spared = verdicts.filter(\n (tree: DeletableWorktree): boolean => !tree.deletable && !gone.has(tree.path)\n && this.isMechanical(tree.classification));\n if (spared.length === 0) return '';\n let out = '\\nWorktrees deliberately left alone:\\n';\n let unverified = 0;\n for (const tree of spared) {\n out += ` · ${tree.path} — ${tree.reason}\\n`;\n if (tree.reason.includes(LOCK_LIVENESS_UNVERIFIABLE)) unverified += 1;\n }\n if (unverified > 0) {\n out += `\\n${String(unverified)} of those carry a claude-agent lock whose liveness cannot be `\n + 'verified.\\nTo judge those on their branch and commits alone — unlocking and removing only\\n'\n + `the ones that come back dead — re-run:\\n pnpm wp-cleanup ${FLAG_IGNORE_STALE_LOCKS}\\n`;\n }\n return out;\n }\n\n private isMechanical(classification: string): boolean {\n return classification === CLASSIFICATION_LOCKED\n || classification === CLASSIFICATION_CURRENT\n || classification === CLASSIFICATION_DETACHED\n || classification === CLASSIFICATION_PRUNABLE;\n }\n\n // The table a human answers: path, branch, and the same reason the branch prompt would show, since\n // the verdict IS the branch's verdict.\n promptBlock(promptable: DeletableWorktree[]): string {\n let out = '\\n' + SEP\n + `🤔 ${String(promptable.length)} worktree(s) are probably dead — your call\\n` + SEP + '\\n'\n + 'Removing one deletes its DIRECTORY and its branch. The branch is archived as a tag first,\\n'\n + 'so both come back with one `git worktree add -b …` — but uncommitted or untracked files in\\n'\n + 'that directory are NOT archived, and git will refuse the removal if any exist.\\n\\n';\n for (let i = 0; i < promptable.length; i += 1) {\n const tree = promptable[i];\n out += ` [${String(i + 1)}] ${tree.path}\\n [${tree.branch}] — ${tree.reason}\\n`;\n }\n return out;\n }\n}\n"]}
1
+ {"version":3,"file":"worktree-cleanup.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/commands/worktree-cleanup.ts"],"names":[],"mappings":";;;;AAAA,sEAA+W;AAC/W,yCAA2D;AAE3D,uDAA4D;AAE5D,MAAM,GAAG,GAAG,0DAA0D,CAAC;AAEvE;;;;;;;;;;;;;;GAcG;AAEI,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAEV;IACA;IACA;IAGA;IANrB,YACqB,cAAqC,EACrC,MAAsB,EACtB,eAAgC;IACjD,gGAAgG;IAChG,+EAA+E;IAC9D,WAA8B;QAL9B,mBAAc,GAAd,cAAc,CAAuB;QACrC,WAAM,GAAN,MAAM,CAAgB;QACtB,oBAAe,GAAf,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,IAAI,CAAC,MAAM,IAAI,CAAC;QAC5F,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;CACJ,CAAA;AA1KY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGA,0CAAqB;QAC7B,mCAAc;QACL,oCAAe;QAGnB,sCAAiB;GAP1C,sBAAsB,CA0KlC","sourcesContent":["import { BranchMutationLog, MutationVerb, DeletableWorktree, MergedBranchesService, ReapedWorktree, WorktreeReapResult, WorktreeReaper, WorktreeService, WorktreeWorkInFlight, CLASSIFICATION_LOCKED, CLASSIFICATION_CURRENT, CLASSIFICATION_DETACHED, CLASSIFICATION_PRUNABLE, ADJUDICATED_CLASSIFICATIONS, LOCK_LIVENESS_UNVERIFIABLE } from '@webpieces/repo-workflow-core';\nimport { injectable, bindingScopeValues } from 'inversify';\n\nimport { FLAG_IGNORE_STALE_LOCKS } from './cleanup-options';\n\nconst SEP = '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\\n';\n\n/**\n * The WORKTREE half of `wp-cleanup` — the verdicts, the reap and the human-facing text.\n *\n * Split out of CleanupCommand rather than bolted onto it because the two halves answer different\n * questions: a branch is a ref, a worktree is a DIRECTORY OF FILES, and the second one needs its own\n * report (paths, not just names), its own restore command (`git worktree add`, not `git checkout -b`)\n * and its own spared vocabulary (locked, detached, \"you are standing in it\"). Keeping them in one class\n * meant every string had to hedge about which kind of thing it was talking about.\n *\n * WHY worktrees are reaped BEFORE branches in wp-cleanup: a worktree HOLDS its branch, so that branch\n * is spared as `in-use` with \"remove that worktree before deleting the branch\". Reaping the worktree\n * first is what makes the branch reapable — the reap takes the branch with it, and the branch pass that\n * follows recomputes its verdicts against the post-removal truth. Run the other way round, every\n * worktree-held branch survives forever, which is exactly the deadlock this change exists to break.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class WorktreeCleanupSection {\n constructor(\n private readonly mergedBranches: MergedBranchesService,\n private readonly reaper: WorktreeReaper,\n private readonly worktreeService: WorktreeService,\n // COMPUTED, not restated: the branch-mutation log is per-worktree, so the relative literal this\n // message used to carry named a file that does not exist in a linked worktree.\n private readonly mutationLog: BranchMutationLog,\n ) {}\n\n /**\n * FRESH verdicts — never the cache on disk. Same rule the branch half follows: the cached file is\n * deliberately allowed to go stale, which is fine for BLOCKING a `git worktree add` and never fine\n * for removing a directory, since the tree may have gained uncommitted work since it was written.\n */\n async verdicts(repoRoot: string, ignoreStaleLocks: boolean): Promise<DeletableWorktree[]> {\n return (await this.mergedBranches.computeMergedBranches(repoRoot, ignoreStaleLocks)).worktrees;\n }\n\n provablyDead(verdicts: DeletableWorktree[]): DeletableWorktree[] {\n return verdicts.filter((tree: DeletableWorktree): boolean => tree.deletable);\n }\n\n /**\n * The spared worktrees a human can meaningfully rule on, grouped most-safe first — the same\n * classification order the branch prompt uses, because it is literally the same verdict on the\n * branch the worktree holds.\n *\n * Deliberately excluded: LOCKED (a lock is standing and we cannot say whose), CURRENT (removing your own cwd\n * is not a thing to offer), DETACHED (no branch, so nothing to archive and nothing to judge) and\n * PRUNABLE (already provably dead — it is in the auto-reap list, not this one).\n */\n promptable(verdicts: DeletableWorktree[]): DeletableWorktree[] {\n const out: DeletableWorktree[] = [];\n for (const classification of ADJUDICATED_CLASSIFICATIONS) {\n for (const tree of verdicts) {\n if (!tree.deletable && tree.classification === classification) out.push(tree);\n }\n }\n return out;\n }\n\n /**\n * The zero-commit worktrees that are genuinely husks — the ones holding no uncommitted or\n * untracked work — with a printed line for each one that is spared.\n *\n * THIS IS THE ONE CHECK THAT MAKES REAPING A ZERO-COMMIT WORKTREE SAFE. A branch with no commits\n * of its own can lose nothing; a DIRECTORY with no commits can lose everything an agent has typed\n * in the last twenty minutes, and the two are indistinguishable by ref alone. `git status\n * --porcelain` is the difference, it is one local spawn, and it fails safe to \"dirty\".\n *\n * It is applied ONLY to the husks. Anything with unique commits is decided by flag or prompt, and\n * git's own refusal to remove a dirty worktree (WorktreeReaper never passes `--force`) is the\n * backstop there — but a backstop that reports a FAILURE is not good enough for a delete nobody\n * was asked about, which is why the husk path states the spare instead of tripping over it.\n */\n async withoutUncommitted(husks: DeletableWorktree[]): Promise<DeletableWorktree[]> {\n const clean: DeletableWorktree[] = [];\n let spared = '';\n for (const tree of husks) {\n const held = await this.workInFlight(tree.path);\n if (held.held) {\n // The REASON is printed verbatim, because \"it has uncommitted files\" and \"git would\n // not tell me\" send an operator to two different places.\n spared += ` · ${tree.path} [${tree.branch}] — ${held.reason};\\n`\n + ' nothing archives that, so it is left exactly where it is\\n';\n continue;\n }\n clean.push(tree);\n }\n if (spared !== '') {\n process.stdout.write('\\nZero-commit worktrees SPARED because work may be in flight in them:\\n' + spared);\n }\n return clean;\n }\n\n // Seam: one git spawn per candidate, overridden in the spec so the decision is testable with no\n // real worktrees on disk.\n protected workInFlight(worktreePath: string): Promise<WorktreeWorkInFlight> {\n return this.worktreeService.workInFlight(worktreePath);\n }\n\n reap(\n repoRoot: string,\n verb: MutationVerb,\n targets: DeletableWorktree[],\n retention: string,\n ): Promise<WorktreeReapResult> {\n return this.reaper.reapWorktrees(repoRoot, process.cwd(), verb, targets, retention);\n }\n\n report(repoRoot: string, result: WorktreeReapResult): string {\n if (result.reaped.length === 0 && result.failed.length === 0) return '';\n\n let out = '\\n' + SEP + `🌲 Removed ${String(result.reaped.length)} dead worktree(s)\\n` + SEP + '\\n';\n for (const entry of result.reaped) out += this.reapedLine(entry);\n\n if (result.failed.length > 0) {\n out += `\\n⚠️ ${String(result.failed.length)} worktree(s) could not be removed:\\n`;\n for (const entry of result.failed) out += ` ✗ ${entry.path} — ${entry.error}\\n`;\n }\n // Printed on success too: removing a worktree deletes real files, and a human who cannot see\n // how to undo that has to take it on trust — which is precisely what nobody should have to do.\n out += `\\nEvery removal is logged (phase REAP_WORKTREE) in\\n${this.mutationLog.branchMutationLogPath(repoRoot)}\\n`\n + 'with the `recover=` command that brings back both the directory and its branch.\\n';\n return out;\n }\n\n private reapedLine(entry: ReapedWorktree): string {\n const branch = entry.branch !== '' ? ` [${entry.branch}]` : ' [detached]';\n // The restore command is printed inline for the same reason the branch half prints the archive\n // tag: it is the one thing that makes this reversible without going and digging in a log.\n const restore = `\\n restore: ${this.reaper.restoreCommand(entry)}`;\n // A directory that went while its branch survived is a real half-state and must not read as done.\n const partial = entry.branch !== '' && !entry.branchDeleted\n ? `\\n ⚠️ the branch '${entry.branch}' was NOT deleted — git refused it`\n : '';\n return ` ✓ ${entry.path}${branch} — ${entry.reason}${restore}${partial}\\n`;\n }\n\n /**\n * The spared worktrees, with WHY — including the ones nobody will ever be asked about.\n *\n * When any of them is a claude-agent lock whose agent could not be verified either way, the block\n * ends with the flag that judges it on its branch instead. That hint lives HERE and not in the\n * verdict's own reason for one reason: the flag is wp-cleanup's, its spelling is one constant in\n * this package, and a rules-config message naming it would be a second copy of that spelling free\n * to drift. The reason says what is KNOWN; this says what you can DO about it.\n */\n sparedBlock(verdicts: DeletableWorktree[], removed: DeletableWorktree[]): string {\n const gone = new Set(removed.map((tree: DeletableWorktree): string => tree.path));\n const spared = verdicts.filter(\n (tree: DeletableWorktree): boolean => !tree.deletable && !gone.has(tree.path)\n && this.isMechanical(tree.classification));\n if (spared.length === 0) return '';\n let out = '\\nWorktrees deliberately left alone:\\n';\n let unverified = 0;\n for (const tree of spared) {\n out += ` · ${tree.path} — ${tree.reason}\\n`;\n if (tree.reason.includes(LOCK_LIVENESS_UNVERIFIABLE)) unverified += 1;\n }\n if (unverified > 0) {\n out += `\\n${String(unverified)} of those carry a claude-agent lock whose liveness cannot be `\n + 'verified.\\nTo judge those on their branch and commits alone — unlocking and removing only\\n'\n + `the ones that come back dead — re-run:\\n pnpm wp-cleanup ${FLAG_IGNORE_STALE_LOCKS}\\n`;\n }\n return out;\n }\n\n private isMechanical(classification: string): boolean {\n return classification === CLASSIFICATION_LOCKED\n || classification === CLASSIFICATION_CURRENT\n || classification === CLASSIFICATION_DETACHED\n || classification === CLASSIFICATION_PRUNABLE;\n }\n\n // The table a human answers: path, branch, and the same reason the branch prompt would show, since\n // the verdict IS the branch's verdict.\n promptBlock(promptable: DeletableWorktree[]): string {\n let out = '\\n' + SEP\n + `🤔 ${String(promptable.length)} worktree(s) are probably dead — your call\\n` + SEP + '\\n'\n + 'Removing one deletes its DIRECTORY and its branch. The branch is archived as a tag first,\\n'\n + 'so both come back with one `git worktree add -b …` — but uncommitted or untracked files in\\n'\n + 'that directory are NOT archived, and git will refuse the removal if any exist.\\n\\n';\n for (let i = 0; i < promptable.length; i += 1) {\n const tree = promptable[i];\n out += ` [${String(i + 1)}] ${tree.path}\\n [${tree.branch}] — ${tree.reason}\\n`;\n }\n return out;\n }\n}\n"]}
@@ -44,7 +44,7 @@ export declare class ChecklistDetector {
44
44
  roster(defs: readonly ChecklistDefinition[], changedFiles: readonly string[]): TriggeredChecklist[];
45
45
  detect(defs: readonly ChecklistDefinition[], changedFiles: readonly string[]): TriggeredChecklist[];
46
46
  private firedPatterns;
47
- detectForRepo(repoRoot: string, defs: readonly ChecklistDefinition[]): TriggeredChecklist[];
48
- detectForRange(repoRoot: string, defs: readonly ChecklistDefinition[], base: string, head?: string): TriggeredChecklist[];
47
+ detectForRepo(repoRoot: string, defs: readonly ChecklistDefinition[]): Promise<TriggeredChecklist[]>;
48
+ detectForRange(repoRoot: string, defs: readonly ChecklistDefinition[], base: string, head?: string): Promise<TriggeredChecklist[]>;
49
49
  toRequired(triggered: readonly TriggeredChecklist[]): RequiredChecklist[];
50
50
  }
@@ -83,10 +83,10 @@ let ChecklistDetector = class ChecklistDetector {
83
83
  return def.patterns.filter((p) => changedFiles.some((f) => (0, rules_config_1.isPathExcluded)(f, [p])));
84
84
  }
85
85
  // Resolve the diff base for the local branch, then detect. Returns [] when there is no base to diff.
86
- detectForRepo(repoRoot, defs) {
86
+ async detectForRepo(repoRoot, defs) {
87
87
  if (defs.length === 0)
88
88
  return [];
89
- const range = this.diffScope.resolveBase(repoRoot);
89
+ const range = await this.diffScope.resolveBase(repoRoot);
90
90
  if (!range.base)
91
91
  return [];
92
92
  return this.detectForRange(repoRoot, defs, range.base, range.head);
@@ -94,12 +94,12 @@ let ChecklistDetector = class ChecklistDetector {
94
94
  // Same detection against an EXPLICIT (base, head) — used by CI, where the useful range is the PR's
95
95
  // merge base .. head. tsOnly=false is load-bearing: the default drops every *.sql / Dockerfile / .env*
96
96
  // / metadata file a checklist most wants to key on, silently producing "no checklists matched".
97
- detectForRange(repoRoot, defs, base, head) {
97
+ async detectForRange(repoRoot, defs, base, head) {
98
98
  if (defs.length === 0 || !base)
99
99
  return [];
100
100
  const opts = new rules_config_1.ChangedFilesOptions();
101
101
  opts.tsOnly = false;
102
- const changedFiles = this.diffScope.getChangedFiles(repoRoot, base, head, opts);
102
+ const changedFiles = await this.diffScope.getChangedFiles(repoRoot, base, head, opts);
103
103
  return this.detect(defs, changedFiles);
104
104
  }
105
105
  // Flatten matched checklists into the RequiredChecklist shape that summary.json enforcement + the hint
@@ -1 +1 @@
1
- {"version":3,"file":"checklist-detector.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/checklist-detector.ts"],"names":[],"mappings":";;;;AAAA,0DAEiC;AACjC,yCAA2D;AAE3D,sGAAsG;AACtG,iFAAiF;AACjF,MAAa,kBAAkB;IAC3B,GAAG,CAAsB;IACzB,YAAY,CAAW;IACvB,uGAAuG;IACvG,yGAAyG;IACzG,eAAe,CAAW;IAE1B,YAAY,GAAwB,EAAE,YAAsB,EAAE,kBAA4B,EAAE;QACxF,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IAC3C,CAAC;CACJ;AAZD,gDAYC;AAED;;;GAGG;AACH,MAAa,eAAe;IACxB,OAAO,CAAuB,CAAC,qEAAqE;IACpG,gBAAgB,CAAS,CAAM,+DAA+D;IAC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G,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrG,CAAC;CACJ,CAAA;AA9DY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEG,wBAAS;GADxC,iBAAiB,CA8D7B","sourcesContent":["import {\n ChecklistDefinition, RequiredChecklist, DiffScope, ChangedFilesOptions, isPathExcluded,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\n// A checklist whose `patterns` matched the diff (so its reviewer subagent must run), plus the matched\n// files (for the dashboard + hint). Data-only (per CLAUDE.md, classes for data).\nexport class TriggeredChecklist {\n def: ChecklistDefinition;\n matchedFiles: string[];\n // Which of `def.patterns` actually hit a changed file. Carried so the printed instruction can say WHAT\n // matched, not just which files: a reviewer judges a `db/migrations/**` hit differently from a `**` one.\n matchedPatterns: string[];\n\n constructor(def: ChecklistDefinition, matchedFiles: string[], matchedPatterns: string[] = []) {\n this.def = def;\n this.matchedFiles = matchedFiles;\n this.matchedPatterns = matchedPatterns;\n }\n}\n\n/**\n * Every DEFINED checklist paired with what it matched, plus the two facts a reader needs to judge a skip:\n * how many files were even considered, and whether a diff was computable at all. Data-only (per CLAUDE.md).\n */\nexport class ChecklistRoster {\n entries: TriggeredChecklist[]; // one per defined checklist, in config order; matchedFiles may be []\n changedFileCount: number; // N — \"matched 0 of N changed files\" is only meaningful with N\n /**\n * false when no fork point resolved. Load-bearing: with no base the changed-file set is EMPTY, so\n * nothing matches — including patternless ALWAYS-RUNS checklists. Rendering that as \"all skipped ✅\"\n * would post a green all-clear to GitHub for a PR where no checklist was actually evaluated.\n */\n baseResolved: boolean;\n\n constructor(entries: TriggeredChecklist[], changedFileCount: number, baseResolved: boolean) {\n this.entries = entries;\n this.changedFileCount = changedFileCount;\n this.baseResolved = baseResolved;\n }\n}\n\n/**\n * Decides which company review checklists a branch matched, from what the diff CHANGED. Path matching\n * uses `isPathExcluded` — the SAME minimatch-based matcher rules-config already shares across\n * exclude-paths and the rule validators. A checklist with empty `patterns` matches every PR (always runs).\n *\n * `@injectable(bindingScopeValues.Singleton)` + injects {@link DiffScope} so it appears in the DI design\n * and reuses the ONE git-diff service instead of adding new git plumbing.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ChecklistDetector {\n constructor(private readonly diffScope: DiffScope) {}\n\n /**\n * Pure matching over EVERY defined checklist, matched or not — one entry per def, in config order, with\n * `matchedFiles: []` for the ones nothing hit. This is what lets the PR comment publish the full roster:\n * a skipped checklist is the normal, healthy outcome, and a comment that lists only the ones that fired\n * cannot distinguish \"evaluated and irrelevant\" from \"never configured\".\n *\n * A skipped entry has `matchedPatterns: []` — and so does a PATTERNLESS one. They mean opposite things,\n * so a renderer must decide \"always runs\" from `def.patterns.length === 0`, NEVER from\n * `matchedPatterns.length`, or every skipped checklist claims the whole diff was in its scope.\n */\n roster(defs: readonly ChecklistDefinition[], changedFiles: readonly string[]): TriggeredChecklist[] {\n return defs.map((def: ChecklistDefinition): TriggeredChecklist => {\n const matched = def.patterns.length === 0\n ? [...changedFiles]\n : changedFiles.filter((f: string): boolean => isPathExcluded(f, def.patterns));\n return new TriggeredChecklist(def, matched, this.firedPatterns(def, changedFiles));\n });\n }\n\n // Pure matching — unit-testable without git. Return every checklist whose patterns hit a changed file\n // (empty patterns ⇒ always matches). Defined as the roster minus the empty entries so the set that GATES\n // and the set the comment REPORTS can never be computed two different ways.\n detect(defs: readonly ChecklistDefinition[], changedFiles: readonly string[]): TriggeredChecklist[] {\n return this.roster(defs, changedFiles)\n .filter((t: TriggeredChecklist): boolean => t.matchedFiles.length > 0);\n }\n\n // Which of a checklist's globs hit at least one changed file. [] for a patternless checklist (it matches\n // every PR, and saying \"matched by nothing\" would read as a bug).\n private firedPatterns(def: ChecklistDefinition, changedFiles: readonly string[]): string[] {\n return def.patterns.filter((p: string): boolean => changedFiles.some((f: string): boolean => isPathExcluded(f, [p])));\n }\n\n // Resolve the diff base for the local branch, then detect. Returns [] when there is no base to diff.\n detectForRepo(repoRoot: string, defs: readonly ChecklistDefinition[]): TriggeredChecklist[] {\n if (defs.length === 0) return [];\n const range = this.diffScope.resolveBase(repoRoot);\n if (!range.base) return [];\n return this.detectForRange(repoRoot, defs, range.base, range.head);\n }\n\n // Same detection against an EXPLICIT (base, head) — used by CI, where the useful range is the PR's\n // merge base .. head. tsOnly=false is load-bearing: the default drops every *.sql / Dockerfile / .env*\n // / metadata file a checklist most wants to key on, silently producing \"no checklists matched\".\n detectForRange(repoRoot: string, defs: readonly ChecklistDefinition[], base: string, head?: string): TriggeredChecklist[] {\n if (defs.length === 0 || !base) return [];\n const opts = new ChangedFilesOptions();\n opts.tsOnly = false;\n const changedFiles = this.diffScope.getChangedFiles(repoRoot, base, head, opts);\n return this.detect(defs, changedFiles);\n }\n\n // Flatten matched checklists into the RequiredChecklist shape that summary.json enforcement + the hint\n // consume.\n toRequired(triggered: readonly TriggeredChecklist[]): RequiredChecklist[] {\n return triggered.map((t: TriggeredChecklist): RequiredChecklist =>\n new RequiredChecklist(\n t.def.id, t.def.reviewer, t.def.doc, t.matchedFiles, t.matchedPatterns, t.def.required));\n }\n}\n"]}
1
+ {"version":3,"file":"checklist-detector.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/checklist-detector.ts"],"names":[],"mappings":";;;;AAAA,0DAEiC;AACjC,yCAA2D;AAE3D,sGAAsG;AACtG,iFAAiF;AACjF,MAAa,kBAAkB;IAC3B,GAAG,CAAsB;IACzB,YAAY,CAAW;IACvB,uGAAuG;IACvG,yGAAyG;IACzG,eAAe,CAAW;IAE1B,YAAY,GAAwB,EAAE,YAAsB,EAAE,kBAA4B,EAAE;QACxF,IAAI,CAAC,GAAG,GAAG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IAAI,EAAE,IAAI,CAAC,CAAC;QACtF,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC3C,CAAC;IAED,uGAAuG;IACvG,WAAW;IACX,UAAU,CAAC,SAAwC;QAC/C,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAqB,EAAqB,EAAE,CAC9D,IAAI,gCAAiB,CACjB,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,eAAe,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrG,CAAC;CACJ,CAAA;AA9DY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAEG,wBAAS;GADxC,iBAAiB,CA8D7B","sourcesContent":["import {\n ChecklistDefinition, RequiredChecklist, DiffScope, ChangedFilesOptions, isPathExcluded,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\n\n// A checklist whose `patterns` matched the diff (so its reviewer subagent must run), plus the matched\n// files (for the dashboard + hint). Data-only (per CLAUDE.md, classes for data).\nexport class TriggeredChecklist {\n def: ChecklistDefinition;\n matchedFiles: string[];\n // Which of `def.patterns` actually hit a changed file. Carried so the printed instruction can say WHAT\n // matched, not just which files: a reviewer judges a `db/migrations/**` hit differently from a `**` one.\n matchedPatterns: string[];\n\n constructor(def: ChecklistDefinition, matchedFiles: string[], matchedPatterns: string[] = []) {\n this.def = def;\n this.matchedFiles = matchedFiles;\n this.matchedPatterns = matchedPatterns;\n }\n}\n\n/**\n * Every DEFINED checklist paired with what it matched, plus the two facts a reader needs to judge a skip:\n * how many files were even considered, and whether a diff was computable at all. Data-only (per CLAUDE.md).\n */\nexport class ChecklistRoster {\n entries: TriggeredChecklist[]; // one per defined checklist, in config order; matchedFiles may be []\n changedFileCount: number; // N — \"matched 0 of N changed files\" is only meaningful with N\n /**\n * false when no fork point resolved. Load-bearing: with no base the changed-file set is EMPTY, so\n * nothing matches — including patternless ALWAYS-RUNS checklists. Rendering that as \"all skipped ✅\"\n * would post a green all-clear to GitHub for a PR where no checklist was actually evaluated.\n */\n baseResolved: boolean;\n\n constructor(entries: TriggeredChecklist[], changedFileCount: number, baseResolved: boolean) {\n this.entries = entries;\n this.changedFileCount = changedFileCount;\n this.baseResolved = baseResolved;\n }\n}\n\n/**\n * Decides which company review checklists a branch matched, from what the diff CHANGED. Path matching\n * uses `isPathExcluded` — the SAME minimatch-based matcher rules-config already shares across\n * exclude-paths and the rule validators. A checklist with empty `patterns` matches every PR (always runs).\n *\n * `@injectable(bindingScopeValues.Singleton)` + injects {@link DiffScope} so it appears in the DI design\n * and reuses the ONE git-diff service instead of adding new git plumbing.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ChecklistDetector {\n constructor(private readonly diffScope: DiffScope) {}\n\n /**\n * Pure matching over EVERY defined checklist, matched or not — one entry per def, in config order, with\n * `matchedFiles: []` for the ones nothing hit. This is what lets the PR comment publish the full roster:\n * a skipped checklist is the normal, healthy outcome, and a comment that lists only the ones that fired\n * cannot distinguish \"evaluated and irrelevant\" from \"never configured\".\n *\n * A skipped entry has `matchedPatterns: []` — and so does a PATTERNLESS one. They mean opposite things,\n * so a renderer must decide \"always runs\" from `def.patterns.length === 0`, NEVER from\n * `matchedPatterns.length`, or every skipped checklist claims the whole diff was in its scope.\n */\n roster(defs: readonly ChecklistDefinition[], changedFiles: readonly string[]): TriggeredChecklist[] {\n return defs.map((def: ChecklistDefinition): TriggeredChecklist => {\n const matched = def.patterns.length === 0\n ? [...changedFiles]\n : changedFiles.filter((f: string): boolean => isPathExcluded(f, def.patterns));\n return new TriggeredChecklist(def, matched, this.firedPatterns(def, changedFiles));\n });\n }\n\n // Pure matching — unit-testable without git. Return every checklist whose patterns hit a changed file\n // (empty patterns ⇒ always matches). Defined as the roster minus the empty entries so the set that GATES\n // and the set the comment REPORTS can never be computed two different ways.\n detect(defs: readonly ChecklistDefinition[], changedFiles: readonly string[]): TriggeredChecklist[] {\n return this.roster(defs, changedFiles)\n .filter((t: TriggeredChecklist): boolean => t.matchedFiles.length > 0);\n }\n\n // Which of a checklist's globs hit at least one changed file. [] for a patternless checklist (it matches\n // every PR, and saying \"matched by nothing\" would read as a bug).\n private firedPatterns(def: ChecklistDefinition, changedFiles: readonly string[]): string[] {\n return def.patterns.filter((p: string): boolean => changedFiles.some((f: string): boolean => isPathExcluded(f, [p])));\n }\n\n // Resolve the diff base for the local branch, then detect. Returns [] when there is no base to diff.\n async detectForRepo(repoRoot: string, defs: readonly ChecklistDefinition[]): Promise<TriggeredChecklist[]> {\n if (defs.length === 0) return [];\n const range = await this.diffScope.resolveBase(repoRoot);\n if (!range.base) return [];\n return this.detectForRange(repoRoot, defs, range.base, range.head);\n }\n\n // Same detection against an EXPLICIT (base, head) — used by CI, where the useful range is the PR's\n // merge base .. head. tsOnly=false is load-bearing: the default drops every *.sql / Dockerfile / .env*\n // / metadata file a checklist most wants to key on, silently producing \"no checklists matched\".\n async detectForRange(repoRoot: string, defs: readonly ChecklistDefinition[], base: string, head?: string): Promise<TriggeredChecklist[]> {\n if (defs.length === 0 || !base) return [];\n const opts = new ChangedFilesOptions();\n opts.tsOnly = false;\n const changedFiles = await this.diffScope.getChangedFiles(repoRoot, base, head, opts);\n return this.detect(defs, changedFiles);\n }\n\n // Flatten matched checklists into the RequiredChecklist shape that summary.json enforcement + the hint\n // consume.\n toRequired(triggered: readonly TriggeredChecklist[]): RequiredChecklist[] {\n return triggered.map((t: TriggeredChecklist): RequiredChecklist =>\n new RequiredChecklist(\n t.def.id, t.def.reviewer, t.def.doc, t.matchedFiles, t.matchedPatterns, t.def.required));\n }\n}\n"]}
@@ -256,7 +256,7 @@ let ChecklistScanner = class ChecklistScanner {
256
256
  const base = basis.base;
257
257
  // ONE changed-file computation feeds both the roster (all X) and the applicable set (N). `detect` is
258
258
  // pure and defined as the roster minus its empty entries, so the two cannot disagree about a match.
259
- const changedFiles = this.changedFiles(repoRoot, base);
259
+ const changedFiles = await this.changedFiles(repoRoot, base);
260
260
  const roster = new checklist_detector_1.ChecklistRoster(this.checklistDetector.roster(defined, changedFiles), changedFiles.length, base !== '');
261
261
  const matched = this.checklistDetector.toRequired(this.checklistDetector.detect(defined, changedFiles));
262
262
  // THE ONE CHOKE POINT for both reviewer opt-outs. Suppressing HERE — rather than in
@@ -265,7 +265,7 @@ let ChecklistScanner = class ChecklistScanner {
265
265
  // existing. A second check in either command would be a second answer to one question.
266
266
  const context = opts.contextStage === ''
267
267
  ? this.prContextWriter.contextFor(repoRoot, featureName, basis)
268
- : this.prContextWriter.ensure(repoRoot, featureName, basis, opts.contextStage, changedFiles);
268
+ : await this.prContextWriter.ensure(repoRoot, featureName, basis, opts.contextStage, changedFiles);
269
269
  const homeConfig = this.homeConfig.load();
270
270
  const projectDisabled = defined.some((d) => d.reviewer.maxAgents === 0);
271
271
  if (homeConfig.turnOffAllReviewers || projectDisabled) {
@@ -384,7 +384,7 @@ let ChecklistScanner = class ChecklistScanner {
384
384
  * deletes a migration, an auth check or a terraform rule changed exactly what a
385
385
  * checklist exists to catch, and under the default no checklist fires at all.
386
386
  */
387
- changedFiles(repoRoot, base) {
387
+ async changedFiles(repoRoot, base) {
388
388
  if (base === '')
389
389
  return [];
390
390
  const opts = new rules_config_1.ChangedFilesOptions();
@@ -1 +1 @@
1
- {"version":3,"file":"checklist-scanner.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/checklist-scanner.ts"],"names":[],"mappings":";;;;AAAA,0DAGiC;AACjC,yCAA2D;AAC3D,iEAAsD;AACtD,6DAA8F;AAC9F,6CAA4D;AAC5D,2DAAsD;AACtD,qEAAgE;AAChE,6DAE8B;AAC9B,iEAAmE;AACnE,6DAA+D;AAE/D,uEAAuE;AACvE,MAAa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AE,CAAC,CAAC,CAAC;IACnF,CAAC;IAED;;;;;;;;;OASG;IACK,YAAY,CAAC,QAAgB,EAAE,IAAY;QAC/C,IAAI,IAAI,KAAK,EAAE;YAAE,OAAO,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAI,kCAAmB,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,oFAAoF;QACpF,OAAO,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAC3E,CAAC;CACJ,CAAA;AArMY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGF,mCAAY;QACP,sCAAiB;QACzB,wBAAS;QACD,8BAAiB;QACnB,mCAAe;QACb,gCAAiB;QAGxB,gCAAiB;QAChB,6CAAoB;QACd,6CAAwB;QACjC,gDAAyB;QAC3B,4CAAuB;GAd3C,gBAAgB,CAqM5B","sourcesContent":["import {\n ChangedFilesOptions, ChecklistDefinition, ChecklistResult, ChecklistReviewContext, DiffScope,\n HomeConfigService, RequiredChecklist, ReviewJsonService, VERDICT_RED, summaryJsonPath,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from './git-readAiBranchName';\nimport { ChecklistDetector, ChecklistRoster, TriggeredChecklist } from './checklist-detector';\nimport { DiffBasis, DiffBasisResolver } from './diff-basis';\nimport { PrContextWriter } from './pr-context-writer';\nimport { ChecklistScopeHasher } from './checklist-scope-hasher';\nimport {\n STANDING_CARRIED, STANDING_REJECTED, STANDING_STALE, VerdictProvenanceService, VerdictStanding,\n} from './verdict-provenance';\nimport { ReviewStageReceiptService } from './review-stage-receipt';\nimport { ReviewRoundStateService } from './review-round-state';\n\n/** How a caller wants the scan filtered. Data-only (per CLAUDE.md). */\nexport class ChecklistScanOptions {\n /**\n * false — `outstanding` is every applicable checklist (what `wp-review-upsert-pr` LISTS).\n * true — `outstanding` drops the ones already carrying a passing/overridden verdict, leaving only what\n * still owes review (what `wp-finish-upsert-pr` BLOCKS on).\n */\n filterAlreadyReviewed: boolean;\n /**\n * Which per-stage snapshot this scan should persist ('stage3-finish', …), or '' for \"do not write\n * pr-context.json here\".\n *\n * '' exists for stage ②, which cannot write yet: the context records `diffDir`, and the diff has not\n * been materialized at scan time. Letting the scan write anyway meant stage ② wrote the file twice,\n * ~60 lines apart, the first time with an empty diffDir. Now it writes once, after materializing.\n *\n * The DEFAULT is deliberately non-empty, so writing is what you get by NOT thinking about it. A\n * reviewer block that lost its diff command because nobody had written pr-context.json is a bug this\n * codebase has already shipped once (see PrContextWriter's docstring); opting out must be an explicit,\n * visible act by a caller that takes responsibility for writing it later — not an omission.\n */\n contextStage: string;\n /**\n * `commands.pr-gate.maxReviewerRounds`, as the caller's validated config states it. REQUIRED and first,\n * so a scan always states the budget its CARRIED verdicts were judged under (issue #1053: a stale green\n * or yellow is carried whatever round it came from, and the reason names the budget).\n */\n maxReviewerRounds: number;\n\n constructor(maxReviewerRounds: number, filterAlreadyReviewed = false, contextStage = 'stage-scan') {\n this.maxReviewerRounds = maxReviewerRounds;\n this.filterAlreadyReviewed = filterAlreadyReviewed;\n this.contextStage = contextStage;\n }\n}\n\n/**\n * The answer to \"what review does this branch owe?\", in the X → N → Z terms the commands report:\n * X = `defined` — every checklist in pr-gate.checklists\n * N = `applicable` — those whose patterns matched (or that have no patterns, so always run)\n * Z = `outstanding` — of N, those still owing a verdict (only when filterAlreadyReviewed)\n * Data-only.\n */\nexport class ChecklistScan {\n defined: ChecklistDefinition[]; // X\n applicable: RequiredChecklist[]; // N\n reviewed: RequiredChecklist[]; // N − Z: already have a passing/warned/overridden verdict\n outstanding: RequiredChecklist[]; // Z (== applicable when not filtering)\n context: ChecklistReviewContext; // fork-point sha + pr-context.json path\n summaryPath: string; // the branch's summary.json; verdict files sit beside it\n forkPoint: string; // '' when no fork point resolved\n // ALL X, matched or not, with why — what the PR comment publishes as its roster. Skipped checklists are\n // absent from `applicable` by construction, and recovering them downstream would mean a second\n // changed-file computation with different semantics (see the class comment).\n roster: ChecklistRoster;\n // Verdict files that exist but cannot be read as a verdict (e.g. still using the removed `success`).\n // Carried on the SCAN because wp-finish-upsert-pr refuses on missing reviewers before it ever parses\n // summary.json — a complaint raised only in there would never reach the AI.\n formatErrors: string[];\n /**\n * The basis the matching ACTUALLY ran against. Carried out so a caller that materializes the diff\n * (stage ②) reuses the identical range instead of resolving its own — two independent resolutions is\n * exactly how the changed-file set and the printed `git diff` command came to disagree.\n */\n basis: DiffBasis;\n changedFiles: string[]; // the full changed-file set the matching ran against\n /**\n * The verdict files the scan ALREADY read, carried out rather than dropped.\n *\n * `outstanding` answers \"who still owes a verdict?\" but not \"why\" — and the two reasons demand opposite\n * actions from the reader: a reviewer that never ran must be SPAWNED, a reviewer that ran and REFUSED\n * must not be (it will refuse again; the finding has to be fixed first). Telling them apart means\n * resolving each checklist's verdict, and without the results here every caller either re-reads the same\n * files off disk — a second read that can disagree with this one — or merges the two cases into one\n * message, which is exactly the loop this field exists to break.\n */\n results: ChecklistResult[];\n /**\n * The OPTIONAL (`required: false`) applicable checklists carrying no verdict file — i.e. nobody ran them.\n *\n * Deliberately NOT in `outstanding` when filtering: that is the exemption that makes `required: false`\n * mean something. Carried out as its own set rather than merely subtracted, because both readers need it\n * BY NAME and neither can recover it from what is left: stage ② offers exactly these to the human, and\n * the PR dashboard must publish them as \"not run\" rather than let a shorter roster imply everything\n * passed. An optional checklist that ran and went RED is absent from here and stays in `outstanding`.\n */\n optionalNotRun: RequiredChecklist[];\n /**\n * TRUE when either this machine's `experimental.turnOffAllReviewers` switch is on or the project sets\n * `commands.pr-gate.reviewerAgents: 0`, and therefore when `applicable`, `reviewed`,\n * `outstanding`, `results`, `optionalNotRun` and `formatErrors` above are ALL EMPTY BY DECREE rather\n * than because nothing matched. Those two states are indistinguishable from the empty lists alone,\n * and telling them apart is the entire reason this field exists: an unreviewed PR must never render\n * as a reviewed one.\n *\n * `defined`, `roster`, `basis`, `changedFiles` and `context` are deliberately left INTACT under\n * suppression, so every reader can still say WHAT was switched off — including which REQUIRED\n * checklists would otherwise have run.\n *\n * See `HOME_KEY_TURN_OFF_ALL_REVIEWERS` in rules-config for the flag's contract; it is an\n * `experimental.*` flag, so only a human ever ends it.\n */\n reviewersDisabled: boolean;\n /**\n * The checklists that WOULD have been `applicable` had the reviewers not been suppressed — required\n * ones included. EMPTY on every ordinary run, and empty is not ambiguous there because\n * `reviewersDisabled` is false.\n *\n * Carried by NAME and not as a count because every reader needs a different slice of it: stage ②\n * prints them so a human can see exactly which required reviewer was killed, the dashboard names them\n * in the 1st comment, and the compact PR body needs only `.length`. Recomputing any of that\n * downstream would mean a second changed-file computation that can disagree with this one.\n */\n suppressed: RequiredChecklist[];\n /**\n * How every EXISTING verdict file stands (issue #863): CURRENT (submitted through `wp-write-review` and\n * its checklist's in-scope diff is unchanged), CARRIED (its in-scope diff changed since, but it counts\n * anyway — staleness never re-reviews, issue #1053, and a human override always wins, issue #1051),\n * STALE (a red whose in-scope diff changed: it still refuses) or REJECTED (no bin provenance, or edited\n * after submission — it is not a review, and is left OUT of `results` so it is owed like one that never\n * ran). Empty under suppression.\n */\n standings: VerdictStanding[];\n /** checklist id → ChecklistScopeHasher's hash of its in-scope diff NOW. Recorded in the stage-② receipt. */\n scopeHashes: Record<string, string>;\n /**\n * The checklists this diff matches NOW that were never briefed, because a review round had already\n * started when a later commit first triggered them (issue #1053). The checklist set is FROZEN at the\n * briefing, so these never block and are never owed a reviewer: the dashboard names them on one\n * informational line. Empty before any round starts, and under suppression.\n */\n notBriefed: RequiredChecklist[];\n /**\n * checklist id → the dashboard stamp of every ORANGE whose final-round fix the author recorded (issue\n * #1053). Already folded into `results` (as `remediation`) — carried out so `wp-finish-upsert-pr` hands\n * the identical stamps to its summary.json load, which reads the verdicts afresh.\n */\n orangeFixes: Record<string, string>;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n defined: ChecklistDefinition[],\n applicable: RequiredChecklist[],\n reviewed: RequiredChecklist[],\n outstanding: RequiredChecklist[],\n context: ChecklistReviewContext,\n summaryPath: string,\n forkPoint: string,\n roster: ChecklistRoster,\n formatErrors: string[],\n // REQUIRED, and placed BEFORE the defaulted tail deliberately. A defaulted `reviewersDisabled =\n // false` would let every existing construction keep compiling while asserting, silently, that no\n // reviewer was switched off — the widening-by-omission `.claude/rules/no-backwards-compat.md`\n // rejects, and on the one field whose whole job is to stop an unreviewed PR reading as reviewed.\n reviewersDisabled: boolean,\n suppressed: RequiredChecklist[],\n basis: DiffBasis = new DiffBasis(),\n changedFiles: string[] = [],\n // Defaulted so a caller that only cares about the X/N/Z counts (and every existing test construction)\n // stays a one-liner; the scanner itself always passes the real set.\n results: ChecklistResult[] = [],\n optionalNotRun: RequiredChecklist[] = [],\n ) {\n this.defined = defined;\n this.applicable = applicable;\n this.reviewed = reviewed;\n this.outstanding = outstanding;\n this.context = context;\n this.summaryPath = summaryPath;\n this.forkPoint = forkPoint;\n this.roster = roster;\n this.formatErrors = formatErrors;\n this.reviewersDisabled = reviewersDisabled;\n this.suppressed = suppressed;\n this.basis = basis;\n this.changedFiles = changedFiles;\n this.results = results;\n this.optionalNotRun = optionalNotRun;\n this.standings = [];\n this.scopeHashes = {};\n this.notBriefed = [];\n this.orangeFixes = {};\n }\n}\n\n/** The checklists a scan JUDGES, and the ones the diff matches that it deliberately does not (#1053). Data-only. */\nexport class JudgedScope {\n applicable: RequiredChecklist[];\n notBriefed: RequiredChecklist[];\n\n constructor(applicable: RequiredChecklist[], notBriefed: RequiredChecklist[]) {\n this.applicable = applicable;\n this.notBriefed = notBriefed;\n }\n}\n\n/**\n * The ONE computation of which reviewer subagents a branch owes, shared by `wp-review-upsert-pr` (which lists) and\n * `wp-finish-upsert-pr` (which blocks). They previously each assembled this from the same parts in slightly\n * different ways, and any divergence means the command that reports and the command that gates disagree.\n *\n * Two properties are deliberate and load-bearing:\n *\n * 1. **The base is the FORK POINT of main, computed directly** — never `DiffScope.resolveBase`, which\n * overlays `NX_BASE`/`NX_HEAD` from the environment. That made review coverage depend on an env var.\n * It now arrives via {@link DiffBasisResolver}, which injects ForkPoint; same sha, one resolution.\n * 2. **UNCOMMITTED work counts.** `getChangedFiles` is called with NO head, which is the branch of it that\n * diffs base → WORKING TREE and unions in untracked files. Passing a head would diff commit-to-commit and\n * silently miss staged, unstaged and untracked changes — so a checklist matching only uncommitted files\n * would never fire and its reviewer would never be listed.\n * 3. **The range and the command it prints are the SAME basis.** Property 2 used to be true of the file set\n * only: reviewers were handed `git diff <base> HEAD`, which on a dirty tree covers a different range and\n * prints nothing. Both now derive from one {@link DiffBasis}, carried on the scan so a materializing\n * caller cannot re-resolve and drift.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ChecklistScanner {\n constructor(\n private readonly aiBranchName: AiBranchName,\n private readonly checklistDetector: ChecklistDetector,\n private readonly diffScope: DiffScope,\n private readonly diffBasisResolver: DiffBasisResolver,\n private readonly prContextWriter: PrContextWriter,\n private readonly reviewJsonService: ReviewJsonService,\n // Injected BY TYPE (no Symbol token, per CLAUDE.md) so the ONE reviewer kill switch is read in the\n // ONE place that computes what a branch owes — see the suppression note on `scan`.\n private readonly homeConfig: HomeConfigService,\n private readonly scopeHasher: ChecklistScopeHasher,\n private readonly verdictProvenance: VerdictProvenanceService,\n private readonly receipts: ReviewStageReceiptService,\n private readonly rounds: ReviewRoundStateService,\n ) {}\n\n /**\n * `defined` is the caller's ALREADY-VALIDATED `prGate.checklists`. The scanner deliberately does not load\n * config itself: `loadAndValidate` is the one gate on the checklist set (it rejects a non-array\n * `checklists`, including the removed `{ doc }` manifest shape, and verifies every guidance doc and\n * reviewer-agent file exists), both callers already run it for other fields, and keeping the read out of\n * here leaves this a function of its inputs rather than of the filesystem.\n */\n async scan(repoRoot: string, defined: ChecklistDefinition[], opts: ChecklistScanOptions): Promise<ChecklistScan> {\n const featureName = await this.aiBranchName.getFeatureName();\n const summaryPath = summaryJsonPath(repoRoot, featureName);\n // ONE basis for the file set, the reproduce command and any downstream materialization. The fork\n // point still comes from ForkPoint (never DiffScope.resolveBase) — DiffBasisResolver injects it.\n const basis = await this.diffBasisResolver.resolve(repoRoot);\n const base = basis.base;\n // ONE changed-file computation feeds both the roster (all X) and the applicable set (N). `detect` is\n // pure and defined as the roster minus its empty entries, so the two cannot disagree about a match.\n const changedFiles = this.changedFiles(repoRoot, base);\n const roster = new ChecklistRoster(\n this.checklistDetector.roster(defined, changedFiles), changedFiles.length, base !== '');\n const matched = this.checklistDetector.toRequired(this.checklistDetector.detect(defined, changedFiles));\n // THE ONE CHOKE POINT for both reviewer opt-outs. Suppressing HERE — rather than in\n // `wp-review-upsert-pr` and again in `wp-finish-upsert-pr` — is what keeps the command that LISTS\n // and the command that BLOCKS in agreement by construction, which is this class's whole reason for\n // existing. A second check in either command would be a second answer to one question.\n const context = opts.contextStage === ''\n ? this.prContextWriter.contextFor(repoRoot, featureName, basis)\n : this.prContextWriter.ensure(repoRoot, featureName, basis, opts.contextStage, changedFiles);\n const homeConfig = this.homeConfig.load();\n const projectDisabled = defined.some((d: ChecklistDefinition): boolean => d.reviewer.maxAgents === 0);\n if (homeConfig.turnOffAllReviewers || projectDisabled) {\n // EMPTY: applicable, reviewed, outstanding, formatErrors, results, optionalNotRun. INTACT:\n // defined, roster, basis, changedFiles, context — so every downstream reader can still say\n // WHAT was suppressed, which is the difference between an honest record and a silent one.\n return new ChecklistScan(\n defined, [], [], [], context, summaryPath, base, roster, [], true, matched, basis,\n changedFiles, [], []);\n }\n const judged = this.judgedScope(repoRoot, featureName, summaryPath, roster, matched);\n const applicable = judged.applicable;\n const scopeHashes = await this.scopeHasher.hashes(repoRoot, basis, applicable);\n const loaded = this.reviewJsonService.loadChecklistResults(summaryPath, applicable);\n const orangeFixes = await this.rounds.orangeFixes(repoRoot, summaryPath, loaded);\n for (const result of loaded) result.remediation = orangeFixes[result.id] ?? '';\n const standings = this.standingsOf(summaryPath, loaded, scopeHashes)\n .map((s: VerdictStanding): VerdictStanding => this.carried(s, loaded, opts.maxReviewerRounds));\n const results = this.liveResults(loaded, standings);\n const stillOwed = this.reviewJsonService.pendingChecklists(applicable, results);\n const owedIds = new Set(stillOwed.map((r: RequiredChecklist): string => r.id));\n // NOT `!owedIds.has(...)`-with-the-optional-exemption-folded-in: an optional checklist nobody ran is\n // neither reviewed nor blocking, and calling it \"reviewed\" would put a ✓ on the dashboard for a review\n // that never happened.\n const reviewed = applicable.filter((r: RequiredChecklist): boolean => !owedIds.has(r.id));\n const optionalNotRun = this.reviewJsonService.optionalWithoutVerdict(applicable, results);\n const scan = new ChecklistScan(\n defined,\n applicable,\n reviewed,\n opts.filterAlreadyReviewed ? this.blocking(stillOwed, optionalNotRun) : applicable,\n context,\n summaryPath,\n base,\n roster,\n this.reviewJsonService.checklistFormatErrors(applicable, results),\n false,\n [],\n basis,\n changedFiles,\n results,\n optionalNotRun,\n );\n scan.standings = standings;\n scan.scopeHashes = scopeHashes;\n scan.notBriefed = judged.notBriefed;\n scan.orangeFixes = orangeFixes;\n return scan;\n }\n\n /**\n * FROZEN at the briefing (issue #1053): once a review round has started, the checklists this branch owes\n * are the ones that were briefed (still defined, with whatever the current diff matches for each) — never\n * ones a later commit newly triggers, which no round will ever brief. Recomputing them from the current\n * diff is exactly the deadlock that drove an agent to move the review directory aside to get unstuck.\n * Before any round starts, the set is simply what the diff matches.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private judgedScope(repoRoot: string, featureName: string, summaryPath: string, roster: ChecklistRoster, matched: RequiredChecklist[]): JudgedScope {\n const receipt = this.receipts.read(repoRoot, featureName);\n if (!this.rounds.roundStarted(summaryPath, receipt)) return new JudgedScope(matched, []);\n const briefedIds = new Set(this.rounds.briefedChecklistIds(summaryPath, receipt));\n const briefed = roster.entries.filter((t: TriggeredChecklist): boolean => briefedIds.has(t.def.id));\n return new JudgedScope(\n this.checklistDetector.toRequired(briefed),\n matched.filter((r: RequiredChecklist): boolean => !briefedIds.has(r.id)));\n }\n\n /**\n * Judge every READABLE verdict against its bin provenance and the in-scope diff as it is now. A file\n * with a format problem is left to the format complaint, which names the fix; it is not assessed.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private standingsOf(\n summaryPath: string, loaded: readonly ChecklistResult[], scopeHashes: Record<string, string>,\n ): VerdictStanding[] {\n return loaded\n .filter((r: ChecklistResult): boolean => r.problem === '')\n .map((r: ChecklistResult): VerdictStanding =>\n this.verdictProvenance.assess(summaryPath, r, scopeHashes[r.id] ?? ''));\n }\n\n /**\n * A STALE verdict that must NOT be owed again, re-stood as CARRIED with the reason.\n *\n * 1. A human override for the checklist stands (issue #1051). Staleness is judged BEFORE the verdict is\n * resolved, so without this a stale verdict read as \"never ran\" and the override written for it was\n * never looked at — the human's in-session decision was shadowed by a hash comparison.\n * 2. Otherwise a green, yellow or orange ALWAYS carries (issue #1053): staleness never triggers a\n * re-review. `maxReviewerRounds` is a hard ceiling, and the only thing that ever opens another round is\n * a RED with a round left — a verdict that went stale because the author kept working is not one.\n *\n * A RED stays STALE: it still refuses, and stage ② re-briefs it while a round remains. A REJECTED verdict\n * is never carried: it is not a review.\n */\n private carried(s: VerdictStanding, loaded: readonly ChecklistResult[], maxRounds: number): VerdictStanding {\n if (s.standing !== STANDING_STALE) return s;\n const result = loaded.find((r: ChecklistResult): boolean => r.id === s.checklistId);\n const override = result?.override ?? null;\n if (override !== null && override.problem === '') {\n return new VerdictStanding(s.checklistId, STANDING_CARRIED, s.status, s.fromSha,\n `${s.reason}, but a human override (authorized by ${override.authorizedBy}) stands — the verdict counts`);\n }\n if (s.status === VERDICT_RED) return s;\n return new VerdictStanding(s.checklistId, STANDING_CARRIED, s.status, s.fromSha,\n `${s.reason}; CARRIED FORWARD without re-review — a ${s.status} verdict stands whatever round it came from, `\n + `and only a red opens another of the ${maxRounds} allowed round(s)`);\n }\n\n /**\n * The verdicts that still COUNT: every one except a REJECTED verdict, which is not a review. A stale\n * verdict still counts (see {@link carried}): a stale green, yellow or orange stands, and a stale red\n * still refuses — a refusal is not lifted by changing other code in its scope.\n */\n private liveResults(loaded: readonly ChecklistResult[], standings: readonly VerdictStanding[]): ChecklistResult[] {\n const dropped = new Set(standings\n .filter((s: VerdictStanding): boolean => s.standing === STANDING_REJECTED)\n .map((s: VerdictStanding): string => s.checklistId));\n return loaded.filter((r: ChecklistResult): boolean => !dropped.has(r.id));\n }\n\n /**\n * What `wp-finish-upsert-pr` actually REFUSES on: everything still owing a verdict, minus the optional\n * checklists nobody ran.\n *\n * The subtraction happens HERE — in the one place `outstanding` is computed — and not in the gate, so\n * there is a single answer to \"does this branch owe review?\". When the gate did its own filtering, the\n * command that lists and the command that blocks were two implementations of the same question, which is\n * exactly the divergence this class's docstring exists to prevent.\n */\n private blocking(stillOwed: readonly RequiredChecklist[], optionalNotRun: readonly RequiredChecklist[]): RequiredChecklist[] {\n const skipped = new Set(optionalNotRun.map((r: RequiredChecklist): string => r.id));\n return stillOwed.filter((r: RequiredChecklist): boolean => !skipped.has(r.id));\n }\n\n /**\n * Every file changed since the fork point, INCLUDING uncommitted and untracked ones. Two non-default\n * options, both load-bearing:\n *\n * `tsOnly:false` — the default drops every *.sql / Dockerfile / .env* file a checklist most wants\n * to key on, which would silently shrink the set a reviewer is pointed at.\n * `includeDeletions:true` — the default is `--diff-filter=d`, so a DELETED file is invisible. A PR that\n * deletes a migration, an auth check or a terraform rule changed exactly what a\n * checklist exists to catch, and under the default no checklist fires at all.\n */\n private changedFiles(repoRoot: string, base: string): string[] {\n if (base === '') return [];\n const opts = new ChangedFilesOptions();\n opts.tsOnly = false;\n opts.includeDeletions = true;\n // No head argument — see the class comment. This is what includes the working tree.\n return this.diffScope.getChangedFiles(repoRoot, base, undefined, opts);\n }\n}\n"]}
1
+ {"version":3,"file":"checklist-scanner.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/pr-gate/src/scripts/workflow/checklist-scanner.ts"],"names":[],"mappings":";;;;AAAA,0DAGiC;AACjC,yCAA2D;AAC3D,iEAAsD;AACtD,6DAA8F;AAC9F,6CAA4D;AAC5D,2DAAsD;AACtD,qEAAgE;AAChE,6DAE8B;AAC9B,iEAAmE;AACnE,6DAA+D;AAE/D,uEAAuE;AACvE,MAAa,oBAAoB;IAC7B;;;;OAIG;IACH,qBAAqB,CAAU;IAC/B;;;;;;;;;;;;OAYG;IACH,YAAY,CAAS;IACrB;;;;OAIG;IACH,iBAAiB,CAAS;IAE1B,YAAY,iBAAyB,EAAE,qBAAqB,GAAG,KAAK,EAAE,YAAY,GAAG,YAAY;QAC7F,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,qBAAqB,GAAG,qBAAqB,CAAC;QACnD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;CACJ;AAjCD,oDAiCC;AAED;;;;;;GAMG;AACH,MAAa,aAAa;IACtB,OAAO,CAAwB,CAAM,IAAI;IACzC,UAAU,CAAsB,CAAK,IAAI;IACzC,QAAQ,CAAsB,CAAO,0DAA0D;IAC/F,WAAW,CAAsB,CAAI,uCAAuC;IAC5E,OAAO,CAAyB,CAAK,wCAAwC;IAC7E,WAAW,CAAS,CAAkB,yDAAyD;IAC/F,SAAS,CAAS,CAAmB,iCAAiC;IACtE,wGAAwG;IACxG,+FAA+F;IAC/F,6EAA6E;IAC7E,MAAM,CAAkB;IACxB,qGAAqG;IACrG,qGAAqG;IACrG,4EAA4E;IAC5E,YAAY,CAAW;IACvB;;;;OAIG;IACH,KAAK,CAAY;IACjB,YAAY,CAAW,CAAc,qDAAqD;IAC1F;;;;;;;;;OASG;IACH,OAAO,CAAoB;IAC3B;;;;;;;;OAQG;IACH,cAAc,CAAsB;IACpC;;;;;;;;;;;;;;OAcG;IACH,iB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;;;;;;;;OAQG;IACK,QAAQ,CAAC,SAAuC,EAAE,cAA4C;QAClG,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAoB,EAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACpF,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAoB,EAAW,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnF,CAAC;IAED;;;;;;;;;OASG;IACK,KAAK,CAAC,YAAY,CAAC,QAAgB,EAAE,IAAY;QACrD,IAAI,IAAI,KAAK,EAAE;YAAE,OAAO,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAI,kCAAmB,EAAE,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,oFAAoF;QACpF,OAAO,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAC3E,CAAC;CACJ,CAAA;AArMY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,EAAC,8BAAkB,CAAC,SAAS,CAAC;6CAGF,mCAAY;QACP,sCAAiB;QACzB,wBAAS;QACD,8BAAiB;QACnB,mCAAe;QACb,gCAAiB;QAGxB,gCAAiB;QAChB,6CAAoB;QACd,6CAAwB;QACjC,gDAAyB;QAC3B,4CAAuB;GAd3C,gBAAgB,CAqM5B","sourcesContent":["import {\n ChangedFilesOptions, ChecklistDefinition, ChecklistResult, ChecklistReviewContext, DiffScope,\n HomeConfigService, RequiredChecklist, ReviewJsonService, VERDICT_RED, summaryJsonPath,\n} from '@webpieces/rules-config';\nimport { injectable, bindingScopeValues } from 'inversify';\nimport { AiBranchName } from './git-readAiBranchName';\nimport { ChecklistDetector, ChecklistRoster, TriggeredChecklist } from './checklist-detector';\nimport { DiffBasis, DiffBasisResolver } from './diff-basis';\nimport { PrContextWriter } from './pr-context-writer';\nimport { ChecklistScopeHasher } from './checklist-scope-hasher';\nimport {\n STANDING_CARRIED, STANDING_REJECTED, STANDING_STALE, VerdictProvenanceService, VerdictStanding,\n} from './verdict-provenance';\nimport { ReviewStageReceiptService } from './review-stage-receipt';\nimport { ReviewRoundStateService } from './review-round-state';\n\n/** How a caller wants the scan filtered. Data-only (per CLAUDE.md). */\nexport class ChecklistScanOptions {\n /**\n * false — `outstanding` is every applicable checklist (what `wp-review-upsert-pr` LISTS).\n * true — `outstanding` drops the ones already carrying a passing/overridden verdict, leaving only what\n * still owes review (what `wp-finish-upsert-pr` BLOCKS on).\n */\n filterAlreadyReviewed: boolean;\n /**\n * Which per-stage snapshot this scan should persist ('stage3-finish', …), or '' for \"do not write\n * pr-context.json here\".\n *\n * '' exists for stage ②, which cannot write yet: the context records `diffDir`, and the diff has not\n * been materialized at scan time. Letting the scan write anyway meant stage ② wrote the file twice,\n * ~60 lines apart, the first time with an empty diffDir. Now it writes once, after materializing.\n *\n * The DEFAULT is deliberately non-empty, so writing is what you get by NOT thinking about it. A\n * reviewer block that lost its diff command because nobody had written pr-context.json is a bug this\n * codebase has already shipped once (see PrContextWriter's docstring); opting out must be an explicit,\n * visible act by a caller that takes responsibility for writing it later — not an omission.\n */\n contextStage: string;\n /**\n * `commands.pr-gate.maxReviewerRounds`, as the caller's validated config states it. REQUIRED and first,\n * so a scan always states the budget its CARRIED verdicts were judged under (issue #1053: a stale green\n * or yellow is carried whatever round it came from, and the reason names the budget).\n */\n maxReviewerRounds: number;\n\n constructor(maxReviewerRounds: number, filterAlreadyReviewed = false, contextStage = 'stage-scan') {\n this.maxReviewerRounds = maxReviewerRounds;\n this.filterAlreadyReviewed = filterAlreadyReviewed;\n this.contextStage = contextStage;\n }\n}\n\n/**\n * The answer to \"what review does this branch owe?\", in the X → N → Z terms the commands report:\n * X = `defined` — every checklist in pr-gate.checklists\n * N = `applicable` — those whose patterns matched (or that have no patterns, so always run)\n * Z = `outstanding` — of N, those still owing a verdict (only when filterAlreadyReviewed)\n * Data-only.\n */\nexport class ChecklistScan {\n defined: ChecklistDefinition[]; // X\n applicable: RequiredChecklist[]; // N\n reviewed: RequiredChecklist[]; // N − Z: already have a passing/warned/overridden verdict\n outstanding: RequiredChecklist[]; // Z (== applicable when not filtering)\n context: ChecklistReviewContext; // fork-point sha + pr-context.json path\n summaryPath: string; // the branch's summary.json; verdict files sit beside it\n forkPoint: string; // '' when no fork point resolved\n // ALL X, matched or not, with why — what the PR comment publishes as its roster. Skipped checklists are\n // absent from `applicable` by construction, and recovering them downstream would mean a second\n // changed-file computation with different semantics (see the class comment).\n roster: ChecklistRoster;\n // Verdict files that exist but cannot be read as a verdict (e.g. still using the removed `success`).\n // Carried on the SCAN because wp-finish-upsert-pr refuses on missing reviewers before it ever parses\n // summary.json — a complaint raised only in there would never reach the AI.\n formatErrors: string[];\n /**\n * The basis the matching ACTUALLY ran against. Carried out so a caller that materializes the diff\n * (stage ②) reuses the identical range instead of resolving its own — two independent resolutions is\n * exactly how the changed-file set and the printed `git diff` command came to disagree.\n */\n basis: DiffBasis;\n changedFiles: string[]; // the full changed-file set the matching ran against\n /**\n * The verdict files the scan ALREADY read, carried out rather than dropped.\n *\n * `outstanding` answers \"who still owes a verdict?\" but not \"why\" — and the two reasons demand opposite\n * actions from the reader: a reviewer that never ran must be SPAWNED, a reviewer that ran and REFUSED\n * must not be (it will refuse again; the finding has to be fixed first). Telling them apart means\n * resolving each checklist's verdict, and without the results here every caller either re-reads the same\n * files off disk — a second read that can disagree with this one — or merges the two cases into one\n * message, which is exactly the loop this field exists to break.\n */\n results: ChecklistResult[];\n /**\n * The OPTIONAL (`required: false`) applicable checklists carrying no verdict file — i.e. nobody ran them.\n *\n * Deliberately NOT in `outstanding` when filtering: that is the exemption that makes `required: false`\n * mean something. Carried out as its own set rather than merely subtracted, because both readers need it\n * BY NAME and neither can recover it from what is left: stage ② offers exactly these to the human, and\n * the PR dashboard must publish them as \"not run\" rather than let a shorter roster imply everything\n * passed. An optional checklist that ran and went RED is absent from here and stays in `outstanding`.\n */\n optionalNotRun: RequiredChecklist[];\n /**\n * TRUE when either this machine's `experimental.turnOffAllReviewers` switch is on or the project sets\n * `commands.pr-gate.reviewerAgents: 0`, and therefore when `applicable`, `reviewed`,\n * `outstanding`, `results`, `optionalNotRun` and `formatErrors` above are ALL EMPTY BY DECREE rather\n * than because nothing matched. Those two states are indistinguishable from the empty lists alone,\n * and telling them apart is the entire reason this field exists: an unreviewed PR must never render\n * as a reviewed one.\n *\n * `defined`, `roster`, `basis`, `changedFiles` and `context` are deliberately left INTACT under\n * suppression, so every reader can still say WHAT was switched off — including which REQUIRED\n * checklists would otherwise have run.\n *\n * See `HOME_KEY_TURN_OFF_ALL_REVIEWERS` in rules-config for the flag's contract; it is an\n * `experimental.*` flag, so only a human ever ends it.\n */\n reviewersDisabled: boolean;\n /**\n * The checklists that WOULD have been `applicable` had the reviewers not been suppressed — required\n * ones included. EMPTY on every ordinary run, and empty is not ambiguous there because\n * `reviewersDisabled` is false.\n *\n * Carried by NAME and not as a count because every reader needs a different slice of it: stage ②\n * prints them so a human can see exactly which required reviewer was killed, the dashboard names them\n * in the 1st comment, and the compact PR body needs only `.length`. Recomputing any of that\n * downstream would mean a second changed-file computation that can disagree with this one.\n */\n suppressed: RequiredChecklist[];\n /**\n * How every EXISTING verdict file stands (issue #863): CURRENT (submitted through `wp-write-review` and\n * its checklist's in-scope diff is unchanged), CARRIED (its in-scope diff changed since, but it counts\n * anyway — staleness never re-reviews, issue #1053, and a human override always wins, issue #1051),\n * STALE (a red whose in-scope diff changed: it still refuses) or REJECTED (no bin provenance, or edited\n * after submission — it is not a review, and is left OUT of `results` so it is owed like one that never\n * ran). Empty under suppression.\n */\n standings: VerdictStanding[];\n /** checklist id → ChecklistScopeHasher's hash of its in-scope diff NOW. Recorded in the stage-② receipt. */\n scopeHashes: Record<string, string>;\n /**\n * The checklists this diff matches NOW that were never briefed, because a review round had already\n * started when a later commit first triggered them (issue #1053). The checklist set is FROZEN at the\n * briefing, so these never block and are never owed a reviewer: the dashboard names them on one\n * informational line. Empty before any round starts, and under suppression.\n */\n notBriefed: RequiredChecklist[];\n /**\n * checklist id → the dashboard stamp of every ORANGE whose final-round fix the author recorded (issue\n * #1053). Already folded into `results` (as `remediation`) — carried out so `wp-finish-upsert-pr` hands\n * the identical stamps to its summary.json load, which reads the verdicts afresh.\n */\n orangeFixes: Record<string, string>;\n\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n defined: ChecklistDefinition[],\n applicable: RequiredChecklist[],\n reviewed: RequiredChecklist[],\n outstanding: RequiredChecklist[],\n context: ChecklistReviewContext,\n summaryPath: string,\n forkPoint: string,\n roster: ChecklistRoster,\n formatErrors: string[],\n // REQUIRED, and placed BEFORE the defaulted tail deliberately. A defaulted `reviewersDisabled =\n // false` would let every existing construction keep compiling while asserting, silently, that no\n // reviewer was switched off — the widening-by-omission `.claude/rules/no-backwards-compat.md`\n // rejects, and on the one field whose whole job is to stop an unreviewed PR reading as reviewed.\n reviewersDisabled: boolean,\n suppressed: RequiredChecklist[],\n basis: DiffBasis = new DiffBasis(),\n changedFiles: string[] = [],\n // Defaulted so a caller that only cares about the X/N/Z counts (and every existing test construction)\n // stays a one-liner; the scanner itself always passes the real set.\n results: ChecklistResult[] = [],\n optionalNotRun: RequiredChecklist[] = [],\n ) {\n this.defined = defined;\n this.applicable = applicable;\n this.reviewed = reviewed;\n this.outstanding = outstanding;\n this.context = context;\n this.summaryPath = summaryPath;\n this.forkPoint = forkPoint;\n this.roster = roster;\n this.formatErrors = formatErrors;\n this.reviewersDisabled = reviewersDisabled;\n this.suppressed = suppressed;\n this.basis = basis;\n this.changedFiles = changedFiles;\n this.results = results;\n this.optionalNotRun = optionalNotRun;\n this.standings = [];\n this.scopeHashes = {};\n this.notBriefed = [];\n this.orangeFixes = {};\n }\n}\n\n/** The checklists a scan JUDGES, and the ones the diff matches that it deliberately does not (#1053). Data-only. */\nexport class JudgedScope {\n applicable: RequiredChecklist[];\n notBriefed: RequiredChecklist[];\n\n constructor(applicable: RequiredChecklist[], notBriefed: RequiredChecklist[]) {\n this.applicable = applicable;\n this.notBriefed = notBriefed;\n }\n}\n\n/**\n * The ONE computation of which reviewer subagents a branch owes, shared by `wp-review-upsert-pr` (which lists) and\n * `wp-finish-upsert-pr` (which blocks). They previously each assembled this from the same parts in slightly\n * different ways, and any divergence means the command that reports and the command that gates disagree.\n *\n * Two properties are deliberate and load-bearing:\n *\n * 1. **The base is the FORK POINT of main, computed directly** — never `DiffScope.resolveBase`, which\n * overlays `NX_BASE`/`NX_HEAD` from the environment. That made review coverage depend on an env var.\n * It now arrives via {@link DiffBasisResolver}, which injects ForkPoint; same sha, one resolution.\n * 2. **UNCOMMITTED work counts.** `getChangedFiles` is called with NO head, which is the branch of it that\n * diffs base → WORKING TREE and unions in untracked files. Passing a head would diff commit-to-commit and\n * silently miss staged, unstaged and untracked changes — so a checklist matching only uncommitted files\n * would never fire and its reviewer would never be listed.\n * 3. **The range and the command it prints are the SAME basis.** Property 2 used to be true of the file set\n * only: reviewers were handed `git diff <base> HEAD`, which on a dirty tree covers a different range and\n * prints nothing. Both now derive from one {@link DiffBasis}, carried on the scan so a materializing\n * caller cannot re-resolve and drift.\n *\n * `@injectable(bindingScopeValues.Singleton)` so it is injected by type and drawn in the DI design.\n */\n@injectable(bindingScopeValues.Singleton)\nexport class ChecklistScanner {\n constructor(\n private readonly aiBranchName: AiBranchName,\n private readonly checklistDetector: ChecklistDetector,\n private readonly diffScope: DiffScope,\n private readonly diffBasisResolver: DiffBasisResolver,\n private readonly prContextWriter: PrContextWriter,\n private readonly reviewJsonService: ReviewJsonService,\n // Injected BY TYPE (no Symbol token, per CLAUDE.md) so the ONE reviewer kill switch is read in the\n // ONE place that computes what a branch owes — see the suppression note on `scan`.\n private readonly homeConfig: HomeConfigService,\n private readonly scopeHasher: ChecklistScopeHasher,\n private readonly verdictProvenance: VerdictProvenanceService,\n private readonly receipts: ReviewStageReceiptService,\n private readonly rounds: ReviewRoundStateService,\n ) {}\n\n /**\n * `defined` is the caller's ALREADY-VALIDATED `prGate.checklists`. The scanner deliberately does not load\n * config itself: `loadAndValidate` is the one gate on the checklist set (it rejects a non-array\n * `checklists`, including the removed `{ doc }` manifest shape, and verifies every guidance doc and\n * reviewer-agent file exists), both callers already run it for other fields, and keeping the read out of\n * here leaves this a function of its inputs rather than of the filesystem.\n */\n async scan(repoRoot: string, defined: ChecklistDefinition[], opts: ChecklistScanOptions): Promise<ChecklistScan> {\n const featureName = await this.aiBranchName.getFeatureName();\n const summaryPath = summaryJsonPath(repoRoot, featureName);\n // ONE basis for the file set, the reproduce command and any downstream materialization. The fork\n // point still comes from ForkPoint (never DiffScope.resolveBase) — DiffBasisResolver injects it.\n const basis = await this.diffBasisResolver.resolve(repoRoot);\n const base = basis.base;\n // ONE changed-file computation feeds both the roster (all X) and the applicable set (N). `detect` is\n // pure and defined as the roster minus its empty entries, so the two cannot disagree about a match.\n const changedFiles = await this.changedFiles(repoRoot, base);\n const roster = new ChecklistRoster(\n this.checklistDetector.roster(defined, changedFiles), changedFiles.length, base !== '');\n const matched = this.checklistDetector.toRequired(this.checklistDetector.detect(defined, changedFiles));\n // THE ONE CHOKE POINT for both reviewer opt-outs. Suppressing HERE — rather than in\n // `wp-review-upsert-pr` and again in `wp-finish-upsert-pr` — is what keeps the command that LISTS\n // and the command that BLOCKS in agreement by construction, which is this class's whole reason for\n // existing. A second check in either command would be a second answer to one question.\n const context = opts.contextStage === ''\n ? this.prContextWriter.contextFor(repoRoot, featureName, basis)\n : await this.prContextWriter.ensure(repoRoot, featureName, basis, opts.contextStage, changedFiles);\n const homeConfig = this.homeConfig.load();\n const projectDisabled = defined.some((d: ChecklistDefinition): boolean => d.reviewer.maxAgents === 0);\n if (homeConfig.turnOffAllReviewers || projectDisabled) {\n // EMPTY: applicable, reviewed, outstanding, formatErrors, results, optionalNotRun. INTACT:\n // defined, roster, basis, changedFiles, context — so every downstream reader can still say\n // WHAT was suppressed, which is the difference between an honest record and a silent one.\n return new ChecklistScan(\n defined, [], [], [], context, summaryPath, base, roster, [], true, matched, basis,\n changedFiles, [], []);\n }\n const judged = this.judgedScope(repoRoot, featureName, summaryPath, roster, matched);\n const applicable = judged.applicable;\n const scopeHashes = await this.scopeHasher.hashes(repoRoot, basis, applicable);\n const loaded = this.reviewJsonService.loadChecklistResults(summaryPath, applicable);\n const orangeFixes = await this.rounds.orangeFixes(repoRoot, summaryPath, loaded);\n for (const result of loaded) result.remediation = orangeFixes[result.id] ?? '';\n const standings = this.standingsOf(summaryPath, loaded, scopeHashes)\n .map((s: VerdictStanding): VerdictStanding => this.carried(s, loaded, opts.maxReviewerRounds));\n const results = this.liveResults(loaded, standings);\n const stillOwed = this.reviewJsonService.pendingChecklists(applicable, results);\n const owedIds = new Set(stillOwed.map((r: RequiredChecklist): string => r.id));\n // NOT `!owedIds.has(...)`-with-the-optional-exemption-folded-in: an optional checklist nobody ran is\n // neither reviewed nor blocking, and calling it \"reviewed\" would put a ✓ on the dashboard for a review\n // that never happened.\n const reviewed = applicable.filter((r: RequiredChecklist): boolean => !owedIds.has(r.id));\n const optionalNotRun = this.reviewJsonService.optionalWithoutVerdict(applicable, results);\n const scan = new ChecklistScan(\n defined,\n applicable,\n reviewed,\n opts.filterAlreadyReviewed ? this.blocking(stillOwed, optionalNotRun) : applicable,\n context,\n summaryPath,\n base,\n roster,\n this.reviewJsonService.checklistFormatErrors(applicable, results),\n false,\n [],\n basis,\n changedFiles,\n results,\n optionalNotRun,\n );\n scan.standings = standings;\n scan.scopeHashes = scopeHashes;\n scan.notBriefed = judged.notBriefed;\n scan.orangeFixes = orangeFixes;\n return scan;\n }\n\n /**\n * FROZEN at the briefing (issue #1053): once a review round has started, the checklists this branch owes\n * are the ones that were briefed (still defined, with whatever the current diff matches for each) — never\n * ones a later commit newly triggers, which no round will ever brief. Recomputing them from the current\n * diff is exactly the deadlock that drove an agent to move the review directory aside to get unstuck.\n * Before any round starts, the set is simply what the diff matches.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private judgedScope(repoRoot: string, featureName: string, summaryPath: string, roster: ChecklistRoster, matched: RequiredChecklist[]): JudgedScope {\n const receipt = this.receipts.read(repoRoot, featureName);\n if (!this.rounds.roundStarted(summaryPath, receipt)) return new JudgedScope(matched, []);\n const briefedIds = new Set(this.rounds.briefedChecklistIds(summaryPath, receipt));\n const briefed = roster.entries.filter((t: TriggeredChecklist): boolean => briefedIds.has(t.def.id));\n return new JudgedScope(\n this.checklistDetector.toRequired(briefed),\n matched.filter((r: RequiredChecklist): boolean => !briefedIds.has(r.id)));\n }\n\n /**\n * Judge every READABLE verdict against its bin provenance and the in-scope diff as it is now. A file\n * with a format problem is left to the format complaint, which names the fix; it is not assessed.\n */\n // eslint-disable-next-line @typescript-eslint/max-params\n private standingsOf(\n summaryPath: string, loaded: readonly ChecklistResult[], scopeHashes: Record<string, string>,\n ): VerdictStanding[] {\n return loaded\n .filter((r: ChecklistResult): boolean => r.problem === '')\n .map((r: ChecklistResult): VerdictStanding =>\n this.verdictProvenance.assess(summaryPath, r, scopeHashes[r.id] ?? ''));\n }\n\n /**\n * A STALE verdict that must NOT be owed again, re-stood as CARRIED with the reason.\n *\n * 1. A human override for the checklist stands (issue #1051). Staleness is judged BEFORE the verdict is\n * resolved, so without this a stale verdict read as \"never ran\" and the override written for it was\n * never looked at — the human's in-session decision was shadowed by a hash comparison.\n * 2. Otherwise a green, yellow or orange ALWAYS carries (issue #1053): staleness never triggers a\n * re-review. `maxReviewerRounds` is a hard ceiling, and the only thing that ever opens another round is\n * a RED with a round left — a verdict that went stale because the author kept working is not one.\n *\n * A RED stays STALE: it still refuses, and stage ② re-briefs it while a round remains. A REJECTED verdict\n * is never carried: it is not a review.\n */\n private carried(s: VerdictStanding, loaded: readonly ChecklistResult[], maxRounds: number): VerdictStanding {\n if (s.standing !== STANDING_STALE) return s;\n const result = loaded.find((r: ChecklistResult): boolean => r.id === s.checklistId);\n const override = result?.override ?? null;\n if (override !== null && override.problem === '') {\n return new VerdictStanding(s.checklistId, STANDING_CARRIED, s.status, s.fromSha,\n `${s.reason}, but a human override (authorized by ${override.authorizedBy}) stands — the verdict counts`);\n }\n if (s.status === VERDICT_RED) return s;\n return new VerdictStanding(s.checklistId, STANDING_CARRIED, s.status, s.fromSha,\n `${s.reason}; CARRIED FORWARD without re-review — a ${s.status} verdict stands whatever round it came from, `\n + `and only a red opens another of the ${maxRounds} allowed round(s)`);\n }\n\n /**\n * The verdicts that still COUNT: every one except a REJECTED verdict, which is not a review. A stale\n * verdict still counts (see {@link carried}): a stale green, yellow or orange stands, and a stale red\n * still refuses — a refusal is not lifted by changing other code in its scope.\n */\n private liveResults(loaded: readonly ChecklistResult[], standings: readonly VerdictStanding[]): ChecklistResult[] {\n const dropped = new Set(standings\n .filter((s: VerdictStanding): boolean => s.standing === STANDING_REJECTED)\n .map((s: VerdictStanding): string => s.checklistId));\n return loaded.filter((r: ChecklistResult): boolean => !dropped.has(r.id));\n }\n\n /**\n * What `wp-finish-upsert-pr` actually REFUSES on: everything still owing a verdict, minus the optional\n * checklists nobody ran.\n *\n * The subtraction happens HERE — in the one place `outstanding` is computed — and not in the gate, so\n * there is a single answer to \"does this branch owe review?\". When the gate did its own filtering, the\n * command that lists and the command that blocks were two implementations of the same question, which is\n * exactly the divergence this class's docstring exists to prevent.\n */\n private blocking(stillOwed: readonly RequiredChecklist[], optionalNotRun: readonly RequiredChecklist[]): RequiredChecklist[] {\n const skipped = new Set(optionalNotRun.map((r: RequiredChecklist): string => r.id));\n return stillOwed.filter((r: RequiredChecklist): boolean => !skipped.has(r.id));\n }\n\n /**\n * Every file changed since the fork point, INCLUDING uncommitted and untracked ones. Two non-default\n * options, both load-bearing:\n *\n * `tsOnly:false` — the default drops every *.sql / Dockerfile / .env* file a checklist most wants\n * to key on, which would silently shrink the set a reviewer is pointed at.\n * `includeDeletions:true` — the default is `--diff-filter=d`, so a DELETED file is invisible. A PR that\n * deletes a migration, an auth check or a terraform rule changed exactly what a\n * checklist exists to catch, and under the default no checklist fires at all.\n */\n private async changedFiles(repoRoot: string, base: string): Promise<string[]> {\n if (base === '') return [];\n const opts = new ChangedFilesOptions();\n opts.tsOnly = false;\n opts.includeDeletions = true;\n // No head argument — see the class comment. This is what includes the working tree.\n return this.diffScope.getChangedFiles(repoRoot, base, undefined, opts);\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { MutationVerb } from '@webpieces/repo-workflow-core';
1
+ import { MainSyncStatusService, MutationVerb } from '@webpieces/repo-workflow-core';
2
2
  import { BranchNaming } from './branch-naming';
3
3
  import { CleanTmp } from './cleanTmp';
4
4
  import { GitExec } from './git-exec';
@@ -26,7 +26,8 @@ export declare class MergeEnd {
26
26
  private readonly cleanTmpService;
27
27
  private readonly gitExec;
28
28
  private readonly mergeState;
29
- constructor(branchNaming: BranchNaming, cleanTmpService: CleanTmp, gitExec: GitExec, mergeState: MergeState);
29
+ private readonly mainSyncStatus;
30
+ constructor(branchNaming: BranchNaming, cleanTmpService: CleanTmp, gitExec: GitExec, mergeState: MergeState, mainSyncStatus: MainSyncStatusService);
30
31
  /**
31
32
  * Complete a 3-point squash merge. See {@link MergeEndOptions} for what `conflictedFiles` and
32
33
  * `pushRemote` mean. Either way the merge ends fully finalized on the feature branch.
@@ -62,11 +62,13 @@ let MergeEnd = class MergeEnd {
62
62
  cleanTmpService;
63
63
  gitExec;
64
64
  mergeState;
65
- constructor(branchNaming, cleanTmpService, gitExec, mergeState) {
65
+ mainSyncStatus;
66
+ constructor(branchNaming, cleanTmpService, gitExec, mergeState, mainSyncStatus) {
66
67
  this.branchNaming = branchNaming;
67
68
  this.cleanTmpService = cleanTmpService;
68
69
  this.gitExec = gitExec;
69
70
  this.mergeState = mergeState;
71
+ this.mainSyncStatus = mainSyncStatus;
70
72
  }
71
73
  /**
72
74
  * Complete a 3-point squash merge. See {@link MergeEndOptions} for what `conflictedFiles` and
@@ -157,7 +159,7 @@ let MergeEnd = class MergeEnd {
157
159
  (0, repo_workflow_core_1.logBranchMutation)(repoRoot, renameEvent);
158
160
  // Branch now contains origin/main — stamp a clean main-sync status so the feature-branch-guard
159
161
  // unblocks edits immediately (no wait for the async refresher).
160
- (0, repo_workflow_core_1.stampCleanMainSyncStatus)(repoRoot);
162
+ await this.mainSyncStatus.stampCleanMainSyncStatus(repoRoot);
161
163
  // Clean sync → the pre-merge snapshot was never needed; delete it LAST. Conflict sync → keep it.
162
164
  // ALSO keep it when we did not push: the squash rewrite then exists ONLY in this working copy, so
163
165
  // deleting the snapshot would leave a history rewrite with no copy anywhere. It is disposable only
@@ -233,6 +235,7 @@ exports.MergeEnd = MergeEnd = tslib_1.__decorate([
233
235
  tslib_1.__metadata("design:paramtypes", [branch_naming_1.BranchNaming,
234
236
  cleanTmp_1.CleanTmp,
235
237
  git_exec_1.GitExec,
236
- merge_state_1.MergeState])
238
+ merge_state_1.MergeState,
239
+ repo_workflow_core_1.MainSyncStatusService])
237
240
  ], MergeEnd);
238
241
  //# sourceMappingURL=merge-end.js.map