Bind cellular actions to tick traces
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 40s
Foundation / checks (postgres) (push) Canceled after 0s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (client) (push) Canceled after 1m27s
Foundation / checks (ecs) (push) Canceled after 1m19s
Foundation / checks (network) (push) Canceled after 54s

This commit is contained in:
dingo
2026-10-10 23:34:52 -04:00
parent eeb663d696
commit 0b85aa45c2
6 changed files with 240 additions and 0 deletions
+10
View File
@@ -168,6 +168,11 @@ if(EVO_BUILD_QUIC)
add_library(evo_session_client STATIC src/client/session/region_session.cpp)
target_link_libraries(evo_session_client PUBLIC evo_network_quic evo_network_protocol)
evo_owned_target(evo_session_client)
# M11.3d: bind reliable cellular session actions to the complete life-ordered trace.
add_library(evo_cellular_session_adapter STATIC
src/server/session/cellular_session_batch.cpp)
target_link_libraries(evo_cellular_session_adapter PUBLIC evo::lifecycle evo_network_protocol)
evo_owned_target(evo_cellular_session_adapter)
# M10.4c headless session client (development and test only; ADR-0092).
add_executable(evo-session-probe apps/evo-session-probe/main.cpp)
target_link_libraries(evo-session-probe PRIVATE evo_session_client evo_network_tls)
@@ -205,6 +210,11 @@ if(EVO_BUILD_QUIC)
evo_msquic_runtime(evo-quic-session-tests)
add_test(NAME quic-sessions COMMAND evo-quic-session-tests)
set_tests_properties(quic-sessions PROPERTIES TIMEOUT 120 LABELS "quic;quic-session")
add_executable(evo-cellular-session-batch-tests tests/cellular_session_batch_tests.cpp)
target_link_libraries(evo-cellular-session-batch-tests PRIVATE evo_cellular_session_adapter)
evo_owned_target(evo-cellular-session-batch-tests)
add_test(NAME cellular-session-batch COMMAND evo-cellular-session-batch-tests)
set_tests_properties(cellular-session-batch PROPERTIES TIMEOUT 60 LABELS "quic;cellular")
add_executable(evo-quic-smoke-tests tests/quic_smoke.cpp)
target_link_libraries(evo-quic-smoke-tests PRIVATE evo_msquic evo_network_tls)
evo_owned_target(evo-quic-smoke-tests)
+7
View File
@@ -264,6 +264,13 @@ scoped change before starting the next segment.
changed-input refusal. The caller still needs to own the live scheduler and
join admitted actions to the profile-4 host publication loop. Process kill
tests and CI execution remain open.
- 11.3d-7c: a bounded adapter now overlays carried v7 actions onto the
scheduler-supplied complete living-set inputs. It binds each action by
authenticated account to exactly one live life, preserves the canonical 24
bytes for the atomic action block, and refuses stale, malformed, duplicate or
unowned actions. Other life inputs remain scheduler-owned. The application
scheduler, profile-4 genesis tooling, process kill tests and CI execution
remain open.
## Exit boundary
+14
View File
@@ -6317,3 +6317,17 @@ modified server/client sources and `tests/quic_sessions.cpp`, with and without
this checkout because its cached MSVC 19.44 compiler is reported as having no
known C++23 features. `clang-format` is unavailable on `PATH`. The QUIC test
binary, PostgreSQL suite, and CI have not run here.
## 2026-10-10 — M11.3d-7c action-to-life trace adapter (CI pending)
Added a QUIC-build-only server adapter that overlays carried v7 actions on the
scheduler's complete per-life tick inputs. It verifies tick and account
ownership, rejects duplicate actions for one life in a tick, and emits the
canonical action-block records while leaving other life behavior to the
scheduler. Focused tests cover the overlay, preservation of supplied inputs,
replay-trace matching and malformed/unowned/duplicate refusal.
GCC 13.2 C++23 strict-warning syntax checks pass for the adapter and new test in
debug and `NDEBUG`; `git diff --check` passes. The executable test, full QUIC
preset and CI have not run. The local QUIC preset remains blocked by cached MSVC
C++23 feature detection, as recorded above.
@@ -0,0 +1,32 @@
#pragma once
#include "evo/network/intent_admission.hpp"
#include "evo/server/lifecycle/cellular_batch.hpp"
#include <cstdint>
#include <expected>
#include <span>
#include <vector>
namespace evo::server {
enum class CellularSessionBatchError : std::uint8_t {
tick,
intents,
action,
life,
duplicate_action
};
struct CellularSessionTick {
CellularTickIntents intents;
std::vector<CellularActionRecord> actions;
};
// Overlays authenticated v7 actions onto the scheduler's complete per-life input set.
// The scheduler owns all non-player and no-message behavior; this adapter only binds a
// durable action to the one live account-owned life and preserves its canonical bytes.
[[nodiscard]] std::expected<CellularSessionTick, CellularSessionBatchError>
prepare_cellular_session_tick(const CellularLives& state, std::uint64_t tick,
std::span<const CellularLifeIntent> baseline,
std::span<const network::CarriedAction> actions);
} // namespace evo::server
@@ -0,0 +1,70 @@
#include "evo/server/cellular_session_batch.hpp"
#include <algorithm>
#include <optional>
namespace evo::server {
std::expected<CellularSessionTick, CellularSessionBatchError>
prepare_cellular_session_tick(const CellularLives& state, std::uint64_t tick,
std::span<const CellularLifeIntent> baseline,
std::span<const network::CarriedAction> actions) {
if (tick == 0 || tick != state.tick() + 1)
return std::unexpected{CellularSessionBatchError::tick};
if (baseline.size() != state.lives().size())
return std::unexpected{CellularSessionBatchError::intents};
if (actions.size() > max_cellular_action_records)
return std::unexpected{CellularSessionBatchError::action};
CellularSessionTick prepared;
prepared.intents.lives.assign(baseline.begin(), baseline.end());
std::ranges::sort(prepared.intents.lives, {}, &CellularLifeIntent::life_id);
for (std::size_t i = 0; i < state.lives().size(); ++i)
if (prepared.intents.lives[i].life_id != state.lives()[i].identity.life ||
(i != 0 && prepared.intents.lives[i - 1].life_id ==
prepared.intents.lives[i].life_id))
return std::unexpected{CellularSessionBatchError::intents};
prepared.actions.reserve(actions.size());
for (const auto& action : actions) {
if (!action.account.valid() || action.action_id == 0 || action.tick != tick ||
action.kind != network::ActionKind::cellular || !action.cellular_input)
return std::unexpected{CellularSessionBatchError::action};
const auto input = network::decode_cellular_action_input(*action.cellular_input);
if (!input || input->tick != tick)
return std::unexpected{CellularSessionBatchError::action};
const auto life = std::ranges::find(state.lives(), action.account.bytes,
&CellularOwnedLife::account);
if (life == state.lives().end())
return std::unexpected{CellularSessionBatchError::life};
const auto owned_intent = std::ranges::lower_bound(
prepared.intents.lives, life->identity.life, {}, &CellularLifeIntent::life_id);
if (owned_intent == prepared.intents.lives.end() ||
owned_intent->life_id != life->identity.life)
return std::unexpected{CellularSessionBatchError::intents};
if (std::ranges::find_if(prepared.actions, [&](const CellularActionRecord& previous) {
return previous.account == action.account.bytes;
}) != prepared.actions.end())
return std::unexpected{CellularSessionBatchError::duplicate_action};
owned_intent->intent.movement = {input->move_x, input->move_y};
owned_intent->intent.intake_target =
input->has_intake_target
? std::optional<biology::CellularPatchAddress>{biology::CellularPatchAddress{
input->intake_x_um, input->intake_y_um}}
: std::nullopt;
CellularActionRecord record;
record.account = action.account.bytes;
record.action_id = action.action_id;
record.input = *action.cellular_input;
prepared.actions.push_back(record);
}
std::ranges::sort(prepared.actions, [](const CellularActionRecord& left,
const CellularActionRecord& right) {
if (left.account != right.account)
return left.account < right.account;
return left.action_id < right.action_id;
});
return prepared;
}
} // namespace evo::server
+107
View File
@@ -0,0 +1,107 @@
#include "evo/server/cellular_session_batch.hpp"
#include <array>
#include <cstdint>
#include <cstdio>
#include <source_location>
#include <stdexcept>
#include <string>
#include <vector>
namespace {
using namespace evo;
using namespace evo::server;
void check(bool value, std::source_location at = std::source_location::current()) {
if (!value)
throw std::runtime_error("cellular session batch line " + std::to_string(at.line()));
}
#define CHECK(...) check(static_cast<bool>(__VA_ARGS__))
accounting::Inventory founder_price(std::uint64_t count) {
const auto endowment = biology::primitive_endowment();
CHECK(endowment);
auto funding = endowment->body;
funding.energy.value = endowment->reserve.energy.value + endowment->construction.value;
funding.energy.value *= count;
for (auto& channel : funding.matter)
channel.value *= count;
return funding;
}
void actions_bind_to_owned_life_and_preserve_other_inputs() {
auto primitive = PrimitiveLives::create(
{90, 1, 7, 17, founder_price(2), {{0, 0}, {20, 0}}});
CHECK(primitive);
LifeRequest request{};
request.account.back() = 1;
request.action = 1;
CHECK((*primitive)->spawn(request, {1, 101, 201, 301, {1}}));
request.account.back() = 2;
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}}}}}}};
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});
CHECK(state && (*state)->lives().size() == 2);
const auto& controlled = (*state)->lives()[0];
const auto& other = (*state)->lives()[1];
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});
network::CarriedAction action{network::AccountId{controlled.account}, 77, 2,
network::ActionKind::cellular, input};
const std::array actions{action};
const auto prepared = prepare_cellular_session_tick(**state, 2, baseline, actions);
CHECK(prepared && prepared->intents.lives.size() == 2 && prepared->actions.size() == 1);
CHECK(prepared->intents.lives[0] ==
CellularLifeIntent{controlled.identity.life,
{{-3, 4}, biology::CellularPatchAddress{0, 0}}});
CHECK(prepared->intents.lives[1] == baseline[1]);
CHECK(prepared->actions[0] ==
CellularActionRecord{controlled.account, 77, input});
CellularBatch batch;
batch.header = {(*state)->world(), (*state)->region(), (*state)->frame(), {}, {}, 1, 2};
batch.header.predecessor.fill(1);
batch.header.predecessor_digest.fill(2);
batch.ticks.push_back(prepared->intents);
CHECK(match_cellular_actions_to_trace(**state, batch, prepared->actions));
auto altered = baseline;
altered[1].intent.movement.x = 10;
const auto preserved = prepare_cellular_session_tick(**state, 2, altered, actions);
CHECK(preserved && preserved->intents.lives[1].intent.movement.x == 10);
CHECK(prepare_cellular_session_tick(**state, 3, baseline, actions).error() ==
CellularSessionBatchError::tick);
CHECK(prepare_cellular_session_tick(**state, 2, std::span{baseline}.first(1), actions).error() ==
CellularSessionBatchError::intents);
const std::array duplicate{action, action};
CHECK(prepare_cellular_session_tick(**state, 2, baseline, duplicate).error() ==
CellularSessionBatchError::duplicate_action);
auto unknown = action;
unknown.account.bytes.back() = 3;
const std::array unknown_actions{unknown};
CHECK(prepare_cellular_session_tick(**state, 2, baseline, unknown_actions).error() ==
CellularSessionBatchError::life);
auto malformed = action;
malformed.cellular_input = std::array<std::uint8_t, network::cellular_action_input_bytes>{};
const std::array malformed_actions{malformed};
CHECK(prepare_cellular_session_tick(**state, 2, baseline, malformed_actions).error() ==
CellularSessionBatchError::action);
}
} // namespace
int main() try {
actions_bind_to_owned_life_and_preserve_other_inputs();
std::puts("cellular session batch: ok");
} catch (const std::exception& e) {
std::fprintf(stderr, "%s\n", e.what());
return 1;
}