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
+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) {