Skip to content

Add policy impact analysis against historical audit logs #53

@haasonsaas

Description

@haasonsaas

Context

Formal.ai offers policy backtesting against 31 days of real traffic — operators can see what a proposed policy would have done before activating it. This removes the fear of deploying a policy that breaks production queries. Gate already stores audit events with statement, query_type, username, and resource — the raw materials exist.

Proposal

Build a policy simulation/backtesting feature:

  • API endpoint: POST /api/v1/policies/{id}/simulate with time range parameter
  • Engine: replay historical audit log entries through a candidate policy (draft or dry_run state)
  • Output: summary of what the policy would have done:
    • Total queries evaluated
    • Queries that would have been allowed / blocked / masked
    • Top blocked queries (with statement preview)
    • Affected users and resources
  • Admin UI: visual report showing the impact analysis before promotion to active
  • Leverage existing Postgres audit log — no new data pipeline needed

Acceptance Criteria

  • Simulate endpoint replays audit logs through a candidate policy
  • Returns summary with allow/block/mask counts and top affected queries
  • Works for draft and dry_run policies
  • Admin UI shows impact report with promote/discard actions
  • Configurable time range (last 1h, 24h, 7d, 30d)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions