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,53 @@
# Tasks — foundation gap 5: configurable default tenant
## 1. Implementation
- [x] 1.1 Add `defaultTenant?: TenantContext | null` to
`RequestPipelineOptions` (`request-pipeline.types.ts`).
- [x] 1.2 Add `defaultTenant?: TenantContext | null` to `HostConfig`
(`host/host.types.ts`).
- [x] 1.3 Wire `config.defaultTenant ?? null` through
`host.ts` → `RequestPipeline` constructor.
- [x] 1.4 Replace hard-coded `{id: "public", slug: "public"}` injection
in `request-pipeline.ts` with config-aware logic.
- [x] 1.5 Widen `PipelineCapabilityResolver.forRequest`'s `tenant`
parameter to `TenantContext | null`.
- [x] 1.6 Update downstream pipeline call sites (`rateKey`, logger meta,
`buildRequestContext`, `succeed()`/`fail()` signatures) to tolerate
`tenantCtx === null`.
## 2. Tests
- [x] 2.1 Replace the legacy "public stub" test with a "null tenant by
default" assertion.
- [x] 2.2 Add a test asserting an explicit `defaultTenant` is propagated
verbatim to `ctx.tenant` / `ctx.tenantId` / `PipelineResult.tenantId`.
- [x] 2.3 Add a test asserting auth-required routes still 400 on a
resolver miss regardless of `defaultTenant`.
## 3. Migration
- [x] 3.1 Migrate the foundation-stack E2E (`e2e/foundation-stack/src/server.ts`)
to opt into the legacy fallback (`defaultTenant: { id: "public", ... }`)
so the existing `tenantId === "public"` assertion remains green.
## 4. Docs
- [x] 4.1 Document the new behaviour in
`packages/api-stack/api/api-host/src/host/host.md`.
- [x] 4.2 Document the per-step interaction in
`request-pipeline.types.ts` (`RequestPipelineOptions.defaultTenant`).
## 5. Spec
- [x] 5.1 Author MODIFIED Requirements delta under
`specs/api-host/spec.md`.
- [x] 5.2 Fold delta into `openspec/specs/api-host/spec.md`.
- [x] 5.3 Move change folder to `openspec/archive/2026-05-26-foundation-fix-gap-5-default-tenant/`.
## 6. Gate
- [x] 6.1 `bunx turbo lint typecheck test build --filter=@suaveplan/api-host` green.
- [x] 6.2 `bunx turbo test:coverage --filter=@suaveplan/api-host` —
`request-pipeline.ts` reports 100% line + branch coverage; touched
lines in `host.ts` are exercised by existing `createHost(...)` tests.