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:
@@ -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) {
|
||||
|
||||
@@ -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 ==
|
||||
|
||||
@@ -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&) {
|
||||
|
||||
Reference in New Issue
Block a user