Trailproof Class
TheTrailproof class is the main entry point. It manages the hash chain, store, and optional signer.
Constructor
emit()
Record a new event in the audit trail.TrailEvent — the complete event with auto-generated fields.
Throws: ValidationError if required fields are missing or empty.
Behavior:
- Auto-generates
event_id(UUID v4) andtimestamp(ISO-8601 UTC) - Computes
hashusing the hash chain engine - Sets
prev_hashto the previous event’s hash (or genesis hash for the first event) - If a signing key is configured, computes and sets
signature - Appends the event to the store
query()
Search events with filters and pagination.QueryResult { events, next_cursor }.
All filters are optional. No filters returns all events up to limit. Filters use exact match except from_time and to_time which are range filters.
verify()
Walk the hash chain and check every event’s hash.VerifyResult { intact, total, broken }.
Empty chain returns { intact: true, total: 0, broken: [] }.
get_trace() / getTrace()
Get all events for a specific trace ID, ordered by timestamp.TrailEvent objects matching the trace ID, ordered by timestamp.