Skip to content

fix(update): stop schema admission when snapshot cleanup fails - #156265

Merged
fuller-stack-dev merged 3 commits into
mainfrom
openclaw/schema-preflight-cleanup-20260923
Sep 23, 2026
Merged

fuller-stack-dev merged 3 commits into
mainfrom
openclaw/schema-preflight-cleanup-20260923

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Original atomic-update tracking

Tracked in the maintained split indexes on #144005 and #145169. This PR retains its own dedicated Atomic update workers session. Its component completion does not by itself close the originals or prove the complete no-loss recovery journey.


What Problem This Solves

Fixes updates proceeding after their schema-inspection snapshot could not be cleaned up, or reporting only a cleanup error while losing the original inspection or cancellation error.

User Impact

Updates stop before further schema admission when owned snapshot cleanup fails. Original failures remain available alongside cleanup failures. Successful cleanup and existing reader settlement behavior are unchanged; no database schema, backup-retention, or recovery-publication change.

Why This Change Was Made

Collect cleanup failures after closing the schema reader, await the snapshot owner's asynchronous cleanup, and require its success before proceeding.

This is the narrow schema-cleanup successor extracted from #144005, originally opened by @steipete, with the cleanup implementation from 4146d06f8a3208222189d14af897325d4daa4fb3 by @fuller-stack-dev. It is a prerequisite for #155544, not a replacement for the remaining capture/recovery work. Related: #145169. Reuses the already-landed async cleanup and reader-settlement implementations.

Evidence

  • Unchanged current-main reproduction: 6 failed / 3 passed. The forward-update caller admitted a retained snapshot, and cleanup hid inspection, cancellation, and admission-close errors.
  • Fixed candidate: all 10 focused cases pass, including deferred cleanup, retained-reader refusal, original error identity/aggregation, native reader close, preservation of source and unrelated snapshot bytes, and recovery after an owned filesystem-removal failure.
  • Whole-file test audit completed; deterministic small SQLite fixtures verify physically private state and handoff paths and retire owned resources before deletion. No skipped cases or weakened assertions.
  • Independent API production and test-quality review: no actionable P0–P2 findings. Scoped lint: zero warnings/errors; formatting and 16 changed-file checks passed.
  • Local remaining type checks are blocked by the compiler-boundary guard rejecting pnpm's supported global shared dependency graph. No guard bypass or duplicate private install; exact-head hosted CI must supply those remaining gates before landing.

Cleanup-failure contract and review follow-up

The requested boundary is strict: every false or rejected owned-snapshot cleanup blocks subsequent schema admission, including an ordinary removal failure after readers have retired. This consciously aligns the global-state path with the existing agent-snapshot cleanup check; it is not a change to the shared snapshot API or its other best-effort callers. The diagnostic keeps the owned path, and the source database is not mutated. A new focused filesystem-fault case injects EACCES only for the owned snapshot directory, verifies refusal and unchanged source bytes, then removes the fault and verifies successful retry and cleanup.

This is the disposition of ClawSweeper's compatibility question from run35826509816. The stricter refusal is intentional for this separately assigned cleanup prerequisite; warning-only continuation on false would violate that contract. This leaf makes no schema migration, driver-marker, service activation, backup-retention, or recovery-publication change. Its authorized acceptance scope is isolated caller/snapshot behavior, not a full installed published-driver upgrade or native no-loss cell; those broader checks are not claimed here.

Requalification after upstream repair

Head 81d1f342 preserves the original contributor ancestry and the exact three-file source/test tree from aa293cd3. Its metadata-only refresh requests fresh CI against main after 813a10e7 repaired the unrelated route-loader TS2322. No UI change is included.

The patch was also applied unchanged to repaired main 4adc92df: both commits were patch-identical by range-diff, all ten focused tests passed (72.89s wrapper wall, including 57.28s worker compilation; individual cases 8–56ms), scoped lint reported zero warnings/errors, and 16 changed-file checks passed. The existing canonical-global-store compiler guard still prevents local type gates; current-head CI owns the remaining proof. The prior six-failure baseline and independent API review are reused for the unchanged patch, not presented as a completed current-head CI result.

Stored-data review disposition: the earlier bot summary flagged unknown-data-model-change solely at the existing schema-preflight path, while its technical review explicitly found no schema, stored-data representation, dependency, or authorization-contract change. This patch changes only cleanup settlement and error aggregation around an existing read-only inspection. It adds no SQL/schema/version/migration changes, and focused success/failure/retry tests assert unchanged source-database bytes. Thus no data-model migration is introduced. The stricter cleanup-refusal behavior and its accepted isolated-component proof scope remain as stated above; no published-driver or complete no-loss upgrade proof is claimed.

Preserve inspection and cancellation errors while collecting admission-close,
native-close and owned snapshot cleanup failures. Await asynchronous cleanup
and refuse further schema admission when retirement returns false.

Extract the reviewed cleanup slice from the original update-capture work;
do not carry its backup, restoration or publication changes.

Source-Commit: 4146d06
Original-PR: #144005
@clawsweeper

clawsweeper Bot commented Sep 23, 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.

@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review September 23, 2026 06:21
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: M labels Sep 23, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 23, 2026, 3:50 AM ET / 07:50 UTC (Revision 2).

ClawSweeper review

What this changes

The PR makes database schema checks reject failed snapshot cleanup while preserving earlier inspection or cancellation errors, with focused update-caller regression tests.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains a useful, focused fix absent from current main and the latest release. No actionable correctness defect was found. The previous migration-proof blocker does not apply because the patch changes no stored-data contract; the member author explicitly records acceptance of the stricter cleanup behavior.

Priority: P2
Reviewed head: 81d1f342434916a91c4e98adceb736203262f2bf

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable repair with meaningful regression coverage and no actionable findings; reported validation was not rerun during review.
Proof confidence 🌊 off-meta tidepool Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Its reported isolated tests exercise update preflight and the real cleanup owner with injected faults, but do not claim a complete installed update. No authority-bearing or stored-data contract changes are introduced, so the previous migration-proof requirement does not apply.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Its reported isolated tests exercise update preflight and the real cleanup owner with injected faults, but do not claim a complete installed update. No authority-bearing or stored-data contract changes are introduced, so the previous migration-proof requirement does not apply.
Evidence reviewed 8 items Pinned introduced change: Reviewed the merge-base-to-head patch. It changes only cleanup settlement, error collection, and associated tests; no schema, migration, dependency, configuration, or authorization contract changes are introduced.
Current-main defect remains: Current main awaits stateSnapshot.cleanupAsync() but ignores its boolean result. Its nested finally blocks can also replace an earlier inspection failure with a cleanup failure.
Latest-release comparison: The supplied latest release, v2026.9.5, also ignores the state snapshot cleanup result at line 489. The requested repair is not already shipped there.
Findings None None.
Security None None.

How this fits together

OpenClaw checks database compatibility before updates, Doctor operations, and startup proceed. These checks inspect private SQLite snapshots, then close readers and retire temporary files before returning their results.

flowchart TD
  A[Update or startup request] --> B[Database schema checks]
  C[Existing SQLite database] --> D[Private inspection snapshot]
  B --> D
  D --> E[Close reader and await cleanup]
  E --> F{Cleanup succeeded?}
  F -->|Yes| G[Return schema results]
  F -->|No| H[Stop and preserve errors]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +44, Tests +280. Total +324 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 57 13 +44
Tests 1 280 0 +280
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 337 13 +324

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +44 lines; tests +280 lines The production growth isolates cleanup error aggregation; the tests exercise ten distinct settlement and failure scenarios.

Stored data model

Persistent data-model change detected: unknown-data-model-change: src/state/openclaw-database-preflight.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep cleanup settlement with the existing snapshot owner and preserve all failure causes before allowing schema checks to continue.

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

Yes, source establishes the failure path: cleanup can return false while current-main schema preflight continues, and cleanup exceptions can replace earlier errors. The submitted regressions target those paths; this review did not execute them.

Is this the best way to solve the issue?

Yes. The patch reuses the existing snapshot lifecycle and error aggregator, preserves successful behavior, and implements the explicitly accepted refusal contract without changing persistent data.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs a bounded update-preflight cleanup and diagnostic defect without evidence of a widespread urgent outage.
  • merge-risk: 🚨 compatibility: Previously tolerated snapshot-removal failures now stop schema admission; the member author's recorded disposition explicitly accepts this tradeoff.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Its reported isolated tests exercise update preflight and the real cleanup owner with injected faults, but do not claim a complete installed update. No authority-bearing or stored-data contract changes are introduced, so the previous migration-proof requirement does not apply.

Evidence

What I checked:

  • Pinned introduced change: Reviewed the merge-base-to-head patch. It changes only cleanup settlement, error collection, and associated tests; no schema, migration, dependency, configuration, or authorization contract changes are introduced. (src/state/openclaw-database-preflight-cleanup.ts:8, 81d1f3424349)
  • Current-main defect remains: Current main awaits stateSnapshot.cleanupAsync() but ignores its boolean result. Its nested finally blocks can also replace an earlier inspection failure with a cleanup failure. (src/state/openclaw-database-preflight.ts:473, fdf8d86f8f56)
  • Latest-release comparison: The supplied latest release, v2026.9.5, also ignores the state snapshot cleanup result at line 489. The requested repair is not already shipped there. (src/state/openclaw-database-preflight.ts:489, ec9c1a13db89)
  • Accepted compatibility tradeoff: The captured PR body's cleanup-failure disposition explicitly requires false or rejected cleanup to stop admission, including filesystem removal failures after readers retire. The author is GitHub-verified MEMBER. The disposition limits acceptance to isolated caller/snapshot behavior and leaves complete published-driver and no-loss recovery acceptance with the broader update work. (81d1f3424349)
  • Regression coverage and validation scope: Read all ten cases covering the production update-preflight caller, retained readers, EACCES removal failure and retry, deferred cleanup, error identity, aggregation, native close, and unchanged source/unrelated snapshot bytes. Snapshot preparation and selected faults are injected. The captured body reports ten passing cases, 72.89 seconds wrapper wall including 57.28 seconds compilation, and 8–56 milliseconds per case. No tests were executed during this read-only review. (src/cli/update-cli/update-command-schema-cleanup.test.ts:94, 81d1f3424349)
  • Re-review continuity: The earlier reviewed head and current head have identical trees. The prior review had no findings; its migration-proof next step is resolved by independently inspecting the introduced patch and confirming that no stored-data representation or migration changes. (81d1f3424349)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-23T06:52:43.723Z sha aa293cd :: blocked before merge. :: none

Refresh exact-head CI after main 813a10e fixed the route-loader TS2322 blocker. Preserve the reviewed schema-cleanup patch and original contributor ancestry; no UI changes.
@fuller-stack-dev
fuller-stack-dev enabled auto-merge (squash) September 23, 2026 07:45
@fuller-stack-dev
fuller-stack-dev merged commit a976c5c into main Sep 23, 2026
208 of 209 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the openclaw/schema-preflight-cleanup-20260923 branch September 23, 2026 08:44
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 24, 2026
…law#156265)

* fix(update): refuse schema admission when snapshot cleanup fails

Preserve inspection and cancellation errors while collecting admission-close,
native-close and owned snapshot cleanup failures. Await asynchronous cleanup
and refuse further schema admission when retirement returns false.

Extract the reviewed cleanup slice from the original update-capture work;
do not carry its backup, restoration or publication changes.

Source-Commit: 4146d06
Original-PR: openclaw#144005

* test(update): cover owned snapshot removal failure recovery

* chore(update): requalify schema cleanup after upstream type repair

Refresh exact-head CI after main 005cbdc fixed the route-loader TS2322 blocker. Preserve the reviewed schema-cleanup patch and original contributor ancestry; no UI changes.
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

1 participant