GH-3536: Conjoined EF Core contexts advertise a distinct DbContextUsage descriptor - #3545
Merged
Merged
Conversation
…ge descriptor Residual from the conjoined EF Core multi-tenancy epic (#3465 / #3464 Phase 3): a conjoined context looked identical to a plain single-DB context in its DbContextUsage descriptor, so CritterWatch's descriptor-driven UI had nothing to gate/badge on. The tenancy-style discriminator switched on the IDbContextBuilder type name and only knew the by-data-source / by-connection-string builders; ConjoinedDbContextBuilder<T> fell through to "Single". - Detect ConjoinedDbContextBuilder<T> and advertise tenancy style "Conjoined" - With one shared-database descriptor + a non-"Single" style, the existing cardinality logic now reports DatabaseCardinality.DynamicMultiple, as the #3464 design promised - Surface the active tenant ids from the wolverine_tenants registry (via the already-registered ConjoinedTenantSource<T>) onto that single shared DatabaseDescriptor.TenantIds. Best-effort: a registry read failure degrades to an empty tenant list rather than nulling the whole snapshot Compliance battery in EfCoreTests.MultiTenancy/ConjoinedTenancy asserts the "Conjoined" style, DynamicMultiple cardinality, and registry tenant ids on the descriptor for both PostgreSQL and SqlServer. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FKAxzuZ36VP6UPcTQf3MUs
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.
Closes #3536
Residual from the conjoined EF Core multi-tenancy epic (#3465 / #3464 Phase 3). As shipped in 6.21.0 / 6.22.0-alpha.1, a conjoined context looked identical to a plain single-DB context in its
DbContextUsagedescriptor, so CritterWatch's descriptor-driven UI (JasperFx/CritterWatch#720) had nothing to gate or badge on. Tenant management already lit up (via theIDynamicTenantSource<string>registration), but the UI gating side was blind to conjoined.Root cause
TenantedDbContextUsageSource<T>'s tenancy-style discriminator switched on theIDbContextBuilder<T>implementation type name and only knewTenantedDbContextBuilderByDbDataSource/TenantedDbContextBuilderByConnectionString;ConjoinedDbContextBuilder<T>fell through to"Single", and its singleFindAllAsync()context carried no tenant ids.Fix
ConjoinedDbContextBuilder<T>explicitly and advertise tenancy style"Conjoined"."Single"style, the existing cardinality logic now reportsDatabaseCardinality.DynamicMultiple— exactly the shape the Conjoined EF Core multi-tenancy, Phase 3: wolverine_tenants registry + IDynamicTenantSource for CritterWatch #3464 design promised ("DynamicMultipleplus tenant ids on its singleDatabaseDescriptor"), without fabricating N per-tenant database entries.wolverine_tenantsregistry — via the already-registeredConjoinedTenantSource<T>— onto that single sharedDatabaseDescriptor.TenantIds. Isolated in its own try/catch so a registry read hiccup degrades to an empty tenant list rather than nulling the whole snapshot (matching the best-effort contract of the surrounding code).Design note
Per the issue's acceptance criteria ("settle the exact shape with the CritterWatch#720 consumer, since conjoined is one physical database with a dynamic tenant list, which neither existing cardinality models cleanly"), this uses both signals: a
"Conjoined"tenancy-style string (unambiguous discriminator) andDynamicMultiplecardinality with the tenant ids on the one shared descriptor. Happy to adjust the exact enum/string if the CritterWatch consumer prefers a different split.Tests
EfCoreTests.MultiTenancy/ConjoinedTenancy/ConjoinedDescriptorCompliance.csasserts, for both PostgreSQL and SqlServer:"Conjoined"(not"Single"), cardinality isDynamicMultiple, and there is exactly one shared-database descriptor;MainDatabase.TenantIds.All 4 pass locally against the Postgres/SqlServer test containers.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FKAxzuZ36VP6UPcTQf3MUs