Skip to content

Backend: Persist write-ahead audit log entries to Prisma for multi-instance durability #856

Description

@Junirezz

Context

writeAheadAuditLog.ts implements prepare/commit/rollback semantics for admin configuration changes (Issue #707). Entries are stored in a process-local array capped at 10,000 records.

Problem / Gap

Write-ahead audit entries are lost on restart and are invisible to peer instances in multi-pod deployments. Operators cannot reconstruct partial config changes after a crash between prepare and commit.

Proposed approach

  • Add a Prisma model for write-ahead audit entries with status, snapshots, and request ID.
  • Replace the in-memory store with a repository that falls back to memory only in test mode.
  • Expose existing admin list/rollback endpoints against persisted data.
  • Add retention cleanup aligned with admin audit log policy.

Acceptance criteria

  • WAL entries survive process restart and are queryable from any backend instance.
  • Pending entries older than a configurable TTL are surfaced in admin metrics and can be rolled back.
  • Unit and integration tests cover prepare/commit/rollback against Prisma.
  • No breaking changes to existing WAL HTTP response shapes.

Files/areas affected

  • backend/src/writeAheadAuditLog.ts
  • backend/prisma/schema.prisma
  • backend/src/index.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions