Pin the cellular v4 bundle and admit it in schema v34
Foundation / checks (checks) (push) Successful in 41m8s
Foundation / checks (deploy) (push) Successful in 4m26s
Foundation / checks (ecs) (push) Successful in 2m29s
Foundation / checks (network) (push) Successful in 19m43s
Foundation / checks (postgres) (push) Successful in 44m7s
Foundation / checks (tsan) (push) Successful in 10m5s
Foundation / checks (client) (push) Successful in 13m57s
Foundation / postgres-tools (push) Successful in 1m24s
Foundation / image (push) Successful in 3m20s
Foundation / server-image (push) Successful in 3m23s

ADR-0124: checkpoints pin cellular bundle v4 (rules 3, owner envelope 4,
revision archive) with the revision history profile and format-3 traces.
A format-4/rules-3 opening provisions on v4, and evo-world-clone accepts
--opening cellular-v2 for it. Migration 34 widens canonical action input
validation to target kind 2 (engulf, no coordinates), admits v4 manifests
through the existing v3 parser chain, and lets birth binding read
format-3 traces for v3 and v4. The migration runner and its checks extend
to version 34, with SQL and provisioning tests for v4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-13 19:11:43 -04:00
co-authored by Claude Opus 5.5
parent e17ade8cb7
commit bf5c626f19
15 changed files with 380 additions and 95 deletions
+14 -11
View File
@@ -10,16 +10,16 @@
// evo-world-clone check-store --world W --region R --pg-* ... --objects DIR // evo-world-clone check-store --world W --region R --pg-* ... --objects DIR
// [--reserve-mib N] // [--reserve-mib N]
// evo-world-clone provision --world W --region R --opening // evo-world-clone provision --world W --region R --opening
// development-v1|primitive-v1|cellular-v1 // development-v1|primitive-v1|cellular-v1|cellular-v2
// --pg-* ... --objects DIR --build HEX [--commit HEX32] [--retain-build] // --pg-* ... --objects DIR --build HEX [--commit HEX32] [--retain-build]
// primitive-v1 also requires --frame N --source-id N, every --funding-*-* channel, // primitive-v1 also requires --frame N --source-id N, every --funding-*-* channel,
// and one or more ordered --site X,Y values. // and one or more ordered --site X,Y values.
// cellular-v1 also requires --width-um N --height-um N --ambient-temperature-mk N // cellular-v1 and cellular-v2 also require --width-um N --height-um N
// and one or more ordered --patch X,Y,SOURCE,ENERGY,C,N,P,O values plus a stable --commit // --ambient-temperature-mk N and one or more ordered --patch X,Y,SOURCE,ENERGY,C,N,P,O values
// HEX32. // plus a stable --commit HEX32. cellular-v2 is the same opening on rules 3 (ADR-0124:
// primitive-v1 and cellular-v1 accept --life-allocator-start N (ADR-0123): the world's // engulfment, detritus). primitive-v1 and cellular-v1/v2 accept --life-allocator-start N
// life-identity allocator is created once at the operator-audited start N; a later run // (ADR-0123): the world's life-identity allocator is created once at the operator-audited
// leaves it untouched and refuses one that is below N. // start N; a later run leaves it untouched and refuses one that is below N.
// evo-world-clone compare --world A --region R --other-world B --pg-* ... // evo-world-clone compare --world A --region R --other-world B --pg-* ...
// --objects DIR [--other-objects DIR] --retained HEX... [--max-commits N] // --objects DIR [--other-objects DIR] --retained HEX... [--max-commits N]
// //
@@ -271,7 +271,8 @@ std::optional<Options> parse(int argc, char** argv) {
else if (o.command == "check-store" && flag == "--reserve-mib" && n && *n <= 1048576) else if (o.command == "check-store" && flag == "--reserve-mib" && n && *n <= 1048576)
o.reserve_mib = *n; o.reserve_mib = *n;
else if (o.command == "provision" && flag == "--opening" && else if (o.command == "provision" && flag == "--opening" &&
(value == "development-v1" || value == "primitive-v1" || value == "cellular-v1")) (value == "development-v1" || value == "primitive-v1" || value == "cellular-v1" ||
value == "cellular-v2"))
o.opening = value; o.opening = value;
else if (o.command == "provision" && flag == "--frame" && n) else if (o.command == "provision" && flag == "--frame" && n)
o.primitive_frame = n; o.primitive_frame = n;
@@ -344,7 +345,7 @@ std::optional<Options> parse(int argc, char** argv) {
return std::nullopt; return std::nullopt;
if (cellular_options) if (cellular_options)
return std::nullopt; return std::nullopt;
} else if (o.opening == "cellular-v1") { } else if (o.opening == "cellular-v1" || o.opening == "cellular-v2") {
const bool has_stock = std::ranges::any_of(o.cellular_patches, [](const auto& patch) { const bool has_stock = std::ranges::any_of(o.cellular_patches, [](const auto& patch) {
return patch.stock.energy.value != 0 || return patch.stock.energy.value != 0 ||
std::ranges::any_of(patch.stock.matter, std::ranges::any_of(patch.stock.matter,
@@ -453,7 +454,7 @@ std::vector<std::uint8_t> probe_bytes() {
int provision(const Options& o) { int provision(const Options& o) {
const bool primitive = o.opening == "primitive-v1"; const bool primitive = o.opening == "primitive-v1";
const bool cellular = o.opening == "cellular-v1"; const bool cellular = o.opening == "cellular-v1" || o.opening == "cellular-v2";
const auto primitive_frame = o.primitive_frame.value_or(0); const auto primitive_frame = o.primitive_frame.value_or(0);
if ((primitive || cellular) && primitive_frame == 0) if ((primitive || cellular) && primitive_frame == 0)
return 2; return 2;
@@ -555,7 +556,9 @@ int provision(const Options& o) {
} }
auto opening = server::CellularLives::create( auto opening = server::CellularLives::create(
*primitive_opening, std::move(*habitat), *primitive_opening, std::move(*habitat),
{{cellular_width_um, cellular_height_um}, 0, cellular_temperature_mk}); {{cellular_width_um, cellular_height_um}, 0, cellular_temperature_mk},
o.opening == "cellular-v2" ? server::CellularLivesProfile::engulf
: server::CellularLivesProfile::offers);
if (!opening) { if (!opening) {
std::printf("cellular opening refused %u\n", static_cast<unsigned>(opening.error())); std::printf("cellular opening refused %u\n", static_cast<unsigned>(opening.error()));
return 4; return 4;
@@ -12,7 +12,7 @@ spec:
env: env:
- {name: REGION_SESSION, value: "dev"} - {name: REGION_SESSION, value: "dev"}
- {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"} - {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"}
- {name: REGION_SESSION_WINDOW, value: "dev-20261013T230446-66189:1791943486"} - {name: REGION_SESSION_WINDOW, value: "dev-20261013T231142-52381:1791943902"}
- {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"} - {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"}
ports: ports:
# QUIC (ADR-0090): UDP only; nothing listens on TCP 7400. # QUIC (ADR-0090): UDP only; nothing listens on TCP 7400.
+7
View File
@@ -436,6 +436,13 @@ scoped change before starting the next segment.
flag, and no longer reports an unencodable message as sent. SQL admission of flag, and no longer reports an unencodable message as sent. SQL admission of
kind 2 and the rules-3 bundle remain. kind 2 and the rules-3 bundle remain.
- 11.3f-4 (ADR-0124): checkpoints pin cellular bundle v4 (rules 3, envelope
4) with the revision history profile and format-3 traces; `evo-world-clone
provision --opening cellular-v2` provisions a rules-3 genesis on it. Schema
migration 34 widens canonical input validation to kind 2 and normalizes v4
manifests through the v3 parser chain, and birth binding accepts format-3
traces for v3 and v4. Deployment remains.
## Exit boundary ## Exit boundary
11.3 closes only when the documented segments have evidence and the player-facing 11.3 closes only when the documented segments have evidence and the player-facing
+18
View File
@@ -7258,3 +7258,21 @@ Executed locally: MSVC Debug `ctest` 68/68; client-network build with
cannot send one) passing; `motion-trace-smoke` failed once under `-j 6` load cannot send one) passing; `motion-trace-smoke` failed once under `-j 6` load
and passed alone. g++-14 `-Werror`, clang-tidy-19 (two existing reports in the and passed alone. g++-14 `-Werror`, clang-tidy-19 (two existing reports in the
mutation test remain) and clang-format 19.1.5. mutation test remain) and clang-format 19.1.5.
## 2026-10-13 — M11.3f-4 cellular v4 bundle and schema v34 (CI pending)
`cellular_v4_versions` (rules 3, envelope 4, archive 2) joins the allowed
cellular bundles with the revision history profile; a helper selects
format-3 traces for v3 and v4 in publication, preparation and recovery.
Provisioning maps a format-4/rules-3 opening to v4, and `evo-world-clone`
accepts `--opening cellular-v2` for it. Migration 34 replaces
`valid_cellular_action_input` (kind 2 with zero coordinates), wraps
`parse_checkpoint_manifest` to admit v4 through the v3 chain, and lets
`cellular_births` read format-3 traces for v3 and v4. `apply.sql`,
`migrate-postgres.sh` and `postgres-check.sh` extend to version 34.
Executed locally: MSVC Debug `ctest` 68/68, including region-checkpoint
contracts for the v4 genesis (round trip, restore, wrong history, v3 bundle
refusal, successor); g++-14 `-Werror` and clang-tidy-19 on the persistence,
provisioner and PostgreSQL test sources; `bash -n` on both scripts. The SQL
migration, `region_migration_tests` (v34 history, kind-2 input validation) and
`region_store_tests` (cellular-v2 provisioning under v4) run only in CI.
@@ -53,6 +53,12 @@ struct CellularVersionBundle {
inline constexpr CellularVersionBundle cellular_v1_versions{}; inline constexpr CellularVersionBundle cellular_v1_versions{};
inline constexpr CellularVersionBundle cellular_v2_versions{2, 2, 1, 1, 1, 2, 1, 1, 1}; inline constexpr CellularVersionBundle cellular_v2_versions{2, 2, 1, 1, 1, 2, 1, 1, 1};
inline constexpr CellularVersionBundle cellular_v3_versions{2, 3, 1, 1, 1, 2, 1, 2, 1}; inline constexpr CellularVersionBundle cellular_v3_versions{2, 3, 1, 1, 1, 2, 1, 2, 1};
// ADR-0124: rules 3 (engulfment, detritus) and owner envelope 4 (corpse causes).
inline constexpr CellularVersionBundle cellular_v4_versions{3, 4, 1, 1, 1, 2, 1, 2, 1};
// Bundles with genome revisions: the revision history profile and format-3 traces.
[[nodiscard]] constexpr bool cellular_revision_bundle(const CellularVersionBundle& b) noexcept {
return b == cellular_v3_versions || b == cellular_v4_versions;
}
// Batch evidence bound by manifest v2 (ADR-0063); all zero at genesis. // Batch evidence bound by manifest v2 (ADR-0063); all zero at genesis.
struct BatchDigests { struct BatchDigests {
@@ -0,0 +1,145 @@
-- M11.3f, ADR-0124: admit the cellular-v4 bundle (rules 3: engulfment and detritus;
-- owner envelope 4: corpse causes) and canonical action target kind 2 (engulf).
-- Earlier bundles, kinds and committed rows keep their exact meaning.
-- Byte 12 of the canonical input is a target kind: 0 none, 1 patch, 2 engulf. Only a
-- patch target carries coordinates. Widening cannot invalidate an existing row.
CREATE OR REPLACE FUNCTION evolution.valid_cellular_action_input(p_input bytea, p_tick evolution.u64)
RETURNS boolean LANGUAGE plpgsql IMMUTABLE STRICT
SET search_path = pg_catalog, pg_temp AS $$
BEGIN
IF octet_length(p_input) <> 24 THEN
RETURN false;
END IF;
IF evolution.manifest_uint(p_input, 0, 8) = 0
OR evolution.manifest_uint(p_input, 0, 8) <> p_tick OR get_byte(p_input, 12) > 2
OR substring(p_input FROM 14 FOR 3) <> '\x000000' THEN
RETURN false;
END IF;
IF get_byte(p_input, 12) <> 1 AND substring(p_input FROM 17 FOR 8) <> '\x0000000000000000' THEN
RETURN false;
END IF;
RETURN true;
END $$;
-- The v4 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_v33;
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';
v4_bundle constant bytea := '\x030000000400000001000000010000000100000002000000010000000200000001000000';
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) = v4_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_v33(overlay(m PLACING v3_bundle FROM 161 FOR 36));
r.versions := v4_bundle;
RETURN r;
END IF;
RETURN evolution.parse_checkpoint_manifest_v33(m);
END $$;
REVOKE ALL ON FUNCTION evolution.parse_checkpoint_manifest(bytea) FROM PUBLIC;
-- Birth binding: v3 and v4 publications carry format-3 traces; earlier bundles format 2.
-- Otherwise unchanged from schema v28.
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);
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 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 (34, :'migration_sha_34');
+19 -4
View File
@@ -109,6 +109,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
SELECT :'history_v30' || ',31:' || :'migration_sha_31' AS history_v31 \gset SELECT :'history_v30' || ',31:' || :'migration_sha_31' AS history_v31 \gset
SELECT :'history_v31' || ',32:' || :'migration_sha_32' AS history_v32 \gset SELECT :'history_v31' || ',32:' || :'migration_sha_32' AS history_v32 \gset
SELECT :'history_v32' || ',33:' || :'migration_sha_33' AS history_v33 \gset SELECT :'history_v32' || ',33:' || :'migration_sha_33' AS history_v33 \gset
SELECT :'history_v33' || ',34:' || :'migration_sha_34' AS history_v34 \gset
SELECT :'history' = :'history_v22' AS at_v22, SELECT :'history' = :'history_v22' AS at_v22,
:'history' = :'history_v23' AS at_v23, :'history' = :'history_v23' AS at_v23,
:'history' = :'history_v24' AS at_v24, :'history' = :'history_v24' AS at_v24,
@@ -120,8 +121,10 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
:'history' = :'history_v30' AS at_v30, :'history' = :'history_v30' AS at_v30,
:'history' = :'history_v31' AS at_v31, :'history' = :'history_v31' AS at_v31,
:'history' = :'history_v32' AS at_v32, :'history' = :'history_v32' AS at_v32,
:'history' = :'history_v33' AS at_v33 \gset :'history' = :'history_v33' AS at_v33,
\if :at_v33 :'history' = :'history_v34' AS at_v34 \gset
\if :at_v34
\elif :at_v33
\elif :at_v32 \elif :at_v32
\elif :at_v31 \elif :at_v31
\ir 0032_fix_cellular_v3_manifest_normalization.sql \ir 0032_fix_cellular_v3_manifest_normalization.sql
@@ -481,7 +484,8 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
coalesce(max(version), 0) = 30 AS at_v30, coalesce(max(version), 0) = 30 AS at_v30,
coalesce(max(version), 0) = 31 AS at_v31, coalesce(max(version), 0) = 31 AS at_v31,
coalesce(max(version), 0) = 32 AS at_v32, coalesce(max(version), 0) = 32 AS at_v32,
coalesce(max(version), 0) = 33 AS at_v33 coalesce(max(version), 0) = 33 AS at_v33,
coalesce(max(version), 0) = 34 AS at_v34
FROM evolution.schema_migrations \gset FROM evolution.schema_migrations \gset
\if :at_v24 \if :at_v24
\ir 0025_cellular_v2_bundle.sql \ir 0025_cellular_v2_bundle.sql
@@ -493,6 +497,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\ir 0031_fix_cellular_birth_publication_record.sql \ir 0031_fix_cellular_birth_publication_record.sql
\ir 0032_fix_cellular_v3_manifest_normalization.sql \ir 0032_fix_cellular_v3_manifest_normalization.sql
\ir 0033_fix_cellular_action_tick_offset.sql \ir 0033_fix_cellular_action_tick_offset.sql
\ir 0034_cellular_v4_engulf_bundle.sql
\elif :at_v25 \elif :at_v25
\ir 0026_cellular_profile_migration.sql \ir 0026_cellular_profile_migration.sql
\ir 0027_cellular_v3_migration.sql \ir 0027_cellular_v3_migration.sql
@@ -502,6 +507,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\ir 0031_fix_cellular_birth_publication_record.sql \ir 0031_fix_cellular_birth_publication_record.sql
\ir 0032_fix_cellular_v3_manifest_normalization.sql \ir 0032_fix_cellular_v3_manifest_normalization.sql
\ir 0033_fix_cellular_action_tick_offset.sql \ir 0033_fix_cellular_action_tick_offset.sql
\ir 0034_cellular_v4_engulf_bundle.sql
\elif :at_v26 \elif :at_v26
\ir 0027_cellular_v3_migration.sql \ir 0027_cellular_v3_migration.sql
\ir 0028_cellular_v3_trace_bounds.sql \ir 0028_cellular_v3_trace_bounds.sql
@@ -510,6 +516,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\ir 0031_fix_cellular_birth_publication_record.sql \ir 0031_fix_cellular_birth_publication_record.sql
\ir 0032_fix_cellular_v3_manifest_normalization.sql \ir 0032_fix_cellular_v3_manifest_normalization.sql
\ir 0033_fix_cellular_action_tick_offset.sql \ir 0033_fix_cellular_action_tick_offset.sql
\ir 0034_cellular_v4_engulf_bundle.sql
\elif :at_v27 \elif :at_v27
\ir 0028_cellular_v3_trace_bounds.sql \ir 0028_cellular_v3_trace_bounds.sql
\ir 0029_cellular_mutation_reservations.sql \ir 0029_cellular_mutation_reservations.sql
@@ -517,29 +524,37 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\ir 0031_fix_cellular_birth_publication_record.sql \ir 0031_fix_cellular_birth_publication_record.sql
\ir 0032_fix_cellular_v3_manifest_normalization.sql \ir 0032_fix_cellular_v3_manifest_normalization.sql
\ir 0033_fix_cellular_action_tick_offset.sql \ir 0033_fix_cellular_action_tick_offset.sql
\ir 0034_cellular_v4_engulf_bundle.sql
\elif :at_v28 \elif :at_v28
\ir 0029_cellular_mutation_reservations.sql \ir 0029_cellular_mutation_reservations.sql
\ir 0030_cellular_birth_publication_binding.sql \ir 0030_cellular_birth_publication_binding.sql
\ir 0031_fix_cellular_birth_publication_record.sql \ir 0031_fix_cellular_birth_publication_record.sql
\ir 0032_fix_cellular_v3_manifest_normalization.sql \ir 0032_fix_cellular_v3_manifest_normalization.sql
\ir 0033_fix_cellular_action_tick_offset.sql \ir 0033_fix_cellular_action_tick_offset.sql
\ir 0034_cellular_v4_engulf_bundle.sql
\elif :at_v29 \elif :at_v29
\ir 0030_cellular_birth_publication_binding.sql \ir 0030_cellular_birth_publication_binding.sql
\ir 0031_fix_cellular_birth_publication_record.sql \ir 0031_fix_cellular_birth_publication_record.sql
\ir 0032_fix_cellular_v3_manifest_normalization.sql \ir 0032_fix_cellular_v3_manifest_normalization.sql
\ir 0033_fix_cellular_action_tick_offset.sql \ir 0033_fix_cellular_action_tick_offset.sql
\ir 0034_cellular_v4_engulf_bundle.sql
\elif :at_v30 \elif :at_v30
\ir 0031_fix_cellular_birth_publication_record.sql \ir 0031_fix_cellular_birth_publication_record.sql
\ir 0032_fix_cellular_v3_manifest_normalization.sql \ir 0032_fix_cellular_v3_manifest_normalization.sql
\ir 0033_fix_cellular_action_tick_offset.sql \ir 0033_fix_cellular_action_tick_offset.sql
\ir 0034_cellular_v4_engulf_bundle.sql
\elif :at_v31 \elif :at_v31
\ir 0032_fix_cellular_v3_manifest_normalization.sql \ir 0032_fix_cellular_v3_manifest_normalization.sql
\ir 0033_fix_cellular_action_tick_offset.sql \ir 0033_fix_cellular_action_tick_offset.sql
\ir 0034_cellular_v4_engulf_bundle.sql
\elif :at_v32 \elif :at_v32
\ir 0033_fix_cellular_action_tick_offset.sql \ir 0033_fix_cellular_action_tick_offset.sql
\ir 0034_cellular_v4_engulf_bundle.sql
\elif :at_v33 \elif :at_v33
\ir 0034_cellular_v4_engulf_bundle.sql
\elif :at_v34
\else \else
\echo 'Unknown or changed migration history after v33' \echo 'Unknown or changed migration history after v34'
DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$; DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$;
\endif \endif
-- Effective-privilege audit on every run, including no-ops (ADR-0060). Attributes -- Effective-privilege audit on every run, including no-ops (ADR-0060). Attributes
+13
View File
@@ -59,6 +59,19 @@ and one five-channel inventory. The archive must contain the matching dead
organism and death tick. Inventory must retain at least the genome-derived body organism and death tick. Inventory must retain at least the genome-derived body
matter; heat is not part of the corpse. matter; heat is not part of the corpse.
### Format 4 (rules 3, ADR-0124)
Magic `AEVCLV04`, format 4, rules 3, with the revision-format archive and the
format 2/3 life records. Each corpse record is 116 bytes: the 100 bytes above,
then a u8 cause (1 starved, 2 engulfed), seven zero bytes and the predator's u64
life id (non-zero exactly when engulfed, never the corpse's own). The inventory
is empty: under rules 3 a dead cell's inventory moved to its predator and to
detritus in the habitat's patch at the corpse's 1 mm cell. Formats 1-3 keep no
cause. The checkpoint manifest pins these as cellular version bundle
`{rules 3, envelope 4, habitat 1, coordinate 1, genome 1, development 2,
founder 1, archive 2, mutation_state 1}` with the revision history profile
(schema v34).
## Restore validation ## Restore validation
The decoder checks envelope bounds and checksum, identity/tick, versions, The decoder checks envelope bounds and checksum, identity/tick, versions,
+15 -11
View File
@@ -62,10 +62,10 @@ bool prepared_is_canonical(const CellularPreparedCommit& prepared,
std::unexpected{server::CellularActionBlockError::format}}; std::unexpected{server::CellularActionBlockError::format}};
const auto encoded_trace = server::encode_cellular_batch(trace); const auto encoded_trace = server::encode_cellular_batch(trace);
const auto digest = sha256(prepared.trace); const auto digest = sha256(prepared.trace);
const bool trace_version_matches = (manifest.cellular_versions == cellular_v3_versions && const bool revision = cellular_revision_bundle(manifest.cellular_versions);
trace.format_version == server::cellular_batch_format) || const bool trace_version_matches =
(manifest.cellular_versions != cellular_v3_versions && (revision && trace.format_version == server::cellular_batch_format) ||
trace.format_version == server::cellular_batch_v2_format); (!revision && trace.format_version == server::cellular_batch_v2_format);
return manifest.profile == CheckpointProfile::cellular_lives_v1 && trace_version_matches && return manifest.profile == CheckpointProfile::cellular_lives_v1 && trace_version_matches &&
manifest.key == prepared.key && manifest.commit == prepared.commit && manifest.key == prepared.key && manifest.commit == prepared.commit &&
manifest.sequence > 0 && manifest.batch.trace_bytes == prepared.trace.size() && digest && manifest.sequence > 0 && manifest.batch.trace_bytes == prepared.trace.size() && digest &&
@@ -99,9 +99,14 @@ provision_cellular_region(Postgres& owner, const FilesystemObjectStore& objects,
genesis_manifest(key, frame, commit, biology::cellular_motion_tick_microseconds, build, genesis_manifest(key, frame, commit, biology::cellular_motion_tick_microseconds, build,
payload.size(), *digest, CheckpointProfile::cellular_lives_v1); payload.size(), *digest, CheckpointProfile::cellular_lives_v1);
if (manifest && opening.format_version() == server::cellular_lives_format && if (manifest && opening.format_version() == server::cellular_lives_format &&
opening.rules_version() == server::cellular_lives_rules) opening.rules_version() == server::cellular_lives_rules) {
manifest->cellular_versions = cellular_v2_versions; manifest->cellular_versions = cellular_v2_versions;
else if (manifest && (opening.format_version() != server::cellular_lives_legacy_format || } else if (manifest && opening.format_version() == server::cellular_lives_engulf_format &&
opening.rules_version() == server::cellular_lives_engulf_rules) {
// ADR-0124: a rules-3 region starts on the v4 bundle with genome revisions.
manifest->cellular_versions = cellular_v4_versions;
manifest->history_profile = cellular_revision_history_profile;
} else if (manifest && (opening.format_version() != server::cellular_lives_legacy_format ||
opening.rules_version() != 1)) opening.rules_version() != 1))
return std::unexpected{failure(PublicationError::candidate)}; return std::unexpected{failure(PublicationError::candidate)};
auto encoded = manifest ? encode_manifest(*manifest) auto encoded = manifest ? encode_manifest(*manifest)
@@ -326,7 +331,7 @@ publish_cellular_batch(Postgres& db, const FilesystemObjectStore& objects, const
const auto predecessor_digest = sha256(predecessor.manifest); const auto predecessor_digest = sha256(predecessor.manifest);
auto committed_batch = batch; auto committed_batch = batch;
if (previous) if (previous)
committed_batch.format_version = previous->cellular_versions == cellular_v3_versions committed_batch.format_version = cellular_revision_bundle(previous->cellular_versions)
? server::cellular_batch_format ? server::cellular_batch_format
: server::cellular_batch_v2_format; : server::cellular_batch_v2_format;
const auto trace = server::encode_cellular_batch(committed_batch); const auto trace = server::encode_cellular_batch(committed_batch);
@@ -501,10 +506,9 @@ recover_cellular_checkpoint(Postgres& db, const FilesystemObjectStore& objects,
auto trace = server::decode_cellular_batch(*trace_bytes); auto trace = server::decode_cellular_batch(*trace_bytes);
if (!trace) if (!trace)
return fail_with(RecoveryError::tail); return fail_with(RecoveryError::tail);
if ((manifest->cellular_versions == cellular_v3_versions && const bool revision = cellular_revision_bundle(manifest->cellular_versions);
trace->format_version != server::cellular_batch_format) || if ((revision && trace->format_version != server::cellular_batch_format) ||
(manifest->cellular_versions != cellular_v3_versions && (!revision && trace->format_version != server::cellular_batch_v2_format))
trace->format_version != server::cellular_batch_v2_format))
return fail_with(RecoveryError::tail); return fail_with(RecoveryError::tail);
if (trace->header.world != key.world || trace->header.region != key.region || if (trace->header.world != key.world || trace->header.region != key.region ||
trace->header.frame != manifest->frame || trace->header.frame != manifest->frame ||
+8 -6
View File
@@ -69,7 +69,8 @@ bool structural(const CheckpointManifest& m) noexcept {
if ((!cellular && m.cellular_versions != cellular_v1_versions) || if ((!cellular && m.cellular_versions != cellular_v1_versions) ||
(cellular && m.cellular_versions != cellular_v1_versions && (cellular && m.cellular_versions != cellular_v1_versions &&
m.cellular_versions != cellular_v2_versions && m.cellular_versions != cellular_v2_versions &&
m.cellular_versions != cellular_v3_versions) || m.cellular_versions != cellular_v3_versions &&
m.cellular_versions != cellular_v4_versions) ||
(cellular && m.versions != environmental_v1_versions)) (cellular && m.versions != environmental_v1_versions))
return false; return false;
if (primitive && (m.manifest_version != 2 || m.tick_microseconds != 50000 || if (primitive && (m.manifest_version != 2 || m.tick_microseconds != 50000 ||
@@ -154,14 +155,15 @@ bool supported(const CheckpointManifest& m) noexcept {
m.versions == primitive_v1_versions && m.tick_microseconds == 50000 && m.versions == primitive_v1_versions && m.tick_microseconds == 50000 &&
m.rng_streams == 0 && m.durability == DurabilityPolicy::single_volume_development; m.rng_streams == 0 && m.durability == DurabilityPolicy::single_volume_development;
if (m.profile == CheckpointProfile::cellular_lives_v1) { if (m.profile == CheckpointProfile::cellular_lives_v1) {
const bool history_matches = (m.cellular_versions != cellular_v3_versions && const bool revision = cellular_revision_bundle(m.cellular_versions);
m.history_profile == cellular_history_profile) || const bool history_matches =
(m.cellular_versions == cellular_v3_versions && (!revision && m.history_profile == cellular_history_profile) ||
m.history_profile == cellular_revision_history_profile); (revision && m.history_profile == cellular_revision_history_profile);
return m.manifest_version == 2 && history_matches && return m.manifest_version == 2 && history_matches &&
(m.cellular_versions == cellular_v1_versions || (m.cellular_versions == cellular_v1_versions ||
m.cellular_versions == cellular_v2_versions || m.cellular_versions == cellular_v2_versions ||
m.cellular_versions == cellular_v3_versions) && m.cellular_versions == cellular_v3_versions ||
m.cellular_versions == cellular_v4_versions) &&
m.versions == environmental_v1_versions && m.tick_microseconds == 50000 && m.versions == environmental_v1_versions && m.tick_microseconds == 50000 &&
m.rng_streams == 0 && m.durability == DurabilityPolicy::single_volume_development; m.rng_streams == 0 && m.durability == DurabilityPolicy::single_volume_development;
} }
+29
View File
@@ -504,6 +504,35 @@ void cellular_profile() {
after_revision_migration->cellular_versions == cellular_v3_versions && after_revision_migration->cellular_versions == cellular_v3_versions &&
after_revision_migration->history_profile == cellular_revision_history_profile); after_revision_migration->history_profile == cellular_revision_history_profile);
// ADR-0124: a rules-3 owner restores only under the v4 bundle and revision history.
auto engulf_primitive = PrimitiveLives::create({7, 3, 9, 17, funding, {{0, 0}}});
auto engulf_habitat = CellularHabitat::create({7, 3, 9, 1'000, 1'000, {}});
CHECK(engulf_primitive && engulf_habitat);
auto engulf_owner =
CellularLives::create(**engulf_primitive, std::move(*engulf_habitat),
{{1'000, 1'000}, 0, 293'150}, CellularLivesProfile::engulf);
CHECK(engulf_owner);
const auto engulf_payload = (*engulf_owner)->snapshot();
auto v4 = genesis_manifest(key, 9, filled<16>(0x30), 50000, build, engulf_payload.size(),
filled<32>(0x31), CheckpointProfile::cellular_lives_v1);
CHECK(v4);
v4->cellular_versions = cellular_v4_versions;
v4->history_profile = cellular_revision_history_profile;
CHECK(supported(*v4) && cellular_revision_bundle(v4->cellular_versions));
const auto v4_bytes = encode_manifest(*v4);
CHECK(v4_bytes && decode_manifest(*v4_bytes) == *v4);
CHECK(restore_cellular_payload(engulf_payload, *v4));
auto v4_wrong_history = *v4;
v4_wrong_history.history_profile = cellular_history_profile;
CHECK(!supported(v4_wrong_history));
auto as_v3 = *v4;
as_v3.cellular_versions = cellular_v3_versions;
CHECK(!restore_cellular_payload(engulf_payload, as_v3)); // Envelope and rules differ.
const auto v4_next =
successor_manifest(*v4, filled<32>(0x32), filled<16>(0x33), lease(), 1, build,
engulf_payload.size(), filled<32>(0x34), batch_for(1, 1));
CHECK(v4_next && supported(*v4_next) && v4_next->cellular_versions == cellular_v4_versions);
auto bad_identity = *manifest; auto bad_identity = *manifest;
bad_identity.key.region = 4; bad_identity.key.region = 4;
const auto wrong_identity = restore_cellular_payload(payload, bad_identity); const auto wrong_identity = restore_cellular_payload(payload, bad_identity);
+11 -1
View File
@@ -212,7 +212,7 @@ void upgrade_across_migration_and_barrier() {
" EVO_PG_RUNTIME_ROLE=evo_runtime_test bash \"$EVO_SOURCE_ROOT/" " EVO_PG_RUNTIME_ROLE=evo_runtime_test bash \"$EVO_SOURCE_ROOT/"
"tools/migrate-postgres.sh\" > /dev/null") == 0); "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," 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"); "25,26,27,28,29,30,31,32,33,34");
CHECK(scalar(*owner_db, "SELECT (c.condeferrable AND c.condeferred AND " CHECK(scalar(*owner_db, "SELECT (c.condeferrable AND c.condeferred AND "
"c.confrelid = 'evolution.region_commits'::regclass)::text " "c.confrelid = 'evolution.region_commits'::regclass)::text "
"FROM pg_catalog.pg_constraint c WHERE c.conrelid = " "FROM pg_catalog.pg_constraint c WHERE c.conrelid = "
@@ -242,6 +242,16 @@ void upgrade_across_migration_and_barrier() {
"repeat('00', 23), 'hex'), 1)::text") == "true"); "repeat('00', 23), 'hex'), 1)::text") == "true");
CHECK(scalar(*owner_db, "SELECT evolution.valid_cellular_action_input(decode(repeat('00', 24), " CHECK(scalar(*owner_db, "SELECT evolution.valid_cellular_action_input(decode(repeat('00', 24), "
"'hex'), 1)::text") == "false"); "'hex'), 1)::text") == "false");
// Schema v34 (ADR-0124): target kind 2 is engulf, with no coordinates; kind 3 is unknown.
CHECK(scalar(*owner_db,
"SELECT evolution.valid_cellular_action_input(decode('01' || "
"repeat('00', 11) || '02' || repeat('00', 11), 'hex'), 1)::text") == "true");
CHECK(scalar(*owner_db, "SELECT evolution.valid_cellular_action_input(decode('01' || "
"repeat('00', 11) || '02' || repeat('00', 3) || '01' || "
"repeat('00', 7), 'hex'), 1)::text") == "false");
CHECK(scalar(*owner_db,
"SELECT evolution.valid_cellular_action_input(decode('01' || "
"repeat('00', 11) || '03' || repeat('00', 11), 'hex'), 1)::text") == "false");
CHECK(scalar(*owner_db, CHECK(scalar(*owner_db,
"SELECT evolution.check_cellular_action_block(decode(repeat('01', 16) || " "SELECT evolution.check_cellular_action_block(decode(repeat('01', 16) || "
"'0100000000000000' || '0100000000000000' || repeat('00', 16), 'hex'), " "'0100000000000000' || '0100000000000000' || repeat('00', 16), 'hex'), "
+38 -8
View File
@@ -431,23 +431,23 @@ void provisioning_creates_the_life_allocator_once() {
// ADR-0123: an image promotion changes --build, but a cellular genesis records the // ADR-0123: an image promotion changes --build, but a cellular genesis records the
// build that wrote it. A rerun under a new build still resolves the same genesis, // build that wrote it. A rerun under a new build still resolves the same genesis,
// while a different commit or opening is refused. // while a different commit or opening is refused.
void cellular_provisioning_survives_a_build_promotion() { // One cellular provisioning run for region 1 of `world` with a one-founder opening.
using evo::biology::primitive_endowment; std::vector<std::string> provision_cellular(const ServerRegion& r, const std::string& world,
const ServerRegion r{{9761, 1}, fresh("cellular-provision-9761")}; const std::string& opening, const std::string& build,
const auto endowed = primitive_endowment(); const std::string& commit, const std::string& patch,
int& code) {
const auto endowed = evo::biology::primitive_endowment();
CHECK(endowed); CHECK(endowed);
evo::accounting::Inventory funding = endowed->body; evo::accounting::Inventory funding = endowed->body;
funding.energy.value += endowed->reserve.energy.value + endowed->construction.value; funding.energy.value += endowed->reserve.energy.value + endowed->construction.value;
const auto run = [&](const std::string& build, const std::string& commit,
const std::string& patch, int& code) {
Child tool{{env("EVO_WORLD_CLONE_BIN"), Child tool{{env("EVO_WORLD_CLONE_BIN"),
"provision", "provision",
"--world", "--world",
"9761", world,
"--region", "--region",
"1", "1",
"--opening", "--opening",
"cellular-v1", opening,
"--pg-host", "--pg-host",
env("PGHOST"), env("PGHOST"),
"--pg-port", "--pg-port",
@@ -490,6 +490,35 @@ void cellular_provisioning_survives_a_build_promotion() {
patch}}; patch}};
code = tool.wait_exit(30s); code = tool.wait_exit(30s);
return tool.lines(); return tool.lines();
}
// ADR-0124: cellular-v2 provisions a rules-3 genesis under the v4 bundle (schema v34),
// resolves it again on rerun, and refuses the same region asked for as cellular-v1.
void cellular_v2_provisioning_uses_the_engulf_bundle() {
const ServerRegion r{{9762, 1}, fresh("cellular-v2-provision-9762")};
const std::string build(64, 'e');
const std::string commit(32, 'f');
const std::string patch = "3000,3000,2,1000,1000,1000,1000,1000";
int code = -1;
const auto first = provision_cellular(r, "9762", "cellular-v2", build, commit, patch, code);
CHECK(code == 0 && has(first, "provisioned world=9762 region=1 sequence=0 tick=0"));
const auto again = provision_cellular(r, "9762", "cellular-v2", build, commit, patch, code);
CHECK(code == 0 && has(again, "already-provisioned world=9762 region=1 sequence=0 tick=0"));
const auto older = provision_cellular(r, "9762", "cellular-v1", build, commit, patch, code);
CHECK(code == 4);
auto db = owner();
const auto head = load_region_checkpoint(*db, r.key, 5s);
CHECK(head);
const auto manifest = decode_manifest(head->manifest);
CHECK(manifest && manifest->cellular_versions == cellular_v4_versions &&
manifest->history_profile == cellular_revision_history_profile);
}
void cellular_provisioning_survives_a_build_promotion() {
const ServerRegion r{{9761, 1}, fresh("cellular-provision-9761")};
const auto run = [&](const std::string& build, const std::string& commit,
const std::string& patch, int& code) {
return provision_cellular(r, "9761", "cellular-v1", build, commit, patch, code);
}; };
const std::string first_build(64, 'c'); const std::string first_build(64, 'c');
const std::string second_build = std::string(63, 'c') + "d"; const std::string second_build = std::string(63, 'c') + "d";
@@ -515,6 +544,7 @@ void run_region_store_tests() {
primitive_provisioning_is_explicit_and_profile_safe(); primitive_provisioning_is_explicit_and_profile_safe();
provisioning_creates_the_life_allocator_once(); provisioning_creates_the_life_allocator_once();
cellular_provisioning_survives_a_build_promotion(); cellular_provisioning_survives_a_build_promotion();
cellular_v2_provisioning_uses_the_engulf_bundle();
full_volumes_publish_nothing(); full_volumes_publish_nothing();
failing_writes_leave_nothing(); failing_writes_leave_nothing();
check_store_qualifies_the_stores(); check_store_qualifies_the_stores();
+5 -5
View File
@@ -122,7 +122,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 -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 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" 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 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
# v2 heads have no payload binding: v2->v3 fails closed and leaves history at v2. # 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="$(sha256sum "$root/migrations/0002_region_fencing.sql")"
v2_sha="${v2_sha%% *}" v2_sha="${v2_sha%% *}"
@@ -143,7 +143,7 @@ PGDATABASE=v3_commits psql -X -v ON_ERROR_STOP=1 \
-c "INSERT INTO evolution.retained_builds VALUES (decode(repeat('b1', 32), 'hex'))" \ -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 -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" 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")" = 33: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 test "$(PGDATABASE=v3_commits psql -XAtc "SELECT count(*) || ':' || string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 34: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
test "$(PGDATABASE=v3_commits psql -XAtc "SELECT count(*) FROM evolution.region_commits")" = 1 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 # 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. # no durable decisions for it. The v5 upgrade must refuse before changing anything.
@@ -197,7 +197,7 @@ PGDATABASE=v6_populated psql -X -v ON_ERROR_STOP=1 \
-c "INSERT INTO evolution.retained_builds VALUES (decode(repeat('b1', 32), 'hex'))" \ -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 -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" 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 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
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 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 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 phase permission-audit
@@ -250,9 +250,9 @@ expect_audit_failure 'REVOKE EXECUTE ON FUNCTION evolution.claim_account_control
bash "$root/tools/migrate-postgres.sh" # Restored configuration passes the audit again. bash "$root/tools/migrate-postgres.sh" # Restored configuration passes the audit again.
phase checksum-drift phase checksum-drift
# Unknown future versions and checksum drift must not be repaired silently. # 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=34 WHERE version=33' psql -X -v ON_ERROR_STOP=1 -c 'UPDATE evolution.schema_migrations SET version=35 WHERE version=34'
if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi 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=33 WHERE version=34" psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET version=34 WHERE version=35"
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=14" 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 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" psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=13"
+3
View File
@@ -78,6 +78,8 @@ digest_32="$(sha256sum "$root/migrations/0032_fix_cellular_v3_manifest_normaliza
digest_32="${digest_32%% *}" digest_32="${digest_32%% *}"
digest_33="$(sha256sum "$root/migrations/0033_fix_cellular_action_tick_offset.sql")" digest_33="$(sha256sum "$root/migrations/0033_fix_cellular_action_tick_offset.sql")"
digest_33="${digest_33%% *}" digest_33="${digest_33%% *}"
digest_34="$(sha256sum "$root/migrations/0034_cellular_v4_engulf_bundle.sql")"
digest_34="${digest_34%% *}"
psql -X --no-password --set=ON_ERROR_STOP=1 --set="migration_sha=$digest" \ 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_2=$digest_2" --set="migration_sha_3=$digest_3" \
--set="migration_sha_4=$digest_4" --set="migration_sha_5=$digest_5" \ --set="migration_sha_4=$digest_4" --set="migration_sha_5=$digest_5" \
@@ -104,5 +106,6 @@ psql -X --no-password --set=ON_ERROR_STOP=1 --set="migration_sha=$digest" \
--set="migration_sha_31=$digest_31" \ --set="migration_sha_31=$digest_31" \
--set="migration_sha_32=$digest_32" \ --set="migration_sha_32=$digest_32" \
--set="migration_sha_33=$digest_33" \ --set="migration_sha_33=$digest_33" \
--set="migration_sha_34=$digest_34" \
--set="runtime_role=$runtime_role" \ --set="runtime_role=$runtime_role" \
--file="$root/migrations/apply.sql" --file="$root/migrations/apply.sql"