feat(persistence): admit durable retained offspring plans
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (client) (push) Canceled after 1m11s
Foundation / checks (checks) (push) Canceled after 1m13s
Foundation / checks (postgres) (push) Canceled after 1m8s
Foundation / checks (ecs) (push) Canceled after 1m13s
Foundation / checks (network) (push) Canceled after 1m14s
Foundation / checks (deploy) (push) Canceled after 1m18s

This commit is contained in:
dingo
2026-10-19 15:04:30 -04:00
parent 39509ecd40
commit c60cdf8e19
20 changed files with 850 additions and 46 deletions
+19
View File
@@ -1,5 +1,24 @@
# Build and dev delivery
## Current delivery flow (maintainer confirmed 2026-10-19)
Pushing to Git runs Actions, which builds and publishes to Harbor; ArgoCD picks
up the deployment and delivers it to Kubernetes. Workload manifests are under
`deploy/`. Use this configured flow for development delivery. The manual-sync
and image-pinning instructions below describe earlier setup and must not be
treated as a request to replace the current automation.
DEV workloads use `evolution-dev`, run on worker nodes rather than the control
plane, and retain the existing PostgreSQL server, network structure and URLs.
Qualification data must remain isolated from existing worlds. Immediately before
each push refresh `REGION_SESSION_WINDOW` in
`kubernetes/region/dev-session-route/listener.yaml` with a unique activation and
an absolute UTC expiry four hours ahead. Record actual pipeline/deployment
results separately: a push alone does not prove build success or reachability.
World0 deployment, reset and pruning remain outside routine development.
## Historical setup and verification notes
The maintainer has configured Gitea, Harbor and Argo. Gitea run
[1399](https://git.aeternalisgames.com/dingo/AEvolution/actions/runs/1399)
successfully built, tested and published commit `8ab48d3`. This repository adds
@@ -12,7 +12,7 @@ spec:
env:
- {name: REGION_SESSION, value: "dev"}
- {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"}
- {name: REGION_SESSION_WINDOW, value: "dev-20261019T181708-5ae9e40b:1792448228"}
- {name: REGION_SESSION_WINDOW, value: "dev-20261019T190400-b82838f2:1792451040"}
- {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"}
ports:
# QUIC (ADR-0090): UDP only; nothing listens on TCP 7400.
+15
View File
@@ -1,5 +1,20 @@
# Project status and next steps
## Durable retained offspring plans - 2026-10-19
[ADR-0168](adr/0168-durable-retained-plan-admission.md)/schema 55 adds explicit
raw bundle-11 -> 12 fenced upgrades, trace-4 publication, earned plan selections
and repeated funded births. Recovery rederives the full upgrade from retained
source objects and replays subsequent choices/births exactly. Ambiguous retries,
stale writers, rollback, pending choices and missing/corrupt/false evidence are
covered. No default or DEV opening opts into this version automatically.
[Validation](engineering/VALIDATION.md) records executed checks. Population and
migration support, census plan semantics, control succession, retained NPC
behavior, client choice UI and the remaining M12 operational/ecology/product
gates remain open. Delivery follows Git Actions -> Harbor -> ArgoCD -> Kubernetes
using the checked-in `deploy/` manifests.
## Portable retained-plan checkpoint upgrade - 2026-10-19
[ADR-0167](adr/0167-retained-plan-checkpoint-upgrade.md) defines raw-only bundle
@@ -0,0 +1,57 @@
# ADR-0168: Durable raw retained-plan admission
## Status and scope
Accepted scoped persistence segment of ADR-0163/0165-0167, 2026-10-19. Raw
profile 4 only. No automatic upgrade, default/DEV change, population conversion,
migration/census qualification, control succession or client-choice UI.
## Decision
Schema 55 admits exactly raw bundle 12 with trace 4 through the existing fenced
cellular publisher. Only explicit raw bundle 11 -> 12 no-tick upgrades use the
immutable cellular profile/version journal. Verify both source bindings, derive
the complete owner upgrade and read back the target object before publishing.
Journal evidence, result commit and head move remain one transaction under the
current lease/exact head. Pending intervals/handoffs prevent new upgrades.
Retain original manifests, traces, input blocks and digests. SQL may normalize
parser-local copies of the tuple/trace layout only after verifying the actual
trace length/SHA-256 and exact owner/trace version pairing. Stored bytes, retry
identity and authority checks always use the actual bundle-12/trace-4 evidence.
Legacy helpers remain private. No new runtime privilege or provisioning path.
Mutation outcomes are derived by complete C++ replay and bound atomically to the
existing allocator reservation and action block. For this editing mode only,
admit result 4 (offspring plan applied), 3 (declined) or 1 (life died); reject
in-life applied/funding result meanings. A decline must match operator zero;
successful plan selection must match a nonzero operator. Old result domains and
old trace/tuple meanings remain unchanged. Recovery loads the exact actions,
replays the complete checkpoint, and compares every result and all target bytes.
Upgrade recovery verifies the immutable source/target manifests and objects,
journal versions/digests and exact retained transformation using the original
writer fields under current recovery authority. Missing, corrupt or biologically
false evidence fails closed without an older-head fallback. Exact retries retain
original bytes/receipt; changed retries conflict and stale writers remain fenced.
Bundle 12 remains raw-only. Population/census/migration adapters must refuse it,
and unsupported evidence cannot become zero life or terminal extinction. A
recovered raw owner may continue authoritative biology; no worker opts into the
upgrade automatically. NPC behavior retention, birth-time one-way control and
their presentation remain separate contracts.
## Alternatives, consequences and qualification
New genesis would discard ancestry/stock history; a second upgrade journal would
duplicate authority. Broadly admitting every revision bundle would mix two
mutation meanings. Use the existing journal and an exact tuple/trace/result set.
Risks include parser normalization bypassing strong bindings, wrong result
meanings and partial history after ambiguous publication. Require private SQL
tests for the upgrade, exact recovery/continuation, earned plan selections and
repeated funded births, stale/current leases, exact/conflicting retries, rollback,
pending work, missing/corrupt/false objects and replacement recovery. Run the full
persistence/backup/DR/upgrade and privilege/checksum matrix plus appropriate
portable, analysis and sanitizer checks. This is not M12 completion or a product
acceptance decision.
+2
View File
@@ -1,5 +1,7 @@
# Architecture decision records
- [ADR-0168: Durable raw retained-plan admission](0168-durable-retained-plan-admission.md) - schema 55, explicit raw bundle-11 -> 12 fenced upgrades and trace-4 mutation/birth publication with exact recovery; no automatic opening or population admission.
- [ADR-0167: Explicit retained-plan checkpoint upgrade](0167-retained-plan-checkpoint-upgrade.md) - portable raw-only bundle 12 and exact no-tick bundle-11 source transformation; SQL/durable admission and population support remain separate.
- [ADR-0166: Retained-plan replay traces](0166-retained-plan-replay-traces.md) - explicit raw trace 4 for owner 8/rules 10, inherited-offer action matching and complete-result replay; durable admission remains separate.
+12 -3
View File
@@ -20,11 +20,20 @@ retained plans and earned selections, unchanged expressed parents and repeated
funded births. [ADR-0166](../adr/0166-retained-plan-replay-traces.md) adds portable
raw trace-4 replay, action matching and exact process restart. Existing same-genome
behavior remains. [ADR-0167](../adr/0167-retained-plan-checkpoint-upgrade.md) defines
the portable raw checkpoint tuple and exact retained-source upgrade. Durable
plan/trace/bundle admission,
population/migration/census admission, the in-life expression catalog, authority
the portable raw checkpoint tuple and exact retained-source upgrade.
[ADR-0168](../adr/0168-durable-retained-plan-admission.md) adds schema 55,
explicit fenced raw admission, plan selections and repeated funded births with
complete source/target recovery. Population/migration/census admission, the
in-life expression catalog, authority
handoff and NPC/UI integration are still required.
Delivery follows the maintainer-confirmed Git Actions -> Harbor -> ArgoCD ->
Kubernetes flow using `deploy/`. DEV qualification belongs in `evolution-dev`
on worker nodes, using the existing PostgreSQL server/network endpoints and
isolated test data. A successful local check or Git push alone is not evidence
that a target-host fault drill or deployed workload passed. Direct workstation
Kubernetes access is not a prerequisite for this delivery flow.
## Persistence boundary resolved by 12.3b
ADR-0142 adds dedicated profile 5, population trace 1 and schema 44; raw profile 4
+56
View File
@@ -1,5 +1,61 @@
# Validation report
## 2026-10-19 - Durable raw retained-plan admission
[ADR-0168](../adr/0168-durable-retained-plan-admission.md)/schema 55 adds the
explicit raw bundle-11 -> 12 upgrade and trace-4 durable publisher/recovery.
Complete retained source and target bytes are independently bound, restored and
compared. A valid equal-stock but different-position upgrade fails recovery;
metadata checks alone never establish the biological transformation. SQL
parser-local normalization first verifies the actual trace length/SHA-256 and
version; retained evidence and retry identity use the original bytes.
Executed locally before the following census segment:
- MSVC 19.44 Release full CTest **89/89, 22.93 s**; GCC 14.2 Release **89/89,
17.58 s**, with NDEBUG.
- Clang 19.1/clang-tidy 19 persistence build and private population/fault suite
passed **56 s total**, including retained plans and existing raw/cohort,
interval, migration and registered-census controls.
- Clang 19.1 ASan/UBSan persistence build and the same private suite passed
**111 s total**, without sanitizer reports.
- GCC 14.2 full private schema-55 matrix passed **624 s total**: complete
integration suite (454 s), network partitions (82 s), reservation concurrency,
backup/history-domain/restore, disaster recovery, upgrade rehearsal, migration
history, runtime privileges and checksum drift. No shared database was used.
- Repository clang-format 19 and staged/working diff checks passed. No golden
was replaced. The exact staged deployment policy passes: 75 objects in 74
files, 138 rendered objects in 17 overlays, zero failures.
The refreshed DEV session window expires **2026-10-19 23:04:00 UTC**. Pipeline
build/deployment success and live reachability are not inferred from this push.
The real finite-food fixture follows the required earlier version upgrades,
preserves suspended lives, selects an earned plan without changing the parent's
expressed genome, publishes result 4 and produces at least two funded children
with that plan. Complete recovery under a replacement lease preserves the
family. Tests refuse skipped/repeated upgrades, population conversion, pending
mutation work, stale/current conflicting retries, wrong result meanings,
trace-3/owner-8 pairing and altered traces with the original digest. A triggered
result-insert failure rolls back journal/head; process loss before publication,
an ambiguous timed request, exact duplicate retry, source loss/corruption and
biologically false source transformation retain their explicit failure behavior.
An earlier full run used an old test binary missing the new migration-checksum
argument and failed its upgrade rehearsal. The test was corrected and rebuilt.
The next full run was canceled at the maintainer's stop request; its shell trap
printed an exit-0 timing summary before reporting the child hangup. That summary
is **not** a completed test pass. Only the subsequent uninterrupted run counts.
All database tests use disposable local clusters, not the shared DEV server.
The maintainer confirms delivery through Git Actions, Harbor, ArgoCD and
Kubernetes, with workloads in `evolution-dev` on workers and the existing
PostgreSQL/network/URLs. This workstation has no configured Kubernetes context;
direct access is not required for that delivery flow. No target-host performance,
multi-host failure, deployed reachability, actual-days ecology, product/UI,
TSan or World0 evidence is inferred from local tests or a Git push. Default
biology and player control behavior remain unchanged; M12 is still in progress.
## 2026-10-19 - Portable retained-plan checkpoint upgrade
[ADR-0167](../adr/0167-retained-plan-checkpoint-upgrade.md) adds raw-only bundle
@@ -273,6 +273,12 @@ migrate_cellular_maturation_profile(Postgres&, const FilesystemObjectStore&, con
const CommittedCheckpoint&, Uuid commit,
const Sha256Digest& build, std::chrono::milliseconds timeout,
const PublishHooks& hooks = {});
// ADR-0168: explicit raw-only bundle 11 -> 12, retaining complete source evidence.
[[nodiscard]] std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
migrate_cellular_inheritance_profile(Postgres&, const FilesystemObjectStore&, const LeaseGrant&,
const CommittedCheckpoint&, Uuid commit,
const Sha256Digest& build, std::chrono::milliseconds timeout,
const PublishHooks& hooks = {});
// Verify the recorded no-tick operation under current authority, replaying its
// entire source/target payload. Version upgrades and profile transitions retain
// separate evidence; neither is inferred solely from the target tuple.
@@ -89,6 +89,13 @@ population_envelope_version(const CellularVersionBundle& b) noexcept {
b == cellular_v6_versions || b == cellular_v7_versions || b == cellular_v8_versions ||
b == cellular_v9_versions || b == cellular_v10_versions || b == cellular_v11_versions;
}
// Exact raw trace version for admitted cellular tuples; bundle 12 has its own semantics.
[[nodiscard]] constexpr std::uint32_t
cellular_checkpoint_trace_format(const CellularVersionBundle& b) noexcept {
return b == cellular_v12_versions ? server::cellular_batch_inheritance_format
: cellular_revision_bundle(b) ? server::cellular_batch_format
: server::cellular_batch_v2_format;
}
// Batch evidence bound by manifest v2 (ADR-0063); all zero at genesis.
struct BatchDigests {
+280
View File
@@ -0,0 +1,280 @@
-- ADR-0168: raw-only bundle 12 / trace 4 and exact bundle 11 -> 12 upgrades.
-- Normalization below is parser-local. Stored evidence and retries retain real bytes.
ALTER FUNCTION evolution.parse_checkpoint_manifest(bytea) RENAME TO parse_checkpoint_manifest_v54;
REVOKE ALL ON FUNCTION evolution.parse_checkpoint_manifest_v54(bytea) FROM PUBLIC, :"runtime_role";
CREATE FUNCTION evolution.parse_checkpoint_manifest(m bytea)
RETURNS evolution.checkpoint_manifest LANGUAGE plpgsql IMMUTABLE
SET search_path=pg_catalog,pg_temp AS $$
DECLARE c evolution.checkpoint_manifest;
b11 constant bytea := '\x090000000700000002000000010000000100000004000000030000000200000001000000';
b12 constant bytea := '\x0a0000000800000002000000010000000100000004000000030000000200000001000000';
BEGIN
IF m IS NOT NULL AND octet_length(m)=360 AND evolution.manifest_uint(m,12,4)=4
AND evolution.manifest_uint(m,228,4)=0 AND evolution.manifest_uint(m,232,4)=4
AND evolution.manifest_uint(m,236,4)=1 AND substring(m FROM 161 FOR 36)=b12 THEN
c := evolution.parse_checkpoint_manifest_v54(overlay(m PLACING b11 FROM 161 FOR 36));
c.versions := b12;
RETURN c;
END IF;
RETURN evolution.parse_checkpoint_manifest_v54(m);
END $$;
REVOKE ALL ON FUNCTION evolution.parse_checkpoint_manifest(bytea) FROM PUBLIC;
ALTER FUNCTION evolution.cellular_births(bytea,bytea) RENAME TO cellular_births_v54;
REVOKE ALL ON FUNCTION evolution.cellular_births_v54(bytea,bytea) FROM PUBLIC, :"runtime_role";
CREATE FUNCTION evolution.cellular_births(t bytea,m bytea)
RETURNS TABLE(account_id uuid,request_id evolution.u64,generation evolution.u64,identity evolution.u64,born evolution.u64)
LANGUAGE plpgsql IMMUTABLE SET search_path=pg_catalog,pg_temp AS $$
DECLARE c evolution.checkpoint_manifest := evolution.parse_checkpoint_manifest(m);
b11 constant bytea := '\x090000000700000002000000010000000100000004000000030000000200000001000000';
b12 constant bytea := '\x0a0000000800000002000000010000000100000004000000030000000200000001000000';
BEGIN
IF c.versions=b12 THEN
IF t IS NULL OR octet_length(t)<>c.trace_bytes OR sha256(t)<>c.trace_sha256
OR evolution.manifest_uint(t,8,4)<>4 THEN
RAISE EXCEPTION 'invalid retained-plan trace binding' USING ERRCODE='22023';
END IF;
t := overlay(t PLACING '\x03000000'::bytea FROM 9 FOR 4);
m := overlay(m PLACING b11 FROM 161 FOR 36);
m := overlay(m PLACING sha256(t) FROM 289 FOR 32);
END IF;
RETURN QUERY SELECT * FROM evolution.cellular_births_v54(t,m);
END $$;
REVOKE ALL ON FUNCTION evolution.cellular_births(bytea,bytea) FROM PUBLIC;
ALTER TABLE evolution.cellular_mutation_action_publications
DROP CONSTRAINT cellular_mutation_action_publications_result_check;
ALTER TABLE evolution.cellular_mutation_action_publications
ADD CONSTRAINT cellular_mutation_action_publications_result_check CHECK(result BETWEEN 0 AND 4);
CREATE OR REPLACE FUNCTION evolution.cellular_mutation_selections(p_trace bytea, p_manifest bytea)
RETURNS TABLE(tick evolution.u64, life_id evolution.u64, event_index evolution.u64,
offer_tick evolution.u64, successor_identity evolution.u64, operator_id integer)
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 integer;
off integer := 112;
intent_count integer;
birth_count integer;
mutation_count integer;
previous_life numeric;
BEGIN
PERFORM * FROM evolution.cellular_births(p_trace, p_manifest); -- Binding and structure.
IF evolution.manifest_uint(p_trace, 8, 4) NOT IN (3,4) THEN
RETURN; -- Format 2 carries no selections.
END IF;
ticks := (c.end_tick - c.begin_tick)::integer;
FOR tick_index IN 0 .. ticks - 1 LOOP
intent_count := evolution.manifest_uint(p_trace, off, 4)::integer;
birth_count := evolution.manifest_uint(p_trace, off + 4, 4)::integer;
mutation_count := evolution.manifest_uint(p_trace, off + 8, 4)::integer;
off := off + 16 + intent_count * 24 + birth_count * 40;
previous_life := 0;
FOR mutation_index IN 0 .. mutation_count - 1 LOOP
tick := c.begin_tick + tick_index + 1;
life_id := evolution.manifest_uint(p_trace, off, 8);
event_index := evolution.manifest_uint(p_trace, off + 8, 8);
offer_tick := evolution.manifest_uint(p_trace, off + 16, 8);
successor_identity := evolution.manifest_uint(p_trace, off + 24, 8);
operator_id := evolution.manifest_uint(p_trace, off + 32, 2)::integer;
IF life_id = 0 OR life_id <= previous_life OR event_index = 0 OR offer_tick = 0
OR offer_tick >= tick OR successor_identity = 0
OR substring(p_trace FROM off + 35 FOR 6) <> '\x000000000000' THEN
RAISE EXCEPTION 'invalid cellular mutation selection' USING ERRCODE = '22023';
END IF;
previous_life := life_id;
off := off + 40;
RETURN NEXT;
END LOOP;
END LOOP;
END $$;
-- Results 0 applied, 1 life died, 2 insufficient funding, 3 declined.
CREATE OR REPLACE FUNCTION evolution.check_cellular_mutation_block(p_manifest bytea, p_trace bytea,
p_mutations bytea, p_results bytea)
RETURNS integer LANGUAGE plpgsql STABLE SECURITY INVOKER
SET search_path = pg_catalog, pg_temp AS $$
DECLARE
c evolution.checkpoint_manifest := evolution.parse_checkpoint_manifest(p_manifest);
n integer;
account uuid;
account_bytes bytea;
action numeric;
tick numeric;
input bytea;
previous_tick numeric := -1;
previous_account bytea := ''::bytea;
previous_action numeric := -1;
r evolution.cellular_mutation_reservations%ROWTYPE;
BEGIN
IF p_mutations IS NULL OR p_results IS NULL OR octet_length(p_mutations) = 0
OR octet_length(p_mutations) % 64 <> 0 OR octet_length(p_mutations) / 64 > 1024
OR octet_length(p_results) <> octet_length(p_mutations) / 64 THEN
RAISE EXCEPTION 'invalid cellular mutation block' USING ERRCODE = '22023';
END IF;
n := octet_length(p_mutations) / 64;
IF (SELECT count(*) FROM evolution.cellular_mutation_selections(p_trace, p_manifest)) <> n THEN
RAISE EXCEPTION 'cellular mutation block does not cover the trace' USING ERRCODE = '22023';
END IF;
FOR i IN 0 .. n - 1 LOOP
account_bytes := substring(p_mutations FROM 64 * i + 1 FOR 16);
account := encode(account_bytes, 'hex')::uuid;
action := evolution.manifest_uint(p_mutations, 64 * i + 16, 8);
input := substring(p_mutations FROM 64 * i + 25 FOR 34);
tick := evolution.manifest_uint(input, 0, 8);
IF account = '00000000-0000-0000-0000-000000000000' OR action = 0
OR NOT evolution.valid_cellular_mutation_input(input)
OR substring(p_mutations FROM 64 * i + 59 FOR 6) <> '\x000000000000'
OR (c.versions='\x0a0000000800000002000000010000000100000004000000030000000200000001000000'::bytea
AND (get_byte(p_results,i) NOT IN (1,3,4)
OR (evolution.manifest_uint(input,32,2)=0 AND get_byte(p_results,i) NOT IN (1,3))
OR (evolution.manifest_uint(input,32,2)<>0 AND get_byte(p_results,i) NOT IN (1,4))))
OR (c.versions<>'\x0a0000000800000002000000010000000100000004000000030000000200000001000000'::bytea
AND get_byte(p_results,i)>3)
OR tick <= c.begin_tick OR tick > c.end_tick
OR (tick, account_bytes, action) <= (previous_tick, previous_account, previous_action) THEN
RAISE EXCEPTION 'invalid cellular mutation record' USING ERRCODE = '22023';
END IF;
previous_tick := tick;
previous_account := account_bytes;
previous_action := action;
SELECT * INTO r FROM evolution.cellular_mutation_reservations x
WHERE x.world_id = c.world_id AND x.account_id = account AND x.action_id = action;
IF NOT FOUND OR r.region_id <> c.region_id OR r.input_bytes <> input
OR r.target_tick <> evolution.manifest_uint(input, 0, 8) THEN
RAISE EXCEPTION 'cellular mutation reservation conflicts' USING ERRCODE = 'EVL16';
END IF;
IF NOT EXISTS (SELECT 1 FROM evolution.cellular_mutation_selections(p_trace, p_manifest) s
WHERE s.tick = r.target_tick AND s.successor_identity = r.successor_identity
AND s.life_id = evolution.manifest_uint(input, 8, 8)
AND s.event_index = evolution.manifest_uint(input, 16, 8)
AND s.offer_tick = evolution.manifest_uint(input, 24, 8)
AND s.operator_id = evolution.manifest_uint(input, 32, 2)) THEN
RAISE EXCEPTION 'cellular mutation differs from its trace' USING ERRCODE = '22023';
END IF;
END LOOP;
RETURN n;
END $$;
ALTER FUNCTION evolution.publish_cellular_profile_migration(bytea) RENAME TO publish_cellular_profile_migration_v54;
REVOKE ALL ON FUNCTION evolution.publish_cellular_profile_migration_v54(bytea) FROM PUBLIC, :"runtime_role";
CREATE OR REPLACE FUNCTION evolution.publish_cellular_profile_migration(p_manifest bytea)
RETURNS TABLE(region_frame evolution.u64, head_sequence evolution.u64, head_commit uuid,
head_digest text, head_tick evolution.u64)
LANGUAGE plpgsql SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS $$
DECLARE
c evolution.checkpoint_manifest := evolution.parse_checkpoint_manifest(p_manifest);
s evolution.checkpoint_manifest;
h evolution.region_heads%ROWTYPE;
p evolution.region_commits%ROWTYPE;
old evolution.region_commits%ROWTYPE;
frame evolution.u64;
d bytea := sha256(p_manifest);
source_bundle constant bytea := '\x090000000700000002000000010000000100000004000000030000000200000001000000';
target_bundle constant bytea := '\x0a0000000800000002000000010000000100000004000000030000000200000001000000';
zero32 constant bytea := decode(repeat('00', 32), 'hex');
BEGIN
IF c.versions <> target_bundle THEN
RETURN QUERY SELECT * FROM evolution.publish_cellular_profile_migration_v54(p_manifest);
RETURN;
END IF;
IF c.profile <> 4 OR c.commit_sequence = 0 OR c.begin_tick <> c.end_tick
OR c.end_tick = 0 OR c.versions <> target_bundle
OR evolution.manifest_uint(p_manifest, 228, 4) <> 0
OR evolution.manifest_uint(p_manifest, 232, 4) <> (CASE c.profile WHEN 4 THEN 4 ELSE 5 END)
OR evolution.manifest_uint(p_manifest, 236, 4) <> 1
OR c.trace_bytes <> 0 OR c.trace_sha256 <> zero32
OR c.decision_count <> 0 OR c.decisions_sha256 <> zero32 THEN
RAISE EXCEPTION 'invalid retained-plan profile migration' USING ERRCODE = '22023';
END IF;
PERFORM evolution.check_region_lease(c.world_id, c.region_id, c.holder, c.epoch);
SELECT * INTO old FROM evolution.region_commits r WHERE r.commit_id = c.commit_id;
IF FOUND THEN
IF old.manifest <> p_manifest THEN
RAISE EXCEPTION 'cellular profile migration identity reused' USING ERRCODE = 'EVL07';
END IF;
SELECT * INTO p FROM evolution.region_commits r
WHERE r.world_id = old.world_id AND r.region_id = old.region_id
AND r.commit_sequence = old.commit_sequence - 1;
IF NOT FOUND OR NOT EXISTS (
SELECT 1 FROM evolution.cellular_profile_migrations m
WHERE m.target_commit = c.commit_id AND m.world_id = c.world_id
AND m.region_id = c.region_id AND m.source_sequence = p.commit_sequence
AND m.source_commit = p.commit_id AND m.source_manifest_sha256 = p.commit_digest
AND m.source_payload_sha256 = p.payload_sha256 AND m.source_versions = p.versions
AND m.target_sequence = old.commit_sequence AND m.target_manifest_sha256 = d
AND m.target_payload_sha256 = old.payload_sha256 AND m.target_versions = old.versions
AND m.source_commit = c.predecessor_commit
AND m.source_manifest_sha256 = c.predecessor_digest) THEN
RAISE EXCEPTION 'cellular profile migration identity reused' USING ERRCODE = 'EVL07';
END IF;
SELECT l.frame_id INTO frame FROM evolution.region_leases l
WHERE l.world_id = c.world_id AND l.region_id = c.region_id;
RETURN QUERY SELECT frame, old.commit_sequence, old.commit_id,
encode(old.commit_digest, 'hex'), old.end_tick;
RETURN;
END IF;
IF EXISTS (SELECT 1 FROM evolution.population_interval_pending x
WHERE x.world_id = c.world_id AND x.region_id = c.region_id) THEN
RAISE EXCEPTION 'retained-plan upgrade waits for interval' USING ERRCODE = 'EVL18';
END IF;
IF EXISTS (SELECT 1 FROM evolution.cellular_mutation_reservations x
WHERE x.world_id=c.world_id AND x.region_id=c.region_id AND NOT EXISTS
(SELECT 1 FROM evolution.cellular_mutation_action_publications a
WHERE a.world_id=x.world_id AND a.account_id=x.account_id AND a.action_id=x.action_id)) THEN
RAISE EXCEPTION 'retained-plan upgrade waits for mutation choice' USING ERRCODE='EVL18';
END IF;
SELECT * INTO h FROM evolution.region_heads r
WHERE r.world_id = c.world_id AND r.region_id = c.region_id FOR UPDATE;
IF NOT FOUND OR h.commit_sequence = 18446744073709551615
OR c.commit_sequence <> h.commit_sequence + 1 OR c.predecessor_commit <> h.commit_id
OR c.predecessor_digest <> h.digest OR c.begin_tick <> h.end_tick THEN
RAISE EXCEPTION 'region head moved' USING ERRCODE = 'EVL03';
END IF;
SELECT * INTO p FROM evolution.region_commits r
WHERE r.world_id = c.world_id AND r.region_id = c.region_id
AND r.commit_sequence = h.commit_sequence;
IF NOT FOUND THEN
RAISE EXCEPTION 'missing migration predecessor' USING ERRCODE = 'XX000';
END IF;
s := evolution.parse_checkpoint_manifest(p.manifest);
IF s.profile <> c.profile OR s.versions <> source_bundle OR p.versions <> source_bundle
OR c.frame_id <> s.frame_id OR c.tick_microseconds <> s.tick_microseconds
OR s.commit_id <> c.predecessor_commit OR s.end_tick <> c.end_tick
OR evolution.manifest_uint(p.manifest, 232, 4) <> (CASE c.profile WHEN 4 THEN 4 ELSE 5 END)
OR NOT EXISTS (SELECT 1 FROM evolution.retained_builds b
WHERE b.build_identity = c.build_identity) THEN
RAISE EXCEPTION 'unsupported retained-plan profile migration' USING ERRCODE = 'EVL06';
END IF;
SELECT l.frame_id INTO frame FROM evolution.region_leases l
WHERE l.world_id = c.world_id AND l.region_id = c.region_id;
IF c.frame_id <> frame THEN
RAISE EXCEPTION 'foreign frame' USING ERRCODE = '22023';
END IF;
INSERT INTO evolution.cellular_profile_migrations(target_commit, world_id, region_id,
source_sequence, source_commit, source_manifest_sha256, source_payload_sha256,
source_versions, target_sequence, target_manifest_sha256, target_payload_sha256,
target_versions)
VALUES (c.commit_id, c.world_id, c.region_id, p.commit_sequence, p.commit_id,
p.commit_digest, p.payload_sha256, p.versions, c.commit_sequence, d,
c.payload_sha256, c.versions);
INSERT INTO evolution.region_commits(world_id, region_id, commit_sequence, commit_id,
commit_digest, manifest, begin_tick, end_tick, published_epoch, tick_microseconds,
versions, build_identity, payload_bytes, payload_sha256)
VALUES (c.world_id, c.region_id, c.commit_sequence, c.commit_id, d, p_manifest,
c.begin_tick, c.end_tick, c.epoch, c.tick_microseconds, c.versions,
c.build_identity, c.payload_bytes, c.payload_sha256);
UPDATE evolution.region_heads r
SET commit_sequence = c.commit_sequence, commit_id = c.commit_id, digest = d,
end_tick = c.end_tick, published_epoch = c.epoch
WHERE r.world_id = c.world_id AND r.region_id = c.region_id;
RETURN QUERY SELECT frame, c.commit_sequence, c.commit_id, encode(d, 'hex'), c.end_tick;
END $$;
REVOKE ALL ON FUNCTION evolution.publish_cellular_profile_migration(bytea) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION evolution.publish_cellular_profile_migration(bytea) TO :"runtime_role";
INSERT INTO evolution.schema_migrations(version,sha256) VALUES(55,:'migration_sha_55');
+12 -3
View File
@@ -130,6 +130,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
SELECT :'history_v51' || ',52:' || :'migration_sha_52' AS history_v52 \gset
SELECT :'history_v52' || ',53:' || :'migration_sha_53' AS history_v53 \gset
SELECT :'history_v53' || ',54:' || :'migration_sha_54' AS history_v54 \gset
SELECT :'history_v54' || ',55:' || :'migration_sha_55' AS history_v55 \gset
SELECT :'history' = :'history_v22' AS at_v22,
:'history' = :'history_v23' AS at_v23,
:'history' = :'history_v24' AS at_v24,
@@ -162,8 +163,10 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
:'history' = :'history_v51' AS at_v51,
:'history' = :'history_v52' AS at_v52,
:'history' = :'history_v53' AS at_v53,
:'history' = :'history_v54' AS at_v54 \gset
\if :at_v54
:'history' = :'history_v54' AS at_v54,
:'history' = :'history_v55' AS at_v55 \gset
\if :at_v55
\elif :at_v54
\elif :at_v53
\elif :at_v52
\elif :at_v51
@@ -565,7 +568,8 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
coalesce(max(version), 0) = 51 AS at_v51,
coalesce(max(version), 0) = 52 AS at_v52,
coalesce(max(version), 0) = 53 AS at_v53,
coalesce(max(version), 0) = 54 AS at_v54
coalesce(max(version), 0) = 54 AS at_v54,
coalesce(max(version), 0) = 55 AS at_v55
FROM evolution.schema_migrations \gset
\if :at_v24
\ir 0025_cellular_v2_bundle.sql
@@ -788,6 +792,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\elif :at_v52
\elif :at_v53
\elif :at_v54
\elif :at_v55
\else
\echo 'Unknown or changed migration history after v43'
DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$;
@@ -836,6 +841,10 @@ SELECT coalesce(max(version), 0) = 53 AS needs_v54 FROM evolution.schema_migrati
\if :needs_v54
\ir 0054_maturing_cellular_migration.sql
\endif
SELECT coalesce(max(version), 0) = 54 AS needs_v55 FROM evolution.schema_migrations \gset
\if :needs_v55
\ir 0055_retained_cellular_plans.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
+12 -7
View File
@@ -33,13 +33,18 @@ the result. `supported()` describes reader support only. Legacy revision-bundle
helpers remain the trace-3 admission set and exclude bundle 12.
No population envelope maps to bundle 12. Profile transitions, population
successors/restore, census and migration remain unsupported for this owner.
successors/restore, census and migration remain unsupported for this owner in
the portable upgrade segment.
Missing or unsupported projections cannot establish zero life or extinction.
SQL schema and C++ durable upgrade/publication adapters are unchanged; neither
portable candidate function is a new durable entry point.
The portable candidate functions perform no durable publication.
The next durable segment must admit this exact pair through fenced atomic
evidence/result/head publication, retain both complete manifests and payloads,
rederive the target on recovery, refuse pending intervals/handoffs and qualify
exact retries, stale writers, ambiguous outcomes and process/storage failures.
[ADR-0168](../docs/adr/0168-durable-retained-plan-admission.md) adds schema 55
and `migrate_cellular_inheritance_profile` as the separate durable adapter.
It admits only this exact raw pair through the existing fenced atomic
evidence/result/head transaction, retains both complete manifests and payloads,
and rederives the complete target during recovery. Pending intervals/handoffs
and unbound mutation choices refuse the upgrade. Subsequent biological batches
require trace 4 and mutation outcomes 1 (life died), 3 (declined) or 4 (plan
applied); legacy result meanings remain versioned. Exact retry bytes/receipts,
ambiguous publication and stale-writer fencing use the existing contracts.
No worker or DEV/default opening selects bundle 12 automatically.
+37 -24
View File
@@ -95,7 +95,11 @@ bool prepared_mutations_are_canonical(const CellularPreparedCommit& prepared,
const auto decoded = server::decode_cellular_mutation_action_block(
prepared.mutations, manifest.begin_tick, manifest.end_tick);
if (!decoded || decoded->size() != selections || prepared.results.size() != selections ||
std::ranges::any_of(prepared.results, [](std::uint8_t result) { return result > 3; }))
std::ranges::any_of(prepared.results, [&](std::uint8_t result) {
return manifest.cellular_versions == cellular_v12_versions
? result != 1 && result != 3 && result != 4
: result > 3;
}))
return false;
const auto encoded = server::encode_cellular_mutation_action_block(
*decoded, manifest.begin_tick, manifest.end_tick);
@@ -116,10 +120,8 @@ bool prepared_is_canonical(const CellularPreparedCommit& prepared,
std::unexpected{server::CellularActionBlockError::format}};
const auto encoded_trace = server::encode_cellular_batch(trace);
const auto digest = sha256(prepared.trace);
const bool revision = cellular_revision_bundle(manifest.cellular_versions);
const bool trace_version_matches =
(revision && trace.format_version == server::cellular_batch_format) ||
(!revision && trace.format_version == server::cellular_batch_v2_format);
trace.format_version == cellular_checkpoint_trace_format(manifest.cellular_versions);
return manifest.profile == CheckpointProfile::cellular_lives_v1 && trace_version_matches &&
manifest.key == prepared.key && manifest.commit == prepared.commit &&
manifest.sequence > 0 && manifest.batch.trace_bytes == prepared.trace.size() && digest &&
@@ -240,7 +242,8 @@ retry_cellular_profile_migration(Postgres& db, const CellularProfileMigrationPre
!supported(*manifest) || !encode_manifest(*manifest) ||
!((manifest->profile == CheckpointProfile::cellular_lives_v1 &&
(manifest->cellular_versions == cellular_v2_versions ||
manifest->cellular_versions == cellular_v3_versions)) ||
manifest->cellular_versions == cellular_v3_versions ||
manifest->cellular_versions == cellular_v12_versions)) ||
((manifest->profile == CheckpointProfile::cellular_lives_v1 ||
manifest->profile == CheckpointProfile::cellular_population_v1) &&
(manifest->cellular_versions == cellular_v10_versions ||
@@ -282,7 +285,8 @@ std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
migrate_rules_profile(Postgres& db, const FilesystemObjectStore& objects, const LeaseGrant& lease,
const CommittedCheckpoint& predecessor, Uuid commit,
const Sha256Digest& build, milliseconds timeout, const PublishHooks& hooks,
bool maturation) {
decltype(&cellular_maturation_upgrade_payload) upgrade_payload,
decltype(&cellular_maturation_upgrade_manifest) derive) {
const auto previous = decode_manifest(predecessor.manifest);
const auto previous_digest = sha256(predecessor.manifest);
if (!previous || !previous_digest || predecessor.head.digest != *previous_digest ||
@@ -294,15 +298,12 @@ migrate_rules_profile(Postgres& db, const FilesystemObjectStore& objects, const
auto source = objects.get({previous->payload_sha256, previous->payload_bytes});
if (!source)
return std::unexpected(migration_failure(PublicationError::predecessor, source.error()));
auto payload = maturation ? cellular_maturation_upgrade_payload(*source, *previous)
: cellular_boundary_upgrade_payload(*source, *previous);
auto payload = upgrade_payload(*source, *previous);
if (!payload)
return std::unexpected(migration_failure(PublicationError::candidate));
const auto digest = sha256(*payload);
if (!digest)
return std::unexpected(migration_failure(PublicationError::digest));
const auto derive =
maturation ? cellular_maturation_upgrade_manifest : cellular_boundary_upgrade_manifest;
auto manifest =
derive(*previous, *previous_digest, commit, lease, build, payload->size(), *digest);
if (!manifest)
@@ -324,7 +325,8 @@ migrate_cellular_boundary_profile(Postgres& db, const FilesystemObjectStore& obj
Uuid commit, const Sha256Digest& build, milliseconds timeout,
const PublishHooks& hooks) {
return migrate_rules_profile(db, objects, lease, predecessor, commit, build, timeout, hooks,
false);
cellular_boundary_upgrade_payload,
cellular_boundary_upgrade_manifest);
}
std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
migrate_cellular_maturation_profile(Postgres& db, const FilesystemObjectStore& objects,
@@ -332,7 +334,18 @@ migrate_cellular_maturation_profile(Postgres& db, const FilesystemObjectStore& o
Uuid commit, const Sha256Digest& build, milliseconds timeout,
const PublishHooks& hooks) {
return migrate_rules_profile(db, objects, lease, predecessor, commit, build, timeout, hooks,
true);
cellular_maturation_upgrade_payload,
cellular_maturation_upgrade_manifest);
}
std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
migrate_cellular_inheritance_profile(Postgres& db, const FilesystemObjectStore& objects,
const LeaseGrant& lease,
const CommittedCheckpoint& predecessor, Uuid commit,
const Sha256Digest& build, milliseconds timeout,
const PublishHooks& hooks) {
return migrate_rules_profile(db, objects, lease, predecessor, commit, build, timeout, hooks,
cellular_inheritance_upgrade_payload,
cellular_inheritance_upgrade_manifest);
}
std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
@@ -483,9 +496,8 @@ publish_cellular_batch(Postgres& db, const FilesystemObjectStore& objects, const
const auto predecessor_digest = sha256(predecessor.manifest);
auto committed_batch = batch;
if (previous)
committed_batch.format_version = cellular_revision_bundle(previous->cellular_versions)
? server::cellular_batch_format
: server::cellular_batch_v2_format;
committed_batch.format_version =
cellular_checkpoint_trace_format(previous->cellular_versions);
const auto trace = server::encode_cellular_batch(committed_batch);
const auto action_block = server::encode_cellular_action_block(actions, batch.header.begin_tick,
batch.header.end_tick);
@@ -621,9 +633,11 @@ verify_cellular_no_tick_checkpoint(Postgres& db, const FilesystemObjectStore& ob
const LeaseGrant recorded{m.holder, m.epoch, m.frame, milliseconds{0}};
const bool boundary = m.cellular_versions == cellular_v10_versions;
const bool maturation = m.cellular_versions == cellular_v11_versions;
const auto derive = maturation ? cellular_maturation_upgrade_manifest
: boundary ? cellular_boundary_upgrade_manifest
: cellular_profile_migration_manifest;
const bool inheritance = m.cellular_versions == cellular_v12_versions;
const auto derive = inheritance ? cellular_inheritance_upgrade_manifest
: maturation ? cellular_maturation_upgrade_manifest
: boundary ? cellular_boundary_upgrade_manifest
: cellular_profile_migration_manifest;
auto expected = derive(*source, *source_digest, m.commit, recorded, m.build, m.payload_bytes,
m.payload_sha256);
if (!expected || *expected != m)
@@ -631,9 +645,10 @@ verify_cellular_no_tick_checkpoint(Postgres& db, const FilesystemObjectStore& ob
auto bytes = objects.get({source->payload_sha256, source->payload_bytes});
if (!bytes)
return fail(RecoveryError::tail);
if (boundary || maturation) {
auto upgraded = maturation ? cellular_maturation_upgrade_payload(*bytes, *source)
: cellular_boundary_upgrade_payload(*bytes, *source);
if (boundary || maturation || inheritance) {
auto upgraded = inheritance ? cellular_inheritance_upgrade_payload(*bytes, *source)
: maturation ? cellular_maturation_upgrade_payload(*bytes, *source)
: cellular_boundary_upgrade_payload(*bytes, *source);
if (!upgraded || !std::ranges::equal(*upgraded, payload))
return fail(RecoveryError::history);
} else {
@@ -712,9 +727,7 @@ recover_cellular_loaded(Postgres& db, const FilesystemObjectStore& objects, Regi
auto trace = server::decode_cellular_batch(*trace_bytes);
if (!trace)
return fail_with(RecoveryError::tail);
const bool revision = cellular_revision_bundle(manifest->cellular_versions);
if ((revision && trace->format_version != server::cellular_batch_format) ||
(!revision && trace->format_version != server::cellular_batch_v2_format))
if (trace->format_version != cellular_checkpoint_trace_format(manifest->cellular_versions))
return fail_with(RecoveryError::tail);
if (trace->header.world != key.world || trace->header.region != key.region ||
trace->header.frame != manifest->frame ||
+1 -1
View File
@@ -606,7 +606,7 @@ load_cellular_mutation_publications(Postgres& db, RegionKey key, const LeaseGran
const auto action = parse_integer<std::uint64_t>(row[1]);
const auto input = unhex<34>(row[2].value_or(std::string{}));
const auto result = parse_integer<std::uint32_t>(row[3]);
if (!account || !action || *action == 0 || !input || !result || *result > 3)
if (!account || !action || *action == 0 || !input || !result || *result > 4)
return std::unexpected{malformed(false)};
publications.push_back({*account, *action, *input, static_cast<std::uint8_t>(*result)});
}
+1
View File
@@ -99,6 +99,7 @@ network::AdmitStatus admit_status(CellularMutationAdmission admission) noexcept
network::ActionOutcome action_outcome(const FinalCellularMutation& mutation) noexcept {
return {mutation.action_id,
mutation.result == CellularMutationResult::applied ||
mutation.result == CellularMutationResult::offspring_plan_applied ||
mutation.result == CellularMutationResult::declined
? network::ActionResult::committed
: network::ActionResult::committed_no_effect,
+314
View File
@@ -24,6 +24,7 @@
void run_population_publication_tests();
namespace {
void retained_plan_admission();
using namespace evo;
using namespace evo::server;
using namespace evo::persistence;
@@ -3517,6 +3518,7 @@ void host_ownership_and_admission(Fixture& f) {
}
} // namespace
void run_population_publication_tests() {
retained_plan_admission();
Fixture fixture;
funded_source(fixture);
history_pages(fixture);
@@ -3594,3 +3596,315 @@ void run_population_publication_tests() {
std::puts("rules-9 durable migration and post-settlement funded growth passed");
std::puts("population publication, exact recovery, process loss and fencing passed");
}
namespace {
void retained_plan_admission() {
Fixture f;
f.key = {30205, 1};
f.next_id = 55000;
funded_source(f);
const std::array<Sha256Digest, 1> builds{f.build};
const auto reload = [&] {
auto db = connection();
auto loaded = take(recover_cellular_checkpoint(*db, *f.objects, f.key, f.lease, builds, 5s),
"plan recovery");
f.head = std::move(loaded.committed);
f.raw = std::move(loaded.state);
};
auto skipped = take(cellular_boundary_upgrade_manifest(
take(decode_manifest(f.head.manifest), "plan source"),
f.head.head.digest, f.id(), f.lease, f.build, f.raw->snapshot().size(),
take(sha256(f.raw->snapshot()), "plan source hash")),
"skipped plan fixture");
skipped.cellular_versions = cellular_v12_versions;
require(!publish_cellular_profile_migration(*f.db,
take(encode_manifest(skipped), "skip encode"), 5s),
"SQL plan upgrade skipped prerequisites");
f.head = take(
migrate_cellular_boundary_profile(*f.db, *f.objects, f.lease, f.head, f.id(), f.build, 5s),
"plan boundary prerequisite");
f.head = take(migrate_cellular_maturation_profile(*f.db, *f.objects, f.lease, f.head, f.id(),
f.build, 5s),
"plan maturation prerequisite");
reload();
const auto before = f.head;
const auto source = take(decode_manifest(before.manifest), "retained plan source");
const auto expected = take(f.raw->inheritance_upgrade_candidate(), "plan oracle")->snapshot();
Uuid account{};
account.back() = 1;
const auto pending_input =
encode_cellular_mutation_input({account, 57001, before.head.end_tick + 1, {100, 1, 1, 0}});
take(f.db->query("BEGIN", {}, 5s), "pending plan transaction");
take(reserve_cellular_mutation(*f.db, f.key, f.lease, account, 1, 57001, pending_input, 5s),
"pending plan reservation");
const auto pending = migrate_cellular_inheritance_profile(*f.db, *f.objects, f.lease, before,
f.id(), f.build, 5s);
require(!pending && std::string(pending.error().store.cause.sqlstate.data(), 5) == "EVL18",
"upgrade reinterpreted pending choice");
take(f.db->query("ROLLBACK", {}, 5s), "discard pending plan fixture");
// Valid same-cut biology with equal stock must still fail exact upgrade replay.
auto false_payload = expected;
const auto put = [](std::vector<std::uint8_t>& bytes, std::size_t offset, std::uint64_t value) {
for (unsigned i = 0; i < 8; ++i)
bytes.at(offset + i) = static_cast<std::uint8_t>(value >> (8U * i));
};
put(false_payload, 316 + 4 * 8 + 72, f.raw->lives().front().position.x_um + 1);
std::uint64_t fnv = 14695981039346656037ULL;
for (const auto byte : std::span{false_payload}.first(false_payload.size() - 8))
fnv = (fnv ^ byte) * 1099511628211ULL;
put(false_payload, false_payload.size() - 8, fnv);
const auto false_object = take(f.objects->put(false_payload), "false plan object");
const auto false_manifest = take(
cellular_inheritance_upgrade_manifest(source, before.head.digest, f.id(), f.lease, f.build,
false_object.bytes, false_object.sha256),
"false plan manifest");
require(take(restore_cellular_payload(false_payload, false_manifest), "valid false plan state")
->current_total() == f.raw->current_total() &&
false_payload != expected,
"false plan fixture changed inventory");
take(f.db->query("BEGIN", {}, 5s), "false plan transaction");
take(publish_cellular_profile_migration(
*f.db, take(encode_manifest(false_manifest), "false plan bytes"), 5s),
"false plan metadata");
const auto false_recovery =
recover_cellular_checkpoint(*f.db, *f.objects, f.key, f.lease, builds, 5s);
require(!false_recovery && false_recovery.error().kind == RecoveryError::history,
"false plan upgrade recovered by stock equality");
take(f.db->query("ROLLBACK", {}, 5s), "rollback false plan metadata");
take(
f.owner->query(
"CREATE FUNCTION evolution.test_refuse_plan55() RETURNS trigger LANGUAGE plpgsql AS $$ "
"BEGIN IF NEW.world_id=30205 THEN RAISE EXCEPTION 'plan55 fault' USING "
"ERRCODE='40001'; "
"END IF; RETURN NEW; END $$",
{}, 5s),
"plan fault function");
take(f.owner->query(
"CREATE TRIGGER test_refuse_plan55 BEFORE INSERT ON evolution.region_commits "
"FOR EACH ROW EXECUTE FUNCTION evolution.test_refuse_plan55()",
{}, 5s),
"plan fault trigger");
const auto rejected = migrate_cellular_inheritance_profile(*f.db, *f.objects, f.lease, before,
f.id(), f.build, 5s);
take(f.owner->query("DROP TRIGGER test_refuse_plan55 ON evolution.region_commits", {}, 5s),
"drop plan fault trigger");
take(f.owner->query("DROP FUNCTION evolution.test_refuse_plan55()", {}, 5s),
"drop plan fault function");
require(!rejected && take(load_region_checkpoint(*f.db, f.key, 5s), "plan failed head").head ==
before.head,
"failed plan result advanced head");
const auto evidence = take(
f.owner->query(
"SELECT count(*)::text FROM evolution.cellular_profile_migrations WHERE world_id=30205 "
"AND "
"target_versions='"
"\\x0a0000000800000002000000010000000100000004000000030000000200000001000000'::bytea",
{}, 5s),
"failed plan evidence");
require(evidence.front().front() == "0", "failed plan result retained upgrade journal");
const auto killed_id = f.id();
const auto child = ::fork();
require(child >= 0, "plan process fork");
if (child == 0) {
auto db = connection();
PublishHooks hooks;
hooks.before_transaction = [] { ::kill(::getpid(), SIGKILL); };
[[maybe_unused]] const auto result = migrate_cellular_inheritance_profile(
*db, *f.objects, f.lease, before, killed_id, f.build, 5s, hooks);
::_exit(32);
}
int status{};
require(::waitpid(child, &status, 0) == child && WIFSIGNALED(status) &&
WTERMSIG(status) == SIGKILL &&
take(load_region_checkpoint(*f.db, f.key, 5s), "killed plan head").head ==
before.head,
"pre-transaction process loss published plan upgrade");
auto locker = connection(true);
take(locker->query("BEGIN", {}, 5s), "uncertain plan transaction");
take(
locker->query(
"SELECT 1 FROM evolution.region_leases WHERE world_id=30205 AND region_id=1 FOR UPDATE",
{}, 5s),
"hold plan lease lock");
auto timed = connection();
const auto unknown = migrate_cellular_inheritance_profile(*timed, *f.objects, f.lease, before,
f.id(), f.build, 300ms);
if (unknown)
throw std::runtime_error("plan lock did not cause ambiguous publication");
require(unknown.error().kind == PublicationError::unknown &&
!unknown.error().prepared.manifest.empty(),
"ambiguous plan request lost exact bytes");
take(locker->query("ROLLBACK", {}, 5s), "release plan lease lock");
const auto prepared = unknown.error().prepared;
auto writer = connection();
f.head = take(retry_cellular_profile_migration(*writer, prepared, 5s), "retry plan request");
require(take(retry_cellular_profile_migration(*writer, prepared, 5s), "duplicate plan request")
.head == f.head.head,
"duplicate plan request advanced head");
auto conflict = prepared;
auto changed = take(decode_manifest(conflict.manifest), "changed plan retry");
++changed.build[0];
conflict.manifest = take(encode_manifest(changed), "changed plan bytes");
require(!retry_cellular_profile_migration(*writer, conflict, 5s),
"changed plan retry accepted");
reload();
require(f.raw->snapshot() == expected && f.head.head.end_tick == before.head.end_tick,
"durable plan upgrade changed biology or time");
require(!migrate_cellular_inheritance_profile(*f.db, *f.objects, f.lease, f.head, f.id(),
f.build, 5s) &&
!migrate_cellular_to_population(*f.db, *f.objects, f.lease, f.head, f.id(), f.build,
{true, 1200, 1800}, 5s),
"repeated plan upgrade or population bypass");
const auto path = f.objects->directory() / hexadecimal(source.payload_sha256, false);
const auto backup = path.string() + ".plan55-test";
std::filesystem::rename(path, backup);
const auto missing = recover_cellular_checkpoint(*f.db, *f.objects, f.key, f.lease, builds, 5s);
{
std::ofstream corrupt(path, std::ios::binary);
corrupt << 'X';
}
const auto corrupt = recover_cellular_checkpoint(*f.db, *f.objects, f.key, f.lease, builds, 5s);
std::filesystem::remove(path);
std::filesystem::rename(backup, path);
require(!missing && !corrupt, "unusable retained source allowed fallback");
reload();
const auto step = [&](unsigned count, bool bud) {
CellularBatch batch{f.header(count), {}};
batch.format_version = cellular_batch_inheritance_format;
for (unsigned tick = 0; tick < count; ++tick) {
auto inputs = take(wildlife_intents(*f.raw, f.raw->tick() + 1), "plan wildlife");
for (const auto& life : f.raw->lives()) {
if (life.account == LifeAccount{})
continue;
CellularLifeIntent input{life.identity.life, {}};
input.intent.frozen = life.identity.life != 100;
input.intent.bud = life.identity.life == 100 && bud;
inputs.push_back(input);
}
std::ranges::sort(inputs, {}, &CellularLifeIntent::life_id);
take(f.raw->advance_tick(inputs), "plan biological tick");
batch.ticks.push_back({std::move(inputs), {}, {}});
}
f.head = take(publish_cellular_batch(*f.db, *f.objects, f.lease, f.head, batch, *f.raw,
f.id(), f.build, 5s),
"plan trace-4 publication")
.committed;
take(renew_region_lease(*f.db, f.key, f.lease, 60000ms, 5s), "plan writer renewal");
};
step(1, false);
for (unsigned tries = 0; tries < 1000 && !f.raw->lives().front().mutation.offer; ++tries)
step(64, false);
const auto parent = f.raw->lives().front();
const auto offer = parent.mutation.offer;
if (!offer)
throw std::runtime_error("durable inherited offer missing");
require(parent.identity.life == 100, "durable plan actor died");
const auto control = take(
claim_account_control(*f.db, f.key, f.lease, account, 2, 101, 60000ms, 5s), "plan control");
CellularMutationActionRecord action{account,
57002,
f.raw->tick() + 1,
{100, parent.mutation.event_index,
parent.mutation.offer_tick,
offer->candidates.front().operator_id}};
const auto reservation = take(
reserve_cellular_mutation(*f.db, f.key, f.lease, account, control.generation,
action.action_id, encode_cellular_mutation_input(action), 5s),
"plan selection reservation");
CellularBatch chosen{f.header(1), {}};
chosen.format_version = cellular_batch_inheritance_format;
auto inputs = take(wildlife_intents(*f.raw, f.raw->tick() + 1), "selected plan wildlife");
for (const auto& life : f.raw->lives()) {
if (life.account == LifeAccount{})
continue;
CellularLifeIntent input{life.identity.life, {}};
input.intent.frozen = life.identity.life != 100;
inputs.push_back(input);
}
std::ranges::sort(inputs, {}, &CellularLifeIntent::life_id);
chosen.ticks.push_back({inputs,
{},
{{100, action.input.event_index, action.input.offer_tick,
reservation.successor_identity, action.input.operator_id}}});
const auto executed =
take(f.raw->advance_tick_with_mutations(inputs, chosen.ticks.front().mutations),
"select durable plan");
require(executed.mutations.front().result == CellularMutationResult::offspring_plan_applied &&
f.raw->lives().front().identity.genome == parent.identity.genome,
"plan changed expressed genome");
const auto trace_bytes = take(encode_cellular_batch(chosen), "selected trace bytes");
const auto block =
take(encode_cellular_mutation_action_block(std::span{&action, 1}, chosen.header.begin_tick,
chosen.header.end_tick),
"selected mutation block");
const auto candidate_manifest =
take(successor_manifest(
take(decode_manifest(f.head.manifest), "selected predecessor manifest"),
f.head.head.digest, f.id(), f.lease, f.raw->tick(), f.build,
f.raw->snapshot().size(), take(sha256(f.raw->snapshot()), "selected payload hash"),
{trace_bytes.size(), take(sha256(trace_bytes), "selected trace hash"), 0, {}}),
"selected metadata fixture");
for (const std::uint8_t bad_result :
{std::uint8_t{0}, std::uint8_t{2}, std::uint8_t{3}, std::uint8_t{5}})
require(!publish_cellular_mutation_checkpoint(
*f.db, take(encode_manifest(candidate_manifest), "bad-result manifest"), {}, {},
trace_bytes, block, std::span{&bad_result, 1}, 5s),
"SQL admitted a foreign inherited result meaning");
auto old_trace = chosen;
old_trace.format_version = cellular_batch_format;
const auto old_bytes = take(encode_cellular_batch(old_trace), "wrong-version trace");
auto bad_pair = candidate_manifest;
bad_pair.batch.trace_sha256 = take(sha256(old_bytes), "wrong-version trace hash");
const std::uint8_t applied = 4;
require(!publish_cellular_mutation_checkpoint(
*f.db, take(encode_manifest(bad_pair), "wrong-pair manifest"), {}, {}, old_bytes,
block, std::span{&applied, 1}, 5s) &&
take(load_region_checkpoint(*f.db, f.key, 5s), "failed result head").head ==
f.head.head,
"SQL mixed trace versions or retained a rejected result");
auto altered_trace = trace_bytes;
altered_trace.at(cellular_batch_header_bytes + cellular_batch_tick_header_bytes + 8) = 1;
require(!publish_cellular_mutation_checkpoint(
*f.db, take(encode_manifest(candidate_manifest), "trace digest fixture"), {}, {},
altered_trace, block, std::span{&applied, 1}, 5s),
"parser normalization bypassed the actual trace digest");
const auto selected =
take(publish_cellular_batch(*f.db, *f.objects, f.lease, f.head, chosen, *f.raw, f.id(),
f.build, 5s, {}, {}, std::span{&action, 1}),
"durable plan publication");
f.head = selected.committed;
require(selected.mutation_results ==
std::vector{CellularMutationResult::offspring_plan_applied},
"plan result lost meaning");
const auto selected_bytes = f.raw->snapshot();
reload();
require(f.raw->snapshot() == selected_bytes, "selected plan did not recover exactly");
std::size_t born = 0;
for (unsigned tries = 0; tries < 500 && born < 2; ++tries) {
step(64, true);
born =
static_cast<std::size_t>(std::ranges::count_if(f.raw->lives(), [&](const auto& life) {
return life.parent_life == 100 &&
life.identity.genome == reservation.successor_identity;
}));
for (const auto& corpse : f.raw->corpses())
if (corpse.parent_life == 100 &&
take(f.raw->archive().organism(corpse.organism), "inherited dead sibling").genome ==
reservation.successor_identity)
++born;
}
require(born >= 2, "durable parent never repeated its selected offspring plan");
const auto final_bytes = f.raw->snapshot();
const auto stale = f.lease;
take(release_region_lease(*f.db, f.key, f.lease, 5s), "release plan writer");
f.lease =
take(acquire_region_lease(*f.db, f.key, f.build, 60000ms, 5s), "replacement plan writer");
require(!retry_cellular_profile_migration(*f.db, prepared, 5s) &&
!migrate_cellular_inheritance_profile(*f.db, *f.objects, stale, before, f.id(),
f.build, 5s),
"stale plan writer escaped fence");
reload();
require(f.raw->snapshot() == final_bytes, "replacement changed inherited family");
std::puts("retained-plan upgrade, choices, births, exact recovery and faults passed");
}
} // namespace
+2 -1
View File
@@ -220,6 +220,7 @@ void upgrade_across_migration_and_barrier() {
" -v migration_sha_52=$(s 0052_census_pending_migrations.sql)"
" -v migration_sha_53=$(s 0053_funded_cellular_maturation.sql)"
" -v migration_sha_54=$(s 0054_maturing_cellular_migration.sql)"
" -v migration_sha_55=$(s 0055_retained_cellular_plans.sql)"
" -v runtime_role=evo_runtime_test -f migrations/apply.sql"
" > /dev/null 2>&1") != 0);
CHECK(history(*owner_db) == "1,2,3,4,5,6,7");
@@ -237,7 +238,7 @@ void upgrade_across_migration_and_barrier() {
"tools/migrate-postgres.sh\" > /dev/null") == 0);
CHECK(history(*owner_db) == "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,"
"25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,"
"47,48,49,50,51,52,53,54");
"47,48,49,50,51,52,53,54,55");
CHECK(scalar(*owner_db, "SELECT (c.condeferrable AND c.condeferred AND "
"c.confrelid = 'evolution.region_commits'::regclass)::text "
"FROM pg_catalog.pg_constraint c WHERE c.conrelid = "
+8 -1
View File
@@ -58,19 +58,24 @@ for invalid in NULL "'00000000-0000-0000-0000-000000000000'"; do
done
# Reconstruct the exact pre-context metadata schema in this disposable database.
# Restore the resulting real legacy backup through both supported workflows.
# Undo schema 54's three replacements as well as schema 53 below; the legacy
# Undo schema 55's plan validators, schema 54's three replacements and schema 53;
# backup must contain the actual pre-context function contracts and privileges.
awk '/^CREATE FUNCTION evolution\.(check_cellular_migration_trace|prepare_cellular_migration_freeze|publish_cellular_migration)\(/ {capture=1; sub(/^CREATE FUNCTION/,"CREATE OR REPLACE FUNCTION")} capture {print} capture && /^END \$\$;/ {capture=0}' \
"$root/migrations/0047_cellular_migration_freeze.sql" \
"$root/migrations/0049_cellular_migration_publication.sql" | sql > /dev/null
awk '/^CREATE OR REPLACE FUNCTION evolution\.(cellular_mutation_selections|check_cellular_mutation_block)\(/ {capture=1} capture {print} capture && /^END \$\$;/ {capture=0}' \
"$root/migrations/0040_cellular_mutation_decline.sql" | sql > /dev/null
sql -v runtime_role="$EVO_PG_RUNTIME_ROLE" > /dev/null <<'SQL'
DROP FUNCTION evolution.parse_checkpoint_manifest(bytea);
DROP FUNCTION evolution.parse_checkpoint_manifest_v54(bytea);
ALTER FUNCTION evolution.parse_checkpoint_manifest_v52(bytea) RENAME TO parse_checkpoint_manifest;
DROP FUNCTION evolution.cellular_births(bytea,bytea);
DROP FUNCTION evolution.cellular_births_v54(bytea,bytea);
ALTER FUNCTION evolution.cellular_births_v52(bytea,bytea) RENAME TO cellular_births;
DROP FUNCTION evolution.check_population_trace(bytea,bytea);
ALTER FUNCTION evolution.check_population_trace_v52(bytea,bytea) RENAME TO check_population_trace;
DROP FUNCTION evolution.publish_cellular_profile_migration(bytea);
DROP FUNCTION evolution.publish_cellular_profile_migration_v54(bytea);
ALTER FUNCTION evolution.publish_cellular_profile_migration_v52(bytea) RENAME TO publish_cellular_profile_migration;
GRANT EXECUTE ON FUNCTION evolution.publish_cellular_profile_migration(bytea) TO :"runtime_role";
DROP FUNCTION evolution.publish_population_profile_transition_v44(bytea);
@@ -79,6 +84,8 @@ DROP FUNCTION evolution.fork_restored_history_v1(uuid);
DROP FUNCTION evolution.load_world_cellular_migrations_v1(evolution.u64);
DROP FUNCTION evolution.load_history_domain_v1();
DROP TABLE evolution.history_domain_cuts, evolution.current_history_domain, evolution.history_domains;
ALTER TABLE evolution.cellular_mutation_action_publications DROP CONSTRAINT cellular_mutation_action_publications_result_check;
ALTER TABLE evolution.cellular_mutation_action_publications ADD CONSTRAINT cellular_mutation_action_publications_result_check CHECK(result BETWEEN 0 AND 3);
DELETE FROM evolution.schema_migrations WHERE version>=51;
UPDATE evolution.retained_builds SET retired_at=NULL;
SQL
+5 -5
View File
@@ -154,7 +154,7 @@ PGDATABASE=upgrade_path psql -X -v ON_ERROR_STOP=1 -1 -v "migration_sha=$v1_sha"
-f "$root/migrations/0001_region_bootstrap.sql" > /dev/null
test "$(PGDATABASE=upgrade_path psql -XAtc "SELECT string_agg(version::text, ',') FROM evolution.schema_migrations")" = 1
PGDATABASE=upgrade_path bash "$root/tools/migrate-postgres.sh"
test "$(PGDATABASE=upgrade_path psql -XAtc "SELECT string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54
test "$(PGDATABASE=upgrade_path psql -XAtc "SELECT string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55
# v2 heads have no payload binding: v2->v3 fails closed and leaves history at v2.
v2_sha="$(sha256sum "$root/migrations/0002_region_fencing.sql")"
v2_sha="${v2_sha%% *}"
@@ -175,7 +175,7 @@ PGDATABASE=v3_commits psql -X -v ON_ERROR_STOP=1 \
-c "INSERT INTO evolution.retained_builds VALUES (decode(repeat('b1', 32), 'hex'))" \
-c "SELECT evolution.provision_region_checkpoint(decode('4145564f52434d31' || '01000000' || '01000000' || '0100000000000000' || '0100000000000000' || '0900000000000000' || repeat('11', 16) || repeat('00', 8) || repeat('00', 16) || repeat('00', 32) || repeat('00', 16) || repeat('00', 16) || repeat('00', 8) || '50c3000000000000' || '020000000200000001000000010000000100000001000000010000000100000001000000' || repeat('b1', 32) || '00000000' || '00000000' || '01000000' || '6400000000000000' || repeat('a0', 32), 'hex'))" > /dev/null
PGDATABASE=v3_commits bash "$root/tools/migrate-postgres.sh"
test "$(PGDATABASE=v3_commits psql -XAtc "SELECT count(*) || ':' || string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 54:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54
test "$(PGDATABASE=v3_commits psql -XAtc "SELECT count(*) || ':' || string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 55:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55
test "$(PGDATABASE=v3_commits psql -XAtc "SELECT count(*) FROM evolution.region_commits")" = 1
# Review P1: a v4 database holding a published (possibly terminal) checkpoint has
# no durable decisions for it. The v5 upgrade must refuse before changing anything.
@@ -229,7 +229,7 @@ PGDATABASE=v6_populated psql -X -v ON_ERROR_STOP=1 \
-c "INSERT INTO evolution.retained_builds VALUES (decode(repeat('b1', 32), 'hex'))" \
-c "SELECT evolution.provision_region_checkpoint(decode('4145564f52434d31' || '02000000' || '01000000' || '0100000000000000' || '0100000000000000' || '0900000000000000' || repeat('11', 16) || repeat('00', 8) || repeat('00', 16) || repeat('00', 32) || repeat('00', 16) || repeat('00', 16) || repeat('00', 8) || '50c3000000000000' || '020000000200000001000000010000000100000001000000010000000100000001000000' || repeat('b1', 32) || '00000000' || '00000000' || '01000000' || '6400000000000000' || repeat('a0', 32) || repeat('00', 80), 'hex'))" > /dev/null
PGDATABASE=v6_populated bash "$root/tools/migrate-postgres.sh"
test "$(PGDATABASE=v6_populated psql -XAtc "SELECT string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54
test "$(PGDATABASE=v6_populated psql -XAtc "SELECT string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55
test "$(PGDATABASE=v6_populated psql -XAtc "SELECT count(*) FROM evolution.region_commits c, LATERAL evolution.parse_checkpoint_manifest(c.manifest) m WHERE m.commit_sequence = 0 AND m.predecessor_commit IS NULL")" = 1
test "$(PGDATABASE=v6_populated psql -XAtc "SELECT string_agg(conname, ',') FROM pg_constraint WHERE conrelid = 'evolution.region_heads'::regclass AND contype = 'c' AND pg_get_constraintdef(oid) LIKE '%end_tick%'")" = region_heads_published_tick
phase permission-audit
@@ -287,9 +287,9 @@ expect_audit_failure 'REVOKE EXECUTE ON FUNCTION evolution.load_world_cellular_m
expect_audit_failure 'GRANT EXECUTE ON FUNCTION evolution.fork_restored_history_v1(uuid) TO evo_runtime_test' 'REVOKE EXECUTE ON FUNCTION evolution.fork_restored_history_v1(uuid) FROM evo_runtime_test'
phase checksum-drift
# Unknown future versions and checksum drift must not be repaired silently.
psql -X -v ON_ERROR_STOP=1 -c 'UPDATE evolution.schema_migrations SET version=55 WHERE version=54'
psql -X -v ON_ERROR_STOP=1 -c 'UPDATE evolution.schema_migrations SET version=56 WHERE version=55'
if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET version=54 WHERE version=55"
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET version=55 WHERE version=56"
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=14"
if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=13"
+3
View File
@@ -120,6 +120,8 @@ digest_53="$(sha256sum "$root/migrations/0053_funded_cellular_maturation.sql")"
digest_53="${digest_53%% *}"
digest_54="$(sha256sum "$root/migrations/0054_maturing_cellular_migration.sql")"
digest_54="${digest_54%% *}"
digest_55="$(sha256sum "$root/migrations/0055_retained_cellular_plans.sql")"
digest_55="${digest_55%% *}"
psql -X --no-password --set=ON_ERROR_STOP=1 --set="migration_sha=$digest" \
--set="migration_sha_2=$digest_2" --set="migration_sha_3=$digest_3" \
--set="migration_sha_4=$digest_4" --set="migration_sha_5=$digest_5" \
@@ -166,5 +168,6 @@ psql -X --no-password --set=ON_ERROR_STOP=1 --set="migration_sha=$digest" \
--set="migration_sha_51=$digest_51" \
--set="migration_sha_52=$digest_52" \
--set="migration_sha_53=$digest_53" --set="migration_sha_54=$digest_54" \
--set="migration_sha_55=$digest_55" \
--set="runtime_role=$runtime_role" \
--file="$root/migrations/apply.sql"