Skip to content

API Reference parrot.semantic.policy

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

parrot.semantic.policy

View source

Model policy side-file: grants, masks, RLS, and saved queries.

Alias Limits

Re-exported from parrot.semantic.models.Limits.

Class MaskRule

Projection masking and usage exemptions for a physical column.

Fields:

Field Type Default Description
strategy Literal['null', 'hash', 'partial']
projection_roles list[str]
usage_roles list[str]

Alias ModelMember

Re-exported from parrot.semantic.models.ModelMember.

Class ModelPolicy

Governance policy associated with one semantic model.

Fields:

Field Type Default Description
governed bool True
connection str ''
limits Limits
roles dict[str, RoleGrant]
masks dict[str, MaskRule]
rls list[RlsRule]
saved_queries list[SavedQuery]
allowed_functions list[str]

Method ModelPolicy.digest

Return the SHA-256 digest of canonical policy JSON.

digest() -> str

Returns: str

Method ModelPolicy.allowed_members

Return the union of matching role projection grants.

allowed_members(roles: frozenset[str], members: list[ModelMember]) -> set[str]

Parameter Type Default Description
roles frozenset[str] Trusted roles associated with the subject.
members list[ModelMember] Members exposed by the enclosing semantic model.

Returns: set[str]

Method ModelPolicy.usage_allowed

Return whether roles may use a column outside projection.

A mask's usage exemption is a separate, explicit permission and takes precedence for its protected column.

usage_allowed(roles: frozenset[str], column: str) -> bool

Parameter Type Default Description
roles frozenset[str]
column str

Returns: bool

Method ModelPolicy.mask_for

Return the applicable projection mask, if the roles lack exemption.

mask_for(roles: frozenset[str], column: str) -> MaskRule | None

Parameter Type Default Description
roles frozenset[str]
column str

Returns: MaskRule | None

Alias RlsRule

Re-exported from parrot.auth.RlsRule.

Class RoleGrant

A role's semantic-member projection and physical-column usage grants.

Fields:

Field Type Default Description
metrics list[str] | Literal['*']
dimensions list[str] | Literal['*']
usage list[str] | Literal['*']

Class SavedQuery

A reviewed, model-local semantic query.

Fields:

Field Type Default Description
name str
query SemanticQuery
verified_by str
verified_at date
description str ''

Alias SemanticPolicyError

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

Alias SemanticQuery

Re-exported from parrot.semantic.models.SemanticQuery.

Function load_policy

Parse and validate a model policy file.

load_policy(path: Path, members: list[ModelMember], tables: set[str], columns: dict[str, set[str]] | None = None) -> ModelPolicy

Parameter Type Default Description
path Path Path to the <model>.policy.yaml side-file.
members list[ModelMember] Semantic members available to the policy.
tables set[str] Physical tables available to RLS rules.
columns dict[str, set[str]] | None None Physical columns per table; lets a mask target a column that is exposed only through a metric (e.g. amount behind revenue).

Returns: ModelPolicy

Raises:

  • SemanticPolicyError — If the policy has invalid schema, bindings, or RLS.

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