Add fenced durable primitive life reservations (M11.2c-1)
Foundation / checks (deploy) (push) Successful in 14s
Foundation / checks (ecs) (push) Successful in 2m3s
Foundation / checks (postgres) (push) Canceled after 0s
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 (checks) (push) Canceled after 5m17s
Foundation / checks (client) (push) Canceled after 5m17s
Foundation / checks (network) (push) Canceled after 2m57s

This commit is contained in:
dingo
2026-10-09 21:55:28 -04:00
parent 48684d30d9
commit 8568eff39d
15 changed files with 453 additions and 18 deletions
+7 -5
View File
@@ -1,6 +1,6 @@
# Project status and next steps
## Current gate - 2026-10-09 (M11.1)
## Current gate - 2026-10-09 (M11.2)
ADR-0098 records the maintainer's decisions for the first playable cellular loop:
- **Budding:** the parent keeps control and funds one wildlife bud.
@@ -15,7 +15,7 @@ ADR-0098 records the maintainer's decisions for the first playable cellular loop
- **Birth cost:** a first bud fundable within a session (a tunable playtest target).
- **Friend recognition:** deferred.
11.1's ratified engineering half, time-based biological rates, is under way (ADR-0099;
11.1's ratified engineering half, time-based biological rates, is complete (ADR-0099;
the maintainer chose directional rounding):
- **Segment 1 (done):** `accounting/rates.hpp` converts a per-second rate to a per-tick
amount without saved state. Costs round up and capacities down, so rounding never
@@ -33,7 +33,7 @@ the maintainer chose directional rounding):
second. A full-grown founder that pays full-speed movement throughout funds its first
bud in 5, 10 and 15 minutes when feeding 100%, 50% and 33% of the time (ADR-0099).
11.1 is complete.
- **Next:** 11.2, primitive lives and persistent control. Server side only; client UI
- **In progress:** 11.2, primitive lives and persistent control. Server side only; client UI
parts of 11.x are deferred to the maintainer. Its
[delivery plan](engineering/M11_2_DELIVERY_PLAN.md) and accepted
[ADR-0100](adr/0100-primitive-lives-and-persistent-control.md) identify the new
@@ -42,8 +42,10 @@ the maintainer chose directional rounding):
11.2a adds in-memory funded creation: full-grown primitive founders, equal
energy-only reserves, conserved pool/body/heat and exact successful retries.
11.2b adds a bounded creation-state checkpoint codec with full inventory/archive
closure and exact retry recovery. Durable publication, world-wide binding and
session integration remain.
closure and exact retry recovery. 11.2c-1 adds durable identity reservations,
world-wide account exclusivity, and retained refusals under fenced account
control. A reservation spends nothing and is not a spawned organism.
Atomic body/checkpoint publication, life binding and session integration remain.
Open from M10 (BACKLOG):
- the maintainer's native-client observation, moved to the later 2k drill;
@@ -190,3 +190,16 @@ re-encoding. It refuses unknown versions, mismatched region identity, duplicate
life bindings and inconsistent funding. No biological timers exist in this
creation-only version; introducing progression requires a new format first.
Durable publication and session integration remain 11.2c/d.
## 11.2c-1: Durable identity reservations
Schema v15 adds [life reservations](../../schemas/life-reservations-v1.md):
one pending request per world/account, world-wide durable identity allocation,
exact retries and immutable refusal records. Reservations spend no resources
and are never reported as organisms. The owner must provision an audited unused
identity range; runtime cannot initialize it. Control/lease expiry is checked
after lock waits. This precedes atomic body/checkpoint publication in 11.2c-2.
New-life request IDs use a separate operation namespace from M10 no-effect probe
actions. The future protocol must make that explicit rather than overloading the
existing probe result lookup. This avoids silently changing deployed probe rules.
+12 -2
View File
@@ -62,5 +62,15 @@ migration/ownership and process-kill checks when those segments exist. Run netwo
presets whenever a replicated type changes. Record unavailable environments.
Local checks do not close ADR-0097's reference-worker qualification.
This initial review changes documentation only. No spawn, migration, provisioning
or biological implementation has been performed.
## Progress
- 11.2a: funded in-memory creation, committed as `69101a7`.
- 11.2b: creation-state codec, committed as `48684d3`. Published checkpoint profile
registration is still required with 11.2c-2; this codec alone is not durability.
- 11.2c-1: schema v15 reservations/identity allocation and durable refusals. These
spend nothing and do not publish an organism. Focused PostgreSQL tests and the
full migration/process, backup/restore, upgrade and privilege regressions pass.
- 11.2c-2 and 11.2d remain: atomic funded checkpoint publication, reconciliation,
host/session integration and crash-boundary qualification.
No deployed world has been provisioned or changed by this work.
+29
View File
@@ -5514,3 +5514,32 @@ Windows MSVC release 62/62 CTest checks, clang-tidy 19 on the two changed source
files, repository format-check and `git diff --check`. All passed. The Linux
full-suite results from 11.2a are not claimed as new codec runs. No wire type or
deployed profile changed; no deployment occurred.
## 2026-10-09 — M11.2c-1 durable life reservations
Schema v15 adds a world allocator, one pending reservation per account and
retained refusals. Reservation success allocates identity only; it neither spends
funding nor publishes a body. Dedicated real-PostgreSQL tests cover independent
connections/regions, concurrent retries, takeover routing, stale generations,
expiry after allocator lock waits, exhaustion, rollback, immutable refusal
results and runtime table-access rejection.
Executed successfully:
- Focused `tools/ci/postgres-check.sh --life-reservations-only` against a fresh,
disposable PostgreSQL 18.6 cluster, including the final exhaustion/rollback cases.
- Full GCC 14 PostgreSQL/QUIC build in `build/m97-postgres`, then the complete
`tools/ci/postgres-check.sh build/m97-postgres/evo-postgres-tests`: adapter,
lease/control, checkpoint, host/session, process-kill, recovery, clone, migration,
backup/restore, host-loss, upgrade, constraints and effective privilege checks.
Log: `/tmp/m112c-pg-correct.log` in WSL; final success marker verified.
- Shell syntax checks and CI path-selection regression checks (16 cases).
- Clang 19 clang-tidy on `tests/region_migration_tests.cpp` using the Clang
PostgreSQL compilation database, repository format-check and `git diff --check`.
Environment: WSL required escalated access. An earlier run selected an obsolete
build cache with PostgreSQL disabled and was stopped; it is not counted. An initial
clang-tidy invocation used a GCC compilation database and rejected GCC module flags;
the proper Clang database completed cleanly. No sanitizer rerun is claimed for this
SQL subsection; prior lifecycle sanitizer results remain recorded above. No wire
type changed. All database work used disposable local clusters; no world deployment,
reset or provisioning occurred.
+119
View File
@@ -0,0 +1,119 @@
-- M11.2c-1, ADR-0100. Durable allocation only: no reservation is a living body.
-- Owner provisions an audited unused identity range for a world. Runtime cannot
-- initialize/reset it. One common counter allocates life/organism/genome/event
-- values in their DISTINCT namespaces; it never reuses a reserved value.
CREATE TABLE evolution.life_allocators (
world_id evolution.u64 PRIMARY KEY CHECK (world_id > 0),
next_identity evolution.u64 NOT NULL CHECK (next_identity > 0)
);
CREATE TABLE evolution.life_reservations (
world_id evolution.u64 NOT NULL REFERENCES evolution.life_allocators,
account_id uuid NOT NULL CHECK (account_id <> '00000000-0000-0000-0000-000000000000'),
request_id evolution.u64 NOT NULL CHECK (request_id > 0),
identity evolution.u64 NOT NULL CHECK (identity > 0),
region_id evolution.u64 NOT NULL,
rules integer NOT NULL CHECK (rules = 1),
rejection smallint NOT NULL DEFAULT 0 CHECK (rejection BETWEEN 0 AND 3),
PRIMARY KEY (world_id, account_id, request_id),
UNIQUE (world_id, identity),
FOREIGN KEY (world_id, region_id) REFERENCES evolution.region_leases
);
-- 0 reserved; 1 insufficient funding; 2 no placement/capacity; 3 cancelled.
-- Retain rejections and allocations forever. A new request may follow rejection.
CREATE UNIQUE INDEX one_reserved_life_per_account
ON evolution.life_reservations(world_id, account_id) WHERE rejection = 0;
REVOKE ALL ON evolution.life_allocators, evolution.life_reservations FROM PUBLIC;
-- Extends lock order: upgrade -> lease -> account -> reservation -> allocator.
-- Internal helper, never granted to runtime. Checks database time AFTER lock waits.
CREATE FUNCTION evolution.check_life_control(p_world evolution.u64, p_region evolution.u64,
p_holder uuid, p_epoch evolution.u64, p_account uuid, p_generation evolution.u64)
RETURNS void LANGUAGE plpgsql SECURITY INVOKER SET search_path = pg_catalog, pg_temp AS $$
DECLARE c evolution.account_controls%ROWTYPE;
BEGIN
IF p_account IS NULL OR p_account = '00000000-0000-0000-0000-000000000000'
OR p_generation IS NULL OR p_generation = 0 THEN
RAISE EXCEPTION 'invalid life control' USING ERRCODE = '22023';
END IF;
PERFORM evolution.check_region_lease(p_world, p_region, p_holder, p_epoch);
SELECT * INTO c FROM evolution.account_controls a
WHERE a.world_id = p_world AND a.account_id = p_account FOR UPDATE;
IF NOT FOUND OR c.generation <> p_generation OR c.region_id IS DISTINCT FROM p_region
OR c.region_epoch IS DISTINCT FROM p_epoch OR c.expires_at <= clock_timestamp()
OR c.expires_at IS NULL THEN
RAISE EXCEPTION 'life control fenced' USING ERRCODE = 'EVL02';
END IF;
PERFORM evolution.check_region_lease(p_world, p_region, p_holder, p_epoch);
END $$;
-- Life request IDs are a separate operation namespace from M10 no-effect probes.
-- Exact retry returns original owner/identity even after account control moves;
-- caller must route to owner, never create another body in the new region.
CREATE FUNCTION evolution.reserve_primitive_life(p_world evolution.u64, p_region evolution.u64,
p_holder uuid, p_epoch evolution.u64, p_account uuid, p_generation evolution.u64,
p_request evolution.u64, p_rules integer)
RETURNS TABLE (life_identity evolution.u64, life_region evolution.u64, rejection smallint)
LANGUAGE plpgsql SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS $$
DECLARE r evolution.life_reservations%ROWTYPE; allocated numeric;
BEGIN
IF p_request IS NULL OR p_request = 0 OR p_rules IS DISTINCT FROM 1 THEN
RAISE EXCEPTION 'invalid life request' USING ERRCODE = '22023';
END IF;
PERFORM evolution.check_life_control(p_world, p_region, p_holder, p_epoch, p_account, p_generation);
SELECT * INTO r FROM evolution.life_reservations x
WHERE x.world_id = p_world AND x.account_id = p_account AND x.request_id = p_request;
IF FOUND THEN
RETURN QUERY SELECT r.identity, r.region_id, r.rejection;
RETURN;
END IF;
IF EXISTS (SELECT 1 FROM evolution.life_reservations x
WHERE x.world_id = p_world AND x.account_id = p_account AND x.rejection = 0) THEN
RAISE EXCEPTION 'life already reserved' USING ERRCODE = 'EVL16';
END IF;
SELECT a.next_identity INTO allocated FROM evolution.life_allocators a
WHERE a.world_id = p_world FOR UPDATE;
IF NOT FOUND THEN
RAISE EXCEPTION 'life allocator not provisioned' USING ERRCODE = 'EVL04';
END IF;
IF allocated = 18446744073709551615 THEN
RAISE EXCEPTION 'life identities exhausted' USING ERRCODE = 'EVL05';
END IF;
-- A wait for the allocator must not let an expired controller originate work.
PERFORM evolution.check_life_control(p_world, p_region, p_holder, p_epoch, p_account, p_generation);
UPDATE evolution.life_allocators SET next_identity = allocated + 1 WHERE world_id = p_world;
INSERT INTO evolution.life_reservations(world_id, account_id, request_id, identity, region_id, rules)
VALUES (p_world, p_account, p_request, allocated, p_region, p_rules);
RETURN QUERY SELECT allocated::evolution.u64, p_region, 0::smallint;
END $$;
CREATE FUNCTION evolution.reject_primitive_life(p_world evolution.u64, p_region evolution.u64,
p_holder uuid, p_epoch evolution.u64, p_account uuid, p_generation evolution.u64,
p_request evolution.u64, p_reason smallint)
RETURNS smallint LANGUAGE plpgsql SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS $$
DECLARE r evolution.life_reservations%ROWTYPE;
BEGIN
IF p_request IS NULL OR p_request = 0 OR p_reason IS NULL OR p_reason NOT BETWEEN 1 AND 3 THEN
RAISE EXCEPTION 'invalid life rejection' USING ERRCODE = '22023';
END IF;
PERFORM evolution.check_life_control(p_world, p_region, p_holder, p_epoch, p_account, p_generation);
SELECT * INTO r FROM evolution.life_reservations x
WHERE x.world_id = p_world AND x.account_id = p_account AND x.request_id = p_request FOR UPDATE;
IF NOT FOUND OR r.region_id <> p_region THEN
RAISE EXCEPTION 'life reservation not owned' USING ERRCODE = 'EVL04';
END IF;
IF r.rejection <> 0 THEN RETURN r.rejection; END IF;
UPDATE evolution.life_reservations SET rejection = p_reason
WHERE world_id = p_world AND account_id = p_account AND request_id = p_request;
RETURN p_reason;
END $$;
REVOKE ALL ON FUNCTION
evolution.check_life_control(evolution.u64,evolution.u64,uuid,evolution.u64,uuid,evolution.u64),
evolution.reserve_primitive_life(evolution.u64,evolution.u64,uuid,evolution.u64,uuid,evolution.u64,evolution.u64,integer),
evolution.reject_primitive_life(evolution.u64,evolution.u64,uuid,evolution.u64,uuid,evolution.u64,evolution.u64,smallint)
FROM PUBLIC;
GRANT EXECUTE ON FUNCTION
evolution.reserve_primitive_life(evolution.u64,evolution.u64,uuid,evolution.u64,uuid,evolution.u64,evolution.u64,integer),
evolution.reject_primitive_life(evolution.u64,evolution.u64,uuid,evolution.u64,uuid,evolution.u64,evolution.u64,smallint)
TO :"runtime_role";
INSERT INTO evolution.schema_migrations(version, sha256) VALUES (15, :'migration_sha_15');
+28 -2
View File
@@ -73,28 +73,43 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|| ',9:' || :'migration_sha_9' || ',10:' || :'migration_sha_10'
|| ',11:' || :'migration_sha_11' || ',12:' || :'migration_sha_12'
|| ',13:' || :'migration_sha_13' || ',14:' || :'migration_sha_14'
AS at_v14 \gset
\if :at_v14
AS at_v14,
:'history' = '1:' || :'migration_sha' || ',2:' || :'migration_sha_2'
|| ',3:' || :'migration_sha_3' || ',4:' || :'migration_sha_4'
|| ',5:' || :'migration_sha_5' || ',6:' || :'migration_sha_6'
|| ',7:' || :'migration_sha_7' || ',8:' || :'migration_sha_8'
|| ',9:' || :'migration_sha_9' || ',10:' || :'migration_sha_10'
|| ',11:' || :'migration_sha_11' || ',12:' || :'migration_sha_12'
|| ',13:' || :'migration_sha_13' || ',14:' || :'migration_sha_14'
|| ',15:' || :'migration_sha_15' AS at_v15 \gset
\if :at_v15
\elif :at_v14
\ir 0015_life_reservations.sql
\elif :at_v13
\ir 0014_probe_overdue.sql
\ir 0015_life_reservations.sql
\elif :at_v12
\ir 0013_probe_incoming.sql
\ir 0014_probe_overdue.sql
\ir 0015_life_reservations.sql
\elif :at_v11
\ir 0012_probe_handoff.sql
\ir 0013_probe_incoming.sql
\ir 0014_probe_overdue.sql
\ir 0015_life_reservations.sql
\elif :at_v10
\ir 0011_region_actions.sql
\ir 0012_probe_handoff.sql
\ir 0013_probe_incoming.sql
\ir 0014_probe_overdue.sql
\ir 0015_life_reservations.sql
\elif :at_v9
\ir 0010_account_control.sql
\ir 0011_region_actions.sql
\ir 0012_probe_handoff.sql
\ir 0013_probe_incoming.sql
\ir 0014_probe_overdue.sql
\ir 0015_life_reservations.sql
\elif :at_v8
\ir 0009_serialized_authority.sql
\ir 0010_account_control.sql
@@ -102,6 +117,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
\ir 0012_probe_handoff.sql
\ir 0013_probe_incoming.sql
\ir 0014_probe_overdue.sql
\ir 0015_life_reservations.sql
\elif :at_v7
\ir 0008_upgrade_barrier.sql
\ir 0009_serialized_authority.sql
@@ -110,6 +126,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
\ir 0012_probe_handoff.sql
\ir 0013_probe_incoming.sql
\ir 0014_probe_overdue.sql
\ir 0015_life_reservations.sql
\elif :at_v6
\ir 0007_region_clones.sql
\ir 0008_upgrade_barrier.sql
@@ -119,6 +136,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
\ir 0012_probe_handoff.sql
\ir 0013_probe_incoming.sql
\ir 0014_probe_overdue.sql
\ir 0015_life_reservations.sql
\elif :at_v5
\ir 0006_commit_lookup.sql
\ir 0007_region_clones.sql
@@ -129,6 +147,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
\ir 0012_probe_handoff.sql
\ir 0013_probe_incoming.sql
\ir 0014_probe_overdue.sql
\ir 0015_life_reservations.sql
\elif :at_v4
\ir pre_v5_guard.sql
\ir 0005_batch_decisions.sql
@@ -141,6 +160,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
\ir 0012_probe_handoff.sql
\ir 0013_probe_incoming.sql
\ir 0014_probe_overdue.sql
\ir 0015_life_reservations.sql
\elif :at_v3
\ir 0004_lineage_profile.sql
\ir pre_v5_guard.sql
@@ -154,6 +174,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
\ir 0012_probe_handoff.sql
\ir 0013_probe_incoming.sql
\ir 0014_probe_overdue.sql
\ir 0015_life_reservations.sql
\elif :at_v2
\ir 0003_region_checkpoints.sql
\ir 0004_lineage_profile.sql
@@ -168,6 +189,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
\ir 0012_probe_handoff.sql
\ir 0013_probe_incoming.sql
\ir 0014_probe_overdue.sql
\ir 0015_life_reservations.sql
\elif :at_v1
\ir 0002_region_fencing.sql
\ir 0003_region_checkpoints.sql
@@ -183,6 +205,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
\ir 0012_probe_handoff.sql
\ir 0013_probe_incoming.sql
\ir 0014_probe_overdue.sql
\ir 0015_life_reservations.sql
\else
\echo 'Unknown or changed migration history'
DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$;
@@ -203,6 +226,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
\ir 0012_probe_handoff.sql
\ir 0013_probe_incoming.sql
\ir 0014_probe_overdue.sql
\ir 0015_life_reservations.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
@@ -223,6 +247,8 @@ BEGIN
UNION
SELECT m.member FROM pg_catalog.pg_auth_members m JOIN closure c ON m.roleid = c.oid
), fenced(oid) AS (VALUES
('evolution.reserve_primitive_life(evolution.u64,evolution.u64,uuid,evolution.u64,uuid,evolution.u64,evolution.u64,integer)'::regprocedure::oid),
('evolution.reject_primitive_life(evolution.u64,evolution.u64,uuid,evolution.u64,uuid,evolution.u64,evolution.u64,smallint)'::regprocedure::oid),
('evolution.acquire_region_lease(evolution.u64,evolution.u64,integer)'::regprocedure::oid),
('evolution.acquire_region_lease(evolution.u64,evolution.u64,integer,bytea)'::regprocedure::oid),
('evolution.renew_region_lease(evolution.u64,evolution.u64,uuid,evolution.u64,integer)'::regprocedure::oid),
+56
View File
@@ -0,0 +1,56 @@
# Primitive life identity reservations (database schema v15)
ADR-0100, M11.2c-1. A reservation has no biological body or resource debit.
It is not a successful spawn and must never be acknowledged as one.
The owner provisions `life_allocators(world_id, next_identity)` only after
auditing an unused range above every retained identity in the life, organism,
genome and origin-event namespaces for that world. There is no runtime initializer,
reset or automatic provisioning. This subsection does not provision a dev world.
Every allocation uses one value in each of those distinct namespaces. The counter
is shared across the world's regions, never wraps, and retains gaps from rejected
requests. Future birth/mutation allocators must share this allocation authority;
independent counters cannot issue overlapping identities.
`life_reservations` retains world/account/request ID, allocated identity, owning
region, founder-life rules and rejection. These new-life request IDs form a
separate operation namespace from M10 no-effect probe action IDs. The future
protocol must expose that distinction explicitly; a generic ActionQuery cannot
resolve a life request by assumption.
| Rejection | Meaning |
|---|---|
| 0 | Reserved only; not yet a published organism |
| 1 | Insufficient funding |
| 2 | No placement/capacity |
| 3 | Cancelled |
One unrejected reservation per world/account is enforced by a partial unique
index. Rejected rows remain permanently queryable by retry. A different request
may follow rejection and gets a new identity. There is no deletion API.
`reserve_primitive_life` requires the exact region lease and current durable
account-control generation. Exact retry returns the original identity, owner and
rejection without another allocation. A different pending request is `EVL16`.
Unsupported rules/invalid arguments are `22023`; missing provisioning is `EVL04`;
exhaustion is `EVL05`; stale/expired control or lease is `EVL02`.
`reject_primitive_life` durably records the first refusal, requiring current
control in the reservation's owning region. Repeating it returns the first reason.
This operation will need an additional guard against rejecting a published body
when publication is introduced; v15 alone cannot publish bodies.
The lock order is upgrade lock, region lease, account control, reservation and
allocator. Allocation checks lease and control expiry again after the allocator
lock wait. Runtime has EXECUTE only on the two guarded operations, never the
tables or internal control helper. Migration's effective privilege audit covers
these additions, including no-op migration runs.
A takeover may inspect its old reservation before its session wait expires, but
gets no biological control from it. The owner region stays unchanged. Session
admission must still honor ADR-0091's takeover wait before originating gameplay.
Final spawn success, checkpoint publication and reconciliation are 11.2c-2/d.
Validation: `tools/ci/postgres-check.sh --life-reservations-only` starts a fresh
local socket-only PostgreSQL test cluster. The full postgres-check also executes
these tests, alongside migration, backup, restore and existing process checks.
+2 -1
View File
@@ -180,6 +180,7 @@ void upgrade_across_migration_and_barrier() {
" -v migration_sha_12=$(s 0012_probe_handoff.sql)"
" -v migration_sha_13=$(s 0013_probe_incoming.sql)"
" -v migration_sha_14=$(s 0014_probe_overdue.sql)"
" -v migration_sha_15=$(s 0015_life_reservations.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");
@@ -195,7 +196,7 @@ void upgrade_across_migration_and_barrier() {
CHECK(shell("PGDATABASE=" + database +
" EVO_PG_RUNTIME_ROLE=evo_runtime_test bash \"$EVO_SOURCE_ROOT/"
"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");
CHECK(history(*owner_db) == "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15");
CHECK(renew_region_lease(*runtime, r.key, *lease, 20000ms, 5s));
confirm(publish_next(20)); // 41..60, now v8.
CHECK(head.head.end_tick == 60);
+3
View File
@@ -42,6 +42,9 @@ echo change >> tools/ci/dr-check.sh; git commit -qam dr-script
script_base="$(git rev-parse HEAD~1)"
expect "push: only dr-check.sh changed runs postgres" 0 CI_EVENT=push "CI_BEFORE=$script_base" -- postgres
expect "push: only dr-check.sh changed skips image" 1 CI_EVENT=push "CI_BEFORE=$script_base" -- image
life_base="$(git rev-parse HEAD)"
echo check > tools/ci/life-reservations-check.sql; git add .; git commit -qm life-check
expect "push: life reservation check runs postgres" 0 CI_EVENT=push "CI_BEFORE=$life_base" -- postgres
# Client dependency updates must select the isolated client gate.
mkdir -p tools
client_base="$(git rev-parse HEAD)"
+1 -1
View File
@@ -31,7 +31,7 @@ fi
# Every suite runs when the workflow or this selector changes.
common='\.gitea/workflows/|tools/ci/ci-paths\.sh'
native='CMakeLists\.txt|CMakePresets\.json|cmake/|include/|src/|apps/'
postgres_tools='migrations/|tools/prepare-postgres\.sh|tools/migrate-postgres\.sh|tools/backup/|tools/ci/postgres-check\.sh|tools/ci/backup-check\.sh|tools/ci/dr-check\.sh|tools/ci/upgrade-check\.sh'
postgres_tools='migrations/|tools/prepare-postgres\.sh|tools/migrate-postgres\.sh|tools/backup/|tools/ci/postgres-check\.sh|tools/ci/life-reservations-|tools/ci/backup-check\.sh|tools/ci/dr-check\.sh|tools/ci/upgrade-check\.sh'
case "$suite" in
client)
pattern="$common|$native|experiments/(client|ui)/|tools/(prepare-imgui|imgui-pin)\.cmake|tools/prepare-sdl3\\.cmake|tools/sdl3-pin\\.cmake|deploy/docker/Dockerfile"
+101
View File
@@ -0,0 +1,101 @@
-- Runs only in the isolated PostgreSQL test cluster (tools/ci/postgres-check.sh).
\set ON_ERROR_STOP on
INSERT INTO evolution.life_allocators VALUES (9750, 1);
INSERT INTO evolution.region_leases(world_id,region_id,frame_id) VALUES (9750,1,7),(9750,2,7);
INSERT INTO evolution.retained_builds(build_identity) VALUES (decode(repeat('d5',32),'hex'))
ON CONFLICT DO NOTHING;
SET ROLE evo_runtime_login;
SELECT * FROM evolution.acquire_region_lease(9750,1,60000,decode(repeat('d5',32),'hex')) \gset
SELECT * FROM evolution.claim_account_control(9750,1,:'lease_holder',:lease_epoch,
'11111111-1111-1111-1111-111111111111',1,1,60000) \gset
SELECT * FROM evolution.reserve_primitive_life(9750,1,:'lease_holder',:lease_epoch,
'11111111-1111-1111-1111-111111111111',:control_generation,10,1) \gset
SELECT 1 / ((:life_identity = 1 AND :life_region = 1 AND :rejection = 0)::int);
-- Successful allocation retry returns identical IDs, without another counter increment.
SELECT * FROM evolution.reserve_primitive_life(9750,1,:'lease_holder',:lease_epoch,
'11111111-1111-1111-1111-111111111111',:control_generation,10,1) \gset
SELECT 1 / ((:life_identity = 1)::int);
-- Capture parameters for PL/pgSQL exception assertions without string interpolation.
SELECT set_config('test.holder', :'lease_holder', false),
set_config('test.epoch', :'lease_epoch', false);
DO $$ BEGIN
BEGIN
PERFORM evolution.reserve_primitive_life(9750,1,current_setting('test.holder')::uuid,
current_setting('test.epoch')::numeric,'11111111-1111-1111-1111-111111111111',1,11,1);
RAISE EXCEPTION 'accepted a second outstanding life';
EXCEPTION WHEN SQLSTATE 'EVL16' THEN NULL; END;
BEGIN
PERFORM evolution.reserve_primitive_life(9750,1,current_setting('test.holder')::uuid,
current_setting('test.epoch')::numeric,'11111111-1111-1111-1111-111111111111',99,10,1);
RAISE EXCEPTION 'accepted stale control';
EXCEPTION WHEN SQLSTATE 'EVL02' THEN NULL; END;
BEGIN
PERFORM evolution.reserve_primitive_life(9750,1,current_setting('test.holder')::uuid,
current_setting('test.epoch')::numeric,'11111111-1111-1111-1111-111111111111',1,10,2);
RAISE EXCEPTION 'accepted unknown rules';
EXCEPTION WHEN SQLSTATE '22023' THEN NULL; END;
BEGIN
PERFORM 1 FROM evolution.life_reservations;
RAISE EXCEPTION 'runtime can access reservations directly';
EXCEPTION WHEN insufficient_privilege THEN NULL; END;
END $$;
SELECT 1 / ((evolution.reject_primitive_life(9750,1,:'lease_holder',:lease_epoch,
'11111111-1111-1111-1111-111111111111',1,10,1::smallint) = 1)::int);
-- First durable refusal is immutable, including across a different proposed reason.
SELECT 1 / ((evolution.reject_primitive_life(9750,1,:'lease_holder',:lease_epoch,
'11111111-1111-1111-1111-111111111111',1,10,2::smallint) = 1)::int);
SELECT * FROM evolution.reserve_primitive_life(9750,1,:'lease_holder',:lease_epoch,
'11111111-1111-1111-1111-111111111111',1,11,1) \gset
SELECT 1 / ((:life_identity = 2)::int);
SELECT * FROM evolution.reserve_primitive_life(9750,1,:'lease_holder',:lease_epoch,
'11111111-1111-1111-1111-111111111111',1,10,1) \gset
SELECT 1 / ((:life_identity = 1 AND :rejection = 1)::int);
RESET ROLE;
SELECT 1 / ((SELECT next_identity = 3 FROM evolution.life_allocators WHERE world_id=9750)::int);
UPDATE evolution.life_allocators SET next_identity=18446744073709551615 WHERE world_id=9750;
SET ROLE evo_runtime_login;
SELECT * FROM evolution.claim_account_control(9750,1,:'lease_holder',:lease_epoch,
'55555555-5555-5555-5555-555555555555',1,3,60000) \gset
DO $$ BEGIN
BEGIN
PERFORM evolution.reserve_primitive_life(9750,1,current_setting('test.holder')::uuid,
current_setting('test.epoch')::numeric,'55555555-5555-5555-5555-555555555555',1,1,1);
RAISE EXCEPTION 'wrapped exhausted allocator';
EXCEPTION WHEN SQLSTATE 'EVL05' THEN NULL; END;
END $$;
RESET ROLE;
SELECT 1 / ((SELECT count(*) = 2 FROM evolution.life_reservations WHERE world_id=9750)::int);
SELECT 1 / ((SELECT next_identity = 18446744073709551615 FROM evolution.life_allocators WHERE world_id=9750)::int);
UPDATE evolution.life_allocators SET next_identity=3 WHERE world_id=9750;
-- Deliberate transaction rollback: no allocation or reservation can survive alone.
BEGIN;
SET LOCAL ROLE evo_runtime_login;
SELECT * FROM evolution.reserve_primitive_life(9750,1,:'lease_holder',:lease_epoch,
'55555555-5555-5555-5555-555555555555',1,1,1);
ROLLBACK;
SELECT 1 / ((SELECT next_identity = 3 FROM evolution.life_allocators WHERE world_id=9750)::int);
SELECT 1 / ((SELECT count(*) = 2 FROM evolution.life_reservations WHERE world_id=9750)::int);
-- Expired region cannot reserve or resolve through its stale authority.
UPDATE evolution.region_leases SET expires_at=clock_timestamp()-interval '1 second'
WHERE world_id=9750 AND region_id=1;
SET ROLE evo_runtime_login;
DO $$ BEGIN
BEGIN
PERFORM evolution.reserve_primitive_life(9750,1,current_setting('test.holder')::uuid,
current_setting('test.epoch')::numeric,'11111111-1111-1111-1111-111111111111',1,11,1);
RAISE EXCEPTION 'accepted expired region authority';
EXCEPTION WHEN SQLSTATE 'EVL02' THEN NULL; END;
END $$;
SELECT * FROM evolution.acquire_region_lease(9750,2,60000,decode(repeat('d5',32),'hex')) \gset
SELECT * FROM evolution.claim_account_control(9750,2,:'lease_holder',:lease_epoch,
'11111111-1111-1111-1111-111111111111',2,2,60000) \gset
-- A takeover may inspect the reservation while waiting; it grants no body/control
-- before the session layer's takeover wait. The original owner remains region 1.
SELECT * FROM evolution.reserve_primitive_life(9750,2,:'lease_holder',:lease_epoch,
'11111111-1111-1111-1111-111111111111',:control_generation,11,1) \gset
SELECT 1 / ((:life_identity = 2 AND :life_region = 1)::int);
RESET ROLE;
-- Restore tests must retain the allocator above every historical reservation.
SELECT 1 / ((SELECT count(*) = 2 FROM evolution.life_reservations WHERE world_id=9750)::int);
UPDATE evolution.region_leases SET expires_at=clock_timestamp()-interval '1 second'
WHERE world_id=9750;
+65
View File
@@ -0,0 +1,65 @@
#!/usr/bin/env bash
set -euo pipefail
# Only called against the disposable postgres-check cluster. Two independently
# connected regions contend for one world allocator, then retry after reconnect.
work="$(mktemp -d /tmp/evo-life-reservations.XXXXXXXX)"
psql -X -v ON_ERROR_STOP=1 > /dev/null <<'SQL'
INSERT INTO evolution.life_allocators VALUES (9751,1);
INSERT INTO evolution.region_leases(world_id,region_id,frame_id) VALUES (9751,1,7),(9751,2,7);
SQL
runtime() { psql -XAt -v ON_ERROR_STOP=1 -U "$EVO_PG_RUNTIME_USER" "$@"; }
IFS='|' read -r holder_a epoch_a frame_a duration_a < <(runtime -c "SELECT * FROM evolution.acquire_region_lease(9751,1,60000,decode(repeat('d5',32),'hex'))")
IFS='|' read -r holder_b epoch_b frame_b duration_b < <(runtime -c "SELECT * FROM evolution.acquire_region_lease(9751,2,60000,decode(repeat('d5',32),'hex'))")
account_a=22222222-2222-2222-2222-222222222222
account_b=33333333-3333-3333-3333-333333333333
runtime -c "SELECT * FROM evolution.claim_account_control(9751,1,'$holder_a',$epoch_a,'$account_a',1,1,60000)" > /dev/null
runtime -c "SELECT * FROM evolution.claim_account_control(9751,2,'$holder_b',$epoch_b,'$account_b',1,1,60000)" > /dev/null
reserve_a="SELECT life_identity FROM evolution.reserve_primitive_life(9751,1,'$holder_a',$epoch_a,'$account_a',1,1,1)"
reserve_b="SELECT life_identity FROM evolution.reserve_primitive_life(9751,2,'$holder_b',$epoch_b,'$account_b',1,1,1)"
# Hold allocator row so both actual independent connections queue for it.
psql -X -v ON_ERROR_STOP=1 -c "BEGIN; SELECT * FROM evolution.life_allocators WHERE world_id=9751 FOR UPDATE; SELECT pg_sleep(1); COMMIT" > "$work/lock" &
locker=$!
# No correctness assumption on which client wins; the shared counter must issue
# exactly two distinct identities, even if the lock process starts last.
runtime -c "$reserve_a" > "$work/a" &
first=$!
runtime -c "$reserve_b" > "$work/b" &
second=$!
wait "$first"; wait "$second"; wait "$locker"
test "$(cat "$work/a")" != "$(cat "$work/b")"
test "$(runtime -c "$reserve_a")" = "$(cat "$work/a")"
test "$(runtime -c "$reserve_b")" = "$(cat "$work/b")"
test "$(psql -XAtc 'SELECT next_identity FROM evolution.life_allocators WHERE world_id=9751')" = 3
# Same account/request on two independent connections retains exactly one ID.
runtime -c "$reserve_a" > "$work/retry1" &
first=$!
runtime -c "$reserve_a" > "$work/retry2" &
second=$!
wait "$first"; wait "$second"
cmp "$work/a" "$work/retry1"; cmp "$work/a" "$work/retry2"
test "$(psql -XAtc 'SELECT count(*) FROM evolution.life_reservations WHERE world_id=9751')" = 2
account_c=44444444-4444-4444-4444-444444444444
runtime -c "SELECT * FROM evolution.claim_account_control(9751,2,'$holder_b',$epoch_b,'$account_c',1,2,1000)" > /dev/null
psql -X -v ON_ERROR_STOP=1 > "$work/expiry-lock" <<'SQL' &
BEGIN;
SELECT * FROM evolution.life_allocators WHERE world_id=9751 FOR UPDATE;
\echo life-lock-held
SELECT pg_sleep(2);
COMMIT;
SQL
locker=$!
locked=false
for attempt in $(seq 1 200); do
if grep -q life-lock-held "$work/expiry-lock"; then locked=true; break; fi
sleep 0.01
done
test "$locked" = true
if runtime -c "SELECT * FROM evolution.reserve_primitive_life(9751,2,'$holder_b',$epoch_b,'$account_c',1,1,1)" > "$work/expired" 2>&1; then
echo 'Expired controller allocated an identity after waiting' >&2; exit 1
fi
wait "$locker"
grep -q 'life control fenced' "$work/expired"
test "$(psql -XAtc 'SELECT next_identity FROM evolution.life_allocators WHERE world_id=9751')" = 3
test "$(psql -XAtc 'SELECT count(*) FROM evolution.life_reservations WHERE world_id=9751')" = 2
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.region_leases SET expires_at=clock_timestamp()-interval '1 second' WHERE world_id=9751" > /dev/null
printf '%s\n' 'PASS independent life reservation connections, shared allocator and reconnect retries'
+12 -5
View File
@@ -17,6 +17,11 @@ psql -X -v ON_ERROR_STOP=1 -c 'CREATE ROLE evo_runtime_test NOLOGIN' \
export EVO_PG_RUNTIME_ROLE=evo_runtime_test EVO_PG_RUNTIME_USER=evo_runtime_login
bash "$root/tools/migrate-postgres.sh"
bash "$root/tools/migrate-postgres.sh" # exact supported upgrade/restart is a no-op
if [ "${1:-}" = --life-reservations-only ]; then
psql -X -v ON_ERROR_STOP=1 -f "$root/tools/ci/life-reservations-check.sql" > /dev/null
bash "$root/tools/ci/life-reservations-concurrency.sh"
exit 0
fi
# M7.9 clone target: a separate database with its own runtime group and login,
# so a clone shares neither the source's database nor its runtime credentials.
psql -X -v ON_ERROR_STOP=1 -c 'CREATE ROLE evo_clone_runtime NOLOGIN' -c 'CREATE ROLE evo_clone_login LOGIN IN ROLE evo_clone_runtime'
@@ -30,6 +35,8 @@ export EVO_SERVER_BIN EVO_WORLD_CLONE_BIN
EVO_SERVER_BIN="$(dirname "${1:?path to evo-postgres-tests}")/evo-server"
EVO_WORLD_CLONE_BIN="$(dirname "$1")/evo-world-clone"
"$1"
psql -X -v ON_ERROR_STOP=1 -f "$root/tools/ci/life-reservations-check.sql" > /dev/null
bash "$root/tools/ci/life-reservations-concurrency.sh"
# M8.7: online backup under load, restore on a separate cluster, isolated rebuild.
bash "$root/tools/ci/backup-check.sh"
# M8.8: host-loss rehearsal: in-place restore, fenced old environment, measured rewind.
@@ -61,7 +68,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
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
# 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%% *}"
@@ -82,7 +89,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")" = 14:1,2,3,4,5,6,7,8,9,10,11,12,13,14
test "$(PGDATABASE=v3_commits psql -XAtc "SELECT count(*) || ':' || string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 15:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
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.
@@ -136,7 +143,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
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
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
# Inherited privileges bypass fencing, so every migrate run audits effective rights.
@@ -181,9 +188,9 @@ expect_audit_failure 'GRANT SELECT ON evolution.account_controls TO evo_runtime_
expect_audit_failure 'REVOKE EXECUTE ON FUNCTION evolution.claim_account_control(evolution.u64, evolution.u64, uuid, evolution.u64, uuid, evolution.u64, evolution.u64, integer) FROM evo_runtime_test' 'GRANT EXECUTE ON FUNCTION evolution.claim_account_control(evolution.u64, evolution.u64, uuid, evolution.u64, uuid, evolution.u64, evolution.u64, integer) TO evo_runtime_test'
bash "$root/tools/migrate-postgres.sh" # Restored configuration passes the audit again.
# 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=15 WHERE version=14'
psql -X -v ON_ERROR_STOP=1 -c 'UPDATE evolution.schema_migrations SET version=16 WHERE version=15'
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=14 WHERE version=15"
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET version=15 WHERE version=16"
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"
+2 -2
View File
@@ -4,7 +4,7 @@
# exported). Real evo-server processes on world 500:
# 1. Failed migration: a migration that takes the migration lock, alters a history
# table, holds its locks for 3 s and then fails runs while build b1 serves.
# Nothing it did remains (schema still v14, no new column); the host keeps its
# Nothing it did remains (schema still v15, no new column); the host keeps its
# authority, and every acknowledgement stays durable.
# 2. Barrier (ADR-0068 operator order): build b2 is retained, and a b2 host is started
# while b1 still holds the lease (it waits, never ready). upgrade_barrier(b1) fences
@@ -61,7 +61,7 @@ SQL
[ "$code" != 0 ] && grep -q 'division by zero' "$work/migration.log" || fail "the rehearsal migration did not fail"
[ "$(q -c "SELECT count(*) FROM information_schema.columns WHERE table_name = 'region_commits' AND column_name = 'rehearsal_column'")" = 0 ] ||
fail "the failed migration left a column"
[ "$(q -c 'SELECT max(version) FROM evolution.schema_migrations')" = 14 ] || fail "schema version moved"
[ "$(q -c 'SELECT max(version) FROM evolution.schema_migrations')" = 15 ] || fail "schema version moved"
wait_ack "$work/b1.log" $((before + 40)) || fail "b1 did not resume after the failed migration"
kill -0 "$b1_pid" 2> /dev/null || fail "b1 exited during the failed migration"
bash "$root/tools/migrate-postgres.sh" > /dev/null || fail "migrate after the failure"
+3
View File
@@ -40,6 +40,8 @@ digest_13="$(sha256sum "$root/migrations/0013_probe_incoming.sql")"
digest_13="${digest_13%% *}"
digest_14="$(sha256sum "$root/migrations/0014_probe_overdue.sql")"
digest_14="${digest_14%% *}"
digest_15="$(sha256sum "$root/migrations/0015_life_reservations.sql")"
digest_15="${digest_15%% *}"
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" \
@@ -47,5 +49,6 @@ psql -X --no-password --set=ON_ERROR_STOP=1 --set="migration_sha=$digest" \
--set="migration_sha_8=$digest_8" --set="migration_sha_9=$digest_9" \
--set="migration_sha_10=$digest_10" --set="migration_sha_11=$digest_11" --set="migration_sha_12=$digest_12" --set="migration_sha_13=$digest_13" \
--set="migration_sha_14=$digest_14" \
--set="migration_sha_15=$digest_15" \
--set="runtime_role=$runtime_role" \
--file="$root/migrations/apply.sql"