portal-semantic-layer

Compiles validated Pydantic semantic queries into deterministic Polars lazy expressions for financial silos.

Updated Jul 27, 2026
One-click install
npx skills add https://github.com/ArthurZizumbo/karisma-data --skill portal-semantic-layer-arthurzizumbo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: portal-semantic-layer
Source: https://github.com/ArthurZizumbo/karisma-data/tree/main/.claude/skills/portal-semantic-layer
Command: npx skills add https://github.com/ArthurZizumbo/karisma-data --skill portal-semantic-layer-arthurzizumbo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires polars, pydantic.

What problem does it solve? It prevents LLMs and clients from sending free-form SQL, Polars, or Python code against financial data by enforcing structured, catalog-validated queries that compile into deterministic, reproducible results. ## Core Features & Use Cases - Structured Query Schema: Define SemanticQuery, SemanticFilter, and SemanticResult Pydantic models with limits on dimensions, filters, and row counts. - Catalog Validation: Resolve business metric and dimension names to physical columns, raising typed errors (UnknownMetricError, UnknownDimensionError) before compilation. - Deterministic Compiler: Generate parameterized Polars lazy plans from validated queries so the same query and seed always produce the same result. - Cross-Silo Joins: Join creditos and derivados exposures by catalog-declared counterparty keys, never ad-hoc client keys. - Use Case: A risk analyst asks for saldo_total by producto with mora >= 90 days; the query is validated against the catalog, compiled to a lazy Polars plan, and executed against parquet extracts with catalog citations in the result. ## Quick Start Ask the assistant to implement the semantic query schema and deterministic Polars compiler in ml/semantic/compiler.py following the SMQ pattern with catalog validation.

Frequently Asked Questions about portal-semantic-layer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a semantic layer that compiles queries to Polars?▼

Define a Pydantic SemanticQuery model with metric, dimensions, filters, and date range, validate it against a catalog of business names, then compile it into a parameterized Polars LazyFrame plan using group_by and aggregation functions mapped from the catalog spec.

How to validate metrics and dimensions before running a query?▼

Resolve each business name through a catalog index before compilation. Raise a typed UnknownMetricError or UnknownDimensionError when a name is missing, returning a 422 response with fuzzy match suggestions instead of executing anything.

Can Polars lazy frames join data across different financial silos?▼

Yes, but joins should only use keys declared in the catalog, such as counterparty identifiers linking creditos and derivados. Aggregate each silo first, then join with a full outer join and coalesced keys; never accept ad-hoc join keys from clients.

Why should query filters never use string interpolation?▼

Interpolating user strings into expressions enables injection and non-deterministic plans. Filters must be parameterized by the compiler, building Polars predicates from validated filter operators like eq, gte, or between against catalog-resolved columns.

What are the limits of a deterministic semantic query compiler?▼

It only supports metrics, dimensions, aggregations, and joins declared in the catalog, so arbitrary ad-hoc analysis is not possible. Dimensions are capped at four and filters at eight per query, and results are limited to 100,000 rows.