aeat.domain.calculations.registry._corpus_catalogue module

BOE/AEAT corpus-catalogue integrity helpers.

Verifies each SourceReference in a registry source catalogue against the bundled corpus filesystem: that the cited corpus file exists, stays within the repository root, and matches the recorded byte count and SHA-256. The source here is a corpus file (a BOE/AEAT consolidated text or AEAT manual), not a binding BindingSourceKind; this module is the corpus-catalogue verifier, not a registry binding family.

The corpus SOURCE BINARIES (.pdf / .xls / .xlsx under corpus/) are excluded from the slim aeat runtime wheel and shipped in an optional aeat_data companion distribution. The gate is companion-aware: a binary that is PRESENT (in the runtime tree or the companion) stays byte-exact hash-enforced exactly as before; a companion binary that is ABSENT from both roots yields an accumulable, loud advisory naming the missing set and the aeat-cli[corpus-sources] install hint rather than hard-failing — the split-install degradation is loud, never silent. Every non-binary corpus file (extracted text, normative HTML, XSD) stays in the runtime wheel, so its absence remains a hard failure as before.

CORPUS_SOURCES_INSTALL_HINT

Operator install command that adds the optional aeat_data companion.

Named in every companion-absent advisory so an operator whose split install lacks the corpus source binaries learns exactly how to restore full byte-integrity verification and the aeat app registry verification verbs.

exception CorpusCompanionAdvisory[source]

Bases: UserWarning

Loud, non-fatal advisory that the aeat_data companion binaries are absent.

is_companion_corpus_binary(source)[source]

Return whether a source is a corpus binary shipped by the aeat_data companion.

Derived from the catalogue entry alone: a corpus/... file whose extension is one the slim aeat wheel excludes (.pdf / .xls / .xlsx). Extracted-text, normative HTML, and XSD sources stay in the runtime wheel and are NOT companion binaries, so their absence stays a hard failure.

Return type:

bool

Parameters:

source (SourceReference)

verify_source_file(root, source)[source]

Verify one source reference against the local repository filesystem.

Returns None when the cited file is PRESENT (in the source tree or the aeat_data companion) and its byte count and SHA-256 match — the byte-exact contract, unchanged. When the file is a companion corpus binary (.pdf / .xls / .xlsx under corpus/) that is ABSENT from both roots, returns an accumulable advisory string instead of raising, so the split-install degradation is loud but non-fatal. A mismatched present file, a path that escapes the repository root, or an absent NON-companion file (extracted text, HTML, XSD) still raises RegistryValidationError exactly as before.

Return type:

str | None

Parameters:
verify_source_catalogue(root, sources)[source]

Verify every source reference in a source catalogue mapping.

Present binaries stay byte-exact hash-enforced (a mismatch or an absent non-companion file raises RegistryValidationError). Absent companion binaries are accumulated into ONE loud advisory naming the missing set and the aeat-cli[corpus-sources] install hint: the advisory is both emitted through CorpusCompanionAdvisory (so a split-install run surfaces it loudly at first registry load) and returned to the caller, so the degradation is never silenced. When every declared binary is present the return is empty and no advisory is emitted.

Return type:

tuple[str, ...]

Parameters: