Hash chain vs WORM storage vs OpenTelemetry traces: making an LLM audit log tamper-evident
A hash chain detects edits to an LLM audit log, an append-only or WORM store refuses them, and OpenTelemetry traces explain behaviour. Compared on what each proves, who holds authority, erasure, and cost.
Drafted by an AI agent, from a research brief, primary sources and the Pleach docs; reviewed by a maintainer before publishing.
No @pleach/* package is on npm yet. Each name holds a 0.0.1 placeholder until its first release, so the code here describes the source, not an install that works today. Package status
A hash chain makes an LLM audit log tamper-evident, an append-only or WORM store makes it tamper-resistant, and OpenTelemetry traces make it explainable. Each rests on a different source of authority. A trace relies on the pipeline that collects it. A WORM store relies on whoever administers its permissions. A hash chain relies on arithmetic, plus an anchor held outside your system.
They answer different questions, so audit setups usually combine two. This post compares them on what each proves, who holds authority, erasure, and cost. For what goes in each row, see adding an audit ledger without rewriting your agent loop and reconstructing an agent decision for audit trail review.
The options side by side
| OpenTelemetry traces | Append-only DB table (triggers, grants) | WORM object storage (S3 Object Lock) | Hash chain with outside anchor | |
|---|---|---|---|---|
| Built for | Latency, errors, request flow | Refusing edits from application roles | Retaining objects unchanged for a set period | Letting a reviewer recompute the record |
| Integrity mechanism | Collection pipeline | Triggers and revoked grants | Retention mode on each object version | Each row hashes over its predecessor |
| Final authority | Trace backend operator | Table owner and superusers | Compliance mode: no user, including root, during retention | Holder of the anchor (timestamp authority or published head) |
| Edit handling | Records what was exported | Refuses at write time | Refuses at write time | Detects at verify time |
| Volume recorded | Sampled by design | Every row | Every locked version | Every row |
| Erasure approach | Delete the spans | Crypto-shred, or a guarded destroy path | Crypto-shred, or wait for retention to expire | Crypto-shred, or delete and re-root |
| Running cost | Exporter, collector, backend | Triggers and grants | Storage and retention | One hash per row, a verifier, an anchoring schedule |
These setups aren't like-for-like. A trace backend and a WORM bucket solve different problems, so the sections below compare them only on audit properties.
How do OpenTelemetry traces fit into an audit trail?
Traces explain what happened; an audit record attests to it, so the two run side by side. Traces are the right tool for latency, error rates, and following one request across services.
Sampling is how tracing pipelines control volume. The OpenTelemetry sampling docs call it "one of the most effective ways to reduce the costs of observability." They define "not sampled" as: "A trace or span is not processed or exported."
The same page names when not to sample. One listed case is being "bound by circumstances such as regulation that prohibit dropping data." An audit record of LLM calls usually falls there. So keep one unsampled row per call, and let traces carry the debugging detail around it.
What does an append-only or WORM store guarantee, and to whom?
An append-only store guarantees that actors below its permission boundary can't change a record. That's integrity by permission. It stops the common failures: an application bug or a leaked service key changing history.
A database table guarded by triggers
In PostgreSQL, a BEFORE row trigger can abort an UPDATE or DELETE. The CREATE TRIGGER docs note that TRUNCATE triggers fire "only FOR EACH STATEMENT," so a complete guard pairs row triggers with a statement-level trigger.
Ownership sits above the guard. The PostgreSQL privileges docs state that "the right to modify or destroy an object is inherent in being the object's owner, and cannot be granted or revoked in itself." Pair the table with a hash chain when reviewers need assurance that doesn't rest on the database administrator.
Object storage with S3 Object Lock
S3 Object Lock stores objects under a write-once-read-many model with two retention modes:
- Governance mode. Most users can't delete or overwrite a locked version, and a specially permissioned role can adjust retention. AWS suggests it for testing settings before using compliance mode.
- Compliance mode. A locked version "can't be overwritten or deleted by any user, including the root user." Its retention period can't be shortened.
A legal hold adds protection with no expiry date until someone removes it. AWS notes that Object Lock has been assessed for environments subject to SEC 17a-4, CFTC, and FINRA rules.
What regulators ask for
SEC Rule 17a-4(f)(2)(i) offers two alternatives for electronic records. Paragraph (B) is the classic WORM option: "Preserve the records exclusively in a non-rewriteable, non-erasable format." Paragraph (A) instead allows a complete, time-stamped audit trail of "all modifications to and deletions of the record," with enough information to re-create the original. A hash chain alone doesn't supply that: it shows a record changed, but re-creating the original needs the earlier version kept as well.
How does a hash chain make an audit log tamper-evident?
A hash chain lets a reviewer recompute the record instead of trusting it. Each row stores a hash over the previous row's hash and its own canonical content. A backfill, a reorder, or a removed row breaks a link, and a verifier reports where.
A hash chain is tamper-evident, not tamper-proof, so pair it with controls that tie it to something outside the writer:
- A recorded head. The verifier checks that the chain reaches a stored head, which covers the most recent rows.
- A keyed hash. An HMAC with a key held outside the database ties each hash to that key.
- An outside anchor. Send the chain head to a timestamp authority. RFC 3161 defines a service that "supports assertions of proof that a datum existed before a particular time." The authority time-stamps only "a hash representation of the datum," so log content never leaves your system.
Anchor on a schedule rather than only at audit time. Each anchor fixes a verifiable state, and an anchor only adds assurance once someone checks it.
Merkle logs: the same idea at internet scale
Certificate Transparency applies this idea to TLS certificates. RFC 6962 describes "publicly auditable, append-only, untrusted logs," and RFC 9162, which obsoletes it, defines each log as "a single, append-only Merkle Tree." Section 2.1.3 defines an inclusion proof, which shows a leaf exists in the tree. Section 2.1.4 states that "Merkle consistency proofs prove the append-only property of the tree."
Outside parties do the checking. RFC 9162 Section 8.3 says "auditing ensures that the current published state of a log is reachable from previously published states." Publishing a private log's heads where others can see them brings the same check to an audit trail.
How do you reconcile erasure with an immutable log?
Encrypt personal fields under a per-subject key and destroy the key on erasure. The ciphertext stays, so every hash still verifies and every WORM lock still holds.
The two requirements pull in different directions. GDPR Article 17 gives a data subject the right to erasure "without undue delay." A hash chain depends on every row staying in place, and compliance-mode Object Lock keeps each locked version until retention ends.
Key destruction has a name in sanitization guidance. NIST SP 800-88 Rev. 2 defines cryptographic erase as applying key sanitization to the keys protecting encrypted data, "making recovery of the decrypted target data infeasible." It notes that for cloud storage, cryptographic erase "may be the only viable purge sanitization technique option."
Article 17(3) also lists exemptions, including "compliance with a legal obligation" and "the establishment, exercise or defence of legal claims." Whether erasure applies depends on why you keep the log. Crypto-shredding works when the payload is encrypted at write time, so decide on it before the first row lands.
Traces have the simple case: delete the spans.
When to use each
- You need latency, error, and cross-service debugging: OpenTelemetry traces, sampled.
- You want application bugs and leaked keys unable to change history: an append-only table with triggers and revoked grants.
- A regulation requires non-rewriteable storage for a fixed period: WORM object storage in compliance mode, with crypto-shredding for personal data.
- A reviewer must verify the record without relying on your database administrator: a hash chain with a recorded head and scheduled outside anchoring.
- You're audited on LLM calls specifically: an unsampled per-call row, hash-chained, with traces alongside for debugging.
How Pleach does it
Pleach runs all three and doesn't treat them as rivals. Its WORM docs put it in one line: the chain detects an edit, WORM refuses it, so run both. Package status is on /docs/packages.
The hash chain
Each event-log row stores a hash, a SHA-256 over the previous row's hash and the canonical row, per the hash chain page. Writer-side stamping is on by default, and verifyChainForChat walks the chain and reports the first broken index.
- Recorded head. Pass
expectedHeadand the verifier refuses a chain that doesn't reach it. - Keyed chain. With a signing key, rows use HMAC-SHA256.
- Scheduled anchoring. An outside RFC 3161 timestamp authority signs the chain's merkle root.
verifyChainAnchorsre-derives the root from live rows and compares it.evaluateChainAnchorFreshnessgrades staleness.verifyRfc3161Receiptin@pleach/compliancechecks the token against pinned CA roots.
@pleach/recipes composes the verify-and-anchor pass as chainAnchorScheduler, with runOnce() and no loop, so the schedule stays yours.
The WORM tier
The opt-in WORM tier puts triggers on the event-log table that refuse UPDATE, DELETE, and TRUNCATE for every application role. It constrains application roles rather than the table owner, so pair it with the chain. Apply it with npx @pleach/core schema --apply --with worm; a host process that updates event-log rows will start failing once it's applied.
Erasure, the call ledger, and traces
GDPR erasure runs through crypto-shredding. executeErasureRequest destroys the per-subject key, seals a signed shred proof, and returns chainRebuilt: false. You supply the key registry from your own KMS; no reference implementation ships.
Each LLM call writes one AuditableCall row, with no sampling. Its own chain is opt-in with hashChain: true and verified by verifyAuditableCallChain. @pleach/core emits one llm.invocation span per call, matching the ledger row one to one. Core has no OpenTelemetry imports; you wire a small OtelExporter bridge, as shown on OTel spans.
The chain isn't access control; layer it on RLS, auth, TLS, and database-level immutability. Per-tenant retention scheduling stays host-side today, through the GDPRSoftDelete plug-point in the audit ledger.
Key takeaways
- Traces explain; an unsampled record attests. OpenTelemetry's docs treat sampling as a cost control and list data-retention regulation as a reason not to sample.
- Permission-based immutability has a final authority. In PostgreSQL that's the table owner; in S3 compliance mode no user, including root, can delete during retention.
- A hash chain is tamper-evident, not tamper-proof. Anchor its head on a schedule with an RFC 3161 authority or a published head.
- Crypto-shredding reconciles erasure with immutability. Destroying a per-subject key leaves hashes and locks intact, and NIST calls it cryptographic erase.
- Most audit setups combine two layers. One refuses edits, one detects them, and traces sit alongside for debugging.
References
- OpenTelemetry. Sampling.
- PostgreSQL Global Development Group. CREATE TRIGGER.
- PostgreSQL Global Development Group. Privileges.
- Amazon Web Services. Locking objects with Object Lock.
- U.S. Securities and Exchange Commission. 17 CFR 240.17a-4, Records to be preserved by certain exchange members, brokers and dealers.
- RFC 3161: Internet X.509 Public Key Infrastructure Time-Stamp Protocol (TSP). IETF, 2001.
- RFC 6962: Certificate Transparency. IETF, 2013.
- RFC 9162: Certificate Transparency Version 2.0. IETF.
- European Union. GDPR Article 17: Right to erasure.
- NIST. SP 800-88 Rev. 2: Guidelines for Media Sanitization. September 2025.
Frequently asked
How do you make an audit log of LLM calls tamper-evident?
Chain each row to the one before it with a hash, then anchor the chain outside your own control. Each row stores a hash over the previous row's hash and its own content, so an edited, reordered, or removed row breaks the link. An outside anchor, such as an RFC 3161 timestamp token over the chain head, lets a reviewer check the log against a state your own administrators can't change.
Is a hash-chained audit log tamper-proof?
No. A hash chain is tamper-evident, not tamper-proof: it detects changes rather than refusing them. Pair it with two things. Anchor the chain head on a schedule with a party outside your control, such as an RFC 3161 timestamp authority. Store the log behind a control that refuses edits, such as database triggers or WORM object storage. The chain and the guard together cover detection and prevention.
How do OpenTelemetry traces fit into an LLM audit trail?
Traces sit alongside the audit record, not in place of it. OpenTelemetry is built for latency, error, and cross-service debugging, and its docs describe sampling as one of the most effective ways to reduce observability cost. The same docs list regulation that prohibits dropping data as a reason not to sample. Keep an unsampled per-call record for audit and use traces to explain it.
What is the difference between a hash chain and a WORM store?
A WORM store refuses an edit when someone attempts it. A hash chain detects an edit after it happened. Database triggers apply to roles below the table owner, while S3 Object Lock in compliance mode applies to every user, including the account root user. A hash chain refuses nothing but lets any reviewer recompute the record. Many setups run both.
How do you handle GDPR erasure in an immutable audit log?
Use crypto-shredding. Write personal fields encrypted under a per-subject key, then destroy the key on erasure. The ciphertext stays, so the hash chain and any WORM lock stay intact. NIST SP 800-88 Rev. 2 calls this cryptographic erase. GDPR Article 17(3) also lists exemptions, such as a legal obligation to retain, so the right answer depends on why you keep the log.
How does Pleach make its LLM audit log tamper-evident?
Every event-log row stores the previous row's hash and its own hash, a SHA-256 over the previous hash and the canonical row. An opt-in WORM tier adds triggers that refuse UPDATE, DELETE, and TRUNCATE for application roles. Scheduled anchoring has an RFC 3161 timestamp authority sign the chain's merkle root. GDPR erasure runs through crypto-shredding with executeErasureRequest, which never rebuilds the chain.