Audit and events
The audit chain
On this page
Introduction
Signari's audit trail is a "hash chain": each entry carries a hash of the one before it. So removing or editing an entry breaks the chain at every entry after it, and verification names where.
This page says how Signari keeps the chain one line while many requests write to
it at once. It also says what you can do with a chain that is already broken. You
check the chain with signari audit verify, and declare a restart point in a
broken one with signari audit checkpoint.
Note
Exporting and archiving the trail are described in Audit export.
How the chain stays one line
Two entries that claim the same predecessor are a "fork". When the chain is verified, a fork cannot be told apart from a deleted entry. So only one append at a time reaches the chain, however many requests, or copies of Signari, are writing.
Each append takes a transaction-scoped advisory lock on the whole chain. Only then does it read the chain's tail and insert the new entry. A commit or a rollback releases the lock, so a process that dies mid-append cannot wedge the trail.
The lock's key is one constant, because the chain is global. It is verified in ID order across every organisation, so a lock per organisation would let two appends claim one predecessor.
The three steps are one statement, core.audit_append (migration 0239). The
function is volatile, so each statement inside it takes a new snapshot. The read
of the tail therefore sees whatever committed while the append waited for the
lock.
The lock is held until the commit, and every audited transaction waits behind it. So a record written in a transaction of its own is appended together with the others that arrive while one is being written. Examples are a revocation's record, a token exchange's and a backchannel request's.
core.audit_append_many (migration 0305) appends such a group. It takes the lock
once and reads the tail once. It hashes each record after the one before it, and
makes one commit for all of them. The same bytes are hashed under the same lock,
so a version of Signari from before migration 0305 appends to the same chain. Each
record is committed before the request it belongs to is answered.
A record whose group cannot be appended is written again on its own, so its failure takes no other request's record with it. A record that joins another transaction, as a sign-in's does, still appends in that transaction.
TestConcurrentAppendsDoNotForkTheChain runs 12 concurrent writers. It then walks
the whole table for any two entries that share a predecessor, so it also catches
a fork made by any other path. What one instance does under
load gives the rates the lock allows.
Identifiers are hashed as they are stored
PostgreSQL accepts a universally unique identifier (UUID) in several spellings: upper case, in braces, without hyphens, or with a hyphen after every four digits. Whatever the spelling, it stores the canonical form.
Verification recomputes each entry's hash from its stored columns. So Signari passes each ID through PostgreSQL before hashing it, as it does the detail column, which jsonb also normalises. The hash covers exactly what is stored, whatever spelling a caller used.
The Admin API also refuses a non-canonical ID in a path, but the chain does not depend on every caller doing that.
Living with a chain that is already broken
A chain with a break in it cannot produce a verified export again, of any period. That includes entries written correctly long after the break.
A break does not always mean tampering. A defect in an earlier version of Signari can leave one, and the changelog lists the defects that did.
Signari has no repair tool, and will not have one. Rewriting entries to close a break is the operation the chain exists to detect.
Instead, you can declare a "checkpoint", with the reason for it:
Shellsignari audit checkpoint -by "ada@example.com" \ -reason "forks written before the upgrade, by a known defect; see the changelog"
A checkpoint repairs nothing: no entry is rewritten, re-linked or removed. It is a declaration, recorded in the chain itself, that the entries before it are not asserted and that verification restarts there.
The export then says so, next to the verified count:
Text Chain verified over 235 entries SINCE A CHECKPOINT. The 5465 entries before it are NOT asserted by this export. A checkpoint was declared on 2026-08-16 by ada@example.com: forks written before the upgrade, by a known defect; see the changelog A checkpoint repairs nothing. It records that the earlier chain was already broken and that verification restarts here. If you are submitting this somewhere that matters, submit the reason with it.
The checkpoint's reason records why the earlier breaks are there. Every export that crosses the checkpoint carries it, where an auditor will see it.
Why this is not a way to hide a deletion
Four rules keep a checkpoint from hiding a deletion:
- It is refused on a sound chain. On an intact log, a checkpoint can only narrow what a later verification covers. So there is no legitimate reason to declare one.
- It is itself an audit entry, written through the ordinary path and linked like any other. Declaring one leaves an entry in the chain it starts, and removing that entry breaks the chain at its successor.
- It covers only what precedes it. A break after the checkpoint still fails the export. A test deletes an entry after one and expects the refusal.
- The reason is mandatory, and is carried into every export that crosses it.
Only the link from the starting entry to its predecessor is disclaimed. The entry's own hash is still checked, so an entry altered at the boundary still fails verification. A test covers that too.
A break after a checkpoint is reported at that break, never at an earlier one the checkpoint disclaims. The report says that the declaration does not cover it, so an administrator who knows about the old break cannot mistake the new one for it.
Someone with database access can still delete or alter entries. A hash chain does not prevent that; it makes it detectable, and a checkpoint does not change that.
Testing the chain
The tests that prove a break is detected have to make one, by deleting and altering audit entries. That breaks a database's chain permanently, and every later audit test on it would fail on data it never touched.
So those tests run only against a disposable database named in
SIGNARI_DESTRUCTIVE_TEST_DSN, and skip without it:
Shellcreatedb signari_scratchSIGNARI_DSN=…signari_scratch signari migrate allSIGNARI_DESTRUCTIVE_TEST_DSN=…signari_scratch go test ./internal/audit/
Changed Signari v0.2