Add v5 primitive-life session wire protocol
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (ecs) (push) Successful in 1m56s
Foundation / checks (client) (push) Successful in 12m41s
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 (postgres) (push) Canceled after 2m43s
Foundation / checks (network) (push) Canceled after 13m22s
Foundation / checks (checks) (push) Canceled after 15m28s

This commit is contained in:
dingo
2026-10-10 13:15:20 -04:00
parent 066b85333b
commit 8c6e244dad
8 changed files with 248 additions and 32 deletions
+16 -1
View File
@@ -371,7 +371,7 @@ void session_codec() {
mutated.at(0) ^= 1;
CHECK(refused(decode_session(mutated), SessionCodecError::bad_magic));
mutated = bytes;
mutated.at(4) = 5; // A future version.
mutated.at(4) = 6; // A future version.
CHECK(refused(decode_session(mutated), SessionCodecError::unsupported_version));
mutated = bytes;
mutated.at(7) = 1;
@@ -400,6 +400,21 @@ void session_codec() {
CHECK(std::get<SessionIntention>(*decode_session(encode_session(intent))) == intent);
const ActionOutcome outcome{5, ActionResult::not_committed, 0, 0};
CHECK(std::get<ActionOutcome>(*decode_session(encode_session(outcome))) == outcome);
const std::array<SessionMessage, 4> life_messages{
PrimitiveLifeRequest{7, 8, 9}, PrimitiveLifeReceipt{9, AdmitStatus::admitted, 10},
PrimitiveLifeOutcome{9, PrimitiveLifeResult::born, 11, 12}, PrimitiveLifeQuery{9}};
for (const auto& message : life_messages) {
const auto bytes = encode_session(message);
std::uint16_t version{};
const auto decoded = decode_session(bytes, &version);
CHECK(bytes.at(4) == 5 && version == session_protocol_v5);
CHECK(decoded && decoded->index() == message.index());
CHECK(decoded && encode_session(*decoded) == bytes);
auto v4 = bytes;
v4.at(4) = 4;
CHECK(refused(decode_session(v4), SessionCodecError::unknown_type));
}
CHECK(encode_session(life_messages[0], session_protocol_version).empty());
// A state claim appended to an intention (position, energy) is not a valid message.
auto claimed = encode_session(intent);
for (int i = 0; i < 16; ++i)