Files
aevolution/include/evo/server/lifecycle/cellular_population_batch.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

55 lines
2.9 KiB
C++

#pragma once
#include "evo/server/lifecycle/cellular_batch.hpp"
#include "evo/server/lifecycle/cellular_population.hpp"
namespace evo::server {
struct CellularPopulationBoundary {
std::uint64_t sequence{};
std::vector<CellularCohortMember> members;
bool operator==(const CellularPopulationBoundary&) const = default;
};
struct CellularPopulationConversion {
std::uint64_t genome{};
bool to_cohort{};
bool operator==(const CellularPopulationConversion&) const = default;
};
struct CellularPopulationBatch {
CellularBatchHeader header;
// Exactly one: 1..64 unattended biological ticks, or a no-tick whole-group conversion.
CellularBatch biology;
std::optional<CellularPopulationConversion> conversion;
std::vector<CellularPopulationBoundary> boundaries;
// 1: envelope 1/owner 6; 2: envelope 2/owner 7; 3: envelope 3/owner 8.
std::uint32_t format_version{1};
bool operator==(const CellularPopulationBatch&) const = default;
};
inline constexpr std::size_t population_batch_header_bytes = 136;
inline constexpr std::size_t max_population_batch_bytes =
population_batch_header_bytes + cellular_batch_bytes_for(biology::max_cellular_frozen_lives) +
max_cellular_batch_ticks * (16 + 16 * biology::max_cellular_frozen_lives);
struct CellularPopulationExecution {
CellularPopulationBatch batch;
std::unique_ptr<CellularPopulation> state;
};
// Lingering controlled cells remain vulnerable. Their permanent death path must
// stay on profile 4; unattended population intervals require full suspension.
[[nodiscard]] bool population_interval_safe(const CellularLives&) noexcept;
// Build an unattended interval from a detached biological copy. Controlled cells
// receive frozen-only intentions; the unchanged wildlife controller supplies the
// rest. The returned recorded intentions replay without rerunning that controller.
[[nodiscard]] std::expected<CellularBatch, CellularPopulationError>
unattended_population_inputs(const CellularLives&, const CellularBatchHeader&);
[[nodiscard]] std::expected<CellularPopulationExecution, CellularPopulationError>
prepare_population_batch(const CellularPopulation& base, CellularBatch biology);
[[nodiscard]] std::expected<CellularPopulationExecution, CellularPopulationError>
prepare_population_conversion(const CellularPopulation& base, CellularBatchHeader header,
CellularPopulationConversion conversion);
[[nodiscard]] std::expected<std::unique_ptr<CellularPopulation>, CellularPopulationError>
replay_population_batch(const CellularPopulation& base, const CellularPopulationBatch& batch);
[[nodiscard]] std::expected<std::vector<std::uint8_t>, CellularPopulationError>
encode_population_batch(const CellularPopulationBatch& batch);
[[nodiscard]] std::expected<CellularPopulationBatch, CellularPopulationError>
decode_population_batch(std::span<const std::uint8_t> bytes);
} // namespace evo::server