Skip to content

API Reference parrot.semantic.governance.pipeline

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

parrot.semantic.governance.pipeline

View source

Fixed-order request-local governance with exact provenance.

Alias ColumnUse

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

Class GovernancePipeline

Authorize and rewrite a clone; never mutate reusable compilation output.

Parameter Type Default Description
pbac PbacGate Fail-closed PBAC gate.
rls RlsPushdown Unbound RLS pass; a request-local copy is bound per call.
allowed_functions frozenset[str] Toolkit-level additive function allowlist extensions.

Method GovernancePipeline.govern

Validate, qualify, authorize, resolve lineage, push RLS, mask and cap.

Order: negative validation → qualification → resource subset/PBAC → usage lineage → RLS → masking → positive guard → render. CPU AST passes run in a worker thread; PBAC is awaited on every call. The caller performs the pre-compile manifest gate.

govern(sql: str, *, model: LoadedModel, ctx: PermissionContext | None, roles: frozenset[str]) -> GovernedQuery

Parameter Type Default Description
sql str Compiled (or raw) SQL text; never mutated.
model LoadedModel Loaded model snapshot; never mutated.
ctx PermissionContext | None Trusted request permission context.
roles frozenset[str] Trusted roles of the subject.

Returns: GovernedQuery — The governed query with exact provenance.

Raises:

  • SemanticAccessError — On any authorization, lineage or RLS denial.
  • SemanticValidationError — On unsafe or unsupported SQL.

Alias GovernedQuery

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

Alias LoadedModel

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

Alias PbacGate

Re-exported from parrot.semantic.governance.pbac.PbacGate.

Alias PermissionContext

Re-exported from parrot.auth.PermissionContext.

Alias PhysicalResources

Re-exported from parrot.tools.dataset_manager.sources.resolver.PhysicalResources.

Alias PositiveGuard

Re-exported from parrot.semantic.governance.guard.PositiveGuard.

Alias QueryValidator

Re-exported from parrot.security.query_validator.QueryValidator.

Alias RlsPushdown

Re-exported from parrot.semantic.governance.rls.RlsPushdown.

Alias SemanticAccessError

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

Alias SemanticError

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

Alias SemanticValidationError

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

Alias apply_masks

Re-exported from parrot.semantic.governance.masking.apply_masks.

Alias effective_allowed_functions

Re-exported from parrot.semantic.governance.guard.effective_allowed_functions.

Alias enforce_usage_rights

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

Alias resolve_column_uses

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

Alias resources_from_ast

Re-exported from parrot.semantic.governance.pbac.resources_from_ast.

Function subject_digest

Hash canonical typed subject metadata, never the dataclass hash or repr.

The digest covers user id, tenant id, sorted roles and every session metadata item (policy-relevant: RLS subject attributes are read from it), each encoded with an explicit type tag so "1" and 1 never collide.

subject_digest(ctx: PermissionContext | None) -> str

Parameter Type Default Description
ctx PermissionContext | None Trusted request permission context; None only for ungoverned calls.

Returns: str — Hex SHA-256 digest of the canonical subject document.

Raises:

  • SemanticAccessError — If identity fields or metadata are not canonically encodable.

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