Skip to content

fix(update): scale the metadata inventory output cap with its path list - #188912

Closed
wr-web wants to merge 1 commit into
openclaw:mainfrom
wr-web:fix/update-inventory-output-cap
Closed

wr-web wants to merge 1 commit into
openclaw:mainfrom
wr-web:fix/update-inventory-output-cap

Conversation

@wr-web

@wr-web wr-web commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #188897

Note: #188907 was opened while this was in progress; at the time of writing it contains only a planned it.todo. This PR has the implementation, the failing-then-passing regression and a live A/B run.

What Problem This Solves

The update capture measures every state database through readUpdateStateDatabaseSizes(). That function sends the path list to the updateStateSizes child process and reads back one JSON array. The child's stdout was capped at a fixed 1 MiB with terminateOnOutputLimit. Each result entry repeats its path, so the cap is reached after roughly 6,000 to 7,000 databases (fewer when paths are long). The child is then killed with output-limit and the capture is never sealed. The reporter has about 640,000 inventory paths and 4 of 4 retained captures incomplete ("no sealed manifest is available").

User Impact

Long-lived installs with many agent databases get a sealed recovery set again, instead of an update that succeeds with no usable rollback capture.

Why This Change Was Made

The child's output is derived from its input: one entry per existing path, holding that same path plus a decimal sizeBytes. So the stdout cap is now computed from the request: input JSON bytes, plus 64 bytes per path for the size field and punctuation, plus 1 MiB of slack. This keeps output bounded (a misbehaving child still hits output-limit) without making the bound a fixed count that scales the wrong way. The child script, the timeout budget and the progress channel (stderr) are unchanged.

Not addressed here: the reporter's very large inventories still pass every path through one child request and one parsed array. That works at the measured sizes, but chunking could be a follow-up if maintainers prefer it.

Evidence

Production readUpdateStateDatabaseSizes() with the real updateStateSizes child process, on Windows 11 / Node 26.12.1.

  • Setup: N distinct agent databases (<state>/agents/agent-NNNNNN/agent/openclaw-agent.sqlite) created on disk.
  • Variable: same harness and files; only src/infra/update-candidate-state.sizes.ts differs between main 2908f7a and this branch.

proof

databases input JSON main 2908f7a this branch
3,000 282 KB 3,000 entries (238 ms) 3,000 entries (234 ms)
6,000 564 KB 6,000 entries (371 ms) 6,000 entries (372 ms)
12,000 1.13 MB output-limit: "State schema inventory failed (output-limit): Worker output exceeded its capture limit" (1.2 s) 12,000 entries (710 ms)
40,000 3.76 MB output-limit (2.6 s) 40,000 entries (2.1 s)

The regression is a new case in src/infra/update-candidate-state.budget.test.ts, "inventories more paths than a fixed 1 MiB result would hold". It inventories 12,000 paths through the real child.

  • On main: it fails with the same output-limit the reporter saw.
  • With this change: it passes.
  • Existing cases: the output-limit case (child output capped at 1 byte through the runner) and the metadata-budget cases still pass.

Command: node scripts/run-vitest.mjs run src/infra/update-candidate-state.budget.test.ts -t "inventor".

Gates run locally: oxfmt, oxlint, pnpm check:line-cap-ratchet, pnpm check:test-lines-ratchet. Not run: a full openclaw update on a large real state directory. The proof calls the inventory step directly.

@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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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. and removed clawsweeper:intake:bug 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 real behavior proof before merge.

What this changes

This PR scales the metadata inventory worker’s stdout limit with its serialized input and adds a large-inventory regression test.

Example: Inventory 12,000 existing database paths on Windows 11 with Node 26.12.1.

  • Before: The worker exceeds the fixed 1 MiB stdout limit and fails with output-limit.
  • After: The supplied production-function run returns all 12,000 entries.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch is focused and source-correct, with a meaningful real-child regression, but required shipped-entry-point validation remains incomplete.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Large installations can complete an update without a usable original-state recovery capture.
Reason: The diff fixes a concrete metadata failure with no new option or parallel owner, but should use Related rather than claim complete issue closure because other large result transports remain capped.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR provides a focused repair for a current-main inventory failure; the competing proposals do not yet establish a safely landable replacement.

Priority: P1
Reviewed head: a1033a0757310f73a01b2e3c0705655fe0fbc0d8

Before merge

  • Add real behavior proof - The inspected screenshot and body demonstrate readUpdateStateDatabaseSizes with its real updateStateSizes child on Windows 11/Node 26.12.1, returning 12,000 and 40,000 entries after base output-limit failures. This is useful production-function evidence, but the contributor expressly did not exercise openclaw update, capture sealing, or a latest-stable upgrade. Supply that CLI scenario with manifest and preserved-data results, redacting IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Supply a shipped-CLI large-inventory update/capture run and latest-stable upgrade evidence showing the recovery manifest seals with settings and data intact, distinguishing installed-driver limitations.
Agent review details

How this fits together

The updater sends database paths to an isolated metadata worker, receives JSON containing paths and SQLite-family sizes, and uses those measurements for backup and schema inspection.

flowchart TD
A[Update capture] --> B[Database path inventory]
B --> C[Metadata inventory launcher]
C --> D[Isolated filesystem worker]
D --> E[Bounded JSON result]
E --> F[Backup and schema inspection]
Loading

Technical review

Best possible solution:

Keep the input-derived bound in the existing inventory owner and describe this PR as a partial repair until the complete capture path is verified.

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

Yes: enough existing long-path entries deterministically exceed current main’s fixed cap, and the contributor supplies matching base-versus-fix production-function output; this read-only review executed no target code.

Is this the best way to solve the issue?

The serialized-input budget is a small, sound repair for this worker’s result-size mismatch, but sibling discovery and backup receipts retain separate limits that can still prevent large captures from sealing.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Metadata inventory output budget changes intended behavior with a stated reason (fe0be1a: The packaging refactor retained a bounded, self-contained helper usable after replacement of the updater package; it carried forward the fixed cap rather than establishing its original introduction.)
  • Inspection diagnostics and process lifecycle keeps the original intent (feb2c81: Provide bounded progress and useful failure diagnostics while retaining the stdout JSON contract and joining process cleanup.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +4, Tests +12. Total +16 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 6 2 +4
Tests 1 12 0 +12
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 18 2 +16

Root-cause cluster

Relationship: partial_overlap
Canonical: #188897
Summary: The canonical issue covers failed large recovery captures; this PR repairs the metadata result cap while another proposal also addresses sibling transports.

Members:

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

Labels

Label changes:

  • add P1: The source-backed defect prevents usable pre-update recovery captures on reported official installations with large inventories.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • 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.

Label justifications:

  • P1: The source-backed defect prevents usable pre-update recovery captures on reported official installations with large inventories.
  • 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.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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:30 PM ET / October 31, 2026, 01:30 UTC.

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Thank you for the fix and A/B evidence. Superseded by #188919, merged as 4f1515d: it keeps the fixed 1 MiB per-child cap with batching (rather than #188912's scaled cap) and also covers sibling result transports and the unsealed-capture warning. The fix is not yet released.

@wr-web

wr-web commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

On the requested shipped-CLI proof, here is what I found while trying to set it up. I'm asking whether the current evidence is enough, rather than requesting a re-review.

  • A latest-stable upgrade cannot exercise this fix. The original-state capture runs inside the installed updater (update-recovery-baseline-capture.ts → createUpdateDatabaseBackup → readUpdateStateDatabaseSizes). Updating from any released version runs that release's fixed 1 MiB cap. The new cap only applies once a build containing this change is the installed updater, which means the update after the one that ships it.
  • The inventory size comes from resources, not general state files. The capture inventories the agent/shared databases plus the resources declared by plugins with pending doctor state migrations (collectBackupResources). The reporter's ~640k paths come from such declared resource trees on a long-lived install. To reproduce that through openclaw update, I would need a source install with a pending plugin migration whose declared tree holds more than about 7k files. I could not construct that faithfully on a local isolated state.

What the PR proves today:

  • the production readUpdateStateDatabaseSizes() with the real updateStateSizes child process;
  • main fails with the reporter's output-limit at 12,000 and 40,000 databases, and this branch inventories all of them;
  • the regression test fails on main with the same output-limit.

If a maintainer can point to a state shape or harness that drives the original-state capture with a large declared resource tree, I'll run it on this branch and attach the sealed-manifest result. Otherwise I'd suggest treating the function-level A/B as the evidence for this cap change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High-priority user-facing bug, regression, or broken workflow. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XS 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.

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

2 participants