Persist primitive life outcomes across control moves
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m57s
Foundation / checks (client) (push) Successful in 12m36s
Foundation / checks (network) (push) Successful in 13m43s
Foundation / checks (tsan) (push) Successful in 8m14s
Foundation / checks (postgres) (push) Failing after 17m26s
Foundation / checks (checks) (push) Successful in 33m23s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m57s
Foundation / checks (client) (push) Successful in 12m36s
Foundation / checks (network) (push) Successful in 13m43s
Foundation / checks (tsan) (push) Successful in 8m14s
Foundation / checks (postgres) (push) Failing after 17m26s
Foundation / checks (checks) (push) Successful in 33m23s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
This commit is contained in:
@@ -211,45 +211,28 @@ admission and retry behavior, not end-to-end recoverability or deployable gamepl
|
|||||||
Death, respawn, offline timers, biological tick integration and life transfer are
|
Death, respawn, offline timers, biological tick integration and life transfer are
|
||||||
outside 11.2 and remain governed by later gates.
|
outside 11.2 and remain governed by later gates.
|
||||||
|
|
||||||
## 11.2d contract gap: durable request outcomes and moved control
|
## 11.2d request outcomes and control movement
|
||||||
|
|
||||||
The first v5 request/receipt/outcome/query codec is implemented, but server
|
Schema v17 closes the request contract without transferring a pending biological
|
||||||
execution must remain disabled until the durable request contract is closed.
|
operation between regions. A conflicting new request gets a durable
|
||||||
Inspection of schema v15/v16 and the C++ read adapter found two gaps:
|
`existing_life` refusal row, so exact retry and query return the same final
|
||||||
|
result. The authenticated current controller can query by world/account/request
|
||||||
|
independently of the reservation's region; results include the owner and, after
|
||||||
|
publication, the immutable born tick and commit receipt. Missing rows resolve as
|
||||||
|
unknown, while a reserved row remains pending and is never called a birth.
|
||||||
|
|
||||||
- `reserve_primitive_life` raises `EVL16` when the account already has another
|
When account control changes region or region epoch, the same fenced control
|
||||||
reserved or living life. It inserts no row for the incoming request, so that
|
transaction marks unpublished reservations in the old region cancelled.
|
||||||
request has no durable final outcome for exact retry or query. The current v5
|
Published bindings are untouched. The cancelled request remains immutable and a
|
||||||
result vocabulary cannot express this refusal.
|
new request is required to try again. This avoids cross-region transfer of
|
||||||
- `load_primitive_lives` reads successful bindings for one region. There is no
|
speculative body state and prevents the old reservation becoming publishable
|
||||||
authenticated world/account/request query that resolves a refusal or a
|
under a new controller. V5 now gives `existing_life` and `cancelled` durable
|
||||||
pending reservation across regions. A repeated reservation can identify the
|
result values distinct from query-only `pending` and `unknown`.
|
||||||
original owner region, but the runtime has no completed routing/recovery
|
|
||||||
contract for it.
|
|
||||||
- A pending reservation is pinned to its original region. If account control
|
|
||||||
moves before publication, admission in the new region returns that owner
|
|
||||||
region, while publication still requires current control. Without an explicit
|
|
||||||
ownership transition, the request can remain stranded; allowing the new
|
|
||||||
region to publish independently would risk two bodies.
|
|
||||||
|
|
||||||
These are contract blockers for 11.2d, not permission to infer new game rules.
|
Migration v17, its typed query adapter and PostgreSQL tests implement this
|
||||||
Before implementing session execution, settle and record a schema/API contract
|
contract. Host/session execution, concurrent-process crash qualification and
|
||||||
that gives every accepted new-life request a durable, immutable queryable
|
readiness integration remain outstanding; v5 stays refused by the running
|
||||||
outcome, including an existing-life refusal, and resolves pending ownership
|
server until those gates pass.
|
||||||
across control movement. One candidate is a world-scoped operation record keyed
|
|
||||||
by `(world, account, request_id)`, with durable pending/final state, owner region,
|
|
||||||
and the successful commit binding/sequence where applicable. Query must be
|
|
||||||
available to the authenticated current controller independently of its region.
|
|
||||||
An ownership move must either atomically transfer the pending operation under
|
|
||||||
the relevant fencing checks, or durably finalize it and require a new request;
|
|
||||||
two regions must never be able to publish it. Extend the versioned result
|
|
||||||
vocabulary for any accepted durable refusals, keeping query-only `pending` and
|
|
||||||
`unknown` distinct from final outcomes.
|
|
||||||
|
|
||||||
The candidate above is a recommendation for review, not an accepted game rule.
|
|
||||||
Add PostgreSQL concurrency and process-crash evidence for exact retries,
|
|
||||||
cross-region queries, control movement during reservation/publication, and
|
|
||||||
immutable refusal results before enabling the v5 handler or primitive host.
|
|
||||||
|
|
||||||
## 11.2c-2d: Object-store publication and recovery adapter
|
## 11.2c-2d: Object-store publication and recovery adapter
|
||||||
|
|
||||||
|
|||||||
@@ -90,13 +90,18 @@ Local checks do not close ADR-0097's reference-worker qualification.
|
|||||||
handling are implemented. Network and QUIC suites pass; targeted manual compile
|
handling are implemented. Network and QUIC suites pass; targeted manual compile
|
||||||
and link were needed because the normal Ninja build invocation idles. Host
|
and link were needed because the normal Ninja build invocation idles. Host
|
||||||
admission and durable execution are a separate slice.
|
admission and durable execution are a separate slice.
|
||||||
- 11.2d contract review: stopped before host/session execution after tracing
|
- 11.2d-2 implementation: schema v17 records an immutable `existing_life`
|
||||||
reservation, publication and query paths. ADR-0100 records the missing durable
|
refusal for each conflicting request, offers an authenticated world/account/
|
||||||
outcome for an existing-life refusal, lack of region-independent request query,
|
request query, and cancels unpublished reservations atomically when control
|
||||||
and unresolved pending-reservation behavior when account control moves. Resolve
|
changes region/epoch. Published bindings remain unchanged; v5 now distinguishes
|
||||||
and validate this request/ownership contract before expanding implementation.
|
`existing_life` and `cancelled` from query-only `pending`/`unknown`. Typed adapter,
|
||||||
- Remaining 11.2d after contract closure: primitive-capable region host, server
|
migration, codec and PostgreSQL tests/docs are updated. Validation is pending:
|
||||||
admission/execution, crash-boundary qualification and readiness integration.
|
the affected C++ files were compiled directly with MSVC and the updated network
|
||||||
The generic two-profile host still cannot serve profile 3.
|
and QUIC suites passed (2/2 and 5/5). PostgreSQL 18.6 is unavailable here, so
|
||||||
|
migration and adapter integration tests remain unrun. Host work remains paused
|
||||||
|
until database validation passes.
|
||||||
|
- Remaining 11.2d after 11.2d-2 validation: primitive-capable region host,
|
||||||
|
server admission/execution, crash-boundary qualification and readiness
|
||||||
|
integration. The generic two-profile host still cannot serve profile 3.
|
||||||
|
|
||||||
No deployed world has been provisioned or changed by this work.
|
No deployed world has been provisioned or changed by this work.
|
||||||
|
|||||||
@@ -5657,3 +5657,25 @@ The operator's live-region smoke test did pass using the prebuilt v4
|
|||||||
`evo-session-probe`, `C:\Dev\tokens\m10-grants.bin` grant 0 and the supplied dev CA:
|
`evo-session-probe`, `C:\Dev\tokens\m10-grants.bin` grant 0 and the supplied dev CA:
|
||||||
`void.aeternalisgames.com:7400` returned Welcome, exit 0. This confirms existing v4
|
`void.aeternalisgames.com:7400` returned Welcome, exit 0. This confirms existing v4
|
||||||
connectivity only; it does not execute or validate v5 or primitive-life handling.
|
connectivity only; it does not execute or validate v5 or primitive-life handling.
|
||||||
|
|
||||||
|
## 2026-10-10 — M11.2d-2 durable primitive-life outcomes (unverified)
|
||||||
|
|
||||||
|
Implemented schema v17 durable `existing_life` outcomes, current-controller
|
||||||
|
world/account/request lookup, and atomic cancellation of unpublished reservations
|
||||||
|
when control changes region or region epoch. Updated v5 outcomes and typed adapter
|
||||||
|
tests. Direct clang-format 19.1.5 dry-run on all changed C++ files and `git diff
|
||||||
|
--check` passed.
|
||||||
|
|
||||||
|
The network preset configured successfully, but its check invocation and a direct
|
||||||
|
`evo-network-tests` Ninja target remained silent without completion for more than
|
||||||
|
35 seconds and were interrupted, matching the previously recorded idle Ninja
|
||||||
|
condition. Direct MSVC Release/NDEBUG compilation succeeded for the modified
|
||||||
|
network protocol/test units, persistence adapter and its changed PostgreSQL test
|
||||||
|
units. The protocol library and network test executable were rebuilt from those
|
||||||
|
objects; `ctest --preset network` passed (2/2) and `ctest --preset quic` passed
|
||||||
|
(5/5).
|
||||||
|
|
||||||
|
`psql` and PostgreSQL 18.6 are unavailable in this environment; Docker's Linux
|
||||||
|
engine is also not running. Schema v17 and its PostgreSQL integration, migration,
|
||||||
|
upgrade and privilege tests have not run. Do not continue to 11.2d host/session
|
||||||
|
execution until those database checks pass.
|
||||||
|
|||||||
@@ -173,10 +173,12 @@ struct ActionQuery {
|
|||||||
};
|
};
|
||||||
enum class PrimitiveLifeResult : std::uint8_t {
|
enum class PrimitiveLifeResult : std::uint8_t {
|
||||||
born = 1,
|
born = 1,
|
||||||
insufficient_funding,
|
insufficient_funding = 2,
|
||||||
no_placement,
|
no_placement = 3,
|
||||||
pending,
|
existing_life = 4,
|
||||||
unknown
|
cancelled = 5,
|
||||||
|
pending = 6,
|
||||||
|
unknown = 7
|
||||||
};
|
};
|
||||||
struct PrimitiveLifeRequest {
|
struct PrimitiveLifeRequest {
|
||||||
std::uint64_t session{}, epoch{}, request_id{};
|
std::uint64_t session{}, epoch{}, request_id{};
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ enum class LifeRefusal : std::uint8_t {
|
|||||||
none = 0, // Reserved only; NOT successful spawn.
|
none = 0, // Reserved only; NOT successful spawn.
|
||||||
insufficient_funding = 1,
|
insufficient_funding = 1,
|
||||||
no_placement = 2,
|
no_placement = 2,
|
||||||
cancelled = 3
|
cancelled = 3,
|
||||||
|
existing_life = 4
|
||||||
};
|
};
|
||||||
struct LifeReservation {
|
struct LifeReservation {
|
||||||
std::uint64_t identity{}, region{};
|
std::uint64_t identity{}, region{};
|
||||||
@@ -40,6 +41,11 @@ struct PrimitiveLifeBinding {
|
|||||||
std::uint64_t commit_sequence{};
|
std::uint64_t commit_sequence{};
|
||||||
friend bool operator==(const PrimitiveLifeBinding&, const PrimitiveLifeBinding&) = default;
|
friend bool operator==(const PrimitiveLifeBinding&, const PrimitiveLifeBinding&) = default;
|
||||||
};
|
};
|
||||||
|
struct PrimitiveLifeOutcome {
|
||||||
|
LifeReservation reservation;
|
||||||
|
std::optional<PrimitiveLifeBinding> published;
|
||||||
|
friend bool operator==(const PrimitiveLifeOutcome&, const PrimitiveLifeOutcome&) = default;
|
||||||
|
};
|
||||||
// Exact retry returns the original identity/owning region/refusal, even after
|
// Exact retry returns the original identity/owning region/refusal, even after
|
||||||
// account control moves. The result grants no authority in the returned region.
|
// account control moves. The result grants no authority in the returned region.
|
||||||
// request_id is in the new-life namespace, separate from M10 probe action IDs.
|
// request_id is in the new-life namespace, separate from M10 probe action IDs.
|
||||||
@@ -57,4 +63,10 @@ reject_primitive_life(Postgres& db, RegionKey key, const LeaseGrant& lease, cons
|
|||||||
// are intentionally absent and must be reacquired after recovery.
|
// are intentionally absent and must be reacquired after recovery.
|
||||||
[[nodiscard]] std::expected<std::vector<PrimitiveLifeBinding>, LifeReservationFailure>
|
[[nodiscard]] std::expected<std::vector<PrimitiveLifeBinding>, LifeReservationFailure>
|
||||||
load_primitive_lives(Postgres& db, RegionKey key, std::chrono::milliseconds timeout);
|
load_primitive_lives(Postgres& db, RegionKey key, std::chrono::milliseconds timeout);
|
||||||
|
// Authenticated world/account/request lookup. A missing value is unknown; a
|
||||||
|
// present pending reservation is still not a published life.
|
||||||
|
[[nodiscard]] std::expected<std::optional<PrimitiveLifeOutcome>, LifeReservationFailure>
|
||||||
|
query_primitive_life(Postgres& db, RegionKey key, const LeaseGrant& lease, const Uuid& account,
|
||||||
|
std::uint64_t generation, std::uint64_t request_id,
|
||||||
|
std::chrono::milliseconds timeout);
|
||||||
} // namespace evo::persistence
|
} // namespace evo::persistence
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
-- M11.2d contract closure, ADR-0100. Existing durable request rows become
|
||||||
|
-- queryable outcomes for conflicts, and reservations cannot remain pending at
|
||||||
|
-- an old owner after account control moves.
|
||||||
|
ALTER TABLE evolution.life_reservations DROP CONSTRAINT life_reservations_rejection_check;
|
||||||
|
ALTER TABLE evolution.life_reservations ADD CONSTRAINT life_reservations_rejection_check
|
||||||
|
CHECK (rejection BETWEEN 0 AND 4);
|
||||||
|
-- 4 is an immutable refusal: another life is already reserved or published.
|
||||||
|
|
||||||
|
CREATE FUNCTION evolution.cancel_moved_primitive_reservations() RETURNS trigger
|
||||||
|
LANGUAGE plpgsql SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS $$
|
||||||
|
BEGIN
|
||||||
|
IF OLD.region_id IS NOT NULL AND
|
||||||
|
(OLD.region_id IS DISTINCT FROM NEW.region_id OR
|
||||||
|
OLD.region_epoch IS DISTINCT FROM NEW.region_epoch) THEN
|
||||||
|
UPDATE evolution.life_reservations r SET rejection = 3
|
||||||
|
WHERE r.world_id = OLD.world_id AND r.account_id = OLD.account_id
|
||||||
|
AND r.region_id = OLD.region_id AND r.rejection = 0
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM evolution.primitive_life_bindings b
|
||||||
|
WHERE b.world_id = r.world_id AND b.account_id = r.account_id
|
||||||
|
AND b.request_id = r.request_id);
|
||||||
|
END IF;
|
||||||
|
RETURN NEW;
|
||||||
|
END $$;
|
||||||
|
CREATE TRIGGER cancel_moved_primitive_reservations
|
||||||
|
AFTER UPDATE OF region_id, region_epoch ON evolution.account_controls
|
||||||
|
FOR EACH ROW EXECUTE FUNCTION evolution.cancel_moved_primitive_reservations();
|
||||||
|
|
||||||
|
-- Exact retry is checked before conflict detection. A conflicting request gets
|
||||||
|
-- its own durable refusal row and allocated identity (a permitted gap), so its
|
||||||
|
-- result survives reconnect and remains distinct from the older request.
|
||||||
|
CREATE OR REPLACE FUNCTION evolution.reserve_primitive_life(p_world evolution.u64,
|
||||||
|
p_region evolution.u64, p_holder uuid, p_epoch evolution.u64, p_account uuid,
|
||||||
|
p_generation evolution.u64, p_request evolution.u64, p_rules integer)
|
||||||
|
RETURNS TABLE (life_identity evolution.u64, life_region evolution.u64, rejection smallint)
|
||||||
|
LANGUAGE plpgsql SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS $$
|
||||||
|
DECLARE r evolution.life_reservations%ROWTYPE; allocated numeric;
|
||||||
|
BEGIN
|
||||||
|
IF p_request IS NULL OR p_request = 0 OR p_rules IS DISTINCT FROM 1 THEN
|
||||||
|
RAISE EXCEPTION 'invalid life request' USING ERRCODE = '22023';
|
||||||
|
END IF;
|
||||||
|
PERFORM evolution.check_life_control(p_world, p_region, p_holder, p_epoch, p_account, p_generation);
|
||||||
|
SELECT * INTO r FROM evolution.life_reservations x
|
||||||
|
WHERE x.world_id = p_world AND x.account_id = p_account AND x.request_id = p_request;
|
||||||
|
IF FOUND THEN
|
||||||
|
RETURN QUERY SELECT r.identity, r.region_id, r.rejection;
|
||||||
|
RETURN;
|
||||||
|
END IF;
|
||||||
|
SELECT a.next_identity INTO allocated FROM evolution.life_allocators a
|
||||||
|
WHERE a.world_id = p_world FOR UPDATE;
|
||||||
|
IF NOT FOUND THEN
|
||||||
|
RAISE EXCEPTION 'life allocator not provisioned' USING ERRCODE = 'EVL04';
|
||||||
|
END IF;
|
||||||
|
IF allocated = 18446744073709551615 THEN
|
||||||
|
RAISE EXCEPTION 'life identities exhausted' USING ERRCODE = 'EVL05';
|
||||||
|
END IF;
|
||||||
|
PERFORM evolution.check_life_control(p_world, p_region, p_holder, p_epoch, p_account, p_generation);
|
||||||
|
IF EXISTS (SELECT 1 FROM evolution.life_reservations x
|
||||||
|
WHERE x.world_id = p_world AND x.account_id = p_account AND x.rejection = 0) THEN
|
||||||
|
UPDATE evolution.life_allocators SET next_identity = allocated + 1 WHERE world_id = p_world;
|
||||||
|
INSERT INTO evolution.life_reservations(world_id, account_id, request_id, identity,
|
||||||
|
region_id, rules, rejection)
|
||||||
|
VALUES (p_world, p_account, p_request, allocated, p_region, p_rules, 4);
|
||||||
|
RETURN QUERY SELECT allocated::evolution.u64, p_region, 4::smallint;
|
||||||
|
RETURN;
|
||||||
|
END IF;
|
||||||
|
UPDATE evolution.life_allocators SET next_identity = allocated + 1 WHERE world_id = p_world;
|
||||||
|
INSERT INTO evolution.life_reservations(world_id, account_id, request_id, identity, region_id, rules)
|
||||||
|
VALUES (p_world, p_account, p_request, allocated, p_region, p_rules);
|
||||||
|
RETURN QUERY SELECT allocated::evolution.u64, p_region, 0::smallint;
|
||||||
|
END $$;
|
||||||
|
|
||||||
|
-- The caller must hold current account control in a live region session. The
|
||||||
|
-- row is world/account/request scoped, not limited to the reservation's region.
|
||||||
|
CREATE FUNCTION evolution.query_primitive_life(p_world evolution.u64, p_region evolution.u64,
|
||||||
|
p_holder uuid, p_epoch evolution.u64, p_account uuid, p_generation evolution.u64,
|
||||||
|
p_request evolution.u64)
|
||||||
|
RETURNS TABLE (life_identity evolution.u64, life_region evolution.u64, rejection smallint,
|
||||||
|
born evolution.u64, commit_id uuid, commit_sequence evolution.u64)
|
||||||
|
LANGUAGE plpgsql SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS $$
|
||||||
|
BEGIN
|
||||||
|
IF p_request IS NULL OR p_request = 0 THEN
|
||||||
|
RAISE EXCEPTION 'invalid life request' USING ERRCODE = '22023';
|
||||||
|
END IF;
|
||||||
|
PERFORM evolution.check_life_control(p_world, p_region, p_holder, p_epoch, p_account, p_generation);
|
||||||
|
RETURN QUERY
|
||||||
|
SELECT r.identity, r.region_id, r.rejection, b.born, b.commit_id, c.commit_sequence
|
||||||
|
FROM evolution.life_reservations r
|
||||||
|
LEFT JOIN evolution.primitive_life_bindings b USING(world_id,account_id,request_id)
|
||||||
|
LEFT JOIN evolution.region_commits c ON c.commit_id=b.commit_id
|
||||||
|
WHERE r.world_id=p_world AND r.account_id=p_account AND r.request_id=p_request;
|
||||||
|
END $$;
|
||||||
|
|
||||||
|
REVOKE ALL ON FUNCTION evolution.cancel_moved_primitive_reservations(),
|
||||||
|
evolution.query_primitive_life(evolution.u64,evolution.u64,uuid,evolution.u64,uuid,evolution.u64,evolution.u64)
|
||||||
|
FROM PUBLIC;
|
||||||
|
GRANT EXECUTE ON FUNCTION
|
||||||
|
evolution.query_primitive_life(evolution.u64,evolution.u64,uuid,evolution.u64,uuid,evolution.u64,evolution.u64)
|
||||||
|
TO :"runtime_role";
|
||||||
|
INSERT INTO evolution.schema_migrations(version,sha256) VALUES (17, :'migration_sha_17');
|
||||||
+22
-2
@@ -89,28 +89,36 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
|||||||
|| ',9:' || :'migration_sha_9' || ',10:' || :'migration_sha_10'
|
|| ',9:' || :'migration_sha_9' || ',10:' || :'migration_sha_10'
|
||||||
|| ',11:' || :'migration_sha_11' || ',12:' || :'migration_sha_12'
|
|| ',11:' || :'migration_sha_11' || ',12:' || :'migration_sha_12'
|
||||||
|| ',13:' || :'migration_sha_13' || ',14:' || :'migration_sha_14'
|
|| ',13:' || :'migration_sha_13' || ',14:' || :'migration_sha_14'
|
||||||
|| ',15:' || :'migration_sha_15' || ',16:' || :'migration_sha_16' AS at_v16 \gset
|
|| ',15:' || :'migration_sha_15' || ',16:' || :'migration_sha_16' AS at_v16,
|
||||||
\if :at_v16
|
:'history' = '1:' || :'migration_sha' || ',2:' || :'migration_sha_2' || ',3:' || :'migration_sha_3' || ',4:' || :'migration_sha_4' || ',5:' || :'migration_sha_5' || ',6:' || :'migration_sha_6' || ',7:' || :'migration_sha_7' || ',8:' || :'migration_sha_8' || ',9:' || :'migration_sha_9' || ',10:' || :'migration_sha_10' || ',11:' || :'migration_sha_11' || ',12:' || :'migration_sha_12' || ',13:' || :'migration_sha_13' || ',14:' || :'migration_sha_14' || ',15:' || :'migration_sha_15' || ',16:' || :'migration_sha_16' || ',17:' || :'migration_sha_17' AS at_v17 \gset
|
||||||
|
\if :at_v17
|
||||||
|
\elif :at_v16
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\elif :at_v15
|
\elif :at_v15
|
||||||
\ir 0016_primitive_publication.sql
|
\ir 0016_primitive_publication.sql
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\elif :at_v14
|
\elif :at_v14
|
||||||
\ir 0015_life_reservations.sql
|
\ir 0015_life_reservations.sql
|
||||||
\ir 0016_primitive_publication.sql
|
\ir 0016_primitive_publication.sql
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\elif :at_v13
|
\elif :at_v13
|
||||||
\ir 0014_probe_overdue.sql
|
\ir 0014_probe_overdue.sql
|
||||||
\ir 0015_life_reservations.sql
|
\ir 0015_life_reservations.sql
|
||||||
\ir 0016_primitive_publication.sql
|
\ir 0016_primitive_publication.sql
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\elif :at_v12
|
\elif :at_v12
|
||||||
\ir 0013_probe_incoming.sql
|
\ir 0013_probe_incoming.sql
|
||||||
\ir 0014_probe_overdue.sql
|
\ir 0014_probe_overdue.sql
|
||||||
\ir 0015_life_reservations.sql
|
\ir 0015_life_reservations.sql
|
||||||
\ir 0016_primitive_publication.sql
|
\ir 0016_primitive_publication.sql
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\elif :at_v11
|
\elif :at_v11
|
||||||
\ir 0012_probe_handoff.sql
|
\ir 0012_probe_handoff.sql
|
||||||
\ir 0013_probe_incoming.sql
|
\ir 0013_probe_incoming.sql
|
||||||
\ir 0014_probe_overdue.sql
|
\ir 0014_probe_overdue.sql
|
||||||
\ir 0015_life_reservations.sql
|
\ir 0015_life_reservations.sql
|
||||||
\ir 0016_primitive_publication.sql
|
\ir 0016_primitive_publication.sql
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\elif :at_v10
|
\elif :at_v10
|
||||||
\ir 0011_region_actions.sql
|
\ir 0011_region_actions.sql
|
||||||
\ir 0012_probe_handoff.sql
|
\ir 0012_probe_handoff.sql
|
||||||
@@ -118,6 +126,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
|||||||
\ir 0014_probe_overdue.sql
|
\ir 0014_probe_overdue.sql
|
||||||
\ir 0015_life_reservations.sql
|
\ir 0015_life_reservations.sql
|
||||||
\ir 0016_primitive_publication.sql
|
\ir 0016_primitive_publication.sql
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\elif :at_v9
|
\elif :at_v9
|
||||||
\ir 0010_account_control.sql
|
\ir 0010_account_control.sql
|
||||||
\ir 0011_region_actions.sql
|
\ir 0011_region_actions.sql
|
||||||
@@ -126,6 +135,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
|||||||
\ir 0014_probe_overdue.sql
|
\ir 0014_probe_overdue.sql
|
||||||
\ir 0015_life_reservations.sql
|
\ir 0015_life_reservations.sql
|
||||||
\ir 0016_primitive_publication.sql
|
\ir 0016_primitive_publication.sql
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\elif :at_v8
|
\elif :at_v8
|
||||||
\ir 0009_serialized_authority.sql
|
\ir 0009_serialized_authority.sql
|
||||||
\ir 0010_account_control.sql
|
\ir 0010_account_control.sql
|
||||||
@@ -135,6 +145,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
|||||||
\ir 0014_probe_overdue.sql
|
\ir 0014_probe_overdue.sql
|
||||||
\ir 0015_life_reservations.sql
|
\ir 0015_life_reservations.sql
|
||||||
\ir 0016_primitive_publication.sql
|
\ir 0016_primitive_publication.sql
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\elif :at_v7
|
\elif :at_v7
|
||||||
\ir 0008_upgrade_barrier.sql
|
\ir 0008_upgrade_barrier.sql
|
||||||
\ir 0009_serialized_authority.sql
|
\ir 0009_serialized_authority.sql
|
||||||
@@ -145,6 +156,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
|||||||
\ir 0014_probe_overdue.sql
|
\ir 0014_probe_overdue.sql
|
||||||
\ir 0015_life_reservations.sql
|
\ir 0015_life_reservations.sql
|
||||||
\ir 0016_primitive_publication.sql
|
\ir 0016_primitive_publication.sql
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\elif :at_v6
|
\elif :at_v6
|
||||||
\ir 0007_region_clones.sql
|
\ir 0007_region_clones.sql
|
||||||
\ir 0008_upgrade_barrier.sql
|
\ir 0008_upgrade_barrier.sql
|
||||||
@@ -156,6 +168,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
|||||||
\ir 0014_probe_overdue.sql
|
\ir 0014_probe_overdue.sql
|
||||||
\ir 0015_life_reservations.sql
|
\ir 0015_life_reservations.sql
|
||||||
\ir 0016_primitive_publication.sql
|
\ir 0016_primitive_publication.sql
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\elif :at_v5
|
\elif :at_v5
|
||||||
\ir 0006_commit_lookup.sql
|
\ir 0006_commit_lookup.sql
|
||||||
\ir 0007_region_clones.sql
|
\ir 0007_region_clones.sql
|
||||||
@@ -168,6 +181,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
|||||||
\ir 0014_probe_overdue.sql
|
\ir 0014_probe_overdue.sql
|
||||||
\ir 0015_life_reservations.sql
|
\ir 0015_life_reservations.sql
|
||||||
\ir 0016_primitive_publication.sql
|
\ir 0016_primitive_publication.sql
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\elif :at_v4
|
\elif :at_v4
|
||||||
\ir pre_v5_guard.sql
|
\ir pre_v5_guard.sql
|
||||||
\ir 0005_batch_decisions.sql
|
\ir 0005_batch_decisions.sql
|
||||||
@@ -182,6 +196,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
|||||||
\ir 0014_probe_overdue.sql
|
\ir 0014_probe_overdue.sql
|
||||||
\ir 0015_life_reservations.sql
|
\ir 0015_life_reservations.sql
|
||||||
\ir 0016_primitive_publication.sql
|
\ir 0016_primitive_publication.sql
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\elif :at_v3
|
\elif :at_v3
|
||||||
\ir 0004_lineage_profile.sql
|
\ir 0004_lineage_profile.sql
|
||||||
\ir pre_v5_guard.sql
|
\ir pre_v5_guard.sql
|
||||||
@@ -197,6 +212,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
|||||||
\ir 0014_probe_overdue.sql
|
\ir 0014_probe_overdue.sql
|
||||||
\ir 0015_life_reservations.sql
|
\ir 0015_life_reservations.sql
|
||||||
\ir 0016_primitive_publication.sql
|
\ir 0016_primitive_publication.sql
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\elif :at_v2
|
\elif :at_v2
|
||||||
\ir 0003_region_checkpoints.sql
|
\ir 0003_region_checkpoints.sql
|
||||||
\ir 0004_lineage_profile.sql
|
\ir 0004_lineage_profile.sql
|
||||||
@@ -213,6 +229,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
|||||||
\ir 0014_probe_overdue.sql
|
\ir 0014_probe_overdue.sql
|
||||||
\ir 0015_life_reservations.sql
|
\ir 0015_life_reservations.sql
|
||||||
\ir 0016_primitive_publication.sql
|
\ir 0016_primitive_publication.sql
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\elif :at_v1
|
\elif :at_v1
|
||||||
\ir 0002_region_fencing.sql
|
\ir 0002_region_fencing.sql
|
||||||
\ir 0003_region_checkpoints.sql
|
\ir 0003_region_checkpoints.sql
|
||||||
@@ -230,6 +247,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
|||||||
\ir 0014_probe_overdue.sql
|
\ir 0014_probe_overdue.sql
|
||||||
\ir 0015_life_reservations.sql
|
\ir 0015_life_reservations.sql
|
||||||
\ir 0016_primitive_publication.sql
|
\ir 0016_primitive_publication.sql
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\else
|
\else
|
||||||
\echo 'Unknown or changed migration history'
|
\echo 'Unknown or changed migration history'
|
||||||
DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$;
|
DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$;
|
||||||
@@ -252,6 +270,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
|||||||
\ir 0014_probe_overdue.sql
|
\ir 0014_probe_overdue.sql
|
||||||
\ir 0015_life_reservations.sql
|
\ir 0015_life_reservations.sql
|
||||||
\ir 0016_primitive_publication.sql
|
\ir 0016_primitive_publication.sql
|
||||||
|
\ir 0017_life_request_outcomes.sql
|
||||||
\endif
|
\endif
|
||||||
-- Effective-privilege audit on every run, including no-ops (ADR-0060). Attributes
|
-- Effective-privilege audit on every run, including no-ops (ADR-0060). Attributes
|
||||||
-- alone are insufficient: predefined roles such as pg_write_all_data, PUBLIC
|
-- alone are insufficient: predefined roles such as pg_write_all_data, PUBLIC
|
||||||
@@ -274,6 +293,7 @@ BEGIN
|
|||||||
), fenced(oid) AS (VALUES
|
), fenced(oid) AS (VALUES
|
||||||
('evolution.publish_primitive_checkpoint(bytea,bytea)'::regprocedure::oid),
|
('evolution.publish_primitive_checkpoint(bytea,bytea)'::regprocedure::oid),
|
||||||
('evolution.load_primitive_lives(evolution.u64,evolution.u64)'::regprocedure::oid),
|
('evolution.load_primitive_lives(evolution.u64,evolution.u64)'::regprocedure::oid),
|
||||||
|
('evolution.query_primitive_life(evolution.u64,evolution.u64,uuid,evolution.u64,uuid,evolution.u64,evolution.u64)'::regprocedure::oid),
|
||||||
('evolution.reserve_primitive_life(evolution.u64,evolution.u64,uuid,evolution.u64,uuid,evolution.u64,evolution.u64,integer)'::regprocedure::oid),
|
('evolution.reserve_primitive_life(evolution.u64,evolution.u64,uuid,evolution.u64,uuid,evolution.u64,evolution.u64,integer)'::regprocedure::oid),
|
||||||
('evolution.reject_primitive_life(evolution.u64,evolution.u64,uuid,evolution.u64,uuid,evolution.u64,evolution.u64,smallint)'::regprocedure::oid),
|
('evolution.reject_primitive_life(evolution.u64,evolution.u64,uuid,evolution.u64,uuid,evolution.u64,evolution.u64,smallint)'::regprocedure::oid),
|
||||||
('evolution.acquire_region_lease(evolution.u64,evolution.u64,integer)'::regprocedure::oid),
|
('evolution.acquire_region_lease(evolution.u64,evolution.u64,integer)'::regprocedure::oid),
|
||||||
|
|||||||
@@ -24,10 +24,13 @@ resolve a life request by assumption.
|
|||||||
| 1 | Insufficient funding |
|
| 1 | Insufficient funding |
|
||||||
| 2 | No placement/capacity |
|
| 2 | No placement/capacity |
|
||||||
| 3 | Cancelled |
|
| 3 | Cancelled |
|
||||||
|
| 4 | Existing life already reserved or published |
|
||||||
|
|
||||||
One unrejected reservation per world/account is enforced by a partial unique
|
One unrejected reservation per world/account is enforced by a partial unique
|
||||||
index. Rejected rows remain permanently queryable by retry. A different request
|
index. Rejected rows remain permanently queryable by retry. A conflicting new
|
||||||
may follow rejection and gets a new identity. There is no deletion API.
|
request now gets its own durable `existing_life` refusal row and consumes an
|
||||||
|
identity (gaps are permitted). A different request may follow a final rejection
|
||||||
|
and gets a new identity. There is no deletion API.
|
||||||
|
|
||||||
`reserve_primitive_life` requires the exact region lease and current durable
|
`reserve_primitive_life` requires the exact region lease and current durable
|
||||||
account-control generation. Exact retry returns the original identity, owner and
|
account-control generation. Exact retry returns the original identity, owner and
|
||||||
@@ -47,9 +50,14 @@ tables or internal control helper. Migration's effective privilege audit covers
|
|||||||
these additions, including no-op migration runs.
|
these additions, including no-op migration runs.
|
||||||
|
|
||||||
A takeover may inspect its old reservation before its session wait expires, but
|
A takeover may inspect its old reservation before its session wait expires, but
|
||||||
gets no biological control from it. The owner region stays unchanged. Session
|
gets no biological control from it. When durable account control changes region
|
||||||
admission must still honor ADR-0091's takeover wait before originating gameplay.
|
or region epoch, the control transaction atomically marks any unpublished old
|
||||||
Final spawn success, checkpoint publication and reconciliation are 11.2c-2/d.
|
reservation cancelled. A published life binding is never changed. Retrying the
|
||||||
|
cancelled request returns that immutable result; starting again requires a new
|
||||||
|
request. Session admission must still honor ADR-0091's takeover wait before
|
||||||
|
originating gameplay. `query_primitive_life` resolves the world/account/request
|
||||||
|
record for the authenticated current controller, independent of reservation
|
||||||
|
region, including final refusals and published commit identity/sequence.
|
||||||
|
|
||||||
Validation: `tools/ci/postgres-check.sh --life-reservations-only` starts a fresh
|
Validation: `tools/ci/postgres-check.sh --life-reservations-only` starts a fresh
|
||||||
local socket-only PostgreSQL test cluster. The full postgres-check also executes
|
local socket-only PostgreSQL test cluster. The full postgres-check also executes
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ are separate implementation gates.
|
|||||||
| 21 PrimitiveLifeQuery | client → server, reliable stream | request_id u64 | 8 |
|
| 21 PrimitiveLifeQuery | client → server, reliable stream | request_id u64 | 8 |
|
||||||
|
|
||||||
Result values: 1 born (identity and commit sequence must both be nonzero), 2 insufficient
|
Result values: 1 born (identity and commit sequence must both be nonzero), 2 insufficient
|
||||||
funding, 3 no placement, 4 pending (query only), 5 unknown (query only). Non-born results
|
funding, 3 no placement, 4 existing life, 5 cancelled, 6 pending (query only), 7 unknown
|
||||||
carry zero identity and commit sequence. Request IDs are a separate namespace from M10
|
(query only). Non-born results carry zero identity and commit sequence. A region-control
|
||||||
|
move durably cancels an unpublished reservation; retrying that request returns cancelled
|
||||||
|
and a new request is required. `existing life` is recorded for the conflicting request,
|
||||||
|
so its exact retry/query remains stable. Request IDs are a separate namespace from M10
|
||||||
action IDs. Receipt reports admission only; it does not claim that a life was durably born.
|
action IDs. Receipt reports admission only; it does not claim that a life was durably born.
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ reserve_primitive_life(Postgres& db, RegionKey key, const LeaseGrant& lease, con
|
|||||||
const auto identity = parse_integer<std::uint64_t>((*rows)[0][0]);
|
const auto identity = parse_integer<std::uint64_t>((*rows)[0][0]);
|
||||||
const auto region = parse_integer<std::uint64_t>((*rows)[0][1]);
|
const auto region = parse_integer<std::uint64_t>((*rows)[0][1]);
|
||||||
const auto refusal = parse_integer<std::uint32_t>((*rows)[0][2]);
|
const auto refusal = parse_integer<std::uint32_t>((*rows)[0][2]);
|
||||||
if (!identity || *identity == 0 || !region || *region == 0 || !refusal || *refusal > 3)
|
if (!identity || *identity == 0 || !region || *region == 0 || !refusal || *refusal > 4)
|
||||||
return std::unexpected{unknown};
|
return std::unexpected{unknown};
|
||||||
return LifeReservation{*identity, *region, static_cast<LifeRefusal>(*refusal)};
|
return LifeReservation{*identity, *region, static_cast<LifeRefusal>(*refusal)};
|
||||||
}
|
}
|
||||||
@@ -690,6 +690,42 @@ load_primitive_lives(Postgres& db, RegionKey key, milliseconds timeout) {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::expected<std::optional<PrimitiveLifeOutcome>, LifeReservationFailure>
|
||||||
|
query_primitive_life(Postgres& db, RegionKey key, const LeaseGrant& lease, const Uuid& account,
|
||||||
|
std::uint64_t generation, std::uint64_t request_id, milliseconds timeout) {
|
||||||
|
const auto base = control_parameters(key, lease, account, generation);
|
||||||
|
const std::array<std::string, 7> p{
|
||||||
|
base[0], base[1], base[2], base[3], base[4], base[5], std::to_string(request_id)};
|
||||||
|
auto rows = db.query("SELECT * FROM evolution.query_primitive_life($1::evolution.u64, "
|
||||||
|
"$2::evolution.u64, $3::uuid, $4::evolution.u64, $5::uuid, "
|
||||||
|
"$6::evolution.u64, $7::evolution.u64)",
|
||||||
|
p, timeout);
|
||||||
|
if (!rows)
|
||||||
|
return std::unexpected{life_failure(rows.error())};
|
||||||
|
if (rows->empty())
|
||||||
|
return std::optional<PrimitiveLifeOutcome>{};
|
||||||
|
const auto& row = (*rows)[0];
|
||||||
|
if (rows->size() != 1 || row.size() != 6)
|
||||||
|
return std::unexpected{LifeReservationFailure{LifeReservationError::store, {}}};
|
||||||
|
const auto identity = parse_integer<std::uint64_t>(row[0]);
|
||||||
|
const auto region = parse_integer<std::uint64_t>(row[1]);
|
||||||
|
const auto refusal = parse_integer<std::uint32_t>(row[2]);
|
||||||
|
if (!identity || *identity == 0 || !region || *region == 0 || !refusal || *refusal > 4)
|
||||||
|
return std::unexpected{LifeReservationFailure{LifeReservationError::store, {}}};
|
||||||
|
PrimitiveLifeOutcome out{
|
||||||
|
LifeReservation{*identity, *region, static_cast<LifeRefusal>(*refusal)}, std::nullopt};
|
||||||
|
if (row[3] || row[4] || row[5]) {
|
||||||
|
const auto born = parse_integer<std::uint64_t>(row[3]);
|
||||||
|
const auto commit = parse_uuid(row[4]);
|
||||||
|
const auto sequence = parse_integer<std::uint64_t>(row[5]);
|
||||||
|
if (!born || *born == 0 || !commit || !sequence || *sequence == 0)
|
||||||
|
return std::unexpected{LifeReservationFailure{LifeReservationError::store, {}}};
|
||||||
|
out.published =
|
||||||
|
PrimitiveLifeBinding{account, request_id, *identity, *born, *commit, *sequence};
|
||||||
|
}
|
||||||
|
return std::optional<PrimitiveLifeOutcome>{std::move(out)};
|
||||||
|
}
|
||||||
|
|
||||||
// Schema v12 probe records and handoff (ADR-0096). Shares this file's parsing rules.
|
// Schema v12 probe records and handoff (ADR-0096). Shares this file's parsing rules.
|
||||||
namespace {
|
namespace {
|
||||||
ProbeStoreFailure probe_failure(const PgFailure& f) {
|
ProbeStoreFailure probe_failure(const PgFailure& f) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Real PostgreSQL schema v15 adapter checks, isolated world 9752.
|
// Real PostgreSQL schema v17 adapter checks, isolated world 9752.
|
||||||
#include "evo/persistence/account_control_store.hpp"
|
#include "evo/persistence/account_control_store.hpp"
|
||||||
#include "evo/persistence/life_reservation_store.hpp"
|
#include "evo/persistence/life_reservation_store.hpp"
|
||||||
#include "evo/persistence/region_lease_store.hpp"
|
#include "evo/persistence/region_lease_store.hpp"
|
||||||
@@ -59,6 +59,8 @@ void run_life_reservation_store_tests() {
|
|||||||
return reserve_primitive_life(*db, a, *lease_a, alice, control->generation, action, rules,
|
return reserve_primitive_life(*db, a, *lease_a, alice, control->generation, action, rules,
|
||||||
5s);
|
5s);
|
||||||
};
|
};
|
||||||
|
const auto absent = query_primitive_life(*db, a, *lease_a, alice, control->generation, 77, 5s);
|
||||||
|
CHECK(absent && !*absent);
|
||||||
CHECK(failed(reserve(request), LifeReservationError::not_available));
|
CHECK(failed(reserve(request), LifeReservationError::not_available));
|
||||||
CHECK(admin->query("INSERT INTO evolution.life_allocators VALUES "
|
CHECK(admin->query("INSERT INTO evolution.life_allocators VALUES "
|
||||||
"(9752,9223372036854775808)",
|
"(9752,9223372036854775808)",
|
||||||
@@ -72,7 +74,15 @@ void run_life_reservation_store_tests() {
|
|||||||
first->refusal == LifeRefusal::none);
|
first->refusal == LifeRefusal::none);
|
||||||
db = connect_as(env("EVO_PG_RUNTIME_USER"));
|
db = connect_as(env("EVO_PG_RUNTIME_USER"));
|
||||||
CHECK(reserve(request) == *first);
|
CHECK(reserve(request) == *first);
|
||||||
CHECK(failed(reserve(2), LifeReservationError::existing_life));
|
const auto conflict = reserve(2);
|
||||||
|
CHECK(conflict && conflict->refusal == LifeRefusal::existing_life && conflict->region == 1 &&
|
||||||
|
conflict->identity == first->identity + 1);
|
||||||
|
CHECK(reserve(2) == *conflict);
|
||||||
|
auto conflict_result =
|
||||||
|
query_primitive_life(*db, a, *lease_a, alice, control->generation, 2, 5s);
|
||||||
|
CHECK(conflict_result && *conflict_result &&
|
||||||
|
(**conflict_result).reservation.refusal == LifeRefusal::existing_life &&
|
||||||
|
!(**conflict_result).published);
|
||||||
CHECK(failed(reserve_primitive_life(*db, a, *lease_a, alice, 2, request, 1, 5s),
|
CHECK(failed(reserve_primitive_life(*db, a, *lease_a, alice, 2, request, 1, 5s),
|
||||||
LifeReservationError::fenced));
|
LifeReservationError::fenced));
|
||||||
CHECK(failed(reject_primitive_life(*db, a, *lease_a, alice, 1, request, LifeRefusal::none, 5s),
|
CHECK(failed(reject_primitive_life(*db, a, *lease_a, alice, 1, request, LifeRefusal::none, 5s),
|
||||||
@@ -91,30 +101,35 @@ void run_life_reservation_store_tests() {
|
|||||||
CHECK(admin->query("BEGIN", {}, 5s));
|
CHECK(admin->query("BEGIN", {}, 5s));
|
||||||
CHECK(admin->query("SELECT * FROM evolution.life_allocators WHERE world_id=9752 FOR UPDATE", {},
|
CHECK(admin->query("SELECT * FROM evolution.life_allocators WHERE world_id=9752 FOR UPDATE", {},
|
||||||
5s));
|
5s));
|
||||||
CHECK(failed(reserve_primitive_life(*db, a, *lease_a, alice, 1, 2, 1, 20ms),
|
CHECK(failed(reserve_primitive_life(*db, a, *lease_a, alice, 1, 3, 1, 20ms),
|
||||||
LifeReservationError::unknown));
|
LifeReservationError::unknown));
|
||||||
CHECK(admin->query("COMMIT", {}, 5s));
|
CHECK(admin->query("COMMIT", {}, 5s));
|
||||||
db = connect_as(env("EVO_PG_RUNTIME_USER"));
|
db = connect_as(env("EVO_PG_RUNTIME_USER"));
|
||||||
const auto reconciled = reserve(2);
|
const auto reconciled = reserve(3);
|
||||||
CHECK(reconciled && reconciled->identity == first->identity + 1);
|
CHECK(reconciled && reconciled->identity == first->identity + 2);
|
||||||
CHECK(reserve(2) == *reconciled);
|
CHECK(reserve(3) == *reconciled);
|
||||||
const auto counter = admin->query(
|
const auto counter = admin->query(
|
||||||
"SELECT next_identity FROM evolution.life_allocators WHERE world_id=9752", {}, 5s);
|
"SELECT next_identity FROM evolution.life_allocators WHERE world_id=9752", {}, 5s);
|
||||||
CHECK(counter && (*counter)[0][0] == "9223372036854775810");
|
CHECK(counter && (*counter)[0][0] == "9223372036854775811");
|
||||||
CHECK(reject_primitive_life(*db, a, *lease_a, alice, 1, 2, LifeRefusal::no_placement, 5s) ==
|
CHECK(reject_primitive_life(*db, a, *lease_a, alice, 1, 3, LifeRefusal::no_placement, 5s) ==
|
||||||
LifeRefusal::no_placement);
|
LifeRefusal::no_placement);
|
||||||
|
const auto pending = reserve(4);
|
||||||
|
CHECK(pending && pending->refusal == LifeRefusal::none);
|
||||||
|
const auto moved = claim_account_control(*db, b, *lease_b, alice, 2, 2, 20000ms, 5s);
|
||||||
|
CHECK(moved);
|
||||||
|
auto moved_result = query_primitive_life(*db, b, *lease_b, alice, moved->generation, 4, 5s);
|
||||||
|
CHECK(moved_result && *moved_result && (**moved_result).reservation.region == 1 &&
|
||||||
|
(**moved_result).reservation.refusal == LifeRefusal::cancelled);
|
||||||
|
const auto cancelled_retry =
|
||||||
|
reserve_primitive_life(*db, b, *lease_b, alice, moved->generation, 4, 1, 5s);
|
||||||
|
CHECK(cancelled_retry && cancelled_retry->refusal == LifeRefusal::cancelled);
|
||||||
CHECK(admin->query("UPDATE evolution.life_allocators SET next_identity=18446744073709551615 "
|
CHECK(admin->query("UPDATE evolution.life_allocators SET next_identity=18446744073709551615 "
|
||||||
"WHERE world_id=9752",
|
"WHERE world_id=9752",
|
||||||
{}, 5s));
|
{}, 5s));
|
||||||
CHECK(failed(reserve(3), LifeReservationError::exhausted));
|
CHECK(failed(reserve_primitive_life(*db, b, *lease_b, alice, moved->generation, 5, 1, 5s),
|
||||||
|
LifeReservationError::exhausted));
|
||||||
const auto moved = claim_account_control(*db, b, *lease_b, alice, 2, 2, 20000ms, 5s);
|
|
||||||
CHECK(moved);
|
|
||||||
CHECK(reserve_primitive_life(*db, b, *lease_b, alice, moved->generation, request, 1, 5s) ==
|
CHECK(reserve_primitive_life(*db, b, *lease_b, alice, moved->generation, request, 1, 5s) ==
|
||||||
*refused);
|
*refused);
|
||||||
CHECK(failed(reject_primitive_life(*db, b, *lease_b, alice, moved->generation, request,
|
|
||||||
LifeRefusal::cancelled, 5s),
|
|
||||||
LifeReservationError::not_available));
|
|
||||||
CHECK(failed(reserve(request), LifeReservationError::fenced));
|
CHECK(failed(reserve(request), LifeReservationError::fenced));
|
||||||
CHECK(release_region_lease(*db, a, *lease_a, 5s));
|
CHECK(release_region_lease(*db, a, *lease_a, 5s));
|
||||||
CHECK(release_region_lease(*db, b, *lease_b, 5s));
|
CHECK(release_region_lease(*db, b, *lease_b, 5s));
|
||||||
|
|||||||
@@ -400,9 +400,15 @@ void session_codec() {
|
|||||||
CHECK(std::get<SessionIntention>(*decode_session(encode_session(intent))) == intent);
|
CHECK(std::get<SessionIntention>(*decode_session(encode_session(intent))) == intent);
|
||||||
const ActionOutcome outcome{5, ActionResult::not_committed, 0, 0};
|
const ActionOutcome outcome{5, ActionResult::not_committed, 0, 0};
|
||||||
CHECK(std::get<ActionOutcome>(*decode_session(encode_session(outcome))) == outcome);
|
CHECK(std::get<ActionOutcome>(*decode_session(encode_session(outcome))) == outcome);
|
||||||
const std::array<SessionMessage, 4> life_messages{
|
const std::array<SessionMessage, 8> life_messages{
|
||||||
PrimitiveLifeRequest{7, 8, 9}, PrimitiveLifeReceipt{9, AdmitStatus::admitted, 10},
|
PrimitiveLifeRequest{7, 8, 9},
|
||||||
PrimitiveLifeOutcome{9, PrimitiveLifeResult::born, 11, 12}, PrimitiveLifeQuery{9}};
|
PrimitiveLifeReceipt{9, AdmitStatus::admitted, 10},
|
||||||
|
PrimitiveLifeOutcome{9, PrimitiveLifeResult::born, 11, 12},
|
||||||
|
PrimitiveLifeOutcome{9, PrimitiveLifeResult::existing_life, 0, 0},
|
||||||
|
PrimitiveLifeOutcome{9, PrimitiveLifeResult::cancelled, 0, 0},
|
||||||
|
PrimitiveLifeOutcome{9, PrimitiveLifeResult::pending, 0, 0},
|
||||||
|
PrimitiveLifeOutcome{9, PrimitiveLifeResult::unknown, 0, 0},
|
||||||
|
PrimitiveLifeQuery{9}};
|
||||||
for (const auto& message : life_messages) {
|
for (const auto& message : life_messages) {
|
||||||
const auto bytes = encode_session(message);
|
const auto bytes = encode_session(message);
|
||||||
std::uint16_t version{};
|
std::uint16_t version{};
|
||||||
|
|||||||
@@ -199,6 +199,11 @@ void run_primitive_publication_tests() {
|
|||||||
auto bindings = db->query("SELECT * FROM evolution.load_primitive_lives(9753,1)", {}, 5s);
|
auto bindings = db->query("SELECT * FROM evolution.load_primitive_lives(9753,1)", {}, 5s);
|
||||||
CHECK(bindings && bindings->size() == 1 && (*bindings)[0][2] == "1" &&
|
CHECK(bindings && bindings->size() == 1 && (*bindings)[0][2] == "1" &&
|
||||||
(*bindings)[0][5] == "1");
|
(*bindings)[0][5] == "1");
|
||||||
|
const auto durable_outcome =
|
||||||
|
query_primitive_life(*db, key, *lease, alice, control->generation, 1, 5s);
|
||||||
|
CHECK(durable_outcome && *durable_outcome && (**durable_outcome).published &&
|
||||||
|
(**durable_outcome).published->identity == 1 &&
|
||||||
|
(**durable_outcome).published->commit_sequence == 1);
|
||||||
auto reject = reject_primitive_life(*db, key, *lease, alice, control->generation, 1,
|
auto reject = reject_primitive_life(*db, key, *lease, alice, control->generation, 1,
|
||||||
LifeRefusal::cancelled, 5s);
|
LifeRefusal::cancelled, 5s);
|
||||||
CHECK(!reject && reject.error().kind == LifeReservationError::existing_life);
|
CHECK(!reject && reject.error().kind == LifeReservationError::existing_life);
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ void upgrade_across_migration_and_barrier() {
|
|||||||
" -v migration_sha_14=$(s 0014_probe_overdue.sql)"
|
" -v migration_sha_14=$(s 0014_probe_overdue.sql)"
|
||||||
" -v migration_sha_15=$(s 0015_life_reservations.sql)"
|
" -v migration_sha_15=$(s 0015_life_reservations.sql)"
|
||||||
" -v migration_sha_16=$(s 0016_primitive_publication.sql)"
|
" -v migration_sha_16=$(s 0016_primitive_publication.sql)"
|
||||||
|
" -v migration_sha_17=$(s 0017_life_request_outcomes.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");
|
||||||
|
|||||||
@@ -69,7 +69,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
|
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
|
||||||
# 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%% *}"
|
||||||
@@ -90,7 +90,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")" = 16:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
|
test "$(PGDATABASE=v3_commits psql -XAtc "SELECT count(*) || ':' || string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 17:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
|
||||||
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.
|
||||||
@@ -144,7 +144,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
|
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
|
||||||
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
|
||||||
# Inherited privileges bypass fencing, so every migrate run audits effective rights.
|
# Inherited privileges bypass fencing, so every migrate run audits effective rights.
|
||||||
@@ -189,9 +189,9 @@ expect_audit_failure 'GRANT SELECT ON evolution.account_controls TO evo_runtime_
|
|||||||
expect_audit_failure 'REVOKE EXECUTE ON FUNCTION evolution.claim_account_control(evolution.u64, evolution.u64, uuid, evolution.u64, uuid, evolution.u64, evolution.u64, integer) FROM evo_runtime_test' 'GRANT EXECUTE ON FUNCTION evolution.claim_account_control(evolution.u64, evolution.u64, uuid, evolution.u64, uuid, evolution.u64, evolution.u64, integer) TO evo_runtime_test'
|
expect_audit_failure 'REVOKE EXECUTE ON FUNCTION evolution.claim_account_control(evolution.u64, evolution.u64, uuid, evolution.u64, uuid, evolution.u64, evolution.u64, integer) FROM evo_runtime_test' 'GRANT EXECUTE ON FUNCTION evolution.claim_account_control(evolution.u64, evolution.u64, uuid, evolution.u64, uuid, evolution.u64, evolution.u64, integer) TO evo_runtime_test'
|
||||||
bash "$root/tools/migrate-postgres.sh" # Restored configuration passes the audit again.
|
bash "$root/tools/migrate-postgres.sh" # Restored configuration passes the audit again.
|
||||||
# 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=17 WHERE version=16'
|
psql -X -v ON_ERROR_STOP=1 -c 'UPDATE evolution.schema_migrations SET version=18 WHERE version=17'
|
||||||
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=16 WHERE version=17"
|
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET version=17 WHERE version=18"
|
||||||
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"
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ SQL
|
|||||||
[ "$code" != 0 ] && grep -q 'division by zero' "$work/migration.log" || fail "the rehearsal migration did not fail"
|
[ "$code" != 0 ] && grep -q 'division by zero' "$work/migration.log" || fail "the rehearsal migration did not fail"
|
||||||
[ "$(q -c "SELECT count(*) FROM information_schema.columns WHERE table_name = 'region_commits' AND column_name = 'rehearsal_column'")" = 0 ] ||
|
[ "$(q -c "SELECT count(*) FROM information_schema.columns WHERE table_name = 'region_commits' AND column_name = 'rehearsal_column'")" = 0 ] ||
|
||||||
fail "the failed migration left a column"
|
fail "the failed migration left a column"
|
||||||
[ "$(q -c 'SELECT max(version) FROM evolution.schema_migrations')" = 16 ] || fail "schema version moved"
|
[ "$(q -c 'SELECT max(version) FROM evolution.schema_migrations')" = 17 ] || fail "schema version moved"
|
||||||
wait_ack "$work/b1.log" $((before + 40)) || fail "b1 did not resume after the failed migration"
|
wait_ack "$work/b1.log" $((before + 40)) || fail "b1 did not resume after the failed migration"
|
||||||
kill -0 "$b1_pid" 2> /dev/null || fail "b1 exited during the failed migration"
|
kill -0 "$b1_pid" 2> /dev/null || fail "b1 exited during the failed migration"
|
||||||
bash "$root/tools/migrate-postgres.sh" > /dev/null || fail "migrate after the failure"
|
bash "$root/tools/migrate-postgres.sh" > /dev/null || fail "migrate after the failure"
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ digest_15="$(sha256sum "$root/migrations/0015_life_reservations.sql")"
|
|||||||
digest_15="${digest_15%% *}"
|
digest_15="${digest_15%% *}"
|
||||||
digest_16="$(sha256sum "$root/migrations/0016_primitive_publication.sql")"
|
digest_16="$(sha256sum "$root/migrations/0016_primitive_publication.sql")"
|
||||||
digest_16="${digest_16%% *}"
|
digest_16="${digest_16%% *}"
|
||||||
|
digest_17="$(sha256sum "$root/migrations/0017_life_request_outcomes.sql")"
|
||||||
|
digest_17="${digest_17%% *}"
|
||||||
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" \
|
||||||
@@ -53,5 +55,6 @@ psql -X --no-password --set=ON_ERROR_STOP=1 --set="migration_sha=$digest" \
|
|||||||
--set="migration_sha_14=$digest_14" \
|
--set="migration_sha_14=$digest_14" \
|
||||||
--set="migration_sha_15=$digest_15" \
|
--set="migration_sha_15=$digest_15" \
|
||||||
--set="migration_sha_16=$digest_16" \
|
--set="migration_sha_16=$digest_16" \
|
||||||
|
--set="migration_sha_17=$digest_17" \
|
||||||
--set="runtime_role=$runtime_role" \
|
--set="runtime_role=$runtime_role" \
|
||||||
--file="$root/migrations/apply.sql"
|
--file="$root/migrations/apply.sql"
|
||||||
|
|||||||
Reference in New Issue
Block a user