M12.4: define explicit boundary-accounting checkpoint upgrades
Foundation / checks (deploy) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 2m38s
Foundation / checks (network) (push) Successful in 22m52s
Foundation / checks (client) (push) Successful in 23m48s
Foundation / checks (tsan) (push) Successful in 23m38s
Foundation / checks (postgres) (push) Successful in 53m31s
Foundation / checks (checks) (push) Successful in 1h9m6s
Foundation / postgres-tools (push) Successful in 2m0s
Foundation / server-image (push) Successful in 4m2s
Foundation / image (push) Successful in 4m40s
Foundation / checks (deploy) (push) Successful in 4s
Foundation / checks (ecs) (push) Successful in 2m38s
Foundation / checks (network) (push) Successful in 22m52s
Foundation / checks (client) (push) Successful in 23m48s
Foundation / checks (tsan) (push) Successful in 23m38s
Foundation / checks (postgres) (push) Successful in 53m31s
Foundation / checks (checks) (push) Successful in 1h9m6s
Foundation / postgres-tools (push) Successful in 2m0s
Foundation / server-image (push) Successful in 4m2s
Foundation / image (push) Successful in 4m40s
This commit is contained in:
@@ -1,5 +1,17 @@
|
||||
# Project status and next steps
|
||||
|
||||
## M12.4f explicit portable accounting upgrade - 2026-10-17
|
||||
|
||||
ADR-0145 declares checkpoint bundle 10 for owner 7/population envelope 2, with an
|
||||
explicit same-profile no-tick upgrade from retained bundle 9. Complete biology,
|
||||
opening stock and cohort policy/membership/sequence are preserved. New genesis,
|
||||
double upgrade and old/new payload confusion are refused; continuation and
|
||||
representation changes preserve the tuple. Native Release passes 78/78;
|
||||
Clang analysis/format, ASan/UBSan and private PostgreSQL admission-refusal checks
|
||||
pass. [Evidence](engineering/VALIDATION.md) keeps this portable contract separate
|
||||
from the dedicated durable upgrade transaction/recovery still required. Schema
|
||||
45 still refuses the new bundle; no live selection or deployment changed.
|
||||
|
||||
## M12 CI execution repair - 2026-10-17
|
||||
|
||||
The captured sanitizer timeout and read-only fixture failures now have scoped
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
# ADR-0145: Explicit checkpoint upgrade for boundary accounting
|
||||
|
||||
## Status
|
||||
|
||||
Accepted for M12.4f's portable checkpoint contract, 2026-10-17. Database admission,
|
||||
durable upgrade evidence and paired transfer publication remain follow-on work.
|
||||
This record authorizes no automatic upgrade, deployment or live region change.
|
||||
|
||||
## Context
|
||||
|
||||
ADR-0144 introduced owner 7/population envelope 2 and population batch 2. Retained
|
||||
checkpoint bundle 9 names owner 6, so labeling the new bytes with bundle 9 would
|
||||
break recovery. Representation changes and ownership-format upgrades have
|
||||
different meanings and must retain separate evidence. An ordinary successor
|
||||
cannot change its predecessor's physical or accounting contract.
|
||||
|
||||
## Decision
|
||||
|
||||
Define portable cellular bundle 10 as `(8,7,2,1,1,4,3,2,1)`. Biology remains rules 8;
|
||||
only the owner accounting envelope changes. Profile 4 contains owner 7 with
|
||||
revision history 4. Profile 5 contains population envelope 2 with history 5 and
|
||||
population batch 2. Bundle 9 keeps envelope 1/batch 1 forever. The 360-byte
|
||||
manifest layout and existing payload bounds are unchanged.
|
||||
|
||||
The sole initial upgrade is an explicit no-tick bundle 9 to 10 candidate,
|
||||
preserving profile, history, region/world/frame, quantum and biological cut. It
|
||||
requires a structurally valid positive-sequence source at a positive tick, a
|
||||
distinct result commit, nonzero source digest, and a supplied nonzero lease in
|
||||
the same frame. The result advances the commit sequence without wrap, retains
|
||||
the exact predecessor link, pins a build and payload digest, and has no tick
|
||||
trace or decisions. No downgrade, repeated upgrade or bundle-10 genesis exists.
|
||||
|
||||
Restore the complete source payload and use ADR-0144's exact owner upgrade.
|
||||
Preserve original opening stock, nursery, habitat, heat, all bodies/reserves,
|
||||
identity, archives, damage, growth, position and timers. Boundary flows start at
|
||||
zero and nonresident history is empty. Population membership, policy and
|
||||
conversion sequence are retained without running the tier policy. Profile 4/5
|
||||
transitions may subsequently wrap/unwrap either bundle, preserving its exact
|
||||
tuple; ordinary successors also inherit it unchanged.
|
||||
|
||||
Portable `supported()` means this build can read a declared tuple; it is not SQL
|
||||
admission or publication authority. I/O must independently establish manifest
|
||||
and payload SHA-256 bindings, retain immutable source/target evidence, enforce
|
||||
the current lease and exact head, and resolve ambiguous outcomes before serving.
|
||||
SQL schema 45 still rejects bundle 10. Its population C++ prepared validator also
|
||||
remains restricted to bundle 9/batch 1. No worker selects the new tuple.
|
||||
|
||||
The next durable segment must admit bundle 10 through a dedicated fenced upgrade
|
||||
transaction, refuse upgrades with unsettled intervals, replay the complete
|
||||
upgrade during recovery, and preserve generic-publication bypass guards. Only
|
||||
then may paired biological escrow use the tuple. A manifest checksum or a
|
||||
portable upgrade candidate alone never transfers authority or stock.
|
||||
|
||||
## Alternatives, costs and qualification
|
||||
|
||||
Changing bundle 9 in place makes retained bytes ambiguous. A new population
|
||||
profile alone omits raw owners and confuses representation with accounting.
|
||||
Fresh provisioning loses opening-stock ancestry. Use the explicit tuple and
|
||||
retained-source upgrade instead. This adds a compatibility branch and does not
|
||||
reduce storage or solve geometry, ecology, maturation or global census.
|
||||
|
||||
Require both representations, real wildlife and nonempty cohort history, exact
|
||||
candidate equality, canonical restore, continued batch-2 biology, profile
|
||||
transitions, old/new confusion refusal, malformed bindings, sequence exhaustion,
|
||||
and no genesis or double upgrade. Actual database admission, retry/fence faults
|
||||
and process recovery are separate evidence requirements before durable use.
|
||||
@@ -1,5 +1,7 @@
|
||||
# Architecture decision records
|
||||
|
||||
- [ADR-0145: Explicit boundary-accounting checkpoint upgrade](0145-boundary-accounting-checkpoint-upgrade.md) - portable bundle 10, exact no-tick retained-source upgrade and representation-preserving continuation; SQL admission and durable upgrade evidence remain open.
|
||||
|
||||
- [ADR-0138: Current cellular population reference instrument](0138-cellular-population-reference-instrument.md) - M12.2c headless rules-8 control, encoded replay partitions and offline closure; no aggregation qualification.
|
||||
|
||||
- [ADR-0134: Exact reserve-strata population experiment](0134-reserve-strata-population-experiment.md) - M12.2b isolated exact-state candidate and predeclared instrument; no runtime tier qualification.
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# Persistence and region authority
|
||||
|
||||
M12.4f defines portable cellular bundle 10 for owner-7 boundary accounting, with
|
||||
an explicit same-profile, no-tick bundle-9 upgrade candidate. Profile transitions
|
||||
preserve either tuple. Portable reader support grants no publication authority;
|
||||
schema 45 still refuses bundle 10 and no worker selects it. Dedicated fenced
|
||||
upgrade evidence/recovery and atomic paired transfer publication remain required.
|
||||
See [ADR-0145](../adr/0145-boundary-accounting-checkpoint-upgrade.md).
|
||||
|
||||
M7.1 now scopes the first implementation in [ADR-0058](../adr/0058-region-durability-contract.md)
|
||||
and [REGION_DURABILITY.md](REGION_DURABILITY.md): full checkpoint batches, not
|
||||
recovery from semantic events or an unimplemented input journal. Candidate uploads
|
||||
|
||||
@@ -83,3 +83,17 @@ after cohort transfer, comparing the complete continued destination snapshot.
|
||||
This closes the portable continuation format boundary needed by a future durable
|
||||
adapter. It does not add a durable bundle or SQL admission: both the current C++
|
||||
prepared validator and SQL checker continue to admit only population batch 1.
|
||||
|
||||
## M12.4f portable checkpoint upgrade boundary
|
||||
|
||||
[ADR-0145](../adr/0145-boundary-accounting-checkpoint-upgrade.md) declares bundle
|
||||
10 for owner 7 and supplies an explicit bundle-9 no-tick upgrade candidate for
|
||||
both existing profiles. The manifest advances its commit sequence and retains
|
||||
the exact source digest while preserving profile, history and biological tick.
|
||||
Complete payload restoration/upgrade retains biology, opening stock and cohort
|
||||
policy/membership/sequence. There is no bundle-10 genesis or repeated upgrade.
|
||||
Ordinary continuation and profile changes preserve the tuple; new/old payload
|
||||
confusion is refused in both directions. Portable reader support does not imply
|
||||
database admission: schema 45 and the population prepared validator still reject
|
||||
the tuple. Dedicated upgrade publication/evidence/recovery is the next segment;
|
||||
paired escrow, geometry and remaining biological gates stay open.
|
||||
|
||||
@@ -54,6 +54,10 @@ Population batch 2 continues owner-7 biology and conversions with retained flows
|
||||
cross-version replay is refused and a new process reproduces a post-transfer
|
||||
64-tick interval. Its durable admission/upgrade remains intentionally unsupported
|
||||
by bundle 9 and schema 45.
|
||||
ADR-0145 now defines the portable bundle-10 declaration and explicit same-profile,
|
||||
no-tick source upgrade, with complete payload preservation and no new genesis.
|
||||
SQL admission, immutable upgrade evidence and replayed recovery remain required
|
||||
before those candidates can become durable region heads.
|
||||
The transfer tests also expose the current rules-8 maturation gap: buds retain
|
||||
their subadult realization while reproduction requires a fully realized parent.
|
||||
Finite extra food alone does not close repeated wildlife generations. A versioned
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# Validation strategy
|
||||
|
||||
M12.4f's checkpoint contract exercises explicit portable bundle-9 to 10 upgrades
|
||||
for raw owners and a real nonempty cohort with retained policy/sequence. It
|
||||
requires complete candidate equality, canonical restore, continued batch-2
|
||||
biology and bundle-preserving representation changes. Negative cases cover
|
||||
old/new payload confusion, malformed source/lease/digest bindings, exhaustion,
|
||||
repeated upgrade and new genesis. The private PostgreSQL population suite must
|
||||
continue refusing these portable candidates through schema 45 and existing
|
||||
prepared/generic publication paths without advancing the head. Durable admission
|
||||
and upgrade crash/retry recovery remain separate gates.
|
||||
|
||||
Tests defend contracts, not directory coverage. All checks remain active in
|
||||
Release builds. Current proof has no actual network, biology or distributed
|
||||
recovery, so those categories below are milestone gates rather than passing
|
||||
|
||||
@@ -1,5 +1,36 @@
|
||||
# Validation report
|
||||
|
||||
## 2026-10-17 - M12.4f portable boundary-accounting checkpoint upgrade
|
||||
|
||||
ADR-0145 adds portable bundle 10, explicit bundle-9 no-tick upgrade candidates
|
||||
for raw and population owners, exact source-payload restoration, and
|
||||
bundle-preserving continuation/profile transitions. Bundle-10 genesis and
|
||||
repeated upgrade are refused. No SQL migration, biological rule, worker default,
|
||||
golden, dependency, live state or deployment changed.
|
||||
|
||||
Executed locally:
|
||||
|
||||
- Native MSVC Release **78/78 passed**, 12.56 s, including the new contract cases.
|
||||
The first sandboxed invocation passed 76/78; its two existing hard-link
|
||||
filesystem fixtures were denied access. The full permitted rerun passed.
|
||||
- Linux Clang 19 analysis checkpoint upgrade **1/1 passed**, 5.12 s; retained
|
||||
checkpoint/migration/restart checks **3/3 passed**, 14.71 s. Repository
|
||||
clang-format 19 gate passed. An initial missing-default fixture warning was
|
||||
corrected before this successful analysis run.
|
||||
- Linux Clang 19 ASan/UBSan checkpoint contracts **2/2 passed**, 16.76 s,
|
||||
with no reports.
|
||||
- Actual GCC 14 optional server/PostgreSQL targets rebuilt; private schema-45
|
||||
population suite passed, 6 s total. A SHA-bound portable bundle-10 upgrade is
|
||||
refused by prepared retry/resolution, direct SQL profile transition and the
|
||||
generic publisher; the committed head stays exact. The retained batch-2 under
|
||||
bundle-9 refusal also remains covered.
|
||||
|
||||
These results qualify the portable declaration and fail-closed admission
|
||||
boundary. They do not qualify durable bundle-10 publication, immutable upgrade
|
||||
evidence/recovery, paired escrow, a coupled atlas/environment, multigeneration
|
||||
ecology or elapsed multi-day stability. Build errors supplied by the maintainer
|
||||
remain preserved in untracked `Build_Errors.txt`.
|
||||
|
||||
## 2026-10-17 - captured M12 CI execution failures
|
||||
|
||||
Reviewed the maintainer's local `Build_Errors.txt`. Repeated checks/TSan runs hit
|
||||
|
||||
@@ -26,7 +26,7 @@ enum class CheckpointProfile : std::uint8_t {
|
||||
environmental_lineage_v1 = 2, // LineageRegion container; history_profile 1.
|
||||
primitive_lives_v1 = 3, // Funded creation state; history_profile 2.
|
||||
cellular_lives_v1 = 4, // Complete cellular state; history_profile 3.
|
||||
cellular_population_v1 = 5, // Population envelope 1; nested cellular bundle 9.
|
||||
cellular_population_v1 = 5, // Exact population envelope; nested cellular bundle 9 or 10.
|
||||
};
|
||||
// history_profile 1: lineage archive format 1 with genome schema 1.
|
||||
inline constexpr std::uint32_t lineage_history_profile = 1;
|
||||
@@ -68,11 +68,19 @@ inline constexpr CellularVersionBundle cellular_v7_versions{6, 6, 1, 1, 1, 3, 2,
|
||||
inline constexpr CellularVersionBundle cellular_v8_versions{7, 6, 1, 1, 1, 4, 3, 2, 1};
|
||||
// ADR-0136 step A: rules 8 on owner envelope 6 with habitat 2 (pools and bubbles).
|
||||
inline constexpr CellularVersionBundle cellular_v9_versions{8, 6, 2, 1, 1, 4, 3, 2, 1};
|
||||
// ADR-0145: portable boundary accounting, unchanged rules 8 on owner envelope 7.
|
||||
// Database publication requires its own explicit schema admission.
|
||||
inline constexpr CellularVersionBundle cellular_v10_versions{8, 7, 2, 1, 1, 4, 3, 2, 1};
|
||||
// Zero means this bundle has no population representation.
|
||||
[[nodiscard]] constexpr std::uint32_t
|
||||
population_envelope_version(const CellularVersionBundle& b) noexcept {
|
||||
return b == cellular_v9_versions ? 1 : b == cellular_v10_versions ? 2 : 0;
|
||||
}
|
||||
// Bundles with genome revisions: the revision history profile and format-3 traces.
|
||||
[[nodiscard]] constexpr bool cellular_revision_bundle(const CellularVersionBundle& b) noexcept {
|
||||
return b == cellular_v3_versions || b == cellular_v4_versions || b == cellular_v5_versions ||
|
||||
b == cellular_v6_versions || b == cellular_v7_versions || b == cellular_v8_versions ||
|
||||
b == cellular_v9_versions;
|
||||
b == cellular_v9_versions || b == cellular_v10_versions;
|
||||
}
|
||||
|
||||
// Batch evidence bound by manifest v2 (ADR-0063); all zero at genesis.
|
||||
@@ -141,7 +149,8 @@ enum class CheckpointError : std::uint8_t {
|
||||
encode_manifest(const CheckpointManifest& manifest);
|
||||
[[nodiscard]] std::expected<CheckpointManifest, CheckpointError>
|
||||
decode_manifest(std::span<const std::uint8_t> bytes);
|
||||
// Profile with its history profile, exact versions, zero RNG and durability policy.
|
||||
// Portable reader support: history, exact versions, zero RNG and durability.
|
||||
// This does not grant admission to a database schema or a publication operation.
|
||||
[[nodiscard]] bool supported(const CheckpointManifest& manifest) noexcept;
|
||||
|
||||
// Genesis for operator provisioning only; recovery never creates one.
|
||||
@@ -197,13 +206,27 @@ restore_cellular_payload(std::span<const std::uint8_t> payload, const Checkpoint
|
||||
[[nodiscard]] std::expected<std::unique_ptr<server::CellularPopulation>, CheckpointError>
|
||||
restore_population_payload(std::span<const std::uint8_t> payload,
|
||||
const CheckpointManifest& manifest);
|
||||
// Dedicated profile 4/bundle 9 <-> profile 5 transition, no biological tick.
|
||||
// Dedicated profile 4 <-> profile 5 transition, preserving bundle 9 or 10 exactly.
|
||||
[[nodiscard]] std::expected<CheckpointManifest, CheckpointError>
|
||||
population_profile_transition_manifest(const CheckpointManifest& predecessor,
|
||||
const Sha256Digest& predecessor_digest, Uuid commit,
|
||||
const LeaseGrant& lease, const Sha256Digest& build,
|
||||
std::uint64_t payload_bytes,
|
||||
const Sha256Digest& payload_sha256);
|
||||
// Explicit portable bundle 9 -> 10 upgrade, preserving profile 4/5 and history.
|
||||
// No tick, representation conversion, new genesis or downgrade. The caller must
|
||||
// independently verify the predecessor manifest/payload SHA-256 bindings; neither
|
||||
// these candidate bytes nor supported() confer publication authority.
|
||||
[[nodiscard]] std::expected<CheckpointManifest, CheckpointError>
|
||||
cellular_boundary_upgrade_manifest(const CheckpointManifest& predecessor,
|
||||
const Sha256Digest& predecessor_digest, Uuid commit,
|
||||
const LeaseGrant& lease, const Sha256Digest& build,
|
||||
std::uint64_t payload_bytes, const Sha256Digest& payload_sha256);
|
||||
// Restores the complete bundle-9 source and derives an exact no-tick owner-7
|
||||
// candidate; population policy, membership and conversion sequence are retained.
|
||||
[[nodiscard]] std::expected<std::vector<std::uint8_t>, CheckpointError>
|
||||
cellular_boundary_upgrade_payload(std::span<const std::uint8_t> payload,
|
||||
const CheckpointManifest& predecessor);
|
||||
// Population manual conversion may publish at the same tick with a nonempty trace.
|
||||
[[nodiscard]] std::expected<CheckpointManifest, CheckpointError> population_successor_manifest(
|
||||
const CheckpointManifest& predecessor, const Sha256Digest& predecessor_digest, Uuid commit,
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# Region commit manifest contract v1 (M7.1 design, M7.4a encoding)
|
||||
|
||||
M12.4f adds the portable bundle-10 declaration `(8,7,2,1,1,4,3,2,1)` for
|
||||
owner-7 boundary accounting, with unchanged rules 8. Profile 4 uses raw owner 7
|
||||
and history 4; profile 5 uses population envelope 2, batch 2 and history 5.
|
||||
An explicit bundle-9 to 10 upgrade preserves the representation and biological
|
||||
tick, advances sequence and retains its predecessor digest; trace/decisions are
|
||||
zero. Bundle-10 genesis is forbidden. Ordinary continuation and representation
|
||||
transitions preserve the exact bundle. Retained bundle 9 keeps envelope/batch 1.
|
||||
These portable readers and candidate constructors grant no database authority:
|
||||
SQL schema 45 still rejects bundle 10. See [ADR-0145](../docs/adr/0145-boundary-accounting-checkpoint-upgrade.md).
|
||||
|
||||
M11.2 adds the portable [primitive creation profile 3](primitive-checkpoint-v1.md)
|
||||
using manifest v2. M11.3 adds profile 4, the
|
||||
[cellular lives profile v1](cellular-lives-v1.md), with its own version bundle,
|
||||
|
||||
@@ -9,10 +9,10 @@ next_population(const CheckpointManifest& previous, const Sha256Digest& previous
|
||||
BatchDigests batch, bool transition) {
|
||||
if (!supported(previous) || !encode_manifest(previous) || previous.sequence == 0 ||
|
||||
previous.sequence == ~std::uint64_t{0} || previous.end_tick == 0 ||
|
||||
previous.cellular_versions != cellular_v9_versions || previous_digest == Sha256Digest{} ||
|
||||
lease.frame != previous.frame || lease.epoch == 0 || lease.holder == Uuid{} ||
|
||||
commit == Uuid{} || commit == previous.commit || end_tick < previous.end_tick ||
|
||||
end_tick - previous.end_tick > max_checkpoint_ticks ||
|
||||
population_envelope_version(previous.cellular_versions) == 0 ||
|
||||
previous_digest == Sha256Digest{} || lease.frame != previous.frame || lease.epoch == 0 ||
|
||||
lease.holder == Uuid{} || commit == Uuid{} || commit == previous.commit ||
|
||||
end_tick < previous.end_tick || end_tick - previous.end_tick > max_checkpoint_ticks ||
|
||||
(previous.profile != CheckpointProfile::cellular_lives_v1 &&
|
||||
previous.profile != CheckpointProfile::cellular_population_v1) ||
|
||||
(!transition && previous.profile != CheckpointProfile::cellular_population_v1))
|
||||
@@ -73,10 +73,71 @@ restore_population_payload(std::span<const std::uint8_t> payload, const Checkpoi
|
||||
return std::unexpected(state.error() == server::CellularPopulationError::unsupported
|
||||
? CheckpointError::unsupported
|
||||
: CheckpointError::payload);
|
||||
if ((*state)->format_version() != 1 ||
|
||||
if ((*state)->format_version() != population_envelope_version(m.cellular_versions) ||
|
||||
(*state)->state().format_version() != m.cellular_versions.envelope ||
|
||||
(*state)->state().rules_version() != m.cellular_versions.rules)
|
||||
return std::unexpected(CheckpointError::unsupported);
|
||||
return std::move(*state);
|
||||
}
|
||||
|
||||
std::expected<CheckpointManifest, CheckpointError>
|
||||
cellular_boundary_upgrade_manifest(const CheckpointManifest& previous,
|
||||
const Sha256Digest& previous_digest, Uuid commit,
|
||||
const LeaseGrant& lease, const Sha256Digest& build,
|
||||
std::uint64_t bytes, const Sha256Digest& digest) {
|
||||
if (!supported(previous))
|
||||
return std::unexpected(CheckpointError::unsupported);
|
||||
if (!encode_manifest(previous) || previous.sequence == 0 ||
|
||||
previous.sequence == ~std::uint64_t{0} || previous.end_tick == 0 ||
|
||||
previous.cellular_versions != cellular_v9_versions ||
|
||||
(previous.profile != CheckpointProfile::cellular_lives_v1 &&
|
||||
previous.profile != CheckpointProfile::cellular_population_v1) ||
|
||||
previous_digest == Sha256Digest{} || commit == Uuid{} || commit == previous.commit ||
|
||||
lease.frame != previous.frame || lease.epoch == 0 || lease.holder == Uuid{})
|
||||
return std::unexpected(CheckpointError::chain);
|
||||
auto next = previous;
|
||||
next.cellular_versions = cellular_v10_versions;
|
||||
next.commit = commit;
|
||||
++next.sequence;
|
||||
next.predecessor_commit = previous.commit;
|
||||
next.predecessor_digest = previous_digest;
|
||||
next.begin_tick = previous.end_tick;
|
||||
next.holder = lease.holder;
|
||||
next.epoch = lease.epoch;
|
||||
next.build = build;
|
||||
next.payload_bytes = bytes;
|
||||
next.payload_sha256 = digest;
|
||||
next.batch = {};
|
||||
if (!encode_manifest(next))
|
||||
return std::unexpected(CheckpointError::format);
|
||||
return next;
|
||||
}
|
||||
|
||||
std::expected<std::vector<std::uint8_t>, CheckpointError>
|
||||
cellular_boundary_upgrade_payload(std::span<const std::uint8_t> payload,
|
||||
const CheckpointManifest& previous) {
|
||||
if (!supported(previous) || previous.cellular_versions != cellular_v9_versions)
|
||||
return std::unexpected(CheckpointError::unsupported);
|
||||
if (!encode_manifest(previous) || previous.sequence == 0 || previous.end_tick == 0)
|
||||
return std::unexpected(CheckpointError::chain);
|
||||
if (previous.profile == CheckpointProfile::cellular_lives_v1) {
|
||||
auto state = restore_cellular_payload(payload, previous);
|
||||
if (!state)
|
||||
return std::unexpected(state.error());
|
||||
auto upgraded = (*state)->migration_upgrade_candidate();
|
||||
if (!upgraded)
|
||||
return std::unexpected(CheckpointError::payload);
|
||||
return (*upgraded)->snapshot();
|
||||
}
|
||||
if (previous.profile == CheckpointProfile::cellular_population_v1) {
|
||||
auto state = restore_population_payload(payload, previous);
|
||||
if (!state)
|
||||
return std::unexpected(state.error());
|
||||
auto upgraded = (*state)->migration_upgrade_candidate();
|
||||
if (!upgraded)
|
||||
return std::unexpected(CheckpointError::payload);
|
||||
return (*upgraded)->snapshot();
|
||||
}
|
||||
return std::unexpected(CheckpointError::unsupported);
|
||||
}
|
||||
} // namespace evo::persistence
|
||||
|
||||
@@ -65,12 +65,13 @@ bool structural(const CheckpointManifest& m) noexcept {
|
||||
const bool cellular_migration = cellular && m.sequence > 0 &&
|
||||
(m.cellular_versions == cellular_v2_versions ||
|
||||
m.cellular_versions == cellular_v3_versions ||
|
||||
m.cellular_versions == cellular_v9_versions) &&
|
||||
m.cellular_versions == cellular_v9_versions ||
|
||||
m.cellular_versions == cellular_v10_versions) &&
|
||||
m.begin_tick == m.end_tick && m.end_tick > 0 &&
|
||||
b == BatchDigests{};
|
||||
const bool population_conversion = population && m.begin_tick == m.end_tick && m.end_tick > 0 &&
|
||||
b.trace_bytes >= server::population_batch_header_bytes + 16;
|
||||
if (population && (m.sequence == 0 || m.cellular_versions != cellular_v9_versions ||
|
||||
if (population && (m.sequence == 0 || population_envelope_version(m.cellular_versions) == 0 ||
|
||||
m.history_profile != population_history_profile || b.decision_count != 0 ||
|
||||
!zero(b.decisions_sha256)))
|
||||
return false;
|
||||
@@ -83,7 +84,8 @@ bool structural(const CheckpointManifest& m) noexcept {
|
||||
m.cellular_versions != cellular_v6_versions &&
|
||||
m.cellular_versions != cellular_v7_versions &&
|
||||
m.cellular_versions != cellular_v8_versions &&
|
||||
m.cellular_versions != cellular_v9_versions) ||
|
||||
m.cellular_versions != cellular_v9_versions &&
|
||||
m.cellular_versions != cellular_v10_versions) ||
|
||||
(cellular && m.versions != environmental_v1_versions))
|
||||
return false;
|
||||
if (primitive && (m.manifest_version != 2 || m.tick_microseconds != 50000 ||
|
||||
@@ -95,6 +97,10 @@ bool structural(const CheckpointManifest& m) noexcept {
|
||||
return false;
|
||||
const bool no_batch = b == BatchDigests{};
|
||||
if (m.sequence == 0) {
|
||||
// Boundary accounting is admitted only by an explicit retained-source
|
||||
// upgrade. Provisioning cannot skip its original opening-stock history.
|
||||
if (cellular && m.cellular_versions == cellular_v10_versions)
|
||||
return false;
|
||||
const bool genesis = zero(m.holder) && m.epoch == 0 && m.begin_tick == m.end_tick &&
|
||||
b.trace_bytes == 0 && zero(b.trace_sha256);
|
||||
if (zero(m.predecessor_commit) && zero(m.predecessor_digest))
|
||||
@@ -168,7 +174,7 @@ bool structural(const CheckpointManifest& m) noexcept {
|
||||
bool supported(const CheckpointManifest& m) noexcept {
|
||||
if (m.profile == CheckpointProfile::cellular_population_v1)
|
||||
return m.manifest_version == 2 && m.history_profile == population_history_profile &&
|
||||
m.cellular_versions == cellular_v9_versions &&
|
||||
population_envelope_version(m.cellular_versions) != 0 &&
|
||||
m.versions == environmental_v1_versions && m.tick_microseconds == 50000 &&
|
||||
m.rng_streams == 0 && m.durability == DurabilityPolicy::single_volume_development;
|
||||
if (m.profile == CheckpointProfile::primitive_lives_v1)
|
||||
@@ -189,7 +195,8 @@ bool supported(const CheckpointManifest& m) noexcept {
|
||||
m.cellular_versions == cellular_v6_versions ||
|
||||
m.cellular_versions == cellular_v7_versions ||
|
||||
m.cellular_versions == cellular_v8_versions ||
|
||||
m.cellular_versions == cellular_v9_versions) &&
|
||||
m.cellular_versions == cellular_v9_versions ||
|
||||
m.cellular_versions == cellular_v10_versions) &&
|
||||
m.versions == environmental_v1_versions && m.tick_microseconds == 50000 &&
|
||||
m.rng_streams == 0 && m.durability == DurabilityPolicy::single_volume_development;
|
||||
}
|
||||
|
||||
@@ -204,6 +204,177 @@ void manifests() {
|
||||
malformed = next;
|
||||
malformed.cellular_versions = cellular_v8_versions;
|
||||
require(!supported(malformed), "unsupported nested rules admitted");
|
||||
|
||||
// Both retained representations have one explicit no-tick accounting
|
||||
// upgrade. Exercise a real cohort, including its nonzero conversion sequence.
|
||||
const auto wildlife = std::ranges::find_if(population->state().lives(), [](const auto& life) {
|
||||
return life.account == LifeAccount{};
|
||||
});
|
||||
require(wildlife != population->state().lives().end(), "upgrade lacks real wildlife");
|
||||
auto converted = checked(prepare_population_conversion(*population, header(*population, 0),
|
||||
{wildlife->identity.genome, true}),
|
||||
"upgrade source cohort");
|
||||
const auto conversion_trace =
|
||||
checked(encode_population_batch(converted.batch), "upgrade source conversion trace");
|
||||
auto cohort_manifest =
|
||||
checked(population_successor_manifest(next, filled<32>(11), filled<16>(12), lease,
|
||||
next.end_tick, next.build,
|
||||
converted.state->snapshot().size(), filled<32>(13),
|
||||
{conversion_trace.size(), filled<32>(14), 0, {}}),
|
||||
"upgrade cohort predecessor");
|
||||
require(!converted.state->members().empty() && converted.state->conversion_sequence() != 0,
|
||||
"upgrade source lacks membership history");
|
||||
const std::array bases{source, cohort_manifest};
|
||||
const std::array payloads{state->snapshot(), converted.state->snapshot()};
|
||||
for (std::size_t index = 0; index < bases.size(); ++index) {
|
||||
const auto& base = bases[index];
|
||||
const auto& payload = payloads[index];
|
||||
auto upgraded_payload =
|
||||
checked(cellular_boundary_upgrade_payload(payload, base), "boundary payload upgrade");
|
||||
auto upgraded = checked(cellular_boundary_upgrade_manifest(
|
||||
base, filled<32>(15), filled<16>(16), lease, filled<32>(17),
|
||||
upgraded_payload.size(), filled<32>(18)),
|
||||
"boundary manifest upgrade");
|
||||
auto expected = base;
|
||||
expected.cellular_versions = cellular_v10_versions;
|
||||
expected.commit = filled<16>(16);
|
||||
++expected.sequence;
|
||||
expected.predecessor_commit = base.commit;
|
||||
expected.predecessor_digest = filled<32>(15);
|
||||
expected.begin_tick = base.end_tick;
|
||||
expected.holder = lease.holder;
|
||||
expected.epoch = lease.epoch;
|
||||
expected.build = filled<32>(17);
|
||||
expected.payload_bytes = upgraded_payload.size();
|
||||
expected.payload_sha256 = filled<32>(18);
|
||||
expected.batch = {};
|
||||
require(upgraded == expected && supported(upgraded) &&
|
||||
checked(decode_manifest(checked(encode_manifest(upgraded), "upgrade encode")),
|
||||
"upgrade decode") == upgraded,
|
||||
"boundary upgrade changed profile, clock, history or identity");
|
||||
if (index == 0) {
|
||||
auto restored = checked(restore_cellular_payload(upgraded_payload, upgraded),
|
||||
"upgraded raw restore");
|
||||
require(
|
||||
restored->snapshot() ==
|
||||
checked(state->migration_upgrade_candidate(), "raw upgrade oracle")->snapshot(),
|
||||
"raw boundary upgrade differs");
|
||||
const auto trace_bytes = cellular_batch_header_bytes + cellular_batch_tick_header_bytes;
|
||||
auto continued = checked(
|
||||
successor_manifest(upgraded, filled<32>(19), filled<16>(20), lease,
|
||||
upgraded.end_tick + 1, upgraded.build, upgraded.payload_bytes,
|
||||
upgraded.payload_sha256, {trace_bytes, filled<32>(21), 0, {}}),
|
||||
"raw upgraded successor");
|
||||
require(continued.cellular_versions == cellular_v10_versions &&
|
||||
continued.profile == upgraded.profile &&
|
||||
continued.history_profile == upgraded.history_profile,
|
||||
"ordinary raw successor changed accounting bundle");
|
||||
} else {
|
||||
auto restored = checked(restore_population_payload(upgraded_payload, upgraded),
|
||||
"upgraded population restore");
|
||||
require(restored->policy() == converted.state->policy() &&
|
||||
restored->conversion_sequence() == converted.state->conversion_sequence() &&
|
||||
std::ranges::equal(restored->members(), converted.state->members()),
|
||||
"accounting upgrade reset cohort membership, policy or sequence");
|
||||
auto biology =
|
||||
checked(unattended_population_inputs(restored->state(), header(*restored, 4)),
|
||||
"upgraded continuation intentions");
|
||||
auto continued =
|
||||
checked(prepare_population_batch(*restored, biology), "upgraded continuation");
|
||||
auto recorded =
|
||||
checked(encode_population_batch(continued.batch), "upgraded continuation trace");
|
||||
auto continued_manifest =
|
||||
checked(population_successor_manifest(
|
||||
upgraded, filled<32>(19), filled<16>(20), lease, upgraded.end_tick + 4,
|
||||
upgraded.build, continued.state->snapshot().size(), filled<32>(21),
|
||||
{recorded.size(), filled<32>(22), 0, {}}),
|
||||
"upgraded population successor");
|
||||
require(continued.batch.format_version == 2 &&
|
||||
restore_population_payload(continued.state->snapshot(), continued_manifest)
|
||||
.has_value(),
|
||||
"upgraded population cannot continue under bundle 10");
|
||||
}
|
||||
auto transition =
|
||||
checked(population_profile_transition_manifest(
|
||||
upgraded, filled<32>(19), filled<16>(20), lease, upgraded.build,
|
||||
upgraded.payload_bytes, upgraded.payload_sha256),
|
||||
"upgraded representation transition");
|
||||
require(transition.cellular_versions == upgraded.cellular_versions &&
|
||||
transition.profile != upgraded.profile &&
|
||||
transition.end_tick == upgraded.end_tick,
|
||||
"representation transition changed accounting bundle or time");
|
||||
require(!cellular_boundary_upgrade_payload(upgraded_payload, upgraded) &&
|
||||
!cellular_boundary_upgrade_manifest(
|
||||
upgraded, filled<32>(19), filled<16>(20), lease, upgraded.build,
|
||||
upgraded.payload_bytes, upgraded.payload_sha256),
|
||||
"accounting upgrade applied twice");
|
||||
auto wrong_bundle = upgraded;
|
||||
wrong_bundle.cellular_versions = cellular_v9_versions;
|
||||
require(index == 0 ? !restore_cellular_payload(upgraded_payload, wrong_bundle)
|
||||
: !restore_population_payload(upgraded_payload, wrong_bundle),
|
||||
"new payload admitted under old manifest");
|
||||
wrong_bundle = base;
|
||||
wrong_bundle.cellular_versions = cellular_v10_versions;
|
||||
require(index == 0 ? !restore_cellular_payload(payload, wrong_bundle)
|
||||
: !restore_population_payload(payload, wrong_bundle),
|
||||
"old payload admitted under new manifest");
|
||||
auto corrupt = payload;
|
||||
corrupt.back() ^= 1;
|
||||
require(!cellular_boundary_upgrade_payload(corrupt, base) &&
|
||||
!cellular_boundary_upgrade_payload(std::span{payload}.first(16), base),
|
||||
"corrupt or truncated upgrade source admitted");
|
||||
for (unsigned fault = 0; fault < 8; ++fault) {
|
||||
auto bad_base = base;
|
||||
auto bad_lease = lease;
|
||||
auto ref = filled<32>(15);
|
||||
auto id = filled<16>(16);
|
||||
switch (fault) {
|
||||
case 0:
|
||||
bad_base.sequence = ~std::uint64_t{0};
|
||||
break;
|
||||
case 1:
|
||||
bad_base.sequence = 0;
|
||||
break;
|
||||
case 2:
|
||||
bad_base.cellular_versions = cellular_v8_versions;
|
||||
break;
|
||||
case 3:
|
||||
++bad_lease.frame;
|
||||
break;
|
||||
case 4:
|
||||
bad_lease.epoch = 0;
|
||||
break;
|
||||
case 5:
|
||||
bad_lease.holder = {};
|
||||
break;
|
||||
case 6:
|
||||
ref = {};
|
||||
break;
|
||||
case 7:
|
||||
id = base.commit;
|
||||
break;
|
||||
default:
|
||||
require(false, "unknown upgrade fault fixture");
|
||||
break;
|
||||
}
|
||||
require(!cellular_boundary_upgrade_manifest(bad_base, ref, id, bad_lease,
|
||||
upgraded.build, upgraded.payload_bytes,
|
||||
upgraded.payload_sha256),
|
||||
"invalid accounting upgrade binding admitted");
|
||||
}
|
||||
auto genesis = upgraded;
|
||||
genesis.sequence = 0;
|
||||
genesis.predecessor_commit = {};
|
||||
genesis.predecessor_digest = {};
|
||||
genesis.holder = {};
|
||||
genesis.epoch = 0;
|
||||
genesis.begin_tick = genesis.end_tick = 0;
|
||||
require(!encode_manifest(genesis), "boundary bundle provisioned without retained upgrade");
|
||||
}
|
||||
require(population_envelope_version(cellular_v8_versions) == 0 &&
|
||||
population_envelope_version(cellular_v9_versions) == 1 &&
|
||||
population_envelope_version(cellular_v10_versions) == 2,
|
||||
"population bundle to envelope mapping differs");
|
||||
}
|
||||
} // namespace
|
||||
int main() try {
|
||||
|
||||
@@ -275,6 +275,29 @@ void conversions_and_retries(Fixture& f) {
|
||||
auto rejected_sql = publish_population_checkpoint(*f.db, future.manifest, future.trace, 5s);
|
||||
require(!rejected_sql && rejected_sql.error().kind == LeaseStoreError::invalid,
|
||||
"schema 45 did not reject the unsupported trace format before commit lookup");
|
||||
const auto current_manifest = take(decode_manifest(f.head.manifest), "upgrade source manifest");
|
||||
const auto boundary_payload =
|
||||
take(cellular_boundary_upgrade_payload(conversion.state->snapshot(), current_manifest),
|
||||
"portable boundary upgrade source");
|
||||
const auto boundary_manifest = take(
|
||||
cellular_boundary_upgrade_manifest(
|
||||
current_manifest, f.head.head.digest, f.id(), f.lease, f.build, boundary_payload.size(),
|
||||
take(sha256(boundary_payload), "boundary payload digest")),
|
||||
"portable boundary upgrade manifest");
|
||||
const PopulationPreparedCommit boundary{
|
||||
f.key,
|
||||
boundary_manifest.commit,
|
||||
take(encode_manifest(boundary_manifest), "boundary candidate encoding"),
|
||||
{}};
|
||||
auto rejected_boundary = retry_population_prepared(*f.db, boundary, 5s);
|
||||
require(!rejected_boundary && rejected_boundary.error().kind == PublicationError::candidate &&
|
||||
!resolve_population_prepared(*f.db, boundary, 5s),
|
||||
"portable bundle 10 bypassed prepared publication admission");
|
||||
auto rejected_upgrade = publish_population_profile_transition(*f.db, boundary.manifest, 5s);
|
||||
require(!rejected_upgrade && rejected_upgrade.error().kind == LeaseStoreError::invalid,
|
||||
"schema 45 admitted portable accounting upgrade without dedicated evidence");
|
||||
require(!publish_region_checkpoint(*f.db, boundary.manifest, {}, 5s),
|
||||
"generic publisher admitted boundary upgrade");
|
||||
require(take(load_region_checkpoint(*f.db, f.key, 5s), "head after future rejection").head ==
|
||||
f.head.head,
|
||||
"future trace changed the retained durable head");
|
||||
|
||||
Reference in New Issue
Block a user