Skip to content

fix: prevent stale PR review labels from persisting - #388

Merged
clawsweeper[bot] merged 1 commit into
mainfrom
feature/clawsweeper-stale-review-verdict
Jul 3, 2026
Merged

clawsweeper[bot] merged 1 commit into
mainfrom
feature/clawsweeper-stale-review-verdict

Conversation

@momothemage

@momothemage momothemage commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Detect open PR reports where the stored pull_head_sha no longer matches the live PR head.
  • Stop syncing old PR review-derived labels in that state, and remove stale rating/status/merge-risk/proof/showcase labels while preserving generic triage labels.
  • Replace the durable review comment with a stale-review notice that records the reviewed and current head SHAs instead of republishing the old verdict.

Problem

Refs openclaw/openclaw#99335. That PR had a durable ClawSweeper review for an older head while the PR branch had moved, but the apply path could still leave review-derived labels from the old verdict on the live PR.

Why this layer

apply-decisions is the path that mutates GitHub labels and durable comments from stored reports. Guarding stale heads there prevents old review state from being published or retained while the fresh review catches up.

Validation

  • PATH=/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin:/Users/mauriceniu/.cache/codex-runtimes/codex-primary-runtime/dependencies/bin:$PATH node --test test/apply-label-sync.test.ts
  • PATH=/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin:/Users/mauriceniu/.cache/codex-runtimes/codex-primary-runtime/dependencies/bin:$PATH pnpm run check
  • git diff --check

Staged Apply Proof

This is a staged apply run using the real apply-decisions path with a mock gh shim, so no live GitHub labels or comments were mutated. The scenario models a durable report reviewed at reviewed-old-head while the live PR head has moved to live-new-head.

Command:

PATH=/Users/mauriceniu/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin:/Users/mauriceniu/.cache/codex-runtimes/codex-primary-runtime/dependencies/bin:$PATH node --input-type=module <staged stale-head apply proof>

Output:

[apply] starting apply: files=1 dry_run=false apply_kind=issue sync_comments_only=true item_numbers=99335
[apply] finished apply closed=0/10 processed=1/1 counts={"review_comment_synced":1}
staged apply proof: PASS
reviewed head: reviewed-old-head
live head: live-new-head
removed review-derived labels: merge-risk: 🚨 session-state, proof: sufficient, rating: 🧂 unranked krab, status: 🔁 re-review loop
preserved labels after apply: ["P2"]
updated report current_pull_head_sha: live-new-head
stale comment status: Codex review: stale review; fresh review needed.
stale comment marker: <!-- clawsweeper-review-status:stale item=99335 reviewed_sha=reviewed-old-head current_sha=live-new-head reason=stale_head -->
old verdict marker present after patch: false

The staged run confirms the stale-head path removes only review-derived PR labels, preserves the generic P2 label, records the current live head, replaces the durable comment with the stale-review notice, and does not keep publishing the old clawsweeper-verdict marker.

@momothemage
momothemage marked this pull request as ready for review July 3, 2026 11:44
@clawsweeper

clawsweeper Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 3, 2026, 7:58 AM ET / 11:58 UTC.

Summary
The PR adds stale pull-request head detection to apply-decision label/comment sync and covers it with focused apply-label-sync tests.

Reproducibility: yes. at source level: current main records pull_head_sha and live PR head data, but the apply path syncs PR readiness labels before comparing those values. The PR body also includes staged after-fix apply output for the stale-head scenario.

Review metrics: 2 noteworthy metrics.

  • Patch surface: 2 files changed, +369/-90. The functional change is confined to the apply-decision path plus one narrow test file.
  • Stale apply proof: 4 review-derived labels removed, 1 priority label preserved. The staged output demonstrates the label behavior maintainers need before merging an apply-lane mutation change.

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

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

Rank-up moves:

  • none.

Risk before merge

  • [P1] This changes the apply lane that mutates live GitHub labels and durable review comments; staged proof covers the intended stale-head path, but maintainers should still accept the live rollout risk explicitly.

Maintainer options:

  1. Merge after reviewing staged proof (recommended)
    Maintainers can accept the remaining live-rollout risk if the staged apply transcript and focused test are enough evidence for this GitHub-mutating path.
  2. Ask for stronger apply proof
    If maintainers want more confidence, ask for an additional dry-run or controlled live apply transcript showing the same label and comment outcome.

Next step before merge

  • No automated repair is needed; the remaining step is maintainer acceptance of an apply-lane automation change with staged proof.

Security
Cleared: No dependency, workflow, secret-handling, or supply-chain changes were found; the relevant concern is automation behavior, covered separately as merge risk.

Review details

Best possible solution:

Land the apply-layer stale-head guard with the focused test and staged proof so stale PR reports remove old review-derived labels, preserve generic triage labels, and replace the old verdict with a stale-review notice.

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

Yes, at source level: current main records pull_head_sha and live PR head data, but the apply path syncs PR readiness labels before comparing those values. The PR body also includes staged after-fix apply output for the stale-head scenario.

Is this the best way to solve the issue?

Yes. Guarding apply-decisions is the narrow mutation-boundary fix because that is where stored review reports become live labels and durable comments.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes staged terminal output from the real apply-decisions path showing stale labels removed, P2 preserved, current head recorded, and the stale-review comment written.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes staged terminal output from the real apply-decisions path showing stale labels removed, P2 preserved, current head recorded, and the stale-review comment written.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: A stale ClawSweeper PR verdict can leave misleading proof, rating, status, or merge-risk labels on live PRs after the branch head changes.
  • merge-risk: 🚨 automation: The diff changes apply-decision behavior that mutates GitHub labels and durable review comments, which green CI alone does not fully settle.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes staged terminal output from the real apply-decisions path showing stale labels removed, P2 preserved, current head recorded, and the stale-review comment written.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes staged terminal output from the real apply-decisions path showing stale labels removed, P2 preserved, current head recorded, and the stale-review comment written.
Evidence reviewed

What I checked:

  • Repository policy read: AGENTS.md was read fully; its conservative apply-lane guidance applies because this PR changes GitHub label/comment mutation. (AGENTS.md:1, f2fc64e0bc74)
  • Current main stale-label path: Current main syncs PR proof, rating, status, feature showcase, Telegram-visible-proof labels for open PR reports before any stored-head versus live-head check. (src/clawsweeper.ts:17435, f2fc64e0bc74)
  • Current main head metadata: Current main already records both live PR head data and report pull_head_sha, so apply has the data needed to detect stale PR reviews. (src/clawsweeper.ts:15159, f2fc64e0bc74)
  • PR stale-head guard: The PR adds stalePullRequestReviewHead plus helpers to identify stale PR review labels and render a stale-review comment with reviewed/current SHAs. (src/clawsweeper.ts:15177, 98dcca704dae)
  • PR apply integration: The PR routes stale open PR reports through stale label cleanup, records current_pull_head_sha, and blocks normal current-review label sync when the reviewed head is stale. (src/clawsweeper.ts:17527, 98dcca704dae)
  • Focused test coverage: The new test simulates an old-head report with a new live head and asserts removal of merge-risk, proof, rating, and status labels while preserving P2 and replacing the durable comment with a stale-review notice. (test/apply-label-sync.test.ts:269, 98dcca704dae)

Likely related people:

  • Peter Steinberger: Git blame ties the current pull_head_sha helpers and PR label-sync apply path to commit 30163df, which introduced the durable exact queue behavior this PR builds on. (role: introduced behavior; confidence: high; commits: 30163dfd667b; files: src/clawsweeper.ts)
  • RomneyDa: Recent merged work in Fix label sync after review placeholder drift #323 repaired label sync after review placeholder drift, and test: split apply policy tests #363 created the focused apply-label-sync test home touched here. (role: recent area contributor; confidence: high; commits: b75626e4df03, e73fecd30a70; files: src/clawsweeper.ts, test/apply-label-sync.test.ts)
  • brokemac79: Recent apply queue rotation work touched the same apply-decisions area and is useful routing context for apply-lane behavior. (role: recent adjacent contributor; confidence: medium; commits: 5bdf6f31c904; 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.

@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 Jul 3, 2026
@momothemage

Copy link
Copy Markdown
Contributor Author

Added staged apply proof to the PR body showing the stale-head path removes only old review-derived labels, preserves P2, records the live head, and replaces the stale durable comment without an old verdict marker.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 3, 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.

@momothemage

Copy link
Copy Markdown
Contributor Author

@clawsweeper automerge

@clawsweeper

clawsweeper Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞✅
Maintainer-approved ClawSweeper automerge is complete.

Approver: momothemage
Head: 98dcca704dae
Merge status: merged by ClawSweeper automerge
Merged at: 2026-07-03T12:01:14Z
Merge commit: b1e238da6eed

What merged:

  • Merged fix: prevent stale PR review labels from persisting after ClawSweeper review.

Automerge notes:

  • No ClawSweeper repair was needed after automerge opt-in.

The automerge loop is complete.

Automerge progress:

  • 2026-07-03 11:59:06 UTC review queued 98dcca704dae (queued)
  • 2026-07-03 12:01:16 UTC merged 98dcca704dae (merged by ClawSweeper automerge)

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. clawsweeper:automerge Maintainer opted this ClawSweeper PR into bounded ClawSweeper-reviewed automerge status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:human-review ClawSweeper automerge is paused for maintainer review 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 Jul 3, 2026
@clawsweeper

clawsweeper Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🦞✅
ClawSweeper is pausing this repair loop for human review.

Source: clawsweeper[bot]
Reason: - No automated repair is needed; the remaining step is maintainer acceptance of an apply-lane automation change with staged proof.; Cleared: No dependency, workflow, secret-handling, or supply-chain changes were found; the relevant concern is automation behavior, covered separately as merge risk. (sha=98dcca704dae06980cdb7472ba6713290b67c306)

Why human review is needed:
This item has security-sensitive risk. ClawSweeper is pausing instead of making an autonomous change that could affect trust, credentials, permissions, or exposure.

What the maintainer can do as a next step:
If the maintainer accepts the current risk and wants ClawSweeper to continue merge gates, comment @clawsweeper approve. If the security-sensitive detail still needs changes, describe the safe path or push the fix, then comment @clawsweeper automerge. If the risk should not be automated, keep the PR paused for manual review or comment @clawsweeper stop.

I added clawsweeper:human-review and left the final call with a maintainer.

@momothemage

Copy link
Copy Markdown
Contributor Author

@clawsweeper approve

azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
Summary:
- Merged fix: prevent stale PR review labels from persisting after ClawSweeper review.

Automerge notes:
- No ClawSweeper repair was needed after automerge opt-in.

Validation:
- ClawSweeper review passed for head 98dcca7.
- Required merge gates passed before the squash merge.

Prepared head SHA: 98dcca7
Review: openclaw#388 (comment)

Co-authored-by: momothemage <[email protected]>
Approved-by: momothemage
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: 🐚 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant