Skip to main content

Overview

The scans table stores scan execution records with compliance scores, mapping configurations, and score history for trend tracking.

Schema

ColumnTypeDescription
idUUID, PKUnique scan identifier
user_idUUID, FKOwner (from auth.uid())
policy_idUUID, FKPolicy scanned against
temporal_scalenumericTime scaling factor (1.0 or 24.0)
mapping_configjsonbColumn mappings (CSV column → schema field)
data_sourcetext'csv'
file_nametextOriginal uploaded file name
record_countintegerRows scanned (capped at 50K)
violation_countintegerTrue violation count (pre-cap)
compliance_scorenumericScore 0–100
statustext'pending', 'running', 'completed', 'failed'
created_attimestamptzTimestamp when scan was created
completed_attimestamptzTimestamp when scan completed
upload_idUUIDReference to in-memory upload store
mapping_idUUIDReference to in-memory mapping store
audit_idUUIDLogical audit session
audit_nametextUser-provided audit name
score_historyjsonbArray of score changes for compliance trend chart

Status Lifecycle

A scan progresses through the following statuses:
  1. pending — Scan has been created but not started
  2. running — Scan is currently executing
  3. completed — Scan finished successfully
  4. failed — Scan encountered an error

Mapping Config JSONB

The mapping_config field stores column mappings from the uploaded CSV to the expected schema fields.

Example Mapping Config

{
  "amount": "transaction_amount",
  "account": "account_id",
  "transaction_type": "type",
  "timestamp": "created_at"
}
This maps:
  • CSV column "transaction_amount" → schema field "amount"
  • CSV column "account_id" → schema field "account"
  • CSV column "type" → schema field "transaction_type"
  • CSV column "created_at" → schema field "timestamp"

Score History JSONB

The score_history field tracks compliance score changes over time, enabling trend visualization.

Example Score History

[
  {
    "score": 85.2,
    "timestamp": "2026-02-22T10:00:00Z",
    "action": "scan_completed",
    "violation_id": null
  },
  {
    "score": 87.1,
    "timestamp": "2026-02-22T10:05:00Z",
    "action": "false_positive",
    "violation_id": "abc-123"
  },
  {
    "score": 85.8,
    "timestamp": "2026-02-22T10:10:00Z",
    "action": "approved",
    "violation_id": "def-456"
  }
]

Score History Actions

ActionDescription
scan_completedInitial score after scan completes
false_positiveScore increased after dismissing a violation
approvedScore decreased after approving a violation
Why Track Score History?Score history enables compliance trend charts that show how the compliance score changes as users review violations. This provides visibility into whether the dataset is becoming more or less compliant over time.

Temporal Scaling

The temporal_scale field adjusts time-based calculations for known datasets:
  • 1.0 — Default scaling (1 hour = 1 hour)
  • 24.0 — For datasets where timestamps represent days instead of hours (e.g., IBM AML dataset)
The engine auto-detects known dataset formats and adjusts temporal_scale accordingly.

In-Memory References

The upload_id and mapping_id fields reference in-memory stores on the server, not database tables. CSV data and column mappings are kept in memory during the audit flow and are not persisted to the database.

Relationships

  • Foreign Key to auth.users — Each scan belongs to a user
  • Foreign Key to policies — Each scan evaluates one policy
  • One-to-Many with violations — Each scan produces multiple violations
  • One-to-Many with pii_findings — Each scan may have PII findings

Build docs developers (and LLMs) love