fix(client): schedule cellular actions by an adaptive lead
Foundation / checks (ecs) (push) Successful in 2m36s
Foundation / checks (deploy) (push) Successful in 5m1s
Foundation / checks (checks) (push) Failing after 13m25s
Foundation / checks (network) (push) Successful in 19m48s
Foundation / checks (client) (push) Successful in 21m0s
Foundation / checks (tsan) (push) Successful in 46m45s
Foundation / checks (postgres) (push) Successful in 1h16m51s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
Foundation / checks (ecs) (push) Successful in 2m36s
Foundation / checks (deploy) (push) Successful in 5m1s
Foundation / checks (checks) (push) Failing after 13m25s
Foundation / checks (network) (push) Successful in 19m48s
Foundation / checks (client) (push) Successful in 21m0s
Foundation / checks (tsan) (push) Successful in 46m45s
Foundation / checks (postgres) (push) Successful in 1h16m51s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
Movement, feeding, engulf and bud actions named the view tick + 1, but the server admits only ticks still ahead of its own when an action arrives. The view trails the server by the replication delay, so most actions were refused as outside the server window and the cell froze while ticks advanced. They now use the same adaptive input lead as intentions (2..7 ticks, inside the server's 8-tick window): an outside-window refusal schedules further ahead, admitted receipts tune it, and movement ticks stay strictly increasing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -263,9 +263,11 @@ class RemoteSession {
|
||||
return cellular_play_;
|
||||
}
|
||||
[[nodiscard]] bool request_cellular(CellAction kind, MutationChoice choice = {}) {
|
||||
const auto tick = kind == CellAction::mutation
|
||||
? server_tick_
|
||||
: server_tick_ + (sent_tick_ && *sent_tick_ == server_tick_ ? 2 : 1);
|
||||
const auto lead = cellular_lead_.lead();
|
||||
const auto tick =
|
||||
kind == CellAction::mutation
|
||||
? server_tick_
|
||||
: server_tick_ + lead + (sent_tick_ && *sent_tick_ == server_tick_ ? 1 : 0);
|
||||
if (!cellular_trial_ || !cellular_play_.queue(kind, tick, choice))
|
||||
return false;
|
||||
action_check_at_ = {};
|
||||
@@ -576,6 +578,8 @@ class RemoteSession {
|
||||
predictor_.reset(); // A new session has a new marker.
|
||||
smoother_.reset();
|
||||
lead_.reset();
|
||||
cellular_lead_.reset();
|
||||
cellular_sent_tick_ = 0;
|
||||
clock_.reset(); // Fresh baseline: the frozen view of a lost session is dropped.
|
||||
interpolator_.reset();
|
||||
markers_.clear();
|
||||
@@ -620,7 +624,10 @@ class RemoteSession {
|
||||
if (server_tick_ == 0 || (sent_tick_ && server_tick_ <= *sent_tick_) ||
|
||||
!cellular_play_.fresh() || cellular_play_.life() == 0 || cellular_play_.ended())
|
||||
return;
|
||||
const auto tick = server_tick_ + 1;
|
||||
// The server admits only ticks still ahead of it when the action arrives; the view
|
||||
// trails it by the replication delay, so schedule by the adaptive lead.
|
||||
// Strictly increasing even when the lead shrinks: one movement per tick.
|
||||
const auto tick = std::max(server_tick_ + cellular_lead_.lead(), cellular_sent_tick_ + 1);
|
||||
const auto steering = steer_cellular(cellular_controls_, intention, cellular_perception(),
|
||||
organisms_.current(), cellular_feed_target_);
|
||||
cellular_feed_target_ = steering.patch;
|
||||
@@ -630,6 +637,7 @@ class RemoteSession {
|
||||
steering.intention.move_y, cellular_feed_target_))
|
||||
return;
|
||||
sent_tick_ = server_tick_;
|
||||
cellular_sent_tick_ = tick;
|
||||
}
|
||||
void service_cellular(Clock::time_point now) {
|
||||
if (cellular_play_.birth_pending() && now >= birth_check_at_) {
|
||||
@@ -646,12 +654,14 @@ class RemoteSession {
|
||||
sent = client_->send_cellular_mutation(p.id, p.tick, p.choice.life, p.choice.event,
|
||||
p.choice.offer_tick, p.choice.operator_id);
|
||||
} else if (p.state == CellActionState::queued) {
|
||||
if (p.tick > server_tick_ + 1)
|
||||
if (p.tick > server_tick_ + cellular_lead_.lead())
|
||||
return; // Do not replace a movement/feeding intention already sent this tick.
|
||||
sent = client_->send_cellular_action(
|
||||
p.id, p.tick, 0, 0, {}, p.kind == CellAction::engulf, p.kind == CellAction::bud);
|
||||
if (sent)
|
||||
if (sent) {
|
||||
sent_tick_ = server_tick_; // The discrete intention owns this tick's target.
|
||||
cellular_sent_tick_ = std::max(cellular_sent_tick_, p.tick);
|
||||
}
|
||||
} else {
|
||||
sent = client_->query_action(p.id); // A query can never bud a second time.
|
||||
}
|
||||
@@ -699,6 +709,10 @@ class RemoteSession {
|
||||
}
|
||||
}
|
||||
for (const auto& receipt : client_->take_action_receipts()) {
|
||||
if (receipt.status == network::AdmitStatus::admitted)
|
||||
cellular_lead_.admitted(receipt.tick, receipt.server_tick);
|
||||
else if (receipt.status == network::AdmitStatus::outside_window)
|
||||
cellular_lead_.too_late(); // Arrived after its tick: schedule further ahead.
|
||||
cellular_play_.receipt(receipt);
|
||||
if (receipt.status != network::AdmitStatus::admitted)
|
||||
cellular_action_status_ = cellular_admission_message(receipt.status);
|
||||
@@ -922,6 +936,8 @@ class RemoteSession {
|
||||
Clock::time_point refresh_sent_at_{};
|
||||
std::map<std::uint64_t, network::quic::ClientConfig> routes_; // Region -> how to dial it.
|
||||
std::uint64_t target_region_{}, region_{}, handoffs_{}, newest_serial_{};
|
||||
client::InputLead cellular_lead_; // Cellular action ticks (2..7 ahead of the view).
|
||||
std::uint64_t cellular_sent_tick_{}; // Newest tick a movement or discrete action named.
|
||||
std::optional<network::WireGrant> ticket_; // A handoff ticket for the next connection.
|
||||
bool handing_off_{};
|
||||
std::unique_ptr<client::RegionSessionClient> client_;
|
||||
|
||||
@@ -12,7 +12,7 @@ spec:
|
||||
env:
|
||||
- {name: REGION_SESSION, value: "dev"}
|
||||
- {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"}
|
||||
- {name: REGION_SESSION_WINDOW, value: "dev-20261021T121524-1032232b:1792599324"}
|
||||
- {name: REGION_SESSION_WINDOW, value: "dev-20261021T125059-4a2c275e:1792601459"}
|
||||
- {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"}
|
||||
ports:
|
||||
# QUIC (ADR-0090): UDP only; nothing listens on TCP 7400.
|
||||
|
||||
Reference in New Issue
Block a user