Every policy decision and approval, and the start of every step and compensation, is written to a hash-chained trail in PostgreSQL before the first call it allows. Results are written when the call returns, and a separate command checks the trail.
Nobody can show an auditor which rule allowed a change and who approved it.
A log that the writing service can edit proves only what that service says about itself.
How it works
Each event's hash covers the previous hash and the event's canonical JSON, so changing one event breaks the link at that event. In the documented deployment Sefra runs as sefra_app, a database role that can insert and read events and cannot update or delete them. Running Sefra as the table owner removes this protection. The verifier reads PostgreSQL directly, so checking the record does not depend on the service that wrote it.
Two chained events
The last two events of the traced plan. The times, the shortened execution id and the first prev_hash are illustrative. Each hash is SHA-256 over prev_hash, a line feed and the RFC 8785 form of the other members shown, so you can recompute it.
{"error":{"code":"DOWNSTREAM_REJECTED","message":"The system of record refused the operation.","retryable":false,"stage":"execution","step":"deposit","violations":[{"actual":422,"message":"The system of record refused the operation.","rule":"downstream.rejected"}]},"status":"rolled_back"}
The verifier passes, then one stored decision is changed directly in the database. The next check names the event and exits non-zero.
The verifier, before and after the change
OK: events 4120 to 4142, head 4142 c32d…BROKEN at seq 4123: hash does not match the event's content
Check it, keep it, export it
Check the chain
Recomputes the chain and reports the first broken link.
Record the head
Gives the current sequence number and head hash, to keep elsewhere.
Export the trail
Writes events as JSON Lines, for an archive or a monitoring system.
Check an export
Recomputes the chain over an exported file alone, without the database. To trust the file, compare its last hash with a head recorded elsewhere.
Redaction
Events hold hashes of payloads, not the payloads. A field marked sensitive is stored in the audit payload table only as a keyed hash, while the real value still goes to the system of record. The real value of a sensitive input exists in the step row while the execution runs and, by default, for 7 days after it ends. Step outputs are kept for 30 days, so that a repeated request can return them.
What it does not do
Someone with full control of the database can rewrite the whole chain. The verifier finds an edit that does not also rewrite every later hash. The planned fix is listed below. Today, store the current head hash somewhere the database administrator does not control.
The trail records what Sefra saw and did. It cannot record the agent's reasoning, and a rationale is stored as unverified.
Admission refusals are counted and not recorded one by one, so that a looping agent cannot flood the log.
The trail is designed to produce evidence. Whether it satisfies a given regulation or auditor is the customer's question.
How it behaves
Automated tests cover each of these behaviours.
A field marked sensitive reaches your system and never appears in the audit events or payloads.
If a stored event is changed, even by a database superuser, the verifier fails and names its sequence number.
A recorded policy decision can be evaluated again from its stored input and matches the recorded output.
An export holds every event in order, and the chain recomputed over the file alone equals the head.
What is planned
On our product plan, and listed on the status page with its current state.