Skip to content

[codex] Prevent stale review comment sync overwrites - #389

Merged
clawsweeper[bot] merged 1 commit into
mainfrom
feature/clawsweeper-stale-comment-sync-guard
Jul 3, 2026
Merged

clawsweeper[bot] merged 1 commit into
mainfrom
feature/clawsweeper-stale-comment-sync-guard

Conversation

@hxy91819

@hxy91819 hxy91819 commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Prevent stale apply/comment-sync runs from overwriting a newer durable ClawSweeper review comment.
  • Trust only pull-request review comments that are bot-owned, have the durable review marker as the final footer, and expose a trailing automation verdict marker with a newer reviewed_at.
  • Add regression coverage for the real overwrite race plus untrusted/user-authored markers, forged marker prose, forged review footers, and issue comments.

Root cause

A long-running apply/comment-sync job could load older state and later PATCH the durable review comment after a newer exact-review run had already updated it. Because the sync path compared desired body/hash metadata but did not check live review freshness, it could roll the public comment from a newer review back to an older one.

Validation

  • pnpm run build
  • pnpm exec node --test test/clawsweeper.test.ts
  • pnpm run format:check
  • autoreview --mode local --codex-bin /root/.nvm/versions/node/v22.21.1/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex ...

Autoreview

Codex autoreview initially found trust-boundary issues in the freshness parser. Accepted and fixed:

  • Do not trust user-authored marker comments.
  • Do not trust marker-shaped text in generated review prose.
  • Do not apply PR verdict-tail freshness logic to issue comments.
  • Require the durable clawsweeper-review marker to be the final footer before trusting the preceding verdict marker.

Final autoreview result: autoreview clean: no accepted/actionable findings reported.

@clawsweeper

clawsweeper Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed. Reviewed July 3, 2026, 8:58 AM ET / 12:58 UTC.

Summary
The PR adds a pull-request-only live-review freshness guard to apply/comment-sync and regression tests for stale overwrite and forged marker cases.

Reproducibility: yes. from source inspection: current main can reach upsertReviewComment from an older report when the rendered body differs from a newer durable PR review comment. I did not run the new tests because this review is read-only.

Review metrics: 2 noteworthy metrics.

  • Changed files: 2 files, 622 insertions, 0 deletions. The patch is concentrated in the apply path and one test file, so review should focus on automation behavior rather than broad product scope.
  • Regression cases: 4 new apply/comment-sync tests. The added cases cover the overwrite race and the main trust-boundary failures that could make marker freshness unsafe.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🌊 off-meta tidepool
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] Because this changes the apply/comment-sync write gate and verdict-marker parser, a parser mistake could suppress a legitimate durable comment refresh or leave stale public review state in place.

Maintainer options:

  1. Merge after checks and maintainer acceptance (recommended)
    If maintainers accept the marker-tail freshness contract, the current green checks and focused regression tests make this a reasonable automation-risk tradeoff.
  2. Ask for staged apply proof
    Maintainers can request redacted apply/comment-sync output showing an older report skipping instead of patching a newer durable PR review comment.
  3. Pause if marker freshness is disputed
    If live comment freshness should not be inferred from verdict marker tails, pause this PR and choose a different durable freshness source.

Next step before merge

  • [P2] No repair lane is needed; this automerge-requested PR has no line-level findings and should proceed through the existing maintainer, mergeability, and check gates.

Security
Cleared: The diff adds no dependencies, workflow permission changes, secret handling, or external code execution; the new parser tightens a bot-owned comment trust boundary.

Review details

Best possible solution:

Land the guarded apply/comment-sync path after CI and maintainer acceptance, preserving the marker-tail trust constraints and regression coverage.

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

Yes from source inspection: current main can reach upsertReviewComment from an older report when the rendered body differs from a newer durable PR review comment. I did not run the new tests because this review is read-only.

Is this the best way to solve the issue?

Yes; the guard sits immediately before the durable comment write and uses PR review marker freshness rather than mutable comment updated_at, which matches the reported race boundary.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P1: The PR addresses an automation race that can roll back the public ClawSweeper review verdict on active pull requests.
  • merge-risk: 🚨 automation: The diff changes the durable review comment sync gate and marker parser used by ClawSweeper apply automation.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR author has MEMBER association, so the external-contributor proof gate does not apply; the PR body reports build, focused unit test, format check, and autoreview validation.
Evidence reviewed

What I checked:

  • Repository policy read: AGENTS.md was read fully; its conservative automation-safety guidance applies because this PR changes ClawSweeper apply/comment-sync behavior. (AGENTS.md:1, b1e238da6eed)
  • Current write boundary: Current main computes durable review comment sync need and reaches upsertReviewComment when the live body differs, without checking whether the live PR review marker is newer than the local report. (src/clawsweeper.ts:18105, b1e238da6eed)
  • PR guard implementation: The PR adds newestReviewMarkerReviewedAt and staleReviewCommentSyncReason, then skips body sync when the live durable PR review marker has a newer reviewed_at than the report. (src/clawsweeper.ts:15416, b01772a76aee)
  • Regression coverage: The diff adds four apply/comment-sync tests covering the overwrite race, untrusted user-authored markers, forged marker placement, and issue comments. (test/clawsweeper.test.ts:917, b01772a76aee)
  • PR state and checks: GitHub reports the PR as mergeable, not draft, and the visible CI/CodeQL status rollup succeeded; the author also requested automerge after the first ClawSweeper review. (b01772a76aee)
  • Adjacent merged work: Merged PR fix: prevent stale PR review labels from persisting #388 fixed stale PR head/label publication, but that merged code does not cover the older-report-overwrites-newer-review-comment race addressed here. (src/clawsweeper.ts:15171, b1e238da6eed)

Likely related people:

  • vincentkoc: Blame and PR metadata tie the durable review marker, marker rendering, comment lookup, and original apply sync write path to the merged review refactor. (role: introduced behavior; confidence: medium; commits: a6ee02e323c1; files: src/clawsweeper.ts)
  • brokemac79: Recent commits changed PR verdict marker metadata, close-marker normalization, and durable comment round-trip handling in the same apply/comment-sync area. (role: recent area contributor; confidence: high; commits: 84796f0c9b0c, 542a35738928; files: src/clawsweeper.ts, test/clawsweeper.test.ts)
  • momothemage: The immediately preceding merged change added stale PR head and review-label handling in the same apply path. (role: adjacent owner; confidence: high; commits: b1e238da6eed; files: src/clawsweeper.ts)
  • Dallin Romney: Recent history links apply-decision test restructuring and label-sync behavior to the test surface touched by this PR. (role: recent test and sync contributor; confidence: medium; commits: b75626e4df03, 323f7bdf7236; files: src/clawsweeper.ts, test/clawsweeper.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.

@clawsweeper clawsweeper Bot added 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. 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
@hxy91819
hxy91819 marked this pull request as ready for review July 3, 2026 12:55
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@hxy91819

hxy91819 commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper automerge

@clawsweeper

clawsweeper Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞✅
ClawSweeper merged this PR after the passing review.

Source: clawsweeper[bot]
Feedback: structured ClawSweeper verdict: pass (sha=b01772a76aee0c84255c079cc6613ddc031c1948)
Merge status: merged by ClawSweeper automerge
Merged at: 2026-07-03T12:59:55Z
Merge commit: f7e8b13d0eb3

What merged:

  • The PR adds a pull-request-only live-review freshness guard to apply/comment-sync and regression tests for stale overwrite and forged marker cases.
  • Reproducibility: yes. from source inspection: current main can reach upsertReviewComment from an older repor ... ffers from a newer durable PR review comment. I did not run the new tests because this review is read-only.

Automerge notes:

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

The automerge loop is complete.

Automerge progress:

  • 2026-07-03 12:58:13 UTC review queued b01772a76aee (queued)
  • 2026-07-03 12:59:45 UTC review passed b01772a76aee (structured ClawSweeper verdict: pass (sha=b01772a76aee0c84255c079cc6613ddc031c1...)
  • 2026-07-03 12:59:56 UTC merged b01772a76aee (merged by ClawSweeper automerge)

@clawsweeper clawsweeper Bot added the clawsweeper:automerge Maintainer opted this ClawSweeper PR into bounded ClawSweeper-reviewed automerge label Jul 3, 2026
@clawsweeper
clawsweeper Bot merged commit f7e8b13 into main Jul 3, 2026
12 checks passed
@clawsweeper
clawsweeper Bot deleted the feature/clawsweeper-stale-comment-sync-guard branch July 3, 2026 12:59
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
Summary:
- The PR adds a pull-request-only live-review freshness guard to apply/comment-sync and regression tests for stale overwrite and forged marker cases.
- Reproducibility: yes. from source inspection: current main can reach upsertReviewComment from an older repor ... ffers from a newer durable PR review comment. I did not run the new tests because this review is read-only.

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

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

Prepared head SHA: b01772a
Review: openclaw#389 (comment)

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