Support cellular births in trace v3
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (postgres) (push) Canceled after 8m28s

This commit is contained in:
dingo
2026-10-11 06:32:26 -04:00
parent d9bf60138e
commit 7d94024a75
3 changed files with 98 additions and 7 deletions
+5 -5
View File
@@ -6780,8 +6780,8 @@ standard-library environment, and WSL is unavailable in this session.
The next M11.4c segment adds owner-side application and deterministic replay of
mutation selections, v3 trace decoding, a separate canonical mutation-action
codec, and SQL v3 trace bounds. No local compile or PostgreSQL test completed:
both targeted Ninja invocations stalled without output and were stopped. The
publisher deliberately refuses batches containing mutation selections until
durable action reservation, publication and recovery are implemented. Formatting
and Linux CI remain pending for this segment.
codec, and SQL v3 trace bounds and birth binding. No local compile or PostgreSQL
test completed: both targeted Ninja invocations stalled without output and were
stopped. The C++ and SQL publishers deliberately refuse batches containing
mutation selections until durable action reservation, publication and recovery
are implemented. Formatting and Linux CI remain pending for this segment.
@@ -45,4 +45,95 @@ BEGIN
END $$;
REVOKE ALL ON FUNCTION evolution.parse_checkpoint_manifest(bytea) FROM PUBLIC;
-- Birth binding remains part of publication in trace v3. Its tick header adds
-- mutation_count and a reserved word after the format-2 intent/birth counts.
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);
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
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 (c.versions = '\x020000000300000001000000010000000100000002000000010000000200000001000000'
AND trace_format <> 3)
OR (c.versions <> '\x020000000300000001000000010000000100000002000000010000000200000001000000'
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 mutation_count <> 0
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 (28, :'migration_sha_28');
+2 -2
View File
@@ -21,5 +21,5 @@ The separate 64-byte mutation-action codec binds an authenticated account,
action ID, scheduled tick and the exact `(life_id, event_index, offer_tick,
operator_id)` input. It is an in-memory codec only at this stage. Durable
reservation, publication and recovery are still required before mutation
selections may be published; the checkpoint publisher currently rejects such
selections.
selections may be published; both C++ and SQL checkpoint publishers currently
reject such selections.