Skip to content

API Reference parrot.semantic.governance.masking

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.semantic.governance.masking

View source

Rewrite projected masked columns per MaskRule.strategy (null / md5-hash / partial).

Alias ColumnUse

Re-exported from parrot.semantic.governance.lineage.ColumnUse.

Alias MaskRule

Re-exported from parrot.semantic.policy.MaskRule.

Alias ModelPolicy

Re-exported from parrot.semantic.policy.ModelPolicy.

Alias PhysicalSchema

Re-exported from parrot.semantic.loader.PhysicalSchema.

Alias SemanticAccessError

Re-exported from parrot.semantic.errors.SemanticAccessError.

Function apply_masks

Rewrite projected masked columns in place.

Every root projection whose physical lineage includes a masked column (for the given roles) is replaced by the strategy expression, aliased to the original output name. Derived projections (UPPER(email), windows, CTE/subquery passthroughs) are masked as a whole. When several masked columns feed one projection, the strictest strategy wins.

apply_masks(tree: exp.Expression, uses: list[ColumnUse], policy: ModelPolicy, roles: frozenset[str], dialect: str) -> tuple[exp.Expression, tuple[str, ...], set[int]]

Parameter Type Default Description
tree exp.Expression A qualified sqlglot query AST (mutated in place).
uses list[ColumnUse] Physical column uses resolved from the unmodified query.
policy ModelPolicy Model governance policy.
roles frozenset[str] Trusted roles from the permission context.
dialect str Target SQL dialect.

Returns: tuple[exp.Expression, tuple[str, ...], set[int]] — The rewritten tree, sorted masked table.column names, and the identities of every pipeline-injected node.

Raises:

  • SemanticAccessError — When masked lineage cannot be placed safely.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally