Complete M7.7 recovery verification before readiness
ADR-0065: before any readiness, recovery now verifies the head's tail. The trace object must exist with its manifest digest, its header must bind profile, region, predecessor and range; the predecessor (schema v6 load_region_commit) must hash to the digest the head names; replaying the trace from the predecessor's verified payload must reproduce every report and the exact head bytes; and trace-derived decisions must equal the head's durable decisions. Missing, corrupt or non-reproducing tails quarantine (RecoveryError::tail); nothing older or empty is served. Test-only crash seams (HostConfig::crash_hook, PublishHooks) and evo-server --crash-at deliver real SIGKILL at before-upload, before-transaction, after-commit and after-ack. The kill matrix, a SIGSTOP/SIGCONT stale owner and damaged-head startups all behave as the durability contract requires; successors verify before readiness. Validated: PostgreSQL suites under GCC Release, clang-tidy and ASan/UBSan; tail-skip and replay-equality mutations each caught. No Docker/Gitea CI, production-lease kill test or deployment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
-- M7.7 recovery tail verification (ADR-0065): read any committed link of a region
|
||||
-- by sequence, so recovery can replay the head's trace from its predecessor.
|
||||
-- Read-only; returns nothing a runtime could not already derive from the chain.
|
||||
CREATE FUNCTION evolution.load_region_commit(p_world evolution.u64, p_region evolution.u64,
|
||||
p_sequence evolution.u64)
|
||||
RETURNS TABLE (region_frame evolution.u64, commit_sequence evolution.u64, commit_id uuid,
|
||||
commit_digest text, end_tick evolution.u64, manifest text)
|
||||
LANGUAGE plpgsql STABLE SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS $$
|
||||
BEGIN
|
||||
RETURN QUERY SELECT l.frame_id, c.commit_sequence, c.commit_id, encode(c.commit_digest, 'hex'),
|
||||
c.end_tick, encode(c.manifest, 'hex')
|
||||
FROM evolution.region_commits c
|
||||
JOIN evolution.region_leases l USING (world_id, region_id)
|
||||
WHERE c.world_id = p_world AND c.region_id = p_region AND c.commit_sequence = p_sequence;
|
||||
IF NOT FOUND THEN
|
||||
RAISE EXCEPTION 'no such commit' USING ERRCODE = 'EVL04';
|
||||
END IF;
|
||||
END $$;
|
||||
REVOKE ALL ON FUNCTION evolution.load_region_commit(evolution.u64, evolution.u64, evolution.u64)
|
||||
FROM PUBLIC;
|
||||
GRANT EXECUTE ON FUNCTION evolution.load_region_commit(evolution.u64, evolution.u64, evolution.u64)
|
||||
TO :"runtime_role";
|
||||
INSERT INTO evolution.schema_migrations(version, sha256) VALUES (6, :'migration_sha_6');
|
||||
+15
-4
@@ -24,26 +24,35 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
||||
|| ',3:' || :'migration_sha_3' || ',4:' || :'migration_sha_4' AS at_v4,
|
||||
:'history' = '1:' || :'migration_sha' || ',2:' || :'migration_sha_2'
|
||||
|| ',3:' || :'migration_sha_3' || ',4:' || :'migration_sha_4'
|
||||
|| ',5:' || :'migration_sha_5' AS at_v5 \gset
|
||||
\if :at_v5
|
||||
|| ',5:' || :'migration_sha_5' AS at_v5,
|
||||
:'history' = '1:' || :'migration_sha' || ',2:' || :'migration_sha_2'
|
||||
|| ',3:' || :'migration_sha_3' || ',4:' || :'migration_sha_4'
|
||||
|| ',5:' || :'migration_sha_5' || ',6:' || :'migration_sha_6' AS at_v6 \gset
|
||||
\if :at_v6
|
||||
\elif :at_v5
|
||||
\ir 0006_commit_lookup.sql
|
||||
\elif :at_v4
|
||||
\ir pre_v5_guard.sql
|
||||
\ir 0005_batch_decisions.sql
|
||||
\ir 0006_commit_lookup.sql
|
||||
\elif :at_v3
|
||||
\ir 0004_lineage_profile.sql
|
||||
\ir pre_v5_guard.sql
|
||||
\ir 0005_batch_decisions.sql
|
||||
\ir 0006_commit_lookup.sql
|
||||
\elif :at_v2
|
||||
\ir 0003_region_checkpoints.sql
|
||||
\ir 0004_lineage_profile.sql
|
||||
\ir pre_v5_guard.sql
|
||||
\ir 0005_batch_decisions.sql
|
||||
\ir 0006_commit_lookup.sql
|
||||
\elif :at_v1
|
||||
\ir 0002_region_fencing.sql
|
||||
\ir 0003_region_checkpoints.sql
|
||||
\ir 0004_lineage_profile.sql
|
||||
\ir pre_v5_guard.sql
|
||||
\ir 0005_batch_decisions.sql
|
||||
\ir 0006_commit_lookup.sql
|
||||
\else
|
||||
\echo 'Unknown or changed migration history'
|
||||
DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$;
|
||||
@@ -55,6 +64,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
||||
\ir 0004_lineage_profile.sql
|
||||
\ir pre_v5_guard.sql
|
||||
\ir 0005_batch_decisions.sql
|
||||
\ir 0006_commit_lookup.sql
|
||||
\endif
|
||||
-- Effective-privilege audit on every run, including no-ops (ADR-0060). Attributes
|
||||
-- alone are insufficient: predefined roles such as pg_write_all_data, PUBLIC
|
||||
@@ -84,7 +94,8 @@ BEGIN
|
||||
('evolution.resolve_region_commit(evolution.u64,evolution.u64,uuid,bytea,bytea)'::regprocedure::oid),
|
||||
('evolution.load_region_decisions(evolution.u64,evolution.u64)'::regprocedure::oid),
|
||||
('evolution.pending_region_outbox(evolution.u64,evolution.u64,integer)'::regprocedure::oid),
|
||||
('evolution.acknowledge_region_outbox(evolution.u64,evolution.u64,integer,integer,evolution.u64)'::regprocedure::oid)
|
||||
('evolution.acknowledge_region_outbox(evolution.u64,evolution.u64,integer,integer,evolution.u64)'::regprocedure::oid),
|
||||
('evolution.load_region_commit(evolution.u64,evolution.u64,evolution.u64)'::regprocedure::oid)
|
||||
), violations(role_oid, reason) AS (
|
||||
SELECT r.oid, 'privileged attribute or owner identity' FROM pg_catalog.pg_roles r
|
||||
JOIN closure c ON c.oid = r.oid
|
||||
@@ -108,7 +119,7 @@ BEGIN
|
||||
OR EXISTS (SELECT 1 FROM pg_catalog.pg_namespace n WHERE n.nspname = 'public'
|
||||
AND pg_catalog.has_schema_privilege(c.oid, n.oid, 'CREATE'))
|
||||
UNION ALL
|
||||
-- Only the ten guarded functions are executable; provisioning/internal are not.
|
||||
-- Only the eleven guarded functions are executable; provisioning/internal are not.
|
||||
SELECT c.oid, 'EXECUTE outside the fenced function set' FROM closure c
|
||||
CROSS JOIN pg_catalog.pg_proc p
|
||||
WHERE p.pronamespace = 'evolution'::regnamespace
|
||||
|
||||
Reference in New Issue
Block a user