Skip to content

[Python] Audit log data model and storage (read/write _fd5_audit_log) #162

@gerchowl

Description

@gerchowl

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corefd5 core libraryaudit-trailAudit trail / provenance chain featureeffort:medium1-4 hoursfeatureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions