Skip to main content

The audit log — configuration

There is almost nothing to configure, and that is the design.

What is recorded, and by what​

Every model carrying AuditedMixin writes an entry on every insert, update and delete: the table, the record, the action, the before and after values, who did it, from which request, and when. It is a database-level listener rather than something each module remembers to call — a module that forgot would be silently unaudited, which is worse than a crash because nothing looks wrong.

On top of that, a state change writes an explicit event with a name and, where a human made a choice, the reason they gave.

What is never recorded​

KindExampleWhy
CredentialsPassword hashes, MFA secretsA log holding a credential is a credential store with worse access control
Personal contact detailsMobile numbers, personal emailThe log is kept for years; a person's private number should not be repeated in it on every change
Regulated identifiersTax ids, licence numbersAGENTS.md rule 11

Those fields appear as changed, with no value. The fact is kept; the data is not. A model declares them with __audit_exclude__.

It cannot be edited​

The audit tables carry an append-only trigger. UPDATE and DELETE are refused by the database, including to this application and including to a migration. That is why there is no delete path in the UI — there is nothing for one to call.

There are two audit tables and they answer different questions:

  • the control plane's, for accounts, entities, users and roles;
  • each entity's own, for that company's business data.

A caller reading the control-plane log sees only their own entity's rows.

Permissions​

PermissionWho holds it
audit_log.readManager and Accounting by default, plus Administrator

There is no audit_log.write and no audit_log.delete. Entries are written by the platform, never by a person.

Exporting​

GET /api/v1/audit/export streams CSV with the same filters the list takes, and the screen builds both from one function so they cannot ask for different things. It is batched rather than materialised: a year of a large customer's history is not a list to hold in memory.

Each row says who by name (actor_name, R19 automation) beside the kind of actor, on screen and as an actor_name column in the export; actor_user_id filters both to one person. Names come from the people with access to this company only: somebody who has left keeps their id and loses the name.

Anybody who may read the log may export it. That is deliberate — an export is a copy of what they can already read on screen, and a separate permission would be a control that stopped nothing.

Retention​

Nothing prunes it, and nothing is planned to. If a customer's regulator requires a retention limit, that is a conversation rather than a setting: deleting audit rows on a schedule needs the append-only trigger relaxed, and that is not a thing to make configurable.