aeat.application.live._verify module¶
Bucket-scoped verify service.
Wraps the two read-only AEAT verify oracles into a bucket-scoped
audit log. Verify observations are persisted through a
SecureObjectRepository scoped to the active profile bucket.
NIF-IVA (VIES) — intracomunitario counterparty validation
TGVI / GROI — intra-community operator (registered Spanish NIF)
Both surfaces are on-demand single-shot checks. The service records
each check as a typed observation tied to the active bucket so the
operator can audit which NIFs were verified, when, and against what
verdict. Subsequent invocations against the same NIF produce a new
observation row; history is never overwritten. Each observation is
wrapped in an Envelope before being written to the secure store.
- Structurally read-only:
the service has no submit / mutate verb;
the underlying drivers call
AeatAccessGate.require_live_read()before remote contact; this layer consumes their results only;the operator’s
--expected valid|invalid|unknownhint is recorded alongside the verdict so a mistaken expectation is auditable.
- class VerifySurface(*values)[source]¶
Bases:
StrEnumClosed catalogue of supported verify surfaces.
- NIF_IVA¶
- TGVI¶
- exception VerifyObservationNotFoundError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
AeatErrorRaised when a verify-observation lookup misses by id.
- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- class VerifyObservation(**data)[source]¶
Bases:
BaseModelOne persisted verify check.
The
observation_idis content-addressed (SHA-256 of canonical fields) so two identical checks against the same NIF on the same timestamp deduplicate without separate id management.- Parameters:
observation_id (str)
bucket_id (Annotated[str, StringConstraints(strip_whitespace=True, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=128, pattern=None, ascii_only=None)])
surface (VerifySurface)
nif (str)
verdict (Literal['valid', 'invalid', 'unknown'])
expected (Literal['valid', 'invalid', 'unknown'] | None)
matched_expectation (bool | None)
checked_at (datetime)
raw_evidence_locator (str | None)
persisted_at (datetime)
- observation_id: str¶
- bucket_id: BucketId¶
- surface: VerifySurface¶
- nif: str¶
- verdict: VerifyVerdict¶
- expected: VerifyVerdict | None¶
- matched_expectation: bool | None¶
- checked_at: datetime¶
- raw_evidence_locator: str | None¶
- persisted_at: datetime¶
- verify_observation_object_key(bucket_id, observation_id)[source]¶
Return the canonical secure-object key for a
VerifyObservation.The key encodes both the bucket and the observation so the store remains globally unique across buckets even when two buckets check the same NIF at the same instant.
- Parameters:
- Raises:
LiveApplicationInputError – When either argument is blank after stripping whitespace.
- Return type:
- class VerifyObservationRepository(*, bucket_id, objects=None)[source]¶
Bases:
objectSecure-object repository for bucket-scoped verify observations.
- Parameters:
bucket_id (str)
objects (SecureObjectRepository | None)
- load(observation_id)[source]¶
Return the
VerifyObservationforobservation_id, orNoneif absent.- Parameters:
observation_id (
str) – The full 64-character SHA-256 hex observation id.- Raises:
LiveApplicationInputError – When the loaded observation’s
bucket_idorobservation_iddoes not match the repository’s own bucket or the requested id.- Return type:
- list_observations()[source]¶
Return all stored observations as a tuple of
VerifyObservationsorted by check time.- Return type:
- save(observation)[source]¶
Persist
observationas an encryptedEnvelopein the object store.- Parameters:
observation (
VerifyObservation) – TheVerifyObservationto persist. Itsbucket_idmust match the repository’s own bucket.- Raises:
LiveApplicationInputError – When
observation.bucket_iddoes not match the repository’s bucket id.- Return type:
- class VerifyService(settings=None)[source]¶
Bases:
objectBucket-scoped audit log of NIF verify checks.
Structurally read-only. The service has no submit, no mutate, and no method that would alter AEAT-side state. Verify surfaces themselves are read-only by construction; this layer only records observations the drivers produce.
- Parameters:
settings (Settings | None)
- record(*, bucket_id, surface, nif, verdict, checked_at, expected=None, raw_evidence_locator=None)[source]¶
Persist one verify observation. Deduplicates identical replays.
Returns a
VerifyObservationwith the persisted observation id and all supplied fields.- Return type:
- Parameters:
- list_observations(*, bucket_id, surface=None, nif=None)[source]¶
Return all
VerifyObservationrecords in capture order. Optional filters.- Return type:
- Parameters:
bucket_id (str)
surface (VerifySurface | None)
nif (str | None)
- show(*, bucket_id, observation_id)[source]¶
Look up and return the
VerifyObservationfor the given full id or unambiguous prefix.- Return type:
- Parameters:
- latest_for_nif(*, bucket_id, surface, nif)[source]¶
Return the most recent
VerifyObservationfor (surface, nif), or None.- Return type:
- Parameters:
bucket_id (str)
surface (VerifySurface)
nif (str)