Implement M7.4a checkpoint publication and verified recovery
ADR-0061 publishes environmental-v1 full checkpoints. Manifest v1 is a fixed 280-byte record (identity, chain, lease, versions, build, zero RNG/history declarations, durability policy, payload length/SHA-256) that PostgreSQL parses and digests itself. Schema v3 adds region_commits with a digest CHECK and a composite head FK, owner-managed retained builds, fenced publish/load functions and owner-only genesis; it drops the bare v2 head kernel and fails closed while v2 heads exist. Linux evo::region_store adds OpenSSL SHA-256, an immutable content-addressed filesystem object store (temp+fsync+link, no overwrite/delete, O_NOFOLLOW exact-length verified reads), and publication (validate -> upload -> read back -> fenced transaction -> receipt check) and recovery (re-digest, allowlist, verify, full restore). Portable evo::region_checkpoint holds the codec and payload validation. Validated: Windows CTest 56/56; WSL Release, clang-tidy and ASan/UBSan private-PostgreSQL suites; four SQL and one host mutation each caught. M7.4 stays open for 7.4b (lineage archive codec and history binding). No Docker/Gitea CI, remote store, process kill or deployment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -68,7 +68,7 @@ every role transitively in it, and rolls back on any violation:
|
||||
`pg_write_all_data`);
|
||||
- any table privilege in `evolution`, including via PUBLIC;
|
||||
- CREATE on the schema, the database or `public`;
|
||||
- EXECUTE outside the five fenced functions.
|
||||
- EXECUTE outside the six fenced functions (schema v3).
|
||||
Attribute checks alone are not enough: a login with `pg_write_all_data` can update
|
||||
lease rows directly. Rerun the migrate Job after adding or changing runtime logins
|
||||
or grants; it is the audit. Grants made later without a rerun are not detected. Bootstrap revokes PUBLIC access to the schema, tables and
|
||||
@@ -77,20 +77,41 @@ never creates logins or passwords, and never grants superuser.
|
||||
|
||||
## Fenced region ownership (schema v2, ADR-0060)
|
||||
|
||||
The runtime role has schema USAGE and EXECUTE on five SECURITY DEFINER functions:
|
||||
`acquire_region_lease`, `renew_region_lease`, `release_region_lease`,
|
||||
`load_region_head` and `advance_region_head`. It cannot read or write tables, create
|
||||
objects, call `check_region_lease` or provision regions. Each mutation locks the lease row
|
||||
In schema v3 the runtime role has schema USAGE and EXECUTE on six SECURITY DEFINER
|
||||
functions: `acquire_region_lease`, `renew_region_lease`, `release_region_lease`,
|
||||
`load_region_head`, `publish_region_checkpoint` and `load_region_checkpoint`. It
|
||||
cannot read or write tables, create objects, call internal check/parse functions or
|
||||
provision regions. (Schema v2's `advance_region_head` is dropped in v3.) Each mutation locks the lease row
|
||||
and checks holder, epoch and expiry with `clock_timestamp()` after the lock wait.
|
||||
Clients never send times. Rejections: EVL01 busy, EVL02 fenced, EVL03 head mismatch,
|
||||
EVL04 not provisioned, EVL05 epoch/sequence exhausted, 22023 invalid arguments.
|
||||
`evo::postgres` maps them to `LeaseStoreError`; a timeout or broken connection is
|
||||
`unknown`.
|
||||
EVL04 not provisioned, EVL05 epoch/sequence exhausted, EVL06 unsupported
|
||||
profile/version/build or a changed rules/quantum, EVL07 reused commit ID, and 22023
|
||||
malformed arguments or manifest. `evo::postgres` maps them to `LeaseStoreError`; a
|
||||
timeout or broken connection is `unknown`.
|
||||
|
||||
Genesis is operator-only (owner login), never done by recovery or runtime:
|
||||
`SELECT evolution.provision_region(world, region, frame, genesis_commit_uuid,
|
||||
'\x<64 hex digest>');`. In schema v2 the head is an identity/digest pointer with no
|
||||
payload binding. Do not provision real world state before M7.4 publication.
|
||||
## Checkpoint publication (schema v3, ADR-0061)
|
||||
|
||||
Each commit row stores the exact 280-byte manifest, and a constraint ties the
|
||||
commit digest to `sha256(manifest)`. The head has a composite foreign key to its
|
||||
commit, so even the owner cannot silently repoint or edit it.
|
||||
|
||||
Payloads are immutable files under a trusted object root:
|
||||
`<root>/w<world>/r<region>/<sha256 hex>`, mode 0700 directories and 0600 files.
|
||||
Mount a dedicated volume that only the region host's user can write. Nothing is
|
||||
ever deleted; orphans from failed transactions are expected.
|
||||
|
||||
Operator steps:
|
||||
1. Record each promoted build (image digest, 32 bytes) before a host uses it:
|
||||
`INSERT INTO evolution.retained_builds(build_identity) VALUES ('\x<64 hex>');`
|
||||
2. Provision genesis only through `provision_environmental_region` on an owner
|
||||
connection. It uploads and verifies the tick-0 payload, then calls the
|
||||
owner-only `provision_region_checkpoint(manifest)`.
|
||||
|
||||
There is no operator CLI for provisioning yet, and no real world has been
|
||||
provisioned. Migrating v2→v3 fails closed if any v2 head exists, because v2 heads
|
||||
have no payload.
|
||||
|
||||
## Host lease discipline
|
||||
|
||||
Hosts use `LeaseAuthority` with `LeasePolicy` defaults: 20 s lease, 5 s renewal
|
||||
interval, 2 s safety margin, 2 s renewal deadline and 5 s commit deadline. The
|
||||
|
||||
Reference in New Issue
Block a user