diff --git a/docs/adr/0105-cellular-session-intention-v6.md b/docs/adr/0105-cellular-session-intention-v6.md index 52848a5..768a500 100644 --- a/docs/adr/0105-cellular-session-intention-v6.md +++ b/docs/adr/0105-cellular-session-intention-v6.md @@ -43,3 +43,15 @@ V6 provides a bounded, explicit wire value for the next server integration. It does not implement admission, durable tick publication, a life view, client UI or cross-region owner routing; M11.3 remains incomplete until those pieces work end to end. + +## Amendment (2026-10-10, M11.3b-5): opt-in session admission + +`RegionSessionsConfig::accept_cellular_intentions` enables v6 login and routes +cellular datagrams through the existing bounded intention admission. The host +can read deterministic scheduled inputs before advancing the simulated tick; +receipts and cumulative simulated watermarks use the negotiated v6 encoding. +`RegionSessionClient` can send v6 movement and an optional patch address. The +setting defaults off, and primitive-life v5 remains mutually exclusive. This +does not connect those inputs to cellular state, durable publication or client +perception. V6 sessions cannot request the M10 probe replication view or receive +probe markers until a cellular perception view is available. diff --git a/docs/engineering/M11_3_DELIVERY_PLAN.md b/docs/engineering/M11_3_DELIVERY_PLAN.md index 3dcc3d3..28de517 100644 --- a/docs/engineering/M11_3_DELIVERY_PLAN.md +++ b/docs/engineering/M11_3_DELIVERY_PLAN.md @@ -134,6 +134,10 @@ scoped change before starting the next segment. admission rules and expose a deterministic read-only schedule until the host advances its simulated watermark. `RegionSessions` and a durable cellular host still do not consume this schedule. +- 11.3b-5: the opt-in v6 `RegionSessions` path admits cellular datagrams and + 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. ## Exit boundary diff --git a/docs/engineering/VALIDATION.md b/docs/engineering/VALIDATION.md index ad786f2..b6bbce6 100644 --- a/docs/engineering/VALIDATION.md +++ b/docs/engineering/VALIDATION.md @@ -5967,3 +5967,22 @@ test and implementation using `-std=c++23`; and `git diff --check`. The network CMake configure stalled during MSVC compiler detection, so the new CTest registration and complete network build await CI. Linux and full M10 network checks remain pending. + +## 2026-10-10 — M11.3b-5 opt-in v6 session integration (CI pending) + +`RegionSessionsConfig::accept_cellular_intentions` now opts into v6 logins and +routes cellular datagrams through bounded intention admission. The host reads +the deterministic tick schedule before advancing the simulated watermark; the +client sends movement and an optional patch address. V6 cannot invoke M10 probe +actions, request M10 interest, or receive default M10 probe snapshots/markers. +The path still has no cellular life owner, durable publication or cellular view. + +Executed locally: warning-as-error MSVC 19.44 Release/NDEBUG compile of the +changed server, client and QUIC test translation units; direct relink of the +prepared QUIC session-test binary; CTest `quic-sessions` (1/1 passed, including +the v6 acceptance/refusal and legacy-view isolation cases); clang-format 19.1.5 +on changed ranges; clang-tidy 19.1.5 on all three changed C++ files using +`-std=c++23`; and `git diff --check`. CMake regeneration completed, but Ninja +idled without launching a compiler, so the changed objects and test executable +were built directly in the existing `build/quic` tree. Linux CI qualification +and the full application build remain pending. diff --git a/include/evo/client/region_session.hpp b/include/evo/client/region_session.hpp index 737e7b3..3b770c4 100644 --- a/include/evo/client/region_session.hpp +++ b/include/evo/client/region_session.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #include // M10.3b client-side session login over QUIC (ADR-0091, schemas/network/session-v1.md). @@ -49,6 +50,11 @@ class RegionSessionClient { // refusal. [[nodiscard]] std::optional send_intention(std::uint64_t tick, std::int16_t move_x, std::int16_t move_y); + // Protocol v6 only. Optional target fields name a visible food patch; they never claim + // position, speed, inventory or acquired stock. + [[nodiscard]] std::optional send_cellular_intention( + std::uint64_t tick, std::int16_t move_x, std::int16_t move_y, + std::optional> intake_target = {}); // A discrete action with a caller-chosen id, unique for the account (stable across // retries and reconnects). False unless established and sent. [[nodiscard]] bool send_action(std::uint64_t action_id, network::ActionKind kind, diff --git a/include/evo/server/region_sessions.hpp b/include/evo/server/region_sessions.hpp index 53f527e..0744b6b 100644 --- a/include/evo/server/region_sessions.hpp +++ b/include/evo/server/region_sessions.hpp @@ -100,6 +100,8 @@ struct RegionSessionsConfig { std::function query_primitive_life; + // M11.3 v6 cellular intentions. Opt-in until a cellular state owner consumes them. + bool accept_cellular_intentions{}; }; // The region host's authority, read once per poll. struct HostFacts { @@ -129,6 +131,10 @@ class RegionSessions { // Actions scheduled for ticks <= `tick`, to be recorded durably with the batch that // simulates that tick (10.4b). Each action is returned once. [[nodiscard]] std::vector carry(std::uint64_t tick); + // Read-only admitted v6 inputs for a tick. The host must inspect them before advancing + // HostFacts::simulated_tick past that tick; poll then publishes the cumulative watermark. + [[nodiscard]] std::vector + cellular_intentions(std::uint64_t tick) const; // These carried actions are durable in `commit_sequence` (each with the tick it rode): // their outcomes go to each account's current session. void committed(std::span actions, std::uint64_t commit_sequence); diff --git a/schemas/network/session-v6-cellular-intention.md b/schemas/network/session-v6-cellular-intention.md index 412bc1d..8729dfd 100644 --- a/schemas/network/session-v6-cellular-intention.md +++ b/schemas/network/session-v6-cellular-intention.md @@ -1,7 +1,11 @@ # Session protocol v6 cellular intention datagram -ADR-0105 defines this message. It is not admitted by the currently integrated -region session server until its v6 cellular-life handler is enabled. +ADR-0105 defines this message. The region session server admits it only when +`RegionSessionsConfig::accept_cellular_intentions` is enabled. This connects +authenticated v6 datagrams to bounded intention admission and tick scheduling; +it does not provide a cellular life owner, durable tick publication or client +presentation. Until a cellular perception view exists, v6 sessions cannot set +replication interest, receive default M10 snapshots or receive probe markers. Each frame starts with the existing 8-byte `EVSN` header. The version is 6, the type is 22 (`cellular_intention`), and header flags are zero. Payload length is diff --git a/src/client/session/region_session.cpp b/src/client/session/region_session.cpp index c990789..4f9920c 100644 --- a/src/client/session/region_session.cpp +++ b/src/client/session/region_session.cpp @@ -62,7 +62,8 @@ struct RegionSessionClient::Impl { return end(SessionCloseReason::protocol, true); // Malformed snapshot. if (const auto ack = accepted.value_or(std::nullopt); ack && connection != 0) // A lost ack only means the next delta is against an older baseline. - (void)endpoint->send_datagram(connection, network::encode_session(*ack)) + (void)endpoint + ->send_datagram(connection, network::encode_session(*ack, protocol_version)) .has_value(); return; } @@ -149,7 +150,8 @@ RegionSessionClient::~RegionSessionClient() = default; std::expected, network::quic::EndpointError> RegionSessionClient::connect(RegionSessionClientConfig config, Clock::time_point now) { if (config.protocol_version != network::session_protocol_version && - config.protocol_version != network::session_protocol_v5) + config.protocol_version != network::session_protocol_v5 && + config.protocol_version != network::session_protocol_v6) return std::unexpected(network::quic::EndpointError::configuration); auto endpoint = network::quic::Endpoint::connect(config.transport); if (!endpoint) @@ -219,6 +221,28 @@ RegionSessionClient::send_intention(std::uint64_t tick, std::int16_t move_x, std return m.next_sequence++; } +std::optional RegionSessionClient::send_cellular_intention( + std::uint64_t tick, std::int16_t move_x, std::int16_t move_y, + std::optional> intake_target) { + auto& m = *impl_; + if (m.protocol_version != network::session_protocol_v6 || + m.state != RegionSessionState::established || m.connection == 0 || !m.welcome) + return std::nullopt; + const network::CellularIntention intention{m.welcome->session, + m.welcome->epoch, + m.next_sequence, + tick, + move_x, + move_y, + intake_target.has_value(), + intake_target ? intake_target->first : 0, + intake_target ? intake_target->second : 0}; + if (!m.endpoint->send_datagram(m.connection, + network::encode_session(intention, m.protocol_version))) + return std::nullopt; + return m.next_sequence++; +} + bool RegionSessionClient::send_action(std::uint64_t action_id, network::ActionKind kind, std::uint64_t tick) { auto& m = *impl_; diff --git a/src/server/session/region_sessions.cpp b/src/server/session/region_sessions.cpp index cf5be68..3501b47 100644 --- a/src/server/session/region_sessions.cpp +++ b/src/server/session/region_sessions.cpp @@ -134,7 +134,8 @@ struct RegionSessions::Impl { } // Realtime answers: a refused datagram is dropped; cumulative watermarks cover it. void send_datagram(const Connection& c, const network::SessionMessage& m) { - (void)endpoint->send_datagram(c.id, network::encode_session(m)).has_value(); + (void)endpoint->send_datagram(c.id, network::encode_session(m, c.protocol_version)) + .has_value(); } [[nodiscard]] network::AdmissionFacts admission() const { return {facts.ready, control.epoch(), facts.simulated_tick}; @@ -322,9 +323,10 @@ struct RegionSessions::Impl { intents.close(c.session); return close(c, SessionCloseReason::capacity, now); } - if (default_interest) + if (default_interest && c.protocol_version != network::session_protocol_v6) (void)replication.set_interest(c.session, *default_interest).has_value(); - if (markers.area()) // Full or refused: the session simply has no marker. + if (markers.area() && c.protocol_version != network::session_protocol_v6) + // Full or refused: the session simply has no marker. (void)(c.probe ? markers.open_at(c.session, c.probe->x, c.probe->y) : markers.open(c.session)) .has_value(); @@ -390,12 +392,20 @@ struct RegionSessions::Impl { return; std::uint16_t wire_version{}; const auto decoded = network::decode_session(bytes, &wire_version); - if (c.state != State::established || !decoded || - wire_version != network::session_protocol_version || - c.protocol_version != network::session_protocol_version) + if (c.state != State::established || !decoded || wire_version != c.protocol_version || + (c.protocol_version != network::session_protocol_version && + !(config.accept_cellular_intentions && + c.protocol_version == network::session_protocol_v6))) return close(c, SessionCloseReason::protocol, now); if (const auto* ack = std::get_if(&*decoded)) return replication.acknowledge(c.session, *ack); + if (c.protocol_version == network::session_protocol_v6) { + const auto* m = std::get_if(&*decoded); + if (!m) + return close(c, SessionCloseReason::protocol, now); + send_datagram(c, intents.intention(c.session, *m, admission())); + return; + } const auto* m = std::get_if(&*decoded); if (!m) return close(c, SessionCloseReason::protocol, now); @@ -543,8 +553,11 @@ struct RegionSessions::Impl { if (c.state == State::hello) { c.protocol_version = wire_version; const bool primitive_v5 = static_cast(config.create_primitive_life); + const bool cellular_v6 = config.accept_cellular_intentions; if ((primitive_v5 && wire_version != network::session_protocol_v5) || - (wire_version == network::session_protocol_v5 && !primitive_v5)) + (wire_version == network::session_protocol_v5 && !primitive_v5) || + (wire_version == network::session_protocol_v6 && !cellular_v6) || + wire_version > network::session_protocol_v6) return close(c, SessionCloseReason::unsupported_version, now); } else if (wire_version != c.protocol_version) { return close(c, SessionCloseReason::unsupported_version, now); @@ -557,7 +570,8 @@ struct RegionSessions::Impl { if (const auto* m = std::get_if(&*decoded)) return refresh(c, *m, now_seconds, now); if (const auto* m = std::get_if(&*decoded)) { - if (c.protocol_version == network::session_protocol_v5) + if (c.protocol_version == network::session_protocol_v5 || + c.protocol_version == network::session_protocol_v6) return close(c, SessionCloseReason::protocol, now); // A durable uniqueness check waits for this poll's single `verify` (M10.9d). if (const auto receipt = intents.admit(c.session, *m, admission())) @@ -565,12 +579,14 @@ struct RegionSessions::Impl { return; } if (const auto* m = std::get_if(&*decoded)) { - if (c.protocol_version == network::session_protocol_v5) + if (c.protocol_version == network::session_protocol_v5 || + c.protocol_version == network::session_protocol_v6) return close(c, SessionCloseReason::protocol, now); return send(c, intents.query(c.session, *m, admission())); } if (const auto* m = std::get_if(&*decoded)) { - if (c.protocol_version == network::session_protocol_v5) + if (c.protocol_version == network::session_protocol_v5 || + c.protocol_version == network::session_protocol_v6) return close(c, SessionCloseReason::protocol, now); (void)replication.set_interest(c.session, *m).has_value(); // Clamped by the server. return; @@ -613,6 +629,7 @@ RegionSessions::create(RegionSessionsConfig config) { config.ticket_lifetime == 0 || config.ticket_lifetime > network::max_ticket_lifetime || ((config.create_primitive_life || config.query_primitive_life) && (!config.create_primitive_life || !config.query_primitive_life || !config.ledger)) || + (config.accept_cellular_intentions && config.create_primitive_life) || config.transport.limits.max_connections < config.control.max_sessions || config.hello_deadline.count() <= 0 || config.close_flush.count() <= 0 || config.renew_interval.count() <= 0 || config.safety_margin.count() <= 0 || @@ -729,7 +746,8 @@ void RegionSessions::poll(const HostFacts& facts, std::uint64_t now_seconds, for (const auto& [session, watermark] : m.intents.simulated(m.admission())) if (auto* c = m.by_session(session); c && c->state == Impl::State::established && - c->protocol_version == network::session_protocol_version) + (c->protocol_version == network::session_protocol_version || + c->protocol_version == network::session_protocol_v6)) m.send_datagram(*c, watermark); for (const auto session : m.control.expire(now_seconds)) if (auto* c = m.by_session(session)) @@ -751,6 +769,11 @@ std::vector RegionSessions::carry(std::uint64_t tick) { return impl_->intents.carry(tick); } +std::vector +RegionSessions::cellular_intentions(std::uint64_t tick) const { + return impl_->intents.scheduled_cellular_intentions(tick); +} + void RegionSessions::committed(std::span actions, std::uint64_t commit_sequence) { impl_->deliver(impl_->intents.committed(actions, commit_sequence)); @@ -764,7 +787,9 @@ void RegionSessions::set_default_interest(network::SessionInterest interest) { auto& m = *impl_; m.default_interest = interest; for (const auto& c : m.connections) - if (c.state == Impl::State::established && !m.replication.interest(c.session)) + if (c.state == Impl::State::established && + c.protocol_version != network::session_protocol_v6 && + !m.replication.interest(c.session)) (void)m.replication.set_interest(c.session, interest).has_value(); } @@ -785,7 +810,9 @@ void RegionSessions::replicate( return s; }; for (const auto& [session, chunks] : m.replication.tick(tick, with_markers, perceives, payload)) - if (const auto* c = m.by_session(session); c && c->state == Impl::State::established) + if (const auto* c = m.by_session(session); + c && c->state == Impl::State::established && + c->protocol_version != network::session_protocol_v6) for (const auto& chunk : chunks) m.send_datagram(*c, chunk); // A refused chunk leaves the snapshot unacknowledged. } @@ -810,7 +837,8 @@ bool RegionSessions::set_motion_area(const network::motion::Area& area, std::int m.spawn_x = std::clamp(spawn_x, area.min_x, area.max_x); m.spawn_y = std::clamp(spawn_y, area.min_y, area.max_y); for (const auto& c : m.connections) - if (c.state == Impl::State::established && !m.markers.of(c.session)) + if (c.state == Impl::State::established && + c.protocol_version != network::session_protocol_v6 && !m.markers.of(c.session)) (void)m.markers.open(c.session).has_value(); return true; } diff --git a/tests/quic_sessions.cpp b/tests/quic_sessions.cpp index 92838c9..3aa5825 100644 --- a/tests/quic_sessions.cpp +++ b/tests/quic_sessions.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include namespace { @@ -429,6 +430,46 @@ void primitive_v5_session(const Files& f) { CHECK(!ledger.claims.empty() && ledger.claims.back().account == account(0xA5)); } +void cellular_v6_session(const Files& f) { + Harness h{f, 4, 64, nullptr, + [](server::RegionSessionsConfig& c) { c.accept_cellular_intentions = true; }}; + const auto alice = account(0xA6); + auto client = h.connect(h.issuer.grant(alice, 1), session_protocol_v6); + CHECK(h.settled(*client) && client->state() == RegionSessionState::established); + CHECK(!client->set_interest(SessionInterest{})); // No M10 probe view in cellular v6. + CHECK(client->view() == nullptr); + h.server->set_default_interest({0, 0, 0, 1}); + h.source = [](const SessionInterest&) { return ReplicationSource{.identity = world_id}; }; + h.pump(); + CHECK(client->view() == nullptr); // Default M10 snapshots are withheld too. + CHECK(!client->send_intention(101, 0, 0)); + CHECK(!client->send_action(1, ActionKind::probe, 101)); + std::optional sequence; + CHECK(h.until([&] { + return (sequence = + client->send_cellular_intention(101, 250, -250, std::pair{3'000u, 2'000u})) + .has_value(); + })); + CHECK(sequence == 1); + std::vector receipts; + CHECK(h.until([&] { return !(receipts = client->take_intention_receipts()).empty(); })); + CHECK(receipts.front() == IntentionReceipt{1, AdmitStatus::admitted, 100}); + const auto pending = h.server->cellular_intentions(101); + CHECK(pending.size() == 1); + CHECK(pending.front().account == alice); + CHECK(pending.front().intention == CellularIntention{must(client->welcome()).session, 5, 1, 101, + 250, -250, true, 3'000, 2'000}); + h.tick = 101; + CHECK(h.until([&] { return client->simulated() && client->simulated()->sequence == 1; })); + CHECK(h.server->cellular_intentions(101).empty()); + + Harness legacy{f}; + auto refused = legacy.connect(legacy.issuer.grant(account(0xA7), 1), session_protocol_v6); + CHECK(legacy.settled(*refused)); + CHECK(refused->state() == RegionSessionState::closed); + CHECK(refused->close_reason() == SessionCloseReason::unsupported_version); +} + // M10.4: intentions, actions and their distinct answers against a simulated host. void intentions_and_actions(const Files& f) { Harness h{f}; @@ -1251,6 +1292,7 @@ int main() try { const auto files = credentials(); login_rules(files); primitive_v5_session(files); + cellular_v6_session(files); limits(files); durable_control(files); intentions_and_actions(files);