Skip to content

Export audit-trail tables to a dedicated folder before a destructive Reset #249

Description

@DutchJaFO

Background

Filed while planning #151 (ADR 014). #156 proposes that Reset stop selectively preserving any table
and instead drop the entire database and rebuild it in one step from the fresh-database baseline
script — the same path a brand-new install uses. That means, once #156 ships, a Reset will empty the
audit-trail tables (System_AuditEntries, System_ImportConflicts, System_ImportActions,
System_ChangeLog) completely, not just rows referencing entities that later changed id. Today these
four tables are excluded from Reset's drop list and survive it unconditionally — #156 removes that
survival entirely.

ADR 014 accepts this loss as the correct behaviour for Reset itself (Reset becomes, by design, "start
over completely"), on the condition that an operator who wants to keep the audit trail has a way to
do so first.
This issue is that export mechanism — a genuine functional gap, not yet designed or
implemented.

What needs to be done

Design and implement an export step that writes the current contents of the four audit-trail tables
to a dedicated audit-history folder before a destructive Reset proceeds. Open design questions to
resolve during planning, not decided here:

  • Trigger: either the export runs automatically and unconditionally as the first step of every
    Reset (before the backup DropAndRebuildAsync already takes), or it is a separate, standalone admin
    action the operator invokes beforehand. Not open for design: a request parameter letting the caller
    opt in/out of the export on a single Reset call.
    Per CLAUDE.md's "Endpoint side-effect policy
    (Single Responsibility)" (added while planning Should System_-prefixed provenance tables purge rows referencing Reset-wiped entities? #151/ADR 014), an endpoint must never grow a flag that
    changes what data survives the call — the choice is between "always happens" (a capture step, not a
    data-retention decision, so it doesn't violate the policy) and "a fully separate action," not a
    toggle on Reset itself.
  • Format and location: what "a dedicated audit-history folder" means operationally — likely
    alongside the existing backup file mechanism (CreateBackup in DatabaseInitializer.cs) rather than
    a new persistence concept. Decide the file format (e.g. one JSON file per table, timestamped) and
    exact path under the data directory.
  • Retention/pruning: an exported audit-history dump on every Reset could accumulate unbounded on a
    long-lived homelab install, similar to the pruning concern already raised in Import-table naming standardization + general import-file content provenance (FileResource / FileResourceLine) #227 for a different
    table. Decide whether this needs its own retention policy from day one or can defer.
  • Scope of the four tables: confirm all four (System_AuditEntries, System_ImportConflicts,
    System_ImportActions, System_ChangeLog) export the same way, or whether any has a reason to be
    handled differently.

Dependency

Release gate on #156, not an implementation-order dependency. Per ADR 014, a tagged release must
never ship #156's destructive full-rebuild Reset without this export path already present in that same
release — but #249 and #156 can be designed, built, and merged in either order or in parallel.

Definition of done

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions