Skip to content

[Python] fd5 edit CLI command with audit logging #164

@gerchowl

Description

@gerchowl

Parent: #161

Goal

Add fd5 edit CLI subcommand that modifies an attribute and appends an audit log entry.

Spec

  • fd5 edit <file> <path>.<attr> <value> [--message MSG] [--in-place]
  • Default: copy-on-write (creates _edited.h5 copy)
  • --in-place: edit original file
  • --message/-m: commit message (optional, defaults to "Edit .")
  • Reads identity from ~/.fd5/identity.toml
  • Creates AuditEntry with: parent_hash, timestamp, author, message, changes
  • Appends entry to _fd5_audit_log, then recomputes content_hash

Flow

  1. Open file (copy or in-place)
  2. Read current content_hash → parent_hash
  3. Read current attribute value → old
  4. Write new attribute value
  5. Append AuditEntry to _fd5_audit_log
  6. Recompute and write content_hash

TDD

  • Test edit creates audit entry
  • Test edit preserves existing audit log entries
  • Test copy-on-write creates new file
  • Test in-place modifies original
  • Test message defaults
  • Test identity is recorded

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