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
+57
View File
@@ -10414,3 +10414,60 @@ command, and another unique session activation expiring four hours ahead. No
credential values, credential file, remote URL change or credential-store change
are included in the repository; temporary helpers stay in ignored build output.
No deployment or live-reachability claim follows from publication.
## 2026-10-27 - Read-only admin portal (ADR-0182 step 1, schema 61)
Scope: ADR-0182's read-only first step. `evo-admin-api` (Keycloak realm role
`aevolution-admin`, audience `aevolution-admin`, client `aevolution-admin-portal`) serves
the static portal and read-only JSON for world 100; schema 61 adds three bounded
SECURITY DEFINER read functions; the cellular region's ops port gains `/admin/view`.
The token verifier gains an optional realm-role rule and returns the email; the ops
server's response bound becomes configurable (default unchanged). No simulation rule,
checkpoint, manifest, wire protocol, genome or golden changed; `extent_of` reads the
existing phenotype budget.
Also fixed a pre-existing PostgreSQL failure (`region store test line 826`, also seen in
Gitea run 542): since 054e485 the DEV revamp tuning file seeds 100 wildlife, which
`evo-world-clone provision` refuses without an audited `--playtest-wildlife-first-id`
range. The cellular-v10 provisioning test now provisions the Git file's rules with its
DEV opening fixture set to zero; seeded wildlife keeps its own suite. Earlier push builds
skipped the PostgreSQL gate, and the 09:00 nightly (run 539) stopped at the format check,
so the failure had not surfaced.
Executed (WSL Ubuntu, GCC 14.2 Release/NDEBUG, existing build/m97-postgres with network,
QUIC and PostgreSQL):
- Built evo-server, evo-world-clone, evo-grant-broker, evo-admin-api, evo-postgres-tests
and evo-cellular-admin-view-tests with -Werror (two missing-field-initializer errors
from the new aggregate members were fixed with default initializers).
- `cellular-admin-view-contracts` passed: header, totals, every cell row (id strings,
account text, position, extent, connected flag, members), the cell and deposit limits
keeping the lowest ids, empty lists, and an unchanged owner snapshot after rendering.
- `tools/ci/postgres-check.sh --suite-only` passed after the fixes above: token role
checks (required role present, absent, wrong shape; email), the admin API over world
9831 (public files with CSP/nosniff headers, `/config.json`, 405 for POST, 401 without or
with a foreign token, 403 without the role, no database contact before verification,
accounts with session/status/lives/resets, one account, 404s, regions, the view cache,
unviewable and unreachable regions, an offline database as 503, and the runtime role
still refused direct table reads), the migration path to schema 61 with the privilege
audit's new fenced functions, and the updated migration history expectation.
- `tools/ci/postgres-check.sh --full` passed (634 s: suite, migration partitions, life
reservations, backup, DR, upgrade, migration history, permission audit, checksum drift).
Two CI scripts that pin the newest schema were updated: history-domain-check's schema-50
rewind now drops the three schema-61 functions first, and the unknown-future-version
probe moves from 61 to 62.
- clang-tidy 19 with warnings as errors on every new or changed source passed after one
unchecked-optional fix in the view test; clang-format 19.1.5 applied to changed C++.
- Deploy suite (deploy-policy-check 80 objects / 150 rendered in 17 overlays, selftest,
ops-lib-check) passed with the new admin-portal-dev component.
- Local process smoke of the built evo-admin-api with the realm's pinned JWKS and a
placeholder (unreachable) database: `/`, `/app.js`, `/style.css`, `/config.json`,
`/healthz` answered 200 with the expected types and security headers, `/api/accounts`
401 for a malformed token, `/missing` 404; no arguments exit 2 with usage.
- `node --check` on the portal script.
Limits: no Keycloak sign-in, browser session or live region view was exercised (the
Keycloak client, Ingress, Secret and a new server image are not in place yet); account
lives and deaths were checked only on accounts without lives. The MSVC and sanitizer
presets and the image build/smoke were not run locally. Nothing was deployed, pushed or
synced; no World0, stage or live database operation occurred.