Complete M7.9a region clones and retained-history audit
Clone a verified committed head into an isolated world and database (ADR-0067): world re-identification with a proven byte round trip, a schema v7 clone genesis naming the source commit and digest with digested inherited outcomes, a read-only source session, an owner-only atomic target transaction and the evo-world-clone tool. audit_region_history re-verifies every retained link. Real-process tests cover trajectory equality after the cut, source isolation, killed clones and retention. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -61,9 +61,18 @@ bool structural(const CheckpointManifest& m) noexcept {
|
||||
if (m.manifest_version != 1 && m.manifest_version != 2)
|
||||
return false;
|
||||
const bool no_batch = b == BatchDigests{};
|
||||
if (m.sequence == 0)
|
||||
return zero(m.predecessor_commit) && zero(m.predecessor_digest) && m.begin_tick == 0 &&
|
||||
m.end_tick == 0 && zero(m.holder) && m.epoch == 0 && no_batch;
|
||||
if (m.sequence == 0) {
|
||||
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))
|
||||
return genesis && m.end_tick == 0 && no_batch;
|
||||
// Clone genesis (ADR-0067, v2 only): the origin is the source commit and
|
||||
// manifest digest; the block digests inherited permanent outcomes.
|
||||
return genesis && m.manifest_version == 2 && !zero(m.predecessor_commit) &&
|
||||
!zero(m.predecessor_digest) && m.predecessor_commit != m.commit &&
|
||||
b.decision_count <= max_batch_decisions &&
|
||||
(b.decision_count == 0) == zero(b.decisions_sha256);
|
||||
}
|
||||
const bool link = !zero(m.predecessor_commit) && m.predecessor_commit != m.commit &&
|
||||
!zero(m.predecessor_digest) && !zero(m.holder) && m.epoch != 0 &&
|
||||
m.end_tick > m.begin_tick &&
|
||||
@@ -200,6 +209,33 @@ genesis_manifest(RegionKey key, std::uint64_t frame, Uuid commit, std::uint64_t
|
||||
return m;
|
||||
}
|
||||
|
||||
std::expected<CheckpointManifest, CheckpointError>
|
||||
clone_manifest(const CheckpointManifest& source, const Sha256Digest& source_digest,
|
||||
RegionKey target, Uuid commit, std::uint64_t payload_bytes,
|
||||
const Sha256Digest& payload_sha256, const BatchDigests& inherited) {
|
||||
if (!supported(source))
|
||||
return std::unexpected{CheckpointError::unsupported};
|
||||
if (!structural(source) || target.world == source.key.world || commit == source.commit ||
|
||||
inherited.trace_bytes != 0 || !zero(inherited.trace_sha256))
|
||||
return std::unexpected{CheckpointError::chain};
|
||||
CheckpointManifest m = source;
|
||||
m.manifest_version = 2;
|
||||
m.key = target;
|
||||
m.commit = commit;
|
||||
m.sequence = 0;
|
||||
m.predecessor_commit = source.commit;
|
||||
m.predecessor_digest = source_digest;
|
||||
m.begin_tick = source.end_tick;
|
||||
m.holder = {};
|
||||
m.epoch = 0;
|
||||
m.payload_bytes = payload_bytes;
|
||||
m.payload_sha256 = payload_sha256;
|
||||
m.batch = inherited;
|
||||
if (!structural(m))
|
||||
return std::unexpected{CheckpointError::format};
|
||||
return m;
|
||||
}
|
||||
|
||||
std::expected<CheckpointManifest, CheckpointError>
|
||||
successor_manifest(const CheckpointManifest& p, const Sha256Digest& predecessor_digest, Uuid commit,
|
||||
const LeaseGrant& lease, std::uint64_t end_tick, const Sha256Digest& build,
|
||||
|
||||
Reference in New Issue
Block a user