Skip to content

P2 F6.1a: persist PEP decisions in a tenant-scoped audit chain #232

Description

@gnanirahulnutakki

Goal

Persist the existing privacy-minimized PEP decision events as a tenant-scoped, append-only, hash-chained PostgreSQL journal, so current reads and typed proposals no longer rely only on process logs for audit durability.

Parent: #24 (E6 F6.1/F6.3 foundation)
Depends on: #230 / PR #231

Scope

  • Add a versioned canonical audit-entry envelope for the current PEP decision event only.
  • Store one strictly ordered sequence and SHA-256 chain per workspace.
  • Serialize concurrent appends by locking a per-workspace chain head in the same transaction as entry insertion and head advancement.
  • Enforce workspace RLS and transaction-local scope on entries and heads.
  • Deny the application role UPDATE/DELETE privileges on immutable entries.
  • Verify sequence continuity, previous hashes, canonical entry hashes, and retained-head agreement.
  • Wire the durable sink into the hub PEP so append failure continues to fail closed before an operation runs.
  • Preserve the existing secret-minimizing boundary: no credentials, tokens, raw arguments, selectors, targets, result data, database URLs, or binding digests in journal entries.

Acceptance criteria

  • Every current PEP decision that returns from the hub enforcement path is durably appended before an allowed operation can proceed.
  • Concurrent appends in one workspace cannot fork or reuse a sequence number.
  • Different workspaces remain independently ordered and RLS-isolated.
  • The application role can insert/select required rows but cannot update or delete immutable audit entries.
  • Verification detects mutation, deletion, reordering, a broken previous-hash link, a forged entry hash, and head mismatch.
  • An unavailable or rejected audit write fails the PEP closed.
  • PostgreSQL integration tests prove append, concurrency, RLS, privilege, and tamper-detection behavior.
  • Unit/race/fuzz tests and the repository CI/release snapshot pass.
  • README is reviewed and updated only if the operator-facing contract changes.

Non-goals / honest claim boundary

This slice does not complete F6.1 or F6.3. It does not add action lifecycle phases, intent-id correlation, the Ardur decision ledger, query/export APIs, retention, WORM media, external timestamping, or externally signed checkpoints. A database owner could still replace the entire chain and head; externally anchored integrity is a later F6.3 slice.

It grants no write/action authority, credential access, network connector, shell, filesystem, dispatch, approval, or execution capability.

Security and reliability design

  • OWASP recommends separate audit records, restrictive database command permissions, sensitive-data minimization, interaction identifiers, and tamper detection.
  • PostgreSQL row locks serialize writers to the same head until transaction end; append and head advancement must be atomic.
  • RLS is defense in depth, not a substitute for table privileges; immutable-entry UPDATE/DELETE must be revoked from the application role.
  • The per-workspace head is mutable coordination state; the event history is immutable.

Cost / operability

Each policy decision adds one short database transaction and serializes within its workspace. This can become a hot-workspace bottleneck at high decision volume. Storage grows linearly; retention, archival, integrity-check metrics, and anchored checkpoints are deliberately deferred and must be designed before production-scale rollout.

Primary sources

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature / child issuegovernancePDP / audit / decision-ledger / tenancyphase-2Phase 2: first governed writesecuritySecurity hardening / isolation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions