Skip to content

fix(reviews): publish fresh reviews from reused command leases - #2045

Merged
vincentkoc merged 1 commit into
mainfrom
fix/reused-review-lease-order
Oct 16, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/reused-review-lease-order

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What Problem This Solves

Fresh reviews can remain unpublished when a queued command reuses its status-comment ID under a later review owner. The publisher treats the equal ID as an older report even when the report's original lease is still active.

Observed in publisher run 38878996581: three members failed with skipped_stale_review_comment_sync; diagnostics showed equal comment/report lease IDs. The workflow's overall success did not mean those reviews were delivered.

User Impact

Fresh issue and PR reviews can replace an older durable review for the same revision while their original status lease remains elected. Missing, expired, replaced, ambiguous, and genuinely newer reviews remain protected. No operator migration is required.

Why This Change Was Made

Command acknowledgements intentionally reuse comment IDs. Comment-ID ordering alone cannot distinguish the owners. Carry the freshly elected lease through the existing publication guards and allow the equal-ID case only with distinct known owners, a strictly later report timestamp, the same reviewed revision, and a live lease matching the report's original owner and ID. A newly acquired mutation lease cannot supply that authority.

The independently verified newer-tuple rule remains strict; this change does not turn an unproven skip into successful supersession. No queue policy, retries, close policy, or schema changes.

Production LOC: +41/-4 (net +37); tests: +119/-2. The positive production delta carries authoritative lease evidence through existing guards. The 447-line isolated CLI replay is separate proof tooling.

Documentation Impact

Updated active contract docs/pr-review-comments.md and added one changelog fragment. Review-publication maintainers own the contract; src/clawsweeper-review-comment-state.ts, the apply lease guards, and the command-acknowledgement flow are its source of truth. Verified against baseline 892e2aabc360d2403f49bcbf42902c3daee7dbf0 and this head. Update when lease election, acknowledgement reuse, or publication ordering changes.

Evidence

  • Signed head: f4e1f232e85c8791051ebbb792a77c582ef70f9a.
  • 91 focused tests passed: node --test test/review-comment-ordering.test.ts test/apply-label-sync.test.ts.
  • Fresh precommit and committed Codex reviews found no actionable issues.
  • Full validation command: pnpm run check, exercised remotely and by the exact-head CI checks.
  • Environment diagnosis: the unchanged baseline and candidate both pass all three SQLite NUL-preservation cases on Node 24.22.0. The unchanged baseline fails those same three cases on the Daytona image's Node 25.9.0. Validation uses Node 24, matching CI; no unrelated persistence assertions were weakened.

Real Behavior Proof

Claim and surface: actual built apply-decisions CLI, durable review PATCH, issue and PR paths, repeated live lease election, and the normal isolated action ledger.

Scenario: synthetic same-revision report/live-comment tuples reproduce the equal reused-ID relationship observed in the failed publisher. This is not a capture of every failure-time lease field: the original incident's expiry was not retained, and the public status comment has since advanced to another owner.

Environment: native Crabbox Daytona, image crabbox-daytona-2x4x10-20260803-3907a63, lease cbx_63cbb038cdb8; Linux x64, Node 24.22.0, pinned pnpm 12.4.1, stock GitHub CLI 2.102.0. Baseline and candidate package manifests/lockfiles match; both compiled trees use the qualified remote dependency install.

Command:

PROOF_PROVIDER=daytona PROOF_LEASE=cbx_63cbb038cdb8 \
  node scripts/e2e/reused-review-lease-publication.mjs \
  "$BASELINE_DIST" "$CANDIDATE_DIST" "$EMPTY_PROOF_DIR"

Observed result, all 12 cases passed:

Scenario Issue PR
Baseline, fresh report with reused lease ID stale skip; 0 PATCH stale skip; 0 PATCH
Candidate, original active elected lease synchronized; 1 PATCH synchronized; 1 PATCH
Newer durable review blocked; 0 PATCH blocked; 0 PATCH
Original lease missing blocked; 0 PATCH blocked; 0 PATCH
Original lease expired blocked; 0 PATCH blocked; 0 PATCH
Original lease replaced before final election blocked; 0 PATCH blocked; 0 PATCH

Both successful PATCH bodies contained the expected report owner and review time. Every case recorded zero forbidden requests. Labels were preseeded from canonical selection helpers so the replay isolates review publication. The PR fixture includes the current v2 activity cursor and exact empty activity connections.

Artifact / trace: checked-in scripts/e2e/reused-review-lease-publication.mjs writes per-case HTTP transcripts, apply results, fixture/report/body hashes, and receipt.json. The executed Node 24 receipt has these source/build identities (SHA-256):

candidate full source 0703f704a0ecf561b0d72b333093a693959c2127cb99fadd96d1c4f2e34911db
candidate source      19728acebb446606e82158af52d5475102fdd432b5ce0bbc6274daadd7ddc06d
ordering owner        356d0865844eb924182df3eb5bd22b5b8451ae2a5d952bbae933a0ee7bf5fa44
baseline dist         a48418899c4ca2f91f2946005453038302da2aa375b874f07ca3d9a96b1e03d4
candidate dist        dd0a8da507cb180e84d867b4e9497da8803586d251160db13cca5ac2aef100cd

The remote capsule retains the baseline Git HEAD; the full-source manifest was independently recomputed from the local committed tree and matches the candidate receipt.

Limits: stock gh talks to a strict isolated HTTP peer; no live GitHub mutations, labels, or closes occur. This proves the changed CLI publication path, not canonical queue completion, R2 publication, or live backlog recovery. Separate GitHub comments do not provide an atomic transaction: replacement observed by the final election blocks mutation; a change after that snapshot remains a pre-existing race window.

Follow-up: preserve typed apply-proof rejection reasons at the publisher before adding an Operations failure-reason chart. The current generic unknown_failure telemetry is insufficient for that chart; it does not justify inferring successful supersession or agent quality.

@clawsweeper

clawsweeper Bot commented Oct 16, 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.

@vincentkoc
vincentkoc marked this pull request as ready for review October 16, 2026 10:42
@vincentkoc
vincentkoc requested a review from obviyus October 16, 2026 10:42
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR allows a fresh review to replace an older review when both reuse the same command-comment ID and the original report lease remains elected.

Example: Issue 103599 has an older durable review and a later report using lease comment 6178075898 under owner github-run-current-1.

  • Before: Publication skips the fresh report because the lease comment IDs are equal.
  • After: Publication updates the durable review only while the report's original owner, comment ID, and revision match the elected active lease.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, useful correction with shipped-CLI proof, meaningful rejection controls, and no actionable finding; persisted formats remain unchanged.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied proof records the built apply-decisions CLI and stock gh exercising issue and PR publication on Daytona lease cbx_63cbb038cdb8 with Node 24.22.0: the original elected owner produces one durable-review PATCH, while newer reviews and missing, expired, or replaced leases produce none. The inspected replay implements those final-effect controls; its reported results cover the changed authority boundary. GitHub transport is isolated, and this evidence does not claim live queue completion, R2 publication, or backlog recovery.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A completed fresh review can remain unpublished while an older durable review stays visible.
Reason: The maintainer-authored direction restores the existing fresh-review publication contract without adding configuration, changing queue policy, or expanding scope.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes a current publication failure, preserves lease ownership checks, and introduces no actionable defect found in this review.

Priority: P2
Reviewed head: f4e1f232e85c8791051ebbb792a77c582ef70f9a

Before merge

None.

Findings

None.

Agent review details

How this fits together

The apply publisher receives completed review reports, compares them with live GitHub review and lease comments, and writes the durable review only after freshness and ownership checks.

flowchart TD
  A[Completed review report] --> C[Publication guards]
  B[Live GitHub comments] --> D[Lease election]
  D --> C
  C --> E[Final ownership check]
  E --> F[Durable review update]
Loading

Technical review

Best possible solution:

Use the existing publication guards with freshly elected original-lease evidence while retaining strict supersession and source-freshness checks.

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

Pinned main deterministically rejects the same-revision equal-ID tuple; the supplied baseline CLI replay reports that failure for both issues and PRs, but no target code was executed during this review.

Is this the best way to solve the issue?

The correction belongs in the shared publication ordering owner and uses existing lease election rather than weakening stale-result handling or adding another coordination mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 892e2aabc360.

Provenance checked

  • Equal-ID review ordering changes intended behavior with a stated reason (unknown: The predicate was carried through refactor: deepen review comment ownership #1906 as a behavior-preserving ownership refactor; scoped git log -S could not establish its original introduction because an older promisor object was unavailable.)
  • Lease election and publication guards keeps the original intent (unknown: Existing guards elect a live same-revision lease and reject competing owners before mutation; refactors moved these guards into focused modules without establishing their original introduction.)
  • Terminal newer-review verification keeps the original intent (c377cfc: Only a fully verified strictly newer durable lease may finish obsolete publication work as superseded.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current-main failure and narrow correction: The pinned main version rejects equal lease IDs regardless of later ownership; the introduced exception requires distinct valid owners, a strictly later report timestamp, matching revision, and the elected original report lease. (src/clawsweeper-review-comment-state.ts:724, f4e1f232e85c)
  • Authority checked before publication: The mutation guard freshly elects the lease and rejects a changed owner, comment ID, or revision before passing lease evidence to the ordering guard; publication also refreshes the lease immediately before comment synchronization. (src/clawsweeper-apply-lease-guards.ts:224, f4e1f232e85c)
  • Supplied production-path proof: The full PR body reports twelve baseline/candidate CLI cases using stock gh against an isolated HTTP peer: active original ownership permits one PATCH, while newer reviews and missing, expired, or replaced leases permit none. The checked-in replay exercises these boundaries and verifies resulting owner and timestamp markers. (scripts/e2e/reused-review-lease-publication.mjs:418, f4e1f232e85c)
  • Intentional acknowledgement reuse: fix: reuse command review status comment #1675 intentionally placed command review coordination on the existing acknowledgement and explicitly accepted its comment-ID arbitration tradeoffs; this PR preserves that design. (docs/pr-review-comments.md:103, 892e2aabc360)
  • Strict supersession contract preserved: fix(publication): stop retrying reviews superseded by newer results #1249 requires a strictly greater live lease ID before terminal supersession; this PR leaves that predicate unchanged and tests that equal-ID publication does not qualify. (src/clawsweeper-review-comment-state.ts:804, c377cfc04209)
  • Policy and inspection limits: The complete root AGENTS.md applies; no nested policies or maintainer-notes directory were present. The checkout remained clean. Historical content searches encountered unavailable promisor objects, and the incident log download redirected to a blocked host; neither limitation establishes a patch defect. (AGENTS.md, f4e1f232e85c)

Likely related people:

  • Peter Steinberger: Raw commit 4b5246a adds src/clawsweeper-apply-lease-guards.ts:185 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4b5246acdf7e; files: src/clawsweeper-apply-lease-guards.ts)

Review metrics

Metric Value Why it matters
Change distribution Production +41/-4; tests +119/-2; isolated CLI replay +447 Production growth carries elected lease evidence through existing guards; the larger replay separately exercises baseline failure and final-write rejection controls.

Labels

Label changes:

  • add P2: A bounded review-publication failure leaves completed reviews undelivered without establishing a broader runtime outage.
  • 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.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A bounded review-publication failure leaves completed reviews undelivered without establishing a broader runtime outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • 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.

Reviewed October 16, 2026, 6:56 AM ET / 10:56 UTC.

@vincentkoc
vincentkoc merged commit cb5eaa3 into main Oct 16, 2026
37 checks passed
@vincentkoc
vincentkoc deleted the fix/reused-review-lease-order branch October 16, 2026 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. 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