feat(auth): migrate the audit hub to TenantId (PMS-139 sweep batch 6) #167
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/pms-139-sweep-hubs"
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 6 of the PMS-139 typed-tenant sweep: the first of the three cross-module hubs - the audit module. Migrating it is what lets the already-swept modules shed their transitional
tenant_id.get()unwraps.How
audit_writewriter now takestenant_id: TenantId. The transparent newtype binds as its innerUuid, so the INSERT body is unchanged.AuditServiceread/append methods takeTenantId:appendandlist_entity_historydirectly,listasOption<TenantId>(the query builder binds the unwrapped value transparently, so no body change). Audit routes derive scope viau.tenant().tenant_id.get()it passed at the audit call site. The codebase-widetenant_id.get()count falls 39 -> 5, and all 5 survivors are correct: thePaymentResponse/TenantUsageDTO fields and thetenantsupdateentity_idcarry a plainUuid;AuditCtx::systemstays aUuidcontext bag; the one remaining transitional unwrap is rmm'sTicketServicecall (clears when tickets is swept).TenantId::from_trusted(..), documented on theaudit_writedoc comment): the not-yet-sweptauthandticketsmodules, thetenantscreate path (a minted id), and theaudit_auth_eventhelper.TenantScoped::tenant(user)instead of the rawauth_state.tenant_id.AuditCtxdeliberately keeps itsOption<Uuid>field (it is the request-extractor context, tolerant of unauthenticated/system callers).Verification
cargo check --all-targets,cargo clippy --all-targets: clean.audit(4),audit_hooks(3),audit_list(1),auth(14),tickets(2),contacts(7),assets(4),projects(4),billing(3),recurring_invoicing(5).cargo test --doc:compile_failnewtype guard holds.Progress: 14 of ~17 modules migrated. Two hubs remain -
notifications(thedispatchhub) andtickets(theTicketServicehub). Sweeping those clears the last transitional.get()(rmm'sTicketServicecall).🤖 Generated with Claude Code