Repository navigation
fix(update): size the disk preflight with the same calculation activation enforces - #183177
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. What this changesThis PR checks activation backup and rollback capacity before staging Git and package updates. Example: Two 8 MiB database families, 140 MiB available for candidate copies, and 100 MiB at the backup destination.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenanceRegression provenance — verified: source commit Merge readiness⛔ Needs changes before merge - 2 items remain Keep open: this PR addresses a current updater sizing defect with a shared calculation, but introduces an order-dependent regression assertion. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe updater measures known SQLite families before staging, checks candidate and durable-backup destinations, and returns admission diagnostics; activation independently rechecks its complete inventory. flowchart TD
A[Git or package update] --> B[Measure known database families]
B --> C[Candidate copy capacity]
B --> D[Shared backup and rollback capacity]
C --> E[Admit or refuse staging]
D --> E
E --> F[Validation]
F --> G[Activation capacity recheck]
Technical reviewBest possible solution: Keep the shared backup-space owner and distinct candidate budget, with an order-independent Git regression assertion. Do we have a high-confidence way to reproduce the issue? Current-main source establishes admission between the candidate and activation thresholds, and the linked report records a matching late failure; no target code was executed during this review. Is this the best way to solve the issue? The production change is focused: it reuses measured inventory, shares activation's existing policy, checks actual destination volumes, and preserves unknown-capacity best effort and final activation checks. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6aee15629b7f. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +77, Tests +100, Docs 0. Total +177 across 9 files. Added test files: 1. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 24, 2026, 11:12 PM ET / October 25, 2026, 03:12 UTC. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50de0118bb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let warnings: string[] = []; | ||
| if (params.backupDirectory) { | ||
| try { | ||
| const backup = await checkUpdateDatabaseBackupSpace(params.backupDirectory, size); |
There was a problem hiding this comment.
Deduplicate canonical database paths for backup admission
When a configured agentDir or OPENCLAW_AGENT_DIR is a symlink alias of the default agent directory, collectStateDatabasePaths() retains both locators and size counts the same database twice. Activation instead resolves those locators with fs.realpath() and deduplicates them in canonicalDatabaseInventory(). Passing the candidate-copy measurement into this new hard gate therefore rejects updates that activation can accommodate: a single 16 MiB family discovered through two aliases requires 112 MiB for the candidate and 144 MiB for the actual backup, but this check demands 176 MiB and refuses with 160 MiB free. Measure a canonical, deduplicated inventory for backup admission while preserving the candidate allocator's separate accounting. This also preserves the repository's best-effort update contract rather than introducing a refusal without a real capacity shortfall.
AGENTS.md reference: AGENTS.md:L78-L78
Useful? React with 👍 / 👎.
…tion enforces (openclaw#183177) The update disk preflight budgeted S + L + 64 MiB while activation required 2S + 3L + 64 MiB (S = all SQLite bytes, L = largest family), so an update could pass preflight, validate for 15 minutes with the Gateway stopped, then fail in activation for disk space. Git and package updates now share one budget owner (update-database-backup-space.ts), so the preflight refuses up front, before validation or downtime, with the required and free bytes and the largest database families. The activation reserve is unchanged. Fixes openclaw#183091. Thanks @etzelm.
Fixes #183091. Thanks @etzelm for the detailed phase timings, sizing analysis, and recovery evidence.
Related: #183133.
What Problem This Solves
An update can pass its initial disk check, spend minutes validating, and then refuse activation because the database backup requires substantially more space than the disposable candidate copy.
User Impact
Git and package updates now refuse before staging when measured space cannot satisfy the activation database backup or a separate source volume's rollback requirement. The message reports exact required and free bytes and lists the database families largest first. Unknown measurements remain best effort.
This runs in the installed updater; installing a newer candidate cannot replace an older updater's initial check. It does not reserve space against later builds, retained runtimes, newly discovered plugin/external state, or concurrent disk use, so activation keeps its complete admission check.
Why This Change Was Made
The initial check inherited the intentionally smaller
S + L + 64 MiBcandidate-copy budget. Activation still enforces2S + 3L + 64 MiBfor backup/rollback/scratch. Both phases now call the same backup-space owner, including aggregation of separate source volumes (S + L + 64 MiBper volume). Git checks.artifacts; package routes check their package manager's durable backup destination, including native project placement.The candidate allocator retains its smaller budget and temporary-directory selection. The larger backup allowance is unchanged: #182632 reuses digests within an observation, but does not eliminate snapshot, rollback-copy, or acquisition/publication files. Optional prior captures also do not replace the current automatic rollback contract. Recovery policy stays intact, with no schema or dependency changes and no new configuration or CLI options.
Evidence
Current head:
50de0118bb2e29c6fd548feba62ddc2c129afc51.The implementation, live proof, consumer runs, and initial gates below were checked at
a561c03037c5d9cdafde1827c6c360eefd4f29e4. To resolve a real PR conflict, this head integrates mainc800ae545e06dedfd4f65f1eac69a4a6a4d6809a, preserves #183075's resource-test cleanup, and reapplies only the new regression. Production changes remain byte-for-byte identical. Fresh integrated-head proof: the full resource suite 25/25 passed, including the capacity regression in 125 ms; infra-test tsgo passed; and a fresh isolated Codex review of the nine-file diff found no actionable P0–P2 defects. Resource wall time was 453.13 s, including 183.624 s shared compiled-worker preparation.The integrated lint wrapper stalled while preparing the newly pinned Bun fork, before linting. After stopping only this lane's wrapper and settling its preparation lock, direct native type-aware oxlint was verified with a temporary deliberate
no-map-spreadviolation (exit 1,oxc(no-map-spread)at line 707), then passed on the restored real file (exit 0). The canary was restored byte-for-byte and is absent from the commit; no rule or suppression changed.Node 26.12.1, with isolated
HOMEandOPENCLAW_STATE_DIRunder the worktree's.artifacts/directory before every product/test invocation.The baseline snapshot implementation returned exit 0 with 100 MiB free although activation needed about 120 MiB; the regression failed with
expected 0 to be 1. The fixed regression refuses at 100 MiB, admits at 140 MiB, preserves unknown-space best effort, leaves the source bytes unchanged, and allocates no backup directory. The existing candidate-copy test still succeeds within its smaller 100 MiB budget.Focused proof: resource suite 27/27 passed, Git entry-point suite 5/5 passed, and npm/package entry-point regression passed. The new capacity regression takes 77 ms and the package regression 585 ms. A test-authoring repair replaced recursive multi-MiB Buffer assertions with exact
Buffer.equals: capacity-test time fell 36.961 s → 0.077 s. The first package attempt was stopped after its equivalent recursive comparison grew to about 6 GiB RSS; the repaired test passed without adding retries or longer timeouts, skipping cases, or weakening assertions. Final Git file: 100.55 s wall, about 3.5 s tests; resource focused replay: 93.98 s wall, 77 ms test; package file: 18.69 s wall, 585 ms test. Most wall time is shared transform/compiled-worker preparation. CI timings are pending.Live local production Git-updater entry-point proof used real Git commands and real filesystem free-space readings, with a sparse SQLite-family fixture to cross the capacity threshold without filling the host disk. Candidate requirement 1,738,414,757,888 bytes fit; activation required 4,345,936,231,424 bytes, against 3,476,654,669,824 bytes available at its backup destination.
snapshot-space-preflightrefused in 9 ms, with zero validation and mutation hooks, unchanged fixture HEAD and file length, and the dominating database path in the diagnostic. The fixture was removed afterward. This proves pre-staging refusal, rather than a full successful upgrade.node --import ./scripts/tsx.mjs .artifacts/upd-l1902/live-space.ts # status=error; reason=snapshot-capacity-insufficient; validations=0; mutations=0The 30 additional consumer files ran with their original argument order: 319 passed, 31 PostgreSQL cases skipped by existing no-connection guards, 11 original-capture cases refused the host's group-writable volume ancestor. All 11 failures reproduce with untouched base production at
3940719bedc79e132a03e1805dcebc24173bad93; the committed capacity regression also fails there with the expected0versus1admission result. The same 11 capture cases plus the fixed regression then all pass (12/12) with a task-owned private temp directory under macOS's per-user temp root. No permission guard or volume permissions were changed. Private replay: 238.09 s wall (53% transform, 42% tests), including 104.31 s shared compiled-worker preparation; the private directory was removed after settlement.Existing slow integration proof on the implementation head: the 13
update-command-database-rollback.test.tsscenarios total 429.068 s of test time (package case 64.090 s);update-database-restore.test.tstotals 183.719 s (largest case 17.136 s). These unchanged fixtures repeatedly launch Doctor/service/inspection processes and verify real custody and restoration across each failure scenario. Reducing that fixture/process cost is a separate test-owner refactor; no timeouts, retries, or assertions were relaxed.Additional consumer command
The private-temp replay used this exact test selection (also used for the base replay):
Core, infra-test, and CLI-update-test tsgo; touched production/test type-aware oxlint; oxfmt; docs MDX; max-lines ratchet; and
git diff --checkpass. Madge reports 0 cycles. Fullcheck:changedSQLite inventory is skipped under the local gate budget; PR CI supplies broad proof. No remote lease was used. An isolated Codex review, supplied with the unchanged activation destination owners, found no actionable P0–P2 defects.Whole-change LOC against the base: production +136/-59, tests +105/-5, docs +2/-2. The backup/rollback admission implementation moved to one shared owner; candidate allocation policy and activation's safety allowance remain intact.