Skip to content

fix(memory): replace node:sqlite with better-sqlite3 to enable sqlite-vec on macOS - #90323

Closed
googlerest wants to merge 3 commits into
openclaw:mainfrom
googlerest:fix/memory-sqlite-vec-macos-extension-loading
Closed

googlerest wants to merge 3 commits into
openclaw:mainfrom
googlerest:fix/memory-sqlite-vec-macos-extension-loading

Conversation

@googlerest

@googlerest googlerest commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #66977.

node:sqlite on macOS is compiled with OMIT_LOAD_EXTENSION=1, making enableLoadExtension(true) throw unconditionally at runtime. This prevents sqlite-vec from loading, leaving all embedding arrays empty ([]) and disabling vector similarity search for all macOS users. FTS5 keyword search still works, but hybrid/vector ranking is completely unavailable.

Root cause: compile-time SQLite flag — no runtime workaround exists.

Fix: replace node:sqlite with better-sqlite3 in the memory subsystem. better-sqlite3 ships its own SQLite binary compiled without OMIT_LOAD_EXTENSION, and exposes db.loadExtension() directly without needing a separate enableLoadExtension() guard.

Changes

  • packages/memory-host-sdk — add better-sqlite3 dep; introduce MemoryDb/MemoryStatement interfaces; add requireBetterSqlite3(); remove enableLoadExtension(true) from loadSqliteVecExtension()
  • src/infra/sqlite-wal.ts — widen db param from DatabaseSync to { exec(sql): unknown } so both backends satisfy the type
  • Memory subsystem files (manager-db, manager-sync-ops, manager-search, memory-schema, qmd-manager, and related) — replace DatabaseSync/SQLInputValue refs with MemoryDb/unknown[]
  • pnpm-workspace.yaml — allow better-sqlite3 build scripts

Real behavior proof

Behavior or issue addressed: On macOS, node:sqlite is compiled with OMIT_LOAD_EXTENSION=1. Calling db.enableLoadExtension(true) throws Error: This API is unavailable when SQLite is not compiled with OMIT_LOAD_EXTENSION=0. After this patch, better-sqlite3 is used instead, which ships its own SQLite binary compiled without that restriction, allowing sqlite-vec to load successfully.

Real environment tested: Local macOS M4 (darwin arm64, Node v25.9.0), branch fix/memory-sqlite-vec-macos-extension-loading, ~/openclaw-dev/.

Exact steps or command run after this patch:

node scripts/run-vitest.mjs packages/memory-host-sdk/src/host/sqlite-vec.integration.test.ts --reporter=verbose

Evidence after fix:

 RUN  v4.1.7 /Users/googlerest/openclaw-dev

 ✓ |unit-fast| packages/memory-host-sdk/src/host/sqlite-vec.integration.test.ts > loadSqliteVecExtension (integration — real better-sqlite3 + real extension) > loads sqlite-vec into a real better-sqlite3 in-memory database 10ms
 ✓ |unit-fast| packages/memory-host-sdk/src/host/sqlite-vec.integration.test.ts > loadSqliteVecExtension (integration — real better-sqlite3 + real extension) > vec_version() is callable after loading sqlite-vec into better-sqlite3 2ms

 Test Files  1 passed (1)
      Tests  2 passed (2)
   Start at  01:59:30
   Duration  4.12s (transform 3.07s, setup 0ms, import 4.02s, tests 13ms, environment 0ms)

Observed result after fix: sqlite-vec loads successfully into a real better-sqlite3 in-memory database on macOS. vec_version() is callable and returns the loaded extension version. The integration test that exercises the actual extension loading path passes.

What was not tested: Live OpenClaw memory session with real conversation data (no live credentials in test environment). The dependency-guard check blocks this PR due to policy requiring maintainer sign-off on new external dependencies (better-sqlite3 in packages/memory-host-sdk/package.json).

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Dependency Guard

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • packages/memory-host-sdk/package.json
  • pnpm-lock.yaml
  • pnpm-workspace.yaml

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfile, shrinkwrap, or workspace dependency policy changes are present.
  • Treat package-lock.json and npm-shrinkwrap.json diffs as security-review surfaces.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

@github-actions

github-actions Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Dependency graph changes are blocked

OpenClaw does not accept dependency graph changes through PRs unless a repository admin or security explicitly authorizes the current head SHA. Dependency updates are generated internally by maintainers so external PRs cannot change the resolved graph.

Detected dependency graph changes:

  • pnpm-lock.yaml changed.
  • packages/memory-host-sdk/package.json changed dependencies.

Auto-scrub was not attempted because this PR changes package manifest dependency graph fields:

  • packages/memory-host-sdk/package.json changed dependencies.

Dependency graph changes must be reviewed by security or handled by maintainers internally. Please remove lockfile changes manually if they are not needed.

To remove lockfile changes, restore them from the target branch:

git fetch origin
git checkout 'origin/main' -- 'pnpm-lock.yaml'
git commit -m 'chore: remove dependency lockfile change'
git push

If this PR intentionally needs a dependency graph change, ask a repository admin or member of @openclaw/openclaw-secops to comment:

/allow-dependencies-change

The action will approve the current head SHA (a2652a1ac4c51964ab5c7d2a4ef225341c65b3e5) when it reruns. A later push requires a fresh approval.

@socket-security

socket-security Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​better-sqlite3@​12.11.18810010093100

View full report

@socket-security

socket-security Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm better-sqlite3 is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: packages/memory-host-sdk/package.json → npm/[email protected]

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at [email protected].

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/[email protected]. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn Medium
Deprecated by its maintainer: npm prebuild-install

Reason: No longer maintained. Please contact the author of the relevant native addon; alternatives are available.

From: pnpm-lock.yaml → npm/[email protected] → npm/[email protected]

ℹ Read more on: This package | This alert | What is a deprecated package?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at [email protected].

Suggestion: Research the state of the package and determine if there are non-deprecated versions that can be used, or if it should be replaced with a new, supported solution.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/[email protected]. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label Jun 4, 2026
@clawsweeper

clawsweeper Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 21, 2026, 2:27 PM ET / 18:27 UTC.

Summary
The PR replaces memory-core's node:sqlite database path with better-sqlite3, retargets memory DB types, adds a sqlite-vec integration test, and changes dependency/build-script metadata.

PR surface: Source -14, Tests +46, Config +4, Other +168. Total +204 across 19 files.

Reproducibility: yes. for the PR blockers: source and CI show dangling DatabaseSync references, an ExecDb type missing prepare(), and missing SDK exports. The original macOS sqlite-vec failure is source-plausible and supported by issue/proof comments, but this Linux checkout did not live-reproduce the macOS Node SQLite compile-option failure.

Review metrics: 1 noteworthy metric.

  • Dependency graph surface: 1 direct native dependency added; 1 build-script allowlist added; 1 pnpm lockfile changed; 0 root package/shrinkwrap deps changed. The runtime fix depends on a native package being available in shipped installs, not only in the workspace package graph.

Stored data model
Persistent data-model change detected: unknown-data-model-change: extensions/memory-core/src/memory/manager-db.ts, unknown-data-model-change: extensions/memory-core/src/memory/manager-sync-ops.ts, vector/embedding metadata: extensions/memory-core/src/memory/manager-db.ts, vector/embedding metadata: extensions/memory-core/src/memory/manager-embedding-cache.ts, vector/embedding metadata: extensions/memory-core/src/memory/manager-fts-state.ts, vector/embedding metadata: extensions/memory-core/src/memory/manager-search.ts, and 11 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #66977
Summary: This PR is the candidate fix for the linked macOS sqlite-vec extension-loading issue, while adjacent FTS and embedding-cache work remain distinct.

Members:

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

Merge readiness
Overall: 🧂 unranked krab
Proof: 🦪 silver shellfish
Patch quality: 🧂 unranked krab
Result: blocked until stronger real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Fix the SDK export, sqlite-vec type, WAL DB contract, and shipped package graph blockers.
  • Get maintainer/security approval for the native dependency graph at the current head SHA.
  • [P1] Add redacted macOS OpenClaw memory index/status/search proof after the backend swap.

Proof guidance:

  • [P1] Needs stronger real behavior proof before merge: The supplied terminal proof shows sqlite-vec loading into better-sqlite3 on macOS, but it does not show the patched OpenClaw memory index/status/search path after the backend swap. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] The native better-sqlite3 dependency and build-script allowlist need maintainer/security approval for the exact head SHA before this can merge.
  • [P1] The proposed backend switch changes a compatibility-sensitive memory database runtime path used by existing stores and upgrades.
  • [P1] The supplied proof does not yet show the patched OpenClaw memory index/status/search flow on macOS after the backend swap.

Maintainer options:

  1. Fix blockers before dependency approval (recommended)
    Have the author or a maintainer update the SDK exports, WAL/sqlite-vec types, shipped package graph, and macOS OpenClaw proof before asking secops to approve the native dependency head.
  2. Approve native backend as accepted risk
    Maintainers may explicitly accept better-sqlite3 as the new memory backend after reviewing the native addon, install script, deprecated prebuild-install transitive dependency, and package/update behavior.
  3. Pause for a maintainer-owned replacement
    If the native dependency direction is not acceptable, close or pause this branch and replace it with a maintainer-owned macOS runtime/package strategy for sqlite-vec.

Next step before merge

  • [P1] The remaining blockers include backend direction and native dependency/security approval, so maintainers need to decide before any automated repair lane should take over.

Security
Needs attention: The diff adds a native dependency and build-script allowlist, and existing dependency/security automation requires maintainer authorization for the exact head SHA.

Review findings

  • [P1] Export the new memory DB symbols through the SDK — extensions/memory-core/src/memory/manager-db.ts:9
  • [P1] Keep sqlite-vec's database type coherent — packages/memory-host-sdk/src/host/sqlite-vec.ts:4
  • [P1] Include prepare in the WAL DB contract — src/infra/sqlite-wal.ts:7
Review details

Best possible solution:

Maintainers should first approve or reject the better-sqlite3 backend direction, then require the branch to fix the SDK/type/package blockers, update the shipped dependency graph, and provide redacted macOS OpenClaw memory index/status/search proof.

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

Yes for the PR blockers: source and CI show dangling DatabaseSync references, an ExecDb type missing prepare(), and missing SDK exports. The original macOS sqlite-vec failure is source-plausible and supported by issue/proof comments, but this Linux checkout did not live-reproduce the macOS Node SQLite compile-option failure.

Is this the best way to solve the issue?

No as currently shaped. Replacing node:sqlite with better-sqlite3 is a plausible mitigation, but the current patch is not the best mergeable form until the SDK/package/type blockers and native dependency approval path are resolved.

Full review comments:

  • [P1] Export the new memory DB symbols through the SDK — extensions/memory-core/src/memory/manager-db.ts:9
    This import uses MemoryDb from openclaw/plugin-sdk/memory-core-host-engine-storage, but the PR does not update packages/memory-host-sdk/src/engine-storage.ts or the SDK re-export path to export MemoryDb, MemoryStatement, or requireBetterSqlite3. The extension will fail typechecking/import resolution until the public subpath exports the new symbols.
    Confidence: 0.93
  • [P1] Keep sqlite-vec's database type coherent — packages/memory-host-sdk/src/host/sqlite-vec.ts:4
    The patch removes the DatabaseSync import and changes the public parameter to MemoryDb, but helper signatures below still reference DatabaseSync; CI reports TS2304 for those dangling names. Change the helper types to the new interface or keep the old import if it is still part of the contract.
    Confidence: 0.96
  • [P1] Include prepare in the WAL DB contract — src/infra/sqlite-wal.ts:7
    ExecDb only declares exec(), but rollback-journal handling still calls db.prepare(...).get(). This produces the CI TS2339 failure and would leave non-WAL network-filesystem handling outside the declared contract.
    Confidence: 0.97
  • [P1] Declare better-sqlite3 in the shipped package graph — packages/memory-host-sdk/package.json:22
    Adding better-sqlite3 only to the private packages/memory-host-sdk manifest does not make it available to published openclaw installs, whose root package.json/npm-shrinkwrap.json carry the shipped dependency graph. The patched dist path would require this module at runtime, so root package metadata or an explicit maintainer-approved package strategy must be updated too.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against bda05dbc2f15.

Label changes

Label justifications:

  • P2: This is a normal-priority memory backend bug fix with meaningful but bounded macOS vector-recall impact.
  • merge-risk: 🚨 compatibility: The PR changes the SQLite backend and package dependency graph used by existing memory stores.
  • merge-risk: 🚨 security-boundary: The PR adds a native dependency and build-script allowlist that require supply-chain review.
  • merge-risk: 🚨 availability: A broken memory database backend or missing shipped dependency can prevent memory indexing/search from starting.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The supplied terminal proof shows sqlite-vec loading into better-sqlite3 on macOS, but it does not show the patched OpenClaw memory index/status/search path after the backend swap. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source -14, Tests +46, Config +4, Other +168. Total +204 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 14 132 146 -14
Tests 2 50 4 +46
Docs 0 0 0 0
Config 2 4 0 +4
Generated 0 0 0 0
Other 1 509 341 +168
Total 19 695 491 +204

Security concerns:

  • [medium] Native dependency requires approval — packages/memory-host-sdk/package.json:22
    better-sqlite3 installs native code through prebuild-install || node-gyp rebuild --release; this intentionally expands the executable install surface and should not merge without maintainer/security approval of the exact dependency graph.
    Confidence: 0.93
  • [low] Deprecated transitive installer remains in graph
    The added dependency currently pulls [email protected], which npm marks deprecated, so maintainers should explicitly accept or avoid that supply-chain risk before allowing the dependency change.
    Confidence: 0.86

What I checked:

Likely related people:

  • vincentkoc: Recent history on sqlite-vec loading, memory DB publishing/reindex safety, and shared SQLite WAL policy points to this person as the strongest routing candidate for the affected runtime paths. (role: recent memory/sqlite contributor; confidence: high; commits: 355a9cbf354c, 9c5ac9f42da2, d64db0fc3d1c; files: packages/memory-host-sdk/src/host/sqlite-vec.ts, extensions/memory-core/src/memory/manager-db.ts, extensions/memory-core/src/memory/manager-sync-ops.ts)
  • steipete: History shows package contract and memory host SDK extraction/localization work on the same SDK/package boundary now affected by the new dependency and exports. (role: memory host SDK and package-surface history contributor; confidence: medium; commits: f7d139dfef96, dc3df62e67c7, eebce9e9c7cb; files: packages/memory-host-sdk/src/host/sqlite-vec.ts, packages/memory-host-sdk/src/host/sqlite.ts, packages/memory-host-sdk/src/engine-storage.ts)
  • corevibe555: This person authored the merged sqlite-vec platform-variant fallback in the same loader path involved in the macOS extension-loading cluster. (role: sqlite-vec fallback contributor; confidence: medium; commits: a1fc955aef6a; files: packages/memory-host-sdk/src/host/sqlite-vec.ts, packages/memory-host-sdk/src/host/sqlite-vec-platform-variant.ts, packages/memory-host-sdk/src/host/sqlite-vec.test.ts)
  • honor2030: This person recently changed shared SQLite WAL checkpoint behavior in the same src/infra/sqlite-wal.ts helper that the PR widens for better-sqlite3. (role: adjacent sqlite WAL contributor; confidence: low; commits: 1a2e41850092; files: src/infra/sqlite-wal.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jun 4, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. plugin: bonjour Plugin integration: bonjour and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 14, 2026
@googlerest

Copy link
Copy Markdown
Contributor Author

Updated real behavior proof — current head 8828988aee

Environment: macOS arm64 (M4), Node v25.9.0, branch fix/memory-sqlite-vec-macos-extension-loading, commit 8828988aee

Results:

node scripts/run-vitest.mjs packages/memory-host-sdk/src/host/sqlite-vec.integration.test.ts --reporter=verbose

 RUN  v4.1.7 /Users/googlerest/openclaw-dev

 ✓  unit-fast  > loadSqliteVecExtension (integration — real better-sqlite3 + real extension)
    > loads sqlite-vec into a real better-sqlite3 in-memory database  58ms
 ✓  unit-fast  > loadSqliteVecExtension (integration — real better-sqlite3 + real extension)
    > vec_version() is callable after loading sqlite-vec into better-sqlite3  8ms

 Test Files  1 passed (1)
       Tests  2 passed (2)
    Duration  13.76s

[test] passed 1 Vitest shard in 23.33s

System: arm64 / Node v25.9.0. sqlite-vec loads into real better-sqlite3 on macOS arm64. vec_version() callable. This proves the fix: node:sqlite OMIT_LOAD_EXTENSION=1 no longer blocks extension loading.

Note: Dependency Guard is still failing — needs /allow-dependencies-change from a repo admin or @openclaw/openclaw-secops member for head SHA 8828988aeea73c3034585da246f02e0c95505891.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@googlerest

Copy link
Copy Markdown
Contributor Author

@openclaw/openclaw-secops — this PR needs /allow-dependencies-change to authorize the native better-sqlite3 dependency addition for head SHA 8828988aeea73c3034585da246f02e0c95505891. The dependency is required to fix sqlite-vec extension loading on macOS (node:sqlite is compiled with OMIT_LOAD_EXTENSION=1 and has no runtime workaround). Proof that it works on macOS arm64 is in the comment above.

@googlerest
googlerest force-pushed the fix/memory-sqlite-vec-macos-extension-loading branch from 8828988 to c4b2877 Compare June 18, 2026 14:37
@openclaw-barnacle openclaw-barnacle Bot removed the plugin: bonjour Plugin integration: bonjour label Jun 18, 2026
Preserves upstream/main additions (cleanupAgedMemoryReindexTempFiles, double-open
safety, reindex lock, NFS WAL detection) while applying PR openclaw#90323 changes:
- MemoryDb interface backed by better-sqlite3
- requireBetterSqlite3 replaces requireNodeSqlite in memory paths
- Remove allowExtension param (better-sqlite3 always supports loadExtension)
- Remove enableLoadExtension(true) call from sqlite-vec
- Set allowBuilds.better-sqlite3 = true in pnpm-workspace.yaml
…e-vec on macOS

Verifies that better-sqlite3 can call loadExtension() without needing
enableLoadExtension(), and that vec_version() is callable after load.
@googlerest
googlerest force-pushed the fix/memory-sqlite-vec-macos-extension-loading branch from bb34875 to 6e15dfb Compare June 18, 2026 15:04
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Jun 18, 2026
@googlerest

Copy link
Copy Markdown
Contributor Author

Behavior addressed: re-verified whether node:sqlite actually has "no runtime workaround" for OMIT_LOAD_EXTENSION on macOS, as this PR's summary claims — and whether better-sqlite3 is still necessary to fix #66977.

Real environment tested: macOS arm64 (M4), Darwin 25.5.0, Node v25.9.0 — same environment and same Node version originally used for this PR's "Real behavior proof".

Exact steps or command run after this patch:

node -e "
const { DatabaseSync } = require('node:sqlite');
const db = new DatabaseSync(':memory:');
try { db.enableLoadExtension(true); } catch (err) { console.log('repro:', err.message); }
"
node -e "
const { DatabaseSync } = require('node:sqlite');
const db = new DatabaseSync(':memory:', { allowExtension: true });
db.enableLoadExtension(true);
const sqliteVec = require('sqlite-vec');
sqliteVec.load(db);
const row = db.prepare('SELECT vec_version() AS v').get();
console.log('loaded, version:', row.v);
"

Evidence after fix:

repro: Cannot enable extension loading because it was disabled at database creation.
loaded, version: v0.1.9

Observed result after fix: confirmed the bug reproduces exactly as described when DatabaseSync is constructed without allowExtension. But node:sqlite already exposes a constructor-level allowExtension option that permits enableLoadExtension/loadExtension to work — sqlite-vec loads successfully and vec_version() returns v0.1.9 once that option is set, with no native dependency swap required.

upstream/main's current extensions/memory-core/src/memory/manager-db.ts already opens the database with new DatabaseSync(dbPath, { allowExtension }), and packages/memory-host-sdk/src/host/sqlite-vec.ts's loadSqliteVecExtension() already calls enableLoadExtension(true) + loads the extension on that handle. This wiring has been on main since at least commit 8d2daf7ef2 ("perf: extract memory sync control helpers", 2026-04-06) — predating this PR (opened 2026-06-04). main solved #66977 with a one-line constructor flag instead of a better-sqlite3 migration.

This PR's premise ("no runtime workaround exists") does not hold against current main. Given that, plus the added native dependency, the pending dependency-guard/secops sign-off requirement, and the now-substantial rebase conflicts against main's evolved memory-core code (6 files, ~2000 commits diverged), I'm closing this PR as superseded.

What was not tested: did not re-run the PR's own sqlite-vec.integration.test.ts against better-sqlite3 again (no need — the question was whether main's existing approach already works, and it does).

Closing as superseded by main's existing allowExtension fix (see extensions/memory-core/src/memory/manager-db.ts + packages/memory-host-sdk/src/host/sqlite-vec.ts on main, wiring present since commit 8d2daf7ef2).

@googlerest googlerest closed this Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies-changed PR changes dependency-related files extensions: memory-core Extension: memory-core merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: sqlite-vec extension cannot load on macOS — node:sqlite compiled with OMIT_LOAD_EXTENSION

1 participant