Storage

In-memory storage for development, PostgreSQL for production. Swap without code changes.

The SDK ships with two storage backends: in-memory (default) for development and PostgreSQL for production. Both implement the same interface, so you can swap between them without changing any application code.

In-Memory Storage (Default)

ts

Good for: Local development, unit and integration tests, single-process deployments, quick prototyping.

Not for: Production with multiple processes, data that must survive restarts, regulatory audit requirements, high-volume event logging.

PostgreSQL Storage

For production, use the PostgreSQL adapter. It persists agents and audit events to your database with automatic table creation.

ts

Note: The pg package is a peer dependency — it is not bundled with the SDK. Install it separately: npm install pg.

Auto-Migration

By default, autoMigrate: true runs CREATE TABLE IF NOT EXISTS on the first storage operation. Tables are only created if they don't already exist.

ts

Warning: Auto-migration has no schema versioning. It only creates tables — it does not run ALTER TABLE for schema changes. If the SDK schema evolves between versions, you must drop and recreate the tables or manage migrations externally.

Database Tables

The PostgreSQL adapter creates two tables. The default prefix is lua_gov.

{prefix}_agents

Registered agents with metadata, scores, and governance levels.

Columns: id, name, framework, owner, description, version, channels, tools, permissions, metadata, composite_score, governance_level, status, registered_at, updated_at

{prefix}_audit_events

Enforcement decisions, custom events, kill switch events, all audit log entries.

Columns: id, agent_id, event_type, outcome, severity, detail, policy_rule_id, created_at

Multi-Tenant with Table Prefix

Use the tablePrefix option to isolate tenants in a shared database. Each prefix gets its own set of tables.

ts

Tip: For full multi-tenant governance with RBAC, org management, and cross-tenant analytics, see the Enterprise package.

PgPoolLike Interface

The adapter accepts any object that implements the PgPoolLike interface. You are not locked into the pg package.

ts