Source code for cadrumo.domain.evidence_consent.record
"""The off-host evidence-consent audit record and its natural key grammar.Owns the shape of one recorded consent decision and the object key it is storedunder. Both are pure data: the record carries no persistence, and the keyfunction is a total function of the record's own fields, so the applicationlayer can recover a stored row's natural key without reaching into the outboundadapter that writes it.**The record documents that a transmission was consented, never what wastransmitted.** It carries the evidence's SHA-256 content ADDRESS, the resolvedprovider and model, the operator surface that took the acknowledgement, and thetimestamp -- never the document bytes, the prompt, or the response. That is thesame "the address, never the bytes" line the consent token itself draws, and itis what keeps the audit trail from becoming a second copy of theconfidentiality problem it exists to document."""from__future__importannotationsfrompydanticimportBaseModel,Fieldfrom...core.identity.bucketimportBucketIdfrom...core.modelsimportSTRICT_FROZEN_CONFIGfrom...core.time.utcimportUtcInstant__all__=["EvidenceConsentLedgerEntry","evidence_consent_ledger_entry_object_key"]
[docs]classEvidenceConsentLedgerEntry(BaseModel):"""One consented off-host evidence dispatch, recorded for later audit. Every field is metadata ABOUT the transmission. Nothing here reconstructs the document: ``evidence_content_address`` is a digest, and there is no field for prompt or response text. """model_config=STRICT_FROZEN_CONFIGentry_id:str=Field(min_length=1,description="Stable id for this ledger entry (a UUID4 hex).")profile_bucket_id:BucketIdevidence_content_address:str=Field(min_length=1,description="SHA-256 content address of the evidence the acknowledgement covered.",)provider:str=Field(min_length=1,description="Resolved off-host provider the request dispatched at.")model:str=Field(min_length=1,description="Resolved model identifier the request dispatched at.")surface:str=Field(min_length=1,description="Operator surface that took the acknowledgement.")recorded_at:UtcInstant=Field(description="UTC timestamp the consent was honoured.")
[docs]defevidence_consent_ledger_entry_object_key(entry:EvidenceConsentLedgerEntry)->str:"""Return the unique natural key one consent entry is saved under. The grammar lives beside the record rather than beside the store, so the writer and the custody carry that must recover the same key read one authority instead of re-deriving it a second time on either side of the persistence boundary. """return"|".join((entry.recorded_at.isoformat(),entry.evidence_content_address,entry.entry_id))