Files
storage/docs/architecture/decisions/046-fold-drizzlebox-as-utils.md
glm-5.1 412ad98f11 Pivot: fold drizzlebox as utils, HonkerEventTarget, OperationSpecs as repo surface
- Update architecture docs to reflect pivot from @libsql/client to Honker
- Fold @alkdev/drizzlebox Phase 0 into src/sqlite/utils/ (ADR-046)
- Add HonkerEventTarget adapter for pubsub TypedEventTarget (ADR-047)
- Replace hand-written CRUD with OperationSpec generation (ADR-048)
- Resolved OQ-26: Honker replaces Redis for single-node pub/sub (POC validated)
- Updated OQ-17, OQ-18, OQ-19 for OperationSpec repository surface
- Added OQ-30 (composite event target), OQ-31 (consumer naming), OQ-32 (Drizzle Kit)
- POC results: adapter buildable, same-process pub/sub works, transactional
  outbox semantics confirmed, concurrent listeners/streams work
- Research doc at docs/research/pivot-honker-sqlite-adapter.md
2026-06-01 16:31:40 +00:00

2.4 KiB

status, date, supersedes
status date supersedes
accepted 2026-06-01 ADR-005, ADR-018

ADR-046: Fold @alkdev/drizzlebox as src/sqlite/utils/

Context

@alkdev/drizzlebox (a fork of drizzle-typebox adapted for @alkdev/typebox) provides createSelectSchema and createInsertSchema functions that derive TypeBox validation schemas from Drizzle table definitions. It is consumed as an external npm dependency by all SQLite table files in @alkdev/storage.

The parent project @alkdev/dbtype also planned a Phase 1 (UJSX→HostConfig →Drizzle pipeline) that was never implemented. With SQLite as the sole database target (ADR-038), the multi-dialect column mappings in dbtype (PG, MySQL, SingleStore) are dead weight for storage.

ADR-018 deferred dbtype integration to post-v1. But the fold of just the Phase 0 subset (column→TypeBox mappings + schema generation) is a straightforward import path change with no behavioral difference.

Decision

Fold the SQLite-only subset of @alkdev/dbtype Phase 0 into src/sqlite/utils/:

Source (dbtype) Target (storage) Changes
schema.ts utils/schema.ts Remove PgEnum handling. Keep createSelectSchema, createInsertSchema, createUpdateSchema.
column.ts utils/column.ts Strip PG, MySQL, SingleStore branches. Keep SQLiteInteger, SQLiteReal, SQLiteText + generic dataType dispatch.
schema.types.ts + schema.types.internal.ts + column.types.ts utils/types.ts Merged. Remove PgEnum overloads.
constants.ts utils/constants.ts Keep as-is.
utils.ts utils/utils.ts Remove PgEnum alias. Keep isColumnType, isWithEnum, JsonSchema, BufferSchema.

All table files change their import from @alkdev/drizzlebox to ../utils/schema.ts.

Consequences

  • No external drizzlebox dependency — one fewer npm package in the dependency graph.
  • SQLite-only column mappings — dead multi-dialect code removed. If a new database host is added later, mappings would need to be re-added.
  • Same API surfacecreateSelectSchema, createInsertSchema, createUpdateSchema produce the same TypeBox schemas.
  • Co-located with tables — utility code lives next to the tables it derives schemas from. Easier to maintain.
  • dbtype Phase 1 (UJSX→HostConfig) not affected — that remains a separate architectural concern, could live in storage or as its own package when built.