feat(auth): migrate knowledge_base + tenants + settings to TenantId (PMS-139 sweep batch 4) #163
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/pms-139-sweep-kb-tenants-settings"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Batch 4 of the PMS-139 typed-tenant sweep: migrate
knowledge_base,tenants, andsettingsfrom bareUuidtenant ids to theTenantIdnewtype.How
u.tenant()(TenantScoped, now imported in eachroutes.rs); every public service method takestenant_id: TenantId. Transparent newtype -> SQL binds and%tenant_idtracing unchanged.user.tenant_idvs pathUuidcomparison and the post-guard service call wraps the path id withTenantId::from_trusted(...)(5 tenant-service + 2 delegated settings-service sites).create_tenantmints a new id andcopy_default_configseeds it from the hardcoded default tenant; neither is a claim, so the seed helper keepsUuidandcreate_tenantbridges its minted id throughfrom_trustedat the singleget_tenantreadback. The twoaudit_writesites unwrap withtenant_id.get()transitionally.settings::is_module_enabledfeeds theRequireModuleEnabledgate inauth/middleware.rs; that caller now derives the tenant viaTenantScoped::tenant(&user).knowledge_basemethod with its verified contact-JWT tenant; bridged throughfrom_trusted+ SAFETY note, since portal runs on contact sessions (notCurrentUser) and gets its own pass later.tests/knowledge_base.rswraps its literal tenant id withfrom_trusted.Verification
cargo check --all-targets,cargo clippy --all-targets: clean.cargo test --test knowledge_base(10),--test tenants(1),--test notifications_backfill(5): pass.cargo test --doc:compile_failnewtype guard holds (2 pass / 3 ignored).tests/settings.rs: 8 pass, 2 fail (disabled_module_returns_404_on_route_access,enabled_module_response_unchanged). Both are the pre-existing billing-404 baseline failures - they reproduce identically on cleanmain(verified viagit stash+ checkout), unrelated to this change.Progress: 11 of ~17 modules migrated. ~6 remain; the
audit_write/notifications::dispatch/TicketServicehubs are swept last (flipping them removes every transitional.get()).🤖 Generated with Claude Code