2.2 KiB
2.2 KiB
Tasks — foundation-fix-gap-4-db-split
- Rename
HostAdapters.db: LedgerDb→HostAdapters.ledgerDb: LedgerDb(host-private). - Add new optional
HostAdapters.db?: AdminDatabaseLike(consumer-facing). - Update host config Zod schema to validate the new shape.
- Update host constructor to pass
config.adapters.ledgerDbintoPluginLedgerandconfig.adapters.dbinto the request-pipeline options. - Add optional
db: AdminDatabaseLiketoRequestPipelineOptions. - Apply
createTenantScopedWrapper(admin, tenantCtx.id)per request in the pipeline driver when bothoptions.dbandtenantCtxare set; thread the result ontoRequestContext.db. Surfacenullotherwise. - Add
db: AdminDatabaseLike | nulltoPluginContext; adddb: TenantScopedDatabaseLike | nulltoRequestContext,JobContext,ConnectionContext. - Update
buildRequestContextsignature + helpers to thread the scoped db onto the constructed context. - Add
@suaveplan/api-db-adapterruntime dep to@suaveplan/api-host/package.json. - Atomically update every in-tree consumer:
api-hosttests (host.test.tsrenamedb → ledgerDb), E2E foundation-stack (server.ts). - Restore
createDbAdapter({ engine: "sqlite", url: ":memory:" })asadapters.dbin the E2E server; keepbun:sqliteraw handle onadapters.ledgerDb. Register an inlinebun:sqlite-backed engine factory. - Add
/api/db-pingroute infixture-plugin.tsexercisingctx.db?.execute+ctx.db?.querythrough the tenant-scoped wrapper. - Add E2E test
db adapter — ctx.db wired through tenant-scoped wrappertotests/foundation.spec.ts. - Add api-host unit tests: (a)
adapters.dbthreaded through toctx.dbwith rewriter-applied SQL; (b)ctx.db === nullwhenadapters.dbundefined; (c)ctx.db === nullwhen tenant resolver returns null. - Verify gate:
bunx turbo lint typecheck test build --filter=@suaveplan/api-host --filter=@suaveplan/api-types --filter=@suaveplan/api-db-adapter. - Verify E2E:
bun test:e2e11/11 green. - Fold deltas into canonical
openspec/specs/api-host/spec.mdandopenspec/specs/api-types/spec.md; move folder toopenspec/archive/2026-05-26-foundation-fix-gap-4-db-split/.