fix(cli): dispatch OS_DATABASE_DRIVER=memory to the mingo InMemoryDriver (#3276)#3285
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 17 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
…ver (#3276) `os dev` / `os start` / `os serve` all advertise a `memory` database driver (`--database-driver memory`, `OS_DATABASE_DRIVER=memory`, and a `memory://` URL scheme), but serve.ts's driver dispatch had no `memory` branch. So selecting it silently fell through to the dev SQLite `:memory:` default (SQLite-in-memory — a different engine), or registered no driver at all in production. Declared ≠ enforced. Fix + refactor: - Extract the driver kind-resolution and construction out of serve.ts's inline if/else chain into utils/storage-driver.ts, mirroring the existing utils/telemetry-datasource.ts / utils/plugin-detection.ts pattern, so the whole dispatch is unit-testable in isolation. - Add the missing `memory` (aliases `mingo`, `in-memory`) branch that builds the mingo InMemoryDriver, honored in dev AND production. - Recognize the advertised `memory://` / `mingo://` URL scheme in inferDriverTypeFromUrl (distinct from sqlite's `:memory:` pseudo-file, which stays SQLite's own in-memory mode). - serve.ts telemetry-datasource provisioning behavior is preserved exactly (keyed on an explicit-sqlite primary path; never the memory driver). Tests (storage-driver.test.ts) cover the full URL→kind mapping, explicit>URL precedence, and every construction branch; the `memory` assertions go red without the new branch (verified: dev→SqlDriver, prod→null). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
xuyushun441-sys
force-pushed
the
fix/cli-memory-driver-dispatch
branch
from
July 19, 2026 16:10
e157e0c to
d8cfa0b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #3276.
os dev/os start/os serveall advertise amemorydatabase driver —--database-driver … | memory(dev.ts:88-90, start.ts:99-100),OS_DATABASE_DRIVER=memory, and amemory://URL scheme in the help text — butserve.ts's driver dispatch had nomemorybranch. So selecting it silentlyfell through to the dev SQLite
:memory:default (resolveSqliteDriver→SQLite-in-memory, a different engine), or, in production, registered no
driver at all. The mingo
InMemoryDriverwas only ever reached as the lastresort when both native
better-sqlite3and the wasm fallback failed to load.Declared ≠ enforced — picking
memorygave a different engine than intended.Fix
serve.ts's inlineif/else chain into
packages/cli/src/utils/storage-driver.ts, mirroring theexisting
utils/telemetry-datasource.ts/utils/plugin-detection.tspattern,so the whole dispatch is unit-testable in isolation (it previously required a
full HTTP boot to exercise). Net −75 lines in
serve.ts.memorybranch (aliasesmingo,in-memory) that builds themingo
InMemoryDriver, honored in dev AND production — an explicit operatorchoice is enforced, not silently swapped.
memory:///mingo://URL scheme ininferDriverTypeFromUrl, kept deliberately distinct from sqlite's:memory:pseudo-file (which stays SQLite's own in-memory mode).
SQLite primary path (
sqliteFilePath), never the memory driver nor the dev-default:memory:store, matching pre-extraction behavior.Tests
storage-driver.test.ts(14 cases) covers the full URL→kind mapping, explicit>URLprecedence, and every construction branch. Proven to go red without the fix
(verified by disabling the branch):
memory→SqlDriverin dev,nullin prod.vitest run— new file 14/14; existing serve/dev tests 29/29tsc -p tsconfig.build.jsoncleaneslintcleanOut of scope (flagged separately)
The same "declared ≠ enforced" gap exists for
turso/libsql: URLs infer todriverType = 'turso'but there is no'turso'dispatch branch and nodriver-tursopackage, so it also falls through to SQLite. Left for a follow-up(either implement a turso driver, or stop advertising it).
🤖 Generated with Claude Code