Skip to content

fix(infra): release completed SQLite readers and prevent cursor restarts - #190242

Merged
roboclaw-bot merged 1 commit into
mainfrom
loop/contributor-pr-184076
Nov 1, 2026
Merged

roboclaw-bot merged 1 commit into
mainfrom
loop/contributor-pr-184076

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Supersedes #184076, thanks @ava-perry.

What Problem This Solves

Fixes WAL growth when a completed SQLite reader is stepped again on affected Node bindings; returning an old iterator can also rewind a newer reader using the same statement.

User Impact

Completed readers release their snapshots, checkpoints can finish, and later iterator calls cannot restart queries or disturb successor readers. No configuration, schema, or migration changes are required.

Why This Change Was Made

The existing SQLite observer now returns native iterators on exhaustion and remembers completion after either exhaustion or explicit return. Repeated calls receive a terminal result. Remove the superseded iterator capability experiment and its private worker-admission fields together; retain the loaded-library safety and identity query using one get().

Simplification pass: production −48 lines, tests +18 net lines against a11289439ae9. The removed probe/transport pays for the terminal-state handling. The separate 18-line regression allocation covers real WAL checkpoint progress and preservation of a successor cursor after stale calls, after subtracting obsolete probe fixtures.

Evidence

  • Base a11289439ae9940e6487c82ef439af80da180571, Node 24.18.0 / SQLite 3.53.1: new real temp-directory database regressions fail. After exhaustion and another next(), PASSIVE checkpoints only 3 of 4 frames; after explicit return, a stale return rewinds the successor and yields row 1 twice.

  • Fixed branch on Node 24.18.0: observer + native runtime suites 79 tests passed, 5.00s total wrapper wall time. WAL fully checkpoints and TRUNCATE returns {busy: 0, log: 0}; the successor yields the remaining rows exactly once.

  • Node 26.12.1: OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs run src/infra/sqlite-native-observer.test.ts src/infra/node-sqlite.test.ts src/state/openclaw-schema-metadata.test.ts src/infra/sqlite-schema-facts.native.test.ts --maxWorkers=1 — 148 passed, 44.12s wall time including the initial worker build. Test execution remains under five seconds per file. Exact-head PR CI passed, including all three PostgreSQL shards and openclaw/ci-gate; elapsed 1460 seconds including setup and all jobs.

  • Focused TypeScript compilation of the six changed TS files plus canonical ambient declarations, targeted oxlint, oxfmt, and git diff --check pass. No references to the retired probe or iterator flags remain in src.

  • Shared autoreview, local candidate against a11289439ae9, Codex GPT-6.1 Sol, P0–P2: scoped-clean, no findings. It reviewed the supplied complete diff and native Node source; unchanged repository context was unavailable and it did not rerun tests. Subsequent changes only remove an unused type import and record the test allocation.

  • Contributor source was read through gh pr view / gh pr diff; it was never checked out or executed. This is an independently implemented, credited replacement. Production Team services were not modified.

  • Hosted ClawSweeper review, exact head 1dd1097bd13e: complete, no actionable findings. It records the same full-Gateway proof limitation.

Finish and return native iterators once, answer later terminal calls in the
observer, and retire unused iterator capability probing and transport.
Prove WAL checkpoint progress and successor-cursor preservation with real
file-backed databases.

Co-authored-by: ava-perry <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 1, 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.

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review November 1, 2026 10:36
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S labels Nov 1, 2026
@roboclaw-bot
roboclaw-bot enabled auto-merge (squash) November 1, 2026 10:40
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR releases completed SQLite readers, prevents later iterator calls from restarting or rewinding queries, and removes unused capability probing.

Example: On Node 24.18.0, exhaust a two-row SELECT, call next() again, insert row 3, and checkpoint the WAL.

  • Before: The query restarts and the checkpoint advances only 3 of 4 frames.
  • After: The iterator stays terminal and the WAL fully checkpoints.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, coherent repair with useful native boundary regressions; evidence remains harness-based and CI is pending.
Proof confidence 🦐 gold shrimp (3/6) This collaborator-authored PR is outside the ordinary contributor proof gate; supplied evidence covers the actual observer and native transport in process on Node 24.18.0 and 26.12.1, reporting full checkpoint progress and unchanged successor rows.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Completed database readers can silently hold WAL snapshots or rewind a successor cursor, preventing checkpoints and allowing WAL growth.
Reason: The maintainer-authored direction addresses a demonstrated lifecycle defect through the existing owner without adding options, schemas, or another execution path.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a concrete SQLite cursor defect still present on main and completes the obsolete-probe cutover; no introduced correctness bug was found.

Priority: P2
Reviewed head: 1dd1097bd13e2eeb91b87a01f00b3402091e40e2

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No patched CLI or Gateway run is supplied; the reported red/green regressions exercise the production observer with real file-backed SQLite.
Agent review details

How this fits together

OpenClaw's database-opening owner installs the native observer, which translates SQLite statement execution into cursor custody and schema-lifecycle updates.

flowchart TD
A[Database caller] --> B[OpenClaw database owner]
B --> C[Native operation observer]
C --> D[Statement iterator]
D --> E[Node SQLite binding]
E --> F[SQLite WAL]
C --> G[Execution custody]
Loading

Technical review

Best possible solution:

Keep completion handling in the existing observer while preserving native-library admission and unfinished-cursor custody.

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

Current-main forwarding and the native implementation establish the failure path, corroborated by reported base-failing file-backed regressions; this read-only review executed no target code.

Is this the best way to solve the issue?

The patch fixes completion at its existing owner, removes superseded machinery, and retains separate native-library safety and identity checks.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Native iterator completion changes intended behavior with a stated reason (bb7d32e: Shared admission measured native restart behavior to account for cursor custody; 697e5bc subsequently protected newer cursor custody after stale returns.)
  • Runtime probe and admission transport changes intended behavior with a stated reason (87d4818: The qualification query reused iterator observations to avoid an extra SQL execution; terminal handling makes those observations unnecessary, while the retained get() still supplies library safety, extension capability, and storage identity.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 00ae274 adds src/infra/sqlite-native-observer.ts:271 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 00ae274c0a15; files: src/infra/sqlite-native-observer.ts)
  • Josh Avant: Raw commit 6c00e67 adds src/infra/sqlite-native-runtime.ts:35 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 6c00e67f5703; files: src/infra/sqlite-native-runtime.ts)

PR surface

Source -48, Tests +18, Docs +4, Other +2. Total -24 across 8 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 28 76 -48
Tests 3 41 23 +18
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 8 75 99 -24

Review metrics

Metric Value Why it matters
Production versus regression code Production +28/-76; tests +41/-23 Removing obsolete probing reduces production code by 48 lines while 18 net test lines protect checkpoint progress and successor-cursor preservation.

Root-cause cluster

Relationship: canonical
Canonical: #190242
Summary: This PR is the credited replacement for the same iterator repair with complete probe removal.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add P2: A focused SQLite reliability repair prevents checkpoint blockage and cursor rewinds on affected bindings without changing configuration or persisted formats.
  • 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: A focused SQLite reliability repair prevents checkpoint blockage and cursor rewinds on affected bindings without changing configuration or persisted formats.
  • 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 November 1, 2026, 5:52 AM ET / 10:52 UTC.

@roboclaw-bot
roboclaw-bot merged commit 2c0ab86 into main Nov 1, 2026
222 of 223 checks passed
@roboclaw-bot
roboclaw-bot deleted the loop/contributor-pr-184076 branch November 1, 2026 11:01
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash auto-merge.

roboclaw-bot added a commit that referenced this pull request Nov 1, 2026
#190242 left assertSafeSqliteRuntime exported with no consumer outside
its module, failing the deadcode:exports gate on main.

Co-authored-by: vyctorbrzezowski <[email protected]>
roboclaw-bot added a commit that referenced this pull request Nov 1, 2026
…CK, cron receipt) (#190276)

* test(auto-reply): stop expecting the retired session channel field

#190213 stopped the fast reply initializer from writing the retired
channel field, but the native slash fast-path test still seeded and
expected it, keeping main CI red. Assert the initialization without the
retired field and that new state omits it.

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

* test(auto-reply): stop expecting the retired session channel field

Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: 3f2d12c9-3b58-4138-8561-cb7952f2cdfe

* fix(infra): keep the SQLite runtime safety check module-private

#190242 left assertSafeSqliteRuntime exported with no consumer outside
its module, failing the deadcode:exports gate on main.

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

* Publish openclaw/mellow-crab

Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: 00c16b2f-1db1-444f-acba-f3e2049e6b05

* test(gateway): stop requiring messageSeq in the committed-mention ACK

chat.send includes messageSeq only once the transcript recorder has
attested placement, which can complete after the ACK. The committed
mention test asserted it unconditionally and failed intermittently on
main; the mention delivery and replay assertions are unchanged.

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

* test(cron): wait for the cancelled run receipt to settle

A cancelled isolated run keeps its receipt running, with the error
recorded, until execution settles (#189469). That settle write can land
after waitForManualRun resolves, so poll the receipt instead of reading
it once.

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

* Publish openclaw/mellow-crab

Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: f306e74f-b8fd-4268-82c9-22f5947f7610

---------

Co-authored-by: vyctorbrzezowski <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 2, 2026
…rts (openclaw#190242)

Finish and return native iterators once, answer later terminal calls in the
observer, and retire unused iterator capability probing and transport.
Prove WAL checkpoint progress and successor-cursor preservation with real
file-backed databases.

Co-authored-by: ava-perry <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 2, 2026
…CK, cron receipt) (openclaw#190276)

* test(auto-reply): stop expecting the retired session channel field

openclaw#190213 stopped the fast reply initializer from writing the retired
channel field, but the native slash fast-path test still seeded and
expected it, keeping main CI red. Assert the initialization without the
retired field and that new state omits it.

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

* test(auto-reply): stop expecting the retired session channel field

Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: 3f2d12c9-3b58-4138-8561-cb7952f2cdfe

* fix(infra): keep the SQLite runtime safety check module-private

openclaw#190242 left assertSafeSqliteRuntime exported with no consumer outside
its module, failing the deadcode:exports gate on main.

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

* Publish openclaw/mellow-crab

Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: 00c16b2f-1db1-444f-acba-f3e2049e6b05

* test(gateway): stop requiring messageSeq in the committed-mention ACK

chat.send includes messageSeq only once the transcript recorder has
attested placement, which can complete after the ACK. The committed
mention test asserted it unconditionally and failed intermittently on
main; the mention delivery and replay assertions are unchanged.

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

* test(cron): wait for the cancelled run receipt to settle

A cancelled isolated run keeps its receipt running, with the error
recorded, until execution settles (openclaw#189469). That settle write can land
after waitForManualRun resolves, so poll the receipt instead of reading
it once.

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

* Publish openclaw/mellow-crab

Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: f306e74f-b8fd-4268-82c9-22f5947f7610

---------

Co-authored-by: vyctorbrzezowski <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 14, 2026
…rts (#190242)

Finish and return native iterators once, keep later terminal calls in the
observer, and remove unused iterator capability probing and transport.
Prove WAL checkpoint progress and successor-cursor preservation.

Release adaptation: retain runtime admission in node-sqlite.ts instead of
introducing the newer sqlite-native-runtime.ts split. Preserve release
native lifecycle, safety-floor and worker contracts; adapt admission and
schema fixtures. Allocate exactly 29 net regression-test lines.

Companions: 1c437d1 (#190303) runtime assertion privacy is already
present. 40101a9 (#190276) has no remaining applicable SQLite change.
5954594 (#193710) certificate warnings are unrelated; e333f7e
(#197657) retires main-only test grants and is not needed for this fix.

Proof: 91 targeted tests passed across native observer, node SQLite and
schema metadata; formatting and diff checks passed.

(cherry picked from commit 2c0ab86)

Co-authored-by: ava-perry <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 15, 2026
Preserve the existing 2026.11.5 beta line and its pending test repairs.
Repair transcript admission, terminal SQLite iterators, binary attachment
classification, detached lifecycle calls, cron late wakes and reload handover.
Carry the explicitly requested Bonjour package-integrity fix and release guidance.

Selected backports: #188055, #198309, #190242, #198860, #198011, #197658,
#197484, #197606. #198011 is the operator-required open PR head, not a
merged-main claim. Cron tests are adapted to the existing beta runtime.

(cherry picked from commit e3064bf)
(cherry picked from commit afa871c)
(cherry picked from commit 2c0ab86)
(cherry picked from commit fee19a9)
(cherry picked from commit dbb6f39)
(cherry picked from commit 4d9f782)
(cherry picked from commit 87c10f5)
(cherry picked from commit ce76ed2)

Proof: frozen parent suite passed all 7 shards (265 tests) in 274.45s.
Separate unchanged-production baseline reproduced transcript/lifecycle,
late-wake and live-receipt failures. SQLite already passed on Node 26.12.1.
Independent review found no actionable P0/P1 defects in this snapshot.
The complete beta.4 candidate and stable-profile FRV remain pending.

Co-authored-by: jalehman <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: Yun. <[email protected]>
Co-authored-by: ava-perry <[email protected]>
Co-authored-by: Alfred J Berchtold <[email protected]>
Co-authored-by: Stronggenetics <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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