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
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
---
|
||||
status: draft
|
||||
last_updated: 2026-05-31
|
||||
last_updated: 2026-06-01
|
||||
---
|
||||
|
||||
# SQLite Host
|
||||
|
||||
The SQLite database host for `@alkdev/storage`. Uses Drizzle ORM with Honker
|
||||
for database operations, pub/sub, event streams, and task queues. TypeBox
|
||||
schemas are auto-generated from Drizzle table definitions via `@alkdev/drizzlebox`.
|
||||
schemas are generated from Drizzle table definitions via `src/sqlite/utils/`
|
||||
(folded from `@alkdev/dbtype`/`@alkdev/drizzlebox`, ADR-046).
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -18,11 +19,13 @@ The SQLite host provides:
|
||||
2. **Identity tables** — accounts, organizations, organization_members, api_keys,
|
||||
audit_logs for multi-tenant authentication and authorization (ADR-041)
|
||||
3. **Drizzle relations** for the relational query API
|
||||
4. **TypeBox schemas** auto-generated from Drizzle tables (select/insert
|
||||
validation) via `@alkdev/drizzlebox`
|
||||
4. **TypeBox schemas** generated from Drizzle tables (select/insert
|
||||
validation) via `src/sqlite/utils/` (folded from @alkdev/drizzlebox, ADR-046)
|
||||
5. **Drizzle-Honker adapter** — thin session adapter for Honker integration
|
||||
(ADR-044)
|
||||
6. **Client factories** — `createSystemDatabase(client)` and
|
||||
(ADR-044, POC validated)
|
||||
6. **HonkerEventTarget** — pubsub `TypedEventTarget` on Honker primitives
|
||||
(ADR-047, POC validated)
|
||||
7. **Client factories** — `createSystemDatabase(client)` and
|
||||
`createTenantDatabase(client)` for the system/tenant DB model (ADR-040)
|
||||
|
||||
## Package Structure
|
||||
@@ -47,10 +50,17 @@ src/sqlite/
|
||||
│ │ ├── edges.ts # edges table + select/insert schemas
|
||||
│ │ └── index.ts # barrel re-export
|
||||
│ └── index.ts # barrel re-export
|
||||
├── relations.ts # Drizzle relational mappings
|
||||
├── utils/ # folded from @alkdev/dbtype Phase 0 (ADR-046)
|
||||
│ ├── schema.ts # createSelectSchema, createInsertSchema, createUpdateSchema
|
||||
│ ├── column.ts # Column→TypeBox mappings (SQLite-only dispatch)
|
||||
│ ├── types.ts # Public + internal TypeScript interfaces
|
||||
│ ├── constants.ts # Integer range constants
|
||||
│ └── utils.ts # isColumnType, isWithEnum, type helpers
|
||||
├── relations.ts # Drizzle relational mappings
|
||||
├── adapter.ts # Drizzle-Honker session adapter
|
||||
├── schema.ts # re-exports all tables + relations
|
||||
└── client.ts # createSystemDatabase(), createTenantDatabase()
|
||||
├── event-target.ts # HonkerEventTarget (pubsub TypedEventTarget on Honker)
|
||||
├── schema.ts # re-exports all tables + relations
|
||||
└── client.ts # createSystemDatabase(), createTenantDatabase()
|
||||
```
|
||||
|
||||
## Common Columns
|
||||
@@ -339,8 +349,11 @@ db.transaction((tx) => {
|
||||
| [041](decisions/041-identity-tables-in-storage.md) | Identity tables in storage | accounts, organizations, api_keys, audit_logs |
|
||||
| [042](decisions/042-scoping-columns-on-graphs.md) | Scoping columns on graphs | `ownerId`, `projectId` on `graphs` table |
|
||||
| [043](decisions/043-graph-type-scope.md) | Graph type scope | `system` / `tenant` / `user` scope on `graph_types` |
|
||||
| [044](decisions/044-drizzle-honker-adapter.md) | Drizzle-Honker adapter | ~100-line session adapter |
|
||||
| [044](decisions/044-drizzle-honker-adapter.md) | Drizzle-Honker adapter | ~100-line session adapter, POC validated |
|
||||
| [045](decisions/045-org-members-authoritative-belongsto-derived.md) | org_members authoritative | SQL table is source of truth; BelongsToEdge is derived |
|
||||
| [046](decisions/046-fold-drizzlebox-as-utils.md) | Fold drizzlebox as utils | SQLite-only column mappings in src/sqlite/utils/ |
|
||||
| [047](decisions/047-honker-event-target.md) | HonkerEventTarget | pubsub TypedEventTarget on Honker |
|
||||
| [048](decisions/048-operation-specs-as-repo-surface.md) | OperationSpecs as repo surface | Table-defined operation contracts |
|
||||
| [019](decisions/019-json-text-for-schema-columns.md) | JSON text for schema columns | SQLite uses `text` with JSON mode |
|
||||
| [020](decisions/020-no-nodetypeid-on-nodes.md) | No nodeTypeId on nodes | Node type enforced at application layer |
|
||||
| [022](decisions/022-composite-fks-for-node-references.md) | Composite FKs for node refs | Edges reference `(graphId, sourceNodeKey)` |
|
||||
|
||||
Reference in New Issue
Block a user