⚒️ PostgreSQL Schema Design — Federation Data Layer
DITEMPA BUKAN DIBERI — Forged, Not Given.
Purpose
Design and maintain PostgreSQL schemas for the federation: capability registry, organ pulse history, drift detection, witness receipts, session state, cooling ledger entries.
When to Use
- Designing new tables or migrations for arifOS, AAA, GEOX, WEALTH, WELL Postgres backends
- Schema for capability registry (tool manifest storage)
- Pulse history tables (organ health time series)
- Drift detection storage (source ↔ runtime comparison snapshots)
- Witness receipt tables (tri-witness evidence logs)
When NOT to Use
- Vector/semantic search — use
redis-qdrant-integration
- Immutable append-only ledger — use
vault999-witness
- Caching layer — use
redis-qdrant-integration
- Frontend state — use
react-spa-discipline
Constitutional Floor Alignment
| Floor |
Application |
| F1 AMANAH |
All schema changes via migration files; never ALTER TABLE in production |
| F2 TRUTH |
Columns typed precisely (TIMESTAMPTZ, UUID, JSONB) — no varchar(255) laziness |
| F4 CLARITY |
Normalize to 3NF by default; only denormalize for measured query perf |
| F11 AUDIT |
Every table has created_at, updated_at, actor_id audit columns |
| F13 SOVEREIGN |
Schema drops require 888_HOLD — data is civilizational memory |
Commands & Patterns
-- Capability registry table pattern
CREATE TABLE capability_registry (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
organ_id TEXT NOT NULL REFERENCES organs(id),
tool_name TEXT NOT NULL,
schema_json JSONB NOT NULL,
status TEXT NOT NULL DEFAULT 'active',
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
actor_id TEXT NOT NULL
);
-- Pulse history (time-series)
CREATE TABLE organ_pulses (
id BIGSERIAL PRIMARY KEY,
organ_id TEXT NOT NULL,
status TEXT NOT NULL,
latency_ms INTEGER,
payload JSONB,
sampled_at TIMESTAMPTZ NOT NULL DEFAULT now()
) PARTITION BY RANGE (sampled_at);
-- Migration pattern — always reversible
-- V001__create_capability_registry.sql
-- V002__add_organ_pulses.sql
Refusal Surface
- ❌
SELECT * in production queries — always name columns
- ❌ Schema changes without migration files
- ❌ Storing JSON when relational columns fit the data
- ❌ Missing indexes on foreign keys and
sampled_at columns
- ❌
DROP COLUMN or DROP TABLE without 888_HOLD
1---2id: FORGE-postgres-schema-design3name: forge-postgres-schema-design4version: 1.0.0-2026.07.175description: "PostgreSQL schema design for the federation data layer — migrations, indexing, and entity modeling."6owner: A-FORGE7risk_tier: high8floor_scope: ['F1', 'F4', 'F11', 'F12']9autonomy_tier: T210capability_tier: fed-reasoning-heavy11ecology_state: WARM12---1314# ⚒️ PostgreSQL Schema Design — Federation Data Layer1516> **DITEMPA BUKAN DIBERI** — Forged, Not Given.1718## Purpose19Design and maintain PostgreSQL schemas for the federation: capability registry, organ pulse history, drift detection, witness receipts, session state, cooling ledger entries.2021## When to Use22- Designing new tables or migrations for arifOS, AAA, GEOX, WEALTH, WELL Postgres backends23- Schema for capability registry (tool manifest storage)24- Pulse history tables (organ health time series)25- Drift detection storage (source ↔ runtime comparison snapshots)26- Witness receipt tables (tri-witness evidence logs)2728## When NOT to Use29- Vector/semantic search — use `redis-qdrant-integration`30- Immutable append-only ledger — use `vault999-witness`31- Caching layer — use `redis-qdrant-integration`32- Frontend state — use `react-spa-discipline`3334## Constitutional Floor Alignment3536| Floor | Application |37|-------|-------------|38| F1 AMANAH | All schema changes via migration files; never `ALTER TABLE` in production |39| F2 TRUTH | Columns typed precisely (TIMESTAMPTZ, UUID, JSONB) — no varchar(255) laziness |40| F4 CLARITY | Normalize to 3NF by default; only denormalize for measured query perf |41| F11 AUDIT | Every table has `created_at`, `updated_at`, `actor_id` audit columns |42| F13 SOVEREIGN | Schema drops require 888_HOLD — data is civilizational memory |4344## Commands & Patterns4546```sql47-- Capability registry table pattern48CREATE TABLE capability_registry (49 id UUID PRIMARY KEY DEFAULT gen_random_uuid(),50 organ_id TEXT NOT NULL REFERENCES organs(id),51 tool_name TEXT NOT NULL,52 schema_json JSONB NOT NULL,53 status TEXT NOT NULL DEFAULT 'active',54 created_at TIMESTAMPTZ NOT NULL DEFAULT now(),55 updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),56 actor_id TEXT NOT NULL57);5859-- Pulse history (time-series)60CREATE TABLE organ_pulses (61 id BIGSERIAL PRIMARY KEY,62 organ_id TEXT NOT NULL,63 status TEXT NOT NULL,64 latency_ms INTEGER,65 payload JSONB,66 sampled_at TIMESTAMPTZ NOT NULL DEFAULT now()67) PARTITION BY RANGE (sampled_at);6869-- Migration pattern — always reversible70-- V001__create_capability_registry.sql71-- V002__add_organ_pulses.sql72```7374## Refusal Surface75- ❌ `SELECT *` in production queries — always name columns76- ❌ Schema changes without migration files77- ❌ Storing JSON when relational columns fit the data78- ❌ Missing indexes on foreign keys and `sampled_at` columns79- ❌ `DROP COLUMN` or `DROP TABLE` without 888_HOLD