clawsweeper icon indicating copy to clipboard operation
clawsweeper copied to clipboard

review: ClawSweeper's own maturity:* labeling changes the issue review-start lease key, causing duplicate review-started placeholders

Open yetval opened this issue 4 months ago • 3 comments

Summary

The per-issue review-start lease is keyed on itemSourceRevisionSha256, whose digest includes the issue's non-ignored labels. ClawSweeper's own review pipeline applies a maturity:* label to the issue mid-review, and maturity: is not in the digest's ignore set. Adding that label changes the lease key, so a second worker no longer recognizes the in-flight lease planted by the first worker and posts a duplicate "ClawSweeper status: review started" placeholder (and a second author notification) for the same review. The lease provides no mutual exclusion across the bot's own labeling step.

Observed live on openclaw/openclaw#104977: placeholder posted at 05:04Z, ClawSweeper applied maturity:stable (plus P1, impact:*) at 05:12Z, a second placeholder posted at 05:14Z. The review then completed normally at 05:19Z, so the end result was correct, but two "review started" comments were posted and the issue author was notified twice for one review.

Observed timeline (openclaw/openclaw#104977)

Time (UTC) Event Source
04:50:46 Issue opened by author, no labels issue created_at
~05:04 Placeholder #1 "review started" posted (worker A) author email notification; comment later deleted
05:12:01 labeled P1 (digest-ignored) issue events
05:12:03 labeled impact:security (digest-ignored) issue events
05:12:05 labeled impact:session-state (digest-ignored) issue events
05:12:07 labeled impact:auth-provider (digest-ignored) issue events
05:12:08 labeled maturity:stable (NOT ignored -> flips lease key) issue events
05:14:04 Placeholder #2 "review started" posted (worker B, owner=github-run-29180841398-1, 30-min lease) comment created_at, marker front matter
05:19:28-37 outcome labels applied (no-stale, issue-rating, clawsweeper:*) issue events
05:19:40 Durable "Codex review" comment posted; both placeholders deleted comment created_at

The only digest-affecting change between the two placeholders (05:04 and 05:14) is the maturity:stable label at 05:12:08.

Environment

  • Commit: 6d204db3299114d14ce3341ccd06d86d12e2b495 (origin/main at time of filing)
  • Surface: issue review-start lease / source-revision digest (coordination between review workers)

Steps to reproduce

  1. A review worker (A) begins reviewing an issue that has no ClawSweeper labels yet. It computes the source-revision digest d0 over {title, body, labels, comments} and plants a review-start lease comment carrying sha=d0.
  2. ClawSweeper's own pipeline labels the issue, including a maturity:* label (e.g. maturity:stable), before the review comment is finalized.
  3. A second worker (B) recomputes the source-revision digest. Because maturity:* is not ignored by the digest, it now differs (d1 != d0).
  4. B looks for a fresh lease at headSha=d1 (freshExactHeadReviewStartLease requires marker.attrs.sha === normalizedHead), does not find A's lease (sha=d0), and posts a second review-start placeholder.

Expected

Labels that ClawSweeper applies to an issue as part of its own review (the maturity:* taxonomy) do not change the review-start lease key, so a second worker recognizes the in-flight lease and does not post a duplicate placeholder.

Actual

The bot's own maturity:* labeling flips the lease key, defeating the lease. A second placeholder comment is posted for the same review and the issue author receives a duplicate notification.

Root cause

revisionLabels feeds every non-ignored label into the lease digest, and the ignore predicate does not cover maturity:.

src/clawsweeper.ts:2701

function revisionLabels(labels: unknown): string[] {
  return (Array.isArray(labels) ? labels : [])
    .map((label) => normalizeLabelName(String(asRecord(label).name ?? label)))
    .filter(Boolean)
    .filter((label) => !isIgnorableSourceRevisionLabel(label))
    .sort();
}

src/clawsweeper.ts:2720

function isClawSweeperAdvisorySourceRevisionLabel(label: string): boolean {
  return (
    /^(?:status|rating|proof|merge-risk|impact|issue-rating):/.test(label) ||
    /^p[0-3]$/.test(label) ||
    // ... no maturity: entry
  );
}

p1 and impact:* are ignored here, so they do not move the key, but maturity:* is not, so it does. The lease then fails the exact-head match at src/repair/comment-router-core.ts:1818 (String(marker.attrs.sha ?? "").toLowerCase() !== normalizedHead -> continue), and the issue lease is keyed on this digest at src/clawsweeper.ts:20374 (leaseRevision = priorReview?.itemSourceRevision).

maturity:* labeling was added by PR #372 ("Label issues affecting stable maturity features") without extending the source-revision ignore set. Fix is to add maturity to the advisory prefix alternation (or otherwise exclude ClawSweeper-applied taxonomy labels from the lease digest) so the bot's own labeling cannot drift its own lease.

Sibling surfaces

  • PR reviews are unaffected: their lease is keyed on pullHeadSha, not the label digest (src/clawsweeper.ts:20375).
  • Human edits to the issue body/title, and human labels not on the ignore list, still correctly change the key and trigger re-review; this fix only stops the bot's own maturity:* label from drifting the key.

Real behavior proof

Behavior addressed: ClawSweeper's own maturity:* label changes the issue review-start lease key, causing a duplicate review-start placeholder. Real environment tested: drove the real production digest function itemSourceRevisionSha256 (via itemSourceRevisionSha256ForTest) from the committed build at commit 6d204db3299114d14ce3341ccd06d86d12e2b495, with identical title/body/comments and only the labels varied per the #104977 event log. Exact steps or command run after this patch: node repro.mjs Evidence after fix:

lease key (itemSourceRevisionSha256), identical title/body/comments, labels vary:

worker A (05:04, no labels)                    sha=e545ac9ae8f77273d5ef52c0090659320c320e791c33c6c2c365db6b6def018c
worker B (05:14, +P1 +impact:* +maturity:stable) sha=0282233ecebcd6b97a626ff0ba9fa1b2f8ffd85ac8d5030384d0547ab6d4b7f5
same as B but WITHOUT maturity:stable           sha=e545ac9ae8f77273d5ef52c0090659320c320e791c33c6c2c365db6b6def018c

A === B ?                 false   (workers see the SAME issue but DIFFERENT lease key)
A === B-without-maturity? true   (p1 + impact:* are ignored: key unchanged)

=> maturity:stable is the SOLE label that flips the lease key; it is applied by ClawSweeper itself mid-review.

Observed result after fix: adding only the bot-applied maturity:stable label changes the lease key (false), while the p1 and impact:* labels leave it unchanged (true), so a second worker cannot match the first worker's lease and posts a duplicate placeholder. What was not tested: I did not drive two concurrent live review workers end to end against a real GitHub issue; the duplicate-placeholder step is inferred from the exact-head lease match at src/repair/comment-router-core.ts:1818 plus the observed #104977 timeline (two placeholders at 05:04Z and 05:14Z bracketing the 05:12Z maturity:stable labeling).

yetval avatar Jul 12 '26 05:07 yetval

Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 12, 2026, 1:39 AM ET / 05:39 UTC.

Summary Current main still has the reported integration bug: ClawSweeper-managed maturity labeling changes the issue revision used for review-start coordination, so exact-head matching can miss the existing lease. The issue remains necessary, and no canonical fix PR was found.

Reproducibility: yes. at source level: current main deterministically changes the issue revision when maturity:stable is added and then requires exact equality with the lease marker. The live event sequence corroborates the triggering label transition, although this review did not run two concurrent workers end to end.

Root-cause cluster Relationship: canonical Canonical: https://github.com/openclaw/clawsweeper/issues/507 Summary: This issue is the canonical tracker for the integration regression where the newer issue lease fingerprint did not account for the existing managed maturity-label namespace.

Members:

  • same_root_cause: https://github.com/openclaw/clawsweeper/pull/501 - This merged PR introduced the source-revision lease fingerprint and the incomplete managed-label exclusion where the defect resides.
  • adjacent_distinct: https://github.com/openclaw/clawsweeper/pull/372 - This merged PR introduced maturity:stable; it is relevant feature provenance but did not implement the later lease fingerprint.

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Next step This is a current, narrow, source-reproducible bug with clear files and validation, no linked fix PR, and no product or security decision blocker.

Review details

Best possible solution:

Classify the ClawSweeper-owned stable-maturity label as advisory for issue source revisions and add focused digest coverage proving bot label sync cannot move the lease key while substantive human changes still do.

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

Yes at source level: current main deterministically changes the issue revision when maturity:stable is added and then requires exact equality with the lease marker. The live event sequence corroborates the triggering label transition, although this review did not run two concurrent workers end to end.

Is this the best way to solve the issue?

Yes. Extending the existing managed advisory-label exclusion and its focused digest test is narrower and safer than weakening exact-head lease matching or changing worker coordination.

AGENTS.md: found and applied where relevant.

Remaining risk / open question:

  • The first production placeholder was deleted after review completion, so the visible GitHub record independently corroborates the label timing but not both placeholder bodies; the deterministic source path and reporter's notification evidence provide the remaining link.
  • The repair must preserve revision changes for human title, body, comment, protected-label, and ordinary-label changes rather than weakening exact-head coordination generally.

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

Label changes

Label changes:

  • add P2: The underlying review completes, but a single review can produce duplicate public placeholders and author notifications.
  • add impact:ux-friction: The regression creates avoidable visible bot noise and can notify an issue author twice for one review.
  • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
  • add clawsweeper:source-repro: Current issue advisory state selects this label.
  • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
  • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

Label justifications:

  • P2: The underlying review completes, but a single review can produce duplicate public placeholders and author notifications.
  • impact:ux-friction: The regression creates avoidable visible bot noise and can notify an issue author twice for one review.
Evidence reviewed

Acceptance criteria:

  • node --test test/review-comment-rendering.test.ts
  • pnpm run check

What I checked:

  • Current source-revision behavior: Issue source revisions hash revisionLabels(source.labels), so every label not excluded by isIgnorableSourceRevisionLabel changes the coordination revision. (src/clawsweeper.ts:2628, 6d204db32991)
  • Missing maturity exclusion: The managed advisory-label predicate covers the other review-generated namespaces but omits maturity:. (src/clawsweeper.ts:2720, 6d204db32991)
  • Issue lease uses source revision: Review coordination uses the prior item source revision for issues and the pull head SHA for pull requests, confirming the report's issue-only scope. (src/clawsweeper.ts:20374, 6d204db32991)
  • Exact-head lease comparison: A review-start lease is rejected when its marker SHA differs from the normalized current revision, so label-induced digest drift makes the earlier lease invisible. (src/repair/comment-router-core.ts:1818, 6d204db32991)
  • Focused regression gap: The existing revision test covers numerous managed labels and verifies ordinary or protected labels still change the digest, but it does not include maturity:stable. (test/review-comment-rendering.test.ts:474, 6d204db32991)
  • Lease-feature provenance: Git blame and pickaxe history tie the source-revision fingerprint and advisory-label predicate to merged pull request https://github.com/openclaw/clawsweeper/pull/501. (src/clawsweeper.ts:2628, 23e9e5218b9b)

Likely related people:

  • vincentkoc: Authored the source-revision fingerprint and exact-head review-start lease integration in https://github.com/openclaw/clawsweeper/pull/501. (role: lease digest feature owner; confidence: high; commits: 23e9e5218b9b; files: src/clawsweeper.ts, src/repair/comment-router-core.ts, test/review-comment-rendering.test.ts)
  • RomneyDa: Authored and merged https://github.com/openclaw/clawsweeper/pull/372, which introduced the managed maturity:stable label involved in this interaction. (role: maturity-label feature owner; confidence: high; commits: c6cc52c7cdce, 82a1bfda0da5; files: src/clawsweeper.ts, test/pr-label-policy.test.ts, test/decision-parser.test.ts)
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[bot] avatar Jul 12 '26 05:07 clawsweeper[bot]

🦞✅ Implementation PR opened: https://github.com/openclaw/clawsweeper/pull/510 Status: The implementation PR passed the worker's edit, validation, review, publish, and post-flight gates. Worker: https://github.com/openclaw/clawsweeper/actions/runs/29182600574

clawsweeper[bot] avatar Jul 12 '26 06:07 clawsweeper[bot]

Thanks @yetval for preserving the notification timeline. This is now fixed by #510, merged as a7c31f1.

The production sequence was a self-induced source-revision CAS failure, rather than two workers competing for an active lease. The first exact issue review applied maturity:stable; its post-label mutation check then treated that bot-managed label as a source-revision change and failed. Normal failure recovery requeued the original event, and the later retry posted the second review-start placeholder.

The landed patch makes the managed maturity label revision-neutral in both source-revision implementations: the review/apply path and the repair/router guard. It continues to treat human, protected, and proof: override label changes as meaningful source drift.

brokemac79 avatar Jul 12 '26 12:07 brokemac79