feat(cellular): region ticks of up to 4,096 lives for testing (schema 68)
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / postgres-tools (push) Successful in 31s
Foundation / server-image (push) Successful in 4m29s
Foundation / image (push) Successful in 5m43s

ADR-0182 section 17. The plan's 2,000-organism cap became the rules-12
key region.organism_cap, which was parsed but never enforced; the real
bound was max_cellular_tick_lives = 256 (ADR-0106), which rules 13's
organism cap could not exceed. The bound is now 4,096, for testing limits
only; the DEV tuning file keeps 256.

- max_cellular_tick_lives (4,096) bounds the raw region path: step, owner
  state, batch trace (cellular_batch_bytes_for) and current checkpoint
  traces. max_cellular_frozen_lives (256) keeps cohort populations,
  population batches, migration traces and pre-v3 cellular traces, whose
  database checks are fixed.
- Tuning: reproduction.organism_cap and wildlife_cap accept up to 4,096.
- Schema 68: the trace checker under the current publishers
  (cellular_births_v45) accepts 4,096 intents, births and mutations per
  tick; spawn_wildlife takes up to 256 cells a command.
- Region view and portal: the lineage archive's fill (births of 65,536,
  genomes of 4,096), at which a region stops ticking.
- PostgreSQL suite: 256 wildlife spawned in one command, then a 289-life
  tick published and recovered exactly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-28 17:30:22 -04:00
co-authored by Claude Opus 5.5
parent 8005e7c4ae
commit 3c753970c8
29 changed files with 301 additions and 49 deletions
+6 -3
View File
@@ -900,7 +900,7 @@ async function regionPage(region, params) {
releaseNote)); releaseNote));
// Actions: wildlife, bubbles, schedules and the command log. // Actions: wildlife, bubbles, schedules and the command log.
const spawnCount = h('input', { type: 'number', min: 1, max: 64, value: 10, class: 'count' }); const spawnCount = h('input', { type: 'number', min: 1, max: 256, value: 10, class: 'count' });
const spawnReason = reasonInput(), spawnNote = h('div', { class: 'note' }); const spawnReason = reasonInput(), spawnNote = h('div', { class: 'note' });
const bubbleCount = h('input', { type: 'number', min: 1, max: 256, value: 20, class: 'count' }); const bubbleCount = h('input', { type: 'number', min: 1, max: 256, value: 20, class: 'count' });
const bubbleAmount = amountInputs(), bubbleReason = reasonInput(), bubbleNote = h('div', { class: 'note' }); const bubbleAmount = amountInputs(), bubbleReason = reasonInput(), bubbleNote = h('div', { class: 'note' });
@@ -1495,12 +1495,15 @@ async function regionPage(region, params) {
const deposits = Number(raw.deposits_total); const deposits = Number(raw.deposits_total);
const r = rate(); const r = rate();
k.tick.set(fmtInt(tick), pace.stalled ? `not advancing for ${fmtDuration((now - pace.movedAt) / 1000)}` : `${r.toFixed(1)} ticks/s`, pace.stalled ? 'warn' : ''); k.tick.set(fmtInt(tick), pace.stalled ? `not advancing for ${fmtDuration((now - pace.movedAt) / 1000)}` : `${r.toFixed(1)} ticks/s`, pace.stalled ? 'warn' : '');
// The lineage archive never forgets: at its limits the region stops ticking.
const archive = raw.archive ? Math.max(Number(raw.archive[0]) / Number(raw.archive[1]), Number(raw.archive[2]) / Number(raw.archive[3])) : 0;
const archiveText = raw.archive ? ` · archive ${Math.floor(archive * 100)}% (${fmtInt(raw.archive[0])} births, ${fmtInt(raw.archive[2])} genomes)` : '';
if (raw.caps) { if (raw.caps) {
// Births stop at the organism cap; wildlife buds stop at the wildlife cap. // Births stop at the organism cap; wildlife buds stop at the wildlife cap.
const cap = Number(raw.caps[0]), wildCap = Number(raw.caps[1]) || cap, lives = players + wild; const cap = Number(raw.caps[0]), wildCap = Number(raw.caps[1]) || cap, lives = players + wild;
const full = lives >= cap ? 'bad' : lives >= wildCap ? 'warn' : ''; const full = lives >= cap || archive >= 0.95 ? 'bad' : lives >= wildCap || archive >= 0.8 ? 'warn' : '';
k.cells.set(`${fmtInt(lives)} / ${fmtInt(cap)}`, k.cells.set(`${fmtInt(lives)} / ${fmtInt(cap)}`,
`${fmtInt(players)} players · ${fmtInt(wild)} wildlife${wildCap < cap ? ` · wildlife stop at ${fmtInt(wildCap)}` : ''}`, `${fmtInt(players)} players · ${fmtInt(wild)} wildlife${wildCap < cap ? ` · wildlife stop at ${fmtInt(wildCap)}` : ''}${archiveText}`,
lives ? full : 'warn', lives / cap, full); lives ? full : 'warn', lives / cap, full);
} else { } else {
k.cells.set(fmtInt(players + wild), `${fmtInt(players)} players · ${fmtInt(wild)} wildlife`, players + wild ? '' : 'warn'); k.cells.set(fmtInt(players + wild), `${fmtInt(players)} players · ${fmtInt(wild)} wildlife`, players + wild ? '' : 'warn');
+9 -1
View File
@@ -1,11 +1,19 @@
# Project status and next steps # Project status and next steps
## Larger region ticks for testing - 2026-10-28
A region tick may hold up to 4,096 lives (was 256), for testing limits only, and
`reproduction.organism_cap` accepts up to 4,096; the DEV file keeps 256. Schema 68 raises the
database's per-tick trace counts and lets one spawn command place 256 wildlife. The region page
shows the lineage archive's fill, which stops a region at 65,536 births. See
[ADR-0182](adr/0182-admin-portal-and-world-tuning.md) section 17.
## Testing a full region - 2026-10-28 ## Testing a full region - 2026-10-28
The Bud button follows a tuning adoption at once (the region's bud-cost cache was keyed by The Bud button follows a tuning adoption at once (the region's bud-cost cache was keyed by
genome only). `reproduction.wildlife_cap` keeps lives above it for players' buds. Two admin genome only). `reproduction.wildlife_cap` keeps lives above it for players' buds. Two admin
commands (schema 67): take reserve from a cell, and remove all wildlife; the region map marks commands (schema 67): take reserve from a cell, and remove all wildlife; the region map marks
cells (shift+click, shift+drag) for bulk removal. The 256-life organism cap is unchanged. See cells (shift+click, shift+drag) for bulk removal. See
[ADR-0182](adr/0182-admin-portal-and-world-tuning.md) section 16. [ADR-0182](adr/0182-admin-portal-and-world-tuning.md) section 16.
## Opening regions from the portal - 2026-10-28 ## Opening regions from the portal - 2026-10-28
+27 -4
View File
@@ -375,10 +375,33 @@ Playtesting region 16 (230 spawned wildlife under the 256-life cap) found three
to the cell inspector, Remove all wildlife to Actions, and marking on the map (shift+click, to the cell inspector, Remove all wildlife to Actions, and marking on the map (shift+click,
shift+drag a box) to remove the marked cells, one `remove_cell` each. shift+drag a box) to remove the marked cells, one `remove_cell` each.
Not changed: the organism cap stays at most 256 (`max_cellular_tick_lives`). That bound sizes The organism cap itself is section 17.
the batch trace, checkpoints, migration traces and the database's trace checks, and region 16
already runs at about a quarter of real time with about 250 lives. Raising it is a separate ### 17. Larger region ticks for testing (delivered 2026-10-28, schema 68)
format and performance change.
The region/movement plan set a 2,000-organism region cap, but the rules-12 key it became
(`region.organism_cap`) was parsed and never enforced. The real bound was the engine's
`max_cellular_tick_lives = 256`, a per-tick safety bound from ADR-0106 that the batch trace,
checkpoints and database trace checks were sized from; rules 13's `reproduction.organism_cap`
was capped at it.
- **Decision (2026-10-28).** The tick bound is 4,096 lives, for testing limits only; regions
are not meant to run that many. The DEV tuning file keeps 256.
- **Split bound.** `max_cellular_tick_lives` (4,096) bounds the raw region path: the step, the
owner state, the batch trace (`cellular_batch_bytes_for`) and current checkpoint traces.
`max_cellular_frozen_lives` (256) keeps the formats whose database checks are fixed: cohort
populations, population batches, migration traces and pre-v3 cellular traces. Rules 12 and
13 never use those paths.
- **Tuning.** `reproduction.organism_cap` and `reproduction.wildlife_cap` accept up to 4,096.
- **Schema 68.** The trace checker under the current publishers (schema 43's, renamed
`cellular_births_v45` by schema 46) accepts up to 4,096 intents, births and mutation choices
per tick; `spawn_wildlife` takes up to 256 cells a command (sixteen commands fill a tick).
- **Archive.** The lineage archive never forgets: a region stops ticking at 65,536 recorded
births or 4,096 genomes. The region view reports both (`archive`) and the portal's
Population shows the fuller one, warning at 80%. A crowded region reaches them sooner.
- **Not changed.** Performance: region 16 ran at about 5 of 20 ticks per second with about
250 lives, so a region near the bound will run far below real time. The client snapshot is
budgeted (nearest changes first), so it degrades rather than fails.
## Delivery order ## Delivery order
+1 -1
View File
@@ -120,7 +120,7 @@ void capacity(std::uint32_t count) {
std::chrono::duration_cast<std::chrono::nanoseconds>(Clock::now() - start).count())); std::chrono::duration_cast<std::chrono::nanoseconds>(Clock::now() - start).count()));
require(population->state().lives().size() == count, "capacity silently culled a life"); require(population->state().lives().size() == count, "capacity silently culled a life");
} }
if (count == biology::max_cellular_tick_lives) { if (count == biology::max_cellular_frozen_lives) {
const auto before = population->state().snapshot(); const auto before = population->state().snapshot();
LifeRequest request{}; LifeRequest request{};
request.account.front() = 1; request.account.front() = 1;
+5 -1
View File
@@ -12,7 +12,11 @@
#include <vector> #include <vector>
namespace evo::biology { namespace evo::biology {
inline constexpr std::size_t max_cellular_tick_lives = 256; // Lives one region tick may hold (ADR-0182 section 17: 4,096 for testing; regions run far
// fewer). Formats frozen at the original 256 (cohort populations, migration traces and the
// pre-v3 cellular traces) keep max_cellular_frozen_lives.
inline constexpr std::size_t max_cellular_tick_lives = 4'096;
inline constexpr std::size_t max_cellular_frozen_lives = 256;
// ADR-0124 (rules 3): a predator needs total mass >= ratio x prey total mass, with the // ADR-0124 (rules 3): a predator needs total mass >= ratio x prey total mass, with the
// ratio in thousandths per micrometre of prey membrane (tunable; 1.5 for 1 um). // ratio in thousandths per micrometre of prey membrane (tunable; 1.5 for 1 um).
@@ -89,13 +89,17 @@ inline constexpr std::size_t cellular_batch_mutation_bytes = 40;
inline constexpr std::size_t cellular_batch_admin_bytes = 64; inline constexpr std::size_t cellular_batch_admin_bytes = 64;
inline constexpr std::size_t max_cellular_tick_admin_commands = 16; inline constexpr std::size_t max_cellular_tick_admin_commands = 16;
inline constexpr std::size_t max_cellular_batch_ticks = 64; inline constexpr std::size_t max_cellular_batch_ticks = 64;
// The largest trace of a batch whose ticks hold at most `lives` lives.
[[nodiscard]] constexpr std::size_t cellular_batch_bytes_for(std::size_t lives) noexcept {
return cellular_batch_header_bytes +
max_cellular_batch_ticks *
(cellular_batch_tick_header_bytes +
lives * (cellular_batch_intent_bytes + cellular_batch_birth_bytes +
cellular_batch_mutation_bytes) +
max_cellular_tick_admin_commands * cellular_batch_admin_bytes);
}
inline constexpr std::size_t max_cellular_batch_bytes = inline constexpr std::size_t max_cellular_batch_bytes =
cellular_batch_header_bytes + cellular_batch_bytes_for(biology::max_cellular_tick_lives);
max_cellular_batch_ticks * (cellular_batch_tick_header_bytes +
biology::max_cellular_tick_lives *
(cellular_batch_intent_bytes + cellular_batch_birth_bytes +
cellular_batch_mutation_bytes) +
max_cellular_tick_admin_commands * cellular_batch_admin_bytes);
enum class CellularBatchError : std::uint8_t { format, version, scope, state }; enum class CellularBatchError : std::uint8_t { format, version, scope, state };
inline constexpr std::size_t cellular_action_record_bytes = 48; inline constexpr std::size_t cellular_action_record_bytes = 48;
inline constexpr std::size_t max_cellular_action_records = 1'024; inline constexpr std::size_t max_cellular_action_records = 1'024;
@@ -191,7 +191,7 @@ enum class CellularAdminKind : std::uint8_t { // A u16 in the trace.
add_bubbles = 3, // `amount` imported as `count` (1..256) bubbles sharing it. add_bubbles = 3, // `amount` imported as `count` (1..256) bubbles sharing it.
add_pool = 4, // `amount` imported into the spent pool. add_pool = 4, // `amount` imported into the spent pool.
release_pool = 5, // Up to `amount` moved from the spent pool into `count` bubbles. release_pool = 5, // Up to `amount` moved from the spent pool into `count` bubbles.
spawn_wildlife = 6, // `count` (1..64) random-genome roots, identities `target`.., imported. spawn_wildlife = 6, // `count` (1..256) random-genome roots, identities `target`.., imported.
// ADR-0182 tuning amendment: the region's rules-13 rules become tuning revision `target`, // ADR-0182 tuning amendment: the region's rules-13 rules become tuning revision `target`,
// whose canonical rules encoding (encode_cellular_revamp_rules) has the SHA-256 held in the // whose canonical rules encoding (encode_cellular_revamp_rules) has the SHA-256 held in the
// energy, carbon, nitrogen and phosphorus amounts (little-endian words; `other` zero). // energy, carbon, nitrogen and phosphorus amounts (little-endian words; `other` zero).
@@ -30,7 +30,7 @@ struct CellularMigrationTrace {
}; };
inline constexpr std::size_t migration_trace_header_bytes = 256; inline constexpr std::size_t migration_trace_header_bytes = 256;
inline constexpr std::size_t max_migration_trace_bytes = inline constexpr std::size_t max_migration_trace_bytes =
migration_trace_header_bytes + 8 * biology::max_cellular_tick_lives + 8; migration_trace_header_bytes + 8 * biology::max_cellular_frozen_lives + 8;
struct RecordedCellularMigration { struct RecordedCellularMigration {
CellularMigrationTrace trace; CellularMigrationTrace trace;
CellularMigrationExecution execution; CellularMigrationExecution execution;
@@ -33,9 +33,9 @@ struct CellularTierPolicy {
}; };
inline constexpr std::size_t cellular_population_header_bytes = 80; inline constexpr std::size_t cellular_population_header_bytes = 80;
inline constexpr std::uint32_t cellular_population_inheritance_format = 3; inline constexpr std::uint32_t cellular_population_inheritance_format = 3;
inline constexpr std::size_t max_cellular_population_bytes = cellular_population_header_bytes + inline constexpr std::size_t max_cellular_population_bytes =
16 * biology::max_cellular_tick_lives + cellular_population_header_bytes + 16 * biology::max_cellular_frozen_lives +
max_cellular_lives_bytes + 8; max_cellular_lives_bytes + 8;
class CellularPopulation { class CellularPopulation {
public: public:
@@ -26,8 +26,8 @@ struct CellularPopulationBatch {
}; };
inline constexpr std::size_t population_batch_header_bytes = 136; inline constexpr std::size_t population_batch_header_bytes = 136;
inline constexpr std::size_t max_population_batch_bytes = inline constexpr std::size_t max_population_batch_bytes =
population_batch_header_bytes + max_cellular_batch_bytes + population_batch_header_bytes + cellular_batch_bytes_for(biology::max_cellular_frozen_lives) +
max_cellular_batch_ticks * (16 + 16 * biology::max_cellular_tick_lives); max_cellular_batch_ticks * (16 + 16 * biology::max_cellular_frozen_lives);
struct CellularPopulationExecution { struct CellularPopulationExecution {
CellularPopulationBatch batch; CellularPopulationBatch batch;
std::unique_ptr<CellularPopulation> state; std::unique_ptr<CellularPopulation> state;
+145
View File
@@ -0,0 +1,145 @@
-- Larger region ticks (ADR-0182 section 17, 2026-10-28). A region tick may hold up to 4,096
-- lives, a bound for testing (regions run far fewer). The cellular trace checker under the
-- current publishers (schema 43's, renamed cellular_births_v45 by schema 46) accepts up to
-- 4,096 intents, births and mutation choices per tick; nothing else in it changes. Cohort
-- populations and migration traces keep their 256 bounds. Spawning takes up to 256 wildlife
-- per command.
CREATE OR REPLACE FUNCTION evolution.cellular_births_v45(p_trace bytea, p_manifest bytea)
RETURNS TABLE(account_id uuid, request_id evolution.u64, generation evolution.u64,
identity evolution.u64, born evolution.u64)
LANGUAGE plpgsql IMMUTABLE SECURITY INVOKER SET search_path = pg_catalog, pg_temp AS $$
DECLARE
c evolution.checkpoint_manifest := evolution.parse_checkpoint_manifest(p_manifest);
revision boolean;
ticks numeric;
tick_index integer;
trace_format numeric;
tick_header_size integer;
intent_count numeric;
birth_count numeric;
mutation_count numeric;
off integer := 112;
account bytea;
previous_account bytea;
previous_request numeric;
BEGIN
revision := c.versions IN (
'\x020000000300000001000000010000000100000002000000010000000200000001000000'::bytea,
'\x030000000400000001000000010000000100000002000000010000000200000001000000'::bytea,
'\x040000000500000001000000010000000100000002000000010000000200000001000000'::bytea,
'\x050000000600000001000000010000000100000002000000010000000200000001000000'::bytea,
'\x060000000600000001000000010000000100000003000000020000000200000001000000'::bytea,
'\x070000000600000001000000010000000100000004000000030000000200000001000000'::bytea,
'\x080000000600000002000000010000000100000004000000030000000200000001000000'::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 > 4096 OR birth_count > 4096 OR mutation_count > 4096
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 $$;
CREATE OR REPLACE FUNCTION evolution.admin_enqueue_command_v1(p_world evolution.u64,
p_region evolution.u64, p_kind integer, p_count integer, p_target evolution.u64,
p_energy evolution.u64, p_carbon evolution.u64, p_nitrogen evolution.u64,
p_phosphorus evolution.u64, p_other evolution.u64, p_subject text, p_reason text)
RETURNS TABLE (command_id bigint, target evolution.u64)
LANGUAGE plpgsql SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS $$
#variable_conflict use_column
DECLARE
has_amount boolean := p_energy + p_carbon + p_nitrogen + p_phosphorus + p_other > 0;
first numeric := p_target;
BEGIN
IF NOT ((p_kind IN (1, 2, 8) AND p_target > 0 AND p_count = 0
AND has_amount = (p_kind IN (2, 8)))
OR (p_kind IN (3, 5) AND p_target = 0 AND p_count BETWEEN 1 AND 256 AND has_amount)
OR (p_kind = 4 AND p_target = 0 AND p_count = 0 AND has_amount)
OR (p_kind = 6 AND p_count BETWEEN 1 AND 256 AND NOT has_amount)
OR (p_kind = 9 AND p_target = 0 AND p_count = 0 AND NOT has_amount)) THEN
RAISE EXCEPTION 'invalid admin command' USING ERRCODE = '22023';
END IF;
IF NOT EXISTS (SELECT 1 FROM evolution.region_leases l
WHERE l.world_id = p_world AND l.region_id = p_region) THEN
RAISE EXCEPTION 'unknown region' USING ERRCODE = '22023';
END IF;
IF p_kind = 6 THEN
SELECT a.next_identity INTO first FROM evolution.life_allocators a
WHERE a.world_id = p_world FOR UPDATE;
IF first IS NULL OR first + p_count > 9223372036854775808 THEN
RAISE EXCEPTION 'no identities for wildlife' USING ERRCODE = '22023';
END IF;
UPDATE evolution.life_allocators SET next_identity = first + p_count
WHERE world_id = p_world;
END IF;
RETURN QUERY
WITH queued AS (
INSERT INTO evolution.admin_commands AS q(world_id, region_id, kind, cell_count, target,
energy, carbon, nitrogen, phosphorus, other, author_subject, reason)
VALUES (p_world, p_region, p_kind, p_count, first, p_energy, p_carbon, p_nitrogen,
p_phosphorus, p_other, p_subject, coalesce(p_reason, ''))
RETURNING q.command_id, q.target)
SELECT queued.command_id, queued.target FROM queued;
END $$;
INSERT INTO evolution.schema_migrations(version,sha256) VALUES(68,:'migration_sha_68');
+12 -3
View File
@@ -143,6 +143,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
SELECT :'history_v64' || ',65:' || :'migration_sha_65' AS history_v65 \gset SELECT :'history_v64' || ',65:' || :'migration_sha_65' AS history_v65 \gset
SELECT :'history_v65' || ',66:' || :'migration_sha_66' AS history_v66 \gset SELECT :'history_v65' || ',66:' || :'migration_sha_66' AS history_v66 \gset
SELECT :'history_v66' || ',67:' || :'migration_sha_67' AS history_v67 \gset SELECT :'history_v66' || ',67:' || :'migration_sha_67' AS history_v67 \gset
SELECT :'history_v67' || ',68:' || :'migration_sha_68' AS history_v68 \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,
@@ -188,8 +189,10 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
:'history' = :'history_v64' AS at_v64, :'history' = :'history_v64' AS at_v64,
:'history' = :'history_v65' AS at_v65, :'history' = :'history_v65' AS at_v65,
:'history' = :'history_v66' AS at_v66, :'history' = :'history_v66' AS at_v66,
:'history' = :'history_v67' AS at_v67 \gset :'history' = :'history_v67' AS at_v67,
\if :at_v67 :'history' = :'history_v68' AS at_v68 \gset
\if :at_v68
\elif :at_v67
\elif :at_v66 \elif :at_v66
\elif :at_v65 \elif :at_v65
\elif :at_v64 \elif :at_v64
@@ -617,7 +620,8 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
coalesce(max(version), 0) = 64 AS at_v64, coalesce(max(version), 0) = 64 AS at_v64,
coalesce(max(version), 0) = 65 AS at_v65, coalesce(max(version), 0) = 65 AS at_v65,
coalesce(max(version), 0) = 66 AS at_v66, coalesce(max(version), 0) = 66 AS at_v66,
coalesce(max(version), 0) = 67 AS at_v67 coalesce(max(version), 0) = 67 AS at_v67,
coalesce(max(version), 0) = 68 AS at_v68
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
@@ -853,6 +857,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\elif :at_v65 \elif :at_v65
\elif :at_v66 \elif :at_v66
\elif :at_v67 \elif :at_v67
\elif :at_v68
\else \else
\echo 'Unknown or changed migration history after v43' \echo 'Unknown or changed migration history after v43'
DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$; DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$;
@@ -953,6 +958,10 @@ SELECT coalesce(max(version), 0) = 66 AS needs_v67 FROM evolution.schema_migrati
\if :needs_v67 \if :needs_v67
\ir 0067_admin_take_and_cull.sql \ir 0067_admin_take_and_cull.sql
\endif \endif
SELECT coalesce(max(version), 0) = 67 AS needs_v68 FROM evolution.schema_migrations \gset
\if :needs_v68
\ir 0068_larger_region_ticks.sql
\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
-- alone are insufficient: predefined roles such as pg_write_all_data, PUBLIC -- alone are insufficient: predefined roles such as pg_write_all_data, PUBLIC
-- grants or SET-able memberships would bypass the fenced functions. Checks the -- grants or SET-able memberships would bypass the fenced functions. Checks the
+2 -2
View File
@@ -86,8 +86,8 @@ constexpr std::array fields{
amount_limit}, amount_limit},
Field{"reproduction.bud_fee_scale_percent", Field{"reproduction.bud_fee_scale_percent",
&CellularRevampTuning::reproduction_bud_fee_scale_percent, 0, 100}, &CellularRevampTuning::reproduction_bud_fee_scale_percent, 0, 100},
Field{"reproduction.organism_cap", &CellularRevampTuning::reproduction_organism_cap, 1, 256}, Field{"reproduction.organism_cap", &CellularRevampTuning::reproduction_organism_cap, 1, 4'096},
Field{"reproduction.wildlife_cap", &CellularRevampTuning::reproduction_wildlife_cap, 0, 256}, Field{"reproduction.wildlife_cap", &CellularRevampTuning::reproduction_wildlife_cap, 0, 4'096},
Field{"organism.load_per_mille", &CellularRevampTuning::organism_load_per_mille, 0, 10'000}, Field{"organism.load_per_mille", &CellularRevampTuning::organism_load_per_mille, 0, 10'000},
Field{"organism.emerge_members", &CellularRevampTuning::organism_emerge_members, 2, 10'000}, Field{"organism.emerge_members", &CellularRevampTuning::organism_emerge_members, 2, 10'000},
Field{"organism.emerge_mass_fg", &CellularRevampTuning::organism_emerge_mass_fg, 0, Field{"organism.emerge_mass_fg", &CellularRevampTuning::organism_emerge_mass_fg, 0,
+2 -2
View File
@@ -155,12 +155,12 @@ bool structural(const CheckpointManifest& m) noexcept {
const auto cellular_v2_max = const auto cellular_v2_max =
server::cellular_batch_header_bytes + server::cellular_batch_header_bytes +
ticks * (server::cellular_batch_v2_tick_header_bytes + ticks * (server::cellular_batch_v2_tick_header_bytes +
biology::max_cellular_tick_lives * biology::max_cellular_frozen_lives *
(server::cellular_batch_intent_bytes + server::cellular_batch_birth_bytes)); (server::cellular_batch_intent_bytes + server::cellular_batch_birth_bytes));
const auto cellular_legacy_max = const auto cellular_legacy_max =
server::cellular_batch_header_bytes + server::cellular_batch_header_bytes +
ticks * (server::cellular_batch_v1_tick_header_bytes + ticks * (server::cellular_batch_v1_tick_header_bytes +
biology::max_cellular_tick_lives * server::cellular_batch_intent_bytes); biology::max_cellular_frozen_lives * server::cellular_batch_intent_bytes);
const bool cellular_current_trace = const bool cellular_current_trace =
b.trace_bytes >= cellular_current_min && b.trace_bytes <= cellular_max && b.trace_bytes >= cellular_current_min && b.trace_bytes <= cellular_max &&
(b.trace_bytes - cellular_current_min) % sizeof(std::uint64_t) == 0; (b.trace_bytes - cellular_current_min) % sizeof(std::uint64_t) == 0;
@@ -82,6 +82,17 @@ std::string render_cellular_admin_view(const CellularLives& state,
append_inventory(out, state.spent()); append_inventory(out, state.spent());
out += "],\"heat\":"; out += "],\"heat\":";
append(out, state.heat().energy.value); append(out, state.heat().energy.value);
// The lineage archive never forgets: births and genomes recorded against its limits, at
// which the region stops ticking.
out += ",\"archive\":[";
append(out, state.archive().recorded());
out.push_back(',');
append(out, biology::max_archived_organisms);
out.push_back(',');
append(out, state.archive().archived());
out.push_back(',');
append(out, biology::max_archived_genomes);
out.push_back(']');
if (state.rules_version() >= cellular_lives_revamp_rules) { if (state.rules_version() >= cellular_lives_revamp_rules) {
const auto& rules = state.revamp_rules(); const auto& rules = state.revamp_rules();
out += ",\"drip\":["; out += ",\"drip\":[";
+1 -1
View File
@@ -1536,7 +1536,7 @@ bool cellular_admin_command_valid(const CellularAdminCommand& c) noexcept {
case CellularAdminKind::add_pool: case CellularAdminKind::add_pool:
return c.id != 0 && c.target == 0 && c.count == 0 && some; return c.id != 0 && c.target == 0 && c.count == 0 && some;
case CellularAdminKind::spawn_wildlife: case CellularAdminKind::spawn_wildlife:
return c.id != 0 && c.count >= 1 && c.count <= 64 && !some && c.target != 0 && return c.id != 0 && c.count >= 1 && c.count <= 256 && !some && c.target != 0 &&
c.target <= cellular_bud_namespace - c.count; c.target <= cellular_bud_namespace - c.count;
case CellularAdminKind::adopt_tuning: case CellularAdminKind::adopt_tuning:
return c.id != 0 && c.count == 0 && c.target != 0 && some && c.amount.matter[3].value == 0; return c.id != 0 && c.count == 0 && c.target != 0 && some && c.amount.matter[3].value == 0;
+1 -1
View File
@@ -80,7 +80,7 @@ CellularMigration::prepare(const CellularLives& source, const CellularLives& des
} }
if (moving.empty()) if (moving.empty())
return std::unexpected(CellularMigrationError::ineligible); return std::unexpected(CellularMigrationError::ineligible);
if (destination.lives().size() + moving.size() > biology::max_cellular_tick_lives) if (destination.lives().size() + moving.size() > biology::max_cellular_frozen_lives)
return std::unexpected(CellularMigrationError::capacity); return std::unexpected(CellularMigrationError::capacity);
const auto area = destination.area(); const auto area = destination.area();
for (const auto& life : moving) { for (const auto& life : moving) {
@@ -29,7 +29,7 @@ bool shape(const CellularMigrationTrace& trace) {
trace.representation != CellularMigrationRepresentation::population) || trace.representation != CellularMigrationRepresentation::population) ||
trace.world == 0 || trace.frame == 0 || trace.tick == 0 || !valid_request(trace.request) || trace.world == 0 || trace.frame == 0 || trace.tick == 0 || !valid_request(trace.request) ||
trace.transferred == accounting::Inventory{} || trace.members.empty() || trace.transferred == accounting::Inventory{} || trace.members.empty() ||
trace.members.size() > biology::max_cellular_tick_lives || trace.members.size() > biology::max_cellular_frozen_lives ||
!std::ranges::is_sorted(trace.members) || !std::ranges::is_sorted(trace.members) ||
std::ranges::adjacent_find(trace.members) != trace.members.end()) std::ranges::adjacent_find(trace.members) != trace.members.end())
return false; return false;
@@ -209,7 +209,7 @@ decode_migration_trace(std::span<const std::uint8_t> bytes) {
for (auto& mass : trace.transferred.matter) for (auto& mass : trace.transferred.matter)
mass.value = in.get(); mass.value = in.get();
const auto count = in.get(4); const auto count = in.get(4);
if (in.get(4) != 0 || count == 0 || count > biology::max_cellular_tick_lives || if (in.get(4) != 0 || count == 0 || count > biology::max_cellular_frozen_lives ||
bytes.size() != migration_trace_header_bytes + 8 * count + 8) bytes.size() != migration_trace_header_bytes + 8 * count + 8)
return std::unexpected(CellularMigrationError::format); return std::unexpected(CellularMigrationError::format);
trace.members.reserve(static_cast<std::size_t>(count)); trace.members.reserve(static_cast<std::size_t>(count));
@@ -39,7 +39,7 @@ bool shape(const CellularPopulationBatch& batch, bool recording) {
return false; return false;
} }
for (const auto& boundary : batch.boundaries) { for (const auto& boundary : batch.boundaries) {
if (boundary.members.size() > biology::max_cellular_tick_lives) if (boundary.members.size() > biology::max_cellular_frozen_lives)
return false; return false;
std::uint64_t previous = 0; std::uint64_t previous = 0;
for (const auto& member : boundary.members) { for (const auto& member : boundary.members) {
@@ -313,7 +313,7 @@ decode_population_batch(std::span<const std::uint8_t> bytes) {
CellularPopulationBoundary boundary; CellularPopulationBoundary boundary;
boundary.sequence = boundary_reader.get(); boundary.sequence = boundary_reader.get();
const auto members = boundary_reader.get(); const auto members = boundary_reader.get();
if (members > biology::max_cellular_tick_lives || members * 16 > bytes.size() - at - 16) if (members > biology::max_cellular_frozen_lives || members * 16 > bytes.size() - at - 16)
return std::unexpected(CellularPopulationError::format); return std::unexpected(CellularPopulationError::format);
for (std::uint64_t member = 0; member < members; ++member) for (std::uint64_t member = 0; member < members; ++member)
boundary.members.push_back({boundary_reader.get(), boundary_reader.get()}); boundary.members.push_back({boundary_reader.get(), boundary_reader.get()});
@@ -92,7 +92,7 @@ CellularPopulation::restore(std::span<const std::uint8_t> bytes, std::uint64_t w
reader.get(8) != tick) reader.get(8) != tick)
return std::unexpected(CellularPopulationError::identity); return std::unexpected(CellularPopulationError::identity);
const auto biological_bytes = reader.get(8), count = reader.get(8); const auto biological_bytes = reader.get(8), count = reader.get(8);
if (count > biology::max_cellular_tick_lives || biological_bytes > max_cellular_lives_bytes || if (count > biology::max_cellular_frozen_lives || biological_bytes > max_cellular_lives_bytes ||
biological_bytes == 0 || biological_bytes == 0 ||
bytes.size() != cellular_population_header_bytes + count * 16 + biological_bytes + 8) bytes.size() != cellular_population_header_bytes + count * 16 + biological_bytes + 8)
return std::unexpected(CellularPopulationError::format); return std::unexpected(CellularPopulationError::format);
+4 -2
View File
@@ -96,8 +96,10 @@ void renders_cells_and_deposits() {
"bubble totals"); "bubble totals");
require(text.find("\"drip\"") == std::string::npos, "a drip before rules 13"); require(text.find("\"drip\"") == std::string::npos, "a drip before rules 13");
require(text.find("],\"heat\":" + std::to_string(state->heat().energy.value) + require(text.find("],\"heat\":" + std::to_string(state->heat().energy.value) +
",\"cells_total\":") != std::string::npos, ",\"archive\":[" + std::to_string(state->archive().recorded()) +
"heat"); ",65536," + std::to_string(state->archive().archived()) +
",4096],\"cells_total\":") != std::string::npos,
"heat and archive");
} }
} }
+1 -1
View File
@@ -245,7 +245,7 @@ void trace_contract(bool maturing = false) {
} }
altered = trace; altered = trace;
altered.members.clear(); altered.members.clear();
for (std::uint64_t i = 1; i <= biology::max_cellular_tick_lives; ++i) for (std::uint64_t i = 1; i <= biology::max_cellular_frozen_lives; ++i)
altered.members.push_back(cellular_bud_identity(3, i)); altered.members.push_back(cellular_bud_identity(3, i));
auto maximum = checked(encode_migration_trace(altered), "maximum pair codec"); auto maximum = checked(encode_migration_trace(altered), "maximum pair codec");
require(maximum.size() == max_migration_trace_bytes && require(maximum.size() == max_migration_trace_bytes &&
+37
View File
@@ -1593,6 +1593,7 @@ void run_starting_wildlife_publication_tests() {
auto tuned_rules = recovered->state->revamp_rules(); auto tuned_rules = recovered->state->revamp_rules();
auto& upkeep = tuned_rules.body.essential_upkeep_per_thousand; auto& upkeep = tuned_rules.body.essential_upkeep_per_thousand;
upkeep = upkeep == 100 ? 101 : 100; upkeep = upkeep == 100 ? 101 : 100;
tuned_rules.organism_cap = 4'096; // Section 17: room for the crowded tick below.
CHECK(evo::server::cellular_revamp_valid(tuned_rules) && CHECK(evo::server::cellular_revamp_valid(tuned_rules) &&
tuned_rules != recovered->state->revamp_rules()); tuned_rules != recovered->state->revamp_rules());
const auto tuned_digest = checked_value( const auto tuned_digest = checked_value(
@@ -1637,6 +1638,42 @@ void run_starting_wildlife_publication_tests() {
recovered = recover_cellular_checkpoint(*runtime, **objects, key, *lease, builds, 5s); recovered = recover_cellular_checkpoint(*runtime, **objects, key, *lease, builds, 5s);
CHECK(recovered && recovered->state->snapshot() == adopted_bytes && CHECK(recovered && recovered->state->snapshot() == adopted_bytes &&
recovered->state->revamp_rules() == tuned_rules); recovered->state->revamp_rules() == tuned_rules);
// ADR-0182 section 17 (schema 68): 256 wildlife in one command, then a tick of more than
// 256 lives, publish and recover exactly.
const auto [crowd_id, crowd_first] = enqueue(6, 256, 0, 0);
const std::vector<evo::server::CellularAdminCommand> crowd{
{static_cast<std::uint64_t>(crowd_id), Kind::spawn_wildlife, 256, crowd_first, {}}};
auto spawn_batch = admin_batch(crowd);
spawn_batch.header = {key.world, key.region, 1, head.head.commit, head.head.digest, 4, 5};
spawn_batch.ticks.front().lives = checked_value(wildlife_intents(*recovered->state, 5));
CHECK(recovered->state->advance_tick(spawn_batch.ticks.front().lives));
std::vector<evo::server::CellularAdminResult> crowd_results;
auto spawned = recovered->state->admin_candidate(crowd, &crowd_results);
CHECK(spawned && crowd_results.size() == 1 && crowd_results.front().applied &&
(*spawned)->lives().size() > 256);
auto spawn_publish = publish_cellular_batch(*runtime, **objects, *lease, head, spawn_batch,
**spawned, identity(13), build, 5s);
CHECK(spawn_publish);
head = spawn_publish->committed;
recovered = recover_cellular_checkpoint(*runtime, **objects, key, *lease, builds, 5s);
CHECK(recovered && recovered->state->snapshot() == (*spawned)->snapshot());
auto& crowded = recovered->state;
CellularBatch crowded_batch{
{key.world, key.region, 1, head.head.commit, head.head.digest, 5, 6}, {{}}};
crowded_batch.ticks.front().lives = checked_value(wildlife_intents(*crowded, 6));
CHECK(crowded_batch.ticks.front().lives.size() > 256);
CHECK(crowded->advance_tick(crowded_batch.ticks.front().lives));
const auto crowded_bytes = crowded->snapshot();
auto crowded_publish = publish_cellular_batch(*runtime, **objects, *lease, head, crowded_batch,
*crowded, identity(14), build, 5s);
CHECK(crowded_publish);
head = crowded_publish->committed;
recovered = recover_cellular_checkpoint(*runtime, **objects, key, *lease, builds, 5s);
CHECK(recovered && recovered->state->snapshot() == crowded_bytes &&
recovered->state->lives().size() > 256);
std::printf("crowded tick: %zu lives, %zu snapshot bytes (%zu at 33 lives)\n",
recovered->state->lives().size(), crowded_bytes.size(), applied_bytes.size());
CHECK(release_region_lease(*runtime, key, *lease, 5s)); CHECK(release_region_lease(*runtime, key, *lease, 5s));
std::puts("starting wildlife publication and replacement-owner replay passed"); std::puts("starting wildlife publication and replacement-owner replay passed");
} }
+1 -1
View File
@@ -893,7 +893,7 @@ void admin_commands_apply_and_replay() {
{7, Kind::remove_cell, 0, 424'242, {}}, // No such life: refused, nothing changes. {7, Kind::remove_cell, 0, 424'242, {}}, // No such life: refused, nothing changes.
}; };
for (const auto& bad : {CellularAdminCommand{8, Kind::add_pool, 0, 0, {}}, for (const auto& bad : {CellularAdminCommand{8, Kind::add_pool, 0, 0, {}},
CellularAdminCommand{8, Kind::spawn_wildlife, 65, 900'000, {}}, CellularAdminCommand{8, Kind::spawn_wildlife, 257, 900'000, {}},
CellularAdminCommand{8, Kind::add_bubbles, 0, 0, pool}, CellularAdminCommand{8, Kind::add_bubbles, 0, 0, pool},
CellularAdminCommand{0, Kind::add_pool, 0, 0, pool}}) CellularAdminCommand{0, Kind::add_pool, 0, 0, pool}})
require(!cellular_admin_command_valid(bad), "an invalid command shape was accepted"); require(!cellular_admin_command_valid(bad), "an invalid command shape was accepted");
+1 -1
View File
@@ -560,7 +560,7 @@ void admin_api_tests(const Realm& realm) {
{"/api/regions/1/commands", "/api/regions/1/commands?kind=explode", {"/api/regions/1/commands", "/api/regions/1/commands?kind=explode",
"/api/regions/1/commands?kind=add_pool", "/api/regions/1/commands?kind=add_pool&energy=x", "/api/regions/1/commands?kind=add_pool", "/api/regions/1/commands?kind=add_pool&energy=x",
"/api/regions/1/commands?kind=remove_cell&target=7&energy=5", "/api/regions/1/commands?kind=remove_cell&target=7&energy=5",
"/api/regions/1/commands?kind=spawn_wildlife&count=65", "/api/regions/1/commands?kind=spawn_wildlife&count=257",
"/api/regions/1/commands?kind=take_reserve&target=7", "/api/regions/1/commands?kind=take_reserve&target=7",
"/api/regions/1/commands?kind=remove_wildlife&target=7", "/api/regions/1/commands?kind=remove_wildlife&target=7",
"/api/regions/1/commands?kind=remove_wildlife&energy=1"}) "/api/regions/1/commands?kind=remove_wildlife&energy=1"})
+2 -1
View File
@@ -233,6 +233,7 @@ void upgrade_across_migration_and_barrier() {
" -v migration_sha_65=$(s 0065_admin_schedules.sql)" " -v migration_sha_65=$(s 0065_admin_schedules.sql)"
" -v migration_sha_66=$(s 0066_tuning_revisions.sql)" " -v migration_sha_66=$(s 0066_tuning_revisions.sql)"
" -v migration_sha_67=$(s 0067_admin_take_and_cull.sql)" " -v migration_sha_67=$(s 0067_admin_take_and_cull.sql)"
" -v migration_sha_68=$(s 0068_larger_region_ticks.sql)"
" -v runtime_role=evo_runtime_test -f migrations/apply.sql" " -v runtime_role=evo_runtime_test -f migrations/apply.sql"
" > /dev/null 2>&1") != 0); " > /dev/null 2>&1") != 0);
CHECK(history(*owner_db) == "1,2,3,4,5,6,7"); CHECK(history(*owner_db) == "1,2,3,4,5,6,7");
@@ -250,7 +251,7 @@ void upgrade_across_migration_and_barrier() {
"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,34,35,36,37,38,39,40,41,42,43,44,45,46," "25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,"
"47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67"); "47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68");
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 = "
+3
View File
@@ -74,6 +74,9 @@ awk '/^CREATE FUNCTION evolution\.(publish_cellular_checkpoint|publish_cellular_
# Schema 58 widened the canonical action input; restore schema 36's validator. # Schema 58 widened the canonical action input; restore schema 36's validator.
awk '/^CREATE OR REPLACE FUNCTION evolution\.valid_cellular_action_input\(/ {capture=1} capture {print} capture && /^END \$\$;/ {capture=0}' \ awk '/^CREATE OR REPLACE FUNCTION evolution\.valid_cellular_action_input\(/ {capture=1} capture {print} capture && /^END \$\$;/ {capture=0}' \
"$root/migrations/0036_cellular_v5_budding_bundle.sql" | sql > /dev/null "$root/migrations/0036_cellular_v5_budding_bundle.sql" | sql > /dev/null
# Schema 68 raised the trace checker's tick counts; restore schema 43's (renamed _v45 by 46).
awk '/^CREATE OR REPLACE FUNCTION evolution\.cellular_births\(/ {capture=1; sub(/cellular_births\(/,"cellular_births_v45(")} capture {print} capture && /^END \$\$;/ {capture=0}' \
"$root/migrations/0043_cellular_v9_foraging_bundle.sql" | sql > /dev/null
sql -v runtime_role="$EVO_PG_RUNTIME_ROLE" > /dev/null <<'SQL' sql -v runtime_role="$EVO_PG_RUNTIME_ROLE" > /dev/null <<'SQL'
DROP FUNCTION evolution.admin_tuning_text_v1(evolution.u64,bigint); DROP FUNCTION evolution.admin_tuning_text_v1(evolution.u64,bigint);
DROP FUNCTION evolution.admin_tuning_revisions_v1(evolution.u64); DROP FUNCTION evolution.admin_tuning_revisions_v1(evolution.u64);
+5 -5
View File
@@ -172,7 +172,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,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67 test "$(PGDATABASE=upgrade_path psql -XAtc "SELECT string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68
# 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%% *}"
@@ -193,7 +193,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")" = 67:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67 test "$(PGDATABASE=v3_commits psql -XAtc "SELECT count(*) || ':' || string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 68:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68
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.
@@ -247,7 +247,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,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67 test "$(PGDATABASE=v6_populated psql -XAtc "SELECT string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68
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
@@ -305,9 +305,9 @@ expect_audit_failure 'REVOKE EXECUTE ON FUNCTION evolution.load_world_cellular_m
expect_audit_failure 'GRANT EXECUTE ON FUNCTION evolution.fork_restored_history_v1(uuid) TO evo_runtime_test' 'REVOKE EXECUTE ON FUNCTION evolution.fork_restored_history_v1(uuid) FROM evo_runtime_test' expect_audit_failure 'GRANT EXECUTE ON FUNCTION evolution.fork_restored_history_v1(uuid) TO evo_runtime_test' 'REVOKE EXECUTE ON FUNCTION evolution.fork_restored_history_v1(uuid) FROM evo_runtime_test'
phase checksum-drift 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=68 WHERE version=67' psql -X -v ON_ERROR_STOP=1 -c 'UPDATE evolution.schema_migrations SET version=69 WHERE version=68'
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=67 WHERE version=68" psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET version=68 WHERE version=69"
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 -1
View File
@@ -150,6 +150,8 @@ digest_66="$(sha256sum "$root/migrations/0066_tuning_revisions.sql")"
digest_66="${digest_66%% *}" digest_66="${digest_66%% *}"
digest_67="$(sha256sum "$root/migrations/0067_admin_take_and_cull.sql")" digest_67="$(sha256sum "$root/migrations/0067_admin_take_and_cull.sql")"
digest_67="${digest_67%% *}" digest_67="${digest_67%% *}"
digest_68="$(sha256sum "$root/migrations/0068_larger_region_ticks.sql")"
digest_68="${digest_68%% *}"
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" \
@@ -201,6 +203,6 @@ psql -X --no-password --set=ON_ERROR_STOP=1 --set="migration_sha=$digest" \
--set="migration_sha_60=$digest_60" --set="migration_sha_61=$digest_61" \ --set="migration_sha_60=$digest_60" --set="migration_sha_61=$digest_61" \
--set="migration_sha_62=$digest_62" --set="migration_sha_63=$digest_63" \ --set="migration_sha_62=$digest_62" --set="migration_sha_63=$digest_63" \
--set="migration_sha_64=$digest_64" --set="migration_sha_65=$digest_65" \ --set="migration_sha_64=$digest_64" --set="migration_sha_65=$digest_65" \
--set="migration_sha_66=$digest_66" --set="migration_sha_67=$digest_67" "${admin[@]}" \ --set="migration_sha_66=$digest_66" --set="migration_sha_67=$digest_67" --set="migration_sha_68=$digest_68" "${admin[@]}" \
--set="runtime_role=$runtime_role" \ --set="runtime_role=$runtime_role" \
--file="$root/migrations/apply.sql" --file="$root/migrations/apply.sql"