#2001·astrid

feat(audit): retention that never deletes history that has not been anchored

Author: MastaPCreated Sep 28, 2026Updated Sep 28, 2026

Summary

Make audit retention aware of external anchoring, so history that has not been anchored and exported is never deleted.

Motivation

Pruning deletes entries permanently. What remains is a receipt signed with the same runtime key, and only the latest receipt per chain is kept. Automatic pruning runs when the global cap is reached (crates/astrid-audit/src/storage/global.rs:5,7: 1,000,000 entries / 1 GiB). An operator, or the automatic cap, can therefore erase history that no external party has seen. #1542 shows retention is needed; it must not become a way to erase unwitnessed history.

Proposed Implementation

  • Anchored watermark: record, per chain, the position up to which the log has been externally anchored, for example via an admin audit.anchor_receipt call from the anchoring service that stores the certification as evidence.
  • Pruning rules:
    • pruning never passes the watermark;
    • the automatic cap alarms rather than deleting unanchored entries;
    • an optional archive-then-drop step exports pruned segments first.
  • Prune receipts: keep every receipt (not only the latest) and include them in audit.export, so a verifier can connect retained entries to the anchored history.

Alternatives Considered

  • Leave retention anchor-agnostic and rely on the anchoring service to anchor often. This still loses any entries pruned between anchors, and it ties durability to that service's uptime.

Part of #1997.