2.2 KiB
2.2 KiB
Tasks — foundation gap 5: configurable default tenant
1. Implementation
- 1.1 Add
defaultTenant?: TenantContext | nulltoRequestPipelineOptions(request-pipeline.types.ts). - 1.2 Add
defaultTenant?: TenantContext | nulltoHostConfig(host/host.types.ts). - 1.3 Wire
config.defaultTenant ?? nullthroughhost.ts→RequestPipelineconstructor. - 1.4 Replace hard-coded
{id: "public", slug: "public"}injection inrequest-pipeline.tswith config-aware logic. - 1.5 Widen
PipelineCapabilityResolver.forRequest'stenantparameter toTenantContext | null. - 1.6 Update downstream pipeline call sites (
rateKey, logger meta,buildRequestContext,succeed()/fail()signatures) to toleratetenantCtx === null.
2. Tests
- 2.1 Replace the legacy "public stub" test with a "null tenant by default" assertion.
- 2.2 Add a test asserting an explicit
defaultTenantis propagated verbatim toctx.tenant/ctx.tenantId/PipelineResult.tenantId. - 2.3 Add a test asserting auth-required routes still 400 on a
resolver miss regardless of
defaultTenant.
3. Migration
- 3.1 Migrate the foundation-stack E2E (
e2e/foundation-stack/src/server.ts) to opt into the legacy fallback (defaultTenant: { id: "public", ... }) so the existingtenantId === "public"assertion remains green.
4. Docs
- 4.1 Document the new behaviour in
packages/api-stack/api/api-host/src/host/host.md. - 4.2 Document the per-step interaction in
request-pipeline.types.ts(RequestPipelineOptions.defaultTenant).
5. Spec
- 5.1 Author MODIFIED Requirements delta under
specs/api-host/spec.md. - 5.2 Fold delta into
openspec/specs/api-host/spec.md. - 5.3 Move change folder to
openspec/archive/2026-05-26-foundation-fix-gap-5-default-tenant/.
6. Gate
- 6.1
bunx turbo lint typecheck test build --filter=@suaveplan/api-hostgreen. - 6.2
bunx turbo test:coverage --filter=@suaveplan/api-host—request-pipeline.tsreports 100% line + branch coverage; touched lines inhost.tsare exercised by existingcreateHost(...)tests.