M12.7: bind census evidence to database history domains
Foundation / checks (ecs) (push) Successful in 2m23s
Foundation / checks (deploy) (push) Successful in 4m10s
Foundation / checks (network) (push) Successful in 21m32s
Foundation / checks (client) (push) Successful in 22m14s
Foundation / checks (tsan) (push) Successful in 24m30s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 41m43s
Foundation / checks (postgres) (push) Canceled after 41m39s
Foundation / checks (ecs) (push) Successful in 2m23s
Foundation / checks (deploy) (push) Successful in 4m10s
Foundation / checks (network) (push) Successful in 21m32s
Foundation / checks (client) (push) Successful in 22m14s
Foundation / checks (tsan) (push) Successful in 24m30s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (checks) (push) Canceled after 41m43s
Foundation / checks (postgres) (push) Canceled after 41m39s
This commit is contained in:
@@ -142,8 +142,11 @@ capture declared current heads in one short database snapshot, then fully replay
|
|||||||
the immutable cuts; concurrent atomic migration cannot split a selected pair.
|
the immutable cuts; concurrent atomic migration cannot split a selected pair.
|
||||||
Schema 50's [registered-region coverage](schemas/ecology/registered-world-census-coverage-v1.md)
|
Schema 50's [registered-region coverage](schemas/ecology/registered-world-census-coverage-v1.md)
|
||||||
requires every region in the durable authority registry, including unavailable
|
requires every region in the durable authority registry, including unavailable
|
||||||
owners, within the same selected database view. Complete world/branch reconciliation,
|
owners, within the same selected database view. Schema 51's
|
||||||
client queries and terminal extinction remain later gates.
|
[history domain](schemas/ecology/database-history-domain-v1.md) identifies that
|
||||||
|
database history and forks supported restores with parent/exact-cut provenance.
|
||||||
|
Complete world/branch reconciliation, client queries and terminal extinction
|
||||||
|
remain later gates.
|
||||||
`apps/evo-sim` owns CLI/file I/O
|
`apps/evo-sim` owns CLI/file I/O
|
||||||
and reporting. `tests` holds contract,
|
and reporting. `tests` holds contract,
|
||||||
fuzz and measurement programs. `src/server/lifecycle` owns funded primitive
|
fuzz and measurement programs. `src/server/lifecycle` owns funded primitive
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
# Project status and next steps
|
# Project status and next steps
|
||||||
|
|
||||||
|
## M12.7b database history domains and restore provenance - 2026-10-18
|
||||||
|
|
||||||
|
Schema 51 binds registered census evidence to a database history-domain UUID,
|
||||||
|
captured with the registry and heads. Supported restores create a fresh domain
|
||||||
|
before verification/readmission, retaining the parent, restore claim and exact
|
||||||
|
restored cuts. Biological identities/bytes stay unchanged. Legacy backups have
|
||||||
|
unknown original context and acquire adoption only when migrated.
|
||||||
|
|
||||||
|
Default Release CTest **79/79**, focused domain/legacy-restore qualification,
|
||||||
|
ASan/UBSan TLS/storage faults, Clang analysis and formatting pass. Full private
|
||||||
|
persistence/process/backup/DR and migration/permissions qualification passed in
|
||||||
|
**558 s** after correcting an incomplete frozen-helper directory. Results and
|
||||||
|
limits are recorded in [validation](engineering/VALIDATION.md).
|
||||||
|
Cross-domain clone provenance, other viable stores, durable accepted extinction,
|
||||||
|
client access and ecology/soak/product gates remain open; this is not complete M12.
|
||||||
|
|
||||||
## M12.7a registered-world census coverage - 2026-10-18
|
## M12.7a registered-world census coverage - 2026-10-18
|
||||||
|
|
||||||
Schema 50 now uses the durable authority registry as the required regional set
|
Schema 50 now uses the durable authority registry as the required regional set
|
||||||
|
|||||||
@@ -65,3 +65,9 @@ the world ID; external branch identity is still missing. Outside/unsupported sto
|
|||||||
viable reserves, durable accepted reconciliation records and global freshness remain
|
viable reserves, durable accepted reconciliation records and global freshness remain
|
||||||
M12.7 work. No terminal-extinction outcome, client endpoint, live database,
|
M12.7 work. No terminal-extinction outcome, client endpoint, live database,
|
||||||
deployment or World0 action.
|
deployment or World0 action.
|
||||||
|
|
||||||
|
Schema-51 follow-up: [ADR-0155](0155-database-history-domain.md) adds a database
|
||||||
|
history domain to registered results in the same metadata view and forks supported
|
||||||
|
restores with parent/exact-cut provenance. Cross-domain clone provenance and the
|
||||||
|
other reconciliation limits above remain open; registered coverage alone still
|
||||||
|
does not authorize terminal extinction.
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
# ADR-0155: Database history domains for census and restore evidence
|
||||||
|
|
||||||
|
## Status
|
||||||
|
|
||||||
|
Accepted for scoped M12.7b, 2026-10-18. Extends ADR-0133/0153/0154 and the
|
||||||
|
supported ADR-0074/0075 restore workflow. This is an evidence namespace, not a
|
||||||
|
new biological identity, codec, simulation version or terminal-extinction rule.
|
||||||
|
|
||||||
|
## Context and decision
|
||||||
|
|
||||||
|
World IDs and exact immutable commits can be reused by a database restored from
|
||||||
|
a backup. Independently initialized databases can also use the same world IDs.
|
||||||
|
Neither a connection address nor an object path establishes evolutionary history.
|
||||||
|
|
||||||
|
Schema 51 adopts one random, nonzero UUID **history domain per database**, using
|
||||||
|
PostgreSQL's built-in UUID generator. External evidence identifies a world by
|
||||||
|
`(history_domain, world_id)`. Adoption means this database's retained history as
|
||||||
|
observed at migration; it does not reconstruct an unknown earlier namespace.
|
||||||
|
Unchanged migrations preserve the domain. Different worlds remain distinct within
|
||||||
|
the domain. No per-tick writes, payload changes, extension or new dependency.
|
||||||
|
|
||||||
|
Keep owner-controlled `history_domains` events, one `current_history_domain` row,
|
||||||
|
and `history_domain_cuts` for restore provenance. The trusted runtime receives only
|
||||||
|
the fixed-search-path security-definer `load_history_domain_v1()` read function;
|
||||||
|
neither table access nor the ability to fork. The migration privilege audit includes
|
||||||
|
both the new required read grant and denial of the owner-only function.
|
||||||
|
|
||||||
|
Registered cellular snapshots capture the domain **before** registry/head reads in
|
||||||
|
the same short read-only repeatable-read transaction. Return it with registry,
|
||||||
|
exact cuts and fully replayed census. Missing/zero/malformed context fails the
|
||||||
|
whole result; a legacy schema fails rather than inferring a domain. Existing
|
||||||
|
caller-declared snapshots and low-level diagnostic history queries retain their
|
||||||
|
local semantics; they do not acquire an external-history guarantee implicitly.
|
||||||
|
Concurrent context changes belong to a later metadata view. Context identifies
|
||||||
|
captured evidence, not current authority or a freshness guarantee at return.
|
||||||
|
|
||||||
|
## Supported restores and legacy backups
|
||||||
|
|
||||||
|
For either isolated or explicitly authorized dev/stage in-place restore, the
|
||||||
|
existing install transaction first restores the dump, retires all builds and
|
||||||
|
clears holders. Before committing that still-quarantined install, call the new
|
||||||
|
owner-only `fork_restored_history_v1(restore_claim_uuid)` when present. It locks
|
||||||
|
the singleton domain row, refuses any admitted build or held lease, creates a
|
||||||
|
fresh domain whose parent is the restored domain, retains the request, and copies
|
||||||
|
all restored heads' world/region/frame/sequence/commit/digest/tick as fork cuts
|
||||||
|
before switching the current domain. Rollback removes the whole fork. Same-request
|
||||||
|
retries return the same current domain without duplicating records; a request from
|
||||||
|
an older fork refuses instead of switching backwards. Lost install receipts keep
|
||||||
|
the existing restore-claim resolution. Biological heads, ancestry and retained
|
||||||
|
objects stay byte-identical. Readmission still waits for head/history verification
|
||||||
|
and, in-place, the full runtime privilege audit.
|
||||||
|
|
||||||
|
A backup predating schema 51 has no source domain. Its restore skips the absent
|
||||||
|
function; later migration adopts a fresh domain with unknown original context.
|
||||||
|
Do not fabricate a parent or exact external branch ancestry. New-schema backups
|
||||||
|
retain the event/cut tables because they dump the entire `evolution` schema.
|
||||||
|
Backup-of-restore forks preserve their known namespace ancestry and exact fork
|
||||||
|
cuts; they do not rewrite biological clone origins or old payloads.
|
||||||
|
|
||||||
|
The operator is trusted and the replacement database must remain isolated during
|
||||||
|
installation/verification. Owner-only SQL is not a new public online branch API.
|
||||||
|
Arbitrary direct `pg_restore`, copying a running database, privileged edits, or
|
||||||
|
readmitting builds outside the supported workflow can copy/forge a domain. No
|
||||||
|
database UUID can detect such a bypass. This contract does not secure an
|
||||||
|
untrusted owner or change fencing, backup durability, deployment or World0 gates.
|
||||||
|
|
||||||
|
## Alternatives, benefits, costs and risks
|
||||||
|
|
||||||
|
Per-world enrollment tables would duplicate the authority registry and complicate
|
||||||
|
legacy adoption. Host/database names are mutable routing, and manifest digests
|
||||||
|
can survive a rewind. Embedding new domains in all biological codecs would change
|
||||||
|
deterministic bytes without changing biology. A database namespace keeps those
|
||||||
|
contracts intact and makes restore provenance explicit at metadata cost
|
||||||
|
proportional to the restored regional head count, once per restore.
|
||||||
|
|
||||||
|
Random UUID uniqueness is probabilistic, using the existing supported PostgreSQL
|
||||||
|
runtime. Trusted workflows must rotate consistently; no claim is made for a copied
|
||||||
|
database outside those workflows. Initial adoption cannot recover missing external
|
||||||
|
history. Retention/GC must preserve these records; no deletion feature is added.
|
||||||
|
|
||||||
|
## Qualification and remaining scope
|
||||||
|
|
||||||
|
Test no-op adoption, quarantine refusal, rollback, exact cuts, idempotent and stale
|
||||||
|
requests, runtime privileges, missing context, concurrent snapshot capture, isolated
|
||||||
|
restore and in-place rewind. Run full persistence/backup/DR/migration checks,
|
||||||
|
sanitizers, analysis/format and the default build. No biological golden changes.
|
||||||
|
|
||||||
|
Cross-domain clone-origin provenance is still incomplete: ADR-0067 commits the
|
||||||
|
source biological cut but does not encode its external history domain. A domain
|
||||||
|
alone cannot supply that missing ancestry. Durable accepted reconciliation must
|
||||||
|
later bind domain, exact cuts, registered coverage, other viable/in-flight stores
|
||||||
|
and acceptance freshness; no terminal extinction or complete M12 gate is claimed.
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
# Architecture decision records
|
# Architecture decision records
|
||||||
|
|
||||||
|
- [ADR-0155: Database history domains](0155-database-history-domain.md) - schema 51 binds registered census evidence to a database namespace; supported quarantined restores retain parent domains and exact fork cuts before readmission. Cross-domain clone provenance and accepted extinction remain open.
|
||||||
|
|
||||||
- [ADR-0154: Registered-world census coverage](0154-registered-world-census-coverage.md) - schema 50 uses the existing durable authority registry as the required regional set in a consistent snapshot; omitted/unavailable/over-bound owners fail without a new catalog table or extinction authority.
|
- [ADR-0154: Registered-world census coverage](0154-registered-world-census-coverage.md) - schema 50 uses the existing durable authority registry as the required regional set in a consistent snapshot; omitted/unavailable/over-bound owners fail without a new catalog table or extinction authority.
|
||||||
|
|
||||||
- [ADR-0153: Consistent scoped cellular census snapshots](0153-consistent-cellular-census-snapshots.md) - short read-only repeatable-read head capture followed by exact immutable replay; atomic pairs cannot straddle a declared-region cut, without claiming world/branch completeness.
|
- [ADR-0153: Consistent scoped cellular census snapshots](0153-consistent-cellular-census-snapshots.md) - short read-only repeatable-read head capture followed by exact immutable replay; atomic pairs cannot straddle a declared-region cut, without claiming world/branch completeness.
|
||||||
|
|||||||
@@ -1,12 +1,21 @@
|
|||||||
# Persistence and region authority
|
# Persistence and region authority
|
||||||
|
|
||||||
|
M12.7b/schema 51 adds [database history domains](../../schemas/ecology/database-history-domain-v1.md).
|
||||||
|
Registered census evidence identifies a world by `(history_domain, world_id)`;
|
||||||
|
domain, registry and heads share one metadata view. Supported restores fork the
|
||||||
|
domain while quarantined in the installation transaction, retaining parent/request
|
||||||
|
and exact restored head cuts before verification/readmission. Initial adoption
|
||||||
|
and legacy backups cannot reconstruct unknown original context. Arbitrary trusted
|
||||||
|
database copies outside that workflow can copy a domain. Cross-domain clone
|
||||||
|
provenance, viable-store reconciliation and durable accepted extinction remain open.
|
||||||
|
|
||||||
M12.7a/schema 50 adds [registered-world coverage](../../schemas/ecology/registered-world-census-coverage-v1.md).
|
M12.7a/schema 50 adds [registered-world coverage](../../schemas/ecology/registered-world-census-coverage-v1.md).
|
||||||
The existing authority registry supplies every required region/frame, without
|
The existing authority registry supplies every required region/frame, without
|
||||||
activity, expiry, profile or checkpoint filters. The bounded read function and
|
activity, expiry, profile or checkpoint filters. The bounded read function and
|
||||||
head selection share one database snapshot; resources must match the entire
|
head selection share one database snapshot; resources must match the entire
|
||||||
registered set. Missing/unusable owners and a 65th region fail the query. There
|
registered set. Missing/unusable owners and a 65th region fail the query. There
|
||||||
is no new catalog table or registration write. External branch identity, other
|
is no new catalog table or registration write. Schema 51 adds the namespace above;
|
||||||
viable stores and accepted global extinction reconciliation remain separate.
|
other viable stores and accepted global extinction reconciliation remain separate.
|
||||||
|
|
||||||
M12.6d captures declared regional heads in one short read-only repeatable-read
|
M12.6d captures declared regional heads in one short read-only repeatable-read
|
||||||
transaction, closes it, then fully replays each exact immutable cut before
|
transaction, closes it, then fully replays each exact immutable cut before
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Commit and push each validated scoped segment separately.
|
|||||||
| 12.4 | Owned intervals and durable paired migration/fault qualification implemented in scoped segments through 12.4l | ADR-0143–0149/schema 49; bounded admitted work, source freeze, staged ghost, atomic pair and exact recovery, local TLS and storage faults. Multi-host/orchestrator, linked ecology and integrated stock audits remain open. |
|
| 12.4 | Owned intervals and durable paired migration/fault qualification implemented in scoped segments through 12.4l | ADR-0143–0149/schema 49; bounded admitted work, source freeze, staged ghost, atomic pair and exact recovery, local TLS and storage faults. Multi-host/orchestrator, linked ecology and integrated stock audits remain open. |
|
||||||
| 12.5 | Blocked on 12.2-12.4 | Finite M6 process fixtures do not qualify coupled persistent cellular/cohort atmosphere/water budgets. |
|
| 12.5 | Blocked on 12.2-12.4 | Finite M6 process fixtures do not qualify coupled persistent cellular/cohort atmosphere/water budgets. |
|
||||||
| 12.6 | Regional queries, replayed history, scoped multi-region queries and consistent database head snapshots implemented (12.6a-d) | ADR-0150–0153; short read-only snapshot capture prevents atomic pairs from straddling declared head sets, with exact immutable replay. Durable world/branch coverage, outside transfer/viability reconciliation, target-host query/index costs and client path remain required. |
|
| 12.6 | Regional queries, replayed history, scoped multi-region queries and consistent database head snapshots implemented (12.6a-d) | ADR-0150–0153; short read-only snapshot capture prevents atomic pairs from straddling declared head sets, with exact immutable replay. Durable world/branch coverage, outside transfer/viability reconciliation, target-host query/index costs and client path remain required. |
|
||||||
| 12.7 | Evidence policy and registered-region coverage implemented (12.7a) | ADR-0154/schema 50 requires the durable authority registry in one consistent database cut. External branch identity, other viable/in-flight stores and durable accepted global reconciliation remain required. |
|
| 12.7 | Evidence policy, registered coverage and database history domains implemented (12.7a-b) | ADR-0154/0155/schema 51 captures namespace/registry/heads together; supported quarantined restores fork with exact-cut provenance. Cross-domain clone provenance, other viable/in-flight stores and durable accepted global reconciliation remain required. |
|
||||||
| 12.8 | Not qualified | Actual multi-day integrated ecology/restart/clone evidence remains required. |
|
| 12.8 | Not qualified | Actual multi-day integrated ecology/restart/clone evidence remains required. |
|
||||||
| 12.9 | Not accepted | Returning-player product evidence and expansion review remain required; World0 stays separately blocked. |
|
| 12.9 | Not accepted | Returning-player product evidence and expansion review remain required; World0 stays separately blocked. |
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ or authorize production enablement.
|
|||||||
| 12.3 | Dedicated population profile/trace/store/owning host; exact recovery and private PostgreSQL fault tests | Population-specific executable/network fault drills and target-host publication/capacity qualification. |
|
| 12.3 | Dedicated population profile/trace/store/owning host; exact recovery and private PostgreSQL fault tests | Population-specific executable/network fault drills and target-host publication/capacity qualification. |
|
||||||
| 12.4 | Owned intervals; exact transfer/accounting; durable atomic pair/recovery; independent loopback TLS path loss and owner expiry/replacement/heal; local object sync/read-failure matrix | Multi-host/kernel-network, storage-host and orchestrator drills, linked-boundary contracts and integrated ownership/stock audits at scale. |
|
| 12.4 | Owned intervals; exact transfer/accounting; durable atomic pair/recovery; independent loopback TLS path loss and owner expiry/replacement/heal; local object sync/read-failure matrix | Multi-host/kernel-network, storage-host and orchestrator drills, linked-boundary contracts and integrated ownership/stock audits at scale. |
|
||||||
| 12.5 | Finite cellular contact feeding/decay and separate M6 producer/consumer resource owner | One jointly owned cellular/environment budget, explicit effective depth and source entitlements, versioned water/atmosphere species mapping and producer coefficients, plus closed/open and nutrient-exhaustion comparisons. |
|
| 12.5 | Finite cellular contact feeding/decay and separate M6 producer/consumer resource owner | One jointly owned cellular/environment budget, explicit effective depth and source entitlements, versioned water/atmosphere species mapping and producer coefficients, plus closed/open and nutrient-exhaustion comparisons. |
|
||||||
| 12.6 | Retained archive, regional census/lineage queries, replayed history, scoped multi-region queries and consistent database head snapshots (12.6a-d); registered coverage follows in 12.7a | External branch history context, retained historical coverage/other viable stores, target-host query/index qualification and client permission/presentation; no account power or invented precise statistical ancestry. |
|
| 12.6 | Retained archive, regional census/lineage queries, replayed history, scoped multi-region queries and consistent database head snapshots (12.6a-d); registered coverage/history domains follow in 12.7a-b | Cross-domain clone provenance, retained historical coverage/other viable stores, target-host query/index qualification and client permission/presentation; no account power or invented precise statistical ancestry. |
|
||||||
| 12.7 | Viability/unknown policy; consistent head cuts and durable registered-region coverage (12.7a/schema 50) | External world/branch context, other viable-store/transfer reconciliation and durable accepted global evidence records. Missing/stale/unsupported owners must prevent terminal extinction. |
|
| 12.7 | Viability/unknown policy; consistent cuts, registered-region coverage and database history domains with supported restore forks (12.7a-b/schema 51) | Cross-domain clone provenance, other viable-store/transfer reconciliation and durable accepted global evidence records. Missing/stale/unsupported owners must prevent terminal extinction. |
|
||||||
| 12.8 | Deterministic seed/regime drivers and separate-process exact continuation | Reproducible integrated worlds running for actual days, real restarts/clone comparisons and retained accounting/diversity/cost audits. Accelerated tests cannot supply elapsed days. |
|
| 12.8 | Deterministic seed/regime drivers and separate-process exact continuation | Reproducible integrated worlds running for actual days, real restarts/clone comparisons and retained accounting/diversity/cost audits. Accelerated tests cannot supply elapsed days. |
|
||||||
| 12.9 | M11 feedback and current UI review retained | Returning-player samples on the integrated ecology and explicit product/3D readiness decision after soak evidence. No M12 product acceptance or World0 promotion is inferred. |
|
| 12.9 | M11 feedback and current UI review retained | Returning-player samples on the integrated ecology and explicit product/3D readiness decision after soak evidence. No M12 product acceptance or World0 promotion is inferred. |
|
||||||
|
|
||||||
@@ -127,8 +127,16 @@ same database snapshot. Every registered region is required, including inactive,
|
|||||||
expired, unsupported and unavailable owners. Unknown worlds and a 65th region
|
expired, unsupported and unavailable owners. Unknown worlds and a 65th region
|
||||||
fail rather than becoming zero or a truncated complete set. Concurrent later
|
fail rather than becoming zero or a truncated complete set. Concurrent later
|
||||||
enrollment belongs to a later cut. No duplicate catalog/enrollment write is added.
|
enrollment belongs to a later cut. No duplicate catalog/enrollment write is added.
|
||||||
External branch identity, other viable stores and durable accepted reconciliation
|
That registered-coverage primitive alone does not identify external history or
|
||||||
records remain open; this does not close M12.7 or authorize terminal extinction.
|
authorize terminal extinction.
|
||||||
|
|
||||||
|
M12.7b/schema 51's [history domain](../../schemas/ecology/database-history-domain-v1.md)
|
||||||
|
now binds registered results to a database namespace in the same metadata view.
|
||||||
|
Supported restores fork before verification/readmission and retain parent/request
|
||||||
|
and exact restored cuts. Initial adoption and legacy backups cannot recover
|
||||||
|
unknown original context; direct privileged database copies can bypass the
|
||||||
|
workflow. Cross-domain clone provenance, other viable/in-flight stores and durable
|
||||||
|
accepted reconciliation remain open. This still does not close M12.7.
|
||||||
|
|
||||||
Current expansion readiness: **no-go for M13 integration or World0 promotion**
|
Current expansion readiness: **no-go for M13 integration or World0 promotion**
|
||||||
while these M12 integration/evidence gates remain open. This records the present
|
while these M12 integration/evidence gates remain open. This records the present
|
||||||
|
|||||||
@@ -1,5 +1,14 @@
|
|||||||
# Validation strategy
|
# Validation strategy
|
||||||
|
|
||||||
|
M12.7b/schema 51 checks database-domain adoption/no-op stability, restore-only
|
||||||
|
quarantine, transaction rollback, exact fork cuts, idempotent/stale requests and
|
||||||
|
runtime read-only privileges. Registered snapshots retain their domain during an
|
||||||
|
independent metadata change; the next query sees the new context even with the
|
||||||
|
same manifests. Missing context fails without a partial/zero result. Test actual
|
||||||
|
isolated and in-place restore workflows, lost-install receipt resolution and
|
||||||
|
legacy bundles without context. Run full private persistence/migration/permission
|
||||||
|
regression, default CTest, ASan/UBSan, Clang analysis/format and shell syntax.
|
||||||
|
|
||||||
M12.7a's schema-50 tests require exact authority-registry coverage, including
|
M12.7a's schema-50 tests require exact authority-registry coverage, including
|
||||||
released/expired holders, unavailable heads and unsupported profiles. Check
|
released/expired holders, unavailable heads and unsupported profiles. Check
|
||||||
omitted/extra/duplicate resources, wrong frames, unknown worlds, integral numeric
|
omitted/extra/duplicate resources, wrong frames, unknown worlds, integral numeric
|
||||||
|
|||||||
@@ -1,5 +1,81 @@
|
|||||||
# Validation report
|
# Validation report
|
||||||
|
|
||||||
|
## 2026-10-18 - M12.7b database history domains and restore provenance
|
||||||
|
|
||||||
|
[ADR-0155](../adr/0155-database-history-domain.md)/schema 51 adds a database
|
||||||
|
history-domain UUID to registered census evidence. The domain, registry and heads
|
||||||
|
share one short metadata snapshot; every exact cut still receives full immutable
|
||||||
|
replay. Supported restores fork the namespace in the quarantined installation
|
||||||
|
transaction, retaining parent/request and exact restored head cuts. Biological
|
||||||
|
payloads, rules, versions, goldens and clone manifests do not change.
|
||||||
|
|
||||||
|
Executed locally:
|
||||||
|
|
||||||
|
- Default MSVC Release build succeeded. Initial sandboxed CTest passed 77/79;
|
||||||
|
filesystem/CLI hard-link fixtures were denied creation. The same 79 tests
|
||||||
|
rerun with normal filesystem rights passed **79/79, 13.60 s**.
|
||||||
|
- GCC 14 Release private population/history/registered-census qualification passed
|
||||||
|
**exit 0, 19 s**, including the original context capture/missing-context cases.
|
||||||
|
- Final Clang 19 **ASan/UBSan** population/history/census, migration, loopback TLS
|
||||||
|
request/reply loss and local storage-fault matrix passed **exit 0, 71 s**
|
||||||
|
(67 s population phase), without sanitizer reports.
|
||||||
|
- Focused private SQL qualification passed **exit 0, 8 s**, including domain
|
||||||
|
adoption/no-op stability, current-build/held-lease refusal, rollback, exact fork
|
||||||
|
cuts, idempotent and stale requests, runtime table/function denial, and actual
|
||||||
|
pre-context backups restored through isolated and in-place workflows. Those
|
||||||
|
legacy cases retain unknown original context; in-place migration adopts a
|
||||||
|
fresh domain without invented parent/fork records.
|
||||||
|
- Final clang-tidy 19 passed on the snapshot adapter and both changed integration
|
||||||
|
test files with no owned warnings. Repository clang-format 19, final `bash -n`
|
||||||
|
on all six changed/new shell scripts and `git diff --check` passed. Initial
|
||||||
|
analysis findings were corrected with explicit optional-value validation.
|
||||||
|
|
||||||
|
The first full run exited 1 after **74 s** because the frozen test directory
|
||||||
|
omitted the required `evo-load`/`evo-session-probe` sibling executables, causing
|
||||||
|
the process fixture's spawn failure. The failed log/sentinel are preserved. The
|
||||||
|
complete frozen-binary rerun passed **exit 0, 558 s**: C++ integration/process/
|
||||||
|
load/history **434 s**, migration TLS/storage faults **41 s**, life reservations
|
||||||
|
**4 s**, domain/legacy/backup/restore **31 s**, host-loss DR **7 s**, upgrade
|
||||||
|
**10 s**, migration history **6 s**, runtime permission audit **12 s** and
|
||||||
|
checksum/future-version rejection **8 s**, plus setup/migration. Its completion
|
||||||
|
sentinel records zero and the log contains the final all-phase success summary.
|
||||||
|
Actual schema-51 isolated and in-place restores have different source/current
|
||||||
|
domains with parent/exact-cut provenance. The restore claim binds the new domain
|
||||||
|
already at the post-install, pre-verification/readmission hook. Existing lost-
|
||||||
|
receipt, restart, quarantine and competing-restore cases also pass.
|
||||||
|
|
||||||
|
Snapshot tests change owner-controlled namespace metadata after head capture:
|
||||||
|
the selected result retains the old domain and the next result observes the new
|
||||||
|
domain even though manifests are unchanged. This is a trusted test fault seam,
|
||||||
|
not permission to fork an active environment. Removing the singleton context
|
||||||
|
fails the entire registered query and leaves the connection idle. Real restore
|
||||||
|
quarantine, parent/exact-cut provenance and claim binding are tested separately
|
||||||
|
by the supported backup/DR workflows.
|
||||||
|
|
||||||
|
Schema 51 is additive; prior numbered migrations 1..50 remain unchanged. Migration
|
||||||
|
history expectations now include 51, and unknown-future rejection uses 52. The
|
||||||
|
runtime rights audit requires the getter and rejects grants to the owner-only
|
||||||
|
fork function. No new dependency, worker thread, public client endpoint or live
|
||||||
|
authority is introduced. No new TSan run is claimed for this metadata change.
|
||||||
|
|
||||||
|
Limits: history adoption cannot recover unknown earlier context. Direct privileged
|
||||||
|
database copies/edits outside the supported restore workflow can copy/forge a
|
||||||
|
domain. Cross-domain clone-origin provenance, other viable/in-flight stores,
|
||||||
|
durable accepted reconciliation and complete M12 remain open. No target-host
|
||||||
|
query/capacity claim, remote CI, multi-host drill, actual multi-day soak, product
|
||||||
|
acceptance, live database, deployment or World0 action.
|
||||||
|
|
||||||
|
Logs: `build/m127b-build.log`, `build/m127b-final-build.log`,
|
||||||
|
`build/m127b-final2-build.log`, `build/m127b-native.log`,
|
||||||
|
`build/m127b-native-recheck.log`, `build/m127b-population.log`,
|
||||||
|
`build/m127b-domain-smoke.log`, `build/m127b-domain-smoke-recheck.log`,
|
||||||
|
`build/m127b-domain-final.log`, `build/m127b-domain-validated.log`,
|
||||||
|
`build/m127b-domain-legacy.log`, `build/m127b-final-asan-build.log`,
|
||||||
|
`build/m127b-final-asan.log`, `build/m127b-validated-tidy.log`,
|
||||||
|
`build/m127b-validated-format.log`, `build/m127b-shell.log`,
|
||||||
|
`build/m127b-full.log`, `build/m127b-full.exit`,
|
||||||
|
`build/m127b-full-recheck.log`, `build/m127b-full-recheck.exit` (completion only).
|
||||||
|
|
||||||
## 2026-10-18 - M12.7a registered-world census coverage
|
## 2026-10-18 - M12.7a registered-world census coverage
|
||||||
|
|
||||||
[ADR-0154](../adr/0154-registered-world-census-coverage.md)/schema 50 uses the
|
[ADR-0154](../adr/0154-registered-world-census-coverage.md)/schema 50 uses the
|
||||||
|
|||||||
@@ -80,6 +80,12 @@ a worker recovery test.
|
|||||||
2. Restore the newest verified bundle in place, as the migrator:
|
2. Restore the newest verified bundle in place, as the migrator:
|
||||||
`restore-world.sh --bundle B --objects NEW_VOLUME --in-place --runtime-role ROLE --accept-rewind`.
|
`restore-world.sh --bundle B --objects NEW_VOLUME --in-place --runtime-role ROLE --accept-rewind`.
|
||||||
Record every `REWIND` line: acknowledgements after those ticks are undone.
|
Record every `REWIND` line: acknowledgements after those ticks are undone.
|
||||||
|
Schema-51 bundles also fork the database history domain before readmission;
|
||||||
|
retain the new/parent domains and exact `history_domain_cuts` with the restore
|
||||||
|
claim. External evidence keys worlds by `(history_domain, world_id)`.
|
||||||
|
Older bundles have no original domain: later migration records adoption only.
|
||||||
|
Direct database copies outside this workflow can copy a domain; see
|
||||||
|
[ADR-0155](../adr/0155-database-history-domain.md).
|
||||||
3. Point the environment's connection Secret and object volume at the replacement,
|
3. Point the environment's connection Secret and object volume at the replacement,
|
||||||
then sync the environment's Argo application; the host resumes under a newer epoch.
|
then sync the environment's Argo application; the host resumes under a newer epoch.
|
||||||
4. The moment the old database is reachable (or at once, if it never went away):
|
4. The moment the old database is reachable (or at once, if it never went away):
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ enum class CellularSnapshotError : std::uint8_t {
|
|||||||
transaction,
|
transaction,
|
||||||
history,
|
history,
|
||||||
census,
|
census,
|
||||||
coverage
|
coverage,
|
||||||
|
context
|
||||||
};
|
};
|
||||||
struct RegisteredCellularRegion {
|
struct RegisteredCellularRegion {
|
||||||
std::uint64_t region{}, frame{};
|
std::uint64_t region{}, frame{};
|
||||||
@@ -47,6 +48,7 @@ struct CellularCoverageFailure {
|
|||||||
struct RegisteredCellularCensusSnapshot {
|
struct RegisteredCellularCensusSnapshot {
|
||||||
std::vector<RegisteredCellularRegion> catalog; // Exact registry view used for head selection.
|
std::vector<RegisteredCellularRegion> catalog; // Exact registry view used for head selection.
|
||||||
CellularCensusSnapshot snapshot;
|
CellularCensusSnapshot snapshot;
|
||||||
|
Uuid history_domain{}; // Schema 51 database namespace captured with catalog and heads.
|
||||||
};
|
};
|
||||||
struct CellularSnapshotFailure {
|
struct CellularSnapshotFailure {
|
||||||
CellularSnapshotError kind{};
|
CellularSnapshotError kind{};
|
||||||
@@ -74,12 +76,13 @@ load_cellular_census_snapshot(Postgres&, std::uint64_t world,
|
|||||||
std::span<const Sha256Digest> retained_builds,
|
std::span<const Sha256Digest> retained_builds,
|
||||||
std::chrono::milliseconds timeout,
|
std::chrono::milliseconds timeout,
|
||||||
const CellularCensusSnapshotHooks& hooks = {});
|
const CellularCensusSnapshotHooks& hooks = {});
|
||||||
// Schema 50: require resources for EVERY registered region of this world,
|
// Schema 51: require resources for EVERY registered region of this world,
|
||||||
// including expired/released holders and regions with unavailable checkpoints.
|
// including expired/released holders and regions with unavailable checkpoints.
|
||||||
// Capture the registry and all heads in the SAME short database snapshot.
|
// Capture the registry and all heads in the SAME short database snapshot.
|
||||||
// Empty/over-bound registries or any coverage/frame mismatch fail, never zero.
|
// Empty/over-bound registries or any coverage/frame mismatch fail, never zero.
|
||||||
// Completeness is only for registered regions of this connected database view;
|
// Completeness is only for registered regions of this connected database view;
|
||||||
// no external branch identity, other viable-store reconciliation or extinction.
|
// Domain/world identifies this database history, including supported restore forks.
|
||||||
|
// No other viable-store reconciliation, live authority or terminal extinction.
|
||||||
[[nodiscard]] std::expected<RegisteredCellularCensusSnapshot, CellularSnapshotFailure>
|
[[nodiscard]] std::expected<RegisteredCellularCensusSnapshot, CellularSnapshotFailure>
|
||||||
load_registered_cellular_census_snapshot(Postgres&, std::uint64_t world,
|
load_registered_cellular_census_snapshot(Postgres&, std::uint64_t world,
|
||||||
std::span<const CellularCensusRegionRequest>,
|
std::span<const CellularCensusRegionRequest>,
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
-- Database evidence namespace, not a biological world/format change (ADR-0155).
|
||||||
|
CREATE TABLE evolution.history_domains (
|
||||||
|
domain uuid PRIMARY KEY CHECK (domain <> '00000000-0000-0000-0000-000000000000'),
|
||||||
|
parent uuid REFERENCES evolution.history_domains(domain),
|
||||||
|
request uuid UNIQUE,
|
||||||
|
kind text NOT NULL CHECK (kind IN ('adoption', 'restore')),
|
||||||
|
recorded_at timestamptz NOT NULL DEFAULT pg_catalog.clock_timestamp(),
|
||||||
|
CHECK ((kind = 'adoption' AND parent IS NULL AND request IS NULL) OR
|
||||||
|
(kind = 'restore' AND parent IS NOT NULL AND request IS NOT NULL)),
|
||||||
|
CHECK (parent IS DISTINCT FROM domain),
|
||||||
|
CHECK (request IS NULL OR request <> '00000000-0000-0000-0000-000000000000')
|
||||||
|
);
|
||||||
|
CREATE TABLE evolution.current_history_domain (
|
||||||
|
singleton boolean PRIMARY KEY CHECK (singleton),
|
||||||
|
domain uuid NOT NULL REFERENCES evolution.history_domains(domain)
|
||||||
|
);
|
||||||
|
CREATE TABLE evolution.history_domain_cuts (
|
||||||
|
domain uuid NOT NULL REFERENCES evolution.history_domains(domain),
|
||||||
|
world_id evolution.u64 NOT NULL, region_id evolution.u64 NOT NULL,
|
||||||
|
frame_id evolution.u64 NOT NULL, commit_sequence evolution.u64 NOT NULL,
|
||||||
|
commit_id uuid NOT NULL, digest bytea NOT NULL CHECK (octet_length(digest) = 32),
|
||||||
|
end_tick evolution.u64 NOT NULL,
|
||||||
|
PRIMARY KEY (domain, world_id, region_id)
|
||||||
|
);
|
||||||
|
REVOKE ALL ON evolution.history_domains, evolution.current_history_domain,
|
||||||
|
evolution.history_domain_cuts FROM PUBLIC;
|
||||||
|
WITH adopted AS (
|
||||||
|
INSERT INTO evolution.history_domains(domain, kind)
|
||||||
|
VALUES (pg_catalog.gen_random_uuid(), 'adoption') RETURNING domain
|
||||||
|
)
|
||||||
|
INSERT INTO evolution.current_history_domain SELECT true, domain FROM adopted;
|
||||||
|
|
||||||
|
CREATE FUNCTION evolution.load_history_domain_v1() RETURNS uuid
|
||||||
|
LANGUAGE sql STABLE SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS $$
|
||||||
|
SELECT domain FROM evolution.current_history_domain WHERE singleton;
|
||||||
|
$$;
|
||||||
|
REVOKE ALL ON FUNCTION evolution.load_history_domain_v1() FROM PUBLIC;
|
||||||
|
GRANT EXECUTE ON FUNCTION evolution.load_history_domain_v1() TO :"runtime_role";
|
||||||
|
|
||||||
|
-- Owner-only, called while the supported restore is still quarantined.
|
||||||
|
CREATE FUNCTION evolution.fork_restored_history_v1(p_request uuid) RETURNS uuid
|
||||||
|
LANGUAGE plpgsql SECURITY INVOKER SET search_path = pg_catalog, pg_temp AS $$
|
||||||
|
DECLARE old_domain uuid; new_domain uuid;
|
||||||
|
BEGIN
|
||||||
|
IF p_request IS NULL OR p_request = '00000000-0000-0000-0000-000000000000' THEN
|
||||||
|
RAISE EXCEPTION 'nonzero restore request required' USING ERRCODE='22023';
|
||||||
|
END IF;
|
||||||
|
SELECT domain INTO STRICT old_domain FROM evolution.current_history_domain
|
||||||
|
WHERE singleton FOR UPDATE;
|
||||||
|
SELECT domain INTO new_domain FROM evolution.history_domains WHERE request = p_request;
|
||||||
|
IF FOUND THEN
|
||||||
|
IF new_domain <> old_domain THEN
|
||||||
|
RAISE EXCEPTION 'restore request is no longer current' USING ERRCODE='22023';
|
||||||
|
END IF;
|
||||||
|
RETURN new_domain;
|
||||||
|
END IF;
|
||||||
|
IF EXISTS (SELECT 1 FROM evolution.retained_builds WHERE retired_at IS NULL) OR
|
||||||
|
EXISTS (SELECT 1 FROM evolution.region_leases WHERE holder IS NOT NULL) THEN
|
||||||
|
RAISE EXCEPTION 'restore must remain quarantined' USING ERRCODE='55000';
|
||||||
|
END IF;
|
||||||
|
new_domain := pg_catalog.gen_random_uuid();
|
||||||
|
INSERT INTO evolution.history_domains(domain, parent, request, kind)
|
||||||
|
VALUES (new_domain, old_domain, p_request, 'restore');
|
||||||
|
INSERT INTO evolution.history_domain_cuts
|
||||||
|
SELECT new_domain, h.world_id, h.region_id, l.frame_id, h.commit_sequence,
|
||||||
|
h.commit_id, h.digest, h.end_tick
|
||||||
|
FROM evolution.region_heads h JOIN evolution.region_leases l USING(world_id, region_id);
|
||||||
|
UPDATE evolution.current_history_domain SET domain = new_domain WHERE singleton;
|
||||||
|
RETURN new_domain;
|
||||||
|
END $$;
|
||||||
|
REVOKE ALL ON FUNCTION evolution.fork_restored_history_v1(uuid) FROM PUBLIC;
|
||||||
|
INSERT INTO evolution.schema_migrations VALUES (51, :'migration_sha_51');
|
||||||
+13
-3
@@ -126,6 +126,7 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
|||||||
SELECT :'history_v47' || ',48:' || :'migration_sha_48' AS history_v48 \gset
|
SELECT :'history_v47' || ',48:' || :'migration_sha_48' AS history_v48 \gset
|
||||||
SELECT :'history_v48' || ',49:' || :'migration_sha_49' AS history_v49 \gset
|
SELECT :'history_v48' || ',49:' || :'migration_sha_49' AS history_v49 \gset
|
||||||
SELECT :'history_v49' || ',50:' || :'migration_sha_50' AS history_v50 \gset
|
SELECT :'history_v49' || ',50:' || :'migration_sha_50' AS history_v50 \gset
|
||||||
|
SELECT :'history_v50' || ',51:' || :'migration_sha_51' AS history_v51 \gset
|
||||||
SELECT :'history' = :'history_v22' AS at_v22,
|
SELECT :'history' = :'history_v22' AS at_v22,
|
||||||
:'history' = :'history_v23' AS at_v23,
|
:'history' = :'history_v23' AS at_v23,
|
||||||
:'history' = :'history_v24' AS at_v24,
|
:'history' = :'history_v24' AS at_v24,
|
||||||
@@ -154,8 +155,10 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
|||||||
:'history' = :'history_v47' AS at_v47,
|
:'history' = :'history_v47' AS at_v47,
|
||||||
:'history' = :'history_v48' AS at_v48,
|
:'history' = :'history_v48' AS at_v48,
|
||||||
:'history' = :'history_v49' AS at_v49,
|
:'history' = :'history_v49' AS at_v49,
|
||||||
:'history' = :'history_v50' AS at_v50 \gset
|
:'history' = :'history_v50' AS at_v50,
|
||||||
\if :at_v50
|
:'history' = :'history_v51' AS at_v51 \gset
|
||||||
|
\if :at_v51
|
||||||
|
\elif :at_v50
|
||||||
\elif :at_v49
|
\elif :at_v49
|
||||||
\elif :at_v48
|
\elif :at_v48
|
||||||
\elif :at_v47
|
\elif :at_v47
|
||||||
@@ -549,7 +552,8 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
|
|||||||
coalesce(max(version), 0) = 47 AS at_v47,
|
coalesce(max(version), 0) = 47 AS at_v47,
|
||||||
coalesce(max(version), 0) = 48 AS at_v48,
|
coalesce(max(version), 0) = 48 AS at_v48,
|
||||||
coalesce(max(version), 0) = 49 AS at_v49,
|
coalesce(max(version), 0) = 49 AS at_v49,
|
||||||
coalesce(max(version), 0) = 50 AS at_v50
|
coalesce(max(version), 0) = 50 AS at_v50,
|
||||||
|
coalesce(max(version), 0) = 51 AS at_v51
|
||||||
FROM evolution.schema_migrations \gset
|
FROM evolution.schema_migrations \gset
|
||||||
\if :at_v24
|
\if :at_v24
|
||||||
\ir 0025_cellular_v2_bundle.sql
|
\ir 0025_cellular_v2_bundle.sql
|
||||||
@@ -768,6 +772,7 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
|
|||||||
\elif :at_v48
|
\elif :at_v48
|
||||||
\elif :at_v49
|
\elif :at_v49
|
||||||
\elif :at_v50
|
\elif :at_v50
|
||||||
|
\elif :at_v51
|
||||||
\else
|
\else
|
||||||
\echo 'Unknown or changed migration history after v43'
|
\echo 'Unknown or changed migration history after v43'
|
||||||
DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$;
|
DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$;
|
||||||
@@ -800,6 +805,10 @@ SELECT coalesce(max(version), 0) = 49 AS needs_v50 FROM evolution.schema_migrati
|
|||||||
\if :needs_v50
|
\if :needs_v50
|
||||||
\ir 0050_world_region_catalog.sql
|
\ir 0050_world_region_catalog.sql
|
||||||
\endif
|
\endif
|
||||||
|
SELECT coalesce(max(version), 0) = 50 AS needs_v51 FROM evolution.schema_migrations \gset
|
||||||
|
\if :needs_v51
|
||||||
|
\ir 0051_database_history_domain.sql
|
||||||
|
\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
|
||||||
-- grants or SET-able memberships would bypass the fenced functions. Checks the
|
-- grants or SET-able memberships would bypass the fenced functions. Checks the
|
||||||
@@ -819,6 +828,7 @@ BEGIN
|
|||||||
UNION
|
UNION
|
||||||
SELECT m.member FROM pg_catalog.pg_auth_members m JOIN closure c ON m.roleid = c.oid
|
SELECT m.member FROM pg_catalog.pg_auth_members m JOIN closure c ON m.roleid = c.oid
|
||||||
), fenced(oid) AS (VALUES
|
), fenced(oid) AS (VALUES
|
||||||
|
('evolution.load_history_domain_v1()'::regprocedure::oid),
|
||||||
('evolution.load_world_region_catalog_v1(evolution.u64)'::regprocedure::oid),
|
('evolution.load_world_region_catalog_v1(evolution.u64)'::regprocedure::oid),
|
||||||
('evolution.publish_cellular_migration(uuid,bytea,bytea,uuid,evolution.u64,uuid,evolution.u64)'::regprocedure::oid),
|
('evolution.publish_cellular_migration(uuid,bytea,bytea,uuid,evolution.u64,uuid,evolution.u64)'::regprocedure::oid),
|
||||||
('evolution.load_cellular_migration_commit(evolution.u64,evolution.u64,uuid,evolution.u64,uuid)'::regprocedure::oid),
|
('evolution.load_cellular_migration_commit(evolution.u64,evolution.u64,uuid,evolution.u64,uuid)'::regprocedure::oid),
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Database history domain v1
|
||||||
|
|
||||||
|
Semantic evidence contract, schema 51; [ADR-0155](../../docs/adr/0155-database-history-domain.md).
|
||||||
|
No biological byte format or public client endpoint.
|
||||||
|
|
||||||
|
- A registered census result carries a nonzero 16-byte UUID `history_domain`.
|
||||||
|
The external world key is `(history_domain, census.world)`.
|
||||||
|
- Domain, durable region registry and all selected heads share the same database
|
||||||
|
repeatable-read metadata view. Exact replay and set validation remain required.
|
||||||
|
- A missing/zero/malformed domain fails the entire registered result with a context
|
||||||
|
error; SQL/transport failures retain the transaction error. No inferred domain,
|
||||||
|
local-list fallback, cache substitution or partial/zero result.
|
||||||
|
- Adoption is database-local metadata. It does not identify an unknown original
|
||||||
|
branch predating migration. Caller-declared snapshots remain local observations.
|
||||||
|
- Supported restores of schema-51 bundles fork while quarantined, atomically with
|
||||||
|
installation. Record parent/current domain, restore-claim UUID and exact restored
|
||||||
|
head tuples `(world,region,frame,sequence,commit,digest,end_tick)`. Repeated current
|
||||||
|
requests are idempotent; stale requests and unquarantined forks refuse.
|
||||||
|
- Legacy backups without a domain acquire a fresh adoption only when migrated.
|
||||||
|
Their original external context remains unknown. Direct privileged database
|
||||||
|
copies outside the restore workflow do not receive an automatic new identity.
|
||||||
|
- A captured domain is neither live authority nor a terminal-extinction decision.
|
||||||
|
Cross-domain clone provenance, other viable stores and durable accepted global
|
||||||
|
reconciliation remain separate work.
|
||||||
@@ -39,7 +39,9 @@ genesis-only recovery has no fenced transition to check. Results grant no live
|
|||||||
authority, including when a registered holder is released or expired.
|
authority, including when a registered holder is released or expired.
|
||||||
|
|
||||||
The caller-declared API remains available with its previous scoped semantics.
|
The caller-declared API remains available with its previous scoped semantics.
|
||||||
Registered coverage adds no external branch/rewind identity, viable-reserve or
|
Schema 51 additionally binds registered results to a
|
||||||
|
[database history domain](database-history-domain-v1.md) captured in the same view.
|
||||||
|
Registered coverage alone adds no viable-reserve or
|
||||||
outside-store reconciliation, durable accepted extinction record, client endpoint
|
outside-store reconciliation, durable accepted extinction record, client endpoint
|
||||||
or permission. A consistent registered-region cut alone cannot accept terminal
|
or permission. A consistent registered-region cut alone cannot accept terminal
|
||||||
world extinction. Missing, stale or unsupported ecological evidence stays unknown.
|
world extinction. Missing, stale or unsupported ecological evidence stays unknown.
|
||||||
|
|||||||
@@ -22,7 +22,33 @@ auto coverage_failure(CellularCoverageError kind, PgFailure cause = {}) {
|
|||||||
struct Captured {
|
struct Captured {
|
||||||
std::vector<RegisteredCellularRegion> catalog;
|
std::vector<RegisteredCellularRegion> catalog;
|
||||||
std::vector<CommittedCheckpoint> cuts;
|
std::vector<CommittedCheckpoint> cuts;
|
||||||
|
Uuid history_domain{};
|
||||||
};
|
};
|
||||||
|
std::expected<Uuid, Failure> history_domain(Postgres& db, std::chrono::milliseconds timeout) {
|
||||||
|
const auto rows = db.query("SELECT pg_catalog.encode(pg_catalog.uuid_send("
|
||||||
|
"evolution.load_history_domain_v1()),'hex')",
|
||||||
|
{}, timeout);
|
||||||
|
if (!rows)
|
||||||
|
return transaction_failure(rows.error());
|
||||||
|
if (rows->size() != 1 || rows->front().size() != 1)
|
||||||
|
return std::unexpected(Failure{Error::context});
|
||||||
|
const auto& encoded = rows->front()[0];
|
||||||
|
if (!encoded || encoded->size() != 32)
|
||||||
|
return std::unexpected(Failure{Error::context});
|
||||||
|
const auto& text = *encoded;
|
||||||
|
Uuid result{};
|
||||||
|
for (std::size_t i = 0; i < result.size(); ++i) {
|
||||||
|
unsigned byte{};
|
||||||
|
const auto* begin = text.data() + 2 * i;
|
||||||
|
const auto [end, error] = std::from_chars(begin, begin + 2, byte, 16);
|
||||||
|
if (error != std::errc{} || end != begin + 2 || byte > 255)
|
||||||
|
return std::unexpected(Failure{Error::context});
|
||||||
|
result[i] = static_cast<std::uint8_t>(byte);
|
||||||
|
}
|
||||||
|
if (result == Uuid{})
|
||||||
|
return std::unexpected(Failure{Error::context});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
std::expected<std::vector<RegisteredCellularRegion>, Failure>
|
std::expected<std::vector<RegisteredCellularRegion>, Failure>
|
||||||
catalog(Postgres& db, std::uint64_t world, std::chrono::milliseconds timeout) {
|
catalog(Postgres& db, std::uint64_t world, std::chrono::milliseconds timeout) {
|
||||||
const std::array<std::string, 1> parameters{std::to_string(world)};
|
const std::array<std::string, 1> parameters{std::to_string(world)};
|
||||||
@@ -78,6 +104,10 @@ std::expected<Captured, Failure> capture(Postgres& db, std::uint64_t world,
|
|||||||
auto result = [&]() -> std::expected<Captured, Failure> {
|
auto result = [&]() -> std::expected<Captured, Failure> {
|
||||||
Captured captured;
|
Captured captured;
|
||||||
if (registered) {
|
if (registered) {
|
||||||
|
auto domain = history_domain(db, timeout);
|
||||||
|
if (!domain)
|
||||||
|
return std::unexpected(domain.error());
|
||||||
|
captured.history_domain = *domain;
|
||||||
auto required = catalog(db, world, timeout);
|
auto required = catalog(db, world, timeout);
|
||||||
if (!required)
|
if (!required)
|
||||||
return std::unexpected(required.error());
|
return std::unexpected(required.error());
|
||||||
@@ -156,7 +186,8 @@ load_snapshot(Postgres& db, std::uint64_t world,
|
|||||||
if (!census)
|
if (!census)
|
||||||
return std::unexpected(Failure{Error::census, 0, {}, {}, census.error()});
|
return std::unexpected(Failure{Error::census, 0, {}, {}, census.error()});
|
||||||
return RegisteredCellularCensusSnapshot{std::move(cuts->catalog),
|
return RegisteredCellularCensusSnapshot{std::move(cuts->catalog),
|
||||||
{std::move(cuts->cuts), std::move(*census)}};
|
{std::move(cuts->cuts), std::move(*census)},
|
||||||
|
cuts->history_domain};
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|||||||
@@ -822,8 +822,45 @@ void registered_snapshot_coverage(Fixture& f) {
|
|||||||
const std::array first_request{resources.front()};
|
const std::array first_request{resources.front()};
|
||||||
const auto before = take(read(first_request), "registered single-region census");
|
const auto before = take(read(first_request), "registered single-region census");
|
||||||
require(before.catalog == std::vector<RegisteredCellularRegion>{{1, 1}} &&
|
require(before.catalog == std::vector<RegisteredCellularRegion>{{1, 1}} &&
|
||||||
before.snapshot.cuts.size() == 1,
|
before.snapshot.cuts.size() == 1 && before.history_domain != Uuid{},
|
||||||
"registered snapshot lost catalog/cut evidence");
|
"registered snapshot lost catalog/cut evidence");
|
||||||
|
// Trusted owner metadata fault seam: change the namespace after head capture
|
||||||
|
// without changing biology. Real quarantined restore/fork is tested by the
|
||||||
|
// SQL and backup process qualifications, not by bypassing live authority here.
|
||||||
|
const auto domain_before =
|
||||||
|
take(f.owner->query("SELECT evolution.load_history_domain_v1()::text", {}, 5s),
|
||||||
|
"original domain");
|
||||||
|
const CellularCensusSnapshotHooks context_hook{[&](std::size_t) {
|
||||||
|
take(f.owner->query(
|
||||||
|
"WITH added AS (INSERT INTO evolution.history_domains(domain,parent,request,kind) "
|
||||||
|
"SELECT pg_catalog.gen_random_uuid(), domain, pg_catalog.gen_random_uuid(), "
|
||||||
|
"'restore' "
|
||||||
|
"FROM evolution.current_history_domain RETURNING domain) "
|
||||||
|
"UPDATE evolution.current_history_domain SET domain=(SELECT domain FROM added)",
|
||||||
|
{}, 5s),
|
||||||
|
"owner namespace change seam");
|
||||||
|
}};
|
||||||
|
const auto context_race = take(load_registered_cellular_census_snapshot(
|
||||||
|
*reader, world, first_request, builds, 5s, context_hook),
|
||||||
|
"context snapshot race");
|
||||||
|
const auto context_after = take(read(first_request), "next namespace snapshot");
|
||||||
|
require(context_race.history_domain == before.history_domain &&
|
||||||
|
context_after.history_domain != before.history_domain &&
|
||||||
|
context_race.snapshot.cuts[0].manifest == context_after.snapshot.cuts[0].manifest,
|
||||||
|
"namespace escaped the metadata snapshot or was inferred from unchanged cuts");
|
||||||
|
// Missing context must fail, never manufacture a namespace or a zero census.
|
||||||
|
take(f.owner->query("DELETE FROM evolution.current_history_domain", {}, 5s),
|
||||||
|
"owner missing context seam");
|
||||||
|
const auto absent_context = read(first_request);
|
||||||
|
require(!absent_context && absent_context.error().kind == CellularSnapshotError::context &&
|
||||||
|
reader->transaction_idle(),
|
||||||
|
"missing namespace was accepted");
|
||||||
|
require(domain_before.size() == 1 && domain_before[0].size() == 1, "original domain shape");
|
||||||
|
const std::array<std::string, 1> original_domain{
|
||||||
|
take(domain_before[0][0], "original domain value")};
|
||||||
|
take(f.owner->query("INSERT INTO evolution.current_history_domain VALUES(true,$1::uuid)",
|
||||||
|
original_domain, 5s),
|
||||||
|
"restore owner context seam");
|
||||||
const CellularCensusSnapshotHooks enrollment_hook{[&](std::size_t index) {
|
const CellularCensusSnapshotHooks enrollment_hook{[&](std::size_t index) {
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
enroll(2); // Independent committed enrollment after the registry snapshot.
|
enroll(2); // Independent committed enrollment after the registry snapshot.
|
||||||
|
|||||||
@@ -216,6 +216,7 @@ void upgrade_across_migration_and_barrier() {
|
|||||||
" -v migration_sha_48=$(s 0048_cellular_migration_staging.sql)"
|
" -v migration_sha_48=$(s 0048_cellular_migration_staging.sql)"
|
||||||
" -v migration_sha_49=$(s 0049_cellular_migration_publication.sql)"
|
" -v migration_sha_49=$(s 0049_cellular_migration_publication.sql)"
|
||||||
" -v migration_sha_50=$(s 0050_world_region_catalog.sql)"
|
" -v migration_sha_50=$(s 0050_world_region_catalog.sql)"
|
||||||
|
" -v migration_sha_51=$(s 0051_database_history_domain.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");
|
||||||
@@ -233,7 +234,7 @@ void upgrade_across_migration_and_barrier() {
|
|||||||
"tools/migrate-postgres.sh\" > /dev/null") == 0);
|
"tools/migrate-postgres.sh\" > /dev/null") == 0);
|
||||||
CHECK(history(*owner_db) ==
|
CHECK(history(*owner_db) ==
|
||||||
"1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,"
|
"1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,"
|
||||||
"25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50");
|
"25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51");
|
||||||
CHECK(scalar(*owner_db, "SELECT (c.condeferrable AND c.condeferred AND "
|
CHECK(scalar(*owner_db, "SELECT (c.condeferrable AND c.condeferred AND "
|
||||||
"c.confrelid = 'evolution.region_commits'::regclass)::text "
|
"c.confrelid = 'evolution.region_commits'::regclass)::text "
|
||||||
"FROM pg_catalog.pg_constraint c WHERE c.conrelid = "
|
"FROM pg_catalog.pg_constraint c WHERE c.conrelid = "
|
||||||
|
|||||||
@@ -19,7 +19,8 @@
|
|||||||
# target must have neither `evolution` nor `evolution_restore` and must run the
|
# target must have neither `evolution` nor `evolution_restore` and must run the
|
||||||
# manifest's server version;
|
# manifest's server version;
|
||||||
# 3. INSTALL, one transaction: the dump, a claim row evolution_restore.claims(NONCE,
|
# 3. INSTALL, one transaction: the dump, a claim row evolution_restore.claims(NONCE,
|
||||||
# unpublished), every lease fenced and every current build retired. From that
|
# unpublished), every lease fenced, every current build retired, and a fresh
|
||||||
|
# history domain with parent/exact-cut provenance for schema-51 bundles. From that
|
||||||
# commit on the world is unservable: acquisition, renewal and commits refuse
|
# commit on the world is unservable: acquisition, renewal and commits refuse
|
||||||
# until publication, whatever happens to any connection or the server (review
|
# until publication, whatever happens to any connection or the server (review
|
||||||
# M8 follow-up P1). Then the objects are copied;
|
# M8 follow-up P1). Then the objects are copied;
|
||||||
@@ -37,8 +38,9 @@
|
|||||||
# Cleanup only ever removes what this NONCE owns: the schemas only through a
|
# Cleanup only ever removes what this NONCE owns: the schemas only through a
|
||||||
# transaction that locks this NONCE's unpublished claim, the objects directory only
|
# transaction that locks this NONCE's unpublished claim, the objects directory only
|
||||||
# while it carries this NONCE's marker. A competing restore's or provisioner's state
|
# while it carries this NONCE's marker. A competing restore's or provisioner's state
|
||||||
# is never touched. The default result is a verbatim, owner-only copy with the
|
# is never touched. The default result retains the source's biological world
|
||||||
# source's world identities, no runtime grants and never served; to run it, clone it
|
# identities/bytes, with a fresh history domain when supported, no runtime grants
|
||||||
|
# and never served; to run it, clone it
|
||||||
# into an isolated world (tools/backup/verify-backup.sh --isolate).
|
# into an isolated world (tools/backup/verify-backup.sh --isolate).
|
||||||
#
|
#
|
||||||
# --in-place (M8.8 host-loss recovery for dev/stage, ADR-0075) restores the world
|
# --in-place (M8.8 host-loss recovery for dev/stage, ADR-0075) restores the world
|
||||||
@@ -233,6 +235,14 @@ INSERT INTO evolution_restore.claims(nonce, state, mode, manifest_sha256, label,
|
|||||||
FROM evolution.retained_builds b WHERE b.retired_at IS NULL;
|
FROM evolution.retained_builds b WHERE b.retired_at IS NULL;
|
||||||
UPDATE evolution.retained_builds SET retired_at = pg_catalog.clock_timestamp() WHERE retired_at IS NULL;
|
UPDATE evolution.retained_builds SET retired_at = pg_catalog.clock_timestamp() WHERE retired_at IS NULL;
|
||||||
UPDATE evolution.region_leases SET holder = NULL, expires_at = NULL WHERE holder IS NOT NULL;
|
UPDATE evolution.region_leases SET holder = NULL, expires_at = NULL WHERE holder IS NOT NULL;
|
||||||
|
-- New-schema bundles fork their evidence namespace in the install transaction,
|
||||||
|
-- before any build can be readmitted. Legacy bundles acquire an adoption domain
|
||||||
|
-- only if subsequently migrated; no original domain is invented for them.
|
||||||
|
DO \$\$ BEGIN
|
||||||
|
IF pg_catalog.to_regprocedure('evolution.fork_restored_history_v1(uuid)') IS NOT NULL THEN
|
||||||
|
PERFORM evolution.fork_restored_history_v1('$nonce'::uuid);
|
||||||
|
END IF;
|
||||||
|
END \$\$;
|
||||||
COMMIT;
|
COMMIT;
|
||||||
SQL
|
SQL
|
||||||
} > "$work/install.sql"
|
} > "$work/install.sql"
|
||||||
|
|||||||
@@ -85,6 +85,14 @@ createdb evo_restore_twice
|
|||||||
PGDATABASE=evo_restore_twice bash "$root/tools/backup/restore-world.sh" --bundle "$work/bundle" \
|
PGDATABASE=evo_restore_twice bash "$root/tools/backup/restore-world.sh" --bundle "$work/bundle" \
|
||||||
--objects "$work/twice-a" > /dev/null
|
--objects "$work/twice-a" > /dev/null
|
||||||
code=0
|
code=0
|
||||||
|
# A restored database keeps the biological world/cuts but gets a distinct
|
||||||
|
# evidence namespace before publication, including the isolated workflow.
|
||||||
|
source_domain="$(psql -XAtc 'SELECT evolution.load_history_domain_v1()')"
|
||||||
|
restored_domain="$(PGDATABASE=evo_restore_twice psql -XAtc 'SELECT evolution.load_history_domain_v1()')"
|
||||||
|
[ -n "$restored_domain" ] && [ "$restored_domain" != "$source_domain" ] || fail 'restore reused source history domain'
|
||||||
|
[ "$(PGDATABASE=evo_restore_twice psql -XAtc "SELECT parent FROM evolution.history_domains WHERE domain='$restored_domain'")" = "$source_domain" ] || fail 'restore lost parent domain'
|
||||||
|
[ "$(PGDATABASE=evo_restore_twice psql -XAtc 'SELECT count(*) FROM evolution.history_domains d JOIN evolution.current_history_domain h USING(domain) JOIN evolution_restore.claims c ON d.request=c.nonce::uuid')" = 1 ] || fail 'restore lost claim/domain binding'
|
||||||
|
[ "$(PGDATABASE=evo_restore_twice psql -XAtc "SELECT count(*) FROM evolution.history_domain_cuts d JOIN evolution.region_heads h USING(world_id,region_id) WHERE d.domain='$restored_domain' AND d.commit_sequence=h.commit_sequence AND d.commit_id=h.commit_id AND d.digest=h.digest AND d.end_tick=h.end_tick")" = 1 ] || fail 'restore lost exact cut provenance'
|
||||||
PGDATABASE=evo_restore_twice bash "$root/tools/backup/restore-world.sh" --bundle "$work/bundle" \
|
PGDATABASE=evo_restore_twice bash "$root/tools/backup/restore-world.sh" --bundle "$work/bundle" \
|
||||||
--objects "$work/twice-b" > "$work/twice.log" 2>&1 || code=$?
|
--objects "$work/twice-b" > "$work/twice.log" 2>&1 || code=$?
|
||||||
[ "$code" = 4 ] && grep -q 'already has an evolution schema' "$work/twice.log" || fail "a second restore into one database"
|
[ "$code" = 4 ] && grep -q 'already has an evolution schema' "$work/twice.log" || fail "a second restore into one database"
|
||||||
@@ -137,6 +145,7 @@ grep -q 'rolled back; the database was not changed (confirmed)' "$work/pair-a.lo
|
|||||||
createdb evo_restore_gate
|
createdb evo_restore_gate
|
||||||
restore evo_restore_gate "$work/gate" EVO_RESTORE_TEST_HOOK='
|
restore evo_restore_gate "$work/gate" EVO_RESTORE_TEST_HOOK='
|
||||||
if [ "$1" = after-install ]; then
|
if [ "$1" = after-install ]; then
|
||||||
|
psql -XAt -c "SELECT count(*) FROM evolution.history_domains d JOIN evolution.current_history_domain h USING(domain) JOIN evolution_restore.claims c ON d.request=c.nonce::uuid" > "'"$work"'/gate-domain.log"
|
||||||
psql -XAt -c "SELECT * FROM evolution.acquire_region_lease(300, 1, 20000, decode(repeat('"'"'b1'"'"', 32), '"'"'hex'"'"'))" > "'"$work"'/gate-before.log" 2>&1 || true
|
psql -XAt -c "SELECT * FROM evolution.acquire_region_lease(300, 1, 20000, decode(repeat('"'"'b1'"'"', 32), '"'"'hex'"'"'))" > "'"$work"'/gate-before.log" 2>&1 || true
|
||||||
pg_ctl -D "$PGHOST/data" -m fast -w restart > /dev/null
|
pg_ctl -D "$PGHOST/data" -m fast -w restart > /dev/null
|
||||||
psql -XAt -c "SELECT * FROM evolution.acquire_region_lease(300, 1, 20000, decode(repeat('"'"'b1'"'"', 32), '"'"'hex'"'"'))" > "'"$work"'/gate-after.log" 2>&1 || true
|
psql -XAt -c "SELECT * FROM evolution.acquire_region_lease(300, 1, 20000, decode(repeat('"'"'b1'"'"', 32), '"'"'hex'"'"'))" > "'"$work"'/gate-after.log" 2>&1 || true
|
||||||
@@ -146,6 +155,7 @@ grep -q 'build not current' "$work/gate-before.log" && grep -q 'build not curren
|
|||||||
{ cat "$work/gate-before.log" "$work/gate-after.log" >&2; fail "authority was available before publication"; }
|
{ cat "$work/gate-before.log" "$work/gate-after.log" >&2; fail "authority was available before publication"; }
|
||||||
[ "$(PGDATABASE=evo_restore_gate psql -XAtc 'SELECT count(*) FROM evolution.retained_builds WHERE retired_at IS NULL')" = 1 ] ||
|
[ "$(PGDATABASE=evo_restore_gate psql -XAtc 'SELECT count(*) FROM evolution.retained_builds WHERE retired_at IS NULL')" = 1 ] ||
|
||||||
fail "publication did not restore the current build"
|
fail "publication did not restore the current build"
|
||||||
|
[ "$(cat "$work/gate-domain.log")" = 1 ] || fail 'domain was not forked before verification/readmission'
|
||||||
|
|
||||||
# A committed install whose completion is lost is resolved from the claim and
|
# A committed install whose completion is lost is resolved from the claim and
|
||||||
# verified, not reported as unchanged.
|
# verified, not reported as unchanged.
|
||||||
|
|||||||
@@ -59,6 +59,11 @@ grep -q "^REWIND region 400/1 restored at tick $cut " "$work/restore.log" &&
|
|||||||
grep -q '^RESTORE IN PLACE VERIFIED regions=1 ' "$work/restore.log" || fail "restore evidence"
|
grep -q '^RESTORE IN PLACE VERIFIED regions=1 ' "$work/restore.log" || fail "restore evidence"
|
||||||
[ "$(db evo_dr_new -c 'SELECT count(*) FROM evolution.region_leases WHERE holder IS NOT NULL')" = 0 ] ||
|
[ "$(db evo_dr_new -c 'SELECT count(*) FROM evolution.region_leases WHERE holder IS NOT NULL')" = 0 ] ||
|
||||||
fail "a restored lease is still held"
|
fail "a restored lease is still held"
|
||||||
|
old_domain="$(db evo_dr_old -c 'SELECT evolution.load_history_domain_v1()')"
|
||||||
|
new_domain="$(db evo_dr_new -c 'SELECT evolution.load_history_domain_v1()')"
|
||||||
|
[ -n "$new_domain" ] && [ "$new_domain" != "$old_domain" ] || fail 'rewind reused source history domain'
|
||||||
|
[ "$(db evo_dr_new -c "SELECT parent FROM evolution.history_domains WHERE domain='$new_domain'")" = "$old_domain" ] || fail 'rewind lost source domain'
|
||||||
|
[ "$(db evo_dr_new -c "SELECT end_tick FROM evolution.history_domain_cuts WHERE domain='$new_domain' AND world_id=400 AND region_id=1")" = "$cut" ] || fail 'rewind cut provenance'
|
||||||
serve evo_dr_new "$work/new-objects" "$work/new.log"; new_pid=$server_pid
|
serve evo_dr_new "$work/new-objects" "$work/new.log"; new_pid=$server_pid
|
||||||
wait_ack "$work/new.log" $((cut + 30)) || { tail "$work/new.log" >&2; fail "the new host did not serve"; }
|
wait_ack "$work/new.log" $((cut + 30)) || { tail "$work/new.log" >&2; fail "the new host did not serve"; }
|
||||||
grep -q "^phase running epoch=2 committed=$cut " "$work/new.log" ||
|
grep -q "^phase running epoch=2 committed=$cut " "$work/new.log" ||
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Private postgres-check cluster only. No deployed database or biological rules.
|
||||||
|
set -euo pipefail
|
||||||
|
root="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||||
|
createdb evo_history_domain
|
||||||
|
export PGDATABASE=evo_history_domain
|
||||||
|
bash "$root/tools/migrate-postgres.sh" > /dev/null
|
||||||
|
sql() { psql -XAt --no-password -v ON_ERROR_STOP=1 "$@"; }
|
||||||
|
fail() { echo "history-domain qualification FAILED: $*" >&2; exit 1; }
|
||||||
|
original="$(sql -c 'SELECT evolution.load_history_domain_v1()')"
|
||||||
|
[ -n "$original" ] || fail 'missing adoption domain'
|
||||||
|
bash "$root/tools/migrate-postgres.sh" > /dev/null
|
||||||
|
[ "$(sql -c 'SELECT evolution.load_history_domain_v1()')" = "$original" ] || fail 'no-op changed domain'
|
||||||
|
work="$(mktemp -d /tmp/evo-history-domain.XXXXXXXX)"
|
||||||
|
objects="$work/objects"
|
||||||
|
mkdir -m 700 "$objects"
|
||||||
|
trap 'rm -rf -- "$work"' EXIT
|
||||||
|
"${EVO_WORLD_CLONE_BIN:?private fixture tool}" provision --world 70201 --region 1 \
|
||||||
|
--opening development-v1 --pg-host "$PGHOST" --pg-port "$PGPORT" \
|
||||||
|
--pg-database "$PGDATABASE" --pg-user "$PGUSER" --objects "$objects" \
|
||||||
|
--build "$(printf 'cd%.0s' {1..32})" --retain-build true > /dev/null
|
||||||
|
request=51515151-5151-5151-5151-515151515151
|
||||||
|
if sql -c "SELECT evolution.fork_restored_history_v1('$request')" > /dev/null 2>&1; then
|
||||||
|
fail 'fork accepted a current build'
|
||||||
|
fi
|
||||||
|
[ "$(sql -c 'SELECT evolution.load_history_domain_v1()')" = "$original" ] || fail 'refusal mutated domain'
|
||||||
|
sql -c 'UPDATE evolution.retained_builds SET retired_at=clock_timestamp()' > /dev/null
|
||||||
|
if PGUSER="$EVO_PG_RUNTIME_USER" sql -c "SELECT evolution.fork_restored_history_v1('$request')" > /dev/null 2>&1; then
|
||||||
|
fail 'runtime can fork history'
|
||||||
|
fi
|
||||||
|
if PGUSER="$EVO_PG_RUNTIME_USER" sql -c 'SELECT * FROM evolution.current_history_domain' > /dev/null 2>&1; then
|
||||||
|
fail 'runtime can access context tables'
|
||||||
|
fi
|
||||||
|
sql -c "UPDATE evolution.region_leases SET epoch=1, holder=pg_catalog.gen_random_uuid(), expires_at=clock_timestamp()+interval '1 hour'" > /dev/null
|
||||||
|
if sql -c "SELECT evolution.fork_restored_history_v1('$request')" > /dev/null 2>&1; then
|
||||||
|
fail 'fork accepted a held lease'
|
||||||
|
fi
|
||||||
|
sql -c 'UPDATE evolution.region_leases SET holder=NULL, expires_at=NULL' > /dev/null
|
||||||
|
# An aborted transaction leaves both the namespace and provenance unchanged.
|
||||||
|
sql -c "BEGIN; SELECT evolution.fork_restored_history_v1('$request'); ROLLBACK" > /dev/null
|
||||||
|
[ "$(sql -c 'SELECT count(*) FROM evolution.history_domains')" = 1 ] &&
|
||||||
|
[ "$(sql -c 'SELECT count(*) FROM evolution.history_domain_cuts')" = 0 ] || fail 'rollback retained fork evidence'
|
||||||
|
fork="$(sql -c "SELECT evolution.fork_restored_history_v1('$request')")"
|
||||||
|
[ "$fork" != "$original" ] && [ -n "$fork" ] || fail 'fork reused parent domain'
|
||||||
|
[ "$(sql -c "SELECT evolution.fork_restored_history_v1('$request')")" = "$fork" ] &&
|
||||||
|
[ "$(sql -c 'SELECT count(*) FROM evolution.history_domains')" = 2 ] || fail 'retry duplicated fork'
|
||||||
|
[ "$(PGUSER="$EVO_PG_RUNTIME_USER" sql -c 'SELECT evolution.load_history_domain_v1()')" = "$fork" ] || fail 'runtime context read'
|
||||||
|
[ "$(sql -c "SELECT parent::text||':'||kind FROM evolution.history_domains WHERE domain='$fork'")" = "$original:restore" ] || fail 'parent provenance'
|
||||||
|
[ "$(sql -c "SELECT count(*) FROM evolution.history_domain_cuts d JOIN evolution.region_heads h USING(world_id,region_id) JOIN evolution.region_leases l USING(world_id,region_id) WHERE d.domain='$fork' AND d.frame_id=l.frame_id AND d.commit_sequence=h.commit_sequence AND d.commit_id=h.commit_id AND d.digest=h.digest AND d.end_tick=h.end_tick")" = 1 ] || fail 'exact fork cuts'
|
||||||
|
sql -c "SELECT evolution.fork_restored_history_v1('52525252-5252-5252-5252-525252525252')" > /dev/null
|
||||||
|
if sql -c "SELECT evolution.fork_restored_history_v1('$request')" > /dev/null 2>&1; then
|
||||||
|
fail 'stale request switched context backwards'
|
||||||
|
fi
|
||||||
|
for invalid in NULL "'00000000-0000-0000-0000-000000000000'"; do
|
||||||
|
if sql -c "SELECT evolution.fork_restored_history_v1($invalid)" > /dev/null 2>&1; then
|
||||||
|
fail 'invalid request accepted'
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# Reconstruct the exact pre-context metadata schema in this disposable database.
|
||||||
|
# Restore the resulting real legacy backup through both supported workflows.
|
||||||
|
sql > /dev/null <<'SQL'
|
||||||
|
DROP FUNCTION evolution.fork_restored_history_v1(uuid);
|
||||||
|
DROP FUNCTION evolution.load_history_domain_v1();
|
||||||
|
DROP TABLE evolution.history_domain_cuts, evolution.current_history_domain, evolution.history_domains;
|
||||||
|
DELETE FROM evolution.schema_migrations WHERE version=51;
|
||||||
|
UPDATE evolution.retained_builds SET retired_at=NULL;
|
||||||
|
SQL
|
||||||
|
bash "$root/tools/backup/backup-world.sh" --objects "$objects" --out "$work/legacy" --label legacy-context > /dev/null
|
||||||
|
createdb evo_history_legacy_isolated
|
||||||
|
PGDATABASE=evo_history_legacy_isolated bash "$root/tools/backup/restore-world.sh" \
|
||||||
|
--bundle "$work/legacy" --objects "$work/isolated" > "$work/isolated.log" 2>&1 ||
|
||||||
|
{ cat "$work/isolated.log" >&2; fail 'legacy isolated restore'; }
|
||||||
|
[ "$(PGDATABASE=evo_history_legacy_isolated sql -c "SELECT to_regprocedure('evolution.load_history_domain_v1()') IS NULL")" = t ] || fail 'invented legacy source context'
|
||||||
|
createdb evo_history_legacy_inplace
|
||||||
|
PGDATABASE=evo_history_legacy_inplace bash "$root/tools/backup/restore-world.sh" \
|
||||||
|
--bundle "$work/legacy" --objects "$work/inplace" --in-place \
|
||||||
|
--runtime-role "$EVO_PG_RUNTIME_ROLE" --accept-rewind > "$work/inplace.log" 2>&1 ||
|
||||||
|
{ cat "$work/inplace.log" >&2; fail 'legacy in-place restore'; }
|
||||||
|
[ "$(PGDATABASE=evo_history_legacy_inplace sql -c "SELECT count(*) FROM evolution.history_domains WHERE kind='adoption' AND parent IS NULL AND request IS NULL")" = 1 ] &&
|
||||||
|
[ "$(PGDATABASE=evo_history_legacy_inplace sql -c 'SELECT count(*) FROM evolution.history_domain_cuts')" = 0 ] || fail 'invented legacy branch provenance'
|
||||||
|
echo 'history-domain adoption, quarantine, rollback, exact cuts, retries, privileges and legacy restores passed'
|
||||||
@@ -114,6 +114,8 @@ if [ "$mode" = full ]; then
|
|||||||
bash "$root/tools/ci/life-reservations-concurrency.sh"
|
bash "$root/tools/ci/life-reservations-concurrency.sh"
|
||||||
fi
|
fi
|
||||||
phase backup-check
|
phase backup-check
|
||||||
|
# Schema 51: isolated database namespace adoption/forks and effective privileges.
|
||||||
|
bash "$root/tools/ci/history-domain-check.sh"
|
||||||
# M8.7: online backup under load, restore on a separate cluster, isolated rebuild.
|
# M8.7: online backup under load, restore on a separate cluster, isolated rebuild.
|
||||||
bash "$root/tools/ci/backup-check.sh"
|
bash "$root/tools/ci/backup-check.sh"
|
||||||
phase dr-check
|
phase dr-check
|
||||||
@@ -152,7 +154,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,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50
|
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,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51
|
||||||
# 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%% *}"
|
||||||
@@ -173,7 +175,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")" = 50:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50
|
test "$(PGDATABASE=v3_commits psql -XAtc "SELECT count(*) || ':' || string_agg(version::text, ',' ORDER BY version) FROM evolution.schema_migrations")" = 51:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51
|
||||||
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.
|
||||||
@@ -227,7 +229,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,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50
|
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,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51
|
||||||
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
|
||||||
phase permission-audit
|
phase permission-audit
|
||||||
@@ -280,11 +282,13 @@ expect_audit_failure 'REVOKE EXECUTE ON FUNCTION evolution.claim_account_control
|
|||||||
bash "$root/tools/migrate-postgres.sh" # Restored configuration passes the audit again.
|
bash "$root/tools/migrate-postgres.sh" # Restored configuration passes the audit again.
|
||||||
# Schema 50: registry access is granted only through the bounded read function.
|
# Schema 50: registry access is granted only through the bounded read function.
|
||||||
expect_audit_failure 'REVOKE EXECUTE ON FUNCTION evolution.load_world_region_catalog_v1(evolution.u64) FROM evo_runtime_test' 'GRANT EXECUTE ON FUNCTION evolution.load_world_region_catalog_v1(evolution.u64) TO evo_runtime_test'
|
expect_audit_failure 'REVOKE EXECUTE ON FUNCTION evolution.load_world_region_catalog_v1(evolution.u64) FROM evo_runtime_test' 'GRANT EXECUTE ON FUNCTION evolution.load_world_region_catalog_v1(evolution.u64) TO evo_runtime_test'
|
||||||
|
expect_audit_failure 'REVOKE EXECUTE ON FUNCTION evolution.load_history_domain_v1() FROM evo_runtime_test' 'GRANT EXECUTE ON FUNCTION evolution.load_history_domain_v1() TO evo_runtime_test'
|
||||||
|
expect_audit_failure 'GRANT EXECUTE ON FUNCTION evolution.fork_restored_history_v1(uuid) TO evo_runtime_test' 'REVOKE EXECUTE ON FUNCTION evolution.fork_restored_history_v1(uuid) FROM evo_runtime_test'
|
||||||
phase checksum-drift
|
phase checksum-drift
|
||||||
# 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=51 WHERE version=50'
|
psql -X -v ON_ERROR_STOP=1 -c 'UPDATE evolution.schema_migrations SET version=52 WHERE version=51'
|
||||||
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=50 WHERE version=51"
|
psql -X -v ON_ERROR_STOP=1 -c "UPDATE evolution.schema_migrations SET version=51 WHERE version=52"
|
||||||
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"
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ digest_49="$(sha256sum "$root/migrations/0049_cellular_migration_publication.sql
|
|||||||
digest_49="${digest_49%% *}"
|
digest_49="${digest_49%% *}"
|
||||||
digest_50="$(sha256sum "$root/migrations/0050_world_region_catalog.sql")"
|
digest_50="$(sha256sum "$root/migrations/0050_world_region_catalog.sql")"
|
||||||
digest_50="${digest_50%% *}"
|
digest_50="${digest_50%% *}"
|
||||||
|
digest_51="$(sha256sum "$root/migrations/0051_database_history_domain.sql")"
|
||||||
|
digest_51="${digest_51%% *}"
|
||||||
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" \
|
||||||
@@ -155,5 +157,6 @@ psql -X --no-password --set=ON_ERROR_STOP=1 --set="migration_sha=$digest" \
|
|||||||
--set="migration_sha_48=$digest_48" \
|
--set="migration_sha_48=$digest_48" \
|
||||||
--set="migration_sha_49=$digest_49" \
|
--set="migration_sha_49=$digest_49" \
|
||||||
--set="migration_sha_50=$digest_50" \
|
--set="migration_sha_50=$digest_50" \
|
||||||
|
--set="migration_sha_51=$digest_51" \
|
||||||
--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