clawsweeper icon indicating copy to clipboard operation
clawsweeper copied to clipboard

Terminal scanner refusal is re-leased by shard, recovery, and backfill lanes; each attempt posts and deletes a placeholder comment

Open yetval opened this issue 2 months ago • 4 comments

Summary

When the agent input scanner refuses a revision (review_failure_reason=findings, exit 79), the PR gets a status comment saying "ClawSweeper will not retry this unchanged revision." That is not what happens. The refusal is terminal only for the lease that failed. Three other producers keep re-leasing the same head, and every attempt posts a fresh "ClawSweeper status: review started." placeholder, fails the scan, and deletes the placeholder. Each placeholder is a notification email to the author, and nothing stays on the PR to explain it.

Measured on openclaw/openclaw#137756 (head 8fa9038605, refused for the reason fixed by #1454): 97 placeholder comments between 2026-09-04T01:36Z and 2026-09-05T09:02Z, then 30 more between 09:06Z and 17:05Z on 2026-09-05. That is 127 posted-then-deleted placeholders in about 40 hours, roughly one every 19 minutes, all for a head the queue had already recorded as a terminal findings failure at 2026-09-04T03:03Z (run 33831631509).

Evidence

Terminal failure recorded, then re-run anyway:

  • 2026-09-04T03:00Z run 33831631509, sourceAction: "re_review", head 8fa9038605: exit 79, REVIEW_FAILURE_STAGE: agent_input_scan, /complete succeeded with review_failure_reason=findings. Artifact exact-review-failure-diagnostics-33831631509-1/manifest.json: "retryable": false, "reason_code": "findings".
  • 2026-09-05T15:58Z run 33976413621, sourceAction: "scheduled_normal_backfill", same head: identical refusal.
  • 2026-09-05T16:11Z run 33977094062 and 16:58Z run 33979488915, claim decision {"itemKind":"issue","sourceEvent":"issues","sourceAction":"failed_review_shard_recovery",...} with no sourceHeadSha (run title "rev 1 head na"): identical refusal.
  • Shard lane, e.g. run 33956911979 ("Review manual hot target", shard 4/22): start-comment=posted #137756, AgentInputScanError: Agent input scan refused: findings, then Queued failed review shards ... through the exact-review control plane: ...,137756,....

Placeholder churn (from the author's notification emails, one per comment): owners github-run-33826257368-1 through github-run-33979505760-1, 127 distinct runs, every one carrying <!-- clawsweeper-review-status:started item=137756 sha=8fa9038605333332e2653d5c86e34bf28d78403b ... -->. None of those comments exist on the PR now.

Root cause

  1. "Will not retry" is implemented as retried: outcome !== "success" && reviewFailureReason === undefined on the completing lease (dashboard/exact-review-queue.ts, /complete handler). Nothing consults the recorded terminal failure when a new decision for the same item arrives. exactReviewFailureSourceFingerprint (dashboard/exact-review-failure-telemetry.ts) includes source_action and head_sha, so a scheduled_normal_backfill or failed_review_shard_recovery decision never matches the re_review failure record even for the identical head.
  2. The shard planner's dueCandidate (src/clawsweeper-review-planning-inventory.ts) selects any open item without a current durable review and never looks at queue failure state. A refused item has no durable review, so it is due on every plan. "Review manual target" and "Review manual hot target" runs are self-dispatched by sweep.yml's Continue sweep step, so this repeats on the sweep cadence.
  3. The Recover failed review shards job (sweep.yml, recover-review-failures) requeues every failed shard item with itemKind: "issue", sourceEvent: "issues", and no head SHA, regardless of exit code. For a PR this also skips the Fence terminal automatic review failure step, whose if: requires itemKind == 'pull_request', so the blocked status is not even written on those attempts.
  4. The shard reviewer posts the review-started lease comment before the input scan runs and deletes it on failure (releaseOwnedReviewLease -> deleteOwnedDedicatedReviewStartLease, src/clawsweeper-review-command-workflow.ts). Combined with 1 to 3, the author receives one email per attempt and the PR shows nothing.

Suggested fix

  • Have the shard job record the review exit code in its failed-shard artifact and make recover-review-failures skip items whose exit was 78 or 79 (terminal for the unchanged source).
  • Make the planner treat a clawsweeper-review-progress blocked marker for the current head as a review record, so shouldReviewItem returns false until the head changes. That also makes the "will not retry this unchanged revision" copy true.
  • Optionally, gate /internal/exact-review/enqueue on the recorded terminal failure when the incoming decision's head (or the live head, when the decision carries none) equals the refused head.
  • Posting the placeholder only after the scan passes would stop the email churn on its own, but the lease exists to prevent overlap during checkout preparation, so that ordering change needs a maintainer decision.

Related

  • #1454 fixes the specific refusal cause on openclaw/openclaw#137756 (cited item bodies inlined into the scanned prompt). It does not address the retry loop described here, which applies to any terminal refusal.
  • #1350 (closed) covered a different prompt-material false positive from source-repro context; it did not cover the retry behavior.

yetval avatar Sep 05 '26 18:09 yetval

Codex review: this still needs some work. Reviewed September 24, 2026, 10:30 AM ET / 14:30 UTC.

Summary The cross-producer scanner-refusal loop remains unresolved. Merged changes narrowed failed-shard recovery and stopped repeated preparation for one incompatible-source case, but current main still removes a queue item after a terminal scanner finding, allowing a later producer to admit the item again. A maintainer must choose how automatic intake establishes that the scanned input is unchanged.

Reproducibility: yes. the current completion code and test show a findings refusal removes its queue row, while the planner has no failure check. The earlier Workerd reproduction observed same-source readmission, but this read-only review did not rerun it on today's main.

Root-cause cluster Relationship: canonical Canonical: https://github.com/openclaw/clawsweeper/issues/1455 Summary: Merged fixes address the cited scanner input cause and parts of recovery, while this issue tracks the remaining cross-producer refusal fence.

Members:

  • adjacent_distinct: https://github.com/openclaw/clawsweeper/pull/1454 - Its merged redaction fix addressed the specific cited-input refusal, not subsequent admission of a terminal failure.
  • partial_overlap: https://github.com/openclaw/clawsweeper/pull/1537 - Its merged recovery repair preserves item identity and excludes nonretryable shard terminals, but expressly leaves the cross-lane fence open.
  • partial_overlap: https://github.com/openclaw/clawsweeper/pull/1671 - Its merged queue parking handles pinned incompatible-source failures, while scanner findings still remove the row.

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

Maintainer decision needed

Question Recommendation
When automatic producers cannot establish complete scanned-input identity after a terminal scanner refusal, should review remain held pending explicit re-review or policy change, or should intake hydrate and verify the full input before readmission? Verify complete input before admission: Use a bounded source manifest shared by queued and direct automatic lanes to admit only materially changed scanner input.

Why: The first choice changes automatic freshness behavior; the second adds bounded hydration work. A head-only hold risks suppressing legitimate new evidence.

Next step The remaining repair crosses automatic admission paths, and the complete-input retry policy needs Peter's decision before implementation.

Review details

Best possible solution:

Apply one complete scanned-input identity contract to queued and direct automatic intake, preserving fresh manual re-review and changed-input recovery; verify the final admission result and absence of start-comment churn in a real queue and workflow path.

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

Yes: the current completion code and test show a findings refusal removes its queue row, while the planner has no failure check. The earlier Workerd reproduction observed same-source readmission, but this read-only review did not rerun it on today's main.

Is this the best way to solve the issue?

Unclear until the retry contract is chosen. A complete scanned-input identity shared across automatic lanes is safer than a head-only or timestamp-only fence.

AGENTS.md: found and applied where relevant.

Remaining risk / open question:

  • Suppressing admission by head SHA, timestamp, or the current narrow queue fingerprint could hide new comments, related material, or policy changes that alter what the scanner would inspect.

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

Label changes

Label changes:

  • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.
  • add clawsweeper:needs-maintainer-review: Current issue advisory state selects this label.
  • add clawsweeper:needs-product-decision: Current issue advisory state selects this label.
  • remove clawsweeper:queueable-fix: Current issue advisory state no longer selects this label.
  • remove clawsweeper:fix-shape-clear: Current issue advisory state no longer selects this label.

Label justifications:

  • P1: Repeated failed review attempts can trigger contributor notifications and waste review capacity on the same terminal refusal.
  • impact:ux-friction: Temporary review-start comments create confusing notifications without leaving an explanatory comment on the PR.
Evidence reviewed

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
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 Sep 05 '26 18:09 clawsweeper[bot]

Reproduced the remaining admission gap on main bbeeb8afb1ec3b2aa10d260d15df8e8bfc639b77 in real workerd with a SQLite Durable Object. A seeded claimed PR lease completed with review_failure_reason: findings and retryable: false: /complete returned {ok:true,requeued:false}. A different producer then enqueued the same head, base and source timestamp: /enqueue returned 202 with queued:true, and pending became 1. No GitHub or provider request was made; this isolates queue readmission rather than claiming a new production comment-churn observation.

The root is in finishExactReviewQueueItem: terminal completion deletes the item, so a later producer has no durable refusal fence. The existing telemetry fingerprint also includes sourceAction, so it cannot serve as cross-producer input identity. Failed-shard recovery already retains per-item terminal/retryable dispositions; suppressing an entire failed shard would regress unrelated work.

A safe fence needs an explicit source-equality contract. Scheduled intake currently sends only kind and sourceUpdatedAt; the parked-source content hash does not include all comments or related scanned material. Head-only or timestamp-only suppression would hide legitimate new evidence, and retaining a manual command row could replay old command authority. Automatic self-continuations also still have a direct shard path.

NEEDS-PETER: choose the automatic retry contract when a producer cannot establish complete scanned-input identity. Options are (1) retain a refusal hold until explicit re-review/policy change, which changes automatic freshness behavior, or (2) require complete source-manifest verification before automatic re-admission, which adds hydration work and needs a bounded budget. I recommend (2), shared by queued and direct automatic lanes, with manual re-review retaining its own fresh command authority. No incomplete fence or notification-only workaround was landed; this issue remains open.

steipete avatar Sep 13 '26 02:09 steipete

Maintainer decision: after a terminal scanner refusal, retain a durable automatic-review hold until an explicit fresh re-review or an intentional scanner-policy epoch change. New comments or other automatic source events alone must not restart it. Use the existing parked queue state and avoid a new scanned-input manifest system.

The implementation must make automatic continuations obey the same queue owner, preserve independent retryable failures and source-incompatible recovery, and never replay the failed command's authority. Newly observed refusals are the rollout boundary; historical deleted rows must not be reconstructed as inferred holds.

steipete avatar Sep 27 '26 09:09 steipete

Fixed and deployed in https://github.com/openclaw/clawsweeper/pull/1701, merged as https://github.com/openclaw/clawsweeper/commit/8d659e7cb903370596e26acea5b81399f291c174. The live Worker health endpoint reports that exact commit. Deployment and smoke verification passed on the rerun: https://github.com/openclaw/clawsweeper/actions/runs/36360975003.

Terminal scanner refusals now remain held across automatic producers, source changes, restart, and close/reopen. Verified re-review commands must postdate the refusal, including in-flight successors; failed manual request identities cannot replay. Fresh explicit retry or an intentional policy-epoch change can release the hold. Five legacy sweep jobs and per-run execution controls were removed in favor of the shared queue and separate apply lane.

Final-head CI, CodeQL, production automerge tests, and ClawSweeper review passed. Real workerd/SQLite proof on macOS and AWS demonstrated parked stale requests with zero review dispatches for the held item, followed by admission of a later command. AWS proof: https://crabbox.openclaw.ai/portal/runs/run_b0d176eaabb3a873045519d4b81d536e. This protects newly observed refusals; historical deleted rows are not inferred as holds.

steipete avatar Sep 28 '26 00:09 steipete