Skip to main content
Control 5 guarantees that no tool action executes without an immutable audit trail committed first. Inside GovernanceGateway.execute() (src/gateway.ts):
  1. After identity, OWASP scanning, budget reservation, policy evaluation, and approval checks succeed, the gateway calls this.config.auditLedger.append({ phase: 'pre_execution', ... }).
  2. Only after append() resolves does the gateway call await executor(request).
  3. If auditLedger.append() throws AuditLedgerUnavailableError (for example, PostgreSQL is unreachable or readonly), executor(request) is never invoked and the reserved workflow budget is released cleanly in the catch block.

Database Engine Immutability (001_audit_ledger.sql)

The schema migration at db/migrations/001_audit_ledger.sql enforces append-only semantics directly in PostgreSQL:
  • Strict CHECK constraints on phase (pre_execution, post_execution, blocked, approval_transition, kill_switch), action_tier (read, propose, write), and decision (allow, require_approval, deny, executed, failed).
  • Trigger trg_audit_ledger_immutable (BEFORE UPDATE OR DELETE ON audit_ledger) invokes reject_audit_ledger_mutation(), raising a PostgreSQL exception (RAISE EXCEPTION 'audit_ledger is append-only: % operations are prohibited', TG_OP;).
  • PostgresAuditLedger.append() runs inside a transaction with LOCK TABLE audit_ledger IN SHARE ROW EXCLUSIVE MODE so sequence numbers (seq) and prev_hash -> entry_hash chains remain strictly linear under concurrent workers.

Hash Chain Computation & Verification

Every record computes its entry_hash from GENESIS_HASH ('0'.repeat(64)) forward via computeAuditEntryHash (src/audit-ledger.ts):
For long-term regulatory retention and SIEM export, the companion AWS & GCP Terraform modules provision WORM buckets (S3 Object Lock and GCS Retention Lock) with write-only runtime IAM permissions.