Repository navigation
fix(state): bound record export reconstruction - #1253
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 10:27 PM ET / August 27, 2026, 02:27 UTC. ClawSweeper reviewWhat this changesThe PR selects export rows by authoritative byte metadata before reconstructing content, caps each response at 50 reconstructed records and 2 MiB of source content, and adds route-level regression coverage. Merge readinessKeep open for maintainer judgment: this is a MEMBER-authored PR, which repository policy treats as non-closeable. Source review finds the metadata-first cap preserves the existing cursor-based export flow and adds focused coverage without a concrete patch defect. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherThe signed internal state-export route reads canonical review records from the Worker Durable Object and returns paginated content to the state hydration client. This change inserts budgeted metadata selection before content reconstruction while retaining the existing response cursor. flowchart LR
A[Signed export request] --> B[Export index]
B --> C[Canonical or backfill metadata]
C --> D[Source-byte and record budget]
D --> E[Content reconstruction]
E --> F[Cursor-based export response]
Before merge
Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Retain metadata-first selection in the direct-publication store so every export page has bounded reconstruction work while the existing nextCursor pagination contract continues to deliver the full journal. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main reconstructs rows before testing the response-size boundary, while the PR's focused route fixture exercises the capped selection and cursor progression. Is this the best way to solve the issue? Yes. Selecting validated authoritative byte metadata before reading content is the narrowest way to bound reconstruction while preserving the established nextCursor protocol. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4a6f9ecb165e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
d261ede to
c58a833
Compare
What Problem This Solves
Resolves a problem where a signed records export could select a large page and reconstruct every candidate before enforcing the serialized response limit, allowing reconstruction work to grow with the requested page.
Why This Change Was Made
ExactReviewDirectPublicationStorenow owns metadata-first export selection. It joins authoritative canonical/backfill byte metadata, validates it fail-closed, and applies explicit source-byte and record-work budgets before reconstructing content while preserving the existing serialized response bound and deterministic cursor semantics.No schema, retry, CPU, snapshot, R2, or public request-shape changes are included.
User Impact
Operators can paginate record exports with bounded per-response reconstruction work. Oversized first records still make cursor progress, and repeated pages retain exact record ordering with no gaps or duplicates.
OpenClaw Bay Impact
Bay is unaffected. The change is limited to the signed internal record-export route and its durable-object store; no Bay query, status, telemetry, or dashboard contract changes.
Documentation Impact
No documentation update is required. The internal route shape and existing export contract remain unchanged; this patch hardens implementation limits only.
Release-note context: no changelog entry is needed because this is internal operational hardening with no user-facing API or configuration change.
Evidence
Real Behavior Proof
/internal/state/records/exportcall cannot reconstruct more than the configured source-byte and record-work budgets, advances its cursor, and repeated calls materialize the exact fixture.ExactReviewQueuedurable object.RECORD_EXPORT_PROOF_PATH="$PWD/.artifacts/bounded-record-export/worker-do-proof.json" node --test --test-concurrency=1 test/record-export-bounds.test.ts50/6/1/1records with source bytes51200/1605120/1600000/1600000; every page remained within the 50-record and 2 MiB source budgets. The oversized first record returned alone, advanced to cursor1, and the final path/digest manifest matched exactly..artifacts/bounded-record-export/worker-do-proof.json.Verification
115/115passed.4/4passed.1/1passed.git diff --check: passed.origin/main: clean.pnpm run check: static checks, docs, formatting, builds, lint, and coverage suites ran; the command exited nonzero on nine unrelated host/toolchain fixtures: one tmux window-lifecycle failure, seven target-validation failures resolving fixture[email protected]or@pnpm/[email protected]from the isolated package mirror, and one Git-hook callback assertion. The changed export suites remain green.Finding Disposition
Added route-level regression coverage for the two metadata branches missing from the original proof: a historical
itemsrecord whose authoritative content exists only in the backfill table, and a canonical tombstone with no backing content row. The test proves exact content/digest/revision/deletion output, cursor order, one backfill reconstruction for the live record, and zero reconstruction for the tombstone. No production or harness change was needed.Root Cause And Ownership
The export owner applied only a post-reconstruction serialized byte limit. Candidate selection lacked authoritative logical byte metadata and a bounded reconstruction-work decision, so the route could perform unbounded content reads before deciding where to stop.
The canonical fix keeps selection in
ExactReviewDirectPublicationStore, uses the existing export index plus canonical/backfill metadata tables, and passes queue-owned hard limits explicitly.LOC
+63/-9, net+54.+505/-0.+93/-8, net+85.Rebase Repair Verification
4a6f9ecb165edc400996fb3bb58c1a56d6133bd2.c58a8339ca860f72c541322599abda67b73d0ecf.500,application/json; charset=utf-8, a string error, and the affected record identity. No production or harness code changed.3/4; invalid-metadata coverage failed on the new Worker response contract.4/4; paired record-export and Durable Object error suite8/8; route/request/canonical matrix115/115; canonical export regression1/1..artifacts/bounded-record-export/rebased-worker-do-proof.jsonrecords page counts50/6/1/1, cursor progress, oversized-first progress, and exact manifest parity.git diff --check: passed. Pre-amend and committed-range reviews: clean.pnpm run check: static checks, builds, formatting, and lint passed; the full suite reached3,734/3,752passing with 9 skipped and the same 9 unrelated host/tooling failures already documented: one tmux proof fixture, seven isolated pnpm-mirror fixtures, and one signing-callback fixture.+63/-9; tests and test support are+521/-0. This repair adds+26/-10intest/record-export-bounds.test.tsonly.