feat(admin): live tuning revisions adopted at recorded ticks (schema 66)
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (checks) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 4m47s
Foundation / postgres-tools (push) Successful in 29s
Foundation / server-image (push) Successful in 4m42s
Foundation / image (push) Successful in 5m55s

ADR-0182 section 13. The admin portal's Tuning page edits the world's
rules-13 tuning (the Git revamp file format); the admin API checks it,
stores an append-only revision and queues an adopt_tuning admin command
(kind 7: revision and rules digest) for every region of the world.

- Lifecycle: adopt_tuning replaces the region's rules after births when
  a resolver names the rules for that revision and digest; the safety
  revision cannot change live. At most one adoption per batch.
- Host: fetches the revision text, rebuilds and digests the rules before
  appending the command; publication and recovery name the rules from
  the successor state, checked against the recorded digest.
- Schema 66: tuning_revisions, admin_set_tuning_v1, load_tuning_revision_v1
  (runtime), admin_tuning_revisions_v1, admin_tuning_text_v1.
- OpsServer: optional bounded request bodies (Content-Length, 413).
- Region view: rules_sha256, so the portal shows each region's revision.
- Portal: Tuning page; baseline from the mounted cellular-revamp.tuning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-27 19:35:09 -04:00
co-authored by Claude Opus 5.5
parent 7041c947a9
commit 7273b157d6
33 changed files with 1241 additions and 97 deletions
+21 -4
View File
@@ -141,6 +141,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
SELECT :'history_v62' || ',63:' || :'migration_sha_63' AS history_v63 \gset
SELECT :'history_v63' || ',64:' || :'migration_sha_64' AS history_v64 \gset
SELECT :'history_v64' || ',65:' || :'migration_sha_65' AS history_v65 \gset
SELECT :'history_v65' || ',66:' || :'migration_sha_66' AS history_v66 \gset
SELECT :'history' = :'history_v22' AS at_v22,
:'history' = :'history_v23' AS at_v23,
:'history' = :'history_v24' AS at_v24,
@@ -184,8 +185,10 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
:'history' = :'history_v62' AS at_v62,
:'history' = :'history_v63' AS at_v63,
:'history' = :'history_v64' AS at_v64,
:'history' = :'history_v65' AS at_v65 \gset
\if :at_v65
:'history' = :'history_v65' AS at_v65,
:'history' = :'history_v66' AS at_v66 \gset
\if :at_v66
\elif :at_v65
\elif :at_v64
\elif :at_v63
\elif :at_v62
@@ -609,7 +612,8 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
coalesce(max(version), 0) = 62 AS at_v62,
coalesce(max(version), 0) = 63 AS at_v63,
coalesce(max(version), 0) = 64 AS at_v64,
coalesce(max(version), 0) = 65 AS at_v65
coalesce(max(version), 0) = 65 AS at_v65,
coalesce(max(version), 0) = 66 AS at_v66
FROM evolution.schema_migrations \gset
\if :at_v24
\ir 0025_cellular_v2_bundle.sql
@@ -843,6 +847,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\elif :at_v63
\elif :at_v64
\elif :at_v65
\elif :at_v66
\else
\echo 'Unknown or changed migration history after v43'
DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$;
@@ -935,6 +940,10 @@ SELECT coalesce(max(version), 0) = 64 AS needs_v65 FROM evolution.schema_migrati
\if :needs_v65
\ir 0065_admin_schedules.sql
\endif
SELECT coalesce(max(version), 0) = 65 AS needs_v66 FROM evolution.schema_migrations \gset
\if :needs_v66
\ir 0066_tuning_revisions.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
@@ -1010,6 +1019,7 @@ BEGIN
('evolution.issue_account_grant(evolution.u64,text,text)'::regprocedure::oid),
('evolution.load_session_window_v1(evolution.u64,evolution.u64)'::regprocedure::oid),
('evolution.load_pending_admin_commands_v1(evolution.u64,evolution.u64)'::regprocedure::oid),
('evolution.load_tuning_revision_v1(evolution.u64,bigint)'::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),
@@ -1093,6 +1103,10 @@ GRANT EXECUTE ON FUNCTION evolution.admin_set_schedule_v1(evolution.u64, evoluti
integer, boolean, text, text) TO :"admin_role";
GRANT EXECUTE ON FUNCTION evolution.admin_schedules_v1(evolution.u64, evolution.u64)
TO :"admin_role";
GRANT EXECUTE ON FUNCTION evolution.admin_set_tuning_v1(evolution.u64, text, bytea, bigint[], text,
text) TO :"admin_role";
GRANT EXECUTE ON FUNCTION evolution.admin_tuning_revisions_v1(evolution.u64) TO :"admin_role";
GRANT EXECUTE ON FUNCTION evolution.admin_tuning_text_v1(evolution.u64, bigint) TO :"admin_role";
SELECT pg_catalog.set_config('evolution.admin_role', :'admin_role', true);
DO $$
DECLARE
@@ -1123,7 +1137,10 @@ BEGIN
('evolution.admin_account_status_v1(evolution.u64)'::regprocedure::oid),
('evolution.admin_account_bans_v1(uuid)'::regprocedure::oid),
('evolution.admin_set_schedule_v1(evolution.u64,evolution.u64,bigint,integer,integer,evolution.u64,evolution.u64,evolution.u64,evolution.u64,evolution.u64,integer,boolean,text,text)'::regprocedure::oid),
('evolution.admin_schedules_v1(evolution.u64,evolution.u64)'::regprocedure::oid)
('evolution.admin_schedules_v1(evolution.u64,evolution.u64)'::regprocedure::oid),
('evolution.admin_set_tuning_v1(evolution.u64,text,bytea,bigint[],text,text)'::regprocedure::oid),
('evolution.admin_tuning_revisions_v1(evolution.u64)'::regprocedure::oid),
('evolution.admin_tuning_text_v1(evolution.u64,bigint)'::regprocedure::oid)
), violations(reason) AS (
SELECT 'admin role is the runtime role' WHERE admin = runtime
UNION ALL