Skip to content

fix(state): await private SQLite snapshot cleanup - #146571

Merged
steipete merged 2 commits into
mainfrom
codex/swarm-async-snapshot-cleanup
Sep 13, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/swarm-async-snapshot-cleanup

Conversation

@steipete

@steipete steipete commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Split from #130741. The startup and CI inventory fixes are already on main through #146410 and #146538.

What Problem This Solves

Asynchronous SQLite inspections removed their private snapshot directories synchronously, blocking the event loop during recursive cleanup. Concurrent cleanup callers also needed one shared completion result.

User Impact

Doctor, update preflight, database verification, and other asynchronous snapshot readers await filesystem cleanup after their native readers close. Failed removal retains the existing cleanup retry ownership and error behavior.

Why This Change Was Made

The existing snapshot owner now supplies asynchronous cleanup alongside its synchronous operation. Concurrent asynchronous callers join one removal attempt; a synchronous caller cannot report success while it remains pending. Asynchronous consumers await that operation, and schema inspection preserves both read and cleanup failures. Synchronous callers retain their existing contract.

The published updater's existing update marker continues to select candidate preflight. This changes no schema, integrity check, retention setting, or timeout.

Evidence

Four entry-point regressions failed before repair. The initial composed validation contained 426 passing tests and one existing Linux-only skip, with a normal build and full canonical checks. CI then exposed an import cycle. Moving the unchanged snapshot type to an import-free module resolves it with zero net production growth and identical emitted JavaScript in all six affected modules. Architecture, canonical checks, SDK declarations, all 153 SDK subpaths, and independent reviews of the cleanup and type changes pass.

A later local sibling run passed 177 cases and hit the existing 30-second continuous-commit Doctor timeout in one case. One planned serial baseline/current comparison passed that case on both sources; the original timeout remains unexplained and retained. No deadline or assertion was changed.

The previous head passed the packaged upgrade cell with full retained evidence: published 2026.9.3 updated to the candidate, preserved legacy operator state, restarted through the updater's service owner, advanced the expected schemas, passed the mock turn and health checks, and completed an already-current second update. That proof is tied to the previous head.

The current head coherently includes the upstream plugin-argument contract and its matching tests. All 20 repair files are unchanged. Its frozen install, full changed checks, architecture, all 18 plugin-registry cases, and one continuous-commit Doctor case pass. Exact-head CI is green. A fresh isolated packaged upgrade on this same head also passes: published 2026.9.3 updates through its own updater, preserves legacy operator state, replaces the supervised process, advances state schema 16→17 and agent schema 19→20, and passes the mock turn, health, already-current second update and all 34 Doctor checks. All 159 evidence files were retained and hash-verified, and the Testbox is stopped. This is the service-manager fixture, not OS-native systemd/launchd proof. The broader Swarm 500 ms responsiveness target remains tracked in #130741.

@clawsweeper

clawsweeper Bot commented Sep 12, 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 app: web-ui App: web-ui extensions: memory-core Extension: memory-core scripts Repository scripts commands Command implementations size: L maintainer Maintainer-authored PR labels Sep 12, 2026
@steipete
steipete marked this pull request as ready for review September 12, 2026 23:45
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 12, 2026, 10:29 PM ET / September 13, 2026, 02:29 UTC (Revision 5).

ClawSweeper review

What this changes

Asynchronous database inspections await shared cleanup of private SQLite snapshots, while synchronous callers retain their existing cleanup operation.

Warning

SQLite table change

This PR modifies persisted SQLite tables in src/infra/sqlite-schema-header.ts. Prefer a design that avoids changing persisted SQLite tables. If the change is necessary, verify migration and upgrade compatibility against an existing database before merge.

Merge readiness

⛔ Blocked before merge - 3 items remain

This remains a useful, review-clean repair. The updated evidence addresses the previous current-head upgrade blocker; no actionable introduced defect was found.

Priority: P2
Reviewed head: 9d02720dbaefefd0d4e29c982af2b80584ebdeb8

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful lifecycle coverage and an addressed upgrade-proof request; no blocking correctness finding remains.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary external-contributor proof gate does not apply to this maintainer-authored PR. Its updated body reports the required current-head published-driver upgrade through Doctor and candidate preflight, including state preservation and successful recovery checks; historical Swarm screenshots do not prove snapshot cleanup.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary external-contributor proof gate does not apply to this maintainer-authored PR. Its updated body reports the required current-head published-driver upgrade through Doctor and candidate preflight, including state preservation and successful recovery checks; historical Swarm screenshots do not prove snapshot cleanup.
Evidence reviewed 9 items Cleanup ownership and settlement: The snapshot owner shares one pending removal promise, refuses synchronous success while removal is pending, and only retires ownership after successful removal. Failed removal retains the existing exit retry.
Read, cleanup, and cancellation ordering: Schema inspection closes its native reader before awaiting snapshot removal, preserves combined read/cleanup failures, and checks cancellation before returning a successful header.
Current main still needs the repair: Fetched main retains recursive rmSync removal and a synchronous-only prepared snapshot handle. The central asynchronous cleanup change is therefore still distinct.
Findings None None.
Security None None.

How this fits together

Doctor, update preflight, and database verification inspect private SQLite copies to avoid disturbing live databases. The snapshot owner removes those copies after readers close and retains failed removals for retry.

flowchart TD
 A[Doctor and database inspections] --> B[Private SQLite snapshot]
 B --> C[Read and close database]
 C --> D[Shared asynchronous cleanup]
 D --> E{Removal succeeds?}
 E -->|Yes| F[Complete inspection]
 E -->|No| G[Retain retry ownership]
Loading

Before merge

  • Resolve merge risk (P1) - Plugins adopting cleanupAsync require a host that supplies the added SDK method; the packaged upgrade evidence covers the bundled pairing, not independently mixed plugin and host versions.
  • Resolve merge risk (P2) - The reported continuous-commit Doctor timeout remains unexplained, although the subsequent serial baseline/current comparison passed on both sources.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +114, Tests +211. Total +325 across 20 files.

View PR surface stats
Area Files Added Removed Net
Source 14 207 93 +114
Tests 6 219 8 +211
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 20 426 101 +325

Review metrics

Metric Value Why it matters
Production versus regression coverage production +114 net lines; tests +211 net lines Production growth implements shared asynchronous settlement and failure preservation; tests cover ordering, retries, cancellation, and source preservation.
SDK handle contract 1 cleanup method added; 0 existing methods removed Existing synchronous consumers remain supported while asynchronous consumers gain an awaited operation.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-lint.ts, unknown-data-model-change: src/infra/sqlite-schema-header.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Retain the additive SDK contract (recommended)
    Accept the documented host-version dependency while preserving synchronous cleanup and shipping Memory Core with its matching runtime.

Technical review

Best possible solution:

Keep one snapshot cleanup owner, preserve the synchronous SDK contract, and retain the matching packaged-upgrade evidence with this asynchronous cutover.

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

Yes, from source: current-main asynchronous snapshot inspections reach recursive rmSync cleanup. The branch adds focused ordering regressions; this review did not execute them.

Is this the best way to solve the issue?

Yes. Extending the existing snapshot owner with shared asynchronous settlement preserves cleanup ownership and avoids a competing implementation.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded responsiveness and cleanup-lifecycle repair for database inspection workflows.
  • merge-risk: 🚨 compatibility: The existing SQLite SDK handle gains a method that newly adopting plugins require their host runtime to provide.
  • 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 ordinary external-contributor proof gate does not apply to this maintainer-authored PR. Its updated body reports the required current-head published-driver upgrade through Doctor and candidate preflight, including state preservation and successful recovery checks; historical Swarm screenshots do not prove snapshot cleanup.

Evidence

What I checked:

  • Cleanup ownership and settlement: The snapshot owner shares one pending removal promise, refuses synchronous success while removal is pending, and only retires ownership after successful removal. Failed removal retains the existing exit retry. (src/infra/sqlite-readonly-location.ts:348, 9d02720dbaef)
  • Read, cleanup, and cancellation ordering: Schema inspection closes its native reader before awaiting snapshot removal, preserves combined read/cleanup failures, and checks cancellation before returning a successful header. (src/infra/sqlite-schema-header.ts:108, 9d02720dbaef)
  • Current main still needs the repair: Fetched main retains recursive rmSync removal and a synchronous-only prepared snapshot handle. The central asynchronous cleanup change is therefore still distinct. (src/infra/sqlite-readonly-location.ts:306, 2a3b63857db3)
  • Latest release comparison: The release source also contains synchronous recursive removal and no asynchronous cleanup method. GitHub contents inspection succeeded after the local release blob was unavailable. (src/infra/sqlite-readonly-location.ts:299, 3a9d69db306c)
  • Previous upgrade request addressed: The supplied complete PR body, captured under sourceRevision d5327259d258a6e6479b19a177ef8689241e02167d07adda23fff06ac1d6ba10, now reports a published-2026.9.3-to-current-head packaged upgrade preserving legacy state, replacing the supervised process, completing schema advancement, health, a mock turn, a second update, and 34 Doctor checks. This answers the retained rank-up request. These are author-reported observations; the 159 retained evidence files are not linked in the supplied body. The service-manager fixture is explicitly distinguished from native systemd/launchd proof. (9d02720dbaef)
  • SDK compatibility boundary: sqlite-runtime exports the snapshot preparers, so their returned handle gains cleanupAsync through an existing SDK entrypoint. The old cleanup operation remains; Memory Core adopts the new method in the same branch. The maintainer-authored body explicitly describes both contracts and reports SDK declaration/subpath checks. (src/plugin-sdk/sqlite-runtime.ts:35, 9d02720dbaef)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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 (4 earlier review cycles)
  • reviewed 2026-09-12T23:51:15.156Z sha 3189dc4c9c971cef8ff87bc3ff8584b281adc2bc :: blocked before merge. :: none
  • reviewed 2026-09-12T23:59:06.922Z sha 41d3c011ecb1e52f61f3481be3a2c240d7fbb9a0 :: blocked before merge. :: none
  • reviewed 2026-09-13T01:07:22.140Z sha 7914a23ae08523e88576932ecfbcba8dcd7cbc79 :: blocked before merge. :: none
  • reviewed 2026-09-13T02:00:23.152Z sha 9d02720 :: blocked before merge. :: none

@steipete
steipete force-pushed the codex/swarm-async-snapshot-cleanup branch from 3189dc4 to 41d3c01 Compare September 12, 2026 23:52
@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 13, 2026
@steipete
steipete force-pushed the codex/swarm-async-snapshot-cleanup branch from 7914a23 to 9d02720 Compare September 13, 2026 01:53
@steipete
steipete merged commit 087769b into main Sep 13, 2026
191 of 193 checks passed
@steipete
steipete deleted the codex/swarm-async-snapshot-cleanup branch September 13, 2026 02:31
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

app: web-ui App: web-ui commands Command implementations extensions: memory-core Extension: memory-core maintainer Maintainer-authored PR 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. scripts Repository scripts size: L 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