Bound engineering UI state and session events for M9.8b

This commit is contained in:
dingo
2026-10-02 08:22:25 -04:00
parent 22c7c341ce
commit a6e8094f57
20 changed files with 327 additions and 19 deletions
+33
View File
@@ -662,9 +662,42 @@ void liveness() {
CHECK(h.until([&] { return again->phase() == SessionPhase::established; }));
}
}
void event_backpressure() {
Harness h;
h.tick();
auto c = h.client(grants(7, 3, 100));
CHECK(h.until([&] { return c->latest_view().has_value(); }));
std::uint64_t sent = 0;
CHECK(h.until([&] {
if (c->phase() != SessionPhase::established)
return true;
// Invalid vector: final rejection frees outstanding capacity, but the host
// intentionally never drains its event queue throughout this burst.
for (int batch = 0; batch < 16; ++batch)
if (c->send({sent + 1, 0, 1000, 1000}))
++sent;
return false;
}));
CHECK(c->phase() == SessionPhase::backoff);
const auto remaining = c->grants_left();
for (int i = 0; i < 100; ++i)
c->poll(Clock::now() + std::chrono::seconds{60});
CHECK(c->grants_left() == remaining && c->phase() == SessionPhase::backoff);
CHECK(c->environment().freshness() == client::Freshness::stale);
const auto events = c->take_events();
CHECK(events.size() <= SessionClient::max_events);
CHECK(has(events, ClientEvent::Kind::backpressure) && has(events, ClientEvent::Kind::lost));
const auto accounted = std::ranges::count_if(events, [](const ClientEvent& e) {
return e.kind == ClientEvent::Kind::result || e.kind == ClientEvent::Kind::unknown;
});
CHECK(static_cast<std::uint64_t>(accounted) == sent);
CHECK(h.until([&] { return c->latest_view().has_value(); }));
CHECK(c->phase() == SessionPhase::established);
}
} // namespace
void session_tests() {
event_backpressure();
ledger_exclusive_owner();
ledger_incomplete_records();
connect_view_intents_and_outcomes();