Skip to content

API Reference parrot.semantic.accounting.models

github-actions[bot] edited this page Dec 2, 2026 · 1 revision

parrot.semantic.accounting.models

View source

Accounting contracts (FEAT-713 spec §2). Standard library and pydantic only.

Class AccountSet

A named, optionally effective-dated, set of accounts as written in the model.

Fields:

Field Type Default Description
accounts tuple[str, ...] ()
select Selector | None None
except_ tuple[str, ...] (
valid_from date | None None
valid_to date | None None
allow_overlap tuple[str, ...] ()

Attribute AccountingGrain

Class AccountingModel

Resolved, validated, hashable model.

Fields:

Field Type Default Description
spec AccountingModelSpec
snapshot_hash str
natures tuple[tuple[str, Nature], ...]
intervals tuple[tuple[date | None, date | None], ...]
sets dict[str, ResolvedSet]
model_hash str

Class AccountingModelSpec

The model YAML as written.

Fields:

Field Type Default Description
model str
version str
tenant str
chart_of_accounts ChartOfAccounts
sets dict[str, AccountSet]
metrics dict[str, MetricDef]
assertions tuple[Assertion, ...] ()
excluded tuple[Exclusion, ...] ()

Attribute AccountingRequest

Attribute AmountConvention

Class Assertion

An <expr> == <expr> invariant checked with an exact tolerance.

Fields:

Field Type Default Description
expr str
tolerance Decimal Decimal('0')
on_failure Literal['flag', 'block'] 'flag'

Class AssertionRequest

A request to evaluate one model assertion over a period.

Fields:

Field Type Default Description
kind Literal['assertion'] 'assertion'
assertion_index int
period Period

Class AssertionResult

Outcome of one assertion check.

Fields:

Field Type Default Description
expr str
status Literal['passed', 'failed', 'skipped']
lhs Decimal | None
rhs Decimal | None
tolerance Decimal
period Period

Class ChartAccount

One account of the account master.

Fields:

Field Type Default Description
account_id str
nature Nature | None
parent_id str | None None
tags tuple[str, ...] ()

Class ChartOfAccounts

Journal layout: source, key columns, sign convention and dimensions.

Fields:

Field Type Default Description
source JournalSource
account_key str
posting_date str
amount_convention AmountConvention
amount str | None None
debit str | None None
credit str | None None
nature NatureSpec | None None
dimensions tuple[str, ...] ()
allow_float bool False

Class ChartSnapshot

Immutable account master.

Fields:

Field Type Default Description
accounts tuple[ChartAccount, ...]
taken_at date
source str

Attributes:

Attribute Type Description
snapshot_hash str sha256 hex of the accounts sorted by account_id, as compact sorted-key JSON.

Class CompiledMetricQuery

A rendered metric (or assertion) query with its plan, request and lineage.

Fields:

Field Type Default Description
sql str
dialect str
sql_hash str
model_hash str
plan_hash str
plan MetricPlan
request AccountingRequest
lineage Lineage
assertions tuple['CompiledMetricQuery', ...] ()

Attributes:

Attribute Type Description
cache_key str Canonical JSON list [model_hash, canonical request, dialect] — CompileCache shape.

Attribute Cumulative

Class Exclusion

Accounts deliberately left out of every set, with the reason.

Fields:

Field Type Default Description
accounts tuple[str, ...]
reason str

Class JournalSource

Where postings live: a database table XOR a named frame.

Fields:

Field Type Default Description
table str | None None schema.table of the journal; mutually exclusive with dataframe.
dataframe str | None None Name of a frame resolved by the frame provider.
connection str | None None ConnectionResolver name; required with table.
driver str | None None DatabaseQueryToolkit driver name; required with table.

Class Lineage

How a result was derived: formula, resolved sets and checked assertions.

Fields:

Field Type Default Description
metric str | None
assertion_index int | None None
formula str
sets tuple[ResolvedSet, ...]
assertions tuple[str, ...]
warnings tuple[str, ...] ()

Class MetricDef

A metric expression over account sets and other metrics.

Fields:

Field Type Default Description
expr str
description str ''
dimensions tuple[str, ...] | None None
unit str | None None

Class MetricPlan

Portable IR — plain data, no sqlglot (FEAT-742 contract).

Fields:

Field Type Default Description
schema_version Literal[1] 1
table str
account_key str
posting_date str
amount_convention AmountConvention
amount str | None
debit str | None
credit str | None
natures tuple[tuple[str, Nature], ...]
result_scale Literal[6] 6
rounding Literal['half_even'] 'half_even'
arithmetic_version Literal[1] 1
cast_decimal bool
sets tuple[PlanSet, ...]
columns tuple[tuple[str, PlanExpr], ...]
grain AccountingGrain | None
dimensions tuple[str, ...]
filters tuple[tuple[str, tuple[str | int, ...]], ...]
scan_from date
output_from date
to_exclusive date
cumulative Cumulative | None

Attributes:

Attribute Type Description
plan_hash str sha256 hex of the plan's canonical JSON.

Class MetricRequest

A request to compute one metric over a period.

Fields:

Field Type Default Description
kind Literal['metric'] 'metric'
metric str
grain AccountingGrain | None None
dimensions tuple[str, ...] ()
filters dict[str, str | int | tuple[str | int, ...]] {}
period Period

Class MetricResult

Final metric result returned to callers.

Fields:

Field Type Default Description
columns tuple[str, ...]
rows tuple[dict, ...]
row_count int
compiled CompiledMetricQuery
assertion_results tuple[AssertionResult, ...]
chart_drift bool
audit_id str
duration_ms int

Attribute Nature

Class NatureSpec

How account natures are resolved: an account-master column XOR an explicit mapping.

Fields:

Field Type Default Description
from_column str | None None
accounts dict[str, Nature] | None None

Class Period

An inclusive [from, to] date window, optionally cumulative (period-to-date).

Fields:

Field Type Default Description
from_ date
to date
cumulative Cumulative | None None

Class PlanExpr

A node of a plan arithmetic expression.

Fields:

Field Type Default Description
op Literal['set', 'num', 'neg', 'add', 'sub', 'mul', 'div']
alias str | None None
value str | None None
args tuple['PlanExpr', ...] ()

Class PlanSet

An aliased account set referenced by plan expressions.

Fields:

Field Type Default Description
alias str
accounts tuple[str, ...]

Attribute RESERVED_METRIC_NAMES

Class ResolvedSet

An account set with its selectors resolved to an explicit, sorted account list.

Fields:

Field Type Default Description
name str
accounts tuple[str, ...]
valid_from date | None
valid_to date | None

Class RuntimeResult

Raw rows returned by a runtime target.

Fields:

Field Type Default Description
columns tuple[str, ...]
rows tuple[dict, ...]
target Literal['database', 'duckdb']
duration_ms int

Class Selector

Account selector resolved against the chart snapshot.

Fields:

Field Type Default Description
prefix str | None None
range tuple[str, str] | None None
tag str | None None

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