Skip to content

Commit 787749d

Browse files
claudebokelley
authored andcommitted
feat(server): add TenantRegistry with per-tenant health tracking
Closes #619. Adds TenantRegistry — a higher-level multi-tenant primitive that provides JS createTenantRegistry parity for Python deployments. Adopters pre-build per-tenant DecisioningPlatform instances and register them; the registry tracks health state (pending/healthy/unverified/disabled) and surfaces a synchronous resolve_by_host for the hot request path. Key design choices over the JS surface: - resolve_by_host is sync (in-memory dict) rather than async — Python owns the mapping directly via register()/unregister(), no external resolver. - auto_validate dropped; validator presence is the opt-in (None = principal- token mode, always healthy). - Per-tenant asyncio.Lock prevents TOCTOU on concurrent recheck() calls. - unregister()-during-recheck race is guarded: post-validator writes check whether the tenant was removed while the validator was awaited. Exports added to adcp.server: TenantRegistry, TenantResolution, TenantHealthState, TenantValidator. Tested with pytest: 25 tests covering lifecycle, state machine, host normalization, sync/async validators, and concurrency correctness. https://claude.ai/code/session_019ucMgF6YS9X5bygYUADztx
1 parent 14d294c commit 787749d

3 files changed

Lines changed: 837 additions & 0 deletions

File tree

src/adcp/server/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ async def get_products(params, context=None):
141141
serve,
142142
)
143143
from adcp.server.sponsored_intelligence import SponsoredIntelligenceHandler
144+
from adcp.server.tenant_registry import (
145+
TenantHealthState,
146+
TenantRegistry,
147+
TenantResolution,
148+
TenantValidator,
149+
)
144150
from adcp.server.tenant_router import (
145151
CallableSubdomainTenantRouter,
146152
InMemorySubdomainTenantRouter,
@@ -211,6 +217,11 @@ async def get_products(params, context=None):
211217
# Idempotency middleware (AdCP #2315 seller side)
212218
"IdempotencyStore",
213219
"MemoryBackend",
220+
# Multi-tenant registry with health tracking
221+
"TenantHealthState",
222+
"TenantRegistry",
223+
"TenantResolution",
224+
"TenantValidator",
214225
# Subdomain tenant routing
215226
"CallableSubdomainTenantRouter",
216227
"InMemorySubdomainTenantRouter",

0 commit comments

Comments
 (0)