feat(admin): read-only admin portal and API (ADR-0182 step 1, schema 61)

evo-admin-api serves the portal at srs.aeternalisgames.com and read-only JSON
for world 100 behind Keycloak (realm role aevolution-admin, audience
aevolution-admin, client aevolution-admin-portal): accounts with session,
status, lives, deaths, resets and mutation choices; one account's lives; the
world's regions; and a live 2D region view of cells, wildlife, pools and
bubbles. The portal is plain HTML/CSS/JS with PKCE sign-in, a strict CSP and
no third-party code.

- Schema 61: three bounded SECURITY DEFINER read functions, fenced in the
  privilege audit; no table or existing function changes.
- Cellular regions answer GET /admin/view on the ops port (NetworkPolicy:
  Prometheus and the admin portal only); CellularLives::extent_of reads the
  existing phenotype budget. No simulation, checkpoint or wire change.
- TokenVerifier takes an optional realm role and returns the email; the ops
  server's response bound is configurable (16 KiB default unchanged).
- DEV component admin-portal-dev (Deployment, Service, NetworkPolicies); the
  Ingress and the aevolution-admin-pg Secret are created out of band.
- CI scripts pinned to schema 60 now expect 61.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-27 12:39:28 -04:00
co-authored by Claude Opus 5.5
parent 46e5ea6c5d
commit 54beceb823
36 changed files with 2331 additions and 37 deletions
+15 -3
View File
@@ -136,6 +136,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
SELECT :'history_v57' || ',58:' || :'migration_sha_58' AS history_v58 \gset
SELECT :'history_v58' || ',59:' || :'migration_sha_59' AS history_v59 \gset
SELECT :'history_v59' || ',60:' || :'migration_sha_60' AS history_v60 \gset
SELECT :'history_v60' || ',61:' || :'migration_sha_61' AS history_v61 \gset
SELECT :'history' = :'history_v22' AS at_v22,
:'history' = :'history_v23' AS at_v23,
:'history' = :'history_v24' AS at_v24,
@@ -174,8 +175,10 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
:'history' = :'history_v57' AS at_v57,
:'history' = :'history_v58' AS at_v58,
:'history' = :'history_v59' AS at_v59,
:'history' = :'history_v60' AS at_v60 \gset
\if :at_v60
:'history' = :'history_v60' AS at_v60,
:'history' = :'history_v61' AS at_v61 \gset
\if :at_v61
\elif :at_v60
\elif :at_v59
\elif :at_v58
\elif :at_v57
@@ -589,7 +592,8 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
coalesce(max(version), 0) = 57 AS at_v57,
coalesce(max(version), 0) = 58 AS at_v58,
coalesce(max(version), 0) = 59 AS at_v59,
coalesce(max(version), 0) = 60 AS at_v60
coalesce(max(version), 0) = 60 AS at_v60,
coalesce(max(version), 0) = 61 AS at_v61
FROM evolution.schema_migrations \gset
\if :at_v24
\ir 0025_cellular_v2_bundle.sql
@@ -818,6 +822,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\elif :at_v58
\elif :at_v59
\elif :at_v60
\elif :at_v61
\else
\echo 'Unknown or changed migration history after v43'
DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$;
@@ -890,6 +895,10 @@ SELECT coalesce(max(version), 0) = 59 AS needs_v60 FROM evolution.schema_migrati
\if :needs_v60
\ir 0060_cellular_revamp_bundle.sql
\endif
SELECT coalesce(max(version), 0) = 60 AS needs_v61 FROM evolution.schema_migrations \gset
\if :needs_v61
\ir 0061_admin_read_views.sql
\endif
-- Effective-privilege audit on every run, including no-ops (ADR-0060). Attributes
-- alone are insufficient: predefined roles such as pg_write_all_data, PUBLIC
-- grants or SET-able memberships would bypass the fenced functions. Checks the
@@ -963,6 +972,9 @@ BEGIN
('evolution.load_cellular_mutation_publications(evolution.u64,evolution.u64,uuid,evolution.u64,uuid)'::regprocedure::oid),
('evolution.end_cellular_lives(evolution.u64,evolution.u64,uuid,evolution.u64,uuid,bytea)'::regprocedure::oid),
('evolution.issue_account_grant(evolution.u64,text,text)'::regprocedure::oid),
('evolution.admin_accounts_v1(evolution.u64)'::regprocedure::oid),
('evolution.admin_account_lives_v1(evolution.u64,uuid)'::regprocedure::oid),
('evolution.admin_regions_v1(evolution.u64)'::regprocedure::oid),
('evolution.revoke_account_grants(evolution.u64,text,text)'::regprocedure::oid),
('evolution.load_cellular_publication_actions(evolution.u64,evolution.u64,uuid,evolution.u64,uuid)'::regprocedure::oid),
('evolution.load_cellular_publication_births(evolution.u64,evolution.u64,uuid,evolution.u64,uuid)'::regprocedure::oid),