Initial Commit

This commit is contained in:
2026-05-27 23:29:53 +01:00
commit fbc70f96e6
10000 changed files with 1102152 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
# Tasks — foundation-fix-gap-4-db-split
- [x] Rename `HostAdapters.db: LedgerDb` → `HostAdapters.ledgerDb: LedgerDb` (host-private).
- [x] Add new optional `HostAdapters.db?: AdminDatabaseLike` (consumer-facing).
- [x] Update host config Zod schema to validate the new shape.
- [x] Update host constructor to pass `config.adapters.ledgerDb` into `PluginLedger` and `config.adapters.db` into the request-pipeline options.
- [x] Add optional `db: AdminDatabaseLike` to `RequestPipelineOptions`.
- [x] Apply `createTenantScopedWrapper(admin, tenantCtx.id)` per request in the pipeline driver when both `options.db` and `tenantCtx` are set; thread the result onto `RequestContext.db`. Surface `null` otherwise.
- [x] Add `db: AdminDatabaseLike | null` to `PluginContext`; add `db: TenantScopedDatabaseLike | null` to `RequestContext`, `JobContext`, `ConnectionContext`.
- [x] Update `buildRequestContext` signature + helpers to thread the scoped db onto the constructed context.
- [x] Add `@suaveplan/api-db-adapter` runtime dep to `@suaveplan/api-host/package.json`.
- [x] Atomically update every in-tree consumer: `api-host` tests (`host.test.ts` rename `db → ledgerDb`), E2E foundation-stack (`server.ts`).
- [x] Restore `createDbAdapter({ engine: "sqlite", url: ":memory:" })` as `adapters.db` in the E2E server; keep `bun:sqlite` raw handle on `adapters.ledgerDb`. Register an inline `bun:sqlite`-backed engine factory.
- [x] Add `/api/db-ping` route in `fixture-plugin.ts` exercising `ctx.db?.execute` + `ctx.db?.query` through the tenant-scoped wrapper.
- [x] Add E2E test `db adapter — ctx.db wired through tenant-scoped wrapper` to `tests/foundation.spec.ts`.
- [x] Add api-host unit tests: (a) `adapters.db` threaded through to `ctx.db` with rewriter-applied SQL; (b) `ctx.db === null` when `adapters.db` undefined; (c) `ctx.db === null` when tenant resolver returns null.
- [x] Verify gate: `bunx turbo lint typecheck test build --filter=@suaveplan/api-host --filter=@suaveplan/api-types --filter=@suaveplan/api-db-adapter`.
- [x] Verify E2E: `bun test:e2e` 11/11 green.
- [x] Fold deltas into canonical `openspec/specs/api-host/spec.md` and `openspec/specs/api-types/spec.md`; move folder to `openspec/archive/2026-05-26-foundation-fix-gap-4-db-split/`.