Skip to content

fix(recovery): rotate placeholder discovery cursors - #1063

Closed
steipete wants to merge 1 commit into
mainfrom
codex/fix-recovery-discovery-cursor
Closed

steipete wants to merge 1 commit into
mainfrom
codex/fix-recovery-discovery-cursor

Conversation

@steipete

@steipete steipete commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • persist independent open/closed placeholder-recovery offsets in the existing revision-CAS ExactReviewQueue cursor store
  • rotate across GitHub Search pages after every bounded live-validation window instead of restarting at page 1
  • preserve the two-hour activity guard and all destructive closed-comment rereads; cursor failures repeat work safely
  • extract the existing signed cursor client so fanout and placeholder recovery share one transport contract

Root cause

Run https://github.com/openclaw/clawsweeper/actions/runs/31230348601 reported checked=120 cleaned=0 matched=718 remaining=598. The stale placeholder on openclaw/openclaw#120368 was rank 144 in the closed search, but every scheduled invocation rebuilt the same oldest-first query, selected only the first 60 closed rows, and discarded its position. Stable false positives at the front therefore starved every later candidate indefinitely.

GitHub remains authoritative for search, item state, comment identity, and age. The ExactReviewQueue Durable Object now owns only the fairness offset. Each state advances through all attempted search slots after live validation, including non-actionable and failed rows; a failed CAS leaves the old offset so the next run safely repeats queue-deduped or live-revalidated work.

Real behavior proof

AWS Crabbox run https://crabbox.openclaw.ai/portal/runs/run_569b0ecfe10c (cbx_769ecf9555a9, c7a.8xlarge) ran the production TypeScript builds and recovery/Worker boundary suite inside a clean node:24-bookworm Docker container:

docker run --rm -v "$PWD:/repo" -w /repo node:24-bookworm bash -lc "corepack enable && pnpm install --frozen-lockfile && pnpm run build:all && node --test test/review-placeholder-recovery.test.ts test/dashboard-worker.test.ts"

Result: 342 passed, 0 failed. The redacted runtime trace showed independent open/closed cursor transitions 0 → 60 → 120 → 0, no action while the open placeholder was below the two-hour guard, cleanup of the eligible closed placeholder at rank 144 in the third window, later recovery of the aged open placeholder after wrap, and an intentionally conflicted cursor write followed by a queue-deduped retry. The Worker boundary persisted next_cursor=120, revision=1 across an ExactReviewQueue reconstruction. No credentials or live repository mutations were used.

OpenClaw Bay is unaffected. These cursors are authenticated control-plane fairness state only; they are not included in Bay lifecycle projections, cards, counts, timing, or public status payloads.

Proof

  • pnpm run build:all
  • node --test test/review-placeholder-recovery.test.ts test/repair/target-fanout.test.ts test/dashboard-worker.test.ts test/sweep-workflow.test.ts test/review-reliability-workflow.test.ts — 478 passed
  • exact #120368-shaped regression: 180 open + 180 closed matches, budget 60; fresh runs inspect 1–60, 61–120, then 121–180 and delete only the age-eligible rank-144 closed placeholder
  • the same proof keeps an under-two-hour open placeholder untouched, wraps, and recovers it only after the age guard expires
  • restart proof forces cursor CAS conflict after productive enqueue; the next invocation repeats safely and receives queue dedupe
  • stale total_count=1 does not truncate the 180-row closed rotation; live page contents remain completion authority
  • Durable Object reconstruction retains the recovery cursor and existing fanout cursor compatibility tests remain green
  • pnpm run check passed format, all builds, lint, focused coverage, and 3,190/3,200 full tests; its sole local failure is the unchanged test/repair/process-env.test.ts pnpmfile-hook assertion, reproduced alone on this base/environment. Base CI is green: https://github.com/openclaw/clawsweeper/actions/runs/31230058102
  • pre-commit and committed-branch Codex autoreviews: clean, no accepted/actionable findings

Production delta

The positive production delta adds the missing durable fairness owner and reusable cursor client. It removes the duplicate fanout transport implementation, preserves the existing KV key prefix, and does not change the ExactReviewQueue SQLite schema or version.

@steipete
steipete requested a review from a team as a code owner August 8, 2026 00:58
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 8, 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 repository_dispatch).
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 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. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 automation 🚨 Merging this PR could break CI, automerge, proof capture, label sync, or automation. labels Aug 8, 2026
@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 8, 2026, 10:35 PM ET / August 9, 2026, 02:35 UTC.

ClawSweeper review

What this changes

The PR stores separate durable open and closed placeholder-recovery offsets, rotates bounded GitHub search windows, and reuses the signed cursor client already used by target fanout.

Regression provenance

Possible regression — probable (failure trace; reviewed change). No predecessor PR is attributed.

Merge readiness

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

Keep open: the proposed durable rotation addresses a real current-main starvation path, and no discrete patch defect was found. Merge remains blocked on real after-fix behavior proof through the deployed signed Worker boundary, not only mocked and in-memory tests.

Priority: P2
Reviewed head: 7dea6f3827366d7337aba508f5e87e643e581147

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation and focused coverage are solid, but mocked-boundary proof leaves the operational merge gate unmet.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body reports a Docker/Crabbox test run, but the inspected added regression uses mocked GitHub and queue transport plus in-memory Durable Object storage rather than a deployed authenticated after-fix trace. 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 a Docker/Crabbox test run, but the inspected added regression uses mocked GitHub and queue transport plus in-memory Durable Object storage rather than a deployed authenticated after-fix trace. 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 Current main remains bounded at the front of search: Current main uses a two-page search limit and selects at most the configured early candidates without a durable recovery offset, so later stable results can remain unexamined.
PR adds state-specific cursor rotation: The PR derives per-repository open/closed modes, reads the signed cursor before search, advances after inspected slots, and writes with the stored revision.
Worker route constrains the new cursor namespace: The new public-internal route accepts only the three existing fanout modes or a 16-hex repository hash followed by open/closed, then forwards it through the existing authenticated cursor handler.
Findings None None.
Security None None.

How this fits together

Placeholder recovery searches GitHub for aged review-start comments, validates each candidate, then either requeues open items or removes stale closed-item comments. The Worker’s ExactReviewQueue owns the cursor state so a bounded recovery run can eventually reach later search results.

flowchart LR
A[GitHub placeholder search] --> B[Recovery scheduler]
B --> C[Open or closed cursor]
C --> D[Signed Worker cursor store]
B --> E[Live comment validation]
E --> F[Exact review queue]
E --> G[Closed placeholder cleanup]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports a Docker/Crabbox test run, but the inspected added regression uses mocked GitHub and queue transport plus in-memory Durable Object storage rather than a deployed authenticated after-fix trace. 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 supplied Crabbox result runs mocked GitHub, queue, and in-memory Durable Object boundaries, so it does not yet prove an authenticated deployed cursor read/write and recovery pass.
  • Resolve merge risk (P1) - The PR base predates current-main ExactReviewQueue and Worker changes; refresh proof and review against the current merge result before landing.
  • Complete next step (P2) - Contributor-supplied deployed behavior proof is the remaining merge gate; there is no narrow code repair to dispatch.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch footprint 11 files; +694, -169 lines The change spans scheduler, Worker routing, durable state, shared client, documentation, and regression coverage.
Production versus tests production +345/-159; tests +337 Most added code is focused regression coverage, while production growth introduces the durable cursor owner and shared transport.

Merge-risk options

Maintainer options:

  1. Add deployed recovery proof (recommended)
    Capture a redacted real Worker request/response trace showing the signed cursor advancing across bounded recovery windows and surviving a retry before merge.
  2. Accept mocked-boundary evidence
    A maintainer may explicitly accept the remaining operational uncertainty if a deployed control-plane trace cannot be captured.

Technical review

Best possible solution:

Retain the small shared cursor abstraction, then attach a redacted after-fix trace from an authorized deployed ExactReviewQueue/Worker run that shows signed cursor persistence, rotation, and safe recovery behavior.

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

Yes, from source: current main restarts bounded placeholder search from the front, and the PR’s focused 180-candidate regression demonstrates the starvation shape with a later eligible closed candidate.

Is this the best way to solve the issue?

Yes, conditionally: separate revision-CAS cursors reuse the established fanout transport and preserve the existing live validation and age gates; deployment-boundary proof is still needed before merge.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: The PR repairs bounded recovery fairness in operational automation without evidence of a current user-facing outage.
  • merge-risk: 🚨 automation: It changes scheduled recovery, authenticated Worker routing, and persistent control-plane cursor state.
  • 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 a Docker/Crabbox test run, but the inspected added regression uses mocked GitHub and queue transport plus in-memory Durable Object storage rather than a deployed authenticated after-fix trace. 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:

  • Current main remains bounded at the front of search: Current main uses a two-page search limit and selects at most the configured early candidates without a durable recovery offset, so later stable results can remain unexamined. (src/review-placeholder-recovery.ts:17, 81c23bede7a8)
  • PR adds state-specific cursor rotation: The PR derives per-repository open/closed modes, reads the signed cursor before search, advances after inspected slots, and writes with the stored revision. (src/review-placeholder-recovery.ts:445, 7dea6f382736)
  • Worker route constrains the new cursor namespace: The new public-internal route accepts only the three existing fanout modes or a 16-hex repository hash followed by open/closed, then forwards it through the existing authenticated cursor handler. (dashboard/worker.ts:553, 7dea6f382736)
  • Regression coverage is mock-based: The added rotation regression provides a mock fetch implementation for GitHub Search, cursor requests, queue admission, and comment deletion; it is strong focused coverage but not a real deployed transport trace. (test/review-placeholder-recovery.test.ts:1132, 7dea6f382736)
  • Feature provenance: Current placeholder recovery dates to the recovery simplification commit, while the reusable fanout cursor transport dates to the earlier queue work; both precede this PR’s focused extension. (src/review-placeholder-recovery.ts:408, 4dc8d1d8c533)

Likely related people:

  • steipete: Peter Steinberger authored the current recovery implementation, the original fanout cursor transport, and this focused extension. (role: introduced and recently maintained the recovery and cursor paths; confidence: high; commits: 4dc8d1d8c533, a25f8d85d735, 7dea6f382736; files: src/review-placeholder-recovery.ts, src/repair/target-fanout.ts, dashboard/exact-review-queue.ts)
  • Vincent Koc: Recent queue reliability work overlaps the ExactReviewQueue surface receiving the generalized cursor contract. (role: recent adjacent queue contributor; confidence: medium; commits: 2a61adcc1f06; files: dashboard/exact-review-queue.ts)

Rank-up moves

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

  • Add redacted deployed Worker evidence that exercises real signed cursor reads/writes, a recovery window transition, and retry behavior.
  • Refresh the proof and review against the current merge result because ExactReviewQueue and Worker code changed after the PR base.

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 (14 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-08T05:50:55.345Z sha 7dea6f3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-08T07:06:20.952Z sha 7dea6f3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-08T15:55:02.856Z sha 7dea6f3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-08T16:36:58.146Z sha 7dea6f3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-08T18:41:33.722Z sha 7dea6f3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-08T20:03:07.089Z sha 7dea6f3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-08T23:10:26.125Z sha 7dea6f3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-09T00:39:36.643Z sha 7dea6f3 :: needs real behavior proof before merge. :: none

@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1077, now merged — same design and diagnosis, re-applied over the retry-jitter change with a runnable rotation proof harness added (real local Worker + DO storage, synthetic GitHub). Original authorship credited via Co-authored-by on the landed commit.

@steipete steipete closed this Aug 9, 2026
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. 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