Skip to content

fix: open agent state on SQLite builds without extensions - #139487

Merged
steipete merged 1 commit into
mainfrom
codex/bun-sqlite-capability
Sep 5, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/bun-sqlite-capability

Conversation

@steipete

@steipete steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users running Bun on macOS could not open ordinary agent state because the system SQLite library does not support native extension loading.

Why This Change Was Made

Detect the loaded SQLite library's extension capability once during runtime validation. Persistent and incognito agent database owners request extension support only when the runtime supports it and permissions allow it. Explicitly extension-required operations remain strict, and extension loading remains disabled by default.

User Impact

Agent databases can open on SQLite builds without extensions. Native vector extensions still require an extension-capable library. No schema, persistence, migration, or permission policy changes.

Evidence

  • Original owner failed both new persistent/incognito regression cases; repaired owner passes.
  • Node: 161 tests passed, with four platform cases skipped.
  • Bun with Homebrew SQLite: 33 targeted tests passed.
  • Stock macOS Bun: all 209 original Gateway agent-event tests passed.
  • Full changed-file checks, lint, formatting, and independent review through P2 passed.
  • Apple's separate read-only WAL-sidecar behavior remains an external runtime limitation; the full Bun campaign is ongoing.

@clawsweeper

clawsweeper Bot commented Sep 5, 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 docs Improvements or additions to documentation size: S maintainer Maintainer-authored PR labels Sep 5, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 7:13 PM ET / 23:13 UTC.

ClawSweeper review

What this changes

Detect SQLite extension support before opening persistent or incognito agent databases, add regression coverage, and document Bun’s macOS limitations.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused repair: current main still requests unsupported extension loading when opening ordinary agent state. No blocking correctness or security findings were identified.

Priority: P2
Reviewed head: 271cf0e7cbbcd5f76825374a64eb847e863cc409

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate; no material authority change activates an exception. Reported Node and macOS Bun tests support the database-open repair but were not independently executed or treated as live runtime traces.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER association exempts this PR from the external-contributor proof gate; no material authority change activates an exception. Reported Node and macOS Bun tests support the database-open repair but were not independently executed or treated as live runtime traces.
Evidence reviewed 9 items Current main still contains the failure mechanism: At the fetched main revision, both persistent and incognito constructors still use allowExtension: !process.permission, without checking the loaded library’s extension capability.
Capability detection preserves existing safety checks: The loaded library is queried once during runtime validation, after the unchanged WAL safety check. The agent owner combines that capability with the existing permission restriction and immediately disables extension loading after construction.
Regression coverage exercises both database modes: Two owner-level cases inject unavailable extension support, write and read schema metadata, and assert that extension loading cannot subsequently be enabled. Separate capability cases cover both compile-option results. These tests were inspected, not executed.
Findings None None.
Security None None.

How this fits together

OpenClaw’s agent database owner opens the SQLite connections used for sessions and other per-agent state. Runtime capability detection determines whether those connections can support native extensions while preserving ordinary database access.

flowchart TD
  A[Agent state request] --> B[Database owner]
  C[Loaded SQLite library] --> D[Version and capability checks]
  D --> E[Runtime permission guard]
  E --> B
  B --> F[Persistent or incognito database]
  F --> G[Agent state reads and writes]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +15, Tests +42, Docs +8. Total +65 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 20 5 +15
Tests 2 43 1 +42
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 71 6 +65

Review metrics

None.

Technical review

Best possible solution:

Keep ordinary agent-state access independent of native extension availability while preserving the WAL floor, permission restrictions, and explicit extension requirements.

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

Yes, source identifies the trigger: ordinary agent database creation requests extension support even when the loaded SQLite library omits it. This review did not execute a failing runtime reproduction.

Is this the best way to solve the issue?

Yes. Detecting the loaded library’s capability at runtime validation and applying it at the database owner is a narrow repair that preserves extension-capable setups and existing storage contracts.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs agent database access on the optional Bun runtime without changing the recommended Node workflow.
  • 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 supplied MEMBER association exempts this PR from the external-contributor proof gate; no material authority change activates an exception. Reported Node and macOS Bun tests support the database-open repair but were not independently executed or treated as live runtime traces.

Evidence

What I checked:

  • Current main still contains the failure mechanism: At the fetched main revision, both persistent and incognito constructors still use allowExtension: !process.permission, without checking the loaded library’s extension capability. (src/state/openclaw-agent-db.ts:439, c91b1eaab768)
  • Capability detection preserves existing safety checks: The loaded library is queried once during runtime validation, after the unchanged WAL safety check. The agent owner combines that capability with the existing permission restriction and immediately disables extension loading after construction. (src/infra/node-sqlite.ts:80, 271cf0e7cbbc)
  • Regression coverage exercises both database modes: Two owner-level cases inject unavailable extension support, write and read schema metadata, and assert that extension loading cannot subsequently be enabled. Separate capability cases cover both compile-option results. These tests were inspected, not executed. (src/state/openclaw-agent-db.test.ts:851, 271cf0e7cbbc)
  • Explicit extension requests retain their contract: Read-only callers that explicitly request extensions still open a separate connection with allowExtension: true. The introduced patch does not change schemas, migrations, stored values, or plugin APIs. (src/state/openclaw-agent-db-readonly.ts:76, 271cf0e7cbbc)
  • Bun’s documented platform boundary: The PR directly depends on Bun’s SQLite behavior. Official Bun documentation confirms that Apple’s SQLite lacks extension support and that a custom library must be selected before opening databases: Bun SQLite extensions.
  • Node constructor capability contract: Official Node documentation confirms that constructing with allowExtension: false prevents later enabling native extension loading, supporting the new owner-level assertion: Node SQLite extension controls.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jason (Json): 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-05T23:05:10.819Z sha 271cf0e :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review September 5, 2026 23:09
@steipete
steipete merged commit 1c1b334 into main Sep 5, 2026
248 checks passed
@steipete
steipete deleted the codex/bun-sqlite-capability branch September 5, 2026 23:27
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 5, 2026
* origin/main: (95 commits)
  perf(build): avoid unrelated gateway artifact scans (#127757)
  fix(update): deliver terminal progress after long updates (#139289)
  fix(ui): show session hover cards for local chat URLs (#139384)
  perf(ui): reuse unchanged transcript key snapshots (#139400)
  fix(ui): make subagent sessions view-only (#139381)
  fix: open agent state on SQLite builds without extensions (#139487)
  perf(skills): detach cached metadata from source strings (#139478)
  fix(ui): show primary user in multi-agent profile hero (#136736)
  perf(sessions): stop decoding the session row four times per SQLite entry patch (#136361)
  refactor(exec): share package-manager option scans (#139482)
  fix(ci): authorize frozen mobile release candidates (#139441)
  fix: avoid session deletion slowdown in large session stores (#139467)
  perf(gateway): reuse node invocation idle timers (#139354)
  fix(auth): preserve selected profiles across plugin scopes (#139413)
  fix(discord): retain voice input until transcription completes (#139484)
  fix(agents): name Gateway storage failures in run-failure copy (#139409)
  fix: keep subagent checks responsive in large session stores (#139450)
  fix(memory): index notes when optional embeddings cannot start (#139463)
  fix: refresh pending approvals when reopening chat (#139457)
  fix(tooling): preserve Git hook choices during install (#139461)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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