Audit ledger

Every settled request writes one ledger entry. Entries are linked by hash, so changing, deleting or reordering a past entry is detectable.

What an entry contains

FieldMeaning
seq, id, timestampPosition, identifier and time.
account_idThe tenant account the request belongs to.
type, statusWhat happened (for example a completion, an input block, an output block, a refusal) and the outcome.
model, classifier, categoryThe model route, the input classifier and the risk category, if any.
prompt_tokens, completion_tokensToken counts.
amount_usd, credits_after_usdSettlement amounts.
policy_sha256The policy that made the decision.
prev_hash, entry_hashThe chain: each entry’s hash covers its content and the previous entry’s hash.
No text

There is no column for prompt or completion text. The ledger cannot be used to reconstruct a conversation, which is what lets it be kept for audit without becoming a store of personal data.

Verifying the chain

GET /api/audit/verify

200  {"valid": true, "head_hash": "…", "active_policy_sha256": "…", …}
409  {"valid": false, "broken_at_seq": 3, "reason": "entry_hash_mismatch"}

A 200 returns the head hash of the chain. Store it somewhere the gateway’s operator cannot rewrite (a separate system, a signed note, a customer’s own record); a later verification must reproduce it or extend it. A 409 names the first position where the chain breaks.

What this proves and what it does not

  • It makes silent alteration of past entries detectable, provided you have kept an earlier head hash outside the system.
  • It does not prove that every request was logged if the gateway was bypassed, and it does not sign entries with a key; anchoring the head hash externally is how you close that gap.
  • Retention, access control and backup of the database are the operator’s responsibility.