Skip to content

feat(state): snapshot+journal record hydration (phase 2) - #874

Merged
steipete merged 1 commit into
mainfrom
feat/worker-state-readers
Jul 26, 2026
Merged

steipete merged 1 commit into
mainfrom
feat/worker-state-readers

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

Phase 2 moves canonical record hydration behind an opt-in Worker-backed snapshot+journal transport while keeping Git as the default source.

Per-repository gzip snapshots are streamed to R2 with multipart upload and keep-two pruning. Authenticated Worker endpoints trigger exports, expose the latest snapshot, and serve byte ranges through a 32 MiB proxy because R2 bindings cannot presign downloads. The measured openclaw-openclaw tree was 603 MB across 34,459 files and compressed to a 124.9 MiB snapshot; typical journal deltas were 44–87 KiB.

hydrate-state now supports CLAWSWEEPER_RECORDS_SOURCE=worker, using an Actions-cached snapshot plus since-revision deltas while preserving the byte-identical on-disk record layout. Snapshot-store unavailability takes the loud, fail-closed Git fallback path. A cursor-resumable workflow_dispatch workflow backfills Git records into canonical Worker storage one repository at a time, and a tree-based parity verifier is the cutover gate.

Contracts

  • Git remains the default records source; this PR does not cut production hydration over to Worker storage.
  • The existing flat per-repository items/ and closed/ record layout remains byte-identical after hydration.
  • Snapshot publication is per repository, journal deltas are revision-addressable, and only the two newest R2 snapshots are retained.
  • Trigger, latest-snapshot, and range endpoints remain authenticated.
  • Backfill is cursor-resumable and explicitly dispatched per repository.
  • Tree parity must pass before any source-default cutover.
  • Provisioning the clawsweeper-state-snapshots R2 bucket is the one pending manual deployment step.

Proof

  • Focused tests: 238/238 passed.
  • Unit tests: 1,638 passed.
  • Autoreview: CLEAN (0.98); TruffleHog clean.
  • Broader local validation had only the previously identified environment-specific failures; exact-head hosted CI is the merge gate.

…rnal deltas (state-repo retirement, phase 2)

canonical records now export via snapshot+journal (per-repo gzip snapshot streamed to R2 via multipart with keep-two pruning and authenticated trigger/latest/range endpoints — 32MiB range proxying since R2 bindings cannot presign; measured: 603MB/34,459-file openclaw-openclaw tree → 124.9MiB snapshot, typical deltas 44-87KiB); hydrate-state gains CLAWSWEEPER_RECORDS_SOURCE=worker mode (Actions-cached snapshot + since-revision deltas, byte-identical on-disk layout, loud fail-closed git fallback when the snapshot store is unavailable); cursor-resumable git→canon backfill workflow (workflow_dispatch per repo); tree-based parity verifier as the cutover gate. Defaults stay git; R2 bucket provisioning (clawsweeper-state-snapshots) is the one pending manual step.
@steipete
steipete requested a review from a team as a code owner July 26, 2026 18:16
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. labels Jul 26, 2026
@clawsweeper

clawsweeper Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 26, 2026, 2:20 PM ET / 18:20 UTC.

ClawSweeper review

What this changes

This PR adds an opt-in Worker-backed snapshot-and-journal transport for hydrating generated state records, with Git retained as the default source.

Merge readiness

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

Keep this PR open until the new production R2 dependency is provisioned and the Worker-backed path has real after-fix proof. The implementation deliberately preserves Git as the default, but the branch’s own deployment contract says the required clawsweeper-state-snapshots bucket is still pending, so merging the Worker binding now could block deployment rather than safely leave the feature dormant.

Priority: P2
Reviewed head: d79ddea09dc582ec37ce41859dfe607371558433
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The branch has substantial focused coverage, but an unprovisioned production dependency and missing real-runtime proof make it not ready to merge.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR body reports focused and unit-test results, but it provides no inspectable after-fix real-runtime proof of the deployed R2 snapshot, Worker hydration, journal replay, or parity path. Please attach a redacted terminal transcript, linked artifact, or recording; after updating the PR body, request @clawsweeper re-review if a fresh review does not start automatically. 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 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body reports focused and unit-test results, but it provides no inspectable after-fix real-runtime proof of the deployed R2 snapshot, Worker hydration, journal replay, or parity path. Please attach a redacted terminal transcript, linked artifact, or recording; after updating the PR body, request @clawsweeper re-review if a fresh review does not start automatically. 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 4 items Pending deployment prerequisite: The PR body explicitly identifies provisioning the clawsweeper-state-snapshots R2 bucket as a pending manual deployment step, while the patch adds that bucket as a Worker binding.
Production binding added: The changed Worker configuration declares an R2 binding named STATE_SNAPSHOTS for clawsweeper-state-snapshots; a deployment needs that named Cloudflare resource to exist.
New authenticated state transport: The patch adds authenticated Worker routes for record export, ingest, snapshot lookup, snapshot triggering, and snapshot chunks, so the deployment prerequisite affects the new state-read path rather than documentation alone.
Findings 1 actionable finding [P1] Provision the R2 bucket before binding production Worker config
Security None None.

How this fits together

ClawSweeper workflows hydrate generated review records before review and apply jobs use them. This PR adds an optional path that reads per-repository snapshots and journal deltas from the authenticated dashboard Worker and its R2-backed snapshot store instead of the state Git checkout.

flowchart LR
  A[Generated state records] --> B[Git state checkout]
  B --> C[Hydrate generated state]
  D[Authenticated dashboard Worker] --> E[Snapshot and journal records]
  F[R2 snapshot bucket] --> D
  E --> C
  C --> G[Review and apply workflows]
Loading

Decision needed

Question Recommendation
Has the production clawsweeper-state-snapshots R2 bucket been provisioned, and should this Worker binding merge only after a successful deployed end-to-end parity run? Provision and verify first: Create the R2 bucket, deploy the Worker binding, and require redacted export, hydration, journal, and parity evidence before merging.

Why: The missing resource is external deployment state rather than a repository-only repair, and it determines whether this otherwise opt-in path can be safely deployed.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports focused and unit-test results, but it provides no inspectable after-fix real-runtime proof of the deployed R2 snapshot, Worker hydration, journal replay, or parity path. Please attach a redacted terminal transcript, linked artifact, or recording; after updating the PR body, request @clawsweeper re-review if a fresh review does not start automatically. 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.
  • Provision the R2 bucket before binding production Worker config (P1) - This adds a Worker binding for clawsweeper-state-snapshots, while the PR body says that bucket is still a pending manual deployment step. Deploying a Worker configuration that references a nonexistent bucket can block the dashboard deployment; provision it and attach deployed proof first, or defer this binding.
  • Resolve merge risk (P1) - The required clawsweeper-state-snapshots R2 bucket is explicitly unprovisioned; merging the Worker binding before that resource exists can block deployment of the dashboard Worker.
  • Resolve merge risk (P1) - The supplied proof lists focused and unit tests, but it does not include inspectable after-fix evidence of a deployed snapshot export, Worker hydration, journal replay, and parity result.
  • Complete next step (P2) - A maintainer must confirm the external R2 resource is provisioned and review deployed end-to-end proof; this cannot be safely repaired by a repository-only automation job.
  • Improve patch quality - Provision the production R2 bucket before deploying the new Worker binding.
  • Improve patch quality - Attach redacted real-runtime evidence for snapshot publication, Worker hydration, journal replay, fallback handling, and tree parity.
  • Improve patch quality - Refresh the PR review after proof is added; a maintainer can comment @clawsweeper re-review if needed.

Findings

  • [P1] Provision the R2 bucket before binding production Worker config — dashboard/wrangler.toml:11-12
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Changed surface 17 files; 3,058 added, 33 removed The PR spans Worker storage, workflow setup, hydration scripts, and test coverage, so deployment proof needs to cover the integrated path.
New state routes 5 authenticated Worker routes The added export, ingest, snapshot lookup, trigger, and chunk endpoints expand the operational state-transport surface.

Merge-risk options

Maintainer options:

  1. Provision and prove the Worker path (recommended)
    Create the required R2 bucket and attach a redacted deployed transcript showing snapshot publication, Worker-mode hydration, journal replay, and tree parity before merge.
  2. Pause the deployment binding
    If the bucket cannot be provisioned now, defer this infrastructure change rather than merge a Worker configuration that references an unavailable production resource.

Technical review

Best possible solution:

Provision the R2 bucket first, then attach redacted real-runtime proof showing a snapshot export, Worker-mode hydration with journal replay, and a successful Git-versus-Worker parity check before merging.

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

No high-confidence live reproduction is included. The deployment failure mode is source-reproducible: the added R2 binding requires the bucket named in dashboard/wrangler.toml to exist in the deployed Cloudflare environment.

Is this the best way to solve the issue?

No, not yet: retaining Git as the default is a sensible compatibility boundary, but the deployment resource and real end-to-end proof must precede a safe merge of the Worker binding.

Full review comments:

  • [P1] Provision the R2 bucket before binding production Worker config — dashboard/wrangler.toml:11-12
    This adds a Worker binding for clawsweeper-state-snapshots, while the PR body says that bucket is still a pending manual deployment step. Deploying a Worker configuration that references a nonexistent bucket can block the dashboard deployment; provision it and attach deployed proof first, or defer this binding.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a normal-priority infrastructure change with a concrete deployment blocker, but Git remains the default and current users are not yet routed to the new source.
  • add merge-risk: 🚨 availability: The new Worker configuration binds a bucket the PR identifies as not yet provisioned, which can prevent the dashboard Worker from deploying.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • 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 and unit-test results, but it provides no inspectable after-fix real-runtime proof of the deployed R2 snapshot, Worker hydration, journal replay, or parity path. Please attach a redacted terminal transcript, linked artifact, or recording; after updating the PR body, request @clawsweeper re-review if a fresh review does not start automatically. 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:

  • P2: This is a normal-priority infrastructure change with a concrete deployment blocker, but Git remains the default and current users are not yet routed to the new source.
  • merge-risk: 🚨 availability: The new Worker configuration binds a bucket the PR identifies as not yet provisioned, which can prevent the dashboard Worker from deploying.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • 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 and unit-test results, but it provides no inspectable after-fix real-runtime proof of the deployed R2 snapshot, Worker hydration, journal replay, or parity path. Please attach a redacted terminal transcript, linked artifact, or recording; after updating the PR body, request @clawsweeper re-review if a fresh review does not start automatically. 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:

  • Pending deployment prerequisite: The PR body explicitly identifies provisioning the clawsweeper-state-snapshots R2 bucket as a pending manual deployment step, while the patch adds that bucket as a Worker binding. (dashboard/wrangler.toml:12, d79ddea09dc5)
  • Production binding added: The changed Worker configuration declares an R2 binding named STATE_SNAPSHOTS for clawsweeper-state-snapshots; a deployment needs that named Cloudflare resource to exist. (dashboard/wrangler.toml:11, d79ddea09dc5)
  • New authenticated state transport: The patch adds authenticated Worker routes for record export, ingest, snapshot lookup, snapshot triggering, and snapshot chunks, so the deployment prerequisite affects the new state-read path rather than documentation alone. (dashboard/worker.ts:561, d79ddea09dc5)
  • Default compatibility boundary: The PR describes Git as the default records source and makes Worker hydration opt-in through the setup-state action inputs, which limits upgrade impact once the deployment dependency is satisfied. (.github/actions/setup-state/action.yml:47, d79ddea09dc5)

Likely related people:

  • steipete: The available PR metadata identifies steipete as author of the single commit implementing the Worker-backed record hydration and R2 snapshot design; no broader current-main ownership trail was available in the supplied review material. (role: proposed architecture author; confidence: medium; commits: d79ddea09dc5; files: dashboard/record-snapshots.ts, scripts/worker-records.ts, dashboard/wrangler.toml)

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 3f3c9cf into main Jul 26, 2026
17 checks passed
@steipete
steipete deleted the feat/worker-state-readers branch July 26, 2026 18:25
azaj01 pushed a commit to azaj01/clawsweeper that referenced this pull request Sep 21, 2026
…rnal deltas (state-repo retirement, phase 2) (openclaw#874)

canonical records now export via snapshot+journal (per-repo gzip snapshot streamed to R2 via multipart with keep-two pruning and authenticated trigger/latest/range endpoints — 32MiB range proxying since R2 bindings cannot presign; measured: 603MB/34,459-file openclaw-openclaw tree → 124.9MiB snapshot, typical deltas 44-87KiB); hydrate-state gains CLAWSWEEPER_RECORDS_SOURCE=worker mode (Actions-cached snapshot + since-revision deltas, byte-identical on-disk layout, loud fail-closed git fallback when the snapshot store is unavailable); cursor-resumable git→canon backfill workflow (workflow_dispatch per repo); tree-based parity verifier as the cutover gate. Defaults stay git; R2 bucket provisioning (clawsweeper-state-snapshots) is the one pending manual step.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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