Skip to content

fix(fanout): move rotation cursor to canonical store - #957

Merged
steipete merged 1 commit into
mainfrom
fix/fanout-cursor-canonical
Jul 30, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/fanout-cursor-canonical

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • move the per-mode target-fanout cursor from clawsweeper-state into authenticated ExactReviewQueue Durable Object KV
  • expose HMAC-authenticated GET/PUT /internal/state/cursors/<mode> with optimistic monotonic revisions
  • make cursor reads, writes, and live-inventory publication fail open so canonical-store trouble never blocks repository dispatch
  • remove the fanout job's state token, Git-state checkout, and repair:publish-main cursor step
  • audit the remaining operational Git writers and make post-side-effect bookkeeping non-fatal while preserving strict pre-dispatch durability fences

Root cause

The scheduled fanout dispatched its selected repositories and then ran a mandatory Git publication for results/target-fanout-cursors/**. Run https://github.com/openclaw/clawsweeper/actions/runs/30533320020 reached that final step, but GitHub rejected the clawsweeper-state push with fatal error in commit_refs. The workflow therefore left the previous cursor in Git. Every later cycle hydrated that same cursor and selected the same head-of-list repositories, so nominal queue capacity did not translate into fleet coverage.

The cursor is now a small Durable Object record keyed by mode. A write includes the revision read before dispatch; a stale writer receives 409 fanout_cursor_revision_conflict instead of silently overwriting a newer cursor. If either read or write fails, fanout emits a prominent warning and continues. Dispatched work remains valid even when cursor persistence is unavailable.

Remaining clawsweeper-state writers

Surface Change in this PR Failure policy after this PR
Target-fanout cursors Converted to ExactReviewQueue Durable Object KV No Git writer remains
Sweep/review/apply/audit dashboard status and auxiliary apply reports/cursors Left in Git for now Best-effort after canonical publication or GitHub mutation
Proof-nudge and bot-proof cursors Left in Git for now Best-effort after proof handling
Spam, self-heal, conflict-self-heal, finalizer, and failed-review retry bookkeeping Left in Git for now Step-level non-fatal publication
Comment-router jobs/** and command ledger Left in Git Strict: publication is the durability fence before retry dispatch
Commit/issue implementation intake jobs/** and results/** Left in Git Strict: publication owns durable intake state
Cluster result jobs/**, results/**, notifications/**, and report state Left in Git Strict dedicated publisher so failure remains visible and retryable
State-history compaction Left in Git Strict maintenance-only writer

Yes, writers to openclaw/clawsweeper-state still remain, so that repository cannot be archived yet. This PR removes the live fanout dependency that is blocking fleet coverage, but the strict rows above still need canonical owners before archival.

Proof

  • node --test test/repair/target-fanout.test.ts test/state-writer-workflow.test.ts test/sweep-workflow.test.ts test/dashboard-worker.test.ts — 369 passed
  • pnpm run format:check — clean
  • pnpm run build:all — clean
  • pnpm run lint — all four linters clean
  • /Users/steipete/.claude/skills/autoreview/scripts/autoreview --mode local — clean, no accepted/actionable findings
  • /Users/steipete/.claude/skills/autoreview/scripts/autoreview --mode branch --base origin/main — clean, no accepted/actionable findings

pnpm run check passed static checks, formatting, builds, lint, and coverage thresholds, but the full macOS run still exits on five unchanged Linux Landlock containment tests. Their generated Python runtime resolves libc.capset, which is unavailable on macOS; this branch does not touch that runtime or test file.

Coverage trajectory

With 138 configured repositories, the 20-repository hot cursor can traverse the fleet in seven 15-minute cycles (about 105 minutes), and the 12-repository normal cursor can traverse it in 12 hourly cycles. Normal fanout can again offer its configured 600 review candidates per hour instead of repeatedly feeding the same repositories. At the observed 127 completed reviews/hour, a static 3,260-item untracked backlog has an ideal drain time of roughly 26 hours; real convergence will vary with new intake, eligible open-item distribution, and queue health.

Deployment

The dashboard Worker must be redeployed so the new Durable Object endpoint is live. Until that redeploy, the merged workflow would still dispatch selected repositories and warn instead of failing, but cursor rotation would restart from the safe default each cycle and would not persist.

@steipete
steipete requested a review from a team as a code owner July 30, 2026 10:30
@clawsweeper clawsweeper Bot added 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. P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Jul 30, 2026
@clawsweeper

clawsweeper Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 30, 2026, 6:33 AM ET / 10:33 UTC.

ClawSweeper review

What this changes

The branch stores each target-fanout mode’s rotation cursor in the authenticated ExactReviewQueue Durable Object, removes the sweep workflow’s Git cursor publication, and makes selected post-side-effect Git bookkeeping writes best-effort.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 5 items remain

This PR addresses a real fanout-coverage failure by moving the rotation cursor off Git-backed state, but it should remain open until the dashboard Worker endpoint is deployed and the full scheduled path is proven against that deployment. Likely related people: steipete is the best available routing candidate from the PR’s implementation and deployment plan, with low historical-confidence evidence.

Priority: P1
Reviewed head: cafa0afe86155e51d4c2747ac7eb6929d2e4d75a
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation and focused test coverage are promising, but the missing deployed-path proof and rollout dependency keep this PR below merge-ready quality.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body reports focused tests, static checks, and local autoreview results, but does not show after-fix behavior in a deployed Worker plus scheduled fanout setup. Add redacted live output or logs showing authenticated cursor persistence and a subsequent advancing fanout run; after updating the PR body, a fresh ClawSweeper review should run automatically, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body reports focused tests, static checks, and local autoreview results, but does not show after-fix behavior in a deployed Worker plus scheduled fanout setup. Add redacted live output or logs showing authenticated cursor persistence and a subsequent advancing fanout run; after updating the PR body, a fresh ClawSweeper review should run automatically, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 5 items Fanout cursor migration: The branch changes target fanout from a checked-out Git cursor to an authenticated cursor-store URL and removes the final Git cursor publication step, addressing the reported failure mode where a rejected state-repository push prevented cursor advancement.
Authenticated canonical endpoint: The dashboard Worker adds narrowly matched GET and PUT routes for the three fanout modes and verifies the ExactReviewQueue HMAC signature before forwarding the request to the Durable Object.
Concurrency protection: The ExactReviewQueue change introduces a per-mode cursor record with a monotonic revision and a conflict response for stale writes, so concurrent scheduled writers do not silently overwrite a newer cursor.
Findings None None.
Security None None.

How this fits together

Target fanout selects repositories for scheduled ClawSweeper review work and advances a per-mode cursor so cycles cover the full configured fleet. The workflow now reads and writes that cursor through the dashboard Worker, which authenticates requests and forwards them to ExactReviewQueue Durable Object storage before dispatch results are published.

flowchart LR
  A[Scheduled target fanout] --> B[Live repository inventory]
  B --> C[Authenticated cursor endpoint]
  C --> D[ExactReviewQueue Durable Object]
  D --> E[Repository selection]
  E --> F[Workflow dispatches]
  E --> G[Cursor revision update]
  G --> D
Loading

Decision needed

Question Recommendation
Should the dashboard Worker endpoint be deployed before this workflow change is merged, with a post-deploy fanout run recorded as release evidence? Deploy endpoint first: Deploy the dashboard Worker, verify cursor GET/PUT and a scheduled fanout advance, then merge the workflow change.

Why: The code deliberately fails open when the endpoint is unavailable, so CI can pass while the deployed workflow continues the same non-rotating behavior that this PR is intended to fix.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports focused tests, static checks, and local autoreview results, but does not show after-fix behavior in a deployed Worker plus scheduled fanout setup. Add redacted live output or logs showing authenticated cursor persistence and a subsequent advancing fanout run; after updating the PR body, a fresh ClawSweeper review should run automatically, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The scheduled workflow begins using the new endpoint as soon as this branch lands, but the endpoint is not available until the dashboard Worker is redeployed; in that window fanout continues dispatching while repeatedly restarting from the default cursor.
  • Resolve merge risk (P1) - Fail-open cursor persistence is intentional, but production proof should show both a successful authenticated write and a subsequent scheduled/read path so warnings do not conceal a permanently unreachable endpoint.
  • Complete next step (P2) - A maintainer must coordinate the dashboard Worker deployment and inspect real scheduled-path evidence; there is no narrow branch repair to dispatch automatically from this review.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Change surface 17 files affected; 644 added, 94 removed The change spans the Worker, Durable Object, scheduled workflow, state-publishing behavior, documentation, and focused tests, so rollout sequencing matters beyond unit coverage.
Cursor modes 3 authenticated cursor modes The new endpoint covers hot intake, normal review, and audit fanout, so one failed deployment affects all scheduled fleet-rotation paths.

Merge-risk options

Maintainer options:

  1. Deploy and prove the cursor endpoint first (recommended)
    Deploy the dashboard Worker, then retain a redacted live GET/PUT and two-cycle fanout result before merging the workflow that depends on it.
  2. Accept temporary non-rotation
    Merge now only if maintainers explicitly accept that fleet rotation will restart from the default cursor until the Worker deployment completes.
  3. Hold for coordinated rollout
    Pause this PR if the endpoint cannot be deployed and verified alongside the scheduled workflow change.

Technical review

Best possible solution:

Deploy the dashboard Worker endpoint before enabling the updated scheduled workflow, then capture a redacted real run showing an authenticated cursor revision advances across two fanout executions while repository dispatch still succeeds.

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

Yes, at source level: the prior workflow required a Git-backed cursor publication after dispatch, and the reported rejected publication leaves the persisted cursor unchanged for later cycles. A current deployed reproduction of the new Worker endpoint and two sequential scheduled fanout runs is still needed.

Is this the best way to solve the issue?

Unclear until rollout evidence is available. Moving this small coordination record to the existing canonical Durable Object is a narrow maintainable fix, but it is only the best solution if the Worker endpoint is deployed before the workflow relies on it and the fail-open behavior is observed in a real run.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The PR addresses a current scheduled fanout failure that can repeatedly select the same repositories and materially reduce fleet review coverage.
  • add merge-risk: 🚨 availability: If the endpoint is absent or unreachable after merge, the intended cursor rotation remains unavailable even though dispatch continues fail-open.
  • add merge-risk: 🚨 automation: The merge changes a scheduled workflow to depend on a new authenticated Worker route whose deployment is explicitly separate from the branch.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports focused tests, static checks, and local autoreview results, but does not show after-fix behavior in a deployed Worker plus scheduled fanout setup. Add redacted live output or logs showing authenticated cursor persistence and a subsequent advancing fanout run; after updating the PR body, a fresh ClawSweeper review should run automatically, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P1: The PR addresses a current scheduled fanout failure that can repeatedly select the same repositories and materially reduce fleet review coverage.
  • merge-risk: 🚨 automation: The merge changes a scheduled workflow to depend on a new authenticated Worker route whose deployment is explicitly separate from the branch.
  • merge-risk: 🚨 availability: If the endpoint is absent or unreachable after merge, the intended cursor rotation remains unavailable even though dispatch continues fail-open.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports focused tests, static checks, and local autoreview results, but does not show after-fix behavior in a deployed Worker plus scheduled fanout setup. Add redacted live output or logs showing authenticated cursor persistence and a subsequent advancing fanout run; after updating the PR body, a fresh ClawSweeper review should run automatically, or a maintainer can comment @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Fanout cursor migration: The branch changes target fanout from a checked-out Git cursor to an authenticated cursor-store URL and removes the final Git cursor publication step, addressing the reported failure mode where a rejected state-repository push prevented cursor advancement. (src/repair/target-fanout.ts:114, cafa0afe8615)
  • Authenticated canonical endpoint: The dashboard Worker adds narrowly matched GET and PUT routes for the three fanout modes and verifies the ExactReviewQueue HMAC signature before forwarding the request to the Durable Object. (dashboard/worker.ts:549, cafa0afe8615)
  • Concurrency protection: The ExactReviewQueue change introduces a per-mode cursor record with a monotonic revision and a conflict response for stale writes, so concurrent scheduled writers do not silently overwrite a newer cursor. (dashboard/exact-review-queue.ts:462, cafa0afe8615)
  • Focused automated coverage: The PR adds worker round-trip and revision-conflict coverage plus fanout/workflow tests; the PR body reports 369 focused tests passed, but this is not proof of the deployed Worker-to-scheduled-workflow path. (test/dashboard-worker.test.ts:2585, cafa0afe8615)
  • Deployment dependency: The PR body explicitly says the dashboard Worker must be redeployed for the new cursor endpoint to exist. Before that deployment, the merged workflow would fail open and restart cursor selection from the safe default each cycle, leaving fleet rotation unresolved. (dashboard/worker.ts:549, cafa0afe8615)

Likely related people:

  • steipete: The PR description defines the fanout failure analysis, the Durable Object migration boundary, and the required dashboard deployment sequence. (role: implementation and deployment-plan author; confidence: low; commits: cafa0afe8615; files: src/repair/target-fanout.ts, dashboard/worker.ts, dashboard/exact-review-queue.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Deploy the dashboard Worker endpoint before the workflow change and add redacted live evidence of an advancing cursor across two fanout runs.
  • Record the rollout ordering in the PR body so reviewers can verify that the scheduled workflow never depends on an undeployed endpoint.

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.

@steipete
steipete merged commit e9df3d7 into main Jul 30, 2026
21 checks passed
@steipete
steipete deleted the fix/fanout-cursor-canonical branch July 30, 2026 10:36
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
Co-authored-by: clawsweeper <274271284+clawsweeper[bot]@users.noreply.github.com>
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. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P1 Urgent regression or broken agent/channel workflow affecting real users now. 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.

1 participant