Files
dingoandClaude Opus 5.5 ab4bf5355f Fix object reuse durability and refuse unsafe pre-v5 upgrades
Review P1 (object durability): a name installed by a put whose directory
fsync failed was later reused as success without syncing again, so a
publication could acknowledge an object that might vanish on power
loss. Reuse (existing and lost-link-race paths) now fsyncs the verified
file and the directory before succeeding, and namespace opens always
sync their parent. A test-only ObjectStoreFaults hook injects directory
sync failures; tests cover failed sync then retries, namespace creation
syncs, and publication refusing to proceed until durability holds.

Review P1 (pre-v5 history): v5 recovery requires one durable decision
per terminal actor, but v3/v4 published checkpoints carry none, so an
accepted upgrade could make regions unrecoverable. pre_v5_guard.sql now
runs before 0005 in every upgrade path and refuses (EVL10) when any
published pre-v5 checkpoint exists; genesis-only regions pass. 0005 is
unchanged. CI publishes a real v4 checkpoint and proves the upgrade is
refused with nothing changed; a committed death without a decision is
shown to recover as quarantined history.

Validated: PostgreSQL suites Release x3, clang-tidy, ASan/UBSan x2;
reverting each fix is caught by its test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 19:20:35 -04:00

18 lines
942 B
SQL

-- Runs inside apply.sql's transaction immediately before 0005 (ADR-0063). Not a
-- migration and not recorded in history; it only refuses an unsafe upgrade.
--
-- Pre-v5 published checkpoints (sequence > 0) may hold organisms that died with no
-- durable decision row, because decisions did not exist before v5. The database
-- cannot inspect payloads to prove otherwise, and v5 recovery requires one
-- decision per terminal actor, so accepting them would make those regions
-- unrecoverable (RecoveryError::history). Genesis-only regions are safe: a tick-0
-- state has no terminal organisms. Until an explicit, verified legacy-history
-- conversion exists, refuse and change nothing.
DO $$
BEGIN
IF EXISTS (SELECT 1 FROM evolution.region_commits WHERE commit_sequence > 0) THEN
RAISE EXCEPTION 'pre-v5 published checkpoints lack durable decisions; convert or re-provision before v5'
USING ERRCODE = 'EVL10';
END IF;
END $$;