Skip to content

Prove what happened

Scenario. An auditor asks: “Who approved this order, what did they see, and how do you know the record has not been changed?”

Start from a clean sandbox, in its directory:

./sandbox destroy
./sandbox up
AGENT=$(./sandbox token agent)
export SEFRA_OPERATOR_TOKEN=$(./sandbox token admin)
RESPONSE=$(curl -sS -X POST http://127.0.0.1:18180/v1/executions \
  -H "Authorization: Bearer $AGENT" -H "Content-Type: application/json" \
  -H "Idempotency-Key: audit-example-order-1" \
  -d '{"intent": "procurement.create_purchase_order",
       "input": {"vendor_id": "v_1001", "sku": "PROJECTOR", "quantity": 22,
                 "unit_price_minor": 100000, "currency": "EUR", "department": "it-ops"},
       "rationale": "Projectors for the training rooms"}')
EXECUTION=$(echo "$RESPONSE" | jq -r .execution_id)
SEFRA_OPERATOR_TOKEN=$(./sandbox token approver) ./sandbox sefra approvals approve "$(echo "$RESPONSE" | jq -r .approval.approval_id)" --comment "Approved for training budget"
./sandbox wait "$EXECUTION" | jq .status

List the execution’s events:

./sandbox sefra executions audit "$EXECUTION" | jq -r '.events[] | "\(.seq)  \(.type)  \(.actor)"'

Then look at the approval decision itself:

./sandbox sefra executions audit "$EXECUTION" | jq '.events[] | select(.type == "approval.decided")'

Each event records who acted and when. The approval is bound to a hash of the exact request, so an approval cannot be reused for a different one.

Each event contains the hash of the event before it, so changing or removing any past event breaks every link after it:

./sandbox sefra audit verify
./sandbox sefra audit head

Store the head value somewhere outside Sefra, such as a ticket or your security monitoring system. This step is what makes the evidence strong. The hashes are not keyed, so someone with full database access could rewrite the events and recompute every hash. They could not make the result match a head you stored elsewhere.

./sandbox sefra audit export > audit-export.jsonl
wc -l < audit-export.jsonl
jq -r .type audit-export.jsonl | sort | uniq -c | sort -rn | head -5

The export is JSON Lines, one event per line, ready for an archive or a security monitoring system. Sensitive fields are redacted in the trail.

To check a file you received, run verify on it, then compare its last event with the head you stored:

./sandbox sefra audit verify --file audit-export.jsonl
./sandbox sefra audit head
tail -n 1 audit-export.jsonl | jq -r '"\(.seq) \(.hash)"'

The seq and hash from audit head must match the file’s last line. verify --file checks only that the file is consistent with itself, so a file that was recomputed or cut short also passes. The comparison with your stored head is what detects that.

The chain shows the record has not been altered up to a head you stored outside the system. Events after that head are protected only once you store a newer one. It does not show that the person at the keyboard was who their sign-in claimed, so the strength of an approval depends on your identity provider. For stronger evidence, require the approval page with "min_evidence": "oidc".