Files
aevolution/docs/adr/0067-region-clones.md
T
dingoandClaude Opus 5.5 703f67834f 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>
2026-09-29 06:47:45 -04:00

112 lines
5.6 KiB
Markdown

# ADR-0067: Region clones and retained-history audit
## Status
Accepted for M7.9a, 2026-09-29. It builds on ADR-0058 (durability contract),
ADR-0061/0062/0063 (checkpoints, lineage, batches) and ADR-0065 (recovery). Region
migration, sealing and durability qualification are M7.9b.
## Context
M7.9 requires a consistent clone into an isolated world identity, retained
durable history and a baseline-versus-restored trajectory. The named risks are a
clone that shares production credentials and rules that change on restore.
OPERATIONS.md says a clone gets isolated world and runtime identities while
keeping source provenance. ADR-0044 already makes generated content depend on
descriptors, not the world ID.
Every payload records its world ID in nested codecs: the envelope configuration,
the transfer header, the field store and the terrain snapshot. Recovery restores
it under the manifest's world. A clone into another world therefore has to
re-identify the payload; copying bytes is not enough. Sequence 0 used to require
tick 0, so a cut at tick N had no representation.
## Decision
**Re-identification (portable).** `EnvironmentalCommunity::rebind_world` and
`LineageRegion::rebind_world` change only the recorded world ID and keep the
frame. That ID lives in the configuration and the field store; terrain snapshots
take it from the field store. The archive, binding, histories and every quantity
are identity-free, and no rule reads the world ID. Tests show that:
- only the new identity restores the rebound bytes;
- continuation reports match;
- rebinding back yields the original bytes exactly.
**Clone genesis (manifest v2, schema v7).** A clone is sequence 0 of the target
region in another world.
- It starts at the source tick: `begin = end = source end tick`.
- Its predecessor fields name the source commit and the SHA-256 of its manifest.
- Its decision count and digest cover the inherited permanent outcomes. It has no
trace, holder or epoch.
- Profile, versions, quantum, frame and build are inherited. A clone never
converts versions.
A provisioned genesis is unchanged (tick 0, no origin, no outcomes), and manifest
v1 cannot carry an origin. Earlier builds refuse clone manifests as malformed, so
they fail closed. Every later link chains from the clone genesis, so the whole
clone history transitively commits to the source cut.
**Database (migration 0007).**
- The `region_heads` constraint becomes "sequence 0 or tick > 0".
- `region_origins` holds one immutable row per clone region.
- The parser accepts clone genesis. `provision_region_checkpoint` refuses origins
and clone worlds.
- The owner-only `provision_region_clone` enforces:
- the target world differs from the source world;
- a world is either original or a clone of exactly one source world;
- when the source is in the same database, the origin is exactly its committed
link (sequence, commit, digest, tick, versions, quantum, profile);
- inherited outcomes match the manifest digest, with each actor dying at most
once.
- It records the outcomes as sequence-0 decisions with no outbox rows: the source
already delivered them, and a clone has no production integrations.
- The runtime role gains nothing.
**Clone (`clone_region`, Linux).**
1. Refuse a zero ID or the source world.
2. Switch the source session to read-only transactions, and confirm it.
3. Recover the source head exactly as readiness does: manifest, payload, tail
replay and outcomes.
4. Re-identify the payload. Restore it as the target, rebind it back, and require
the verified source bytes.
5. Upload to the target store with verified read-back.
6. Provision in one owner transaction, then compare the receipt.
A failure before step 6 leaves at most target orphans. The source is never
written. A cut read without a lease ignores outcomes of links committed after the
head was read; recovery applies the same rule.
**Tool (`evo-world-clone`).** Subcommands `clone` and `audit`. The source and
target need different databases and different users. The source user needs only
the runtime read functions. The target user is the target database's owner. An
optional full history audit runs first. The `--crash-at before-transaction` flag
is for tests only.
**Retention audit (`audit_region_history`).** Verifies every link from genesis to
the head:
- the digest, position and chain;
- the retained build;
- that the payload is present and restores;
- that the trace replays the predecessor's payload to exactly this link's bytes;
- that the outcomes are exactly those derived;
- that the head state agrees with all outcomes.
It is read-only, needs no lease, and is bounded by `max_commits`. Head recovery
alone does not prove retention; the audit does.
## Consequences
- Tests covered clones between separate databases with separate runtime roles.
The same-database path is checked by the database too.
- History is still never deleted. Garbage collection must later treat clone
origins, heads and audit reachability as pins.
- Clone throughput and history-audit cost grow with payload size and chain length;
M7.9b measures them.
- A clone of a clone is allowed; each origin names its immediate source.
## Alternatives rejected
- **Copying the whole source chain into the new world.** Every manifest digest
would change, so the copy would not be the source's history. Holders and epochs
would also leak across authority domains.
- **Keeping the source world ID and separating the durable namespace.** That
needs a new manifest field. Two worlds with one simulation identity also
defeats isolation.
- **Recording provenance only in a table.** The chain would not commit to its
origin, and cross-database clones could not verify it.