Repository navigation
docs(examples): TenantRegistry DB-driven example + concurrent-recheck CI tests - #1358
Merged
Merged
Conversation
… CI tests (#1346) Add worked example for `createTenantRegistry` covering the patterns that multi-tenant SaaS adopters need: DB-seeded startup, runtime register/unregister, zero-traffic-gap JWKS recheck, and config-update semantics (unregister+re-register). Also fixes the stale `MULTI-TENANT.md` skill doc that showed a non-existent `resolveTenant`/`buildPlatform` callback constructor — any agent reading the skill would have generated code that fails to compile on line 1. Refs #1346 https://claude.ai/code/session_018eA64njEkERwFaBmtAyQUV
CI typecheck-skill-examples failed: top-level await in CommonJS module + missing identifiers. Wrap each example block in an async function and inline the loadTenant call so referenced identifiers stay within the existing baseline. Tighten baseline to drop 5 errors that no longer reproduce after the previous skill rewrite. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
bokelley
force-pushed
the
claude/issue-1346-tenant-registry-db-example
branch
from
May 2, 2026 21:53
c5afaa1 to
220bcda
Compare
1 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1346
Adds a worked example for
createTenantRegistrycovering the patterns multi-tenant SaaS adopters need but that the existing static example (decisioning-platform-multi-tenant.ts) doesn't cover: DB-driven startup, runtime register/unregister without restart, zero-gap JWKS recheck, and the update-pattern traffic gap. Also fixes a stale skill doc that showed a non-existent constructor API.What changed
examples/decisioning-platform-multi-tenant-db.ts(new) — exports:buildDbMultiTenantRegistry()— seeds from async DB loader; compatible with pg, Prisma, fetch, etc.adminRegisterTenant()— add tenant without restartadminRecheckTenant()— zero-traffic-gap JWKS recheck after key rotationadminUpdateTenant()— unregister+re-register for platform-config changes (brief 503 gap documented; concurrent-write serialization requirement called out)adminUnregisterTenant()— immediate removal; no drain periodtest/examples/decisioning-platform-multi-tenant-db.test.js(new) — 6-assertion CI test:--strict --noUncheckedIndexedAccess --exactOptionalPropertyTypes)healthyviaawaitFirstValidationPromise.all([recheck×3])asserts≤3validator calls (dedup invariant)resolveByHostreturns null immediately — no drainskills/build-decisioning-platform/advanced/MULTI-TENANT.md(fixed) — previous version showed aresolveTenant/buildPlatformcallback constructor that doesn't exist in the realcreateTenantRegistryAPI. Any agent reading the skill would have generated non-compiling code on line 1. Updated to show correctregister()call pattern, health state table, and link to the new worked example.tsconfig.examples.json— new example added to include list..changeset/tenant-registry-db-example.md— patch changeset.Partial scope note
The issue's acceptance criterion "callout on
docs/migration-6.6-to-6.7.md" (tracked in #1344) is not shipped here — that doc doesn't exist yet. The example'sadminUpdateTenantJSDoc carries a// Migrating from a hand-rolled tenant map? See docs/migration-6.6-to-6.7.md (#1344)placeholder. The final PR in the #1344 sequence should carryCloses #1346.What was tested
npm run typecheck:examples— passesNODE_ENV=test node --test test/examples/decisioning-platform-multi-tenant-db.test.js— 6/6 passnpm run format:check— clean (ran prettier)format + typecheck + build:lib) — passedPre-PR review
≤2→≤3) fixed; concurrent-write hazard inadminUpdateTenantdocumented;minimalPlatform()stub aligned withbuildPlatformstubas anycast comment moved adjacent to cast site; migration TODO placed onadminUpdateTenantJSDocNit noted (not fixed):
register()return type isPromise<TenantStatus> | voidunion — theas Promise<TenantStatus>cast inregisterRowis a necessary workaround until the interface gains overloaded signatures forawaitFirstValidation: true. Tracked as a follow-up DX improvement.Session: https://claude.ai/code/session_018eA64njEkERwFaBmtAyQUV
Generated by Claude Code