Skip to content

API Reference parrot.knowledge.ontology.tenant

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

parrot.knowledge.ontology.tenant

View source

Multi-tenant ontology resolution and caching.

Resolves the merged ontology for each tenant using the three-layer YAML chain (base → domain → client) and caches the result in memory.

FEAT-159 (TASK-1098): Extended to compose PG overlay (approved concept rows and approved schema overlay rows) on top of the YAML chain via the new async resolve_with_overlay() method. The existing synchronous resolve() is unchanged for backward compatibility.

Alias ConceptCatalogService

Re-exported from parrot.knowledge.ontology.concept_catalog.service.ConceptCatalogService.

Alias ConceptRow

Re-exported from parrot.knowledge.ontology.concept_catalog.models.ConceptRow.

Alias EntityDef

Re-exported from parrot.knowledge.ontology.schema.EntityDef.

Alias OntologyDefinition

Re-exported from parrot.knowledge.ontology.schema.OntologyDefinition.

Alias OntologyMerger

Re-exported from parrot.knowledge.ontology.merger.OntologyMerger.

Alias SchemaOverlayRow

Re-exported from parrot.knowledge.ontology.schema_overlay.models.SchemaOverlayRow.

Alias SchemaOverlayService

Re-exported from parrot.knowledge.ontology.schema_overlay.service.SchemaOverlayService.

Alias TenantContext

Re-exported from parrot.knowledge.ontology.schema.TenantContext.

Class TenantOntologyManager

Resolve and cache merged ontology per tenant.

Parameter Type Default Description
ontology_dir Path | str | None None Base directory for ontology YAML files.
base_file str | None None Filename of the base ontology.
domains_dir str | None None Subdirectory for domain ontologies.
clients_dir str | None None Subdirectory for client ontologies.
db_template str | None None ArangoDB database name template ({tenant} placeholder).
pgvector_schema_template str | None None PgVector schema name template.
concept_catalog_service 'ConceptCatalogService | None' None
schema_overlay_service 'SchemaOverlayService | None' None

Method TenantOntologyManager.resolve

Resolve the merged ontology for a tenant.

resolve(tenant_id: str, domain: str | None = None) -> TenantContext

Parameter Type Default Description
tenant_id str Unique tenant identifier.
domain str | None None Optional domain name (e.g. "field_services").

Returns: TenantContext — TenantContext with the merged ontology and DB references.

Method TenantOntologyManager.invalidate

Invalidate cached ontology for a tenant or all tenants.

invalidate(tenant_id: str | None = None) -> None

Parameter Type Default Description
tenant_id str | None None Specific tenant to invalidate. If None, clears all.

Method TenantOntologyManager.list_tenants

Return list of currently cached tenant IDs.

list_tenants() -> list[str]

Returns: list[str] — List of tenant ID strings.

Method TenantOntologyManager.resolve_with_overlay

Resolve ontology composing YAML chain + PG overlay (async).

Extends the standard resolve() flow by fetching:

  1. Approved concept rows from ConceptCatalogService (if configured).
  2. Approved schema overlays from SchemaOverlayService (if configured).

Both are synthesised into OntologyDefinition objects and passed to OntologyMerger.merge_with_overlay() on top of the YAML chain.

Falls back to resolve() (sync, YAML only) when neither service is configured. When the async path completes, the result is stored in _cache using a separate key prefix ("overlay:{tenant_id}") so it does not evict YAML-only cached entries.

resolve_with_overlay(tenant_id: str, domain: str | None = None) -> TenantContext

Parameter Type Default Description
tenant_id str Unique tenant identifier.
domain str | None None Optional domain name.

Returns: TenantContext — TenantContext with the fully composed ontology.

Alias TraversalPattern

Re-exported from parrot.knowledge.ontology.schema.TraversalPattern.

Attribute logger

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