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:
33
AGENTS.md
33
AGENTS.md
@@ -28,10 +28,13 @@ infrastructure from org-scoped graph data.
|
||||
│ │ └── mod.ts # Re-exports all graphs exports
|
||||
│ └── sqlite/ # SQLite host (drizzle-orm + honker-node)
|
||||
│ ├── tables/
|
||||
│ │ ├── identity/ # accounts, organizations, org_members, api_keys, audit_logs
|
||||
│ │ ├── common.ts # shared column definitions
|
||||
│ │ ├── identity/ # accounts, organizations, org_members, api_keys, audit_logs
|
||||
│ │ └── metagraph/ # graph_types, node_types, edge_types, graphs, nodes, edges
|
||||
│ ├── utils/ # createSelectSchema, createInsertSchema, column mappings (ADR-046)
|
||||
│ ├── relations.ts # Drizzle relations
|
||||
│ ├── adapter.ts # Drizzle-Honker session adapter
|
||||
│ ├── event-target.ts # HonkerEventTarget (pubsub TypedEventTarget on Honker)
|
||||
│ ├── schema.ts # Re-exports
|
||||
│ └── client.ts # createSystemDatabase(), createTenantDatabase()
|
||||
└── test/
|
||||
@@ -42,7 +45,7 @@ infrastructure from org-scoped graph data.
|
||||
|
||||
- `@alkdev/storage` → Metagraph Module, graph type definitions (zero deps)
|
||||
- `@alkdev/storage/sqlite` → SQLite tables (metagraph + identity), relations,
|
||||
client, Honker adapter (drizzle-orm + honker-node)
|
||||
client, adapter, event-target, utils (drizzle-orm + honker-node, peer: @alkdev/pubsub)
|
||||
|
||||
PostgreSQL has been removed (ADR-038). SQLite via Honker is the sole database host.
|
||||
|
||||
@@ -60,12 +63,20 @@ PostgreSQL has been removed (ADR-038). SQLite via Honker is the sole database ho
|
||||
4. **Injectable clients**: `createSystemDatabase(client)` and
|
||||
`createTenantDatabase(client)` take pre-created Honker clients, not
|
||||
env vars. Module-level side effects are forbidden.
|
||||
5. **Dependencies**: `@alkdev/typebox` and `@alkdev/drizzlebox` are npm deps
|
||||
(not yet on JSR). This works fine — JSR handles npm dependencies natively.
|
||||
5. **Dependencies**: `@alkdev/typebox` is an npm dep (not yet on JSR).
|
||||
`@alkdev/pubsub` is a peer dep (for `TypedEventTarget` type). The
|
||||
`@alkdev/drizzlebox` external dep has been folded into `src/sqlite/utils/`
|
||||
(ADR-046).
|
||||
6. **SQLite-only via Honker**: No PostgreSQL. Honker provides DB + pub/sub +
|
||||
queues in a single SQLite file (ADR-038, ADR-039).
|
||||
7. **System/tenant DB split**: Identity tables in `system.db`, graph data in
|
||||
`tenant-{orgId}.db` (ADR-040).
|
||||
8. **OperationSpecs as repository surface**: Storage outputs `OperationSpec[]`
|
||||
from table definitions. No hand-written CRUD. The consumer (hub/spoke)
|
||||
registers handlers (ADR-048).
|
||||
9. **HonkerEventTarget**: Bridges pubsub `TypedEventTarget` to Honker
|
||||
`notify`/`listen` and `stream`/`subscribe`. Enables single-node pub/sub
|
||||
without Redis. Transactional outbox semantics confirmed via POC (ADR-047).
|
||||
|
||||
## Commands
|
||||
|
||||
@@ -91,7 +102,7 @@ The codebase has diverged significantly from the originals:
|
||||
Modules to DB row values
|
||||
- Crypto utility ported from `@alkdev/hub/src/crypto/mod.ts` with `EncryptedDataSchema`
|
||||
as a TypeBox schema
|
||||
- `@sinclair/typebox` → `@alkdev/typebox`, `drizzle-typebox` → `@alkdev/drizzlebox`
|
||||
- `@sinclair/typebox` → `@alkdev/typebox`, `drizzle-typebox` → `@alkdev/drizzlebox` → folded into `src/sqlite/utils/` (ADR-046)
|
||||
- TypeScript enums replaced with `as const` objects (`GRAPH_STATUS`, `ACTOR_TYPE`)
|
||||
- `Type.Unknown()` used for unvalidated fields (not `Type.Any()`)
|
||||
- Injectable client pattern (`createSqliteDatabase(client)` takes a pre-created client)
|
||||
@@ -104,7 +115,7 @@ The codebase has diverged significantly from the originals:
|
||||
- Entry points are `mod.ts` files that re-export from subdirectories
|
||||
- TypeBox schemas are named with PascalCase (`NodeType`, `GraphConfig`)
|
||||
- Drizzle table objects are named with camelCase (`graphTypes`, `nodeTypes`)
|
||||
- Schema objects from drizzlebox are named with PascalCase (`InsertGraph`,
|
||||
- Schema objects from utils are named with PascalCase (`InsertGraph`,
|
||||
`SelectGraph`)
|
||||
- Enum constants use `SCREAMING_SNAKE_CASE` objects (`GRAPH_STATUS`,
|
||||
`ACTOR_TYPE`)
|
||||
@@ -129,11 +140,15 @@ are not yet implemented.
|
||||
|
||||
## What's Not Done Yet
|
||||
|
||||
- Drizzle-Honker session adapter (`src/sqlite/adapter.ts`)
|
||||
- Fold dbtype Phase 0 → `src/sqlite/utils/` (ADR-046, import path changes)
|
||||
- Drizzle-Honker session adapter (`src/sqlite/adapter.ts`, POC validated)
|
||||
- HonkerEventTarget (`src/sqlite/event-target.ts`, POC validated, ADR-047)
|
||||
- Identity tables in `src/sqlite/tables/identity/` (accounts, organizations, etc.)
|
||||
- Scoping columns on `graphs` table (`ownerId`, `projectId`)
|
||||
- Graph type `scope` column on `graph_types` table
|
||||
- Remove `actors` table and `src/pg/` directory
|
||||
- Split client factory into `createSystemDatabase()` / `createTenantDatabase()`
|
||||
- Repository/CRUD layer (typed query functions beyond table definitions)
|
||||
- Update client factory to `createSystemDatabase()` / `createTenantDatabase()` (accept Honker client)
|
||||
- Table restructure into subdirectories (metagraph/, identity/)
|
||||
- OperationSpec generation from tables (ADR-048)
|
||||
- ACL graph type (ADR-034)
|
||||
- JSR publication setup (need to create scope/package on jsr.io first)
|
||||
|
||||
Reference in New Issue
Block a user