Decline a mutation offer (ADR-0120 amendment, schema v40)
Foundation / checks (ecs) (push) Successful in 2m20s
Foundation / checks (deploy) (push) Successful in 4m1s
Foundation / checks (tsan) (push) Successful in 9m49s
Foundation / checks (client) (push) Successful in 19m23s
Foundation / checks (network) (push) Successful in 19m31s
Foundation / checks (checks) (push) Successful in 42m41s
Foundation / checks (postgres) (push) Successful in 45m36s
Foundation / postgres-tools (push) Successful in 28s
Foundation / server-image (push) Successful in 3m15s
Foundation / image (push) Successful in 3m18s

An offer the cell cannot afford stayed open, and only one offer is issued at a
time, so banked feeding credit never became a new offer. A v10 choice naming
operator 0 now declines the exact outstanding offer. It is reserved and published
like any choice: schema v40 accepts operator 0 in the reserved input and trace
selections and stores result 3, declined. The owner consumes the offer and
changes nothing else, and the client reports it as committed. Old traces never
carry operator 0, so their replay is unchanged. The Evolution panel gets a
"Decline this offer" button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-15 19:43:36 -04:00
co-authored by Claude Opus 5.5
parent d98d71e7c0
commit 1446d36d26
24 changed files with 396 additions and 46 deletions
+4 -3
View File
@@ -146,9 +146,10 @@ class CellularPlay {
if (kind == CellAction::mutation &&
(!offer_ || choice.life != life_ || choice.event != offer_->event_index ||
choice.offer_tick != offer_->offer_tick || tick <= choice.offer_tick ||
!std::ranges::any_of(offer_->candidates, [&](const auto& c) {
return c.operator_id == choice.operator_id;
})))
(choice.operator_id != 0 && // Operator 0 declines the offer (ADR-0120 amendment).
!std::ranges::any_of(offer_->candidates, [&](const auto& c) {
return c.operator_id == choice.operator_id;
}))))
return false;
const auto id = allocate_id();
if (id == 0)
+8
View File
@@ -831,6 +831,14 @@ void cell_evolution(const PanelView& v, PanelActions& a) {
ImGui::TextColored(amber, "MUTATION AVAILABLE");
disabled_wrapped("Useful feeding earned this choice. Each change trades a capability against "
"upkeep and body mass. The server checks your reserve when it commits.");
// ADR-0120 amendment: declining consumes the offer and changes nothing; more feeding
// (or credit already earned) brings the next one.
ImGui::BeginDisabled(!play->can_act() || !v.remote ||
v.remote->server_tick <= offer->offer_tick);
if (ImGui::Button("Decline this offer", {-1, px(28)}))
a.mutation = MutationChoice{offer->life_identity, offer->event_index, offer->offer_tick, 0};
ImGui::EndDisabled();
disabled_wrapped("Declining keeps your genome; earned feeding brings the next offer.");
constexpr std::array capabilities{"Energy conversion", "Membrane", "Movement",
"Ingestion", "Reproduction", "Target size",
"Thermal tolerance"};
@@ -12,7 +12,7 @@ spec:
env:
- {name: REGION_SESSION, value: "dev"}
- {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"}
- {name: REGION_SESSION_WINDOW, value: "dev-20261015T231128-88134:1792116688"}
- {name: REGION_SESSION_WINDOW, value: "dev-20261015T234335-16592:1792118615"}
- {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"}
ports:
# QUIC (ADR-0090): UDP only; nothing listens on TCP 7400.
@@ -78,3 +78,22 @@ test exact retry, stale identity/context, credit carry, no opening-reserve
credit, checkpoint restore and `NDEBUG`. The durable mutation selection and its
genome/archive/resource publication remain a later segment. No ranked score,
class tree, NPC mutation or automatic reroll is introduced.
## Amendment (2026-10-15): declining an offer
Playtesting showed an offer whose candidates the cell cannot afford stays open
indefinitely: an unaffordable choice is refused without consuming the offer, and only
one offer is issued at a time, so banked credit could never become a new offer.
- A v10 mutation choice (type 25) naming **operator 0** declines the exact
outstanding offer. It is admitted, reserved and published like any choice (schema
v40 accepts operator 0 in the reserved input and the trace selection). Its reserved
successor identity stays unused, which the allocator permits (gaps, never reuse).
- At its tick the owner consumes the offer and changes nothing else: no genome
revision, no inventory change. The published result is **3, declined**, reported to
the client as `committed`.
- As before, a declined offer earns no replacement. A later offer needs feeding
credit, but credit already banked while the offer was open can produce the next
offer immediately.
- Older traces never contain operator 0 (the decoders refused it), so their replay is
unchanged and no rules version is needed.
+31
View File
@@ -7690,3 +7690,34 @@ trip with and without tick effects, v9 refusal, and refusal of a cleared view wi
a cost. Executed locally: those unit tests, the WSL PostgreSQL suite, clang-tidy-19
on the changed sources, WSL client 14/14 with clang-tidy plus the Xvfb check, MSVC
`client-package` 18/18, and clang-format 19.
## 2026-10-15 — declining a mutation offer, schema v40 (CI pending)
ADR-0120 amendment: a v10 mutation choice with operator 0 declines the exact
outstanding offer. It is reserved and published like a choice, and schema v40 lets
the reserved input and trace selections carry operator 0 and stores result 3,
declined. The owner consumes the offer without a genome or inventory change; its
reserved successor identity stays unused. Clients get `committed`, and the
Evolution panel has a "Decline this offer" button, enabled even when the reserve
cannot pay.
Tests:
- owner: a trace and action block with a decline encode, decode, match and replay;
the offer is consumed and the genome, archive and totals are unchanged; an
operator that was not offered is still refused;
- protocol: type 25 with operator 0 round-trips;
- PostgreSQL: the reservation store accepts operator 0 (refused here only by the
pending choice) and refuses a zero offer tick; the host test feeds until a new
offer, declines it, publishes result 3, consumes the offer and reports
`committed`;
- client panels: an unaffordable candidate cannot be chosen, and Decline sends
operator 0.
Executed locally:
- WSL `m97-postgres` build, 79/79 CTests;
- `postgres-check.sh --full`, including the v40 upgrade, history and checksum-drift
drills;
- clang-tidy-19 on the changed sources;
- WSL client 14/14 with clang-tidy, plus the Xvfb check;
- MSVC `client-package` 18/18;
- clang-format 19.
@@ -101,7 +101,13 @@ struct CellularMutationSelection {
std::uint16_t operator_id{};
auto operator<=>(const CellularMutationSelection&) const = default;
};
enum class CellularMutationResult : std::uint8_t { applied, life_died, insufficient_funding };
// declined (ADR-0120 amendment): operator 0 consumed the offer without changing the genome.
enum class CellularMutationResult : std::uint8_t {
applied,
life_died,
insufficient_funding,
declined
};
struct CellularMutationExecution {
std::uint64_t life_id{}, successor_id{};
CellularMutationResult result{};
@@ -0,0 +1,133 @@
-- ADR-0120 amendment: a player may decline an outstanding mutation offer. A decline is an
-- ordinary reserved choice whose operator id is 0: it reserves a successor identity like
-- any choice (that identity simply stays unused), names the exact offer, and publishes
-- with result 3 (declined). The offer is consumed and the genome is unchanged.
-- Reserved inputs and trace selections may name operator 0.
CREATE OR REPLACE FUNCTION evolution.valid_cellular_mutation_input(p_input bytea)
RETURNS boolean LANGUAGE plpgsql IMMUTABLE STRICT
SET search_path = pg_catalog, pg_temp AS $$
BEGIN
IF octet_length(p_input) <> 34 THEN
RETURN false;
END IF;
IF evolution.manifest_uint(p_input, 0, 8) = 0
OR evolution.manifest_uint(p_input, 8, 8) = 0
OR evolution.manifest_uint(p_input, 16, 8) = 0
OR evolution.manifest_uint(p_input, 24, 8) = 0
OR evolution.manifest_uint(p_input, 0, 8) <= evolution.manifest_uint(p_input, 24, 8) THEN
RETURN false;
END IF;
RETURN true;
END $$;
CREATE OR REPLACE FUNCTION evolution.cellular_mutation_selections(p_trace bytea, p_manifest bytea)
RETURNS TABLE(tick evolution.u64, life_id evolution.u64, event_index evolution.u64,
offer_tick evolution.u64, successor_identity evolution.u64, operator_id integer)
LANGUAGE plpgsql IMMUTABLE SECURITY INVOKER SET search_path = pg_catalog, pg_temp AS $$
DECLARE
c evolution.checkpoint_manifest := evolution.parse_checkpoint_manifest(p_manifest);
ticks integer;
off integer := 112;
intent_count integer;
birth_count integer;
mutation_count integer;
previous_life numeric;
BEGIN
PERFORM * FROM evolution.cellular_births(p_trace, p_manifest); -- Binding and structure.
IF evolution.manifest_uint(p_trace, 8, 4) <> 3 THEN
RETURN; -- Format 2 carries no selections.
END IF;
ticks := (c.end_tick - c.begin_tick)::integer;
FOR tick_index IN 0 .. ticks - 1 LOOP
intent_count := evolution.manifest_uint(p_trace, off, 4)::integer;
birth_count := evolution.manifest_uint(p_trace, off + 4, 4)::integer;
mutation_count := evolution.manifest_uint(p_trace, off + 8, 4)::integer;
off := off + 16 + intent_count * 24 + birth_count * 40;
previous_life := 0;
FOR mutation_index IN 0 .. mutation_count - 1 LOOP
tick := c.begin_tick + tick_index + 1;
life_id := evolution.manifest_uint(p_trace, off, 8);
event_index := evolution.manifest_uint(p_trace, off + 8, 8);
offer_tick := evolution.manifest_uint(p_trace, off + 16, 8);
successor_identity := evolution.manifest_uint(p_trace, off + 24, 8);
operator_id := evolution.manifest_uint(p_trace, off + 32, 2)::integer;
IF life_id = 0 OR life_id <= previous_life OR event_index = 0 OR offer_tick = 0
OR offer_tick >= tick OR successor_identity = 0
OR substring(p_trace FROM off + 35 FOR 6) <> '\x000000000000' THEN
RAISE EXCEPTION 'invalid cellular mutation selection' USING ERRCODE = '22023';
END IF;
previous_life := life_id;
off := off + 40;
RETURN NEXT;
END LOOP;
END LOOP;
END $$;
-- Results 0 applied, 1 life died, 2 insufficient funding, 3 declined.
CREATE OR REPLACE FUNCTION evolution.check_cellular_mutation_block(p_manifest bytea, p_trace bytea,
p_mutations bytea, p_results bytea)
RETURNS integer LANGUAGE plpgsql STABLE SECURITY INVOKER
SET search_path = pg_catalog, pg_temp AS $$
DECLARE
c evolution.checkpoint_manifest := evolution.parse_checkpoint_manifest(p_manifest);
n integer;
account uuid;
account_bytes bytea;
action numeric;
tick numeric;
input bytea;
previous_tick numeric := -1;
previous_account bytea := ''::bytea;
previous_action numeric := -1;
r evolution.cellular_mutation_reservations%ROWTYPE;
BEGIN
IF p_mutations IS NULL OR p_results IS NULL OR octet_length(p_mutations) = 0
OR octet_length(p_mutations) % 64 <> 0 OR octet_length(p_mutations) / 64 > 1024
OR octet_length(p_results) <> octet_length(p_mutations) / 64 THEN
RAISE EXCEPTION 'invalid cellular mutation block' USING ERRCODE = '22023';
END IF;
n := octet_length(p_mutations) / 64;
IF (SELECT count(*) FROM evolution.cellular_mutation_selections(p_trace, p_manifest)) <> n THEN
RAISE EXCEPTION 'cellular mutation block does not cover the trace' USING ERRCODE = '22023';
END IF;
FOR i IN 0 .. n - 1 LOOP
account_bytes := substring(p_mutations FROM 64 * i + 1 FOR 16);
account := encode(account_bytes, 'hex')::uuid;
action := evolution.manifest_uint(p_mutations, 64 * i + 16, 8);
input := substring(p_mutations FROM 64 * i + 25 FOR 34);
tick := evolution.manifest_uint(input, 0, 8);
IF account = '00000000-0000-0000-0000-000000000000' OR action = 0
OR NOT evolution.valid_cellular_mutation_input(input)
OR substring(p_mutations FROM 64 * i + 59 FOR 6) <> '\x000000000000'
OR get_byte(p_results, i) > 3
OR tick <= c.begin_tick OR tick > c.end_tick
OR (tick, account_bytes, action) <= (previous_tick, previous_account, previous_action) THEN
RAISE EXCEPTION 'invalid cellular mutation record' USING ERRCODE = '22023';
END IF;
previous_tick := tick;
previous_account := account_bytes;
previous_action := action;
SELECT * INTO r FROM evolution.cellular_mutation_reservations x
WHERE x.world_id = c.world_id AND x.account_id = account AND x.action_id = action;
IF NOT FOUND OR r.region_id <> c.region_id OR r.input_bytes <> input
OR r.target_tick <> evolution.manifest_uint(input, 0, 8) THEN
RAISE EXCEPTION 'cellular mutation reservation conflicts' USING ERRCODE = 'EVL16';
END IF;
IF NOT EXISTS (SELECT 1 FROM evolution.cellular_mutation_selections(p_trace, p_manifest) s
WHERE s.tick = r.target_tick AND s.successor_identity = r.successor_identity
AND s.life_id = evolution.manifest_uint(input, 8, 8)
AND s.event_index = evolution.manifest_uint(input, 16, 8)
AND s.offer_tick = evolution.manifest_uint(input, 24, 8)
AND s.operator_id = evolution.manifest_uint(input, 32, 2)) THEN
RAISE EXCEPTION 'cellular mutation differs from its trace' USING ERRCODE = '22023';
END IF;
END LOOP;
RETURN n;
END $$;
ALTER TABLE evolution.cellular_mutation_action_publications
DROP CONSTRAINT cellular_mutation_action_publications_result_check,
ADD CONSTRAINT cellular_mutation_action_publications_result_check CHECK (result BETWEEN 0 AND 3);
INSERT INTO evolution.schema_migrations(version, sha256) VALUES (40, :'migration_sha_40');
+25 -4
View File
@@ -115,6 +115,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
SELECT :'history_v36' || ',37:' || :'migration_sha_37' AS history_v37 \gset
SELECT :'history_v37' || ',38:' || :'migration_sha_38' AS history_v38 \gset
SELECT :'history_v38' || ',39:' || :'migration_sha_39' AS history_v39 \gset
SELECT :'history_v39' || ',40:' || :'migration_sha_40' AS history_v40 \gset
SELECT :'history' = :'history_v22' AS at_v22,
:'history' = :'history_v23' AS at_v23,
:'history' = :'history_v24' AS at_v24,
@@ -132,8 +133,10 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
:'history' = :'history_v36' AS at_v36,
:'history' = :'history_v37' AS at_v37,
:'history' = :'history_v38' AS at_v38,
:'history' = :'history_v39' AS at_v39 \gset
\if :at_v39
:'history' = :'history_v39' AS at_v39,
:'history' = :'history_v40' AS at_v40 \gset
\if :at_v40
\elif :at_v39
\elif :at_v38
\elif :at_v37
\elif :at_v36
@@ -505,7 +508,8 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
coalesce(max(version), 0) = 36 AS at_v36,
coalesce(max(version), 0) = 37 AS at_v37,
coalesce(max(version), 0) = 38 AS at_v38,
coalesce(max(version), 0) = 39 AS at_v39
coalesce(max(version), 0) = 39 AS at_v39,
coalesce(max(version), 0) = 40 AS at_v40
FROM evolution.schema_migrations \gset
\if :at_v24
\ir 0025_cellular_v2_bundle.sql
@@ -523,6 +527,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\ir 0037_cellular_life_endings.sql
\ir 0038_cellular_v6_presence_bundle.sql
\ir 0039_account_identities.sql
\ir 0040_cellular_mutation_decline.sql
\elif :at_v25
\ir 0026_cellular_profile_migration.sql
\ir 0027_cellular_v3_migration.sql
@@ -538,6 +543,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\ir 0037_cellular_life_endings.sql
\ir 0038_cellular_v6_presence_bundle.sql
\ir 0039_account_identities.sql
\ir 0040_cellular_mutation_decline.sql
\elif :at_v26
\ir 0027_cellular_v3_migration.sql
\ir 0028_cellular_v3_trace_bounds.sql
@@ -552,6 +558,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\ir 0037_cellular_life_endings.sql
\ir 0038_cellular_v6_presence_bundle.sql
\ir 0039_account_identities.sql
\ir 0040_cellular_mutation_decline.sql
\elif :at_v27
\ir 0028_cellular_v3_trace_bounds.sql
\ir 0029_cellular_mutation_reservations.sql
@@ -565,6 +572,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\ir 0037_cellular_life_endings.sql
\ir 0038_cellular_v6_presence_bundle.sql
\ir 0039_account_identities.sql
\ir 0040_cellular_mutation_decline.sql
\elif :at_v28
\ir 0029_cellular_mutation_reservations.sql
\ir 0030_cellular_birth_publication_binding.sql
@@ -577,6 +585,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\ir 0037_cellular_life_endings.sql
\ir 0038_cellular_v6_presence_bundle.sql
\ir 0039_account_identities.sql
\ir 0040_cellular_mutation_decline.sql
\elif :at_v29
\ir 0030_cellular_birth_publication_binding.sql
\ir 0031_fix_cellular_birth_publication_record.sql
@@ -588,6 +597,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\ir 0037_cellular_life_endings.sql
\ir 0038_cellular_v6_presence_bundle.sql
\ir 0039_account_identities.sql
\ir 0040_cellular_mutation_decline.sql
\elif :at_v30
\ir 0031_fix_cellular_birth_publication_record.sql
\ir 0032_fix_cellular_v3_manifest_normalization.sql
@@ -598,6 +608,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\ir 0037_cellular_life_endings.sql
\ir 0038_cellular_v6_presence_bundle.sql
\ir 0039_account_identities.sql
\ir 0040_cellular_mutation_decline.sql
\elif :at_v31
\ir 0032_fix_cellular_v3_manifest_normalization.sql
\ir 0033_fix_cellular_action_tick_offset.sql
@@ -607,6 +618,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\ir 0037_cellular_life_endings.sql
\ir 0038_cellular_v6_presence_bundle.sql
\ir 0039_account_identities.sql
\ir 0040_cellular_mutation_decline.sql
\elif :at_v32
\ir 0033_fix_cellular_action_tick_offset.sql
\ir 0034_cellular_v4_engulf_bundle.sql
@@ -615,6 +627,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\ir 0037_cellular_life_endings.sql
\ir 0038_cellular_v6_presence_bundle.sql
\ir 0039_account_identities.sql
\ir 0040_cellular_mutation_decline.sql
\elif :at_v33
\ir 0034_cellular_v4_engulf_bundle.sql
\ir 0035_cellular_mutation_publication.sql
@@ -622,29 +635,37 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
\ir 0037_cellular_life_endings.sql
\ir 0038_cellular_v6_presence_bundle.sql
\ir 0039_account_identities.sql
\ir 0040_cellular_mutation_decline.sql
\elif :at_v34
\ir 0035_cellular_mutation_publication.sql
\ir 0036_cellular_v5_budding_bundle.sql
\ir 0037_cellular_life_endings.sql
\ir 0038_cellular_v6_presence_bundle.sql
\ir 0039_account_identities.sql
\ir 0040_cellular_mutation_decline.sql
\elif :at_v35
\ir 0036_cellular_v5_budding_bundle.sql
\ir 0037_cellular_life_endings.sql
\ir 0038_cellular_v6_presence_bundle.sql
\ir 0039_account_identities.sql
\ir 0040_cellular_mutation_decline.sql
\elif :at_v36
\ir 0037_cellular_life_endings.sql
\ir 0038_cellular_v6_presence_bundle.sql
\ir 0039_account_identities.sql
\ir 0040_cellular_mutation_decline.sql
\elif :at_v37
\ir 0038_cellular_v6_presence_bundle.sql
\ir 0039_account_identities.sql
\ir 0040_cellular_mutation_decline.sql
\elif :at_v38
\ir 0039_account_identities.sql
\ir 0040_cellular_mutation_decline.sql
\elif :at_v39
\ir 0040_cellular_mutation_decline.sql
\elif :at_v40
\else
\echo 'Unknown or changed migration history after v39'
\echo 'Unknown or changed migration history after v40'
DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$;
\endif
-- Effective-privilege audit on every run, including no-ops (ADR-0060). Attributes
@@ -20,10 +20,10 @@ payload is exactly 64 bytes, little-endian:
| 32 | 8 | stable life identity, nonzero |
| 40 | 8 | earned offer event index, nonzero |
| 48 | 8 | exact offer tick, nonzero and before the intended tick |
| 56 | 2 | offered operator id, nonzero |
| 56 | 2 | offered operator id; 0 declines the offer (ADR-0120 amendment) |
| 58 | 6 | reserved, all zero |
The decoder rejects all zero identities, an offer tick at or after the target
The decoder rejects zero identities (operator 0 is a decline, not an identity), an offer tick at or after the target
tick, reserved bytes, wrong lengths, and use under versions 1–9. When server
admission is enabled, it must bind the action to the authenticated account,
verify the exact current offer and operator, reserve the successor identity
@@ -37,8 +37,10 @@ choice with the tick after its committed head; the receipt's `tick` names it.
Receipt statuses: `admitted`, `not_ready`, `too_many_unresolved` (another
choice of the account is waiting), `invalid_action` (not the exact offer and
candidate, or a changed reuse of the action id), and `duplicate` with the
final outcome. The `ActionOutcome` is `committed` when applied and
final outcome. The `ActionOutcome` is `committed` when applied or declined and
`committed_no_effect` for a durable refusal (life died, insufficient funding).
Operator 0 (2026-10-15) declines the exact current offer: it consumes the offer
without changing the genome, and needs schema v40.
## Type 26 (server to owner)
+1 -1
View File
@@ -642,7 +642,7 @@ std::expected<SessionMessage, SessionCodecError> decode_session(std::span<const
m.offer_tick = get(payload, 48, 8);
m.operator_id = static_cast<std::uint16_t>(get(payload, 56, 2));
if (!m.session || !m.epoch || !m.action_id || !m.tick || !m.life_identity ||
!m.event_index || !m.offer_tick || m.offer_tick >= m.tick || !m.operator_id ||
!m.event_index || !m.offer_tick || m.offer_tick >= m.tick || // operator 0 declines
std::ranges::any_of(payload.subspan(58, 6),
[](std::uint8_t value) { return value != 0; }))
return std::unexpected(SessionCodecError::invalid_value);
@@ -93,7 +93,7 @@ bool prepared_mutations_are_canonical(const CellularPreparedCommit& prepared,
const auto decoded = server::decode_cellular_mutation_action_block(
prepared.mutations, manifest.begin_tick, manifest.end_tick);
if (!decoded || decoded->size() != selections || prepared.results.size() != selections ||
std::ranges::any_of(prepared.results, [](std::uint8_t result) { return result > 2; }))
std::ranges::any_of(prepared.results, [](std::uint8_t result) { return result > 3; }))
return false;
const auto encoded = server::encode_cellular_mutation_action_block(
*decoded, manifest.begin_tick, manifest.end_tick);
+3 -3
View File
@@ -606,7 +606,7 @@ load_cellular_mutation_publications(Postgres& db, RegionKey key, const LeaseGran
const auto action = parse_integer<std::uint64_t>(row[1]);
const auto input = unhex<34>(row[2].value_or(std::string{}));
const auto result = parse_integer<std::uint32_t>(row[3]);
if (!account || !action || *action == 0 || !input || !result || *result > 2)
if (!account || !action || *action == 0 || !input || !result || *result > 3)
return std::unexpected{malformed(false)};
publications.push_back({*account, *action, *input, static_cast<std::uint8_t>(*result)});
}
@@ -1349,7 +1349,7 @@ std::expected<CellularMutationReservation, LifeReservationFailure> reserve_cellu
const auto target_tick = little(input, 0, 8);
if (account == Uuid{} || action_id == 0 || generation == 0 || target_tick == 0 ||
little(input, 8, 8) == 0 || little(input, 16, 8) == 0 || little(input, 24, 8) == 0 ||
target_tick <= little(input, 24, 8) || little(input, 32, 2) == 0)
target_tick <= little(input, 24, 8)) // Operator 0 declines (ADR-0120 amendment).
return std::unexpected{LifeReservationFailure{LifeReservationError::invalid, {}}};
const auto base = control_parameters(key, lease, account, generation);
const std::array<std::string, 9> p{base[0],
@@ -1435,7 +1435,7 @@ load_pending_cellular_mutations(Postgres& db, RegionKey key, const LeaseGrant& l
*generation == 0 || !target_tick || *target_tick == 0 || !successor ||
*successor == 0 || !input || little(*input, 0, 8) != *target_tick ||
little(*input, 8, 8) == 0 || little(*input, 16, 8) == 0 || little(*input, 24, 8) == 0 ||
*target_tick <= little(*input, 24, 8) || little(*input, 32, 2) == 0)
*target_tick <= little(*input, 24, 8))
return std::unexpected{LifeReservationFailure{LifeReservationError::store, {}}};
out.push_back(
{*account, *action, key.region, *generation, *target_tick, *successor, *input});
+7 -4
View File
@@ -97,7 +97,8 @@ network::AdmitStatus admit_status(CellularMutationAdmission admission) noexcept
network::ActionOutcome action_outcome(const FinalCellularMutation& mutation) noexcept {
return {mutation.action_id,
mutation.result == CellularMutationResult::applied
mutation.result == CellularMutationResult::applied ||
mutation.result == CellularMutationResult::declined
? network::ActionResult::committed
: network::ActionResult::committed_no_effect,
mutation.tick, mutation.commit_sequence};
@@ -501,9 +502,11 @@ CellularRegionHost::select_mutation(const persistence::Uuid& account, std::uint6
life->presence != CellularPresence::active) // ADR-0128: only an active life chooses.
return {invalid, 0, {}};
const auto& offer = life->mutation.offer;
if (!offer || !std::ranges::any_of(offer->candidates, [&](const auto& candidate) {
return candidate.operator_id == input.operator_id;
}))
// Operator 0 declines the exact offer (ADR-0120 amendment); otherwise it must be offered.
if (!offer || (input.operator_id != 0 &&
!std::ranges::any_of(offer->candidates, [&](const auto& candidate) {
return candidate.operator_id == input.operator_id;
})))
return {invalid, 0, {}};
const auto grant = authority_.grant();
if (!grant)
+8 -7
View File
@@ -67,7 +67,7 @@ bool valid_ticks(std::span<const CellularTickIntents> ticks) {
for (std::size_t i = 0; i < tick.mutations.size(); ++i) {
const auto& mutation = tick.mutations[i];
if (mutation.life_id == 0 || mutation.event_index == 0 || mutation.offer_tick == 0 ||
mutation.successor_id == 0 || mutation.operator_id == 0 ||
mutation.successor_id == 0 || // Operator 0 declines (ADR-0120 amendment).
(i > 0 && tick.mutations[i - 1].life_id >= mutation.life_id) ||
!identities.insert(mutation.successor_id).second)
return false;
@@ -127,7 +127,7 @@ bool valid_mutation_actions(std::span<const CellularMutationActionRecord> action
const auto& input = action.input;
if (all_zero(action.account) || action.action_id == 0 || action.tick <= begin_tick ||
action.tick > end_tick || input.life_id == 0 || input.event_index == 0 ||
input.offer_tick == 0 || input.offer_tick > begin_tick || input.operator_id == 0 ||
input.offer_tick == 0 || input.offer_tick > begin_tick ||
(i != 0 && !mutation_action_less(actions[i - 1], action)))
return false;
for (std::size_t j = 0; j < i; ++j)
@@ -350,7 +350,7 @@ decode_cellular_batch(std::span<const std::uint8_t> bytes) {
mutation.operator_id = static_cast<std::uint16_t>(get(record, 32, 2));
if (!all_zero(record.subspan(34, 6)) || mutation.life_id == 0 ||
mutation.event_index == 0 || mutation.offer_tick == 0 ||
mutation.successor_id == 0 || mutation.operator_id == 0 ||
mutation.successor_id == 0 ||
(!step.mutations.empty() && step.mutations.back().life_id >= mutation.life_id))
return std::unexpected{CellularBatchError::format};
step.mutations.push_back(mutation);
@@ -398,7 +398,7 @@ decode_cellular_mutation_input(const std::array<std::uint8_t, 16>& account, std:
action.input.operator_id = static_cast<std::uint16_t>(get(input, 32, 2));
if (action_id == 0 || action.tick == 0 || action.input.life_id == 0 ||
action.input.event_index == 0 || action.input.offer_tick == 0 ||
action.input.offer_tick >= action.tick || action.input.operator_id == 0)
action.input.offer_tick >= action.tick)
return std::nullopt;
return action;
}
@@ -616,9 +616,10 @@ match_cellular_mutation_actions_to_trace(const CellularLives& predecessor,
life->mutation.event_index != action.input.event_index ||
life->mutation.offer_tick != action.input.offer_tick ||
life->identity.life != action.input.life_id || offer.parent != life->identity.genome ||
!std::ranges::any_of(offer.candidates, [&](const auto& candidate) {
return candidate.operator_id == action.input.operator_id;
}))
(action.input.operator_id != 0 &&
!std::ranges::any_of(offer.candidates, [&](const auto& candidate) {
return candidate.operator_id == action.input.operator_id;
})))
return std::unexpected{CellularActionBlockError::mismatch};
}
return {};
+15 -5
View File
@@ -1247,7 +1247,7 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
for (std::size_t i = 0; i < selections.size(); ++i) {
const auto& selection = selections[i];
if (selection.life_id == 0 || selection.event_index == 0 || selection.offer_tick == 0 ||
selection.operator_id == 0 || selection.successor_id == 0 ||
selection.successor_id == 0 || // Operator 0 declines (ADR-0120 amendment).
(i != 0 && selections[i - 1].life_id >= selection.life_id))
return std::unexpected{CellularLivesError::invalid_intents};
const auto life = std::ranges::lower_bound(
@@ -1262,10 +1262,11 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
const auto offer = life->mutation.offer.value_or(biology::MutationOffer{});
if (offer.parent != life->identity.genome ||
offer.context.event_index != selection.event_index ||
!std::ranges::any_of(offer.candidates,
[&](const auto& candidate) {
return candidate.operator_id == selection.operator_id;
}) ||
(selection.operator_id != 0 && !std::ranges::any_of(offer.candidates,
[&](const auto& candidate) {
return candidate.operator_id ==
selection.operator_id;
})) ||
state_->archive.find(selection.successor_id))
return std::unexpected{CellularLivesError::mutation};
for (std::size_t j = 0; j < i; ++j)
@@ -1397,6 +1398,15 @@ CellularLives::advance_tick_with_mutations(std::span<const CellularLifeIntent> i
const auto parent = next_archive.find(found->identity.genome);
if (!parent || !found->mutation.offer.has_value())
return std::unexpected{CellularLivesError::mutation};
if (selection.operator_id == 0) {
// ADR-0120 amendment: a decline consumes the offer and changes nothing else; its
// reserved successor identity stays unused. Banked credit may earn the next offer.
found->mutation.offer.reset();
found->mutation.offer_tick = 0;
mutation_results.push_back(
{selection.life_id, selection.successor_id, CellularMutationResult::declined});
continue;
}
const auto offer = found->mutation.offer.value_or(biology::MutationOffer{});
auto transition =
biology::fund_mutation(*parent, offer.context, offer, selection.operator_id,
@@ -104,7 +104,7 @@ prepare_cellular_session_tick(const CellularLives& state, std::uint64_t tick,
reservation.region != state.region() || reservation.generation == 0 ||
reservation.successor_identity == 0 || target_tick != tick ||
reservation.target_tick != tick || life_id == 0 || event_index == 0 ||
offer_tick == 0 || offer_tick >= tick || operator_id == 0)
offer_tick == 0 || offer_tick >= tick)
return std::unexpected{CellularSessionBatchError::mutation};
const auto life =
std::ranges::find(state.lives(), reservation.account, &CellularOwnedLife::account);
@@ -112,9 +112,10 @@ prepare_cellular_session_tick(const CellularLives& state, std::uint64_t tick,
life->mutation.event_index != event_index || life->mutation.offer_tick != offer_tick)
return std::unexpected{CellularSessionBatchError::mutation};
const auto& offer = life->mutation.offer;
if (!offer || !std::ranges::any_of(offer->candidates, [&](const auto& candidate) {
return candidate.operator_id == operator_id;
}))
if (!offer || (operator_id != 0 && // Operator 0 declines the offer.
!std::ranges::any_of(offer->candidates, [&](const auto& candidate) {
return candidate.operator_id == operator_id;
})))
return std::unexpected{CellularSessionBatchError::mutation};
if (std::ranges::any_of(prepared.intents.mutations,
+6
View File
@@ -281,6 +281,12 @@ void v10_mutation_choice_is_a_strict_reliable_action() {
malformed = bytes;
malformed[4] = static_cast<std::uint8_t>(session_protocol_v9);
CHECK(!decode_session(malformed)); // v1-v9 do not know this message.
// ADR-0120 amendment: operator 0 declines the named offer; it is a valid choice.
const CellularMutationAction decline{17, 23, 30, 53, 37, 41, 43, 0};
const auto decline_bytes = encode_session(SessionMessage{decline});
CHECK(!decline_bytes.empty() && decline_bytes[session_header_bytes + 56] == 0 &&
decline_bytes[session_header_bytes + 57] == 0);
CHECK(std::get<CellularMutationAction>(*decode_session(decline_bytes)) == decline);
const ActionOutcome outcome{29, ActionResult::committed, 31, 41};
const auto outcome_bytes = encode_session(SessionMessage{outcome}, session_protocol_v10);
+37
View File
@@ -355,6 +355,43 @@ void retained_feeding_earns_a_persistent_mutation_offer() {
*decoded_action_block));
const auto replayed_mutation = replay_cellular_batch(**revision_owner, *decoded_mutation);
CHECK(replayed_mutation && (*replayed_mutation)->tick() == mutation_batch.header.end_tick);
// ADR-0120 amendment: operator 0 declines the same offer. The trace, its action block and
// replay accept it; the offer is consumed, the genome and inventories are unchanged,
// and the reserved successor identity stays unused.
{
auto declined = selection;
declined.operator_id = 0;
auto decline_batch = mutation_batch;
decline_batch.ticks[0].mutations[0] = declined;
const auto decline_bytes = encode_cellular_batch(decline_batch);
CHECK(decline_bytes);
const auto decoded_decline = decode_cellular_batch(*decline_bytes);
CHECK(decoded_decline && *decoded_decline == decline_batch);
const std::array decline_actions{
CellularMutationActionRecord{(*revision_owner)->lives()[0].account,
45,
decline_batch.header.end_tick,
{life_id, declined.event_index, declined.offer_tick, 0}}};
const auto decline_block = encode_cellular_mutation_action_block(
decline_actions, decline_batch.header.begin_tick, decline_batch.header.end_tick);
CHECK(decline_block);
const auto decoded_block = decode_cellular_mutation_action_block(
*decline_block, decline_batch.header.begin_tick, decline_batch.header.end_tick);
CHECK(decoded_block && match_cellular_mutation_actions_to_trace(
**revision_owner, *decoded_decline, *decoded_block));
const auto replayed_decline = replay_cellular_batch(**revision_owner, *decoded_decline);
CHECK(replayed_decline);
const auto& after = **replayed_decline;
CHECK(!after.lives().empty() && !after.lives()[0].mutation.offer &&
after.lives()[0].mutation.offer_tick == 0 &&
after.lives()[0].identity.genome == (*revision_owner)->lives()[0].identity.genome &&
after.archive().revisions().empty() && !after.archive().find(declined.successor_id) &&
after.current_total() == after.opening_total());
// An operator that was not offered is still refused.
auto unknown = decline_batch;
unknown.ticks[0].mutations[0].operator_id = 0xFFFF;
CHECK(!replay_cellular_batch(**revision_owner, unknown));
}
const std::array idle_next{CellularLifeIntent{life_id, {}}};
const std::array selections{selection};
const auto direct_mutation =
+52
View File
@@ -653,6 +653,58 @@ void cellular_host_admits_mutation_choices() {
CHECK(final_repeat.status == CellularMutationAdmission::final && final_repeat.outcome &&
*final_repeat.outcome == finalized.front());
CHECK(admit_status(final_repeat.status) == evo::network::AdmitStatus::duplicate);
// ADR-0120 amendment (schema v40): feed until the next offer, then decline it. The
// decline reserves and publishes like a choice, with result 3; the offer is consumed
// and the genome is unchanged.
for (int round = 0; round < 8 && !host->state()->lives().front().mutation.offer; ++round) {
CellularBatch feeding;
feeding.header = header(*host, 64);
CellularStepIntent feed{};
feed.intake_target = CellularPatchAddress{0, 0};
for (int tick = 0; tick < 64; ++tick)
feeding.ticks.push_back({{{life_id, feed}}, {}, {}});
CHECK(host->publish(feeding));
}
// A live session renews its control every 5 s; this long test lets it lapse, so it
// claims control again with a newer grant serial, as a reconnecting client would.
CHECK(host->step().ready); // Renews the region lease after the feeding publications.
const auto reclaimed = claim_account_control(*runtime, key, checked_value(host->authority()),
account, 2, 2, 60'000ms, 5s);
CHECK(reclaimed);
const auto decline_generation = checked_value(reclaimed).generation;
const auto& offered = host->state()->lives().front();
CHECK(offered.identity.life == life_id && offered.mutation.offer.has_value());
const auto genome_before = offered.identity.genome;
const CellularMutationActionInput decline{life_id, offered.mutation.event_index,
offered.mutation.offer_tick, 0};
const auto decline_tick = host->state()->tick() + 1;
const auto declined = host->select_mutation(account, decline_generation, 33, decline);
CHECK(declined.status == CellularMutationAdmission::admitted && declined.tick == decline_tick &&
host->queued_mutations().size() == 1);
const auto decline_reservation = host->queued_mutations().front();
CellularBatch decline_batch;
decline_batch.header = header(*host, 1);
decline_batch.ticks.push_back({{{life_id, {}}},
{},
{{life_id, decline.event_index, decline.offer_tick,
decline_reservation.successor_identity, 0}}});
const std::array decline_records{
CellularMutationActionRecord{account, 33, decline_tick, decline}};
const auto decline_published = host->publish(decline_batch, {}, decline_records);
CHECK(decline_published && decline_published->mutation_results.size() == 1 &&
decline_published->mutation_results.front() == CellularMutationResult::declined);
const auto& after_decline = host->state()->lives().front();
CHECK(!after_decline.mutation.offer && after_decline.identity.genome == genome_before);
const auto decline_final = host->take_finalized_mutations();
CHECK(decline_final.size() == 1 &&
decline_final.front().result == CellularMutationResult::declined &&
action_outcome(decline_final.front()).result == evo::network::ActionResult::committed);
CHECK(owner
->query("SELECT 1 FROM evolution.cellular_mutation_action_publications "
"WHERE action_id = 33 AND result = 3",
{}, 5s)
->size() == 1);
host->drain();
}
+10 -2
View File
@@ -535,10 +535,18 @@ void cellular_panels(const std::filesystem::path& review) {
depleted.reserve_energy_pj = 0;
perception.diagnostics = depleted;
draw();
CHECK(!probe(evolution, 0.5F, [&] { return action.mutation.has_value(); }));
// An unaffordable candidate cannot be chosen; declining (operator 0) still can.
const auto chose_candidate = [&] {
return action.mutation.has_value() && action.mutation->operator_id != 0;
};
CHECK(!probe(evolution, 0.5F, chose_candidate));
action.mutation.reset();
CHECK(probe(evolution, 0.5F, [&] { return action.mutation.has_value(); }));
CHECK(action.mutation == MutationChoice{901, 1, 100, 0});
action.mutation.reset();
perception.diagnostics = diagnostics;
draw();
CHECK(probe(evolution, 0.5F, [&] { return action.mutation.has_value(); }));
CHECK(probe(evolution, 0.5F, chose_candidate));
CHECK(action.mutation == MutationChoice{901, 1, 100, 3});
CHECK(play.queue(CellAction::mutation, 102, required(action.mutation)));
const auto mutation_id = required(play.pending()).id;
+9 -1
View File
@@ -2,6 +2,7 @@
#include "evo/persistence/account_control_store.hpp"
#include "evo/persistence/life_reservation_store.hpp"
#include "evo/persistence/region_lease_store.hpp"
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <source_location>
@@ -152,10 +153,17 @@ void run_life_reservation_store_tests() {
CHECK(pending_mutations && pending_mutations->size() == 1 &&
pending_mutations->front() == *mutation);
auto invalid_mutation_input = mutation_input;
invalid_mutation_input[32] = 0; // operator ID zero is invalid
std::fill_n(invalid_mutation_input.begin() + 24, 8, std::uint8_t{0}); // No offer tick.
CHECK(failed(
reserve_cellular_mutation(*db, a, *lease_a, alice, 1, 502, invalid_mutation_input, 5s),
LifeReservationError::invalid));
// Schema v40 (ADR-0120 amendment): operator 0 is a decline, a valid input; it is
// refused here only because the account already has a pending choice.
auto decline_input = mutation_input;
decline_input[32] = 0;
decline_input[33] = 0;
CHECK(failed(reserve_cellular_mutation(*db, a, *lease_a, alice, 1, 503, decline_input, 5s),
LifeReservationError::pending_mutation));
CHECK(reject_primitive_life(*db, a, *lease_a, alice, 1, 3, LifeRefusal::no_placement, 5s) ==
LifeRefusal::no_placement);
const auto pending = reserve(4);
+1 -1
View File
@@ -212,7 +212,7 @@ void upgrade_across_migration_and_barrier() {
" 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,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");
"25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40");
CHECK(scalar(*owner_db, "SELECT (c.condeferrable AND c.condeferred AND "
"c.confrelid = 'evolution.region_commits'::regclass)::text "
"FROM pg_catalog.pg_constraint c WHERE c.conrelid = "
+5 -5
View File
@@ -122,7 +122,7 @@ PGDATABASE=upgrade_path psql -X -v ON_ERROR_STOP=1 -1 -v "migration_sha=$v1_sha"
-f "$root/migrations/0001_region_bootstrap.sql" > /dev/null
test "$(PGDATABASE=upgrade_path psql -XAtc "SELECT string_agg(version::text, ',') FROM evolution.schema_migrations")" = 1
PGDATABASE=upgrade_path bash "$root/tools/migrate-postgres.sh"
test "$(PGDATABASE=upgrade_path psql -XAtc "SELECT string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39
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
# 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%% *}"
@@ -143,7 +143,7 @@ PGDATABASE=v3_commits psql -X -v ON_ERROR_STOP=1 \
-c "INSERT INTO evolution.retained_builds VALUES (decode(repeat('b1', 32), 'hex'))" \
-c "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")" = 39: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
test "$(PGDATABASE=v3_commits psql -XAtc "SELECT count(*) || ':' || string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 40: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
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.
@@ -197,7 +197,7 @@ PGDATABASE=v6_populated psql -X -v ON_ERROR_STOP=1 \
-c "INSERT INTO evolution.retained_builds VALUES (decode(repeat('b1', 32), 'hex'))" \
-c "SELECT evolution.provision_region_checkpoint(decode('4145564f52434d31' || '02000000' || '01000000' || '0100000000000000' || '0100000000000000' || '0900000000000000' || repeat('11', 16) || repeat('00', 8) || repeat('00', 16) || repeat('00', 32) || repeat('00', 16) || repeat('00', 16) || repeat('00', 8) || '50c3000000000000' || '020000000200000001000000010000000100000001000000010000000100000001000000' || repeat('b1', 32) || '00000000' || '00000000' || '01000000' || '6400000000000000' || repeat('a0', 32) || repeat('00', 80), 'hex'))" > /dev/null
PGDATABASE=v6_populated bash "$root/tools/migrate-postgres.sh"
test "$(PGDATABASE=v6_populated psql -XAtc "SELECT string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39
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
test "$(PGDATABASE=v6_populated psql -XAtc "SELECT count(*) FROM evolution.region_commits c, LATERAL evolution.parse_checkpoint_manifest(c.manifest) m WHERE m.commit_sequence = 0 AND m.predecessor_commit IS NULL")" = 1
test "$(PGDATABASE=v6_populated psql -XAtc "SELECT string_agg(conname, ',') FROM pg_constraint WHERE conrelid = 'evolution.region_heads'::regclass AND contype = 'c' AND pg_get_constraintdef(oid) LIKE '%end_tick%'")" = region_heads_published_tick
phase permission-audit
@@ -250,9 +250,9 @@ expect_audit_failure 'REVOKE EXECUTE ON FUNCTION evolution.claim_account_control
bash "$root/tools/migrate-postgres.sh" # Restored configuration passes the audit again.
phase checksum-drift
# Unknown future versions and checksum drift must not be repaired silently.
psql -X -v ON_ERROR_STOP=1 -c 'UPDATE evolution.schema_migrations SET version=40 WHERE version=39'
psql -X -v ON_ERROR_STOP=1 -c 'UPDATE evolution.schema_migrations SET version=41 WHERE version=40'
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=39 WHERE version=40"
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET version=40 WHERE version=41"
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=14"
if bash "$root/tools/migrate-postgres.sh"; then exit 1; fi
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET sha256=repeat('0',64) WHERE version=13"
+3
View File
@@ -90,6 +90,8 @@ digest_38="$(sha256sum "$root/migrations/0038_cellular_v6_presence_bundle.sql")"
digest_38="${digest_38%% *}"
digest_39="$(sha256sum "$root/migrations/0039_account_identities.sql")"
digest_39="${digest_39%% *}"
digest_40="$(sha256sum "$root/migrations/0040_cellular_mutation_decline.sql")"
digest_40="${digest_40%% *}"
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" \
@@ -122,5 +124,6 @@ psql -X --no-password --set=ON_ERROR_STOP=1 --set="migration_sha=$digest" \
--set="migration_sha_37=$digest_37" \
--set="migration_sha_38=$digest_38" \
--set="migration_sha_39=$digest_39" \
--set="migration_sha_40=$digest_40" \
--set="runtime_role=$runtime_role" \
--file="$root/migrations/apply.sql"