| afad | 3.3 | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| version | 0.9.0 | |||||||||||||||||||||
| domain | PRIMARY | |||||||||||||||||||||
| updated | 2026-03-19 | |||||||||||||||||||||
| route |
|
Enumeration of diagnostic severity levels in a validation report.
class ValidationSeverity(StrEnum):
ERROR = "error"
WARNING = "warning"
INFO = "info"| Member | Value | Semantics |
|---|---|---|
ERROR |
"error" |
Blocking failure; ValidationReport.accepted returns False |
WARNING |
"warning" |
Non-blocking advisory |
INFO |
"info" |
Informational; never blocks acceptance |
- Purpose: severity classification for
ValidationFindinginstances. - Type:
StrEnum; string-comparable and JSON-serializable.
Immutable single finding emitted by a validation workflow.
@dataclass(frozen=True, slots=True)
class ValidationFinding:
code: str
message: str
severity: ValidationSeverity
source: str- All fields are required non-empty strings, except
severitywhich must beValidationSeverity. sourceidentifies the originating subsystem (e.g."core.transaction","ftl.resource","legislation.lv.standard.2026").- Immutable; no mutation after construction.
Immutable collection of ValidationFinding instances produced by a validation pass.
@dataclass(frozen=True, slots=True)
class ValidationReport:
findings: tuple[ValidationFinding, ...] = ()
@property
def accepted(self) -> bool: ...
def require_valid(self, *, component: str, operation: str) -> None: ...findingsdefaults to an empty tuple; an empty report is always accepted.accepted:Truewhen no finding carriesValidationSeverity.ERROR; warnings and info do not block.require_valid: raisesftllexengine.integrity.IntegrityCheckFailedErrorwhennot accepted; used at hard-fail boundaries.require_validpopulates both monotonictimestampand wall-clockwall_time_unixin the raisedIntegrityContext.- Combining reports:
ValidationReport(report_a.findings + report_b.findings).
Function that validates chart-of-accounts and transaction invariants across a full book aggregate.
def validate_book(book: Book) -> ValidationReport:| Name | Type | Req | Semantics |
|---|---|---|---|
book |
Book |
Y | Root aggregate to validate |
- Return:
ValidationReportwith zero or more findings; never raises on validation failures. - Runs
validate_chart_of_accountsand thenvalidate_transactionfor each transaction. - Account-reference violations in transactions are collected as separate
ERRORfindings. - Raises:
TypeErroronly ifbookis not aBookinstance (structural precondition).
Function that validates a single journal transaction within the context of a book.
def validate_transaction(book: Book, transaction: JournalTransaction) -> ValidationReport:| Name | Type | Req | Semantics |
|---|---|---|---|
book |
Book |
Y | Provides the known account set |
transaction |
JournalTransaction |
Y | Transaction to validate |
- Return:
ValidationReport; never raises. - Validates balance via
validate_transaction_balance; unknown account codes collected as findings. - Balance failures are returned as an
ERRORfinding, not raised.
Function that runs FTLLexEngine's six-pass static validation pipeline on an FTL source string.
def validate_ftl_resource(
source: str,
*,
known_messages: frozenset[str] | None = None,
known_terms: frozenset[str] | None = None,
known_msg_deps: Mapping[str, frozenset[str]] | None = None,
known_term_deps: Mapping[str, frozenset[str]] | None = None,
) -> ValidationReport:| Name | Type | Req | Semantics |
|---|---|---|---|
source |
str |
Y | Raw FTL source text |
known_messages |
frozenset[str] | None |
N | Message IDs already in bundle for cross-resource checks |
known_terms |
frozenset[str] | None |
N | Term IDs already in bundle |
known_msg_deps |
Mapping[...] | None |
N | Existing message dependency maps |
known_term_deps |
Mapping[...] | None |
N | Existing term dependency maps |
- Return:
ValidationReport; delegates toftllexengine.validation.validate_resource. - Covers all six passes: syntax, structural duplicates, undefined refs, circular refs, chain depth, semantic compliance.
- Can be used independently of a
FluentBundleinstance; suitable for CI/CD pipelines.
Function that validates FTL message variable contracts against declared expected variable sets.
def validate_ftl_resource_schemas(
source: str,
expected_schemas: Mapping[str, frozenset[str]],
) -> ValidationReport:| Name | Type | Req | Semantics |
|---|---|---|---|
source |
str |
Y | Raw FTL source text to validate |
expected_schemas |
Mapping[str, frozenset[str]] |
Y | Map of message ID to expected variable name set |
- Return:
ValidationReport; never raises on contract failures. FTL_SCHEMA_MESSAGE_MISSING(ERROR): a message declared inexpected_schemasis absent fromsource.FTL_SCHEMA_MISMATCH(ERROR): a message exists but its declared variable set differs from the expected set.- Uses
FluentLocalization.validate_message_variables()internally. - Exported from
finestvx.validation.
Function that reconciles cross-currency entries in a journal transaction against a declared exchange rate.
def validate_fx_conversion(
transaction: JournalTransaction,
base_currency: CurrencyCode,
counter_currency: CurrencyCode,
rate: Decimal,
) -> ValidationReport:| Name | Type | Req | Semantics |
|---|---|---|---|
transaction |
JournalTransaction |
Y | Transaction containing entries in both currencies |
base_currency |
CurrencyCode |
Y | Source (debit) currency |
counter_currency |
CurrencyCode |
Y | Target (credit) currency |
rate |
Decimal |
Y | Exchange rate; base_debit_total * rate must equal counter_credit_total within ISO 4217 precision |
- Return:
ValidationReport; never raises on validation failures. FX_RATE_INVALID(ERROR):rateis not finite and positive.FX_BASE_CURRENCY_ABSENT(ERROR): no entries withbase_currencyfound intransaction.FX_COUNTER_CURRENCY_ABSENT(ERROR): no entries withcounter_currencyfound intransaction.FX_RATE_MISMATCH(ERROR):base_debit_total * ratediffers fromcounter_credit_totalbeyond ISO 4217 decimal precision forcounter_currency.- Does not alter the core zero-sum invariant; validates only the cross-currency reconciliation ratio.
- Exported from
finestvx.validation.
Function that validates a posted transaction against its book's configured legislative pack.
def validate_legislative_transaction(
registry: LegislativePackRegistry,
book: Book,
transaction: JournalTransaction,
) -> ValidationReport:| Name | Type | Req | Semantics |
|---|---|---|---|
registry |
LegislativePackRegistry |
Y | Pack registry used to resolve the book's pack code |
book |
Book |
Y | Supplies book.legislative_pack |
transaction |
JournalTransaction |
Y | Transaction to validate |
- Return:
ValidationReport; legislative issues map toERRORfindings withsource = "legislation.<pack_code>". - Raises:
KeyErrorwhenbook.legislative_packis not registered. - Runs in-process (not isolated); for subinterpreter isolation use
FinestVXService.validate_transaction_isolated.