aeat.adapters.persistence.storage.sql._secure_object_row_codec module¶
Row-level codec helpers for SQL secure-object records.
This module keeps the encrypted row decode path and post-write revision metadata update close to the SQL secure-object adapter without leaving both algorithms embedded in the repository class. It derives and persists revision lineage after ciphertext is written, validates row classification and the schema-lineage ceiling before decrypting (a version above the consumer’s current version is refused; an older version decrypts under its written version and is chain-upgraded to current), and refuses rows whose revision hashes no longer match their stored metadata.
See also
SecureObjectRepositoryRepository that delegates revision metadata writes and row decoding here.
derive_revision_id()Deterministic revision-id primitive used after a row write.
verify_revision_self_consistency()Integrity check applied before decrypting an existing row.
build_revision_ancestor_ids()Revision-lineage helper used to persist ancestor chains.
SecureObjectRecordPlaintext record returned after classification, schema, lineage, and AEAD checks pass.
secure_object_payload_aad()Associated-data builder that binds ciphertext to row identity.
SensitivityClassExpected row classification validated before a row is decoded.
- Governing vault records
2026-05-22-secure-storage-production-hardening-architecture-adrand2026-05-28-secure-storage-production-hardening-w04-p07-s30-review-auditrequire secure-object revision lineage and conflict-safe metadata.
- write_revision_metadata(session, *, row_id, namespace, schema_version, written_at, payload, previous_revision_id, previous_revision_ancestor_ids, previous_payload_hash, write_provenance, source_event_id, conflict_policy)[source]¶
- Return type:
- Parameters:
- secure_object_record_from_row(row, *, expected_class, max_supported_version, namespace_definition=None, enforce_registered_row_schema)[source]¶
- Return type:
- Parameters:
row (SecureObjectRow)
expected_class (SensitivityClass)
max_supported_version (int)
namespace_definition (SecureObjectNamespaceDefinition | None)
enforce_registered_row_schema (Callable[[...], None])
- secure_object_list_item_from_raw_row(raw, *, namespace, expected_class, max_supported_version, namespace_definition, enforce_registered_row_schema)[source]¶
Decode one raw
iter_records_with_failuresrow into a typed outcome.Fault-isolated: every failure mode (unknown classification, classification mismatch, unreadable schema version, decrypt failure, revision-lineage inconsistency, upgrade failure) returns a
SecureObjectUnreadablecarrying the reason instead of raising, so a caller iterating many rows can attribute a failure to its own row and keep inspecting the rest.- Return type:
- Parameters:
raw (object)
namespace (str)
expected_class (SensitivityClass)
max_supported_version (int)
namespace_definition (SecureObjectNamespaceDefinition | None)
enforce_registered_row_schema (Callable[[...], None])