f2a12f9fed
v0.4 (Operator Tier — Cohort Dashboard + Auth + Postgres) milestone complete. Phases: ✓ P0 pre-execution (planning) → v0.1.6 ✓ P1 operator foundation (Postgres+auth+VC migration) → v0.1.7 ✓ P2 cohort dashboard + aggregation → v0.1.8 ✓ P3 final review + ship → v0.1.9 (= v0.4 milestone release) Requirements covered (8/8): REQ-MT-01 (Postgres store), REQ-MT-02 (aggregation pipeline), REQ-AUTH-01 (operator auth), REQ-DASH-01 (cohort dashboard), REQ-NFR-AUTH-01 (auth NFRs), REQ-NFR-MT-01 (Postgres-in-LXC), REQ-NFR-DASH-01 (k-anonymity ≥10), REQ-NFR-DASH-02 (freshness ≤24h) Grill MUSTs honored (6/6): G-008, G-011, G-027, G-031, G-038, G-041 Tests: 317 pytest pass, 36 skip (Postgres-requiring), 0 fail; 17/17 vitest pass Review: APPROVE_WITH_NOTES (6/6 personas, 0 P0, 8 P1+ carry-forward) Audit: HEALTHY (reconstruction PASS, 8/8 REQ, 6/6 grill) ---ci--- project: praxis phase: 3 milestone: v0.4 status: complete phase_role: final milestone_complete: true milestone_merged_to_main: true tag: v0.1.9 requirements: covered: [REQ-MT-01, REQ-MT-02, REQ-AUTH-01, REQ-DASH-01, REQ-NFR-AUTH-01, REQ-NFR-MT-01, REQ-NFR-DASH-01, REQ-NFR-DASH-02] partial: [] ---/ci---
71 lines
2.8 KiB
SQL
71 lines
2.8 KiB
SQL
-- Praxis v0.4 operator-tier Postgres schema (reference).
|
|
-- Applied in order by db/pg_migrate.py via db/pg_migrations/*.sql.
|
|
-- The canonical migration is 0001_operator_tier.sql; this file is the
|
|
-- human-readable reference (kept in sync). Uses gen_random_uuid() which
|
|
-- is in PG16 core (no extension needed — R-MT-05 verified).
|
|
--
|
|
-- Tables:
|
|
-- operators — operator accounts (argon2id password hash)
|
|
-- issued_credentials — VC issuance log (learner_ref is opaque, no FK)
|
|
-- mastery_gate_events — mastery gate audit log (REQ-NFR-MAST-02)
|
|
-- cohort_aggregates — k-anonymized cohort metrics (plain table, D-050)
|
|
-- issuer_keys — Ed25519 issuer key lifecycle (active/superseded)
|
|
--
|
|
-- No cross-DB FKs (D-031). learner_ref is an opaque string in Postgres.
|
|
|
|
CREATE TABLE IF NOT EXISTS operators (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
username TEXT UNIQUE NOT NULL,
|
|
password_hash TEXT NOT NULL,
|
|
display_name TEXT,
|
|
role TEXT NOT NULL DEFAULT 'operator',
|
|
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
last_login_at TIMESTAMPTZ
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS issued_credentials (
|
|
id UUID PRIMARY KEY,
|
|
operator_id UUID REFERENCES operators(id),
|
|
learner_ref TEXT NOT NULL,
|
|
vc_type TEXT,
|
|
payload_jsonb JSONB NOT NULL,
|
|
signature_b64 TEXT NOT NULL,
|
|
status TEXT NOT NULL DEFAULT 'active',
|
|
issued_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
revoked_at TIMESTAMPTZ
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS mastery_gate_events (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
learner_ref TEXT NOT NULL,
|
|
scenario_id TEXT,
|
|
path_id TEXT NOT NULL,
|
|
gate_outcome TEXT,
|
|
rubric_scores_jsonb JSONB,
|
|
recorded_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
source TEXT NOT NULL DEFAULT 'sync'
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS cohort_aggregates (
|
|
path TEXT NOT NULL,
|
|
metric TEXT NOT NULL,
|
|
window_start DATE NOT NULL,
|
|
window_end DATE NOT NULL,
|
|
value NUMERIC,
|
|
cell_count INTEGER NOT NULL DEFAULT 0,
|
|
cell_suppressed BOOLEAN NOT NULL DEFAULT FALSE,
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
PRIMARY KEY (path, metric, window_start)
|
|
);
|
|
-- Plain table, NOT partitioned (D-050..D-053; add partitioning post-pilot).
|
|
CREATE INDEX IF NOT EXISTS cohort_aggregates_path_window_idx
|
|
ON cohort_aggregates (path, window_start);
|
|
|
|
CREATE TABLE IF NOT EXISTS issuer_keys (
|
|
id TEXT PRIMARY KEY,
|
|
public_key TEXT NOT NULL,
|
|
private_key_enc BYTEA,
|
|
status TEXT NOT NULL DEFAULT 'active',
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
); |