Snapshot evidence payloads before hashing and appending

Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
This commit is contained in:
Rudy Celekli
2026-10-01 21:52:13 -04:00
parent d3f71c4bb8
commit 1f53bd8a6b
+10 -3
View File
@@ -165,6 +165,11 @@ class DelegationVerifier:
### Evidence Record Structure
```python
from copy import deepcopy
from datetime import datetime
import hashlib
import json
class EvidenceRecord:
"""
Append-only, tamper-evident record of an agent action.
@@ -185,9 +190,9 @@ class EvidenceRecord:
record = {
"agent_id": agent_id,
"action_type": action_type,
"intent": intent,
"intent": deepcopy(intent),
"decision": decision,
"outcome": outcome,
"outcome": deepcopy(outcome),
"timestamp_utc": datetime.utcnow().isoformat(),
"prev_record_hash": prev_hash,
}
@@ -199,7 +204,9 @@ class EvidenceRecord:
# Sign with agent's key
record["signature"] = self.sign(canonical.encode())
self.append(record)
# Keep caller-owned inputs and the returned record independent of the
# stored snapshot; later mutations must not invalidate its signed hash.
self.append(deepcopy(record))
return record
```