aeat.domain.calculations.registry._runtime_graph module

Runtime graph helpers for validated registry formulas.

Walks FormulaExpression trees declared on a ModeloRevision to extract casilla, binding, parameter, relation, and date-binding references, and produces topologically sorted evaluation orders for the formula engine.

See also

aeat.domain.calculations.registry._validate_formulas

Validation layer that rejects dangling expression refs and formula dependency cycles before runtime graph builders are used.

aeat.domain.calculations.registry._formula_runtime

Formula evaluator that consumes these graph projections.

aeat.domain.calculations.registry._queries

Registry query surface that exposes formula dependencies to operators.

expression_casilla_refs(expression)[source]

Return all CasillaId refs.

The input is a validated FormulaExpression tree.

Return type:

tuple[TypeAliasType, ...]

Parameters:

expression (FormulaExpression)

expression_relation_refs(expression)[source]

Return all RelationId refs.

The input is a validated FormulaExpression tree.

Return type:

tuple[TypeAliasType, ...]

Parameters:

expression (FormulaExpression)

expression_binding_refs(expression)[source]

Return all BindingId refs.

The input is a validated FormulaExpression tree.

Return type:

tuple[TypeAliasType, ...]

Parameters:

expression (FormulaExpression)

expression_date_binding_refs(expression)[source]

Return all date-binding BindingId refs.

date_binding leaves carry date-valued profile facts (e.g. birth_date) consumed by the age_at_year_end op. They are distinct from binding leaves (Decimal channel) and need their own collector so callers can populate the date_binding_values channel selectively.

Return type:

tuple[TypeAliasType, ...]

Parameters:

expression (FormulaExpression)

expression_parameter_refs(expression)[source]

Return all ParameterId refs.

Walks both the direct parameter = "..." leaf and the dispatch_table = { key = "param_id" } leaf introduced by the lookup_bracket_by_ccaa op; dispatch_table values reference parameters just like the direct leaf.

Return type:

tuple[TypeAliasType, ...]

Parameters:

expression (FormulaExpression)

enum_consumed_binding_ids(revision)[source]

Return binding ids the revision’s formulas consume as string enums.

A registry binding leaf is resolved from one of two engine channels. When a binding is the args[1] enum-key argument of a dispatch op (lookup_bracket_by_ccaa / lookup_parameter_by_entity_type) the runtime reads it from the string-valued enum_binding_values channel. Every other binding leaf is read from the Decimal-valued binding_values channel.

The engine channel is therefore a property of how the formula consumes the binding, not of the binding’s typed_enum annotation. A binding may carry typed_enum yet still be consumed as a Decimal operand (the Modelo 100 estimacion-directa modality binding is compared against a numeric literal). Routing a binding into the wrong channel makes the engine raise binding ... has no supplied value; this query is the authoritative discriminator that prevents that mismatch.

Parameters:

revision (ModeloRevision) – The ModeloRevision whose formula graph is inspected for enum dispatch binding references.

Return type:

frozenset[TypeAliasType]

revision_date_binding_ids(revision)[source]

Return every date_binding id the revision’s formulas consume.

Date bindings carry date-valued profile facts (e.g. taxpayer birth date) consumed by ops such as age_at_year_end. They are read from the date_binding_values channel, distinct from the Decimal binding_values and string enum_binding_values channels. This is the revision-level sibling of enum_consumed_binding_ids(): callers use it to populate the date channel and to refuse a date-valued binding supplied through a decimal/enum override.

Parameters:

revision (ModeloRevision) – The ModeloRevision whose formula graph is inspected for date_binding leaf references.

Return type:

frozenset[TypeAliasType]

input_casilla_id_map(revision)[source]

Return the canonical casilla id map for a revision input.

The ModeloRevision supplies the declared CasillaId values.

Return type:

dict[TypeAliasType, TypeAliasType]

Parameters:

revision (ModeloRevision)

formula_evaluation_order(revision)[source]

Return computed casilla ids in dependency order.

Casilla references in formula expressions and formula target fields are canonical casilla.id values. Registry validation rejects number fallback references before runtime reaches this graph builder.

Parameters:

revision (ModeloRevision) – The ModeloRevision whose formulas to topologically sort.

Return type:

tuple[TypeAliasType, ...]