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>
24 lines
1.4 KiB
PL/PgSQL
24 lines
1.4 KiB
PL/PgSQL
-- 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');
|