aeat.domain.calculations.registry._scenarios module

Local registry calculation scenario verification harness.

Runs locally curated calculation scenarios against a ValidatedRegistryAuthority snapshot and compares computed outputs to declared expected values, reporting any mismatches with full trace context.

class RegistryScenarioModel(**data)[source]

Bases: BaseModel

Strict frozen base for scenario verification records.

class RegistryScenarioExpectedOutput(**data)[source]

Bases: RegistryScenarioModel

Expected value and trace contract for one scenario output.

Parameters:
  • target_casilla_id (CasillaId)

  • value (Decimal)

  • operand_refs (tuple[str, ...])

  • operand_casilla_refs (tuple[CasillaId, ...])

  • legal_refs (tuple[LegalRefId, ...])

  • source_refs (tuple[SourceRefId, ...])

target_casilla_id: CasillaId
value: Decimal
operand_refs: tuple[str, ...]
operand_casilla_refs: tuple[CasillaId, ...]
legal_refs: tuple[LegalRefId, ...]
source_refs: tuple[SourceRefId, ...]
class RegistryCalculationScenario(**data)[source]

Bases: RegistryScenarioModel

One locally curated scenario for registry-only calculation verification.

Parameters:
id: str
modelo: str
revision: str
filing_period: Period | None
filing_year: int
period: str
inputs: dict[CasillaId, Decimal]
binding_values: dict[BindingId, Decimal]
enum_binding_values: dict[BindingId, str]
relation_values: dict[RelationId, Decimal]
date_context: dict[str, date]
date_binding_values: dict[BindingId, date]
expected_outputs: tuple[RegistryScenarioExpectedOutput, ...]
notes: tuple[str, ...]
class RegistryScenarioComparison(**data)[source]

Bases: RegistryScenarioModel

One expected-vs-actual output comparison for a scenario run.

Parameters:
  • target_casilla_id (CasillaId)

  • expected_value (Decimal)

  • actual_value (Decimal | None)

  • status (Literal['match', 'mismatch'])

  • expected_operand_refs (tuple[str, ...])

  • actual_operand_refs (tuple[str, ...])

  • expected_operand_casilla_refs (tuple[CasillaId, ...])

  • actual_operand_casilla_refs (tuple[CasillaId, ...])

  • expected_legal_refs (tuple[LegalRefId, ...])

  • actual_legal_refs (tuple[LegalRefId, ...])

  • expected_source_refs (tuple[SourceRefId, ...])

  • actual_source_refs (tuple[SourceRefId, ...])

  • detail (str | None)

target_casilla_id: CasillaId
expected_value: Decimal
actual_value: Decimal | None
status: ScenarioStatus
expected_operand_refs: tuple[str, ...]
actual_operand_refs: tuple[str, ...]
expected_operand_casilla_refs: tuple[CasillaId, ...]
actual_operand_casilla_refs: tuple[CasillaId, ...]
expected_source_refs: tuple[SourceRefId, ...]
actual_source_refs: tuple[SourceRefId, ...]
detail: str | None
class RegistryScenarioRunReport(**data)[source]

Bases: RegistryScenarioModel

Result of executing one local registry calculation scenario.

Parameters:
scenario_id: str
registry_snapshot_id: str
status: ScenarioStatus
comparisons: tuple[RegistryScenarioComparison, ...]
calculation: RegistryCalculationResult
run_registry_calculation_scenario(scenario, *, registry_root, source_root)[source]

Execute scenario against the registry calculator and compare outputs.

Return type:

RegistryScenarioRunReport

Returns:

A RegistryScenarioRunReport with per-casilla comparison results.

Parameters:
assert_registry_scenario_matches(report)[source]

Raise with comparison details unless the scenario matched exactly.

Return type:

None

Parameters:

report (RegistryScenarioRunReport)