AshReplicant. Resource. Verifiers. ValidateTenantSource
(AshReplicant v0.2.0)
Copy Markdown
View Source
Compile-verifier (surfaced as a Spark diagnostic; build-blocking under
--warnings-as-errors): a resource that declares non-global Ash multitenancy
must declare a replicant tenant source — tenant_attribute or tenant_mfa.
This is the CONVERSE of ValidateMultitenancy (which checks the shape of a
declared discriminator). The sink resolves the per-row tenant from the source
record via one of those keys; with neither,
AshReplicant.Resolver.resolve_tenant/2 yields {:ok, nil} and the mirror write
is attempted with tenant: nil. For a non-global? multitenant resource Ash then
raises TenantRequired at RUNTIME — so it is fail-closed, never a cross-tenant
leak, but the pipeline halts on every row of that resource. This gate moves the
failure to COMPILE time, matching the project's fail-closed-at-compile-time posture
(ValidateMultitenancy, ValidateSensitive).
Exempt: a global? resource (tenant is optional) and a non-multitenant resource.
The message is value-free — it names schema structure only, never a row value.