Finish #46: swap adapter-local to native SQLite, make sqljs browser-only, update docs#86
Merged
Merged
Conversation
Completes #46: the remaining §5 (adapter-local swap), §2 (sqljs browser cleanup), and §6 (docs) items. adapter-local: - Swaps from record-adapter-sqljs to record-adapter-sqlite (NativeSQLiteRecordAdapter) — invisible at the API surface, per the issue's "none intended" breaking-changes note. Node engine floor rises to >=22.5.0 to match. - Bearer tokens now go through NativeTokenStore at a separate sibling file (`<path>.tokens`), opened lazily on first token method call so plain single-app embedded use that never touches tokens never creates it. - Adds deleteUnreferencedAttachmentRecords delegation, which was missing even before this swap — Stack.deleteAttachment()'s atomic path silently never engaged through LocalAdapter without it. record-adapter-sqljs (browser-only, per the issue's breaking-changes section — no browser consumers exist yet to break): - initialize()/open() take `{ entityId, timezone, persist? }` / `{ bytes, persist? }` instead of a path. No more fs, node:crypto, or Buffer — durability is the embedder's job now (OPFS, IndexedDB, a download), wired through an optional `persist(bytes) => Promise<void>` callback called after every write. - No storage-ownership lock (no path, no PID concept in a browser) and no token methods (moved out entirely, per #46 §4 — a browser adapter has no business shipping bearer-token storage). - sqlite-shared's SharedSqlRecordLogic.onWrite is now awaited rather than fire-and-forget, since sqljs's persist callback is async; native's write path is unaffected (it has no onWrite at all). - Test suite rewritten for the new API (77 tests) — expected given this is an intentionally breaking change, unlike the earlier SqlExecutor consolidation where zero test changes was the point. Docs (README, spec.md): - Package tables: add record-adapter-sqlite, reposition record-adapter-sqljs as browser-only. - Rewrote spec.md's "Concurrency & storage ownership" section — the PID lock file and atomic-persist guidance it described now applies to record-adapter-sqlite (whose WAL journaling actually makes most of it moot) and the still-planned adapter-json, not sqljs, which no longer touches a file at all. - Fixed the capabilities table's blanket "FTS5" claim to distinguish the native adapter (FTS5) from sqljs (FTS4), and the wire-format token-store aside to name StackTokenStore/NativeTokenStore instead of the old inline SQLiteAdapter token methods. Full monorepo: 567 tests passing, clean build/typecheck/lint/format. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RRLiGUZC344E3pgNEGAe5W
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.
Summary
Closes out the remaining items of #46: §5 (
adapter-localswap), §2 (sqljs browser cleanup), and §6 (docs).adapter-local:record-adapter-sqljstorecord-adapter-sqlite(NativeSQLiteRecordAdapter) — invisible at the API surface, per the issue's "none intended" breaking-changes note. Node engine floor rises to>=22.5.0to match.NativeTokenStoreat a separate sibling file (<path>.tokens), opened lazily on first token method call — so plain single-app embedded use that never touches tokens never creates that file.deleteUnreferencedAttachmentRecordsdelegation, which turned out to be missing even before this swap —Stack.deleteAttachment()'s atomic path was silently never engaging throughLocalAdapterwithout it.record-adapter-sqljs(browser-only now, per the issue's breaking-changes section — no browser consumers exist yet to break):initialize()/open()take{ entityId, timezone, persist? }/{ bytes, persist? }instead of a path. No morefs,node:crypto, orBuffer— durability is the embedder's job now (OPFS, IndexedDB, a download), wired through an optionalpersist(bytes) => Promise<void>callback called after every write.sqlite-shared'sSharedSqlRecordLogic.onWriteis now awaited rather than fire-and-forget, since sqljs's persist callback is async; the native adapter's write path is unaffected (it has noonWriteat all).SqlExecutorconsolidation where zero test changes was the whole point.Docs (README, spec.md):
record-adapter-sqlite, repositionrecord-adapter-sqljsas browser-only.record-adapter-sqlite(whose WAL journaling actually makes most of it moot) and the still-plannedadapter-json, not sqljs, which no longer touches a file at all.StackTokenStore/NativeTokenStoreinstead of the old inlineSQLiteAdaptertoken methods.Test plan
pnpm build/pnpm typecheck/pnpm lint/pnpm format:check— full monorepo, cleanpnpm test— full monorepo, 567 tests passing, no regressionsadapter-local's existing 17 tests pass unmodified against the new native-backed implementation, confirming the "no API surface change" promise; added 3 new tests (lazy token-store file creation, anddeleteUnreferencedAttachmentRecordsdelegation)record-adapter-sqljs's test suite rewritten (77 tests) for the new bytes/persist-callback API: in-memory-only operation, persist-callback invocation on every write, open-from-previously-persisted-bytes roundtrip, re-persisting after reopening, plus all the existing CRUD/query/FTS/association/version/FK-enforcement coverage carried over unchanged in behaviorCloses #46.
https://claude.ai/code/session_01RRLiGUZC344E3pgNEGAe5W
Generated by Claude Code