Shield

PostgreSQL Store

Production-grade PostgreSQL store with automatic migrations.

The store/postgres package implements Shield's store.Store interface using the grove ORM with the PostgreSQL driver. It provides full support for all 11 Shield subsystems with automatic schema migrations managed by the grove orchestrator.

Usage

import (
    "context"
    "log"

    "github.com/xraph/grove"
    "github.com/xraph/grove/drivers/pgdriver"
    "github.com/xraph/shield/store/postgres"
)

db, err := grove.Open(pgdriver.Open("postgres://user:pass@localhost:5432/shield"))
if err != nil {
    log.Fatal(err)
}

s := postgres.New(db)
if err := s.Migrate(context.Background()); err != nil {
    log.Fatal(err)
}

Tables

TableSubsystemPurpose
shield_instinctsinstinctBuilt-in safety rules and threat patterns
shield_awarenessawarenessContext-aware detection configurations
shield_boundariesboundaryInput/output boundary enforcement rules
shield_valuesvaluesValue-alignment rule definitions
shield_judgmentsjudgmentContent evaluation and scoring rules
shield_reflexesreflexAutomatic response and action triggers
shield_profilesprofileComposite safety profile configurations
shield_scansscanContent scan results and audit log
shield_policiespolicyOrganizational safety policy definitions
shield_policy_tenantspolicyPolicy-to-tenant assignment mappings
shield_pii_tokenspiiTokenized PII storage for redaction/recovery
shield_compliance_reportscomplianceGenerated compliance audit reports

Internals

AspectDetail
Drivergrove ORM + pgdriver
Migrationsgrove orchestrator with programmatic migrations
TransactionsPostgreSQL-level transactions
ConcurrencyFull MVCC with concurrent readers and writers

When to use

  • Production deployments requiring ACID guarantees and high concurrency.
  • Multi-tenant environments with complex query patterns.
  • Teams already running PostgreSQL in their infrastructure.

On this page