Skip to content

API Reference parrot_tools.querysource.catalog

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

parrot_tools.querysource.catalog

View source

Slug catalog over public.queries with explicit tenant checks (spec §3 M4).

Alias InvalidConditionsError

Re-exported from parrot_tools.querysource.errors.InvalidConditionsError.

Class NormalizedPipeline

Flat view of a MultiQS pipeline dict (design research S6).

Parameter Type Default Description
slug_nodes dict[str, str]
raw_nodes list[str]
has_files bool
has_sources bool
step_names list[str]
output_steps list[str]

Fields:

Field Type Default Description
slug_nodes dict[str, str]
raw_nodes list[str]
has_files bool
has_sources bool
step_names list[str]
output_steps list[str]

Alias QuerysourceToolkitError

Re-exported from parrot_tools.querysource.errors.QuerysourceToolkitError.

Alias SavedSlug

Re-exported from parrot_tools.querysource.models.SavedSlug.

Class SlugCatalog

Reads/writes public.queries through QueryModel with a per-call connection (S1); no auth cache (S2).

Parameter Type Default Description
dsn str
guard TenantGuard

Method SlugCatalog.open

Create the AsyncDB('pg') factory lazily (pattern: connections.py:113-130).

open() -> None

Method SlugCatalog.close

close() -> None

Method SlugCatalog.get

Load one definition; SlugNotFoundError when absent. Always hits the store (S2).

tenant=None reads public.queries through QueryModel (FEAT-558 path, unchanged). A set tenant resolves through QuerySource's DefinitionRepository exactly like TenantQueryHandler._prepare (querysource handlers/tenant.py:198-212) and never falls back to public.

get(slug: str, *, tenant: str | None = None) -> SlugRecord

Parameter Type Default Description
slug str
tenant str | None None

Returns: SlugRecord

Method SlugCatalog.get_allowed

get() then guard.assert_allowed() — unchanged rule, now tenant-aware.

get_allowed(slug: str, *, tenant: str | None = None) -> SlugRecord

Parameter Type Default Description
slug str
tenant str | None None

Returns: SlugRecord

Method SlugCatalog.list

tenant=None: existing QueryModel path over public.queries; tenant set: repo.list(store, params).

list(*, search: str | None, program: str | None, limit: int, tenant: str | None = None) -> list[SlugRecord]

Parameter Type Default Description
search str | None
program str | None
limit int
tenant str | None None

Returns: list[SlugRecord]

Method SlugCatalog.list_programs

Distinct program_slug values across the catalog, sorted (FEAT-593).

Not filtered by TenantGuard: the operator is choosing the scope itself.

list_programs() -> list[str]

Returns: list[str]

Method SlugCatalog.upsert

Insert or (guarded) update a multi-query row: query_raw=json, is_cached=False (S5 ownership check).

upsert(*, slug: str, description: str, pipeline: dict[str, Any], program_slug: str, overwrite: bool) -> SavedSlug

Parameter Type Default Description
slug str
description str
pipeline dict[str, Any]
program_slug str
overwrite bool

Returns: SavedSlug

Alias SlugNotFoundError

Re-exported from parrot_tools.querysource.errors.SlugNotFoundError.

Class SlugRecord

Redacted view of one public.queries row (never source/params/attributes/dwh_*/cache_options).

Parameter Type Default Description
slug str
program_slug str
description str | None
provider str
is_cached bool
cache_timeout int
conditions dict[str, Any] dict()
cond_definition dict[str, Any] dict()
filtering dict[str, Any] dict()
fields list[str] list()
ordering list[str] list()
grouping list[str] list()
query_raw str | None None
pipeline dict[str, Any] | None None

Fields:

Field Type Default Description
slug str
program_slug str
description str | None
provider str
is_cached bool
cache_timeout int
conditions dict[str, Any] field(default_factory=dict)
cond_definition dict[str, Any] field(default_factory=dict)
filtering dict[str, Any] field(default_factory=dict)
fields list[str] field(default_factory=list)
ordering list[str] field(default_factory=list)
grouping list[str] field(default_factory=list)
query_raw str | None None
pipeline dict[str, Any] | None None

Attributes:

Attribute Type Description
is_multiquery bool True when query_raw parsed to a dict holding queries|files|sources.
placeholder_names list[str] keys(cond_definition) ∪ keys(conditions), sorted.

Method SlugRecord.from_row

Build from a QueryModel instance (attribute access; columns verified models.py:49-81).

from_row(row: Any) -> 'SlugRecord'

Parameter Type Default Description
row Any

Returns: 'SlugRecord'

Alias TenantDeniedError

Re-exported from parrot_tools.querysource.errors.TenantDeniedError.

Class TenantGuard

Allowlist of program_slug values; None means unrestricted (proposal U4).

Parameter Type Default Description
programs list[str] | None

Attributes:

Attribute Type Description
programs tuple[str, ...] | None
restricted bool

Method TenantGuard.assert_allowed

Raise TenantDeniedError when restricted and record.program_slug ∉ programs.

assert_allowed(record: SlugRecord) -> None

Parameter Type Default Description
record SlugRecord

Method TenantGuard.resolve_write_program

Program a save must use (S5): explicit ∈ allowlist; single-program default; else error.

resolve_write_program(requested: str | None) -> str

Parameter Type Default Description
requested str | None

Returns: str

Attribute logger

Function normalize_pipeline

Walk the MultiQS shape (multi/init.py:95-97,443; obj.py:49-63); raise InvalidConditionsError when malformed.

normalize_pipeline(pipeline: dict[str, Any]) -> NormalizedPipeline

Parameter Type Default Description
pipeline dict[str, Any]

Returns: NormalizedPipeline

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