feat(cellular): session v14, bundle 15 and rules-13 wildlife
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m29s
Foundation / postgres-tools (push) Successful in 24s
Foundation / server-image (push) Successful in 4m33s
Foundation / image (push) Successful in 4m59s
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 4s
Foundation / checks (postgres) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 5s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (deploy) (push) Successful in 4m29s
Foundation / postgres-tools (push) Successful in 24s
Foundation / server-image (push) Successful in 4m33s
Foundation / image (push) Successful in 4m59s
Session v14 carries the rules-13 revamp: a body block in the owner's view (members, emergence threshold, exclusions, Emerge open, payable energy, mass and the 20 traits), become, emerge and channel exclusions on actions, become on mutation choices, catalog offers (id, chance, cost) and the emerged ending. Older sessions never see a v14 field. The client shows Stay / Become offspring offers named from the shared catalog, continuing as a bud, the organism and its Emerge button, kept channels, the body and the emerged end screen. Bundle 15 (rules 13 on owner format 11) is durable: schema 60 admits it raw-only, stores become as bit 15 of the choice's operator, widens the action input and mutation results, and publishes the 14 -> 15 revamp profile migration. evo-world-clone opens cellular-v10 (cellular-v9 plus the revamp upgrade from --revamp-tuning), resumable and recoverable. Wildlife counts reserve matter as energy, waits for the bud fee, grows organisms one short of emerging, and hunts by the region step's rules-13 engulf test. The play summary adds organisms, offers and the spent pool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,15 @@ struct CellularRevampStepRules {
|
||||
std::uint32_t kill_bubble_per_thousand{500};
|
||||
auto operator<=>(const CellularRevampStepRules&) const = default;
|
||||
};
|
||||
// Rules 13: engulf mass is the body plus the declared share of reserve matter.
|
||||
[[nodiscard]] std::uint64_t cellular_engulf_mass(std::uint64_t body_mass,
|
||||
const accounting::Inventory& reserve,
|
||||
const CellularRevampStepRules& rules) noexcept;
|
||||
// Rules 13: whether a hunter of this engulf mass and capacity may take prey of this engulf mass
|
||||
// and membrane (nanometres), exactly as the region step decides.
|
||||
[[nodiscard]] bool cellular_engulfable(std::uint64_t hunter_mass, std::uint16_t engulf_capacity,
|
||||
std::uint64_t prey_mass, std::uint32_t prey_membrane_nm,
|
||||
const CellularRevampStepRules& rules) noexcept;
|
||||
// Rules 13: one life's heritable feeding, energy and predation values, from its genome.
|
||||
struct CellularRevampLifeInput {
|
||||
CellularBurn burn{};
|
||||
|
||||
@@ -59,20 +59,23 @@ class RegionSessionClient {
|
||||
// retries and reconnects). False unless established and sent.
|
||||
[[nodiscard]] bool send_action(std::uint64_t action_id, network::ActionKind kind,
|
||||
std::uint64_t tick);
|
||||
// Protocol v7-v10. Reuse the exact same fields and action id after reconnect. `engulf`
|
||||
// Protocol v7-v14. Reuse the exact same fields and action id after reconnect. `engulf`
|
||||
// and `bud` (ADR-0124/0125) are exclusive and need a v10 session and no intake target.
|
||||
// `brake` needs v13 or v14; `become` (with `bud`), `emerge` (alone) and `exclude` (matter
|
||||
// channels kept from burning) need v14. Older sessions never send them.
|
||||
[[nodiscard]] bool
|
||||
send_cellular_action(std::uint64_t action_id, std::uint64_t tick, std::int16_t move_x,
|
||||
std::int16_t move_y,
|
||||
std::optional<std::pair<std::uint32_t, std::uint32_t>> intake_target = {},
|
||||
bool engulf = false, bool bud = false, bool brake = false);
|
||||
bool engulf = false, bool bud = false, bool brake = false,
|
||||
bool become = false, bool emerge = false, std::uint8_t exclude = 0);
|
||||
// Protocol v10 (ADR-0121): choose one candidate of the life's outstanding offer. The
|
||||
// receipt names the tick it publishes with; the outcome follows that commit. `tick` is
|
||||
// the client's latest simulated tick (after the offer); the server schedules the next.
|
||||
[[nodiscard]] bool send_cellular_mutation(std::uint64_t action_id, std::uint64_t tick,
|
||||
std::uint64_t life_identity,
|
||||
std::uint64_t event_index, std::uint64_t offer_tick,
|
||||
std::uint16_t operator_id);
|
||||
std::uint16_t operator_id, bool become = false);
|
||||
[[nodiscard]] bool query_action(std::uint64_t action_id);
|
||||
// Primitive profile v5 only. The account and generation are always supplied by the
|
||||
// authenticated session; callers choose only a stable request id.
|
||||
|
||||
@@ -45,19 +45,30 @@ inline constexpr std::uint16_t session_protocol_v12 = 12;
|
||||
// region's current configuration in its perception, each deposit's world velocity, and a brake
|
||||
// flag on cellular actions.
|
||||
inline constexpr std::uint16_t session_protocol_v13 = 13;
|
||||
// v10 to v13 share every cellular message but the perception's contents and v13's brake.
|
||||
// v14 (rules 13, ADR-0179) is v13 plus the cellular revamp: the body block in the perception,
|
||||
// become, emerge and channel exclusions on actions, become on mutation choices, catalog offers
|
||||
// and the emerged ending.
|
||||
inline constexpr std::uint16_t session_protocol_v14 = 14;
|
||||
// v10 to v14 share every cellular message but the perception's contents, v13's brake and v14's
|
||||
// revamp fields.
|
||||
[[nodiscard]] constexpr bool cellular_v10_family(std::uint16_t version) noexcept {
|
||||
return version == session_protocol_v10 || version == session_protocol_v11 ||
|
||||
version == session_protocol_v12 || version == session_protocol_v13;
|
||||
version == session_protocol_v12 || version == session_protocol_v13 ||
|
||||
version == session_protocol_v14;
|
||||
}
|
||||
// Versions whose perception lists pools and bubbles (ADR-0136) instead of square patches.
|
||||
[[nodiscard]] constexpr bool cellular_deposit_version(std::uint16_t version) noexcept {
|
||||
return version == session_protocol_v11 || version == session_protocol_v12 ||
|
||||
version == session_protocol_v13;
|
||||
version == session_protocol_v13 || version == session_protocol_v14;
|
||||
}
|
||||
// Versions that carry captured light and producers (ADR-0176).
|
||||
[[nodiscard]] constexpr bool cellular_light_version(std::uint16_t version) noexcept {
|
||||
return version == session_protocol_v12 || version == session_protocol_v13;
|
||||
return version == session_protocol_v12 || version == session_protocol_v13 ||
|
||||
version == session_protocol_v14;
|
||||
}
|
||||
// Versions that carry liquid motion (rules 12).
|
||||
[[nodiscard]] constexpr bool cellular_liquid_version(std::uint16_t version) noexcept {
|
||||
return version == session_protocol_v13 || version == session_protocol_v14;
|
||||
}
|
||||
// The highest capability a version's mutation offers may name.
|
||||
[[nodiscard]] constexpr std::uint8_t
|
||||
@@ -208,6 +219,10 @@ struct CellularActionInput {
|
||||
bool engulf{};
|
||||
bool bud{}; // Kind 3 (ADR-0125): fund one wildlife bud, zero coordinates, v10 only.
|
||||
bool brake{}; // Byte 13 bit 0 (schema 58, rules 12): oppose relative velocity.
|
||||
// Schema 60 (rules 13): byte 13 bit 1 become the bud, bit 2 emerge; byte 14 the channels
|
||||
// excluded from burning (bits 0-3: C, N, P, other).
|
||||
bool become{}, emerge{};
|
||||
std::uint8_t exclude{};
|
||||
friend bool operator==(const CellularActionInput&, const CellularActionInput&) = default;
|
||||
};
|
||||
inline constexpr std::size_t cellular_action_input_bytes = 24;
|
||||
@@ -224,6 +239,10 @@ struct CellularAction {
|
||||
bool bud{};
|
||||
// v13 (rules 12): brake against relative velocity instead of following the movement.
|
||||
bool brake{};
|
||||
// v14 (rules 13): with `bud`, continue as the bud; leave the region as an organism at the
|
||||
// threshold (no target); matter channels excluded from burning (bits 0-3).
|
||||
bool become{}, emerge{};
|
||||
std::uint8_t exclude{};
|
||||
friend bool operator==(const CellularAction&, const CellularAction&) = default;
|
||||
};
|
||||
// v10 reliable choice. The server binds these values to the authenticated account and
|
||||
@@ -232,12 +251,16 @@ struct CellularMutationAction {
|
||||
std::uint64_t session{}, epoch{}, action_id{}, tick{};
|
||||
std::uint64_t life_identity{}, event_index{}, offer_tick{};
|
||||
std::uint16_t operator_id{};
|
||||
bool become{}; // v14: continue as the offspring the choice splits off.
|
||||
friend bool operator==(const CellularMutationAction&, const CellularMutationAction&) = default;
|
||||
};
|
||||
// v10 server-to-owner offer (ADR-0121, 11.4d): the life's outstanding earned offer, its
|
||||
// candidates in stable operator order (never ranked). Each candidate states the successor's
|
||||
// actual tradeoffs: its capability value and its maintenance and total mass. No candidates
|
||||
// (and zero event/offer) clears a consumed or absent offer.
|
||||
// v14 (rules 13) keeps the layout for a named catalog mutation: `operator_id` is its catalog
|
||||
// id, `parameter` its chance of appearing in parts per million, capability, effect,
|
||||
// maintenance and mass zero, and the cost its tuned cost. The client names it from the catalog.
|
||||
struct CellularOfferedCandidate {
|
||||
std::uint16_t operator_id{};
|
||||
std::uint8_t capability{}, effect{}; // biology::Capability, biology::MutationEffect.
|
||||
@@ -257,8 +280,9 @@ struct CellularMutationOffer {
|
||||
friend bool operator==(const CellularMutationOffer&, const CellularMutationOffer&) = default;
|
||||
};
|
||||
// v10 (ADR-0129): the owner's life ended in `tick`. Cause 1 starved, 2 engulfed, 0 not
|
||||
// recorded (rules below 3). Death is final; a new life is a new request.
|
||||
enum class CellularDeathReason : std::uint8_t { unrecorded, starved, engulfed };
|
||||
// recorded (rules below 3); v14 adds 3, the organism emerged. Death is final; a new life is a
|
||||
// new request.
|
||||
enum class CellularDeathReason : std::uint8_t { unrecorded, starved, engulfed, emerged };
|
||||
struct CellularLifeEnded {
|
||||
std::uint64_t tick{}, life_identity{};
|
||||
CellularDeathReason cause{};
|
||||
@@ -357,6 +381,14 @@ struct CellularLifeDiagnostics {
|
||||
// turn), the authoritative motion state the client predictor reconciles against.
|
||||
std::int32_t velocity_x_q10{}, velocity_y_q10{};
|
||||
std::uint16_t heading{};
|
||||
// v14 only (rules 13): cells in the organism and the emergence threshold, the exclusions
|
||||
// in effect, whether Emerge is open, what the reserve can pay as energy with matter standing
|
||||
// in, total mass, and the heritable body traits (biology::CellularTraits field order).
|
||||
std::uint16_t members{}, emerge_members{};
|
||||
std::uint8_t exclude{};
|
||||
bool can_emerge{};
|
||||
std::uint64_t payable_energy_pj{}, total_mass_fg{};
|
||||
std::array<std::uint16_t, 20> traits{};
|
||||
friend bool operator==(const CellularLifeDiagnostics&,
|
||||
const CellularLifeDiagnostics&) = default;
|
||||
};
|
||||
|
||||
@@ -292,6 +292,12 @@ migrate_cellular_liquid_profile(Postgres&, const FilesystemObjectStore&, const L
|
||||
const CommittedCheckpoint&, Uuid commit, const Sha256Digest& build,
|
||||
const server::CellularLiquidRules& rules,
|
||||
std::chrono::milliseconds timeout, const PublishHooks& hooks = {});
|
||||
// Rules 13: explicit raw-only bundle 14 -> 15, declaring the region's revamp rules.
|
||||
[[nodiscard]] std::expected<CommittedCheckpoint, CellularProfileMigrationFailure>
|
||||
migrate_cellular_revamp_profile(Postgres&, const FilesystemObjectStore&, const LeaseGrant&,
|
||||
const CommittedCheckpoint&, Uuid commit, const Sha256Digest& build,
|
||||
const server::CellularRevampRules& rules,
|
||||
std::chrono::milliseconds timeout, const PublishHooks& hooks = {});
|
||||
// Verify the recorded no-tick operation under current authority, replaying its
|
||||
// entire source/target payload. Version upgrades and profile transitions retain
|
||||
// separate evidence; neither is inferred solely from the target tuple.
|
||||
|
||||
@@ -89,9 +89,12 @@ inline constexpr CellularVersionBundle cellular_v12_versions{10, 8, 2, 1, 1, 4,
|
||||
inline constexpr CellularVersionBundle cellular_v13_versions{11, 9, 2, 1, 1, 5, 4, 2, 1};
|
||||
// Rules 12 on owner format 10 (liquid region), development 6, founder 5 (ADR-0177).
|
||||
inline constexpr CellularVersionBundle cellular_v14_versions{12, 10, 2, 1, 1, 6, 5, 2, 1};
|
||||
// Rules 13 on owner format 11 (the cellular revamp), development 7, founder 6 (ADR-0179).
|
||||
inline constexpr CellularVersionBundle cellular_v15_versions{13, 11, 2, 1, 1, 7, 6, 2, 1};
|
||||
// Raw-only retained-plan bundles, which use trace 4 and their own SQL admission.
|
||||
[[nodiscard]] constexpr bool cellular_plan_bundle(const CellularVersionBundle& b) noexcept {
|
||||
return b == cellular_v12_versions || b == cellular_v13_versions || b == cellular_v14_versions;
|
||||
return b == cellular_v12_versions || b == cellular_v13_versions || b == cellular_v14_versions ||
|
||||
b == cellular_v15_versions;
|
||||
}
|
||||
// Zero means this bundle has no population representation.
|
||||
[[nodiscard]] constexpr std::uint32_t
|
||||
@@ -306,6 +309,17 @@ cellular_liquid_upgrade_manifest(const CheckpointManifest& predecessor,
|
||||
cellular_liquid_upgrade_payload(std::span<const std::uint8_t> payload,
|
||||
const CheckpointManifest& predecessor,
|
||||
const server::CellularLiquidRules& rules);
|
||||
// Rules 13 (ADR-0179): explicit raw-only bundle 14 -> 15 upgrade declaring the revamp rules
|
||||
// from the Git tuning file. The rules are the only input; recovery reads them from the target.
|
||||
[[nodiscard]] std::expected<CheckpointManifest, CheckpointError>
|
||||
cellular_revamp_upgrade_manifest(const CheckpointManifest& predecessor,
|
||||
const Sha256Digest& predecessor_digest, Uuid commit,
|
||||
const LeaseGrant& lease, const Sha256Digest& build,
|
||||
std::uint64_t payload_bytes, const Sha256Digest& payload_sha256);
|
||||
[[nodiscard]] std::expected<std::vector<std::uint8_t>, CheckpointError>
|
||||
cellular_revamp_upgrade_payload(std::span<const std::uint8_t> payload,
|
||||
const CheckpointManifest& predecessor,
|
||||
const server::CellularRevampRules& rules);
|
||||
// ADR-0174: explicit one-way, no-tick profile 5 -> 6 transition. The payload wraps the
|
||||
// identical population with its declared environment; bundle and policy are unchanged.
|
||||
[[nodiscard]] std::expected<CheckpointManifest, CheckpointError>
|
||||
|
||||
@@ -61,6 +61,8 @@ struct CellularActionRecord {
|
||||
struct CellularMutationActionInput {
|
||||
std::uint64_t life_id{}, event_index{}, offer_tick{};
|
||||
std::uint16_t operator_id{};
|
||||
// Rules 13: continue as the split's offspring. Stored as bit 15 of the operator (schema 60).
|
||||
bool become{};
|
||||
friend bool operator==(const CellularMutationActionInput&,
|
||||
const CellularMutationActionInput&) = default;
|
||||
};
|
||||
|
||||
@@ -239,6 +239,7 @@ struct CellularLifeTickFeedback {
|
||||
CellularPresence presence{CellularPresence::active};
|
||||
bool resume_blocked{};
|
||||
accounting::Picojoules light{}; // Rules 11 (ADR-0175): light captured this tick.
|
||||
std::uint8_t exclude{}; // Rules 13: the matter channels kept from burning this tick.
|
||||
auto operator<=>(const CellularLifeTickFeedback&) const = default;
|
||||
};
|
||||
// Which owner version a new region starts on. Offers: format 2, rules 2 (the M11.3/11.4
|
||||
@@ -280,6 +281,10 @@ enum class CellularLivesError : std::uint8_t {
|
||||
checksum,
|
||||
noncanonical
|
||||
};
|
||||
// Rules 13 (reproduction plan section 6): the genome an organism of `members` cells develops
|
||||
// as (the target size times its members); the genome itself for a single cell.
|
||||
[[nodiscard]] std::expected<biology::Genome, CellularLivesError>
|
||||
cellular_organism_genome(const biology::Genome& genome, std::uint32_t members);
|
||||
|
||||
// In-memory authoritative cellular owner. It consumes funded profile-3 opening
|
||||
// state but never mutates or reinterprets that checkpoint. Each tick is applied
|
||||
@@ -310,6 +315,8 @@ class CellularLives {
|
||||
[[nodiscard]] const biology::LineageArchive& archive() const noexcept;
|
||||
[[nodiscard]] accounting::Inventory nursery() const noexcept;
|
||||
[[nodiscard]] accounting::Inventory heat() const noexcept;
|
||||
// Rules 13: burned matter and kill remainders waiting to drip back as bubbles.
|
||||
[[nodiscard]] accounting::Inventory spent() const noexcept;
|
||||
[[nodiscard]] accounting::Inventory opening_total() const noexcept;
|
||||
[[nodiscard]] accounting::Inventory current_total() const noexcept;
|
||||
[[nodiscard]] const CellularBoundaryLedger& boundary_ledger() const noexcept;
|
||||
|
||||
@@ -22,6 +22,10 @@ struct CellularPlaySummary {
|
||||
std::uint64_t lifespan_min{}, lifespan_median{}, lifespan_max{};
|
||||
// Reproduction and evolution: buds so far, mutations applied, living variety.
|
||||
std::uint64_t buds{}, mutations{}, living_genomes{}, deepest_lineage{};
|
||||
// Rules 13: living organisms and the largest one's cells; offers waiting for a choice and
|
||||
// offers earned by the living; matter in the spent pool.
|
||||
std::uint64_t organisms{}, largest_organism{}, offers_pending{}, offers_earned{};
|
||||
std::uint64_t spent_matter_fg{};
|
||||
friend bool operator==(const CellularPlaySummary&, const CellularPlaySummary&) = default;
|
||||
};
|
||||
|
||||
|
||||
@@ -183,9 +183,12 @@ class RegionSessions {
|
||||
// A published v10 choice's outcome, to the account's current v10 session if any.
|
||||
[[nodiscard]] bool send_mutation_outcome(const network::AccountId& account,
|
||||
const network::ActionOutcome& outcome);
|
||||
// The owner's outstanding offer (11.4d), to the account's current v10 session if any.
|
||||
// The owner's outstanding offer (11.4d), to the account's current v10 session if any. A
|
||||
// rules-13 catalog offer (`named`) goes only to a v14 session, an operator offer only to
|
||||
// v10-v13.
|
||||
[[nodiscard]] bool send_mutation_offer(const network::AccountId& account,
|
||||
const network::CellularMutationOffer& offer);
|
||||
const network::CellularMutationOffer& offer,
|
||||
bool named = false);
|
||||
// 11.8 (ADR-0129): the owner's life ended, with its cause, to its v10 session if any.
|
||||
[[nodiscard]] bool send_life_ended(const network::AccountId& account,
|
||||
const network::CellularLifeEnded& ended);
|
||||
|
||||
Reference in New Issue
Block a user