cadrumo.adapters.persistence.storage.sql._secure_object_integrity module¶
Decryptability diagnostics for SQL secure-object persistence.
The three operations here – quarantine, namespace counting, and per-row
enumeration – differ in what they DO with an undecryptable row (move it,
count it, describe it) but agree exactly on how they DECIDE one:
probe_row_decryptability() is that single decision. Keeping it in one
place means an AAD change or a new decryption-failure mode cannot be applied
to two of the three surfaces and missed on the third.
- class RowDecryptability(object_key, payload, readable, reason)[source]¶
Bases:
NamedTupleWhether one stored row decrypts, with the bytes the caller needs to act.
object_keyandpayloadare the normalised wire bytes: callers that quarantine a row re-insert exactly these, so the row that moves is the row that was probed.reasoncarries the decryption failure text and isNonewhenreadableisTrue.
- probe_row_decryptability(raw, *, namespace)[source]¶
Decide whether one secure-object row decrypts under the current master key.
The single decryptability decision behind quarantine, namespace counting, and per-row enumeration. Normalises the row’s bytes through
database_bytes()(SQLite returnsbytes,memoryview, orstrdepending on the driver and query form), rebuilds the row-identity AAD, and attempts the AEAD open.Only
DecryptionErroris treated as “unreadable”: a row whose bytes are structurally impossible to normalise is a programming or schema fault and propagates.- Return type:
- Parameters:
- quarantine_unreadable_rows(engine, *, logger)[source]¶
Move every undecryptable row into
secure_objects_quarantine.Returns a tuple of
SecureObjectNamespaceIntegrityrecords, one per namespace.- Return type:
- Parameters:
- probe_namespace_integrity(engine, namespace, *, logger)[source]¶
Count decryptable and undecryptable rows in
namespace.Returns a
SecureObjectNamespaceIntegrityfor the given namespace.- Return type:
- Parameters:
- iter_namespace_decryptability(engine, namespace)[source]¶
Yield
SecureObjectDecryptabilityRowrecords for one namespace.- Return type:
- Parameters: