Cellular balance rules 6 (ADR-0132, schema v41)
Foundation / checks (checks) (push) Successful in 42m33s
Foundation / checks (deploy) (push) Successful in 4m11s
Foundation / checks (ecs) (push) Successful in 2m27s
Foundation / checks (network) (push) Successful in 19m23s
Foundation / checks (postgres) (push) Successful in 44m44s
Foundation / checks (tsan) (push) Successful in 9m53s
Foundation / checks (client) (push) Successful in 16m19s
Foundation / postgres-tools (push) Successful in 30s
Foundation / server-image (push) Successful in 3m14s
Foundation / image (push) Successful in 3m16s
Foundation / checks (checks) (push) Successful in 42m33s
Foundation / checks (deploy) (push) Successful in 4m11s
Foundation / checks (ecs) (push) Successful in 2m27s
Foundation / checks (network) (push) Successful in 19m23s
Foundation / checks (postgres) (push) Successful in 44m44s
Foundation / checks (tsan) (push) Successful in 9m53s
Foundation / checks (client) (push) Successful in 16m19s
Foundation / postgres-tools (push) Successful in 30s
Foundation / server-image (push) Successful in 3m14s
Foundation / image (push) Successful in 3m16s
The playtest found mutation offers the arena could never pay for. A mutation's matter cost is the real body difference (ADR-0118), so it cannot be discounted. Rules 6 cut it honestly: - genome schema 3 steps a third as far (1/300 of the range); - development version 3 charges a third of the construction energy (13 instead of 40 pJ per 1000 fg). Founder 2 uses both. The cellular-v5 opening creates rules-6 regions on bundle v7, which schema v41 admits. Existing lineages, regions and committed history are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
-- 2026-10-15 balance (ADR-0132): admit the cellular-v7 bundle (rules 6 on owner
|
||||
-- envelope 6, development 3, founder 2: a third of the mutation step and of the
|
||||
-- construction energy). It has no new trace or state layout; earlier bundles and committed
|
||||
-- rows keep their meaning.
|
||||
|
||||
-- The v7 bundle shares v3's revision history profile and format-3 traces. Normalize it
|
||||
-- to v3 for the existing parser chain, then report the real bundle.
|
||||
ALTER FUNCTION evolution.parse_checkpoint_manifest(bytea)
|
||||
RENAME TO parse_checkpoint_manifest_v40;
|
||||
|
||||
CREATE FUNCTION evolution.parse_checkpoint_manifest(m bytea)
|
||||
RETURNS evolution.checkpoint_manifest LANGUAGE plpgsql IMMUTABLE
|
||||
SET search_path = pg_catalog, pg_temp AS $$
|
||||
DECLARE
|
||||
r evolution.checkpoint_manifest;
|
||||
v3_bundle constant bytea := '\x020000000300000001000000010000000100000002000000010000000200000001000000';
|
||||
v7_bundle constant bytea := '\x060000000600000001000000010000000100000003000000020000000200000001000000';
|
||||
BEGIN
|
||||
IF m IS NOT NULL AND octet_length(m) = 360
|
||||
AND evolution.manifest_uint(m, 12, 4) = 4
|
||||
AND substring(m FROM 161 FOR 36) = v7_bundle
|
||||
AND evolution.manifest_uint(m, 228, 4) = 0
|
||||
AND evolution.manifest_uint(m, 232, 4) = 4
|
||||
AND evolution.manifest_uint(m, 236, 4) = 1 THEN
|
||||
r := evolution.parse_checkpoint_manifest_v40(overlay(m PLACING v3_bundle FROM 161 FOR 36));
|
||||
r.versions := v7_bundle;
|
||||
RETURN r;
|
||||
END IF;
|
||||
RETURN evolution.parse_checkpoint_manifest_v40(m);
|
||||
END $$;
|
||||
REVOKE ALL ON FUNCTION evolution.parse_checkpoint_manifest(bytea) FROM PUBLIC;
|
||||
|
||||
-- Birth binding: v3 to v7 publications carry format-3 traces. Otherwise unchanged from
|
||||
-- schema v38.
|
||||
CREATE OR REPLACE FUNCTION evolution.cellular_births(p_trace bytea, p_manifest bytea)
|
||||
RETURNS TABLE(account_id uuid, request_id evolution.u64, generation evolution.u64,
|
||||
identity evolution.u64, born evolution.u64)
|
||||
LANGUAGE plpgsql IMMUTABLE SECURITY INVOKER SET search_path = pg_catalog, pg_temp AS $$
|
||||
DECLARE
|
||||
c evolution.checkpoint_manifest := evolution.parse_checkpoint_manifest(p_manifest);
|
||||
revision boolean;
|
||||
ticks numeric;
|
||||
tick_index integer;
|
||||
trace_format numeric;
|
||||
tick_header_size integer;
|
||||
intent_count numeric;
|
||||
birth_count numeric;
|
||||
mutation_count numeric;
|
||||
off integer := 112;
|
||||
account bytea;
|
||||
previous_account bytea;
|
||||
previous_request numeric;
|
||||
BEGIN
|
||||
revision := c.versions IN (
|
||||
'\x020000000300000001000000010000000100000002000000010000000200000001000000'::bytea,
|
||||
'\x030000000400000001000000010000000100000002000000010000000200000001000000'::bytea,
|
||||
'\x040000000500000001000000010000000100000002000000010000000200000001000000'::bytea,
|
||||
'\x050000000600000001000000010000000100000002000000010000000200000001000000'::bytea,
|
||||
'\x060000000600000001000000010000000100000003000000020000000200000001000000'::bytea);
|
||||
trace_format := evolution.manifest_uint(p_trace, 8, 4);
|
||||
tick_header_size := CASE trace_format WHEN 2 THEN 8 WHEN 3 THEN 16 ELSE 0 END;
|
||||
IF c.profile <> 4 OR c.commit_sequence = 0 OR p_trace IS NULL
|
||||
OR octet_length(p_trace) <> c.trace_bytes OR sha256(p_trace) <> c.trace_sha256
|
||||
OR substring(p_trace FROM 1 FOR 8) <> '\x45564c4342543031'
|
||||
OR tick_header_size = 0
|
||||
OR (revision AND trace_format <> 3)
|
||||
OR (NOT revision AND trace_format <> 2)
|
||||
OR evolution.manifest_uint(p_trace, 12, 4) <> 4
|
||||
OR evolution.manifest_uint(p_trace, 16, 8) <> c.world_id
|
||||
OR evolution.manifest_uint(p_trace, 24, 8) <> c.region_id
|
||||
OR evolution.manifest_uint(p_trace, 32, 8) <> c.frame_id
|
||||
OR encode(substring(p_trace FROM 41 FOR 16), 'hex')::uuid <> c.predecessor_commit
|
||||
OR substring(p_trace FROM 57 FOR 32) <> c.predecessor_digest
|
||||
OR evolution.manifest_uint(p_trace, 88, 8) <> c.begin_tick
|
||||
OR evolution.manifest_uint(p_trace, 96, 8) <> c.end_tick THEN
|
||||
RAISE EXCEPTION 'invalid cellular birth trace binding' USING ERRCODE = '22023';
|
||||
END IF;
|
||||
ticks := c.end_tick - c.begin_tick;
|
||||
IF ticks < 1 OR ticks > 64 OR evolution.manifest_uint(p_trace, 104, 4) <> ticks
|
||||
OR evolution.manifest_uint(p_trace, 108, 4) <> 0 THEN
|
||||
RAISE EXCEPTION 'invalid cellular birth trace range' USING ERRCODE = '22023';
|
||||
END IF;
|
||||
FOR tick_index IN 0 .. ticks::integer - 1 LOOP
|
||||
IF off + tick_header_size > octet_length(p_trace) THEN
|
||||
RAISE EXCEPTION 'truncated cellular tick header' USING ERRCODE = '22023';
|
||||
END IF;
|
||||
intent_count := evolution.manifest_uint(p_trace, off, 4);
|
||||
birth_count := evolution.manifest_uint(p_trace, off + 4, 4);
|
||||
mutation_count := 0;
|
||||
IF trace_format = 3 THEN
|
||||
mutation_count := evolution.manifest_uint(p_trace, off + 8, 4);
|
||||
IF evolution.manifest_uint(p_trace, off + 12, 4) <> 0 THEN
|
||||
RAISE EXCEPTION 'invalid cellular tick reserved word' USING ERRCODE = '22023';
|
||||
END IF;
|
||||
END IF;
|
||||
IF intent_count > 256 OR birth_count > 256 OR mutation_count > 256
|
||||
OR off + tick_header_size + intent_count * 24 + birth_count * 40
|
||||
+ mutation_count * 40 > octet_length(p_trace) THEN
|
||||
RAISE EXCEPTION 'invalid cellular tick counts' USING ERRCODE = '22023';
|
||||
END IF;
|
||||
off := off + tick_header_size + intent_count::integer * 24;
|
||||
previous_account := ''::bytea;
|
||||
previous_request := -1;
|
||||
FOR birth_index IN 0 .. birth_count::integer - 1 LOOP
|
||||
account := substring(p_trace FROM off + 1 FOR 16);
|
||||
account_id := encode(account, 'hex')::uuid;
|
||||
request_id := evolution.manifest_uint(p_trace, off + 16, 8);
|
||||
generation := evolution.manifest_uint(p_trace, off + 24, 8);
|
||||
identity := evolution.manifest_uint(p_trace, off + 32, 8);
|
||||
born := c.begin_tick + tick_index + 1;
|
||||
IF account_id = '00000000-0000-0000-0000-000000000000' OR request_id = 0
|
||||
OR generation = 0 OR identity = 0
|
||||
OR (account, request_id) <= (previous_account, previous_request) THEN
|
||||
RAISE EXCEPTION 'invalid cellular birth record' USING ERRCODE = '22023';
|
||||
END IF;
|
||||
previous_account := account;
|
||||
previous_request := request_id;
|
||||
off := off + 40;
|
||||
RETURN NEXT;
|
||||
END LOOP;
|
||||
off := off + mutation_count::integer * 40;
|
||||
END LOOP;
|
||||
IF off <> octet_length(p_trace) THEN
|
||||
RAISE EXCEPTION 'trailing cellular trace bytes' USING ERRCODE = '22023';
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
INSERT INTO evolution.schema_migrations(version, sha256) VALUES (41, :'migration_sha_41');
|
||||
+26
-4
@@ -116,6 +116,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
||||
SELECT :'history_v37' || ',38:' || :'migration_sha_38' AS history_v38 \gset
|
||||
SELECT :'history_v38' || ',39:' || :'migration_sha_39' AS history_v39 \gset
|
||||
SELECT :'history_v39' || ',40:' || :'migration_sha_40' AS history_v40 \gset
|
||||
SELECT :'history_v40' || ',41:' || :'migration_sha_41' AS history_v41 \gset
|
||||
SELECT :'history' = :'history_v22' AS at_v22,
|
||||
:'history' = :'history_v23' AS at_v23,
|
||||
:'history' = :'history_v24' AS at_v24,
|
||||
@@ -134,8 +135,10 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
||||
:'history' = :'history_v37' AS at_v37,
|
||||
:'history' = :'history_v38' AS at_v38,
|
||||
:'history' = :'history_v39' AS at_v39,
|
||||
:'history' = :'history_v40' AS at_v40 \gset
|
||||
\if :at_v40
|
||||
:'history' = :'history_v40' AS at_v40,
|
||||
:'history' = :'history_v41' AS at_v41 \gset
|
||||
\if :at_v41
|
||||
\elif :at_v40
|
||||
\elif :at_v39
|
||||
\elif :at_v38
|
||||
\elif :at_v37
|
||||
@@ -509,7 +512,8 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
|
||||
coalesce(max(version), 0) = 37 AS at_v37,
|
||||
coalesce(max(version), 0) = 38 AS at_v38,
|
||||
coalesce(max(version), 0) = 39 AS at_v39,
|
||||
coalesce(max(version), 0) = 40 AS at_v40
|
||||
coalesce(max(version), 0) = 40 AS at_v40,
|
||||
coalesce(max(version), 0) = 41 AS at_v41
|
||||
FROM evolution.schema_migrations \gset
|
||||
\if :at_v24
|
||||
\ir 0025_cellular_v2_bundle.sql
|
||||
@@ -528,6 +532,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
|
||||
\ir 0038_cellular_v6_presence_bundle.sql
|
||||
\ir 0039_account_identities.sql
|
||||
\ir 0040_cellular_mutation_decline.sql
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v25
|
||||
\ir 0026_cellular_profile_migration.sql
|
||||
\ir 0027_cellular_v3_migration.sql
|
||||
@@ -544,6 +549,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
|
||||
\ir 0038_cellular_v6_presence_bundle.sql
|
||||
\ir 0039_account_identities.sql
|
||||
\ir 0040_cellular_mutation_decline.sql
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v26
|
||||
\ir 0027_cellular_v3_migration.sql
|
||||
\ir 0028_cellular_v3_trace_bounds.sql
|
||||
@@ -559,6 +565,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
|
||||
\ir 0038_cellular_v6_presence_bundle.sql
|
||||
\ir 0039_account_identities.sql
|
||||
\ir 0040_cellular_mutation_decline.sql
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v27
|
||||
\ir 0028_cellular_v3_trace_bounds.sql
|
||||
\ir 0029_cellular_mutation_reservations.sql
|
||||
@@ -573,6 +580,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
|
||||
\ir 0038_cellular_v6_presence_bundle.sql
|
||||
\ir 0039_account_identities.sql
|
||||
\ir 0040_cellular_mutation_decline.sql
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v28
|
||||
\ir 0029_cellular_mutation_reservations.sql
|
||||
\ir 0030_cellular_birth_publication_binding.sql
|
||||
@@ -586,6 +594,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
|
||||
\ir 0038_cellular_v6_presence_bundle.sql
|
||||
\ir 0039_account_identities.sql
|
||||
\ir 0040_cellular_mutation_decline.sql
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v29
|
||||
\ir 0030_cellular_birth_publication_binding.sql
|
||||
\ir 0031_fix_cellular_birth_publication_record.sql
|
||||
@@ -598,6 +607,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
|
||||
\ir 0038_cellular_v6_presence_bundle.sql
|
||||
\ir 0039_account_identities.sql
|
||||
\ir 0040_cellular_mutation_decline.sql
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v30
|
||||
\ir 0031_fix_cellular_birth_publication_record.sql
|
||||
\ir 0032_fix_cellular_v3_manifest_normalization.sql
|
||||
@@ -609,6 +619,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
|
||||
\ir 0038_cellular_v6_presence_bundle.sql
|
||||
\ir 0039_account_identities.sql
|
||||
\ir 0040_cellular_mutation_decline.sql
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v31
|
||||
\ir 0032_fix_cellular_v3_manifest_normalization.sql
|
||||
\ir 0033_fix_cellular_action_tick_offset.sql
|
||||
@@ -619,6 +630,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
|
||||
\ir 0038_cellular_v6_presence_bundle.sql
|
||||
\ir 0039_account_identities.sql
|
||||
\ir 0040_cellular_mutation_decline.sql
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v32
|
||||
\ir 0033_fix_cellular_action_tick_offset.sql
|
||||
\ir 0034_cellular_v4_engulf_bundle.sql
|
||||
@@ -628,6 +640,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
|
||||
\ir 0038_cellular_v6_presence_bundle.sql
|
||||
\ir 0039_account_identities.sql
|
||||
\ir 0040_cellular_mutation_decline.sql
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v33
|
||||
\ir 0034_cellular_v4_engulf_bundle.sql
|
||||
\ir 0035_cellular_mutation_publication.sql
|
||||
@@ -636,6 +649,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
|
||||
\ir 0038_cellular_v6_presence_bundle.sql
|
||||
\ir 0039_account_identities.sql
|
||||
\ir 0040_cellular_mutation_decline.sql
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v34
|
||||
\ir 0035_cellular_mutation_publication.sql
|
||||
\ir 0036_cellular_v5_budding_bundle.sql
|
||||
@@ -643,29 +657,37 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
|
||||
\ir 0038_cellular_v6_presence_bundle.sql
|
||||
\ir 0039_account_identities.sql
|
||||
\ir 0040_cellular_mutation_decline.sql
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v35
|
||||
\ir 0036_cellular_v5_budding_bundle.sql
|
||||
\ir 0037_cellular_life_endings.sql
|
||||
\ir 0038_cellular_v6_presence_bundle.sql
|
||||
\ir 0039_account_identities.sql
|
||||
\ir 0040_cellular_mutation_decline.sql
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v36
|
||||
\ir 0037_cellular_life_endings.sql
|
||||
\ir 0038_cellular_v6_presence_bundle.sql
|
||||
\ir 0039_account_identities.sql
|
||||
\ir 0040_cellular_mutation_decline.sql
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v37
|
||||
\ir 0038_cellular_v6_presence_bundle.sql
|
||||
\ir 0039_account_identities.sql
|
||||
\ir 0040_cellular_mutation_decline.sql
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v38
|
||||
\ir 0039_account_identities.sql
|
||||
\ir 0040_cellular_mutation_decline.sql
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v39
|
||||
\ir 0040_cellular_mutation_decline.sql
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v40
|
||||
\ir 0041_cellular_v7_balance_bundle.sql
|
||||
\elif :at_v41
|
||||
\else
|
||||
\echo 'Unknown or changed migration history after v40'
|
||||
\echo 'Unknown or changed migration history after v41'
|
||||
DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$;
|
||||
\endif
|
||||
-- Effective-privilege audit on every run, including no-ops (ADR-0060). Attributes
|
||||
|
||||
Reference in New Issue
Block a user