AUD · Audit log
One trigger, app.audit_row, writes audit_log for the tables worth watching: settings, legal entities, pools, bank accounts, contract templates, memberships, invitations, roles and overrides, pricing groups, charge types, vehicle brands and models, lead sources, garages, insurers and partner garages, rental companies, checklist items and body panels (R-MD-74), vehicles, GPS devices (R-GPS-28), drivers, driver documents and platform accounts, background checks, pool transfers, rentals, contracts, inspections, damages, work orders, insurance policies and claims, gate passes and approvals, charges, payments, allocations, adjustments and debt letters. Logins are in Supabase's own auth log. Code AUD.
Not yet a rule
Section titled “Not yet a rule”These questions are open in #74. Each gets a rule with a new ID once it is answered.
- AUD open 1 · Rows with no pool
Answered questions
Section titled “Answered questions”- DOC-Q3 (updates that move only updated_at): they are logged. R-AUD-01 stands as written: every update writes a row, and such a row lists no changed field (R-AUD-03). It records that someone saved the row.
- DOC-Q4 (other document numbers): masked too. A new rule, R-AUD-11: every driver document's number is masked, not only the KTP's.
R-AUD-01 · Every insert, update and delete on a watched table writes one audit row
Section titled “R-AUD-01 · Every insert, update and delete on a watched table writes one audit row”- Status: built
- Example: given a watched table such as vehicles, when a car is inserted and then updated twice, then the car has three audit rows. An update that changes nothing but updated_at still writes one, with no changed field.
- Refusal: none.
- Who: every writer, jobs included.
- Source: [Ref] Database rules and conventions, Audit log; D9 (P6). The update case is DOC-Q3. The watched tables are those the page's opening lists; contract_templates joined them on #459 (2026-11-17, the lead: one call, one audit row, D52).
R-AUD-02 · An audit row keeps the old row, the new row and the names of the changed fields
Section titled “R-AUD-02 · An audit row keeps the old row, the new row and the names of the changed fields”- Status: built
- Example: given a car whose color changes from silver to black, when its audit row is read, then old_data has silver, new_data has black and changed_fields is {color}.
- Refusal: none.
- Who: every watched table.
- Source: [Ref] Database rules and conventions, Audit log.
R-AUD-03 · updated_at is never listed as a changed field
Section titled “R-AUD-03 · updated_at is never listed as a changed field”- Status: built
- Example: given a car whose color changes, when its audit row is read, then changed_fields is {color}, without updated_at.
- Refusal: none.
- Who: every watched table.
- Source: [Ref] Database rules and conventions, Audit log; the M0 acceptance checks.
R-AUD-04 · An audit row records who made the change
Section titled “R-AUD-04 · An audit row records who made the change”- Status: built
- Example: given Deka updates a car, when its audit row is read, then actor_id is Deka's profile id. A job's change has no actor.
- Refusal: none.
- Who: every watched table.
- Source: [Ref] Database rules and conventions, Audit log.
R-AUD-05 · An audit row's source is app, unless the writer marked it cron, or the change was made directly in the database, which reads system with the database user's name
Section titled “R-AUD-05 · An audit row's source is app, unless the writer marked it cron, or the change was made directly in the database, which reads system with the database user's name”- Status: built
- Example: given the daily rent job sets app.source to cron, then its rows read cron; given zuki fixes a row in psql as the postgres user, then its audit row reads source system and records postgres; a change from the web app reads app.
- Refusal: none.
- Who: every writer.
- Source: [Ref] Database rules and conventions, Audit log; #144 (aud 05: how direct changes are reconciled).
R-AUD-06 · NIK, phone and bank account numbers are masked before they're stored in the audit log
Section titled “R-AUD-06 · NIK, phone and bank account numbers are masked before they're stored in the audit log”- Status: built
- Example: given a driver whose phone or secondary_phone changes from 6281234567890, or a payment whose sender's bank account number is recorded, or a company bank account's account_number (R-MD-49), when the audit row is read, then neither old_data nor new_data holds the number in clear.
- Refusal: none.
- Who: every watched table.
- Source: D9 (P6); the M0 acceptance checks; #144 (aud 06: "account" means bank account). Wording only; the behaviour is unchanged. Example widened for drivers.secondary_phone (#351): the audit trigger masks it as it masks phone; the ID and meaning stay.
R-AUD-07 · An audit row records the pool of its row, its car or its driver
Section titled “R-AUD-07 · An audit row records the pool of its row, its car or its driver”- Status: built
- Example: given a payment, which has no pool, by a driver at PML, when its audit row is read, then pool_id is PML.
- Refusal: none.
- Who: every watched table.
- Source: D9 (P6); [Ref] Database rules and conventions, Audit log.
R-AUD-08 · Reading audit rows needs audit_log:read at their pool
Section titled “R-AUD-08 · Reading audit rows needs audit_log:read at their pool”- Status: built
- Example: given a viewer scoped to SBY, when they read audit_log, then the history of PML's cars doesn't come back.
- Refusal: none: hidden.
- Who: every system role holds audit_log:read, scoped by its pools.
- Source: D9 (P6); the M0 acceptance checks.
R-AUD-09 · Nobody can write, change or delete audit rows directly
Section titled “R-AUD-09 · Nobody can write, change or delete audit rows directly”- Status: built
- Example: given a super_admin, when they delete an audit row or insert one, then nothing changes.
- Refusal: none: insufficient_privilege (42501) on insert; no effect on update or delete.
- Who: every app user. Only the audit trigger writes.
- Source: [Ref] Database rules and conventions, Audit log; [Ref] Roles, policy matrix.
R-AUD-10 · GPS positions and append-only event tables aren't audited
Section titled “R-AUD-10 · GPS positions and append-only event tables aren't audited”- Status: built
- Example: given a GPS position or a queue event is inserted, when audit_log is read, then no row for it exists.
- Refusal: none.
- Who: gps_positions and the event tables.
- Source: [Ref] Database rules and conventions, Audit log.
R-AUD-11 · Every driver document's number is masked in the audit log
Section titled “R-AUD-11 · Every driver document's number is masked in the audit log”- Status: built
- Example: given a driver's SIM A number is corrected, when the audit row is read, then doc_number is masked in old_data and new_data, as it is for a KTP, whose number is the NIK.
- Refusal: none.
- Who: driver_documents.
- Source: D9 (P6: the NIK is masked, and a KTP's doc_number is the NIK); D15 (personal data). Added for DOC-Q4.
R-AUD-13 · Audit rows written in one transaction share that transaction's id
Section titled “R-AUD-13 · Audit rows written in one transaction share that transaction's id”- Status: built
- Example: given a booking that writes the rental, the contract and the car's status in one call, when the audit rows are read, then all three carry the same transaction id, so a change and everything it triggered can be read together.
- Refusal: none.
- Who: every watched table.
- Source: #144 (audit log: how to log a change that triggers other modules).
R-AUD-14 · An action that changes many rows is one entry in the activity log, which opens to every row it changed
Section titled “R-AUD-14 · An action that changes many rows is one entry in the activity log, which opens to every row it changed”- Status: planned
- Example: given a pricing group's rate change that starts new rental rows for 40 active rentals in one call (R-RNT-09), when the activity log is read, then it lists one entry for that change; opening it shows the 40 rentals and the rows they changed.
- Refusal: none.
- Who: the activity log page (M7) and whatever reads it. The entries are grouped by the transaction id every audit row carries (R-AUD-13).
- Source: D52 (OQ5: a bulk change happened once, so it is listed once).
R-AUD-15 · The migration's bulk load writes one "migrated" entry per table and run, not an audit row per migrated row
Section titled “R-AUD-15 · The migration's bulk load writes one "migrated" entry per table and run, not an audit row per migrated row”- Status: built
- Example: given a rehearsal that loads 12,400 drivers, when the audit log is read afterwards, then it holds one "migrated" entry for drivers with that run's id and the count 12,400, and no audit row for any single driver; each driver traces back to v1 through its legacy id and the id map.
- Refusal: none.
- Who: the migration machinery (data phase row 4).
- Source: D52.
R-AUD-16 · The audit triggers are off during the migration's load only, and back on before its reconcile, even when the run fails
Section titled “R-AUD-16 · The audit triggers are off during the migration's load only, and back on before its reconcile, even when the run fails”- Status: built
- Example: given a rehearsal whose vehicles step fails halfway, when it stops, then the audit triggers are on again; on a run that succeeds they are on again before the reconcile starts, and the next app change writes its audit row.
- Refusal: none.
- Who: the migration machinery (data phase row 4).
- Source: D52 (a run that fails leaves the triggers on).