Skip to content

fix(review): keep background re-review start status in the durable comment - #2086

Merged
obviyus merged 2 commits into
mainfrom
fix/quiet-background-rereview
Nov 5, 2026
Merged

obviyus merged 2 commits into
mainfrom
fix/quiet-background-rereview

Conversation

@steipete

@steipete steipete commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Since #2039, unchanged items are fully re-reviewed on every target-branch commit. Each run posted a new temporary "ClawSweeper status: review started" comment and later deleted it. GitHub notifies every subscriber of a new comment, but not of an edit. Busy target repositories therefore sent one "review started" notification per commit, even when the review outcome didn't change.

User report: openclaw/Peekaboo#1114. A contributor got about 24 notifications on openclaw/Peekaboo#1106, whose timeline had no non-bot events in that window; the completed review and the next start recorded the same source_revision.

Change

  • Background re-reviews: queue-owned background re-reviews of an item that already has a durable review now carry the started lease by editing that durable review comment. The prior review text stays readable and is restored byte for byte on owned cleanup (failure, supersession, expiry). Completion replaces it as before.
  • Unchanged paths: first reviews, explicit @clawsweeper review requests, commands and uncoordinated callers keep the separate placeholder comment. The uncoordinated race election still needs server-assigned comment IDs, and target-branch re-review admission (fix(review): unchanged issues are fully re-reviewed and re-labeled on every target-branch commit #2039) is unchanged.
  • Legacy placeholders remain fully supported. Every reader of the started marker handles both forms: leases, placeholder recovery, review history, admission, label backfill, the webhook read model and the dashboard.
  • sweep.yml: the failure-cleanup step also expires in-place leases found by owner, so a lost PATCH acknowledgement can't strand one. The queue decision is passed through to classify reservations.
  • Docs: docs/scheduler.md and docs/pr-review-comments.md describe the lifecycle. The changelog fragment is changelog.d/quiet-background-rereview.md.

pr-behavior-proof

Field Contract
Claim A queue-owned background re-review reservation of an already-reviewed item creates zero new GitHub comments, carries the lease in the durable comment, and restores the old body on owned cleanup.
Exercised surface The checked-in reservation workflow shell, the built CLI, and real curl/HTTP requests to loopback GitHub and queue fixtures, including expiry, release and superseded ownership.
Fixture An existing durable review; an explicit re-review; a first background review; a background owner superseded after acquisition.
Command pnpm run build:all, then TMPDIR="$PWD/.artifacts" RESERVATION_PROOF_PROVIDER=local-process RESERVATION_PROOF_LEASE=none RESERVATION_PROOF_IMAGE=macos-node24 node scripts/e2e/review-reservation.mjs .artifacts/quiet-reservation-head --quiet
Environment macOS, Node v24.22.0, provider local-process, image macos-node24, lease none, head d348d5bc6f
Observable result See the output below: zero background POSTs, one POST for explicit and first reviews, and no durable-comment DELETE.
Limits Controlled HTTP responses and a synthetic reservation. No live GitHub subscriber or email delivery, real hosted queue race, model run, or final report-publication end-to-end. Unit tests separately cover completion publication, changed revisions, crash recovery and legacy placeholders.
quiet-background: posted, POST=0, PATCH=3, DELETE=0
explicit-rereview: posted, POST=1, PATCH=0, DELETE=0
background-first-review: posted, POST=1, PATCH=0, DELETE=0
quiet-superseded: superseded, POST=0, PATCH=2, DELETE=0
{"passed":4}

Repairs for the first ClawSweeper review

All four P2 findings on 7f57e82 are fixed in d348d5b, each with a regression test:

Finding Fix Regression test
Adopted apply lease lost on publication The adopted marker is kept through completed-review publication and the following mutation guards adopted in-place apply lock survives completed review publication and subsequent mutation guards
In-place lease displacing a confirmed contender Separate POST leases outrank in-place leases, and mutation guards fence the loser the deterministic 42-vs-1000 post-before-patch and patch-before-post cases
Lossy body reads Lossless comment GET (from #2054) before acquisition, cleanup and the release CLI quiet acquisition and owned cleanup preserve literal escapes and controls losslessly
Durable review near the size limit Keep the original and fall back to the separate placeholder above 61,440 UTF-8 bytes quiet reservation fits exactly at the UTF-8 limit and falls back one byte above it

Integrated lifecycle proof (scripts/e2e/review-lease-lifecycle.mjs, head d348d5bc6f)

PASS post-before-patch (47 loopback requests)
PASS patch-before-post (51 loopback requests)
PASS adopt-publication-close (43 loopback requests)
PASS lossless-cleanup (12 loopback requests)
PASS legacy-upgrade (15 loopback requests)
PASS 5/5

Base-failing, head-passing: an isolated build of 7f57e82, run with the same driver (PROOF_DIST_ROOT=<baseline>/dist --case <name>), fails all four relevant cases:

  • post-before-patch: both contenders reached final durable-comment writes.
  • patch-before-post: the separate contender was held by durable ID 42.
  • adopt-publication-close: publication removed the marker, and the guard reported apply mutation lease 42 is no longer the elected same-head lease, so no close occurred.
  • lossless-cleanup: the literal \u001b and the real escape control were changed.

legacy-upgrade shows that a legacy separate placeholder and an existing durable review created by the old code still load, expire and reap without deleting the old durable review. That is the data-model compatibility proof.

Validation on d348d5b: pnpm run check on Node 24 runs 6,415 tests, of which 6,384 pass, 31 are skipped and none fail. A fresh branch-mode Codex review found no actionable P0–P2 issues.

Limit: the proofs use loopback HTTP. GitHub's inherent read-to-write interval between a comment read and a later write is unchanged from main.

Validation

  • 191 focused tests pass.
  • Two independent Codex reviews (the implementation's own, and a separate one on the final diff) found no actionable P0–P2 issues.

…mment

Since #2039, unchanged items are re-reviewed on every target-branch commit.
Each run posted a new temporary "ClawSweeper status: review started" comment,
and GitHub notifies every subscriber of a new comment, so busy target
repositories sent a notification per commit even when the review did not
change (openclaw/Peekaboo#1114).

Queue-owned background re-reviews of an already-reviewed item now carry the
started lease by editing the durable review comment, preserving the prior
review text and restoring it byte-for-byte on owned cleanup. First reviews,
explicit requests, commands and uncoordinated callers keep the separate
placeholder, legacy placeholders stay recoverable, and sweep failure cleanup
also expires in-place leases discovered by owner.
@steipete
steipete requested a review from a team as a code owner October 24, 2026 05:00
@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T06:07:33.008269Z d348d5b New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 7f57e82583

ℹ️ 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 +284 to +286
const body = quiet
? withQuietReviewStartStatusLease(commentBody(durable)!, leaseOptions)
: renderReviewStartStatusComment(leaseOptions);

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 Keep the mutation lease alive through post-publication apply

When a background re-review produces a close proposal and the publisher adopts its still-active in-place lease, publishing the completed review removes the very marker used as the apply mutation lock. markedReviewCommentForApply in src/clawsweeper-apply-decision-workflow.ts does not preserve that marker, and the subsequent close guard in src/clawsweeper-apply-close-execution.ts calls ownedApplyMutationLeaseBlockReason, which now returns “apply mutation lease … is no longer the elected same-revision lease.” Consequently, an otherwise eligible close is skipped after the review was successfully synced; post-publication recovery-label cleanup can also be blocked. Preserve or transfer the mutation lease until the remaining apply operations finish, rather than removing it with the completed-review PATCH.

AGENTS.md reference: AGENTS.md:L54-L55

Useful? React with 👍 / 👎.

Comment on lines +292 to +295
if (quiet) {
created = upsertReviewComment(options.item.number, body, durable, undefined, {
suppressAutomationMarkers: true,
});

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 the lease election against uncoordinated contenders

If an uncoordinated caller acquires a fresh POST lease after this worker's initial comment read but before this PATCH, reusing the older durable comment ID retroactively changes the election winner. The uncoordinated caller can already have confirmed its ownership and started reviewing, while this worker subsequently sees both leases and elects its own lower-ID durable comment through freshDedicatedReviewStartLeases. Queue heartbeats do not serialize the uncoordinated caller, so both workers proceed despite the existing competing-POST election guarantee. The in-place acquisition needs coordination that also prevents displacement of an already-confirmed non-queue lease.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. 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. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR edits the existing durable review comment to show background re-review progress while preserving lease ownership, review history, and cleanup.

Example: A queue-owned background review starts on an item whose durable review comment is ID 42.

  • Before: Reservation posts a new temporary comment, notifying subscribers, and later deletes it.
  • After: Reservation edits comment 42, creates zero new comments, and restores the previous review on owned cleanup.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful repair with relevant current-head production-path proof, legacy-state coverage, and all earlier findings resolved.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Current-head macOS Node 24 output exercises the shipped reservation shell and CLI over loopback HTTP, showing zero new background comments and owned restoration; the integrated production-owner harness additionally shows both competing-owner orders fenced before final writes and the adopted lock surviving publication, label deletion, and close. Provider is local-process for reservation and local-loopback for lifecycle proof; hosted queue timing, live subscriber delivery, model generation, and full apply orchestration are outside the stated scope.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Subscribers receive repeated review-start notifications even when an item's completed review does not change.
Reason: The reported notification burden is concrete, and maintainer authorship establishes direction for this bounded change while scheduling remains owned by its existing policy.

Merge readiness

✅ Ready for maintainer review

This PR remains useful on current main, resolves all four earlier findings, and has no new actionable correctness or security finding.

Priority: P2
Reviewed head: d348d5bc6f07cc75eb3bc6302732348083f45601

Before merge

None.

Findings

None.

Agent review details

How this fits together

The exact-review workflow passes queue authority into comment reservation; shared lease readers and apply guards then control publication, label changes, close execution, and cleanup.

flowchart TD
  A[Queued background review] --> B[Check queue authority]
  B --> C[Reserve durable comment lease]
  C --> D[Run review]
  D --> E[Check elected owner]
  E --> F[Publish review and apply guarded changes]
  F --> G[Remove owned start status]
  C --> H[Restore prior review on failure]
Loading

Technical review

Best possible solution:

Keep background start status in the existing durable comment while retaining shared ownership guards, lossless cleanup, and the separate-placeholder fallback.

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

Current-main reservation source posts a fresh temporary comment for each new background acquisition, matching the reported repeated start notifications; this review did not execute target code.

Is this the best way to solve the issue?

The patch addresses notification creation in the existing comment owner and preserves coordination through shared readers and mutation guards, avoiding the previously rejected queue-identity replacement.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 400517640b24.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 2000d96 adds src/clawsweeper-review-comment-state.ts:415 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2000d96fed4c; files: src/clawsweeper-review-comment-state.ts)

Review metrics

Metric Value Why it matters
Change distribution Production/workflow +384/-83; tests and proof +1543/-56 Most growth exercises preservation, competing ownership, publication, recovery, and legacy compatibility across the shared lease lifecycle.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.
  • remove merge-risk: 🚨 automation: Current PR review selected no merge-risk labels.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: Repeated subscriber notifications warrant a focused repair, without evidence of an urgent service outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-24T05:14:20.493Z sha 7f57e82 :: needs real behavior proof before merge. :: [P2] Keep the adopted apply lease alive after review publication | [P2] Prevent in-place acquisition from displacing a confirmed contender | [P2] Read original comment bytes before patching an in-place lease | [P2] Fall back to a separate lease when the durable review is full

Reviewed October 24, 2026, 2:09 AM ET / 06:09 UTC (Revision 2).

…nders

Address ClawSweeper review findings on the in-place background lease:
- keep the adopted apply mutation lock through completed-review publication
  and the following mutation guards;
- let separate POST leases outrank in-place leases and fence the loser, so an
  older durable comment id cannot retroactively win the election;
- read the durable comment losslessly before acquisition, cleanup and CLI
  release so escapes and controls survive the round trip;
- fall back to the separate placeholder when the review plus status and lease
  would exceed the 61,440-byte durable review limit.

Adds an integrated loopback proof covering both contender orders, publication
through the close guard, lossless cleanup and a legacy-state upgrade.
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. 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.

2 participants