@startuml
title Email Admin Runtime Dispatch Tenant Resolution (After)

skinparam backgroundColor #FFFFFF
skinparam defaultFontColor #000000
skinparam ArrowColor #000000
skinparam ParticipantBorderColor #000000
skinparam ParticipantBackgroundColor #D9F2D9
skinparam NoteBackgroundColor #E9F7FF
skinparam NoteBorderColor #000000

actor "Tenant Client" as Client
participant "dispatch_auth_request" as Dispatch
participant "TenantRuntimeRegistry" as Registry
participant "Tenant Auth Runtime\n(AdminPlugin-enabled)" as Runtime

Client -> Dispatch: /admin/email/list
Dispatch -> Registry: resolve_tenant_from_headers(...)
alt invalid / unknown tenant
  Registry --> Dispatch: error
  Dispatch --> Client: 400 JSON error
else known tenant
  Registry --> Dispatch: tenant id
  Dispatch -> Runtime: dispatch_auth_axum_request(...)
  Runtime --> Dispatch: auth response
  Dispatch --> Client: response + x-athena-tenant header
end

note right of Dispatch
Test coverage now verifies known-tenant routing,\nheader fallback resolution, and invalid/unknown\nheader failure paths.
end note

@enduml
