Enable durable cellular session actions
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 37s
Foundation / checks (ecs) (push) Successful in 1m53s
Foundation / checks (postgres) (push) Failing after 50s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (network) (push) Canceled after 2m38s
Foundation / checks (tsan) (push) Canceled after 22s
Foundation / checks (client) (push) Canceled after 3m18s
Foundation / checks (deploy) (push) Successful in 5s
Foundation / checks (checks) (push) Failing after 37s
Foundation / checks (ecs) (push) Successful in 1m53s
Foundation / checks (postgres) (push) Failing after 50s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (network) (push) Canceled after 2m38s
Foundation / checks (tsan) (push) Canceled after 22s
Foundation / checks (client) (push) Canceled after 3m18s
This commit is contained in:
@@ -255,8 +255,15 @@ scoped change before starting the next segment.
|
|||||||
profile-4 adapter, pauses on ambiguous commits and resolves/retries the exact
|
profile-4 adapter, pauses on ambiguous commits and resolves/retries the exact
|
||||||
prepared bytes. It exposes final action acknowledgements only after a confirmed
|
prepared bytes. It exposes final action acknowledgements only after a confirmed
|
||||||
receipt. A real-PostgreSQL test exercises host publication followed by a new
|
receipt. A real-PostgreSQL test exercises host publication followed by a new
|
||||||
host instance recovering the result. Session v7 admission, scheduler
|
host instance recovering the result.
|
||||||
ownership, process kill tests and CI execution remain open.
|
- 11.3d-7b: the QUIC client and region-session host can negotiate the reliable
|
||||||
|
v7 cellular action path. Admission requires both durable control and action
|
||||||
|
ledgers, and the server keeps v7 off the M10 probe/view datagrams. Actions
|
||||||
|
retain canonical biological input bytes through carry and can be retried after
|
||||||
|
reconnect; the session test covers durable duplicate-result recovery and
|
||||||
|
changed-input refusal. The caller still needs to own the live scheduler and
|
||||||
|
join admitted actions to the profile-4 host publication loop. Process kill
|
||||||
|
tests and CI execution remain open.
|
||||||
|
|
||||||
## Exit boundary
|
## Exit boundary
|
||||||
|
|
||||||
|
|||||||
@@ -6300,3 +6300,20 @@ its action result, and recovery through a fresh host instance.
|
|||||||
for the host and integration test. Full CMake build, PostgreSQL execution and
|
for the host and integration test. Full CMake build, PostgreSQL execution and
|
||||||
process fault tests remain pending CI; CMake's documented preset still fails its
|
process fault tests remain pending CI; CMake's documented preset still fails its
|
||||||
cached MSVC C++23 feature check.
|
cached MSVC C++23 feature check.
|
||||||
|
|
||||||
|
## 2026-10-10 — M11.3d-7b reliable cellular session actions (CI pending)
|
||||||
|
|
||||||
|
Added the v7 cellular action send API to the client session and opt-in server
|
||||||
|
admission. The server requires durable control and action ledgers, refuses v7
|
||||||
|
unless enabled, and keeps v7 away from the M10 view/intention datagrams. QUIC
|
||||||
|
session coverage checks admitted/carried canonical input, confirmed result,
|
||||||
|
exact retry after reconnect, and refusal when the same durable action ID is
|
||||||
|
reused with changed input. These changes do not yet connect session scheduling
|
||||||
|
to `CellularRegionHost` publication.
|
||||||
|
|
||||||
|
GCC 13.2 C++23 `-fsyntax-only` checks with warnings as errors pass for the
|
||||||
|
modified server/client sources and `tests/quic_sessions.cpp`, with and without
|
||||||
|
`NDEBUG`; `git diff --check` passes. `cmake --preset quic` cannot configure in
|
||||||
|
this checkout because its cached MSVC 19.44 compiler is reported as having no
|
||||||
|
known C++23 features. `clang-format` is unavailable on `PATH`. The QUIC test
|
||||||
|
binary, PostgreSQL suite, and CI have not run here.
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ class RegionSessionClient {
|
|||||||
// retries and reconnects). False unless established and sent.
|
// retries and reconnects). False unless established and sent.
|
||||||
[[nodiscard]] bool send_action(std::uint64_t action_id, network::ActionKind kind,
|
[[nodiscard]] bool send_action(std::uint64_t action_id, network::ActionKind kind,
|
||||||
std::uint64_t tick);
|
std::uint64_t tick);
|
||||||
|
// Protocol v7 only. Reuse the exact same fields and action id after reconnect.
|
||||||
|
[[nodiscard]] bool send_cellular_action(
|
||||||
|
std::uint64_t action_id, std::uint64_t tick, std::int16_t move_x, std::int16_t move_y,
|
||||||
|
std::optional<std::pair<std::uint32_t, std::uint32_t>> intake_target = {});
|
||||||
[[nodiscard]] bool query_action(std::uint64_t action_id);
|
[[nodiscard]] bool query_action(std::uint64_t action_id);
|
||||||
// Primitive profile v5 only. The account and generation are always supplied by the
|
// Primitive profile v5 only. The account and generation are always supplied by the
|
||||||
// authenticated session; callers choose only a stable request id.
|
// authenticated session; callers choose only a stable request id.
|
||||||
|
|||||||
@@ -102,6 +102,9 @@ struct RegionSessionsConfig {
|
|||||||
query_primitive_life;
|
query_primitive_life;
|
||||||
// M11.3 v6 cellular intentions. Opt-in until a cellular state owner consumes them.
|
// M11.3 v6 cellular intentions. Opt-in until a cellular state owner consumes them.
|
||||||
bool accept_cellular_intentions{};
|
bool accept_cellular_intentions{};
|
||||||
|
// M11.3 v7 durable cellular actions. Requires durable control and action ledgers;
|
||||||
|
// the caller must forward carried inputs to the profile-4 region host.
|
||||||
|
bool accept_cellular_actions{};
|
||||||
};
|
};
|
||||||
// The region host's authority, read once per poll.
|
// The region host's authority, read once per poll.
|
||||||
struct HostFacts {
|
struct HostFacts {
|
||||||
|
|||||||
@@ -151,7 +151,8 @@ std::expected<std::unique_ptr<RegionSessionClient>, network::quic::EndpointError
|
|||||||
RegionSessionClient::connect(RegionSessionClientConfig config, Clock::time_point now) {
|
RegionSessionClient::connect(RegionSessionClientConfig config, Clock::time_point now) {
|
||||||
if (config.protocol_version != network::session_protocol_version &&
|
if (config.protocol_version != network::session_protocol_version &&
|
||||||
config.protocol_version != network::session_protocol_v5 &&
|
config.protocol_version != network::session_protocol_v5 &&
|
||||||
config.protocol_version != network::session_protocol_v6)
|
config.protocol_version != network::session_protocol_v6 &&
|
||||||
|
config.protocol_version != network::session_protocol_v7)
|
||||||
return std::unexpected(network::quic::EndpointError::configuration);
|
return std::unexpected(network::quic::EndpointError::configuration);
|
||||||
auto endpoint = network::quic::Endpoint::connect(config.transport);
|
auto endpoint = network::quic::Endpoint::connect(config.transport);
|
||||||
if (!endpoint)
|
if (!endpoint)
|
||||||
@@ -252,9 +253,22 @@ bool RegionSessionClient::send_action(std::uint64_t action_id, network::ActionKi
|
|||||||
static_cast<std::uint16_t>(kind), tick});
|
static_cast<std::uint16_t>(kind), tick});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RegionSessionClient::send_cellular_action(
|
||||||
|
std::uint64_t action_id, std::uint64_t tick, std::int16_t move_x, std::int16_t move_y,
|
||||||
|
std::optional<std::pair<std::uint32_t, std::uint32_t>> intake_target) {
|
||||||
|
auto& m = *impl_;
|
||||||
|
return m.protocol_version == network::session_protocol_v7 &&
|
||||||
|
m.state == RegionSessionState::established && m.welcome && action_id != 0 && tick != 0 &&
|
||||||
|
m.send(network::CellularAction{m.welcome->session, m.welcome->epoch, action_id, tick,
|
||||||
|
move_x, move_y, intake_target.has_value(),
|
||||||
|
intake_target ? intake_target->first : 0,
|
||||||
|
intake_target ? intake_target->second : 0});
|
||||||
|
}
|
||||||
|
|
||||||
bool RegionSessionClient::query_action(std::uint64_t action_id) {
|
bool RegionSessionClient::query_action(std::uint64_t action_id) {
|
||||||
auto& m = *impl_;
|
auto& m = *impl_;
|
||||||
return m.protocol_version == network::session_protocol_version &&
|
return (m.protocol_version == network::session_protocol_version ||
|
||||||
|
m.protocol_version == network::session_protocol_v7) &&
|
||||||
m.state == RegionSessionState::established && m.send(network::ActionQuery{action_id});
|
m.state == RegionSessionState::established && m.send(network::ActionQuery{action_id});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -323,9 +323,11 @@ struct RegionSessions::Impl {
|
|||||||
intents.close(c.session);
|
intents.close(c.session);
|
||||||
return close(c, SessionCloseReason::capacity, now);
|
return close(c, SessionCloseReason::capacity, now);
|
||||||
}
|
}
|
||||||
if (default_interest && c.protocol_version != network::session_protocol_v6)
|
if (default_interest && c.protocol_version != network::session_protocol_v6 &&
|
||||||
|
c.protocol_version != network::session_protocol_v7)
|
||||||
(void)replication.set_interest(c.session, *default_interest).has_value();
|
(void)replication.set_interest(c.session, *default_interest).has_value();
|
||||||
if (markers.area() && c.protocol_version != network::session_protocol_v6)
|
if (markers.area() && c.protocol_version != network::session_protocol_v6 &&
|
||||||
|
c.protocol_version != network::session_protocol_v7)
|
||||||
// Full or refused: the session simply has no marker.
|
// Full or refused: the session simply has no marker.
|
||||||
(void)(c.probe ? markers.open_at(c.session, c.probe->x, c.probe->y)
|
(void)(c.probe ? markers.open_at(c.session, c.probe->x, c.probe->y)
|
||||||
: markers.open(c.session))
|
: markers.open(c.session))
|
||||||
@@ -394,8 +396,10 @@ struct RegionSessions::Impl {
|
|||||||
const auto decoded = network::decode_session(bytes, &wire_version);
|
const auto decoded = network::decode_session(bytes, &wire_version);
|
||||||
if (c.state != State::established || !decoded || wire_version != c.protocol_version ||
|
if (c.state != State::established || !decoded || wire_version != c.protocol_version ||
|
||||||
(c.protocol_version != network::session_protocol_version &&
|
(c.protocol_version != network::session_protocol_version &&
|
||||||
!(config.accept_cellular_intentions &&
|
!((config.accept_cellular_intentions &&
|
||||||
c.protocol_version == network::session_protocol_v6)))
|
c.protocol_version == network::session_protocol_v6) ||
|
||||||
|
(config.accept_cellular_actions &&
|
||||||
|
c.protocol_version == network::session_protocol_v7))))
|
||||||
return close(c, SessionCloseReason::protocol, now);
|
return close(c, SessionCloseReason::protocol, now);
|
||||||
if (const auto* ack = std::get_if<network::SnapshotAck>(&*decoded))
|
if (const auto* ack = std::get_if<network::SnapshotAck>(&*decoded))
|
||||||
return replication.acknowledge(c.session, *ack);
|
return replication.acknowledge(c.session, *ack);
|
||||||
@@ -406,6 +410,8 @@ struct RegionSessions::Impl {
|
|||||||
send_datagram(c, intents.intention(c.session, *m, admission()));
|
send_datagram(c, intents.intention(c.session, *m, admission()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (c.protocol_version == network::session_protocol_v7)
|
||||||
|
return close(c, SessionCloseReason::protocol, now); // No M10 datagrams in v7.
|
||||||
const auto* m = std::get_if<network::SessionIntention>(&*decoded);
|
const auto* m = std::get_if<network::SessionIntention>(&*decoded);
|
||||||
if (!m)
|
if (!m)
|
||||||
return close(c, SessionCloseReason::protocol, now);
|
return close(c, SessionCloseReason::protocol, now);
|
||||||
@@ -525,6 +531,7 @@ struct RegionSessions::Impl {
|
|||||||
if (receipt.status == network::AdmitStatus::duplicate)
|
if (receipt.status == network::AdmitStatus::duplicate)
|
||||||
if (const auto o = intents.query(c.session, {receipt.action_id}, admission());
|
if (const auto o = intents.query(c.session, {receipt.action_id}, admission());
|
||||||
o.result == network::ActionResult::committed_no_effect ||
|
o.result == network::ActionResult::committed_no_effect ||
|
||||||
|
o.result == network::ActionResult::committed ||
|
||||||
o.result == network::ActionResult::not_committed)
|
o.result == network::ActionResult::not_committed)
|
||||||
send(c, o);
|
send(c, o);
|
||||||
}
|
}
|
||||||
@@ -554,10 +561,12 @@ struct RegionSessions::Impl {
|
|||||||
c.protocol_version = wire_version;
|
c.protocol_version = wire_version;
|
||||||
const bool primitive_v5 = static_cast<bool>(config.create_primitive_life);
|
const bool primitive_v5 = static_cast<bool>(config.create_primitive_life);
|
||||||
const bool cellular_v6 = config.accept_cellular_intentions;
|
const bool cellular_v6 = config.accept_cellular_intentions;
|
||||||
|
const bool cellular_v7 = config.accept_cellular_actions;
|
||||||
if ((primitive_v5 && wire_version != network::session_protocol_v5) ||
|
if ((primitive_v5 && wire_version != network::session_protocol_v5) ||
|
||||||
(wire_version == network::session_protocol_v5 && !primitive_v5) ||
|
(wire_version == network::session_protocol_v5 && !primitive_v5) ||
|
||||||
(wire_version == network::session_protocol_v6 && !cellular_v6) ||
|
(wire_version == network::session_protocol_v6 && !cellular_v6) ||
|
||||||
wire_version > network::session_protocol_v6)
|
(wire_version == network::session_protocol_v7 && !cellular_v7) ||
|
||||||
|
wire_version > network::session_protocol_v7)
|
||||||
return close(c, SessionCloseReason::unsupported_version, now);
|
return close(c, SessionCloseReason::unsupported_version, now);
|
||||||
} else if (wire_version != c.protocol_version) {
|
} else if (wire_version != c.protocol_version) {
|
||||||
return close(c, SessionCloseReason::unsupported_version, now);
|
return close(c, SessionCloseReason::unsupported_version, now);
|
||||||
@@ -571,13 +580,21 @@ struct RegionSessions::Impl {
|
|||||||
return refresh(c, *m, now_seconds, now);
|
return refresh(c, *m, now_seconds, now);
|
||||||
if (const auto* m = std::get_if<network::SessionAction>(&*decoded)) {
|
if (const auto* m = std::get_if<network::SessionAction>(&*decoded)) {
|
||||||
if (c.protocol_version == network::session_protocol_v5 ||
|
if (c.protocol_version == network::session_protocol_v5 ||
|
||||||
c.protocol_version == network::session_protocol_v6)
|
c.protocol_version == network::session_protocol_v6 ||
|
||||||
|
c.protocol_version == network::session_protocol_v7)
|
||||||
return close(c, SessionCloseReason::protocol, now);
|
return close(c, SessionCloseReason::protocol, now);
|
||||||
// A durable uniqueness check waits for this poll's single `verify` (M10.9d).
|
// A durable uniqueness check waits for this poll's single `verify` (M10.9d).
|
||||||
if (const auto receipt = intents.admit(c.session, *m, admission()))
|
if (const auto receipt = intents.admit(c.session, *m, admission()))
|
||||||
answer(c, *receipt);
|
answer(c, *receipt);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (const auto* m = std::get_if<network::CellularAction>(&*decoded)) {
|
||||||
|
if (c.protocol_version != network::session_protocol_v7)
|
||||||
|
return close(c, SessionCloseReason::protocol, now);
|
||||||
|
if (const auto receipt = intents.admit(c.session, *m, admission()))
|
||||||
|
answer(c, *receipt);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (const auto* m = std::get_if<network::ActionQuery>(&*decoded)) {
|
if (const auto* m = std::get_if<network::ActionQuery>(&*decoded)) {
|
||||||
if (c.protocol_version == network::session_protocol_v5 ||
|
if (c.protocol_version == network::session_protocol_v5 ||
|
||||||
c.protocol_version == network::session_protocol_v6)
|
c.protocol_version == network::session_protocol_v6)
|
||||||
@@ -586,7 +603,8 @@ struct RegionSessions::Impl {
|
|||||||
}
|
}
|
||||||
if (const auto* m = std::get_if<network::SessionInterest>(&*decoded)) {
|
if (const auto* m = std::get_if<network::SessionInterest>(&*decoded)) {
|
||||||
if (c.protocol_version == network::session_protocol_v5 ||
|
if (c.protocol_version == network::session_protocol_v5 ||
|
||||||
c.protocol_version == network::session_protocol_v6)
|
c.protocol_version == network::session_protocol_v6 ||
|
||||||
|
c.protocol_version == network::session_protocol_v7)
|
||||||
return close(c, SessionCloseReason::protocol, now);
|
return close(c, SessionCloseReason::protocol, now);
|
||||||
(void)replication.set_interest(c.session, *m).has_value(); // Clamped by the server.
|
(void)replication.set_interest(c.session, *m).has_value(); // Clamped by the server.
|
||||||
return;
|
return;
|
||||||
@@ -630,6 +648,9 @@ RegionSessions::create(RegionSessionsConfig config) {
|
|||||||
((config.create_primitive_life || config.query_primitive_life) &&
|
((config.create_primitive_life || config.query_primitive_life) &&
|
||||||
(!config.create_primitive_life || !config.query_primitive_life || !config.ledger)) ||
|
(!config.create_primitive_life || !config.query_primitive_life || !config.ledger)) ||
|
||||||
(config.accept_cellular_intentions && config.create_primitive_life) ||
|
(config.accept_cellular_intentions && config.create_primitive_life) ||
|
||||||
|
(config.accept_cellular_actions &&
|
||||||
|
(!config.actions || !config.ledger || config.create_primitive_life ||
|
||||||
|
config.accept_cellular_intentions)) ||
|
||||||
config.transport.limits.max_connections < config.control.max_sessions ||
|
config.transport.limits.max_connections < config.control.max_sessions ||
|
||||||
config.hello_deadline.count() <= 0 || config.close_flush.count() <= 0 ||
|
config.hello_deadline.count() <= 0 || config.close_flush.count() <= 0 ||
|
||||||
config.renew_interval.count() <= 0 || config.safety_margin.count() <= 0 ||
|
config.renew_interval.count() <= 0 || config.safety_margin.count() <= 0 ||
|
||||||
@@ -789,6 +810,7 @@ void RegionSessions::set_default_interest(network::SessionInterest interest) {
|
|||||||
for (const auto& c : m.connections)
|
for (const auto& c : m.connections)
|
||||||
if (c.state == Impl::State::established &&
|
if (c.state == Impl::State::established &&
|
||||||
c.protocol_version != network::session_protocol_v6 &&
|
c.protocol_version != network::session_protocol_v6 &&
|
||||||
|
c.protocol_version != network::session_protocol_v7 &&
|
||||||
!m.replication.interest(c.session))
|
!m.replication.interest(c.session))
|
||||||
(void)m.replication.set_interest(c.session, interest).has_value();
|
(void)m.replication.set_interest(c.session, interest).has_value();
|
||||||
}
|
}
|
||||||
@@ -812,7 +834,8 @@ void RegionSessions::replicate(
|
|||||||
for (const auto& [session, chunks] : m.replication.tick(tick, with_markers, perceives, payload))
|
for (const auto& [session, chunks] : m.replication.tick(tick, with_markers, perceives, payload))
|
||||||
if (const auto* c = m.by_session(session);
|
if (const auto* c = m.by_session(session);
|
||||||
c && c->state == Impl::State::established &&
|
c && c->state == Impl::State::established &&
|
||||||
c->protocol_version != network::session_protocol_v6)
|
c->protocol_version != network::session_protocol_v6 &&
|
||||||
|
c->protocol_version != network::session_protocol_v7)
|
||||||
for (const auto& chunk : chunks)
|
for (const auto& chunk : chunks)
|
||||||
m.send_datagram(*c, chunk); // A refused chunk leaves the snapshot unacknowledged.
|
m.send_datagram(*c, chunk); // A refused chunk leaves the snapshot unacknowledged.
|
||||||
}
|
}
|
||||||
@@ -838,7 +861,8 @@ bool RegionSessions::set_motion_area(const network::motion::Area& area, std::int
|
|||||||
m.spawn_y = std::clamp(spawn_y, area.min_y, area.max_y);
|
m.spawn_y = std::clamp(spawn_y, area.min_y, area.max_y);
|
||||||
for (const auto& c : m.connections)
|
for (const auto& c : m.connections)
|
||||||
if (c.state == Impl::State::established &&
|
if (c.state == Impl::State::established &&
|
||||||
c.protocol_version != network::session_protocol_v6 && !m.markers.of(c.session))
|
c.protocol_version != network::session_protocol_v6 &&
|
||||||
|
c.protocol_version != network::session_protocol_v7 && !m.markers.of(c.session))
|
||||||
(void)m.markers.open(c.session).has_value();
|
(void)m.markers.open(c.session).has_value();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
+97
-2
@@ -439,7 +439,16 @@ void cellular_v6_session(const Files& f) {
|
|||||||
CHECK(!client->set_interest(SessionInterest{})); // No M10 probe view in cellular v6.
|
CHECK(!client->set_interest(SessionInterest{})); // No M10 probe view in cellular v6.
|
||||||
CHECK(client->view() == nullptr);
|
CHECK(client->view() == nullptr);
|
||||||
h.server->set_default_interest({0, 0, 0, 1});
|
h.server->set_default_interest({0, 0, 0, 1});
|
||||||
h.source = [](const SessionInterest&) { return ReplicationSource{.identity = world_id}; };
|
h.source = [](const SessionInterest&) {
|
||||||
|
return ReplicationSource{.identity = world_id,
|
||||||
|
.field_revision = 0,
|
||||||
|
.organism_revision = 0,
|
||||||
|
.mask = 0,
|
||||||
|
.environment = {},
|
||||||
|
.organisms = {},
|
||||||
|
.markers = {},
|
||||||
|
.marker_area = {}};
|
||||||
|
};
|
||||||
h.pump();
|
h.pump();
|
||||||
CHECK(client->view() == nullptr); // Default M10 snapshots are withheld too.
|
CHECK(client->view() == nullptr); // Default M10 snapshots are withheld too.
|
||||||
CHECK(!client->send_intention(101, 0, 0));
|
CHECK(!client->send_intention(101, 0, 0));
|
||||||
@@ -470,6 +479,90 @@ void cellular_v6_session(const Files& f) {
|
|||||||
CHECK(refused->close_reason() == SessionCloseReason::unsupported_version);
|
CHECK(refused->close_reason() == SessionCloseReason::unsupported_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cellular_v7_action_session(const Files& f) {
|
||||||
|
struct ActionLedgerFake final : ActionLedger {
|
||||||
|
AccountId owner{};
|
||||||
|
std::uint64_t id{};
|
||||||
|
std::optional<DurableActionRecord> record;
|
||||||
|
std::expected<std::optional<ActionOutcome>, ActionLedgerError>
|
||||||
|
find(const AccountId& account_id, std::uint64_t action_id) override {
|
||||||
|
if (record && owner == account_id && id == action_id)
|
||||||
|
return std::optional<ActionOutcome>{record->outcome};
|
||||||
|
return std::optional<ActionOutcome>{};
|
||||||
|
}
|
||||||
|
std::expected<std::optional<DurableActionRecord>, ActionLedgerError>
|
||||||
|
find_record(const AccountId& account_id, std::uint64_t action_id) override {
|
||||||
|
return owner == account_id && id == action_id ? record
|
||||||
|
: std::optional<DurableActionRecord>{};
|
||||||
|
}
|
||||||
|
} actions;
|
||||||
|
FakeLedger control;
|
||||||
|
Harness h{f, 4, 64, &control, [&](server::RegionSessionsConfig& c) {
|
||||||
|
c.actions = &actions;
|
||||||
|
c.accept_cellular_actions = true;
|
||||||
|
}};
|
||||||
|
const auto alice = account(0xA8);
|
||||||
|
auto client = h.connect(h.issuer.grant(alice, 1), session_protocol_v7);
|
||||||
|
CHECK(h.settled(*client) && client->state() == RegionSessionState::established);
|
||||||
|
CHECK(!client->send_action(88, ActionKind::probe, 101));
|
||||||
|
CHECK(client->send_cellular_action(88, 101, 0, 0));
|
||||||
|
std::vector<ActionReceipt> receipts;
|
||||||
|
CHECK(h.until([&] { return !(receipts = client->take_action_receipts()).empty(); }));
|
||||||
|
CHECK(receipts.front() == ActionReceipt{88, AdmitStatus::admitted, 100, 101});
|
||||||
|
const auto carried = h.server->carry(101);
|
||||||
|
CHECK(carried.size() == 1 && carried.front().account == alice &&
|
||||||
|
carried.front().action_id == 88 && carried.front().tick == 101 &&
|
||||||
|
carried.front().kind == ActionKind::cellular && carried.front().cellular_input ==
|
||||||
|
std::optional{encode_cellular_action_input({101, 0, 0, false, 0, 0})});
|
||||||
|
actions.owner = alice;
|
||||||
|
actions.id = 88;
|
||||||
|
actions.record = DurableActionRecord{
|
||||||
|
ActionOutcome{88, ActionResult::committed, 101, 1}, carried.front().cellular_input};
|
||||||
|
h.server->committed(carried, 1);
|
||||||
|
std::vector<ActionOutcome> outcomes;
|
||||||
|
CHECK(h.until([&] { return !(outcomes = client->take_action_outcomes()).empty(); }));
|
||||||
|
CHECK(outcomes.front() == ActionOutcome{88, ActionResult::committed, 101, 1});
|
||||||
|
|
||||||
|
// Exact retry returns the same final outcome. Reusing the key with changed bytes is refused.
|
||||||
|
CHECK(client->send_cellular_action(88, 101, 0, 0));
|
||||||
|
CHECK(h.until([&] { return !(receipts = client->take_action_receipts()).empty(); }));
|
||||||
|
CHECK(receipts.front().status == AdmitStatus::duplicate);
|
||||||
|
CHECK(h.until([&] { return !(outcomes = client->take_action_outcomes()).empty(); }));
|
||||||
|
CHECK(outcomes.front() == ActionOutcome{88, ActionResult::committed, 101, 1});
|
||||||
|
CHECK(client->send_cellular_action(88, 101, 1, 0));
|
||||||
|
CHECK(h.until([&] { return !(receipts = client->take_action_receipts()).empty(); }));
|
||||||
|
CHECK(receipts.front().status == AdmitStatus::invalid_action);
|
||||||
|
|
||||||
|
// A fresh session host resolves the same action from durable result and input bytes.
|
||||||
|
client->close();
|
||||||
|
CHECK(h.until([&] { return client->state() == RegionSessionState::closed; }));
|
||||||
|
Harness restarted{f, 4, 64, &control, [&](server::RegionSessionsConfig& c) {
|
||||||
|
c.actions = &actions;
|
||||||
|
c.accept_cellular_actions = true;
|
||||||
|
}};
|
||||||
|
auto reconnected = restarted.connect(restarted.issuer.grant(alice, 2),
|
||||||
|
session_protocol_v7);
|
||||||
|
CHECK(restarted.settled(*reconnected) &&
|
||||||
|
reconnected->state() == RegionSessionState::established);
|
||||||
|
CHECK(reconnected->send_cellular_action(88, 101, 0, 0));
|
||||||
|
CHECK(restarted.until(
|
||||||
|
[&] { return !(receipts = reconnected->take_action_receipts()).empty(); }));
|
||||||
|
CHECK(receipts.front().status == AdmitStatus::duplicate);
|
||||||
|
CHECK(restarted.until(
|
||||||
|
[&] { return !(outcomes = reconnected->take_action_outcomes()).empty(); }));
|
||||||
|
CHECK(outcomes.front() == ActionOutcome{88, ActionResult::committed, 101, 1});
|
||||||
|
CHECK(reconnected->send_cellular_action(88, 101, 1, 0));
|
||||||
|
CHECK(restarted.until(
|
||||||
|
[&] { return !(receipts = reconnected->take_action_receipts()).empty(); }));
|
||||||
|
CHECK(receipts.front().status == AdmitStatus::invalid_action);
|
||||||
|
|
||||||
|
Harness refused{f, 4, 64, &control};
|
||||||
|
auto unsupported = refused.connect(refused.issuer.grant(account(0xA9), 1),
|
||||||
|
session_protocol_v7);
|
||||||
|
CHECK(refused.settled(*unsupported) && unsupported->state() == RegionSessionState::closed &&
|
||||||
|
unsupported->close_reason() == SessionCloseReason::unsupported_version);
|
||||||
|
}
|
||||||
|
|
||||||
// M10.4: intentions, actions and their distinct answers against a simulated host.
|
// M10.4: intentions, actions and their distinct answers against a simulated host.
|
||||||
void intentions_and_actions(const Files& f) {
|
void intentions_and_actions(const Files& f) {
|
||||||
Harness h{f};
|
Harness h{f};
|
||||||
@@ -507,7 +600,8 @@ void intentions_and_actions(const Files& f) {
|
|||||||
CHECK(outcomes[0].result == ActionResult::pending);
|
CHECK(outcomes[0].result == ActionResult::pending);
|
||||||
CHECK(h.server->carry(102).empty());
|
CHECK(h.server->carry(102).empty());
|
||||||
const auto carried = h.server->carry(103);
|
const auto carried = h.server->carry(103);
|
||||||
CHECK(carried.size() == 1 && carried[0] == CarriedAction{alice, 7, 103, ActionKind::probe});
|
CHECK(carried.size() == 1 &&
|
||||||
|
carried[0] == CarriedAction{alice, 7, 103, ActionKind::probe, std::nullopt});
|
||||||
h.server->committed(carried, 4);
|
h.server->committed(carried, 4);
|
||||||
CHECK(h.until([&] { return !(outcomes = a->take_action_outcomes()).empty(); }));
|
CHECK(h.until([&] { return !(outcomes = a->take_action_outcomes()).empty(); }));
|
||||||
CHECK(outcomes[0] == ActionOutcome{7, ActionResult::committed_no_effect, 103, 4});
|
CHECK(outcomes[0] == ActionOutcome{7, ActionResult::committed_no_effect, 103, 4});
|
||||||
@@ -1293,6 +1387,7 @@ int main() try {
|
|||||||
login_rules(files);
|
login_rules(files);
|
||||||
primitive_v5_session(files);
|
primitive_v5_session(files);
|
||||||
cellular_v6_session(files);
|
cellular_v6_session(files);
|
||||||
|
cellular_v7_action_session(files);
|
||||||
limits(files);
|
limits(files);
|
||||||
durable_control(files);
|
durable_control(files);
|
||||||
intentions_and_actions(files);
|
intentions_and_actions(files);
|
||||||
|
|||||||
Reference in New Issue
Block a user