Skip to content

fix(review): stop retrying incomplete source revisions - #1311

Merged
sallyom merged 1 commit into
mainfrom
fix/incomplete-source-terminal
Aug 30, 2026
Merged

sallyom merged 1 commit into
mainfrom
fix/incomplete-source-terminal

Conversation

@sallyom

@sallyom sallyom commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • classify AgentInputScanError: incomplete_source as a distinct terminal review failure
  • consume only the failed unchanged revision instead of sending it through the generic retry/recovery loop
  • preserve any newer queued revision and keep the workflow red/operator-visible
  • retain the existing retry behavior for every unclassified failure and older completion client

Root cause

The scanner already marks incomplete_source non-retryable, but the CLI flattened every review failure to exit code 1. The workflow and exact-review queue therefore received an indistinguishable generic failure and repeatedly retried/recovered the same immutable head.

This change carries one narrow reason across the existing boundaries: CLI exit code 78 -> workflow failure_reason -> exact-queue review_failure_reason. The queue consumes that leased revision only when the reason is incomplete_source; a newer revision remains pending.

Behavior proof

Claim: an unchanged review revision rejected as incomplete_source is terminal, while transient failures still retry and a newer revision is preserved.

Exercised surface: signed HTTP enqueue -> production Worker routing -> SQLite-backed ExactReviewQueue Durable Object -> dispatch -> claim -> complete.

Exact-head runtime: Crabbox 0.47.0-46-gfeadcdcc, Podman-backed provider=local-container, image node:24-bookworm, lease cbx_bfcbce5344e3, run run_34e2b681ae4b, head 98b0d7683d2eae06b54dca650e786f7f5beda2f1. Wrangler 4.107.0 ran the real Worker with Miniflare SQLite Durable Object storage; the GitHub API boundary was a loopback deterministic stub so no GitHub mutation occurred.

Observed result: the unchanged terminal completion returned 200 { "ok": true, "requeued": false } and its dispatch count stayed at one after settling. The generic-failure control returned { "requeued": true } and produced a second revision-1 dispatch. When revision 2 arrived during a revision-1 lease, the old completion was fenced with 409 lease_superseded and the next dispatch carried lease_revision: 2.

Artifact/trace: full redacted proof transcript. Crabbox required and collected proof/pr-1311-runtime.json; the 968-byte artifact tar SHA-256 is f5ed83b6b79e35a5e6e4445328cbb5891942ae710191bc6613980a7e6edf061d. Crabbox exited 0 and automatically stopped the lease.

Commands:

pnpm run build:all
node --test --test-name-pattern='only incomplete source scan failures' test/agent-input-scan.test.ts
node --test --test-name-pattern='exact event review publishes directly' test/sweep-workflow.test.ts
node --test --test-name-pattern='exact-review queue terminates incomplete source|exact-review queue validates terminal review failure reasons' test/dashboard-worker-queue-runtime.test.ts
pnpm exec oxfmt --check .github/workflows/sweep.yml dashboard/exact-review-queue.ts src/agent-input-scan.ts src/clawsweeper.ts test/agent-input-scan.test.ts test/dashboard-worker-queue-runtime.test.ts test/sweep-workflow.test.ts
git diff --check

All passed at 98b0d7683d.

Limits: this is the actual local Worker and SQLite Durable Object, not the deployed Cloudflare account. GitHub App/token/workflow/item/dispatch calls were served by the loopback stub. The scanner itself was intentionally not invoked on this machine; proof begins at the typed workflow-to-queue failure contract changed by this PR.

Compatibility and operations

  • no persistence or schema change
  • completion field is additive and optional; omission preserves generic retries
  • invalid reason combinations fail closed
  • workflow remains red so the hydration failure stays visible
  • no OpenClaw Bay UI/display change; this only changes exact-review queue retry semantics

Review note

Local hosted-agent review was not run because this machine must not execute the repository's local scanner dependency. GitHub ClawSweeper review is expected on the established PR.

@sallyom
sallyom requested a review from a team as a code owner August 30, 2026 20:10
@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added 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. labels Aug 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 4:28 PM ET / 20:28 UTC.

ClawSweeper review

What this changes

The PR maps incomplete-source scan failures to a distinct review exit code and queue completion reason so only the unchanged failed revision stops retrying.

Regression provenance

Possible regression — probable (reviewed change; known regression link). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open for normal maintainer review. The current main branch still flattens incomplete-source failures to exit code 1, while this exact-head patch carries a constrained terminal reason through the workflow and queue; its supplied containerized Worker proof covers terminal consumption, generic retries, and newer-revision fencing.

Priority: P2
Reviewed head: 98b0d7683d2eae06b54dca650e786f7f5beda2f1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, constrained patch with strong exact-head durable-queue behavior proof and no actionable correctness finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): At head 98b0d76, Crabbox local-container ran the actual Worker and SQLite-backed ExactReviewQueue over HTTP. The recorded after-fix trace shows the changed queue completion owner consumes an unchanged incomplete-source failure, retains ordinary retry behavior, and fences a stale revision; CLI-to-workflow propagation is additionally covered by focused source tests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): At head 98b0d76, Crabbox local-container ran the actual Worker and SQLite-backed ExactReviewQueue over HTTP. The recorded after-fix trace shows the changed queue completion owner consumes an unchanged incomplete-source failure, retains ordinary retry behavior, and fences a stale revision; CLI-to-workflow propagation is additionally covered by focused source tests.
Evidence reviewed 5 items Current main lacks the typed terminal path: The pinned main revision exits with code 1 for every top-level error; the PR introduces the incomplete-source-specific exit mapping and its workflow propagation, so this work is not already implemented on main.
Queue contract is constrained: The completion endpoint accepts only incomplete_source, only for failure outcomes, rejects retry-kind and publication combinations, and the finalizer stops retrying only when that reason is present while retaining newer revisions.
Exact-head behavior proof: The supplied redacted Crabbox transcript for the exact PR head records a local Worker with SQLite Durable Object over HTTP: terminal completion returned requeued:false, generic failure retried, and an old completion was fenced when revision 2 arrived. GitHub-side calls were intentionally loopback stubs.
Findings None None.
Security None None.

How this fits together

Exact reviews run from the CLI through the sweep workflow into a Worker-backed durable queue, which leases and completes review jobs. The queue decides whether a failed lease is retried, consumed, or superseded by a newer revision.

flowchart LR
  Scanner[Source scanner] --> CLI[Review CLI]
  CLI --> Workflow[Sweep workflow]
  Workflow --> Queue[Exact review queue]
  Queue --> Decision{Failure outcome}
  Decision -->|Incomplete source| Consume[Consume unchanged revision]
  Decision -->|Other failure| Retry[Retry review]
  Queue --> Newer[Preserve newer revision]
Loading

Before merge

  • Resolve merge risk (P1) - The supplied real trace injects the typed reason at the Worker queue boundary; it does not execute a hosted GitHub Actions run from the scanner exception through workflow completion, so the numeric exit-code handoff remains supported by source inspection and workflow tests rather than a full hosted trace.
  • Complete next step (P2) - No repair dispatch is needed: the PR has no identified actionable defect and already includes current real-behavior proof.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Changed surface 7 files affected; 168 additions, 5 deletions The fix crosses CLI, workflow, durable-queue, and focused test boundaries.
Production versus tests production +47/-4, tests +121/-1 Focused coverage is substantially larger than the implementation change and exercises each protocol boundary.

Merge-risk options

Maintainer options:

  1. Accept the bounded workflow protocol risk (recommended)
    Land with the current exact-head Worker proof and focused source coverage, recognizing that the hosted workflow handoff itself was not exercised end to end.

Technical review

Best possible solution:

Land the narrow typed failure protocol while preserving lease-tuple fencing, newer-revision preservation, and generic retry behavior for every other failure class.

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

Yes. The supplied exact-head Crabbox trace drives the production Worker and SQLite queue through terminal, generic-failure, and newer-revision completion scenarios over HTTP.

Is this the best way to solve the issue?

Yes. A narrowly typed optional completion reason preserves the existing retry protocol for all other failures while stopping only the immutable incomplete-source case.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. At head 98b0d76, Crabbox local-container ran the actual Worker and SQLite-backed ExactReviewQueue over HTTP. The recorded after-fix trace shows the changed queue completion owner consumes an unchanged incomplete-source failure, retains ordinary retry behavior, and fences a stale revision; CLI-to-workflow propagation is additionally covered by focused source tests.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): At head 98b0d76, Crabbox local-container ran the actual Worker and SQLite-backed ExactReviewQueue over HTTP. The recorded after-fix trace shows the changed queue completion owner consumes an unchanged incomplete-source failure, retains ordinary retry behavior, and fences a stale revision; CLI-to-workflow propagation is additionally covered by focused source tests.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This corrects bounded review-automation retry behavior without evidence of a current user-facing outage.
  • merge-risk: 🚨 automation: The patch changes how the sweep workflow classifies and completes durable exact-review failures.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): At head 98b0d76, Crabbox local-container ran the actual Worker and SQLite-backed ExactReviewQueue over HTTP. The recorded after-fix trace shows the changed queue completion owner consumes an unchanged incomplete-source failure, retains ordinary retry behavior, and fences a stale revision; CLI-to-workflow propagation is additionally covered by focused source tests.
  • proof: sufficient: Contributor real behavior proof is sufficient. At head 98b0d76, Crabbox local-container ran the actual Worker and SQLite-backed ExactReviewQueue over HTTP. The recorded after-fix trace shows the changed queue completion owner consumes an unchanged incomplete-source failure, retains ordinary retry behavior, and fences a stale revision; CLI-to-workflow propagation is additionally covered by focused source tests.

Evidence

What I checked:

  • Current main lacks the typed terminal path: The pinned main revision exits with code 1 for every top-level error; the PR introduces the incomplete-source-specific exit mapping and its workflow propagation, so this work is not already implemented on main. (src/clawsweeper.ts:18, 98b0d7683d2e)
  • Queue contract is constrained: The completion endpoint accepts only incomplete_source, only for failure outcomes, rejects retry-kind and publication combinations, and the finalizer stops retrying only when that reason is present while retaining newer revisions. (dashboard/exact-review-queue.ts:2035, 98b0d7683d2e)
  • Exact-head behavior proof: The supplied redacted Crabbox transcript for the exact PR head records a local Worker with SQLite Durable Object over HTTP: terminal completion returned requeued:false, generic failure retried, and an old completion was fenced when revision 2 arrived. GitHub-side calls were intentionally loopback stubs. (98b0d7683d2e)
  • Related history: The latest main commit documents the prior hosted-review failure mode: an incomplete-source refusal before agent execution was repeatedly re-leased. This PR addresses the remaining failure disposition rather than duplicating that hydration fix. (src/clawsweeper-review-blobs.ts, a65acb1ee9e2)
  • Patch hygiene: The pinned introduced diff covers seven files with focused CLI, workflow, queue, and test changes; the read-only whitespace check is clean. (.github/workflows/sweep.yml:1303, 98b0d7683d2e)

Likely related people:

  • Masato Hoshino: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-08-30T20:14:54.930Z sha 98b0d76 :: needs real behavior proof before merge. :: none

@sallyom

sallyom commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Exact-head real behavior proof

pr-behavior-proof

  • Claim: an unchanged incomplete_source failure is consumed without redispatch; an unclassified failure still retries; a newer revision is never consumed by the old terminal completion.
  • Exercised surface: signed HTTP enqueue → production Worker routing → SQLite-backed ExactReviewQueue Durable Object → dispatch → claim → complete.
  • Exact head: 98b0d7683d2eae06b54dca650e786f7f5beda2f1
  • Environment: Crabbox 0.47.0-46-gfeadcdcc; provider=local-container; Podman runtime; image node:24-bookworm (node v24.20.0); lease cbx_bfcbce5344e3; run run_34e2b681ae4b.
  • Runtime: Wrangler 4.107.0 local Worker with Miniflare's real SQLite Durable Object storage. GitHub App token, item-state, workflow-state, and repository-dispatch calls used a loopback deterministic stub; no GitHub mutation occurred.
  • Command: Crabbox ran the attached proof script with --no-hydrate --preflight --timing-json and required proof/pr-1311-runtime.json.
  • Artifact/trace: this comment contains the redacted durable transcript. Crabbox also collected run_34e2b681ae4b-artifacts.tgz (968 bytes), SHA-256 f5ed83b6b79e35a5e6e4445328cbb5891942ae710191bc6613980a7e6edf061d.

Observed results

Scenario Production-boundary observation
unchanged incomplete_source enqueue 202; claim 200 at revision 1; complete 200 {"ok":true,"requeued":false}; dispatch count remained 1 after settle
generic failure control claim 200 at revision 1; complete 200 {"ok":true,"requeued":true}; a second revision-1 dispatch was observed
newer revision control revision 2 enqueue 202; old revision-1 completion was fenced with 409 {"error":"lease_superseded","superseded_by_revision":2}; next dispatch carried lease_revision:2

Crabbox exited 0, required artifact matched once, and automatically stopped the lease.

Redacted JSON transcript
{
  "schema_version": 1,
  "tested_head": "98b0d7683d2eae06b54dca650e786f7f5beda2f1",
  "runtime": {
    "boundary": "Wrangler local HTTP -> production Worker -> SQLite Durable Object",
    "github_boundary": "loopback deterministic stub"
  },
  "observations": {
    "unchanged_incomplete_source": {
      "enqueue_status": 202,
      "claim_status": 200,
      "lease_revision": 1,
      "claim_generation": 1,
      "complete": {
        "status": 200,
        "body": {"ok": true, "requeued": false}
      },
      "dispatch_count_after_settle": 1
    },
    "generic_failure": {
      "claim_status": 200,
      "lease_revision": 1,
      "complete": {
        "status": 200,
        "body": {"ok": true, "requeued": true}
      },
      "retry_dispatch_lease_revision": 1
    },
    "newer_revision": {
      "enqueue_revision_2_status": 202,
      "claim_revision_1_status": 200,
      "complete_revision_1": {
        "status": 409,
        "body": {"error": "lease_superseded", "superseded_by_revision": 2}
      },
      "next_dispatch_lease_revision": 2
    }
  },
  "result": "pass"
}

Limits

  • This exercises the actual local Worker and SQLite Durable Object, not the deployed Cloudflare account.
  • The GitHub side of the unchanged queue contract is stubbed at loopback; transport, signing, queue persistence, leasing, completion, retry, and supersession are real.
  • The scanner itself is intentionally not invoked on this machine; proof begins at the typed workflow-to-queue failure contract changed by this PR.
  • OpenClaw Bay is unaffected: this changes mutation-side retry disposition only, while Bay remains an observer-only aggregate reader.

@sallyom

sallyom commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Exact-head real behavior proof is now current in the PR body and available in the redacted Crabbox transcript. It exercises the production Worker and SQLite Durable Object over HTTP at 98b0d7683d2eae06b54dca650e786f7f5beda2f1, including terminal consumption, generic retry, and newer-revision fencing/preservation.

@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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 status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 30, 2026
@sallyom
sallyom merged commit 99fa190 into main Aug 30, 2026
28 checks passed
@sallyom
sallyom deleted the fix/incomplete-source-terminal branch August 30, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. 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