Add cellular mutation action protocol v10
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m52s
Foundation / checks (checks) (push) Failing after 4m1s
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 11m9s
Foundation / checks (network) (push) Canceled after 9m18s
Foundation / checks (postgres) (push) Canceled after 7m18s

This commit is contained in:
dingo
2026-10-11 06:57:22 -04:00
parent 50b6e25c0c
commit 9da2bd37dd
6 changed files with 161 additions and 29 deletions
+37 -1
View File
@@ -182,6 +182,40 @@ void v9_perception_carries_only_valid_owner_diagnostics() {
CHECK(!clear_bytes.empty());
CHECK(std::get<CellularPerception>(*decode_session(clear_bytes)) == cleared);
}
void v10_mutation_choice_is_a_strict_reliable_action() {
const CellularMutationAction action{17, 23, 29, 53, 37, 41, 43, 47};
const auto bytes = encode_session(SessionMessage{action});
CHECK(!bytes.empty() && bytes.size() == session_header_bytes + 64);
std::uint16_t version{};
const auto decoded = decode_session(bytes, &version);
CHECK(decoded && version == session_protocol_v10);
CHECK(std::get<CellularMutationAction>(*decoded) == action);
CHECK(encode_session(*decoded) == bytes);
CHECK(encode_session(SessionMessage{action}, session_protocol_v9).empty());
auto malformed = bytes;
std::fill(malformed.begin() + static_cast<std::ptrdiff_t>(session_header_bytes + 16),
malformed.begin() + static_cast<std::ptrdiff_t>(session_header_bytes + 24),
std::uint8_t{0});
CHECK(!decode_session(malformed)); // The action id is the retry identity.
malformed = bytes;
malformed[session_header_bytes + 58] = 1;
CHECK(!decode_session(malformed)); // Reserved bytes stay canonical.
malformed = bytes;
std::fill(malformed.begin() + static_cast<std::ptrdiff_t>(session_header_bytes + 48),
malformed.begin() + static_cast<std::ptrdiff_t>(session_header_bytes + 56),
std::uint8_t{0xFF});
CHECK(!decode_session(malformed)); // Offer must precede the scheduled tick.
malformed = bytes;
malformed[4] = static_cast<std::uint8_t>(session_protocol_v9);
CHECK(!decode_session(malformed)); // v1-v9 do not know this message.
const ActionOutcome outcome{29, ActionResult::committed, 31, 41};
const auto outcome_bytes = encode_session(SessionMessage{outcome}, session_protocol_v10);
CHECK(!outcome_bytes.empty());
CHECK(std::get<ActionOutcome>(*decode_session(outcome_bytes)) == outcome);
}
} // namespace
int main() {
@@ -191,7 +225,9 @@ int main() {
v7_reliable_action_is_stable_and_strict();
v8_perception_is_bounded_and_canonical();
v9_perception_carries_only_valid_owner_diagnostics();
std::puts("PASS cellular protocol: v6 intention, v7 action, v8/v9 perception framing");
v10_mutation_choice_is_a_strict_reliable_action();
std::puts(
"PASS cellular protocol: v6 intention, v7 action, v8-v10 perception/action framing");
} catch (const std::exception& error) {
std::fprintf(stderr, "%s\n", error.what());
return 1;