Skip to content

fix: preserve PR promotion close semantics - #446

Merged
steipete merged 5 commits into
mainfrom
fix/promotion-close-reasons
Jul 9, 2026
Merged

steipete merged 5 commits into
mainfrom
fix/promotion-close-reasons

Conversation

@steipete

@steipete steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve the resolved close reason for promoted stale F-rated PRs: use low_signal_unmergeable_pr unless the higher-priority no-diff path resolves to duplicate_or_superseded
  • rewrite the archived Summary when a keep-open review is promoted, so stored reports no longer contradict the close decision
  • select ambiguous promotion candidates for every possible enabled outcome, then gate the live resolved reason before report persistence, comment sync, or close mutation
  • keep no-diff precedence independent of apply filtering so a disabled duplicate reason cannot fall through to a lower-priority low-signal close

This is rebased onto 76360b9874 (#444), retaining its apply-throughput changes while making promotion reason selection and filtering consistent.

Proof

  • corepack pnpm install --frozen-lockfile
  • corepack pnpm run build:all
  • node --test test/apply-pr-promotion.test.ts test/apply-pr-duplicate-proof.test.ts test/apply-pr-coverage-proof-close.test.ts test/apply-label-sync.test.ts test/close-reasons.test.ts test/review-close-policy.test.ts test/repair/workflow-utils.test.ts — 140/140 passed
  • corepack pnpm run lint:src
  • corepack pnpm run lint:repair
  • corepack pnpm run lint:scripts
  • corepack pnpm exec oxfmt --check src/clawsweeper.ts src/repair/workflow-utils.ts test/helpers.ts test/apply-pr-promotion.test.ts test/repair/workflow-utils.test.ts
  • git diff --check origin/main...HEAD
  • /Users/steipete/Projects/agent-skills/skills/autoreview/scripts/autoreview --mode branch --base origin/main --parallel-tests 'corepack pnpm run build:all && node --test test/apply-pr-promotion.test.ts test/repair/workflow-utils.test.ts' --stream-engine-output — clean, findings [], 52/52 parallel tests passed

@clawsweeper

clawsweeper Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 12:39 PM ET / 16:39 UTC.

Summary
The branch changes ClawSweeper PR close-promotion logic and repair selection so resolved close reasons are preserved and filtered, adds regression coverage, and adds one changelog line.

Reproducibility: yes. from source inspection: current main still records promoted PR closes as duplicate_or_superseded unconditionally, and the PR changes that path. I did not run a live apply repro because this review is read-only.

Review metrics: 2 noteworthy metrics.

  • Changed surface: 7 files, +413/-60. The PR touches core apply logic, repair workflow selection, helpers, tests, and release notes, so review needs to cover both runtime and automation surfaces.
  • Release-owned file touched: 1 CHANGELOG.md line added. Repository policy reserves changelog edits for release handling, making this a concrete cleanup item before merge.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted live apply or dry-run proof showing the promoted close reason and report/comment outcome.
  • Remove the release-owned CHANGELOG.md line and keep the release-note context in the PR body or commits.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Mock-only: the PR body lists build, lint, unit, and autoreview validation, but no redacted live apply or dry-run output showing the changed promotion behavior; terminal output, logs, or screenshots with private details redacted should be added to the PR body to trigger re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] The diff changes apply-time close selection plus report/comment persistence; without live apply or dry-run proof, gh hydration and comment-sync behavior are still inferred from mocked tests.
  • [P1] The PR still edits release-owned CHANGELOG.md, which conflicts with repository policy for normal PR work.

Maintainer options:

  1. Require live apply proof (recommended)
    Ask for a redacted dry-run or live apply transcript against copied stale PR reports showing the resolved close reason and stored report/comment outcome before merge.
  2. Accept mocked coverage only
    Maintainers can intentionally merge on the mocked apply tests if they are comfortable that live gh hydration and comment sync have no untested edge.

Next step before merge

  • [P1] Needs contributor-supplied redacted live apply or dry-run proof and removal of the release-owned changelog line; ClawSweeper repair should not synthesize that proof or edit release-owned notes.

Security
Cleared: Cleared: the diff changes TypeScript apply logic, tests, helpers, and one changelog line, with no dependency, workflow-permission, secret, package-resolution, or supply-chain change.

Review findings

  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:39
Review details

Best possible solution:

Land the close-reason semantics after removing the release-owned changelog line and adding redacted live apply or dry-run proof demonstrating duplicate, low-signal, and no-diff promotion behavior.

Do we have a high-confidence way to reproduce the issue?

Yes from source inspection: current main still records promoted PR closes as duplicate_or_superseded unconditionally, and the PR changes that path. I did not run a live apply repro because this review is read-only.

Is this the best way to solve the issue?

Mostly yes: carrying the resolved closeReason through report upgrade and apply selection is a narrow fix, and the previous unsafe supersession fallback concern appears addressed. The merge-ready path still needs the changelog line removed and live apply proof added.

Full review comments:

  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:39
    This finding remains from the prior review. AGENTS.md marks CHANGELOG.md as release-owned, and this PR already carries the release-note context in its body, so the branch should not add this line.
    Confidence: 0.92

Overall correctness: patch is correct
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 458cfdc1a59d.

Label changes

Label justifications:

  • P2: This is a normal-priority apply automation fix with limited blast radius and no evidence of an active production outage.
  • merge-risk: 🚨 automation: The diff changes close-apply promotion selection and persistence, which can affect which PRs ClawSweeper automation proposes or applies as closes.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Mock-only: the PR body lists build, lint, unit, and autoreview validation, but no redacted live apply or dry-run output showing the changed promotion behavior; terminal output, logs, or screenshots with private details redacted should be added to the PR body to trigger re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

What I checked:

  • Repository policy read: AGENTS.md was read fully; the relevant policy is that CHANGELOG.md is release-owned and normal PR work should keep release-note context in PR bodies and commits instead. (AGENTS.md:42, 458cfdc1a59d)
  • Current main does not already contain the central change: Current main still upgrades pull-request close promotions to duplicate_or_superseded unconditionally and sets the apply closeReason to duplicate_or_superseded after any promotion, so the PR is not obsolete on main. (src/clawsweeper.ts:13628, 458cfdc1a59d)
  • PR head preserves resolved close reason: At PR head, PullRequestClosePromotion carries closeReason and summary, upgradePullRequestClosePromotionReport writes promotion.closeReason, and apply stores promotion.closeReason after live resolution. (src/clawsweeper.ts:13605, b26b1e5ffd46)
  • Prior unsafe-fallback blocker is addressed: The PR head records unsafe linked canonical candidates and returns null before stale low-signal fallback when a live canonical candidate is unsafe, preserving the supersession guard from the earlier review. (src/clawsweeper.ts:14667, b26b1e5ffd46)
  • Focused promotion-selection coverage added: The PR adds tests for filtered duplicate, low-signal, and no-diff promotion paths, plus supersession-safety coverage when only low-signal closes are enabled. (test/apply-pr-promotion.test.ts:375, b26b1e5ffd46)
  • Real behavior proof is still mock/test only: The PR body lists install, build, lint, unit tests, diff check, and autoreview output, but no redacted live apply or dry-run transcript showing the changed report/comment/close behavior through gh hydration. (b26b1e5ffd46)

Likely related people:

  • brokemac79: Blame and -S history show the close-promotion helpers and workflow close-candidate selection originated in earlier apply-cycle work. (role: introduced behavior; confidence: high; commits: e95da707d494, 682da993aa88; files: src/clawsweeper.ts, src/repair/workflow-utils.ts)
  • steipete: Recent merged close-apply throughput and candidate-ordering work touched the same apply and workflow utility paths now changed by this PR. (role: recent area contributor; confidence: high; commits: 76360b98742b, f070a5ed04c1, bbc8c8f8e4de; files: src/clawsweeper.ts, src/repair/workflow-utils.ts)
  • Yuval Dinodia: Recent review-freshness work touched promotion gating around reviewReportCanPromoteToClose in the same core apply path. (role: adjacent contributor; confidence: medium; commits: eca6fbfa0e6d; files: src/clawsweeper.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (2 earlier review cycles)
  • reviewed 2026-07-09T14:41:55.171Z sha f3292fe :: needs real behavior proof before merge. :: [P1] Preserve unsafe supersession guards before low-signal close | [P3] Remove the release-owned changelog entry
  • reviewed 2026-07-09T14:59:54.687Z sha e632ade :: needs real behavior proof before merge. :: [P3] Remove the release-owned changelog entry

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Jul 9, 2026
@steipete
steipete force-pushed the fix/promotion-close-reasons branch from e632ade to b26b1e5 Compare July 9, 2026 16:34

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b26b1e5ffd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 1575 to 1578
return (
frontMatterValue(markdown, "pr_rating_overall") === "F" ||
frontMatterValue(markdown, "pr_rating_proof") === "F" ||
sectionLineValue(markdown, "Overall tier") === "F" ||
sectionLineValue(markdown, "Proof tier") === "F"
overallTier === "F" &&
(proofTier === "F" || ["missing", "mock_only", "insufficient"].includes(proofStatus))
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve old F-rated PR promotion selection

For stale external PR reports that predate pr_rating_proof / real_behavior_proof_status but do record pr_rating_overall: F (or an Overall tier F), this predicate now returns false because the proof tier/status is blank. The apply path would treat the same report as missing proof when the Real Behavior Proof section is absent and would promote it as low_signal_unmergeable_pr if selected, but scheduled apply only sees numbers from this workflow utility, so those older F-rated reports are skipped indefinitely. Please default absent proof metadata for PRs to the same missing-proof state used by apply.

Useful? React with 👍 / 👎.

Comment thread src/clawsweeper.ts
{ reportDirs: [itemsDir, closedDir] },
);
if (promotion) {
if (promotion && closeReasonEnabled(promotion.closeReason, applyCloseReasons)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Record filtered live promotion checks

When a filtered apply run selects an ambiguous promotion because an enabled outcome is possible (for example --apply-close-reasons low_signal_unmergeable_pr) but live hydration resolves it to a disabled reason such as duplicate_or_superseded, this guard drops the promotion without recording a skip or apply_checked_at. The loop later continues as a non-close item, so cursor rotation still sees the record as unchecked and can keep selecting the same disallowed PR ahead of later enabled low-signal candidates. Record a checked skip for disabled resolved reasons so filtered runs can make progress.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit dda199e into main Jul 9, 2026
9 checks passed
@steipete
steipete deleted the fix/promotion-close-reasons branch July 9, 2026 16:44
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
* fix: preserve promotion close semantics

* fix: gate resolved promotion reasons

* fix: preserve no-diff promotion precedence

* fix: block unsafe promotion fallthrough

* fix: align low-signal promotion selection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant