Skip to content

fix(update): seal recovery captures on large state directories - #188919

Merged
roboclaw-bot merged 2 commits into
mainfrom
roboclaw/update-capture-inventory-batches
Oct 31, 2026
Merged

roboclaw-bot merged 2 commits into
mainfrom
roboclaw/update-capture-inventory-batches

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #188897

What Problem This Solves

Large state directories can leave every pre-update recovery capture incomplete because the inventory exceeds a child process's stdout limit.

User Impact

Recovery captures can now seal with large inventories. Failed optional captures explicitly warn NO ORIGINAL-STATE SNAPSHOT while the update continues; the warning remains in returned JSON and update history.

The fix must be installed in the updater performing the capture. A newer candidate cannot repair an older updater process already running. Older candidate workers retain their existing stdout contract and limit.

Why This Change Was Made

Metadata inventories now run in serial batches budgeted by escaped UTF-8 JSON bytes, with room for result fields, one aggregate deadline, and the same caller cancellation signal. Order, duplicates, missing files, and SQLite sidecar sizes are preserved; failure returns no partial inventory or subsequent child after cancellation. The per-child 1 MiB stdout cap stays unchanged.

The sibling audit also found unbounded database-discovery, backup-receipt, schema/generation, and candidate snapshot results. Both launchers now share an opt-in private result-file transport, read after successful process settlement and bounded like the existing recovery manifest. Legacy stdout interoperability and uncertain-cleanup retention remain intact. Payload capture already runs in process; progress backpressure handling needed no change.

Other open proposals for this issue: #188907 and #188912. This PR implements the requested fixed-cap batching design and covers the sibling result transports and warning behavior.

Evidence

  • RED → GREEN: main ae01f1c113826d3ff41463e74da6c115e5b581ff rejects 12,000 copies of an existing 160-character path with output-limit; the fixed owner returns all 12,000. Original-owner controls also reject the ASCII, UTF-8, and quote/backslash cases.
  • Regression proof: 12,000-entry ASCII/multibyte/escaped inventories, order/duplicates/missing/WAL sizes, cancellation during a later batch, one aggregate deadline, oversized sibling results, and warning visibility in returned JSON pass. New size tests took 1.437 s; sibling transport tests took 8.521 s. Existing backup/budget/schema/lifetime/inventory tests also passed.
  • Real contained capture: Landlock + Bubblewrap, private synthetic state, 12,000 distinct payload files plus config and real SQLite. Sealed manifest: 12,007 entries / 4,075,036 bytes. All 12,002 file payloads were reconstructed and hash-verified; SQLite integrity and sentinel checks passed. Zero capture warnings. Capture plus verification: 57.823 s. Manifest SHA-256: 1fafd9c4b9379d3c2b9ba4bac41d6e5b269f461739a8b14098c81f8de4615995. No protected-state access, service execution, or TCP activity. This proves capture sealing and payload reconstruction; it does not claim an installed-package upgrade or automatic rollback over active state.
  • Local checks: production core typecheck, services and CLI-update test typechecks, focused lint, format, diff check, and test-line ratchet pass. The touched CLI suite has 31 passing / 1 failing test. The unchanged invalid-dev-target existing-state assertion also fails on untouched base ae01f1c with the same missing error callback; its same-order five-test prefix has 4 passing / 1 failing. No retry/ignore/exception masks it. Both capture-warning regressions pass. The candidate resource/legacy-stdout owner suite passes 25/25 under private umask 077; this host’s default 0002 also exposes an unrelated explicit-temp fixture permission failure on untouched base. No product guard or assertion was relaxed.
  • Simplification: one batching owner and one transport shared by the two launchers; no raised stdout cap or new manager/config/schema/cache. Production net +103 lines; tests net +184. The exact +184 test allocation covers the requested scale/cancellation/deadline regressions and distinct sibling/JSON-warning boundaries; shared scalar unchanged.
  • Fresh independent review: Codex autoreview, P0–P2, against base ae01f1c and candidate tree 3155ef3d5b5440be3d8ead464cec865ecc1a8b74: scoped-clean, zero findings. Refreshed after the legacy stdout fixture cutover; one complete pass with all 12 changed files and supplied owner/caller context; the isolated reviewer did not execute tests. Helper source SHA-256: ea4d3415094d50a670f28a1ee092e928a9dbcf7327103014c3a9f909d9a6ef17.
  • Exact-head CI: run 41155734580 completed success on ae632d33a5f6366d661b4e781cb10560370e583f, attempt 1: 45 passed / 26 skipped, including all three PostgreSQL conformance shards. Final PR checks: 63 passed / 57 skipped, none failed or pending. Workflow wall time: 1,504 seconds (25m 4s). The initial legacy-stdout fixture failure was corrected and verified; no workflow was rerun to chase green.

Design credit: @ourcoms2018 proposed and tested the fixed-cap batching design. Co-authored with @ourcoms2018 and @steipete; both human credits are preserved in the commit trailers.

Work sessions

Implementation and verification

Batch metadata inventory by escaped UTF-8 byte size under the existing child
output cap, with one deadline and caller cancellation across batches. Keep
large discovery and backup results in private settled worker artifacts and
make unavailable original-state capture explicit in update warnings.

Co-authored-by: ourcoms2018 <[email protected]>
Co-authored-by: steipete <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: M labels Oct 31, 2026
Make the older-candidate fixture decline result-file transport before
rewriting its real stdout response, preserving the legacy capacity check.

Co-authored-by: ourcoms2018 <[email protected]>
Co-authored-by: steipete <[email protected]>
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR batches metadata inventories, transports large worker results through private files, and makes unavailable recovery captures explicit.

Example: An update captures 12,000 existing files with long paths.

  • Before: The inventory exceeds the 1 MiB stdout cap and leaves the recovery capture incomplete.
  • After: Sequential byte-budgeted batches return the complete inventory without raising the stdout cap.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation is focused and source-consistent, with relevant real-child regressions, but supplied behavior evidence stops short of the required packaged upgrade boundary.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Large installations finish updates with incomplete original-state captures and no usable complete pre-update recovery copy.
Reason: The failure violates documented capture behavior, and the maintainer-authored direction preserves best-effort updates and existing recovery ownership.

Merge readiness

✅ Ready for maintainer review

This PR addresses a confirmed recovery-capture failure still present on current main; source review found no discrete correctness or security defect.

Priority: P1
Reviewed head: ae632d33a5f6366d661b4e781cb10560370e583f

Before merge

None.

Findings

None.

Tests

  • Low-value test src/cli/update-cli/update-command-fresh-preview.test.ts: Collapse the two capture-warning cases: both inject the same nested generic Error and exercise identical control flow, differing only in incidental cause text.
  • Missing end-to-end proof: Provide a packaged latest-stable upgrade with existing settings and data intact, then exercise the repaired installed updater on an oversized capture and inspect its sealed recovery set.
Agent review details

How this fits together

The installed updater inventories source files and databases, delegates inspection and backup to owned workers, and uses their results to seal recovery captures before continuing the update.

flowchart TD
  A[Update CLI] --> B[Recovery capture owner]
  B --> C[Byte budgeted metadata batches]
  C --> D[Bounded metadata child]
  B --> E[Inspection and backup workers]
  E --> F[Private result file or legacy stdout]
  F --> B
  B --> G[Sealed capture or recorded warning]
Loading

Technical review

Best possible solution:

Retain the shared batching and result transport, with packaged upgrade evidence confirming existing settings, data, and recovery captures remain usable.

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

The current parent and real child establish a deterministic oversized-array failure, supported by the reporter's official-release observations and the PR's reported base-versus-fix controls; this review executed no reproduction.

Is this the best way to solve the issue?

Byte-budgeted batches fix the existing inventory owner, while one opt-in result transport closes the same limit in sibling workers without changing stored formats or removing released-worker interoperability.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 18516599b1d4.

Provenance checked

  • Metadata subprocess batching keeps the original intent (22b59cf: Keep filesystem metadata calls cancellable and preserve parent-owned staging across worker settlement.)
  • Worker result transport changes intended behavior with a stated reason (feb2c81: Preserve released stdout JSON interoperability and retain staging when cleanup is uncertain; the PR explains why large results need an opt-in alternative.)
  • Output-limit diagnostics keeps the original intent (05be06d: Report the runner's actual output-limit cause rather than an unexplained terminating signal.)
  • Optional capture warning keeps the original intent (a647368: Avoid telling operators to restart a completed update after optional capture failure; the revised warning preserves that guidance and explains the missing recovery copy.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +103, Tests +184, Docs +1, Other +2. Total +290 across 12 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 6 178 75 +103
Tests 4 210 26 +184
Docs 1 3 2 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 12 393 103 +290

Root-cause cluster

Relationship: same_root_cause
Canonical: #188897
Summary: The issue and both alternative PRs concern the same whole-inventory stdout limit.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P1: Official-release users report repeated unavailable pre-update recovery captures, and current main retains the deterministic output-limit failure.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: Official-release users report repeated unavailable pre-update recovery captures, and current main retains the deterministic output-limit failure.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Provide the packaged upgrade and oversized-capture evidence described above.
  • Collapse the duplicate mocked capture-warning case.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 30, 2026, 9:48 PM ET / October 31, 2026, 01:48 UTC.

@roboclaw-bot
roboclaw-bot merged commit 4f1515d into main Oct 31, 2026
165 of 166 checks passed
@roboclaw-bot
roboclaw-bot deleted the roboclaw/update-capture-inventory-batches branch October 31, 2026 02:09
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…law#188919)

Batch metadata inventories by escaped UTF-8 JSON byte budget while retaining the fixed 1 MiB per-child stdout cap, one aggregate deadline, and caller cancellation. Share bounded private result-file transport across sibling capture launchers and warn clearly when optional original-state capture cannot seal, while allowing updates to succeed.

Verified 12,000-entry ASCII, multibyte, and escaped inventories; cancellation and aggregate deadlines; sibling transports and JSON warning visibility. Contained 12,000-file production capture sealed and all 12,002 restored payload hashes matched. Exact-head CI run 41155734580 passed; fresh independent Codex P0–P2 review and ClawSweeper reported zero findings.

Fixes openclaw#188897

Co-authored-by: ourcoms2018 <[email protected]>
Co-authored-by: steipete <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Release adaptation: port #188919 with its #190991 monotonic-clock companion; omit release-owned changelog. Bounded result-file transport preserves legacy stdout producers; metadata batches retain one aggregate deadline, cancellation, and uncertain cleanup custody. Self-review: one transport owner, no schema changes; retained growth is the required producer/consumer cutover and distinct boundary regressions.

Proof: baseline real-child 12000-entry regression fails output-limit; all 8 inventory, transport, cancellation, deadline and wall-clock regressions pass. Formatting and diff checks pass. Focused CLI preview is still pending; parent release qualification remains required. Later same-path #190991 included; no other later sizes-owner change.

(cherry picked from commit 4f1515d)
(cherry picked from commit ab35e1f)

Co-authored-by: ourcoms2018 <[email protected]>
Co-authored-by: SunnyShu <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M 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.

[Bug]: Update capture never seals on large state dirs — metadata inventory result exceeds the 1 MiB stdout cap

1 participant