Skip to content

fix(review): clean up superseded review-started placeholder comments - #710

Merged
steipete merged 3 commits into
mainfrom
fix/placeholder-comment-cleanup
Jul 20, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/placeholder-comment-cleanup

Conversation

@steipete

@steipete steipete commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Stops stale "ClawSweeper status: review started." placeholder comments from piling up on reviewed items.

Motivating case: openclaw/openclaw#110918 (2026-07-18) — after the durable review comment (created 19:32Z) was updated in place at 22:13Z, two stale placeholders from failed retry attempts (21:41Z, 22:06Z) remained as separate comments. Correctness was unaffected (placeholder recovery keys on the latest bot comment), but the clutter is user-visible on busy PRs.

Change

After upsertReviewComment successfully publishes the durable review comment in the apply flow, cleanupSupersededReviewPlaceholderComments deletes superseded placeholder comments via DELETE /repos/{owner}/{repo}/issues/comments/{id} — the same issues:write surface the existing expired-lease reap already uses.

Safety rails (supersededReviewPlaceholderCommentIds):

  • only comments from the ClawSweeper bot login set (canPatchReviewComment);
  • only bodies that start with the placeholder status line — the durable review comment never does, and its <!-- clawsweeper-review item=N --> marker is an additional exclusion;
  • skips the just-upserted durable comment and the currently held apply mutation lease comment;
  • keeps any placeholder with an unexpired lease (it may belong to a racing worker on a newer revision); only provably superseded placeholders — expired lease or marker-less legacy body — are deleted;
  • sweep failures log and never fail the publish (runtime-budget errors still propagate).

Why no placeholder reuse on retry

Refreshing a surviving placeholder in place (PATCH) was considered and rejected: the review-start lease election picks the lowest server-assigned comment id, so it needs a distinct comment per contender. Two racing workers PATCHing the same comment could both validate ownership and both proceed. Acquisition keeps POSTing a fresh comment; a source comment and a structural test now pin that down. Accumulation stays bounded because every durable-comment publish sweeps the leftovers (a placeholder's lease TTL is ~review timeout + 10 min, so earlier failed attempts are provably expired by then).

Tests

  • supersededReviewPlaceholderCommentIds unit coverage: deletes expired/legacy bot placeholders only; keeps unexpired leases, non-bot authors, keep-listed ids, and never the durable review comment (including a durable body that opens with the placeholder line).
  • Structural test: lease acquisition still POSTs per contender (no PATCH reuse), and the apply publish path calls the sweep right after the durable comment sync.

Build, lint, format, and all touched suites green (review-comment-rendering, clawsweeper-action-ledger, review-placeholder-recovery). Full pnpm run check runs tripped only the known host-load timing flake in failed-review-retry (2.2s runtime-budget test, host load avg 200+ from concurrent workers; same class #709 hardens) — passes on isolated rerun. Autoreview (Codex) clean on the branch diff.

Changelog: one-line Fixed entry under Unreleased.

@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: 017736150e

ℹ️ 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 thread src/clawsweeper.ts
Comment on lines +20800 to +20802
if (error instanceof GitHubRuntimeBudgetError) throw error;
// A failed sweep must never fail the publish; the next apply retries it.
console.error(

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 Retry failed sweeps when the durable comment already matches

When comment enumeration or a placeholder DELETE fails transiently, this function swallows the error and the apply run still records the durable comment as synchronized. On the next apply, that comment body and metadata already match, so needsReviewCommentBodySync is false and the only call to this cleanup routine is skipped; for close proposals the report may also be archived immediately. Thus the promised retry never occurs and the stale placeholder can remain permanently. Persist a cleanup-pending state or invoke the sweep even when no durable-body write is needed.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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 19, 2026
@clawsweeper

clawsweeper Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 19, 2026, 5:43 PM ET / 21:43 UTC.

Summary
Adds a post-publish sweep for expired or legacy ClawSweeper review-start placeholder comments, with helper coverage and a changelog entry.

Reproducibility: yes. in source, with medium confidence: a cleanup list or DELETE failure followed by an apply where the durable comment is already synchronized skips the proposed cleanup trigger. A live GitHub retry sequence was not provided as real-behavior proof.

Review metrics: 1 noteworthy metric.

  • Patch surface: 190 additions across 3 files. The change combines deletion behavior, helper logic, structural coverage, and a release-owned documentation file.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🦪 silver shellfish
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:

  • Ensure failed cleanup is retried when the durable review comment already matches.
  • [P1] Add a focused regression test for that sequence and remove the release-owned changelog entry.
  • Post redacted real-run evidence showing stale placeholders are removed while an active lease is retained; updating the PR body should trigger a fresh review, or a maintainer can comment @clawsweeper re-review.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR describes unit suites and CI-style validation, but does not include after-fix evidence from a real apply/comment-cleanup run; add a redacted live transcript, terminal output, or runtime logs after addressing the retry gap. 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] A transient comment-list or DELETE failure can leave a superseded placeholder permanently because later apply runs may skip the only cleanup call after recognizing that the durable review comment is already synchronized.

Maintainer options:

  1. Retry cleanup after synchronized publishes (recommended)
    Invoke or persist the cleanup so a transient list/delete failure is retried even when the durable review comment already matches on the next apply.
  2. Accept eventual stale placeholders
    Merge the current narrow sweep knowing that a transient cleanup failure can leave visible stale status comments until another durable-comment rewrite occurs.

Next step before merge

  • [P1] The branch needs contributor changes and real apply-path proof before merge; the proof gate cannot be satisfied by an automated repair lane.

Security
Cleared: The patch uses the existing issues-comment write surface and narrows deletion to bot-authored, provably superseded placeholders; no concrete security or supply-chain regression is evident.

Review findings

  • [P2] Retry cleanup after a synchronized durable comment — src/clawsweeper.ts:20735-20813
  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:113
Review details

Best possible solution:

Run the stale-placeholder sweep independently of whether the durable review body needs rewriting, retain the existing lease and bot-author safeguards, add a retry-path regression test, and omit the release-owned changelog edit.

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

Yes in source, with medium confidence: a cleanup list or DELETE failure followed by an apply where the durable comment is already synchronized skips the proposed cleanup trigger. A live GitHub retry sequence was not provided as real-behavior proof.

Is this the best way to solve the issue?

No: sweeping only after a durable-comment write does not reliably solve transient cleanup failures. The narrow maintainable fix is to retry or persist cleanup independently of body synchronization.

Full review comments:

  • [P2] Retry cleanup after a synchronized durable comment — src/clawsweeper.ts:20735-20813
    If comment enumeration or DELETE fails, the error is swallowed and the durable comment is still recorded as synchronized. On a later apply needsReviewCommentBodySync can be false, so this cleanup path is skipped forever and the stale placeholder remains. Run the sweep independently of a body write or persist a pending cleanup state, with a regression test for the retry sequence.
    Confidence: 0.93
  • [P3] Remove the release-owned changelog entry — CHANGELOG.md:113
    Repository policy reserves CHANGELOG.md for release ownership and says normal contributor PRs should preserve release-note context in the PR body or commit message instead. Remove this Unreleased entry from the branch.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P2: The PR fixes a visible automation-quality problem, but the remaining retry gap has limited blast radius and a focused repair path.
  • add merge-risk: 🚨 automation: The new comment-deletion workflow can silently leave review-status artifacts behind after transient GitHub API failures.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR describes unit suites and CI-style validation, but does not include after-fix evidence from a real apply/comment-cleanup run; add a redacted live transcript, terminal output, or runtime logs after addressing the retry gap. 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.

Label justifications:

  • P2: The PR fixes a visible automation-quality problem, but the remaining retry gap has limited blast radius and a focused repair path.
  • merge-risk: 🚨 automation: The new comment-deletion workflow can silently leave review-status artifacts behind after transient GitHub API failures.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR describes unit suites and CI-style validation, but does not include after-fix evidence from a real apply/comment-cleanup run; add a redacted live transcript, terminal output, or runtime logs after addressing the retry gap. 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:

  • Patch cleanup trigger: The proposed helper is called from the durable review-comment publish path, while the supplied review note identifies that later applies can skip this path when the durable comment body already matches. (src/clawsweeper.ts:20735, 017736150e31)
  • Actionable review feedback: The existing review correctly identifies that swallowed enumeration or DELETE failures are not retried when needsReviewCommentBodySync is false, leaving the stale placeholder behind. (src/clawsweeper.ts:20735, 017736150e31)
  • Focused helper coverage: The added unit test verifies candidate selection, but it does not establish retry behavior after a cleanup failure followed by an apply where the durable review comment is already synchronized. (test/review-comment-rendering.test.ts:1235, 017736150e31)
  • Repository policy: The target AGENTS.md treats CHANGELOG.md as release-owned and says normal PRs should not edit it; this branch adds an Unreleased entry. (CHANGELOG.md:113, 017736150e31)

Likely related people:

  • steipete: Authored this review-automation repair and the adjacent merged automation-maintenance PR referenced in the PR discussion; the available context does not establish a stronger current-main owner for this specific path. (role: recent contributor; confidence: low; commits: 017736150e31, d7e01ce59f9d; files: src/clawsweeper.ts, test/review-comment-rendering.test.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.

@steipete
steipete merged commit 24d6273 into main Jul 20, 2026
10 checks passed
@steipete
steipete deleted the fix/placeholder-comment-cleanup branch July 20, 2026 00:57
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
…penclaw#710)

* fix(review): clean up superseded review-started placeholders

* fix(review): drop lease PATCH reuse; sweep placeholders only at publish

* fix(review): sweep placeholders from the pre-mutation comment snapshot
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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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