From 5aeb18a4aaefb5dc8b33eed6cdda8636845776fb Mon Sep 17 00:00:00 2001 From: dingo Date: Sat, 26 Sep 2026 20:33:43 -0400 Subject: [PATCH] Complete M5.8 bounded world restart proof --- CMakeLists.txt | 11 ++ README.md | 2 + apps/evo-tools/world_proof.cpp | 214 ++++++++++++++++++++++++ docs/ROADMAP.md | 4 +- docs/STATUS.md | 16 +- docs/adr/0049-bounded-world-proof.md | 53 ++++++ docs/adr/README.md | 1 + docs/architecture/WORLD_ARCHITECTURE.md | 4 + docs/engineering/VALIDATION.md | 32 ++++ docs/engineering/WORLD_PROOF.md | 85 ++++++++++ tests/world_process_restart.cmake | 31 ++++ 11 files changed, 448 insertions(+), 5 deletions(-) create mode 100644 apps/evo-tools/world_proof.cpp create mode 100644 docs/adr/0049-bounded-world-proof.md create mode 100644 docs/engineering/WORLD_PROOF.md create mode 100644 tests/world_process_restart.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 16f89ff..1e888bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -249,6 +249,17 @@ add_executable(evo-benchmark tests/benchmarks/simulation_benchmark.cpp) target_link_libraries(evo-benchmark PRIVATE evo::simulation) evo_owned_target(evo-benchmark) +add_executable(evo-world-proof apps/evo-tools/world_proof.cpp) +target_link_libraries(evo-world-proof PRIVATE evo::world) +evo_owned_target(evo-world-proof) +if(BUILD_TESTING) + add_test(NAME world-process-restart COMMAND "${CMAKE_COMMAND}" + "-DEVO_WORLD_PROOF=$" + "-DTEST_DIR=${CMAKE_CURRENT_BINARY_DIR}/world-proof" + -P "${CMAKE_CURRENT_SOURCE_DIR}/tests/world_process_restart.cmake") + set_tests_properties(world-process-restart PROPERTIES TIMEOUT 120) +endif() + add_executable(evo-resolution-benchmark tests/benchmarks/resolution_benchmark.cpp) target_link_libraries(evo-resolution-benchmark PRIVATE evo::ecology) evo_owned_target(evo-resolution-benchmark) diff --git a/README.md b/README.md index 3911f44..c57cf35 100644 --- a/README.md +++ b/README.md @@ -137,3 +137,5 @@ from a public dependency's license. M4.6 reproduction, measurements and limits: [aggregate budget report](docs/engineering/AGGREGATE_BUDGET.md). M5.1 local voxel/address API and scope: [local voxel contract](docs/world/LOCAL_VOXEL_CONTRACT.md). + +M5.8 process restart proof and measured costs: [world proof](docs/engineering/WORLD_PROOF.md). diff --git a/apps/evo-tools/world_proof.cpp b/apps/evo-tools/world_proof.cpp new file mode 100644 index 0000000..ae11310 --- /dev/null +++ b/apps/evo-tools/world_proof.cpp @@ -0,0 +1,214 @@ +#include "evo/world/local_files.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { +using namespace evo::world; +using Clock = std::chrono::steady_clock; +constexpr WorldIdentity identity{58, 1}; +constexpr BaseDescriptor descriptor{123456}; +constexpr std::size_t budget = std::size_t{4} * 1024 * 1024; +constexpr std::size_t chunk_count = 8; +enum class Workload : std::uint8_t { uniform, sparse, heavy }; +void require(bool value, std::source_location at = std::source_location::current()) { + if (!value) + throw std::runtime_error("world proof check at line " + std::to_string(at.line())); +} +template T take(std::expected result) { + require(result.has_value()); + return std::move(*result); +} +std::int64_t elapsed(Clock::time_point start) { + return std::chrono::duration_cast(Clock::now() - start).count(); +} +ChunkAddress address(Workload kind, std::size_t i) { + const auto x = static_cast(i); + return {kind == Workload::sparse ? (x - 4) * 8000 : x - 4, 0, -1000}; +} +std::uint32_t removed(Workload kind, std::size_t chunk, std::uint32_t cell) { + if (kind == Workload::sparse && chunk == 0 && cell == 0) + return fill_scale; + if (kind == Workload::heavy && chunk < 4 && cell < 1024) + return 1 + cell % 257; + return 0; +} +std::uint64_t fingerprint(std::span bytes) { + std::uint64_t result = 14695981039346656037ULL; + for (auto byte : bytes) + result = (result ^ byte) * 1099511628211ULL; + return result; +} +// Regression baselines are set after analytical cell/inventory validation. +constexpr std::array goldens{0xdb06d14d81c62c8cULL, 0x9cd2752316152d88ULL, + 0x0dc4f24dc24f58e0ULL}; +void audit(const ChunkStore& state, Workload kind) { + require(state.size() == chunk_count); + std::uint64_t expected_debris{}, remaining{}; + for (std::size_t c = 0; c < chunk_count; ++c) { + const auto view = take(state.view(address(kind, c))); + for (std::uint32_t i = 0; i < base_chunk_cells; ++i) { + const auto sample = + take(state.read(view, take(local_from_ordinal(i, base_chunk_edge)))); + const auto cut = removed(kind, c, i); + require(sample.fill() == fill_scale - cut); + require(sample.material().value == (cut == fill_scale ? 0 : 1)); + expected_debris += cut; + remaining += sample.fill(); + } + } + require(take(state.debris({1})).value == expected_debris); + require(take(state.debris({2})).value == 0); + require(remaining + expected_debris == + chunk_count * base_chunk_cells * std::uint64_t{fill_scale}); +} +void regenerate(ChunkStore& state, Workload kind) { + // The last chunk is never edited. Check against the versioned generator after eviction. + const auto a = address(kind, chunk_count - 1); + const auto old = take(state.view(a)); + require(state.evict(old).has_value()); + const auto fresh = take(state.load(a)); + require(!state.read(old, {})); + const auto generated = take(generate_base_chunk(descriptor, a)); + for (std::uint32_t i = 0; i < base_chunk_cells; ++i) { + require(take(state.read(fresh, take(local_from_ordinal(i, base_chunk_edge)))) == + generated[i]); + } +} +struct Fixture { + std::unique_ptr state; + WorldBytes base, journal, final; + std::int64_t generation_ns{}, edits_ns{}, journal_ns{}, encode_ns{}; + std::size_t base_accounted{}, final_accounted{}, commands{}, cuts{}; +}; +Fixture fixture(Workload kind) { + Fixture f; + const auto begin = Clock::now(); + f.state = take(ChunkStore::create(descriptor, chunk_count, budget, + {{VolumeUnits{10'000'000}, VolumeUnits{10'000'000}}})); + for (std::size_t i = 0; i < chunk_count; ++i) + (void)take(f.state->load(address(kind, i))); + f.generation_ns = elapsed(begin); + f.base_accounted = f.state->accounted_bytes(); + f.base = take(f.state->snapshot(identity)); + f.commands = kind == Workload::heavy ? 64U : (kind == Workload::sparse ? 1U : 0U); + const auto per_command = kind == Workload::heavy ? 64U : 1U; + std::vector> storage(f.commands); + std::vector requests; + requests.reserve(f.commands); + EditReceipt last{}; + for (std::size_t command = 0; command < f.commands; ++command) { + for (std::uint32_t k = 0; k < per_command; ++k) { + const auto c = kind == Workload::heavy ? k / 16 : 0; + const auto ordinal = + kind == Workload::heavy ? static_cast(command) * 16 + k % 16 : 0; + const auto a = address(kind, c); + storage[command][k] = {a, take(local_from_ordinal(ordinal, base_chunk_edge)), + take(f.state->view(a)).revision(), removed(kind, c, ordinal)}; + } + ExcavationRequest r{command + 1, 1, std::span{storage[command]}.first(per_command), 0}; + r.digest = take(excavation_digest(r)); + const auto start = Clock::now(); + last = take(f.state->excavate(r)); + f.edits_ns += elapsed(start); + requests.push_back(r); + } + f.cuts = f.commands * per_command; + audit(*f.state, kind); + if (!requests.empty()) + require(take(f.state->excavate(requests.back())) == last); + const auto encode_start = Clock::now(); + f.final = take(f.state->snapshot(identity)); + f.encode_ns = elapsed(encode_start); + const auto journal_start = Clock::now(); + f.journal = take(make_edit_journal(f.base, identity, requests, budget)); + f.journal_ns = elapsed(journal_start); + f.final_accounted = f.state->accounted_bytes(); + return f; +} +} // namespace + +int main(int argc, char** argv) try { + if (argc != 4) + throw std::runtime_error( + "usage: evo-world-proof "); + const std::string_view phase{argv[1]}, name{argv[2]}; + require(phase == "prepare" || phase == "compact" || phase == "verify"); + require(name == "uniform" || name == "sparse" || name == "heavy"); + const auto kind = name == "uniform" ? Workload::uniform + : (name == "sparse" ? Workload::sparse : Workload::heavy); + const std::filesystem::path root{argv[3]}; + if (phase == "prepare") { + require(std::filesystem::create_directory(root)); + } else { + require(std::filesystem::is_directory(root)); + } + auto reference = fixture(kind); + const auto hash = fingerprint(reference.final); + const auto golden = goldens[static_cast(kind)]; + require(golden == hash); + auto files = take(LocalWorldFiles::open(root, identity, budget)); + std::int64_t publish_ns{}, recovery_ns{}, compaction_ns{}, regeneration_ns{}; + if (phase == "prepare") { + require(!files->current()); + auto base = take(ChunkStore::restore(reference.base, identity, budget)); + const auto start = Clock::now(); + require(files->checkpoint(*base).has_value()); + require(files->publish_journal(reference.base, reference.journal).has_value()); + publish_ns = elapsed(start); + } else { + const auto head = files->current().value_or(FileCommit{}); + require(head.generation == (phase == "compact" ? 2U : 3U)); + require(head.has_journal == (phase == "compact")); + } + const auto recover_start = Clock::now(); + auto restored = take(files->recover()); + recovery_ns = elapsed(recover_start); + require(take(restored->snapshot(identity)) == reference.final); + audit(*restored, kind); + if (phase == "compact") { + const auto start = Clock::now(); + const auto committed = take(files->checkpoint(*restored)); + compaction_ns = elapsed(start); + require(committed.generation == 3 && !committed.has_journal); + } + if (phase == "verify") { + const auto start = Clock::now(); + regenerate(*restored, kind); + regeneration_ns = elapsed(start); + audit(*restored, kind); + } + std::cout << "{\"phase\":\"" << phase << "\",\"workload\":\"" << name + << "\",\"seed\":123456,\"chunks\":8,\"resident_budget\":" << budget + << ",\"commands\":" << reference.commands << ",\"cuts\":" << reference.cuts + << ",\"base_accounted_bytes\":" << reference.base_accounted + << ",\"final_accounted_bytes\":" << reference.final_accounted + << ",\"snapshot_bytes\":" << reference.final.size() + << ",\"journal_bytes\":" << reference.journal.size() + << ",\"debris_volume\":" << take(reference.state->debris({1})).value << ",\"hash\":\"" + << std::hex << hash << std::dec << "\",\"generation_ns\":" << reference.generation_ns + << ",\"edits_ns\":" << reference.edits_ns << ",\"encode_ns\":" << reference.encode_ns + << ",\"journal_build_ns\":" << reference.journal_ns + << ",\"publish_ns\":" << publish_ns << ",\"recovery_ns\":" << recovery_ns + << ",\"compaction_ns\":" << compaction_ns + << ",\"regeneration_ns\":" << regeneration_ns << "}\n"; + return 0; +} catch (const std::exception& e) { + std::fprintf(stderr, "%s\n", e.what()); + return 1; +} catch (...) { + return 1; +} diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index f7a92bd..0a6050b 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -271,8 +271,8 @@ M5.6 is complete under [ADR-0047](adr/0047-world-codec.md): and retry state together. M5.7 implements [single-writer local publication](adr/0048-local-publication.md): two alternating manifest slots, immutable snapshot/journal payloads, verified detached recovery, journal replay, checkpoint compaction and injected pre/post-commit interruption. -This is not a production multi-host durability or ownership service. M5.8 remains the -end-to-end deep-edit/restart and cost-evidence gate. +This is not a production multi-host durability or ownership service. M5.8 implements the [bounded world proof](engineering/WORLD_PROOF.md): separate +prepare/compact/verify processes, conservation oracles, frozen hashes and measured costs. **Decisions still open:** final spherical layout, region dimensions, adaptive LOD, field quantization beyond the initial experiment, hydrology and surface extraction. diff --git a/docs/STATUS.md b/docs/STATUS.md index 993e7e3..f7e0fb9 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -7,7 +7,7 @@ persistent simulation server. The founding vision remains unchanged. ## Completed implementation - Vision, architectural pillars, risks, open-question register, architecture - diagrams, biological contracts, engineering constitution and 48 ADRs. + diagrams, biological contracts, engineering constitution and 49 ADRs. Proposed/deferred choices remain distinct from accepted proof decisions. - M0–M4 task breakdowns with dependencies, acceptance evidence and risks, plus M5–M14 gates in [ROADMAP.md](ROADMAP.md). @@ -61,7 +61,7 @@ for the bounded proof; the general production ECS remains a later measured choic | Priority | Work | Completion evidence | |---|---|---| -| 1 | M5.8 bounded world proof | Deep edit -> checkpoint compaction -> restart with same state/inventory and measured operation costs | +| 1 | M6.1 environmental units and coupling contract | Define habitat mapping, resource units and volume-to-matter accounting before biological coupling | | Research | Improve aggregate fidelity and measure Linux/target-host costs | M4.6 found no qualifying width; see the aggregate budget report | | 2 | Revisit the ADR-0031/0032 reproduction cost model | Reproduction is affordable only at the genome schema's floor; decide whether that is intended before M4 builds cohorts on it | | Delivery gate | Add/update the dev workload when a deployable increment needs it; Argo is ready | Observe Job/pod completion separately from image publication; no World0 changes | @@ -590,9 +590,19 @@ acknowledgements. M5.7 local publication and recovery are implemented above. ADR-0048 adds a single-writer local-filesystem adapter over the M5.6 codec. It uses immutable checksum-named snapshot/journal blobs and two alternating canonical manifest slots; replacing the inactive manifest is the publication point. Checkpoints -compact a committed journal only after a caller supplies the recovered/advanced +compact a committed journal only after a caller supplies the exact recovered state. Recovery validates the selected snapshot and complete journal replay into a detached ChunkStore. Tests cover lock exclusion, journal/restart, compaction, failpoints before and after publication, malformed manifests and missing published payloads. FNV remains a corruption detector, and this local adapter makes no host-loss, multi-region or production durability claim. Filesystem orphan cleanup is deferred. + +## M5.8 bounded world restart proof + +Added evo-world-proof and a CTest workflow that launches fresh prepare, compact and +verify processes for uniform, sparse and heavily modified deep chunks. Independent +cell/debris oracles, exact canonical equality, frozen hashes, retained retries and +clean regeneration checks pass. [Measured costs and reproduction](engineering/WORLD_PROOF.md) +record five Windows Release runs and explicit accounting/durability limits. +No world format or simulation version changed. Next: M6.1 environmental units and +coupling contract; Linux golden execution remains a CI confirmation. diff --git a/docs/adr/0049-bounded-world-proof.md b/docs/adr/0049-bounded-world-proof.md new file mode 100644 index 0000000..633610b --- /dev/null +++ b/docs/adr/0049-bounded-world-proof.md @@ -0,0 +1,53 @@ +# ADR-0049: Bounded world restart proof and measurements + +## Status +Accepted for M5.8 development evidence; no world format or simulation rule change. + +## Context +Individual codecs and file tests do not demonstrate a full create/edit/journal/ +compaction/restart workflow or explain its cost. M5 closes with a reproducible +bounded workload before environmental coupling begins. + +## Decision +Add the host tool `evo-world-proof `. +CTest launches separate processes for each phase. Prepare refuses an existing root, +publishes a base plus a journal, compact recovers and publishes its exact state, +and verify requires the compacted generation and compares full canonical bytes to +a freshly reconstructed uninterrupted fixture. No phase deletes files. + +Three seed-123456 fixtures each own eight 16-cube chunks at chunk Z=-1000: +uniform (empty journal), sparse (widely spaced chunks, one full-cell excavation), +and heavy (64 commands, 64 cuts each across four chunks, 4096 distinct varying fills). +An independent analytical cell oracle checks every fill/material and the exact +debris sum; retained retries and clean eviction/regeneration are checked separately. +Freeze canonical hashes as shared Windows/Linux regression expectations. A hash +observed on one platform does not claim another platform has run it. + +Report JSON phase timings in nanoseconds and store-accounted bytes, snapshot/journal +sizes, command/cut counts and hash. Timings include validation where the API performs +it. No performance threshold: record several independent runs and their range. +Store-accounted bytes exclude host vectors, replay candidates and OS/allocator +overhead; do not label them process peak memory. The explicitly chosen resident +budget and retained output sizes make these limits visible. + +## Alternatives Considered +A single-process close/reopen misses process-local state dependencies. A planet +stress test before the bounded proof would obscure correctness and capacity limits. +Existing generation reference fixtures remain the independent base-version checks. + +## Benefits +Real process restart, conservation evidence and portable regression fixtures with +reproducible measurements; the headless kernel gains no tooling or IO dependency. + +## Costs +Full reconstruction and repeated restore are deliberately validation-heavy. Retained +local files accumulate because this gate supplies no deletion policy. + +## Risks +Eight chunks cannot establish planet capacity. Filesystem cache, antivirus and host +load affect timings. A graceful process restart is not a physical power-cut test. + +## Consequences +Run the same CTest workflow on supported presets/CI, preserve frozen fingerprints, +document local results and unexecuted platforms. M6 must define volume/matter and +habitat coupling before resources become biologically consumable. diff --git a/docs/adr/README.md b/docs/adr/README.md index 147e006..de4a146 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -55,3 +55,4 @@ design. No unadopted candidate is a link dependency of the proof. - [ADR-0047: World codecs](0047-world-codec.md) - accepted for M5.6 bounded canonical snapshots and detached edit-journal replay. - [ADR-0048: Local publication](0048-local-publication.md) - accepted for M5.7 single-writer snapshot/journal publication and recovery. +- [ADR-0049: Bounded world proof](0049-bounded-world-proof.md) - accepted for M5.8 restart regression and cost evidence. diff --git a/docs/architecture/WORLD_ARCHITECTURE.md b/docs/architecture/WORLD_ARCHITECTURE.md index 96a94d3..43e82e9 100644 --- a/docs/architecture/WORLD_ARCHITECTURE.md +++ b/docs/architecture/WORLD_ARCHITECTURE.md @@ -149,3 +149,7 @@ versions, revisions, finite debris and retry history in one validated snapshot. Journal replay uses the existing excavation transaction on a detached store. Dirty chunks remain pinned; encoding does not acknowledge durability. M5.7 supplies local file publication and compaction; no production persistence dependency was added. + +M5.8 validates the local stack through separate prepare/compact/verify processes; see +[bounded world proof and measurements](../engineering/WORLD_PROOF.md). This adds no +production ownership or biological resource conversion contract. diff --git a/docs/engineering/VALIDATION.md b/docs/engineering/VALIDATION.md index 0bf68f8..b56b54b 100644 --- a/docs/engineering/VALIDATION.md +++ b/docs/engineering/VALIDATION.md @@ -1617,3 +1617,35 @@ Native Windows ASan is not UBSan. Full-size throughput, allocation-failure injec and crash-atomic files remain unverified/later gates. Codecs write no files, clear no dirty flags and issue no durable acknowledgements. No Argo/World0 operation occurred. Next: M5.7 local snapshot/journal publication, compaction and recovery. + +## M5.7 review and M5.8 bounded world proof - 2026-09-26 + +Reviewed a2a12fdc696c005bd3feb496f6efcdc58c28262c against the three prior findings. +Committed-journal compaction compares exact recovered canonical state; poisoned +handles refuse recovery; interruption tests use changed payloads and include partial +write failures. No new blocking finding identified in that correction's scope. + +M5.8 adds ADR-0049, evo-world-proof and world-process-restart CTest. It launches fresh +prepare/compact/verify processes for three workloads, checks all cells and conserved +debris independently, compares canonical bytes, enforces frozen hashes and checks +clean regeneration. Existing formats and simulation goldens are unchanged. + +Executed on Windows x64 / MSVC 19.44: + +- tools/windows-check.ps1 -Preset release -Action check: 48/48 passed, including the + final source with frozen hashes and nonthrowing boundary diagnostics. +- tools/windows-check.ps1 -Preset analysis -Action check: clang-tidy 19 and 48/48 + passed. Initial widening-conversion and exception-boundary diagnostics were fixed. +- tools/windows-check.ps1 -Preset asan -Action check: 48/48 passed. +- tools/windows-check.ps1 -Preset release -Action format: passed. +- Five independent Release process workflows passed; medians/ranges and exact + accounting/payload sizes are in WORLD_PROOF.md. Measurements preceded only the + equivalent size_t constant and error-reporting correction; no success-path + workload, snapshot or algorithm changed. +- git diff --check: passed. + +CTest integrates the same frozen expectations into existing Linux CI, but this +turn did not execute Linux, UBSan, physical power-cut, target-server or cluster +checks. ASan is not UBSan. Process restarts are graceful; M5.7 fault injection +remains separate coverage. No production durability or planet capacity claim. +No Argo or World0 operation occurred. Next: M6.1 units and environmental coupling. diff --git a/docs/engineering/WORLD_PROOF.md b/docs/engineering/WORLD_PROOF.md new file mode 100644 index 0000000..a2e0124 --- /dev/null +++ b/docs/engineering/WORLD_PROOF.md @@ -0,0 +1,85 @@ +# M5.8 bounded world proof + +Scope: [ADR-0049](../adr/0049-bounded-world-proof.md), Windows x64, MSVC 19.44, +Release preset, 2026-09-26. No world format, generator or simulation version changes. + +```mermaid +flowchart LR + A[Prepare process: generate and excavate] --> B[Base snapshot + committed journal] + B --> C[Compact process: replay and checkpoint exact state] + C --> D[Verify process: restore compact snapshot] + D --> E[Canonical equality + cell oracle + clean regeneration] +``` + +Build with the README presets. CTest `world-process-restart` runs all workloads +through three separate OS processes. To inspect one manually, choose a new path +whose parent exists (use `.exe` on Windows): + +```sh +build/release/evo-world-proof prepare heavy build/my-world-proof +build/release/evo-world-proof compact heavy build/my-world-proof +build/release/evo-world-proof verify heavy build/my-world-proof +``` + +Prepare refuses existing directories. Every invocation prints JSON; CTest retains +reports and files under `build//world-proof/`. No phase deletes data. +The tool is developer evidence, not a server, migration utility or deployment. + +## Workloads and correctness + +All fixtures use seed 123456, eight 16-cube chunks, a 4 MiB accounted resident budget +and chunk Z=-1000 (local cell Z starts at -16000m). This is deep local excavation, +not a spherical planet or core simulation. Uniform loads contiguous untouched rock; +sparse loads eight widely separated chunks and removes one complete cell; heavy +applies 64 commands of 64 cuts across four chunks, changing 4096 distinct cells. +Heavy removal at cell ordinal i is `1 + i % 257`, for i=0..1023 in each edited chunk. + +An analytical oracle inspects every material/fill and checks remaining occupied +volume plus debris equals the initial volume. Canonical equality includes revisions +and retry history. An exact duplicate of the last command must retain its receipt. +Verify also evicts/regenerates a clean chunk, compares every cell against the base +generator and rejects the old view. Frozen hashes are regression expectations, +not independent correctness proofs or cryptographic integrity checks. + +| Workload | Commands / cuts | Debris volume units | Canonical hash | Accounted bytes before / after | Snapshot / journal bytes | +|---|---:|---:|---|---:|---:| +| Uniform | 0 / 0 | 0 | db06d14d81c62c8c | 274632 / 274632 | 131468 / 68 | +| Sparse | 1 / 1 | 65535 | 9cd2752316152d88 | 274632 / 278736 | 131592 / 140 | +| Heavy | 64 / 4096 | 526360 | 0dc4f24dc24f58e0 | 274632 / 340168 | 339084 / 198212 | + +Hex JSON omits leading zeros. These goldens are enforced by the same test on Windows +and Linux CI; Linux execution for this change is not yet observed locally. + +## Measured costs + +Five separate complete Release workflows on the development Windows host, with +filesystem caches uncontrolled. Values below are median [minimum, maximum] ms; +they are observations, not thresholds or Dell R730xd capacity estimates. + +| Workload | Generate/load | All edits | Encode | Restore compact snapshot | Compact committed journal | +|---|---:|---:|---:|---:|---:| +| Uniform | .834 [.829,.864] | 0 | .320 [.317,.330] | 1.295 [1.291,1.313] | 7.080 [6.847,7.685] | +| Sparse | .841 [.835,.855] | .040 [.040,.040] | .330 [.322,.331] | 1.344 [1.333,1.362] | 8.338 [8.226,8.706] | +| Heavy | .836 [.833,.855] | 10.808 [10.489,11.718] | .605 [.601,.614] | 5.330 [5.269,5.817] | 25.000 [23.561,25.446] | + +Generation includes store creation/loading. Edit time sums excavation calls, excluding +request construction. Restore timing excludes the freshly reconstructed oracle fixture +and its final comparison; compaction includes committed-state verification, encoding +and filesystem publication. JSON also reports journal-build, publication and clean +regeneration timings; regeneration includes comparison against the generated base. + +Accounted bytes cover the ChunkStore contract, not process peak memory: fixture +vectors, serialization buffers, detached replay candidates, allocator/OS overhead +and filesystem caches are excluded. Both source and recovered states coexist in +this verification tool. Snapshot sizes include full canonical state and exact retry +history. Heavy compaction's 339084 bytes exceed its 131468-byte base plus 198212-byte +journal; compaction removes replay work, and does not promise smaller storage. +Old generations remain on disk; orphan/retention cleanup is a later policy. + +## Limits and next gate + +Graceful process restarts complement M5.7's injected publication failures; they +do not prove physical power-loss or multi-host durability. No planet-scale memory, +throughput, hydrology, renderer or biological nutrient conversion claim follows. +M6.1 must establish environmental units, habitat mapping and volume-to-matter +conversion before coupling this terrain to biology. diff --git a/tests/world_process_restart.cmake b/tests/world_process_restart.cmake new file mode 100644 index 0000000..191f382 --- /dev/null +++ b/tests/world_process_restart.cmake @@ -0,0 +1,31 @@ +if(NOT DEFINED EVO_WORLD_PROOF OR NOT DEFINED TEST_DIR) + message(FATAL_ERROR "EVO_WORLD_PROOF and TEST_DIR are required") +endif() +string(RANDOM LENGTH 16 ALPHABET 0123456789abcdef run_id) +set(run_dir "${TEST_DIR}/${run_id}") +file(MAKE_DIRECTORY "${run_dir}") +# Every command launches a fresh process. Retain build-local evidence; never delete roots. +foreach(workload IN ITEMS uniform sparse heavy) + foreach(phase IN ITEMS prepare compact verify) + execute_process(COMMAND "${EVO_WORLD_PROOF}" "${phase}" "${workload}" "${run_dir}/${workload}" + RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error TIMEOUT 30) + if(NOT result STREQUAL "0") + message(FATAL_ERROR "${workload}/${phase}: ${result}: ${error}") + endif() + file(WRITE "${run_dir}/${workload}-${phase}.json" "${output}") + string(JSON hash GET "${output}" hash) + string(JSON debris GET "${output}" debris_volume) + if(phase STREQUAL "prepare") + set(expected_hash "${hash}") + set(expected_debris "${debris}") + elseif(NOT hash STREQUAL expected_hash OR NOT debris STREQUAL expected_debris) + message(FATAL_ERROR "State differs across processes for ${workload}") + endif() + endforeach() + execute_process(COMMAND "${EVO_WORLD_PROOF}" prepare "${workload}" "${run_dir}/${workload}" + RESULT_VARIABLE repeat OUTPUT_QUIET ERROR_QUIET TIMEOUT 30) + if(NOT repeat STREQUAL "1") + message(FATAL_ERROR "prepare must refuse an existing proof directory") + endif() +endforeach() +message(STATUS "World proof reports: ${run_dir}")