Skip to content

Fix: Guard superseded PR closes against unsafe replacements - #198

Merged
clawsweeper[bot] merged 3 commits into
openclaw:mainfrom
brokemac79:codex/fix-unsafe-superseded-close
May 25, 2026
Merged

clawsweeper[bot] merged 3 commits into
openclaw:mainfrom
brokemac79:codex/fix-unsafe-superseded-close

Conversation

@brokemac79

@brokemac79 brokemac79 commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #197

Summary

  • Adds apply-time validation for PR-to-PR duplicate/superseded close targets.
  • Refuses to close a PR against a linked replacement that is closed unmerged, unreadable, missing positive real behavior proof, F-rated, draft, not cleanly mergeable, or already has its own high-confidence close report.
  • Keeps the close path open for merged replacements or open replacements that are cleanly mergeable and proof-positive.
  • Protects the same-author issue/PR pair preflight so the issue side does not close if the PR side points at an unsafe replacement.
  • Updates the review prompt and README with the safe canonical PR rule.

Why

ClawSweeper could previously close a PR as duplicate/superseded by another PR even when the replacement was itself closed unmerged or otherwise unsafe. That can hide useful contributor work behind a canonical target that will never land.

Real behavior proof

Head tested: 1bcf6fcc76.

The changed close path was exercised through the real apply-decisions dry-run path using controlled GitHub fixtures. The proof-positive replacement case still closes, while the no-proof replacement case stays open.

Relevant terminal output from the dry-run regression run:

[apply] ... would close #332 ... counts={"review_comment_synced":1,"closed":1}
[apply] ... finished apply ... counts={"review_comment_synced":1,"kept_open":1}
? apply-decisions promotes PRs superseded by linked pull requests
? apply-decisions does not promote PRs superseded by no-proof linked pull requests
? apply-decisions does not promote PRs superseded by unsafe linked pull requests
? apply-decisions does not promote PRs superseded by F-rated linked pull requests
? apply-decisions does not promote PRs superseded by section-only unsafe linked reports
? apply-decisions promotes PRs when live proof labels supersede stale linked reports
? apply-decisions does not promote PRs when live labels supersede stale proof reports
? tests 22
? pass 22
? fail 0

That confirms the specific ClawSweeper review concern: an open, clean canonical replacement PR with no positive proof no longer causes the stale source PR to close.

Validation

  • pnpm run format
  • pnpm run build:all
  • pnpm run format:check
  • pnpm run lint
  • node --test --test-name-pattern "no-proof linked|same-author pair close when PR supersession is unsafe|unrelated unsafe|non-clean linked|close comment|section-only unsafe|live labels supersede stale proof|unsafe linked|closed unmerged|bare cluster ref|cannot be read|already proposed for close|skipped close proposal|F-rated|live proof labels|unknown-mergeability|superseded by linked pull requests" test/clawsweeper.test.ts
  • git diff --check
  • codex review --uncommitted via the codex-review helper: clean, no accepted/actionable findings

pnpm run check also got through active-surface checks, limits, build, lint, and most unit tests, but still hits the existing Windows-local failures unrelated to this change: /usr/bin/git is missing for one subprocess test, and a Unix file-mode assertion differs on Windows.

@clawsweeper

clawsweeper Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed. Reviewed May 25, 2026, 11:04 AM ET / 15:04 UTC.

Summary
The branch adds safe-canonical validation for duplicate/superseded PR closes, updates review policy docs, and expands apply-decision regression tests.

Reproducibility: yes. Current main's linked PR supersession path is source-reproducible as accepting an open or merged linked PR with only a supersession signal, and the PR proof exercises the apply-decisions dry-run path for proof-positive versus no-proof replacements.

Review metrics: 1 noteworthy metric.

  • Changed surface: 4 files affected. The runtime change is focused, but it touches the apply path that can close GitHub PRs.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

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

Risk before merge

  • Merging intentionally changes apply-lane automation: some stale PR-to-PR duplicate closes will now stay open unless the replacement is merged or clean, proof-positive, and otherwise viable.

Maintainer options:

  1. Accept the stricter close guard (recommended)
    Merge after checks if maintainers agree that PR-to-PR supersession closes must require a merged or clean proof-positive replacement PR.
  2. Request a production-style dry-run sample
    Before merge, maintainers can ask for one more dry-run against recent state records to estimate close-volume impact.
  3. Pause if the policy is too strict
    Pause or close the PR if maintainers want unknown mergeability or missing proof to remain eligible for duplicate close promotion.

Next step before merge
No repair lane is needed; this automerge-opted PR has no actionable finding and should proceed through normal checks, exact-head mergeability, and maintainer policy acceptance.

Security
Cleared: No concrete security or supply-chain concern was found; the diff narrows GitHub close automation and does not add dependencies, workflow permissions, or secret handling.

Review details

Best possible solution:

Merge the guard once normal exact-head checks pass, keeping PR-to-PR duplicate closes limited to merged or clean proof-positive canonical replacement PRs.

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

Yes. Current main's linked PR supersession path is source-reproducible as accepting an open or merged linked PR with only a supersession signal, and the PR proof exercises the apply-decisions dry-run path for proof-positive versus no-proof replacements.

Is this the best way to solve the issue?

Yes. The branch fixes the narrow apply safety gap at both promotion and final apply gates, documents the policy, and adds regression coverage without changing unrelated close lanes.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 3b76d34e75b9.

Label changes

Label justifications:

  • P1: The PR addresses an automation bug that can close useful contributor PRs against unsafe replacement PRs.
  • merge-risk: 🚨 automation: Merging changes apply-lane close eligibility and can alter which GitHub PRs ClawSweeper auto-closes or keeps open.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 🚀 automerge armed: This PR is in ClawSweeper's automerge lane. Sufficient (terminal): The PR body includes terminal dry-run output from the real apply-decisions path showing the changed close behavior after the fix; the latest head only adds extra test coverage on top of that runtime proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes terminal dry-run output from the real apply-decisions path showing the changed close behavior after the fix; the latest head only adds extra test coverage on top of that runtime proof.
Evidence reviewed

What I checked:

  • Repository policy read: AGENTS.md was read fully; its conservative, automation-safe apply-lane guidance is relevant to this review. (AGENTS.md:1, 3b76d34e75b9)
  • Current main lacks the guard: Current main's linkedPullRequestSupersession path accepts a linked PR when it is open or merged and has a supersession signal; it does not check proof, rating, draft state, clean mergeability, or proposed-close status. (src/clawsweeper.ts:10100, 3b76d34e75b9)
  • PR adds safe-canonical validation: The PR head adds unsafeCanonicalPullRequestReason, blocking closed-unmerged, draft, unknown or non-clean, F-rated, proposed-close, unreadable, and no-positive-proof canonical replacement PRs while allowing merged replacements. (src/clawsweeper.ts:10206, 433e98592c63)
  • Apply integration: The PR wires duplicateCanonicalPullRequestBlockReason into both close-gate preflight and final apply, and passes open/closed report directories into stale PR close promotion. (src/clawsweeper.ts:13296, 433e98592c63)
  • Regression coverage: The PR adds apply-decision cases for proof-positive, merged, no-proof, needs-proof, F-rated, stale-report, unknown/non-clean, closed-unmerged, unreadable, proposed-close, and unsafe same-author pair paths. (test/clawsweeper.test.ts:8079, 433e98592c63)
  • Real behavior proof: The PR body and follow-up comment report terminal dry-run output from the real apply-decisions path showing proof-positive replacement closes and no-proof replacement stays open, with 22 focused tests passing. (1bcf6fcc76fa)

Likely related people:

  • steipete: git blame shows the current linkedPullRequestSupersession and stale PR close promotion lane came from the stale PR close lanes commit. (role: introduced behavior; confidence: high; commits: 97885cf4e291; files: src/clawsweeper.ts, test/clawsweeper.test.ts)
  • Takhoffman: Recent merged work touched adjacent review labels, merge drift, metrics, and AGENTS policy review surfaces around the same review/apply machinery. (role: recent area contributor; confidence: medium; commits: 77e35f078a76, ca82d682d01e, 1734b1683911; files: src/clawsweeper.ts, test/clawsweeper.test.ts, prompts/review-item.md)
  • brokemac79: A prior merged related-context change is adjacent to the richer related PR evidence that exposed this close-policy bug. (role: adjacent contributor; confidence: medium; commits: 68065f816acf; files: src/clawsweeper.ts, test/clawsweeper.test.ts, prompts/review-item.md)
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.

@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. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels May 25, 2026
@clawsweeper

clawsweeper Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🥚 common Frosted Test Hopper

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🥚 common.
Trait: hums during re-review.
Image traits: location release reef; accessory little merge flag; palette coral, mint, and warm cream; mood watchful; pose holding its accessory up for inspection; shell translucent glimmer shell; lighting bright celebratory glints; background small review tokens.
Share on X: post this hatch
Copy: My PR egg hatched a 🥚 common Frosted Test Hopper in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@brokemac79

Copy link
Copy Markdown
Contributor Author

Addressed ClawSweeper's proof/correctness finding in 1bcf6fcc76.

The open replacement path now requires positive proof for unmerged canonical PRs. Merged replacements are still allowed, but an open/clean replacement with no proof: sufficient / proof: override label and no durable sufficient/override report is blocked.

Added regression coverage for the exact no-proof linked PR case, and updated the PR body with terminal proof from the dry-run apply path showing:

  • proof-positive replacement: would close #332
  • no-proof replacement: kept_open
  • focused regression suite: 22 tests passing

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. labels May 25, 2026
@Takhoffman

Copy link
Copy Markdown
Contributor

@clawsweeper automerge

@clawsweeper

clawsweeper Bot commented May 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞✅
ClawSweeper merged this PR after the passing review.

Source: clawsweeper[bot]
Feedback: structured ClawSweeper verdict: pass (sha=433e98592c634234f07db70f96613ea7c4b5399a)
Merge status: merged by ClawSweeper automerge
Merged at: 2026-05-25T15:09:03Z
Merge commit: f2ec021eb55c

What merged:

  • The branch adds safe-canonical validation for duplicate/superseded PR closes, updates review policy docs, and expands apply-decision regression tests.
  • Reproducibility: yes. Current main's linked PR supersession path is source-reproducible as accepting an open ... nd the PR proof exercises the apply-decisions dry-run path for proof-positive versus no-proof replacements.

Automerge notes:

  • PR branch already contained follow-up commit before automerge: Require proof-positive superseded PR targets
  • PR branch already contained follow-up commit before automerge: Fix: Guard superseded PR closes against unsafe replacements

The automerge loop is complete.

Automerge progress:

  • 2026-05-25 14:38:06 UTC review queued 1bcf6fcc76fa (queued)
  • 2026-05-25 14:45:34 UTC review passed 1bcf6fcc76fa (structured ClawSweeper verdict: pass (sha=1bcf6fcc76fa195b5be6c0de95ece664f885c...)
  • 2026-05-25 14:53:48 UTC review queued 433e98592c63 (after repair)
  • 2026-05-25 15:08:50 UTC review passed 433e98592c63 (structured ClawSweeper verdict: pass (sha=433e98592c634234f07db70f96613ea7c4b53...)
  • 2026-05-25 15:09:05 UTC merged 433e98592c63 (merged by ClawSweeper automerge)

@Takhoffman Takhoffman changed the title Guard superseded PR closes against unsafe replacements Fix: Guard superseded PR closes against unsafe replacements May 25, 2026
@clawsweeper clawsweeper Bot added clawsweeper:automerge Maintainer opted this ClawSweeper PR into bounded ClawSweeper-reviewed automerge rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 🚀 automerge armed This PR is in ClawSweeper's automerge lane. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels May 25, 2026
@clawsweeper
clawsweeper Bot force-pushed the codex/fix-unsafe-superseded-close branch from 1bcf6fc to 433e985 Compare May 25, 2026 14:53
@clawsweeper
clawsweeper Bot merged commit f2ec021 into openclaw:main May 25, 2026
6 checks passed
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
…#198)

Summary:
- The branch adds safe-canonical validation for duplicate/superseded PR closes, updates review policy docs, and expands apply-decision regression tests.
- Reproducibility: yes. Current main's linked PR supersession path is source-reproducible as accepting an open ... nd the PR proof exercises the apply-decisions dry-run path for proof-positive versus no-proof replacements.

Automerge notes:
- PR branch already contained follow-up commit before automerge: Require proof-positive superseded PR targets
- PR branch already contained follow-up commit before automerge: Fix: Guard superseded PR closes against unsafe replacements

Validation:
- ClawSweeper review passed for head 433e985.
- Required merge gates passed before the squash merge.

Prepared head SHA: 433e985
Review: openclaw#198 (comment)

Co-authored-by: brokemac79 <[email protected]>
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com>
Approved-by: takhoffman
Co-authored-by: takhoffman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:automerge Maintainer opted this ClawSweeper PR into bounded ClawSweeper-reviewed automerge merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. P1 Urgent regression or broken agent/channel workflow affecting real users now. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 🚀 automerge armed This PR is in ClawSweeper's automerge lane.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ClawSweeper can close a PR as superseded by another PR that is later closed unmerged

2 participants