Skip to main content

Module audience

Module audience 

Source
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 reason default_audience_from_env duplicates the charset check.

Functions§

audience_column_mismatch
True when left_qualifier.audience and right_qualifier.audience are both set but disagree. NULL-tolerant: a NULL audience on 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’s MICROMEGAS_DEFAULT_AUDIENCE for a row written before this stage (a NULL column). qualifier is 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 to DEFAULT_AUDIENCE when unset. Malformed ⇒ Err, so a typo fails startup rather than silently relabelling every legacy row.