Parent: #161
Goal
Create fd5.audit module with AuditEntry dataclass and read/write functions for the _fd5_audit_log root attribute.
Spec
AuditEntry dataclass: parent_hash, timestamp (ISO-8601), author (dict with type/id/name), message, changes (list of dicts with action/path/attr/old/new)
read_audit_log(file: h5py.File) -> list[AuditEntry] — parse JSON from _fd5_audit_log attribute
append_audit_entry(file: h5py.File, entry: AuditEntry) — read existing log, append, write back as JSON
AuditEntry.to_dict() / AuditEntry.from_dict() for JSON serialization
- The
_fd5_audit_log attribute is a VarLenUnicode string (JSON array)
- NOT excluded from content_hash computation (tamper-evident)
TDD
- Test round-trip: write entry → read back → assert equal
- Test append to existing log
- Test empty log returns []
- Test malformed JSON raises clear error
- Test entry validation (required fields)
Parent: #161
Goal
Create
fd5.auditmodule withAuditEntrydataclass and read/write functions for the_fd5_audit_logroot attribute.Spec
AuditEntrydataclass:parent_hash,timestamp(ISO-8601),author(dict withtype/id/name),message,changes(list of dicts withaction/path/attr/old/new)read_audit_log(file: h5py.File) -> list[AuditEntry]— parse JSON from_fd5_audit_logattributeappend_audit_entry(file: h5py.File, entry: AuditEntry)— read existing log, append, write back as JSONAuditEntry.to_dict()/AuditEntry.from_dict()for JSON serialization_fd5_audit_logattribute is a VarLenUnicode string (JSON array)TDD