Skip to content

fix(sqlite): release caller memory after worker opening - #173643

Merged
steipete merged 1 commit into
mainfrom
ci/fix5-sqlite-opening-retention-20261016
Oct 16, 2026
Merged

steipete merged 1 commit into
mainfrom
ci/fix5-sqlite-opening-retention-20261016

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

A retained SQLite worker client keeps its completed opening caller and authority snapshot alive for the client's lifetime. This repairs the two opening-retention failures on main.

User Impact

Completed request memory can be collected while the same SQLite worker remains reusable. There are no schema, stored-data, permission, configuration or update/Doctor behavior changes; the cleanup authority introduced by 0d73885432fb remains active.

Why This Change Was Made

The retained dispatch callback accessed options.cleanupAccess, capturing the entire opening-options object and its caller callbacks. Capture only the cleanup capability beside the existing maintenance scope. The existing native-owner retention test is the regression; its assertions and GC probe are unchanged.

Evidence

  • 0d73885432fb^: the retention file passes 4/4. Current main fails both opening cases alone. An ordered replay of the introducing revision reports the same two failures, with 778 files passing and eight existing skipped files.
  • Candidate: the unchanged retention file passes 4/4, and the maintenance/native cleanup siblings pass 3/3, including policy retirement and physical database replacement. pnpm test ... --maxWorkers=1 completes all three owning configurations successfully.
  • Core types, scoped type-aware lint, boundary lint, formatting, whitespace and isolated P2 review pass. PR CI supplies broad proof.

Release-note context: fix completed caller memory remaining retained after SQLite worker opening. This is bounded first-opener retention, not a claim about sustained Gateway heap growth.

The retained client dispatch added by 0d73885 read cleanupAccess
through the complete opening options, keeping completed caller authority
callbacks and their async context alive for the client lifetime.

Capture the cleanup capability alongside maintenanceScope so the client
keeps its live cleanup authority without retaining the opening request.
All existing admission, maintenance, lease cleanup and database behavior
is preserved; schemas, update/Doctor behavior and stored bytes are unchanged.

The unchanged real-owner retention regression passes 4/4 on the culprit's
parent and fails both opening cases on the culprit and current main.
With this fix it passes 4/4; maintenance and native cleanup siblings pass
3/3. Core types, scoped lint/boundary lint, formatting and P2 review pass.
@clawsweeper

clawsweeper Bot commented Oct 16, 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.

@steipete
steipete marked this pull request as ready for review October 16, 2026 01:58
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T02:00:25.838986Z 198cb66 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete
steipete enabled auto-merge (squash) October 16, 2026 02:06
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The SQLite worker client captures its cleanup capability directly so it can release the completed opening caller.

Example: A request carrying a 1 MiB prompt opens a reusable SQLite worker.

  • Before: The retained dispatch callback keeps the opening options and completed caller reachable.
  • After: The caller can be collected while the same worker remains available for subsequent operations.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch is source-supported and preserves established contracts; validation is reported real-owner regression coverage rather than shipped-entry-point evidence.
Proof confidence 🦐 gold shrimp (3/6) The ordinary contributor proof gate is exempt under the supplied maintainer-authored status; supplied validation covers real SQLite owner collection and reuse, and the capture-only patch does not materially change authority.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A reusable SQLite client can keep a completed request's prompt and authority context in memory for the client's lifetime.
Reason: This restores an established caller-collection contract with a minimal change; the supplied maintainer-authored status and prior feature-owner history establish direction.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR fixes a concrete caller-retention regression still present on current main, and no introduced correctness defect was found.

Priority: P2
Reviewed head: 198cb66ec6ac821aaa4e7791f2e96bc2f206fe5a

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped Gateway retention run is supplied; the unchanged real-owner regression has reported before/after results that were not independently rerun.
Agent review details

How this fits together

The SQLite broker turns opening requests into reusable worker clients, dispatches database operations, and coordinates admission and native cleanup.

flowchart LR
  A[Opening request] --> B[SQLite broker]
  B --> C[Reusable client]
  C --> D[Operation admission]
  D --> E[SQLite worker]
  F[Cleanup capability] --> D
Loading

Technical review

Best possible solution:

Use the direct cleanup-capability capture to release completed opening callers while preserving worker reuse and live cleanup checks.

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

Source inspection establishes the retained dispatch-to-options-to-caller path on fetched main, and the PR reports an unchanged forced-GC regression failing before and passing after the fix; no code was executed during this review.

Is this the best way to solve the issue?

The patch repairs the producer's capture directly, follows the existing retention design, and preserves the same cleanup object, admission checks, maintenance selection, and cleanup lifecycle.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Opening-caller lifetime keeps the original intent (65829ea: Reusable lifecycle resources should release completed callers while preserving current per-operation authority, as documented in perf(runtime): release completed callers from lifecycle resources #164465 and the later opening-capture repair.)
  • Cleanup-only physical custody keeps the original intent (0d73885: Already admitted native leases must remain cleanable after maintenance policy retirement while replacement files and unrelated writes remain rejected.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 4db0224 adds src/infra/sqlite-worker-broker.ts:180 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4db022470af6; files: src/infra/sqlite-worker-broker.ts)
  • Vincent Koc: Raw commit aeffc9e adds src/infra/sqlite-worker-broker.ts:187 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: aeffc9ed744f; files: src/infra/sqlite-worker-broker.ts)

PR surface

Source 0. Total 0 across 1 file. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 3 3 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 3 3 0

Labels

Label changes:

  • add P2: This fixes bounded completed-caller memory retention in reusable SQLite clients without evidence of an urgent outage or sustained heap-growth rate.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: This fixes bounded completed-caller memory retention in reusable SQLite clients without evidence of an urgent outage or sustained heap-growth rate.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 15, 2026, 10:13 PM ET / October 16, 2026, 02:13 UTC.

@steipete
steipete merged commit 161bd95 into main Oct 16, 2026
198 checks passed
@steipete
steipete deleted the ci/fix5-sqlite-opening-retention-20261016 branch October 16, 2026 02:14
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
)

The retained client dispatch added by bbd1a30 read cleanupAccess
through the complete opening options, keeping completed caller authority
callbacks and their async context alive for the client lifetime.

Capture the cleanup capability alongside maintenanceScope so the client
keeps its live cleanup authority without retaining the opening request.
All existing admission, maintenance, lease cleanup and database behavior
is preserved; schemas, update/Doctor behavior and stored bytes are unchanged.

The unchanged real-owner retention regression passes 4/4 on the culprit's
parent and fails both opening cases on the culprit and current main.
With this fix it passes 4/4; maintenance and native cleanup siblings pass
3/3. Core types, scoped lint/boundary lint, formatting and P2 review pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS 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