Enforce cellular patch perception
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 39s
Foundation / checks (ecs) (push) Successful in 1m57s
Foundation / checks (postgres) (push) Failing after 51s
Foundation / checks (tsan) (push) Failing after 32s
Foundation / checks (network) (push) Failing after 3m3s
Foundation / checks (client) (push) Failing after 4m19s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped

This commit is contained in:
dingo
2026-10-10 23:41:47 -04:00
parent dae0572426
commit 82bef03138
8 changed files with 74 additions and 4 deletions
+5
View File
@@ -144,6 +144,11 @@ scoped change before starting the next segment.
exposes the scheduled input to the host; the session client can send v6 movement
and a requested patch address. V6 currently has no M10 probe view. Biology
ownership, durable publication and perceived cell views remain open.
- 11.3b-6: the cellular owner now exposes a life-scoped exact patch view using
its authoritative footprint and ADR-0103's fixed range. V7 action-to-life
binding refuses a requested patch unless it is in that cell's current view;
source provenance and unseen stock remain private. Network view replication
and client presentation remain open.
- 11.3c-4: ADR-0106 defines stable life-identity arbitration for same-tick patch
contention. A detached multi-life candidate resolves all claims against each
patch's remaining per-channel stock; starvation still refuses the candidate
+12
View File
@@ -6345,3 +6345,15 @@ GCC 13.2 strict-warning syntax checks pass for the updated adapter and test in
debug and `NDEBUG`; `git diff --check` passes. Runtime test execution, the QUIC
preset and CI remain pending; the local cached-MSVC CMake limitation is
unchanged.
## 2026-10-10 — M11.3b-6 authoritative cellular patch perception (CI pending)
Added a life-scoped `CellularLives::perceive` API. It recomputes the cell's
authoritative phenotype footprint and returns only the exact in-range patch
address and stock, excluding provenance. The v7 action adapter now rejects
intake targets outside this view, including guessed distant patches.
GCC 13.2 strict-warning syntax checks pass for the lifecycle, session adapter
and focused tests in debug and `NDEBUG`; `git diff --check` passes. Runtime test
execution and full CI are pending; local CMake remains blocked by its cached
MSVC C++23 feature detection.
@@ -18,6 +18,7 @@ enum class CellularSessionBatchError : std::uint8_t {
action,
life,
duplicate_action,
unperceived_target,
head,
batch_full,
action_limit,
@@ -92,6 +92,11 @@ class CellularLives {
[[nodiscard]] accounting::Inventory opening_total() const noexcept;
[[nodiscard]] accounting::Inventory current_total() const noexcept;
[[nodiscard]] std::vector<std::uint8_t> snapshot() const;
// Exact stock view for one live cell, filtered by its authoritative footprint and the
// M11.3 perception radius. Patch provenance and out-of-range stock are never returned.
[[nodiscard]] std::expected<std::vector<biology::CellularPatchPerception>,
CellularLivesError>
perceive(std::uint64_t life_id) const;
[[nodiscard]] static std::expected<std::unique_ptr<CellularLives>, CellularLivesError>
restore(std::span<const std::uint8_t> bytes, std::uint64_t world, std::uint64_t region,
+19 -2
View File
@@ -267,14 +267,14 @@ struct CellularLives::State {
accounting::Inventory current_total{};
State(std::uint64_t world_id, std::uint64_t region_id, std::uint64_t frame_id,
CellularLivesConfig cfg, NurseryConfig nursery,
CellularLivesConfig cfg, NurseryConfig nursery_definition,
std::unique_ptr<biology::CellularHabitat> map,
std::vector<CellularOwnedLife> living, std::vector<CellularOwnedCorpse> dead,
const biology::LineageArchive& history, accounting::Inventory source,
accounting::Inventory accumulated_heat, accounting::Inventory initial,
accounting::Inventory current)
: world{world_id}, region{region_id}, frame{frame_id}, config{cfg},
nursery_config{std::move(nursery)},
nursery_config{std::move(nursery_definition)},
habitat{std::move(map)}, lives{std::move(living)}, corpses{std::move(dead)},
archive{history}, nursery{source}, heat{accumulated_heat}, opening_total{initial},
current_total{current} {}
@@ -457,6 +457,23 @@ std::vector<std::uint8_t> CellularLives::snapshot() const {
return bytes;
}
std::expected<std::vector<biology::CellularPatchPerception>, CellularLivesError>
CellularLives::perceive(std::uint64_t life_id) const {
const auto life = std::ranges::find(state_->lives, life_id, [](const auto& owned) {
return owned.identity.life;
});
if (life == state_->lives.end())
return std::unexpected{CellularLivesError::invalid_life};
const auto budget = budget_for(state_->archive, *life,
state_->config.ambient_temperature_millikelvin);
if (!budget)
return std::unexpected{budget.error()};
auto view = state_->habitat->perceive(life->position, budget->phenotype.extent);
if (!view)
return std::unexpected{CellularLivesError::habitat};
return std::move(*view);
}
std::expected<std::unique_ptr<CellularLives>, CellularLivesError>
CellularLives::restore(std::span<const std::uint8_t> bytes, std::uint64_t world,
std::uint64_t region, std::uint64_t frame, std::uint64_t tick) {
@@ -37,6 +37,14 @@ prepare_cellular_session_tick(const CellularLives& state, std::uint64_t tick,
&CellularOwnedLife::account);
if (life == state.lives().end())
return std::unexpected{CellularSessionBatchError::life};
if (input->has_intake_target) {
const auto view = state.perceive(life->identity.life);
const biology::CellularPatchAddress target{input->intake_x_um, input->intake_y_um};
if (!view || std::ranges::find(*view, target,
&biology::CellularPatchPerception::address) ==
view->end())
return std::unexpected{CellularSessionBatchError::unperceived_target};
}
const auto owned_intent = std::ranges::lower_bound(
prepared.intents.lives, life->identity.life, {}, &CellularLifeIntent::life_id);
if (owned_intent == prepared.intents.lives.end() ||
+5
View File
@@ -73,6 +73,11 @@ void owner_advances_and_closes_death_atomically() {
const auto first_life_id = owner.lives()[0].identity.life;
const auto second_life_id = owner.lives()[1].identity.life;
const auto visible_patches = owner.perceive(first_life_id);
CHECK(visible_patches && visible_patches->size() == 1 &&
visible_patches->front().address == (evo::biology::CellularPatchAddress{0, 0}) &&
visible_patches->front().available == owner.habitat().patches()[0].stock);
CHECK(owner.perceive(0).error() == CellularLivesError::invalid_life);
const std::array invalid_motion{
CellularLifeIntent{first_life_id, {}},
CellularLifeIntent{second_life_id, {{1'001, 0}, std::nullopt}}};
+19 -2
View File
@@ -41,15 +41,24 @@ void actions_bind_to_owned_life_and_preserve_other_inputs() {
CHECK((*primitive)->spawn(request, {2, 102, 202, 302, {1}}));
biology::CellularHabitatConfig habitat_config{
90, 1, 7, 3'000, 2'000, {{{0, 0}, 29, {{10}, {{{10}, {10}, {10}, {10}}}}}}};
90,
1,
7,
20'000,
20'000,
{{{0, 0}, 29, {{10}, {{{10}, {10}, {10}, {10}}}}},
{{15'000, 15'000}, 30, {{10}, {{{10}, {10}, {10}, {10}}}}}}};
auto habitat = biology::CellularHabitat::create(std::move(habitat_config));
CHECK(habitat);
auto state = CellularLives::create(**primitive, std::move(*habitat),
{{3'000, 2'000}, 1, 293'150});
{{20'000, 20'000}, 1, 293'150});
CHECK(state && (*state)->lives().size() == 2);
const auto& controlled = (*state)->lives()[0];
const auto& other = (*state)->lives()[1];
const auto visible = (*state)->perceive(controlled.identity.life);
CHECK(visible && visible->size() == 1 &&
visible->front().address == (biology::CellularPatchAddress{0, 0}));
const std::array baseline{CellularLifeIntent{controlled.identity.life, {{5, 6}, {}}},
CellularLifeIntent{other.identity.life, {{7, 8}, {}}}};
const auto input = network::encode_cellular_action_input({2, -3, 4, true, 0, 0});
@@ -65,6 +74,14 @@ void actions_bind_to_owned_life_and_preserve_other_inputs() {
CHECK(prepared->actions[0] ==
CellularActionRecord{controlled.account, 77, input});
const auto guessed_input =
network::encode_cellular_action_input({2, 0, 0, true, 15'000, 15'000});
const network::CarriedAction guessed{network::AccountId{controlled.account}, 78, 2,
network::ActionKind::cellular, guessed_input};
const std::array guessed_actions{guessed};
CHECK(prepare_cellular_session_tick(**state, 2, baseline, guessed_actions).error() ==
CellularSessionBatchError::unperceived_target);
CellularBatch batch;
batch.header = {(*state)->world(), (*state)->region(), (*state)->frame(), {}, {}, 1, 2};
batch.header.predecessor.fill(1);