Skip to content

Commit e6c2adb

Browse files
committed
docs(driver-memory): stop calling this production-ready; say what it does not enforce (#4065)
The class docstring opened with "A production-ready implementation of the ObjectStack Driver Protocol". The driver stores no constraints of any kind: `create()` is a `table.push()` and `syncSchema()` only allocates an array and indexes temporal fields, so there is no primary key, no uniqueness, no NOT NULL, no foreign key and no column typing. `bulkCreate` lands two rows with the same id where a SQL driver raises a constraint violation, and a read returns both — the second finding in #4065, and the mechanism behind the 2N row growth there. Per Prime Directive #10 the options for `declared ≠ enforced` are implement it, trim the claim, or file it. With this driver moving to maintenance-only — kept for the last-resort rung of the dev step-down, browser/edge runtimes with no SQLite build, and the read-coercion parity gate — the claim is what goes. The docstring now states the missing constraints plainly, names the driver as a WEAK oracle for tests, and points at in-memory SQLite instead. No behaviour change; 197 driver-memory tests unchanged and green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L5q3BZMpdiAueHf2emhDY9
1 parent 988910a commit e6c2adb

2 files changed

Lines changed: 35 additions & 5 deletions

File tree

.changeset/memory-driver-opt-in-persistence.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,13 @@ genuinely wanted durability now state it, rather than inheriting it:
6565
`DevPlugin`'s driver is now explicitly `persistence: false`, matching the cache,
6666
queue, job, i18n, storage and search stubs it ships beside — it was the one piece
6767
of that stack that quietly outlived the process.
68+
69+
**One claim trimmed, no behaviour attached.** The class docstring called this a
70+
"production-ready implementation of the ObjectStack Driver Protocol". It stores
71+
no constraints at all — `create()` is a `table.push()` and `syncSchema()` only
72+
allocates an array — so there is no primary key, uniqueness, `NOT NULL`, foreign
73+
key or column typing, and `bulkCreate` lands duplicate ids where a SQL driver
74+
raises a violation (the second finding in #4065). The docstring now says so, and
75+
points test authors at in-memory SQLite. Per Prime Directive #10 the fix for
76+
`declared ≠ enforced` is to implement it, trim the claim, or file it; with this
77+
driver moving to maintenance-only the claim is what goes.

packages/plugins/driver-memory/src/memory-driver.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,38 @@ interface MemoryTransaction {
8080

8181
/**
8282
* In-Memory Driver for ObjectStack
83-
*
84-
* A production-ready implementation of the ObjectStack Driver Protocol
85-
* powered by Mingo — a MongoDB-compatible query and aggregation engine.
86-
*
83+
*
84+
* An implementation of the ObjectStack Driver Protocol powered by Mingo — a
85+
* MongoDB-compatible query and aggregation engine.
86+
*
8787
* Features:
8888
* - MongoDB-compatible query engine (Mingo) for filtering, projection, aggregation
8989
* - Full CRUD and bulk operations
9090
* - Aggregation pipeline support ($match, $group, $sort, $project, $unwind, etc.)
9191
* - Snapshot-based transactions (begin/commit/rollback)
9292
* - Field projection and distinct values
9393
* - Strict mode and initial data loading
94-
*
94+
*
95+
* ## What this driver does NOT enforce
96+
*
97+
* It stores no constraints of any kind. {@link create} is a `table.push()` and
98+
* {@link syncSchema} only allocates an array and indexes temporal fields, so
99+
* there is no primary key, no uniqueness, no `NOT NULL`, no foreign key and no
100+
* column typing. `bulkCreate` will happily land two rows with the same `id`
101+
* where a SQL driver raises a constraint violation, and a read returns both.
102+
*
103+
* That makes it a WEAK oracle: code green against this driver can still be
104+
* broken against the SQL engines production runs on. Prefer in-memory SQLite
105+
* for tests — `SqlDriver` with `connection: { filename: ':memory:' }`, or
106+
* `SqliteWasmDriver({ filename: ':memory:' })` where no native build is wanted.
107+
* This driver's remaining roles are the last-resort rung of the dev step-down
108+
* (native better-sqlite3 → WASM SQLite → here), browser/edge runtimes where no
109+
* SQLite build is available, and the cross-driver read-coercion parity gate.
110+
*
111+
* The docstring said "production-ready" until #4065; the constraints above were
112+
* true then too, and saying so is the fix (Prime Directive #10 — never advertise
113+
* a capability the runtime does not deliver).
114+
*
95115
* Reference: objectql/packages/drivers/memory
96116
*/
97117
export class InMemoryDriver implements IDataDriver {

0 commit comments

Comments
 (0)