Module Audit_log.Writer

Append-only writer. One per directory; not thread-safe, so the daemon owns exactly one and calls it from the single dispatcher fiber.

type t
val open_ : string -> (t, string) Stdlib.result

open_ dir opens today's file in dir, creating the directory if absent.

Opens O_APPEND | O_CREAT and mode 0o600 — never O_TRUNC. An existing file is continued: the sequence counter and chain head are recovered by reading it, so a restart extends the chain rather than starting a new one.

val append : t -> ?sync:bool -> Audit_record.t -> (unit, string) Stdlib.result

Append one record, assigning its seq. fsyncs before returning when sync is true, which the daemon sets for control actions.

val close : t -> unit
val last_seq : t -> int64

Sequence number of the last record written. 0L on an empty log.

val head_hash : t -> string

Current chain head, hex. This is the value to anchor out of band.

val path : t -> string