Send the owner its outstanding mutation offer over v10

Session protocol v10 adds type 26: the life's earned offer with its unranked
candidates in operator order and each successor's capability value,
maintenance and total mass. The cellular bridge sends it when the offer or the
owner's session changes and clears a consumed offer; the client keeps the
latest one for the maintainer's choice UI (ADR-0121, 11.4d server half).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
dingo
2026-10-13 23:07:50 -04:00
co-authored by Claude Opus 5.5
parent 187b1a7b98
commit f77956e579
16 changed files with 314 additions and 17 deletions
+32
View File
@@ -247,9 +247,35 @@ class CellularBridge {
view.patches.push_back(visible);
}
(void)sessions_->send_cellular_perception(network::AccountId{life.account}, view);
send_offer(life, tick);
}
std::erase_if(offers_, [&](const SentOffer& sent) {
return std::ranges::find(state.lives(), sent.account,
&server::CellularOwnedLife::account) == state.lives().end();
});
replicated_tick_ = tick;
}
// 11.4d: the owner's outstanding offer is sent reliably when it changes or the owner's
// session changes; an empty view clears an offer that was consumed.
void send_offer(const server::CellularOwnedLife& life, std::uint64_t tick) {
const network::AccountId account{life.account};
const auto session = sessions_->holder(account);
const auto& progress = life.mutation;
const SentOffer current{life.account, session.value_or(0), life.identity.life,
progress.offer ? progress.event_index : 0,
progress.offer ? progress.offer_tick : 0};
auto sent = std::ranges::find(offers_, life.account, &SentOffer::account);
if (sent != offers_.end() && *sent == current)
return;
if (!session || (!progress.offer && sent == offers_.end()))
return; // Nothing to show, or no one to show it to.
if (!sessions_->send_mutation_offer(account, server::offer_view(life, tick)))
return; // Not a v10 owner (or the stream refused): retried on a later tick.
if (sent != offers_.end())
*sent = current;
else
offers_.push_back(current);
}
void shutdown() {
sessions_->shutdown(std::chrono::steady_clock::now());
}
@@ -275,6 +301,12 @@ class CellularBridge {
std::unique_ptr<server::RegionSessions> sessions_;
std::optional<server::SessionWindow> window_;
std::optional<std::uint64_t> replicated_tick_;
struct SentOffer {
server::LifeAccount account{};
std::uint64_t session{}, life{}, event_index{}, offer_tick{};
friend bool operator==(const SentOffer&, const SentOffer&) = default;
};
std::vector<SentOffer> offers_; // Last offer view sent to each owner.
bool shutdown_{};
};
} // namespace evo::server_app
@@ -122,5 +122,12 @@ the later 11.4d client action and review UI are complete.
reservations under the current lease before the next publication".
- The wire `tick` of the choice is the client's latest simulated tick (after
the offer); the server, not the client, chooses the publishing tick.
- Not yet done: replicating the offer's unranked candidates to the owner
(11.4d server half) and the client choice and review UI (maintainer).
- 11.4d server half (2026-10-13): v10 adds message type 26, the owner's
outstanding offer with its unranked candidates in operator order and each
successor's capability value, maintenance and total mass, so the choice can
be shown with its actual tradeoffs. The server sends it to the owner's v10
session when the offer or the session changes and clears it when the offer is
consumed; the engineering client keeps the latest offer for its UI. Type 26
extends v10 before any v10 server reaches DEV; v1-v9 are unchanged.
- Remaining after this: the client choice and review UI (maintainer) and the
11.4d playtest notes.
+5 -1
View File
@@ -90,4 +90,8 @@ pending; no gameplay balance is treated as final by this plan.
session. SQL now refuses a checkpoint that skips a reserved choice, and the
host reloads pending reservations after uncertainty or restart. 11.4c is
complete once CI passes; 11.4d's server half (offer replication to the
owner) is next, and the choice UI stays with the maintainer.
owner) is next, and the choice UI stays with the maintainer.- 11.4d server half: v10 type 26 sends the owner its outstanding offer, with
unranked candidates in operator order and each successor's capability value,
maintenance and total mass, when the offer or the session changes; the
engineering client keeps the latest offer. The choice and review UI and the
11.4d playtest notes remain with the maintainer.
+22
View File
@@ -7318,3 +7318,25 @@ outcome; a v7 session cannot send one.
Executed locally: MSVC Debug `ctest` 68/68; client-network QUIC/session 8/8;
g++-14 `-Werror`, clang-tidy-19 and clang-format 19.1.5 on the host, session,
server main and test sources. The PostgreSQL tests run only in CI.
## 2026-10-13 — M11.4d server half: owner offer replication (CI pending)
Session protocol v10 adds type 26 `CellularMutationOffer` (schema in
`schemas/network/session-v10-cellular-mutation-action.md`): the owner's
outstanding offer with up to eight unranked candidates in operator order and
each successor's capability value, maintenance and total mass. `offer_view`
builds it from the life; the cellular bridge sends it through
`RegionSessions::send_mutation_offer` when the offer or the owner's session
changes, and an empty view clears a consumed offer. The client keeps the
latest offer (`mutation_offer()`); the choice UI stays with the maintainer.
Tests: `cellular-intent-protocol` round-trips an offer and a clear, and refuses
it under v9, out of operator order, with a future offer tick, a non-empty clear,
an unknown capability, non-zero reserved bytes and a short payload.
`quic-sessions` delivers an offer and its clear to a v10 owner only;
`cellular_host_admits_mutation_choices` checks `offer_view` against a real
offer.
Executed locally: MSVC Debug `ctest` 68/68, network 74/74, client-network
88/88; g++-14 `-Werror` and clang-tidy-19 on the protocol, session, host,
client, server main and test sources (no new findings); clang-format 19.1.5.
+3
View File
@@ -95,6 +95,9 @@ class RegionSessionClient {
// Newest owner-filtered cellular sensor view (v8), cleared when no owned life exists.
[[nodiscard]] const std::optional<network::CellularPerception>&
cellular_perception() const noexcept;
// The owned life's outstanding mutation offer (v10), cleared when consumed or absent.
[[nodiscard]] const std::optional<network::CellularMutationOffer>&
mutation_offer() const noexcept;
[[nodiscard]] std::expected<client::EnvironmentPresentation, client::ViewError>
environment() const;
[[nodiscard]] std::expected<client::OrganismPresentation, client::ViewError> organisms() const;
+22 -2
View File
@@ -66,7 +66,8 @@ enum class SessionMessageType : std::uint8_t {
cellular_intention = 22,
cellular_action = 23,
cellular_perception = 24,
cellular_mutation_action = 25
cellular_mutation_action = 25,
cellular_mutation_offer = 26 // Server -> owner, stream (v10).
};
// Admission answers for intentions and actions (wire 0..10).
enum class AdmitStatus : std::uint8_t {
@@ -195,6 +196,24 @@ struct CellularMutationAction {
std::uint16_t operator_id{};
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.
struct CellularOfferedCandidate {
std::uint16_t operator_id{};
std::uint8_t capability{}, effect{}; // biology::Capability, biology::MutationEffect.
std::uint32_t parameter{}; // The successor's value; zero when shed.
std::uint64_t maintenance{}, total_mass{};
friend bool operator==(const CellularOfferedCandidate&,
const CellularOfferedCandidate&) = default;
};
inline constexpr std::size_t max_cellular_offered_candidates = 8;
struct CellularMutationOffer {
std::uint64_t tick{}, life_identity{}, event_index{}, offer_tick{};
std::vector<CellularOfferedCandidate> candidates;
friend bool operator==(const CellularMutationOffer&, const CellularMutationOffer&) = default;
};
// v8 server-to-owner view. Addresses and current inventory are already filtered by
// authoritative cell position/range; provenance and account identity are omitted.
struct CellularPerceivedPatch {
@@ -351,7 +370,8 @@ using SessionMessage =
SimulatedThrough, SessionAction, ActionReceipt, ActionOutcome, ActionQuery,
SessionInterest, SnapshotChunk, SnapshotAck, HandoffOffer, SessionRedirect,
PrimitiveLifeRequest, PrimitiveLifeReceipt, PrimitiveLifeOutcome,
PrimitiveLifeQuery, CellularPerception, CellularMutationAction>;
PrimitiveLifeQuery, CellularPerception, CellularMutationAction,
CellularMutationOffer>;
[[nodiscard]] std::vector<std::uint8_t> encode_session(const SessionMessage& message);
[[nodiscard]] std::vector<std::uint8_t> encode_session(const SessionMessage& message,
@@ -68,6 +68,10 @@ struct CellularMutationReply {
// insufficient funding) is `committed_no_effect`, and the owner's view shows the cell.
[[nodiscard]] network::AdmitStatus admit_status(CellularMutationAdmission admission) noexcept;
[[nodiscard]] network::ActionOutcome action_outcome(const FinalCellularMutation& mutation) noexcept;
// The owner's view of a life's outstanding offer at `tick` (11.4d): candidates in their
// stable operator order; no offer gives an empty view that clears the client's.
[[nodiscard]] network::CellularMutationOffer offer_view(const CellularOwnedLife& life,
std::uint64_t tick);
// Single-writer profile-4 authority. The caller supplies a complete bounded trace;
// the host replays it from its recovered state and advances only on a confirmed head.
+3
View File
@@ -183,6 +183,9 @@ 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.
[[nodiscard]] bool send_mutation_offer(const network::AccountId& account,
const network::CellularMutationOffer& offer);
[[nodiscard]] network::ReplicationStats replication_stats() const;
// M10.9a (ADR-0097): the host's load governor output. While `refuse_logins`, a Hello
// carrying a grant is closed with `capacity` before signature work (handoff tickets are
@@ -29,6 +29,44 @@ admission is enabled, it must bind the action to the authenticated account,
verify the exact current offer and operator, reserve the successor identity
idempotently by `(world, account, action_id)`, then schedule the choice for that
advancing tick. The reliable receipt means admission only; the final outcome is
tied to the committed tick and its recovered cellular checkpoint. This document
defines the wire codec only; runtime admission remains disabled until its
durable reservation and publication path is complete.
tied to the committed tick and its recovered cellular checkpoint.
Runtime admission (11.4c-2): the server ignores the client tick for scheduling
(it is the client's latest simulated tick, after the offer) and publishes the
choice with the tick after its committed head; the receipt's `tick` names it.
Receipt statuses: `admitted`, `not_ready`, `too_many_unresolved` (another
choice of the account is waiting), `invalid_action` (not the exact offer and
candidate, or a changed reuse of the action id), and `duplicate` with the
final outcome. The `ActionOutcome` is `committed` when applied and
`committed_no_effect` for a durable refusal (life died, insufficient funding).
## Type 26 (server to owner)
11.4d adds the owner's outstanding offer as a reliable-stream message, type 26,
sent only to the owning account's v10 session when the offer or the session
changes. Payload, little-endian: a 40-byte prefix followed by `count` 24-byte
candidates.
| Payload offset | Size | Field |
|---:|---:|---|
| 0 | 8 | tick of the view, nonzero |
| 8 | 8 | life identity |
| 16 | 8 | offer event index (zero when cleared) |
| 24 | 8 | offer tick, at or before the view tick (zero when cleared) |
| 32 | 2 | candidate count, 0 to 8 |
| 34 | 6 | reserved, all zero |
Each candidate:
| Offset | Size | Field |
|---:|---:|---|
| 0 | 2 | operator id, nonzero, strictly increasing (stable order, never a rank) |
| 2 | 1 | capability (0 to 6, the genome enum) |
| 3 | 1 | effect (0 adjust up, 1 adjust down, 2 acquire, 3 shed) |
| 4 | 4 | the successor's capability value; zero when shed |
| 8 | 8 | the successor's maintenance |
| 16 | 8 | the successor's total mass |
A message with no candidates clears the client's offer and must carry zero event
and offer tick; one with candidates must name a nonzero life, event and offer
tick. Types 25 and 26 are not decoded under versions 1–9.
+14
View File
@@ -29,6 +29,7 @@ struct RegionSessionClient::Impl {
std::vector<network::PrimitiveLifeOutcome> primitive_life_outcomes;
std::optional<network::SnapshotAssembler> snapshots;
std::optional<network::CellularPerception> cellular_perception;
std::optional<network::CellularMutationOffer> mutation_offer;
std::uint64_t snapshot_chunks{}, snapshot_bytes{};
std::optional<network::HandoffOffer> handoff; // v4: continue at another region.
std::optional<network::RegionAddress> redirect; // v4: the probe is owned elsewhere.
@@ -146,6 +147,14 @@ struct RegionSessionClient::Impl {
cellular_perception = *m;
return;
}
if (const auto* m = std::get_if<network::CellularMutationOffer>(&*decoded)) {
seen_tick(m->tick);
if (m->candidates.empty())
mutation_offer.reset();
else
mutation_offer = *m;
return;
}
if (const auto* m = std::get_if<network::PrimitiveLifeReceipt>(&*decoded)) {
seen_tick(m->server_tick);
return keep(primitive_life_receipts, *m);
@@ -381,6 +390,11 @@ RegionSessionClient::cellular_perception() const noexcept {
return impl_->cellular_perception;
}
const std::optional<network::CellularMutationOffer>&
RegionSessionClient::mutation_offer() const noexcept {
return impl_->mutation_offer;
}
std::expected<client::EnvironmentPresentation, client::ViewError>
RegionSessionClient::environment() const {
const auto& snapshots = impl_->snapshots;
+70
View File
@@ -14,6 +14,8 @@ constexpr std::size_t intention_bytes = (std::size_t{4} * 8) + 4;
constexpr std::size_t cellular_intention_bytes = (std::size_t{4} * 8) + 4 + 1 + 3 + 8;
constexpr std::size_t cellular_action_bytes = (std::size_t{4} * 8) + 4 + 1 + 3 + 8;
constexpr std::size_t cellular_mutation_action_bytes = (std::size_t{7} * 8) + 2 + 6;
constexpr std::size_t cellular_offer_prefix_bytes = (std::size_t{4} * 8) + 2 + 6;
constexpr std::size_t cellular_offered_candidate_bytes = 2 + 1 + 1 + 4 + 8 + 8;
constexpr std::size_t cellular_perception_prefix_bytes = 8 + 8 + 2;
constexpr std::size_t cellular_diagnostics_bytes = 64;
constexpr std::size_t cellular_perception_v9_prefix_bytes =
@@ -37,6 +39,22 @@ constexpr std::size_t life_receipt_bytes = 17;
constexpr std::size_t life_outcome_bytes = 25;
constexpr std::size_t life_query_bytes = 8;
// Seven capabilities and four effects (biology genome/mutation enums, frozen on the wire).
bool valid_offer(const CellularMutationOffer& offer) {
if (offer.tick == 0 || offer.candidates.size() > max_cellular_offered_candidates)
return false;
if (offer.candidates.empty())
return offer.event_index == 0 && offer.offer_tick == 0;
std::uint16_t previous = 0;
for (const auto& candidate : offer.candidates) {
if (candidate.operator_id <= previous || candidate.capability > 6 || candidate.effect > 3)
return false;
previous = candidate.operator_id;
}
return offer.life_identity != 0 && offer.event_index != 0 && offer.offer_tick != 0 &&
offer.offer_tick <= offer.tick;
}
bool valid_diagnostics(const CellularLifeDiagnostics& diagnostics) {
const auto movement = static_cast<std::uint8_t>(diagnostics.movement);
const auto intake = static_cast<std::uint8_t>(diagnostics.intake);
@@ -130,6 +148,7 @@ std::vector<std::uint8_t> encode_session(const SessionMessage& message) {
: session_protocol_v8)
: std::holds_alternative<CellularAction>(message) ? session_protocol_v7
: std::holds_alternative<CellularMutationAction>(message) ? session_protocol_v10
: std::holds_alternative<CellularMutationOffer>(message) ? session_protocol_v10
: std::holds_alternative<CellularIntention>(message) ? session_protocol_v6
: is_life ? session_protocol_v5
: session_protocol_version;
@@ -161,6 +180,9 @@ std::vector<std::uint8_t> encode_session(const SessionMessage& message, std::uin
return {};
if (version != session_protocol_v10 && std::holds_alternative<CellularMutationAction>(message))
return {};
if (const auto* offer = std::get_if<CellularMutationOffer>(&message);
offer && (version != session_protocol_v10 || !valid_offer(*offer)))
return {};
if (const auto* action = std::get_if<CellularAction>(&message);
action && action->engulf &&
(version != session_protocol_v10 || action->has_intake_target || action->intake_x_um ||
@@ -262,6 +284,25 @@ std::vector<std::uint8_t> encode_session(const SessionMessage& message, std::uin
put(out, 0, 6);
return out;
}
std::vector<std::uint8_t> operator()(const CellularMutationOffer& m) const {
auto out = header(SessionMessageType::cellular_mutation_offer,
cellular_offer_prefix_bytes +
m.candidates.size() * cellular_offered_candidate_bytes,
version);
for (const auto value : {m.tick, m.life_identity, m.event_index, m.offer_tick})
put(out, value, 8);
put(out, m.candidates.size(), 2);
put(out, 0, 6);
for (const auto& candidate : m.candidates) {
put(out, candidate.operator_id, 2);
out.push_back(candidate.capability);
out.push_back(candidate.effect);
put(out, candidate.parameter, 4);
put(out, candidate.maintenance, 8);
put(out, candidate.total_mass, 8);
}
return out;
}
std::vector<std::uint8_t> operator()(const CellularPerception& m) const {
auto out = header(SessionMessageType::cellular_perception,
(version == session_protocol_v9 || version == session_protocol_v10
@@ -557,6 +598,35 @@ std::expected<SessionMessage, SessionCodecError> decode_session(std::span<const
return std::unexpected(SessionCodecError::invalid_value);
return m;
}
case static_cast<std::uint8_t>(SessionMessageType::cellular_mutation_offer): {
if (wire_version != session_protocol_v10)
return std::unexpected(SessionCodecError::unsupported_version);
if (payload.size() < cellular_offer_prefix_bytes)
return std::unexpected(SessionCodecError::wrong_length);
const auto count = static_cast<std::size_t>(get(payload, 32, 2));
if (count > max_cellular_offered_candidates ||
payload.size() !=
cellular_offer_prefix_bytes + count * cellular_offered_candidate_bytes)
return std::unexpected(SessionCodecError::wrong_length);
CellularMutationOffer m;
m.tick = get(payload, 0, 8);
m.life_identity = get(payload, 8, 8);
m.event_index = get(payload, 16, 8);
m.offer_tick = get(payload, 24, 8);
if (std::ranges::any_of(payload.subspan(34, 6),
[](std::uint8_t value) { return value != 0; }))
return std::unexpected(SessionCodecError::invalid_value);
for (std::size_t i = 0; i < count; ++i) {
const auto at = cellular_offer_prefix_bytes + i * cellular_offered_candidate_bytes;
m.candidates.push_back({static_cast<std::uint16_t>(get(payload, at, 2)),
payload[at + 2], payload[at + 3],
static_cast<std::uint32_t>(get(payload, at + 4, 4)),
get(payload, at + 8, 8), get(payload, at + 16, 8)});
}
if (!valid_offer(m))
return std::unexpected(SessionCodecError::invalid_value);
return m;
}
case static_cast<std::uint8_t>(SessionMessageType::cellular_perception): {
if (wire_version != session_protocol_v8 && wire_version != session_protocol_v9 &&
wire_version != session_protocol_v10)
+17
View File
@@ -102,6 +102,23 @@ network::ActionOutcome action_outcome(const FinalCellularMutation& mutation) noe
mutation.tick, mutation.commit_sequence};
}
network::CellularMutationOffer offer_view(const CellularOwnedLife& life, std::uint64_t tick) {
network::CellularMutationOffer view{tick, life.identity.life, 0, 0, {}};
const auto& offer = life.mutation.offer;
if (!offer)
return view;
view.event_index = life.mutation.event_index;
view.offer_tick = life.mutation.offer_tick;
for (const auto& candidate : offer->candidates)
if (view.candidates.size() < network::max_cellular_offered_candidates)
view.candidates.push_back(
{candidate.operator_id, static_cast<std::uint8_t>(candidate.target),
static_cast<std::uint8_t>(candidate.effect), candidate.parameter,
candidate.maintenance, candidate.total_mass});
std::ranges::sort(view.candidates, {}, &network::CellularOfferedCandidate::operator_id);
return view;
}
CellularRegionHost::CellularRegionHost(CellularHostConfig config, CellularConnect connect,
std::unique_ptr<persistence::FilesystemObjectStore> objects)
: config_{std::move(config)}, connect_{std::move(connect)}, objects_{std::move(objects)},
+18 -9
View File
@@ -148,6 +148,18 @@ struct RegionSessions::Impl {
(void)endpoint->send_message(c.id, network::encode_session(m, c.protocol_version))
.has_value();
}
// Reliable owner-only v10 messages, to the account's established v10 session.
bool send_to_v10_owner(const network::AccountId& account,
const network::SessionMessage& message) {
for (const auto& c : connections) {
if (c.state != State::established ||
c.protocol_version != network::session_protocol_v10 || c.account_id != account)
continue;
const auto bytes = network::encode_session(message, c.protocol_version);
return !bytes.empty() && endpoint->send_message(c.id, bytes).has_value();
}
return false;
}
// 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, c.protocol_version))
@@ -937,15 +949,12 @@ bool RegionSessions::send_cellular_perception(const network::AccountId& account,
bool RegionSessions::send_mutation_outcome(const network::AccountId& account,
const network::ActionOutcome& outcome) {
auto& m = *impl_;
for (const auto& c : m.connections) {
if (c.state != Impl::State::established ||
c.protocol_version != network::session_protocol_v10 || c.account_id != account)
continue;
return m.endpoint->send_message(c.id, network::encode_session(outcome, c.protocol_version))
.has_value();
}
return false;
return impl_->send_to_v10_owner(account, outcome);
}
bool RegionSessions::send_mutation_offer(const network::AccountId& account,
const network::CellularMutationOffer& offer) {
return impl_->send_to_v10_owner(account, offer);
}
void RegionSessions::clear_cellular_perceptions(std::uint64_t tick) {
+38
View File
@@ -255,6 +255,43 @@ void v10_mutation_choice_is_a_strict_reliable_action() {
CHECK(!outcome_bytes.empty());
CHECK(std::get<ActionOutcome>(*decode_session(outcome_bytes)) == outcome);
}
// 11.4d: the owner's offer lists unranked candidates in operator order with their tradeoffs.
void v10_mutation_offer_is_owner_only_and_canonical() {
const CellularMutationOffer offer{
120, 9, 2, 100, {{3, 1, 0, 40, 150'000, 9'000}, {7, 2, 2, 1, 160'000, 9'500}}};
const auto bytes = encode_session(SessionMessage{offer});
CHECK(bytes.size() == session_header_bytes + 40 + (std::size_t{2} * 24));
std::uint16_t version{};
const auto decoded = decode_session(bytes, &version);
CHECK(decoded && version == session_protocol_v10);
CHECK(std::get<CellularMutationOffer>(*decoded) == offer);
CHECK(encode_session(SessionMessage{offer}, session_protocol_v9).empty());
const CellularMutationOffer cleared{121, 9, 0, 0, {}};
const auto clear_bytes = encode_session(SessionMessage{cleared});
CHECK(!clear_bytes.empty() &&
std::get<CellularMutationOffer>(*decode_session(clear_bytes)) == cleared);
auto unordered = offer;
std::swap(unordered.candidates[0], unordered.candidates[1]);
CHECK(encode_session(SessionMessage{unordered}).empty()); // Stable order, never a rank.
auto future = offer;
future.offer_tick = 121;
CHECK(encode_session(SessionMessage{future}).empty());
auto stale_clear = cleared;
stale_clear.event_index = 2;
CHECK(encode_session(SessionMessage{stale_clear}).empty());
auto malformed = bytes;
malformed[session_header_bytes + 40 + 2] = 7; // No eighth capability.
CHECK(!decode_session(malformed));
malformed = bytes;
malformed[session_header_bytes + 34] = 1; // Reserved bytes stay canonical.
CHECK(!decode_session(malformed));
malformed = bytes;
malformed.pop_back();
CHECK(!decode_session(malformed));
}
} // namespace
int main() {
@@ -266,6 +303,7 @@ int main() {
v8_perception_is_bounded_and_canonical();
v9_perception_carries_only_valid_owner_diagnostics();
v10_mutation_choice_is_a_strict_reliable_action();
v10_mutation_offer_is_owner_only_and_canonical();
std::puts(
"PASS cellular protocol: v6 intention, v7 action, v8-v10 perception/action framing");
} catch (const std::exception& error) {
+8
View File
@@ -5,6 +5,7 @@
#include "evo/persistence/sha256.hpp"
#include "evo/server/cellular_region_host.hpp"
#include <algorithm>
#include <cstdlib>
#include <optional>
#include <source_location>
@@ -556,6 +557,13 @@ void cellular_host_admits_mutation_choices() {
life.mutation.offer_tick,
offer.candidates.front().operator_id};
const auto next = host->state()->tick() + 1;
// 11.4d: the owner's view lists the same candidates in operator order.
const auto view = offer_view(life, next - 1);
CHECK(view.life_identity == life_id && view.event_index == choice.event_index &&
view.offer_tick == choice.offer_tick &&
view.candidates.size() == offer.candidates.size() &&
std::ranges::is_sorted(view.candidates, {},
&evo::network::CellularOfferedCandidate::operator_id));
auto wrong = choice;
wrong.operator_id = 0xFFFF;
CHECK(host->select_mutation(account, control->generation, 31, wrong).status ==
+8
View File
@@ -720,6 +720,14 @@ void cellular_v5_spawn_and_v7_action_share_region_sessions(const Files& f) {
CHECK(h.until([&] { return !(outcomes = engulf_client->take_action_outcomes()).empty(); }));
CHECK(outcomes.front() == ActionOutcome{77, ActionResult::committed, 103, 9});
CHECK(!h.server->send_mutation_outcome(account(0xB7), {55, ActionResult::committed, 103, 9}));
// 11.4d: the owner's offer reaches its v10 session only; an empty view clears it.
const CellularMutationOffer offered{103, 901, 2, 95, {{3, 1, 0, 40, 150'000, 9'000}}};
CHECK(!h.server->send_mutation_offer(account(0xB7), offered));
CHECK(h.server->send_mutation_offer(account(0xBB), offered));
CHECK(h.until([&] { return engulf_client->mutation_offer().has_value(); }));
CHECK(engulf_client->mutation_offer() == std::optional{offered});
CHECK(h.server->send_mutation_offer(account(0xBB), {104, 901, 0, 0, {}}));
CHECK(h.until([&] { return !engulf_client->mutation_offer().has_value(); }));
h.server->set_default_interest({0, 0, 0, 7});
h.source = [](const SessionInterest&) {