From bf87aa4de48b5756810acfda47d984e7c28f5792 Mon Sep 17 00:00:00 2001 From: dingo Date: Sun, 11 Oct 2026 01:36:04 -0400 Subject: [PATCH] Exercise client follow for life owner redirects --- docs/engineering/M11_2_DELIVERY_PLAN.md | 9 +++++++-- docs/engineering/VALIDATION.md | 10 ++++++++++ tests/client_remote_session.cpp | 26 +++++++++++++++++++------ tests/fixtures/fake_handoff_world.hpp | 10 +++++++++- 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/docs/engineering/M11_2_DELIVERY_PLAN.md b/docs/engineering/M11_2_DELIVERY_PLAN.md index 84dfcc7..f667908 100644 --- a/docs/engineering/M11_2_DELIVERY_PLAN.md +++ b/docs/engineering/M11_2_DELIVERY_PLAN.md @@ -143,13 +143,18 @@ Local checks do not close ADR-0097's reference-worker qualification. then closes as moved. Cellular startup requires a route catalog containing this region; malformed, duplicate, unavailable, and missing-owner routes fail closed. QUIC tests cover redirect-before-claim and missing-route refusal. - PostgreSQL and migration CI, client switching, and process-kill qualification - remain pending. Do not claim 11.2 complete until redirect/restart gates pass. + PostgreSQL and migration CI and process-kill qualification remain pending. + Client switching is covered by 11.2d-7d below. Do not claim 11.2 complete + until redirect/restart gates pass. - 11.2d-7c qualification: the PostgreSQL-backed region-session process test now creates a life in region 35, logs the account into region 36 with an explicit two-region catalog, checks the redirect and unchanged account-control owner, kills region 35, restarts it, verifies the same life, and checks routing again. Execution remains pending Linux/PostgreSQL CI. +- 11.2d-7d client follow: the two-region remote-client test now gives its + account an active life owner in region 2 and checks that the redirect chooses + a region-2 grant without claiming control in region 1. Runtime execution + remains pending CI. No deployed world has been provisioned or changed by this work. diff --git a/docs/engineering/VALIDATION.md b/docs/engineering/VALIDATION.md index 50e27af..4c73982 100644 --- a/docs/engineering/VALIDATION.md +++ b/docs/engineering/VALIDATION.md @@ -6587,3 +6587,13 @@ The process-test source cannot be syntax-compiled locally because the Windows toolchain lacks POSIX `poll.h`, which its existing process fixture requires. The app bridge header compile, formatting check, and `git diff --check` passed; the PostgreSQL process test has not run and requires CI confirmation. + +## 2026-10-11 — M11.2d-7d client follows life-owner redirect (pending CI) + +Extended `tests/client_remote_session.cpp` and its two-region fake world so the +second login is redirected by the new durable-life-owner hook before region 1 +claims control. The remote client follows region 2, selects its grant from the +bundle, and establishes there. Claim counters assert that region 1 did not take +control. GCC 13.2 strict-warning syntax compilation and Visual Studio LLVM +`clang-format` passed; the test binary has not run. CI execution remains +required. diff --git a/tests/client_remote_session.cpp b/tests/client_remote_session.cpp index 46ab38f..c006976 100644 --- a/tests/client_remote_session.cpp +++ b/tests/client_remote_session.cpp @@ -390,6 +390,11 @@ void crossing_regions(const Files& f) { c.neighbours.push_back( {{neighbour, "localhost:" + std::to_string(neighbour_port), std::string{name}}, area(neighbour == 1 ? 0 : 10 * m)}); + c.life_owner_routes = { + server::LifeOwnerRoute{ + RegionAddress{id, "localhost:" + std::to_string(port), std::string{name}}}, + server::LifeOwnerRoute{RegionAddress{ + neighbour, "localhost:" + std::to_string(neighbour_port), std::string{name}}}}; c.ghost_poll = std::chrono::milliseconds{20}; auto made = server::RegionSessions::create(std::move(c)); CHECK(made.has_value()); @@ -398,14 +403,18 @@ void crossing_regions(const Files& f) { (*made)->set_default_interest({(x0 / m) + 5, 5, 0, 7}); return std::move(*made); }; - // Region 2 listens on a port found by binding a throwaway region first. - std::uint16_t port2 = 0; + // Reserve both ports using throwaway listeners so each world route is complete. + std::uint16_t port1 = 0, port2 = 0; { - auto probe = make(2, db2, key2, *key1, 1, 1, 0); + auto probe = make(1, db1, key1, *key2, 2, 1, 0); + port1 = probe->port(); + } + { + auto probe = make(2, db2, key2, *key1, 1, port1, 0); port2 = probe->port(); } - auto r1 = make(1, db1, key1, *key2, 2, port2, 0); - auto r2 = make(2, db2, key2, *key1, 1, r1->port(), port2); + auto r1 = make(1, db1, key1, *key2, 2, port2, port1); + auto r2 = make(2, db2, key2, *key1, 1, port1, port2); std::uint64_t tick = 100; const auto grants = [&](const AccountId& who, std::uint64_t first) { std::vector out; @@ -465,13 +474,18 @@ void crossing_regions(const Files& f) { world.probes.at(dana).owner == 2 && s.status().marker_x_mm >= 10'000); a.intention.move_x = 0; // A second client with a newer bundle logs in at region 1 and is redirected to region 2, - // where it takes over (the first is superseded). + // where it takes over (the first is superseded). The active life owner lookup must + // redirect before region 1's durable control claim. + world.life_owners[dana] = 2; + const auto region1_claims = db1.claims; + const auto region2_claims = db2.claims; Client b; CHECK(b.host.connect(RemoteSession::open(material(grants(dana, 20))))); auto& t = *b.host.session(); CHECK( pump({&a, &b}, [&] { return t.status().region == 2 && t.status().phase == "connected"; })); CHECK(a.phase() == LaunchPhase::failed && world.probes.at(dana).owner == 2); + CHECK(db1.claims == region1_claims && db2.claims == region2_claims + 1); } } // namespace diff --git a/tests/fixtures/fake_handoff_world.hpp b/tests/fixtures/fake_handoff_world.hpp index 52db609..afe9ae2 100644 --- a/tests/fixtures/fake_handoff_world.hpp +++ b/tests/fixtures/fake_handoff_world.hpp @@ -36,6 +36,7 @@ struct WorldDb { State state{}; }; std::map probes; + std::map life_owners; std::map transfers; bool all_overdue{}; // overdue() reports every open transfer (a restarted source's view). std::uint64_t overdue_reads{}; @@ -114,8 +115,15 @@ struct RegionDb final : server::ProbeLedger, HandoffLedger, ControlLedger { } std::expected claim(const AccountId&, std::uint64_t, std::uint64_t) override { + ++claims; return ControlLease{++control, {}, std::chrono::milliseconds{20000}}; } + std::expected, ControlLedgerError> + primitive_life_owner(const AccountId& account) override { + const auto found = world->life_owners.find(account); + return found == world->life_owners.end() ? std::optional{} + : std::optional{found->second}; + } std::expected renew(const AccountId&, std::uint64_t) override { return std::chrono::milliseconds{20000}; @@ -125,6 +133,6 @@ struct RegionDb final : server::ProbeLedger, HandoffLedger, ControlLedger { } WorldDb* world; std::uint64_t region; - std::uint64_t control{}, saves{}, releases{}; + std::uint64_t control{}, claims{}, saves{}, releases{}; }; } // namespace evo::test