Skip to content

fix(cli): drain SQLite snapshots on one-shot exit - #178730

Open
Frosmans wants to merge 3 commits into
openclaw:mainfrom
Frosmans:codex/fix-157712
Open

Frosmans wants to merge 3 commits into
openclaw:mainfrom
Frosmans:codex/fix-157712

Conversation

@Frosmans

@Frosmans Frosmans commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes one-shot CLI state reads retaining SQLite snapshot owners after the command finishes.

Fixes #157712.

User Impact

One-shot commands release their retained snapshot worker and private files before exiting. The source database remains unchanged. No configuration, schema or persistent-data migration is required.

Why This Change Was Made

Normal CLI resource finalization now invokes the existing asynchronous snapshot cleanup owner after database teardown. Signal-only cleanup and a synchronous process-exit hook cannot retire that owner safely.

This revision integrates current main to resolve the actual merge conflict and replaces the mock-call assertion with a subprocess regression using a real SQLite database and the production snapshot worker. It introduces no new cleanup mechanism or retention policy.

Evidence

  • The new process regression passes with the fix: it reads value 42 through a real retained snapshot, exits successfully, removes the snapshot directory and preserves the source bytes.

  • Negative control with only the snapshot finalizer removed: the same subprocess fails its 20-second completion bound because the retained owner prevents exit.

  • CLI finalization suites: 10/10 passed. Existing SQLite cleanup/native-owner suites: 21/21 passed.

  • Focused config/CLI typecheck, targeted formatting/lint and git diff --check: passed.

  • Changed process-test file: 6/6 passed, 3.86 seconds Vitest duration and 4.77 seconds wrapper wall time. Hosted CI time is not yet available for this revision.

  • The previous mock-exports CI failure was inherited from the frozen upstream base, not this patch. Upstream fixed it in 2466488c29e25f6fdafe0d6419387116e4194ade; no unrelated doctor-test repair or blind rerun is included here.

  • Local autoreview assessed the complete staged candidate against main 176c9c7496fd99c2cc1259bcb96e7d63fd84ef7c for P0/P1/P2 defects: complete, no actionable findings. Review scope was the change and supplied CLI/snapshot source context, not a whole-repository audit. Hosted checks and maintainer review remain separate from local proof.

Close retained SQLite snapshot owners during normal CLI teardown so one-shot state reads do not leave staged copies behind.

Fixes openclaw#157712
@clawsweeper

clawsweeper Bot commented Oct 20, 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 cli CLI command changes triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. size: XS labels Oct 20, 2026
@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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 31e749f745c6f3f96718e2a6ac77c6569d452fb3, but the PR head is now c69017c8b819b3498d736a99331f3f4ff4cfe185. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

Review history (1 earlier review cycle)
  • reviewed 2026-10-20T20:05:56.206Z sha 31e749f :: needs real behavior proof before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Oct 20, 2026
@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 21, 2026
steipete added a commit that referenced this pull request Nov 2, 2026
Reserve private state admission for a genuinely hot rollback journal during
startup, then recover the canonical database only after ownership and config
guards pass. Normal startup and runtime readers keep using live SQLite.

Remove Gateway legacy snapshot scanning. Drain active snapshot payloads with
async bounded truncation and retain producer custody through reply delivery
and parent exit. Integrate the one-shot CLI drain from #178730.

Co-authored-by: Frosmans <[email protected]>
steipete added a commit that referenced this pull request Nov 2, 2026
* fix: prevent large-database Gateway startup and cleanup stalls

* fix: preserve observation policy for live state reads

* fix: preserve crash restart without routine state snapshots

Reserve private state admission for a genuinely hot rollback journal during
startup, then recover the canonical database only after ownership and config
guards pass. Normal startup and runtime readers keep using live SQLite.

Remove Gateway legacy snapshot scanning. Drain active snapshot payloads with
async bounded truncation and retain producer custody through reply delivery
and parent exit. Integrate the one-shot CLI drain from #178730.

Co-authored-by: Frosmans <[email protected]>

* fix: avoid agent startup copies and preserve snapshot handoff

Permit native closed-WAL inspection under the existing Gateway live-read policy while retaining full integrity checks and offline artifact preservation. Release producer staging locks before result publication while keeping cleanup custody through delivery.

Prove both regressions at their owning boundaries, repair callback fixtures, and isolate the PostgreSQL orphan-inventory test from sibling schema cleanup. The actual cleanup owner took 57.8 seconds to drain a synthetic 35 GiB clone, so avoiding the unnecessary agent copy removes that admission work.

---------

Co-authored-by: Frosmans <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 3, 2026
…aw#190918)

* fix: prevent large-database Gateway startup and cleanup stalls

* fix: preserve observation policy for live state reads

* fix: preserve crash restart without routine state snapshots

Reserve private state admission for a genuinely hot rollback journal during
startup, then recover the canonical database only after ownership and config
guards pass. Normal startup and runtime readers keep using live SQLite.

Remove Gateway legacy snapshot scanning. Drain active snapshot payloads with
async bounded truncation and retain producer custody through reply delivery
and parent exit. Integrate the one-shot CLI drain from openclaw#178730.

Co-authored-by: Frosmans <[email protected]>

* fix: avoid agent startup copies and preserve snapshot handoff

Permit native closed-WAL inspection under the existing Gateway live-read policy while retaining full integrity checks and offline artifact preservation. Release producer staging locks before result publication while keeping cleanup custody through delivery.

Prove both regressions at their owning boundaries, repair callback fixtures, and isolate the PostgreSQL orphan-inventory test from sibling schema cleanup. The actual cleanup owner took 57.8 seconds to drain a synthetic 35 GiB clone, so avoiding the unnecessary agent copy removes that admission work.

---------

Co-authored-by: Frosmans <[email protected]>

This branch has not been deployed

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

Labels

cli CLI command changes P1 High-priority user-facing bug, regression, or broken workflow. size: S

Projects

None yet

1 participant