Skip to content
Sefra

Pillar: evidence

A record you can verify

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.

See how to verify the trail

What goes wrong without it

  • 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.

  1. #4141 compensation.succeeded

    seq
    4141
    at
    2026-11-17T10:42:07.214506Z
    type
    compensation.succeeded
    execution_id
    exe_…B
    step_index
    0
    actor
    system:worker
    body
    {"attempt":1,"response_status":200,"step":"vendor"}
    prev_hash
    9b1f4c7ae2d05386c1fa7e40d92b6c3158ea07fd4c26b9e1830d5fa7c46e12bd
    hash
    6f9a68767d14ddca87fbbd3d308cce650a7b52e9732a158baed337ef8e9c52e6
  2. This event's prev_hash is the hash above.

    #4142 execution.completed

    seq
    4142
    at
    2026-11-17T10:42:07.231877Z
    type
    execution.completed
    execution_id
    exe_…B
    step_index
    null
    actor
    system:worker
    body
    {"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"}
    prev_hash
    6f9a68767d14ddca87fbbd3d308cce650a7b52e9732a158baed337ef8e9c52e6
    hash
    c32d101661006686f284daf7ee9a07e8ae497a1896f3a6f9a5d4ce72dc82253d

The verifier on a tampered row

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.

  • Anchored audit checkpointsPlanned
  • Payload retention and erasurePlanned

Start with a pilot

Stopping an agent is the easy half. Sefra also finishes the job.