Files
aevolution/include/evo/server/lifecycle/cellular_migration_trace.hpp
T
dingoandClaude Opus 5.5 3c753970c8
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 4s
Foundation / postgres-tools (push) Successful in 31s
Foundation / server-image (push) Successful in 4m29s
Foundation / image (push) Successful in 5m43s
feat(cellular): region ticks of up to 4,096 lives for testing (schema 68)
ADR-0182 section 17. The plan's 2,000-organism cap became the rules-12
key region.organism_cap, which was parsed but never enforced; the real
bound was max_cellular_tick_lives = 256 (ADR-0106), which rules 13's
organism cap could not exceed. The bound is now 4,096, for testing limits
only; the DEV tuning file keeps 256.

- max_cellular_tick_lives (4,096) bounds the raw region path: step, owner
  state, batch trace (cellular_batch_bytes_for) and current checkpoint
  traces. max_cellular_frozen_lives (256) keeps cohort populations,
  population batches, migration traces and pre-v3 cellular traces, whose
  database checks are fixed.
- Tuning: reproduction.organism_cap and wildlife_cap accept up to 4,096.
- Schema 68: the trace checker under the current publishers
  (cellular_births_v45) accepts 4,096 intents, births and mutations per
  tick; spawn_wildlife takes up to 256 cells a command.
- Region view and portal: the lineage archive's fill (births of 65,536,
  genomes of 4,096), at which a region stops ticking.
- PostgreSQL suite: 256 wildlife spawned in one command, then a 289-life
  tick published and recovered exactly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 17:30:22 -04:00

63 lines
3.1 KiB
C++

#pragma once
#include "evo/server/lifecycle/cellular_migration.hpp"
#include <array>
namespace evo::server {
struct CellularMigrationEndpoint {
std::uint64_t region{};
std::array<std::uint8_t, 16> predecessor{}, commit{};
std::array<std::uint8_t, 32> predecessor_digest{};
bool operator==(const CellularMigrationEndpoint&) const = default;
};
struct CellularMigrationRequest {
std::array<std::uint8_t, 16> request{};
CellularMigrationEndpoint source, destination;
std::uint64_t genome{};
bool operator==(const CellularMigrationRequest&) const = default;
};
enum class CellularMigrationRepresentation : std::uint8_t { individual = 1, population = 2 };
struct CellularMigrationTrace {
CellularMigrationRepresentation representation{CellularMigrationRepresentation::individual};
std::uint64_t world{}, frame{}, tick{};
CellularMigrationRequest request;
accounting::Inventory transferred;
std::vector<std::uint64_t> members;
// Trace 1 retains rules 8; trace 2 requires rules 9. Both require owner 7.
std::uint32_t format_version{1};
bool operator==(const CellularMigrationTrace&) const = default;
};
inline constexpr std::size_t migration_trace_header_bytes = 256;
inline constexpr std::size_t max_migration_trace_bytes =
migration_trace_header_bytes + 8 * biology::max_cellular_frozen_lives + 8;
struct RecordedCellularMigration {
CellularMigrationTrace trace;
CellularMigrationExecution execution;
};
struct RecordedPopulationMigration {
CellularMigrationTrace trace;
CellularPopulationMigrationExecution execution;
};
// Portable recorded pair, not a receipt or ownership grant. The I/O adapter must
// establish the trusted request against BOTH immutable predecessor manifests and
// digest-checked payloads, then fence/commit both results before activation.
// Durable admission is separate (ADR-0161/schema 54); a trace grants no authority.
[[nodiscard]] std::expected<RecordedCellularMigration, CellularMigrationError>
prepare_migration_trace(const CellularLives&, const CellularLives&,
const CellularMigrationRequest&);
[[nodiscard]] std::expected<RecordedPopulationMigration, CellularMigrationError>
prepare_migration_trace(const CellularPopulation&, const CellularPopulation&,
const CellularMigrationRequest&);
[[nodiscard]] std::expected<CellularMigrationExecution, CellularMigrationError>
replay_migration_trace(const CellularLives&, const CellularLives&,
const CellularMigrationRequest& trusted, const CellularMigrationTrace&);
[[nodiscard]] std::expected<CellularPopulationMigrationExecution, CellularMigrationError>
replay_migration_trace(const CellularPopulation&, const CellularPopulation&,
const CellularMigrationRequest& trusted, const CellularMigrationTrace&);
[[nodiscard]] std::expected<std::vector<std::uint8_t>, CellularMigrationError>
encode_migration_trace(const CellularMigrationTrace&);
[[nodiscard]] std::expected<CellularMigrationTrace, CellularMigrationError>
decode_migration_trace(std::span<const std::uint8_t>);
} // namespace evo::server