Expand description
The precedence rule for a row’s own audience column, and the coalesced_audience_column/
audience_column_mismatch SQL fragments shared by the writer and both enforcement prongs.
The precedence rule every audience-carrying reader follows, and the two SQL fragments
shared by the writer (lakehouse::blocks_view) and both enforcement prongs
(lakehouse::audience_guard, lakehouse::ownership_rewrite) – and by metadata.rs, the
JIT / per-process path.
A row’s own audience column is the authoritative label for that row. It is the
authenticated fact recorded at the moment the row was written (processes.audience,
streams.audience, blocks.audience). A NULL column means the row predates this stage
and resolves to the deployment’s MICROMEGAS_DEFAULT_AUDIENCE. No row’s audience is ever
derived from another row’s for any row that carries the column; a reader with no
audience column of its own still resolves through the owning process/stream row.
check_process_audience_conflict (and its stream-side mirror
check_stream_audience_conflict) still governs only the processes (or streams) row it
re-registers.
Constants§
- DEFAULT_
AUDIENCE - The audience assigned to anything that arrives without one. Matches
micromegas_auth::policy::PUBLIC_AUDIENCE, kept as a local copy for the same crate-boundary reasondefault_audience_from_envduplicates the charset check.
Functions§
- audience_
column_ mismatch - True when
left_qualifier.audienceandright_qualifier.audienceare both set but disagree. NULL-tolerant: a NULLaudienceon either side does not count as a mismatch, so a legacy row on either side of the join passes through cleanly. Both qualifiers must be trusted table names/aliases, never user input. - coalesced_
audience_ column COALESCE(<qualifier>.audience, $<param>)– a row’s own stamp, or the deployment’sMICROMEGAS_DEFAULT_AUDIENCEfor a row written before this stage (a NULL column).qualifieris inlined as SQL text, so it must be a trusted table name or alias, never user input; the default stays a bind parameter, since it is operator-supplied config.- default_
audience_ from_ env - Resolves
MICROMEGAS_DEFAULT_AUDIENCE– the audience a never-stamped row is read as – defaulting toDEFAULT_AUDIENCEwhen unset. Malformed ⇒Err, so a typo fails startup rather than silently relabelling every legacy row.