[rust] T2-3 live integration gate + auto-reconnect (#9) #27
Loading…
Reference in a new issue
No description provided.
Delete branch "task/9-live-integration-gate"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
T2-3 the Phase-2 GATE (issue #9)
The first full end-to-end proof that the Rust client drives a real character, plus the last piece of the original T2-1 scope (auto-reconnect with backoff) and the
use_potionaction.The GATE (
tests/live_integration_gate.rs, #[ignore]d)One connected session, five steps, each its own function so a failure names the step:
startdecoded, alive onmain, hp > 0;move_toa 60 px leg; the server's settle frame confirms the position changed and the char settled;attackit; assert the server's authoritativegame_responseand that the monster'shpdrops across theentitiessnapshots;use_potion("hp"); server success + the shared 4 s cooldown is tracked; a second drink of either potion is refused locally by the shared gate;game_response {place:"say"}.Logs in as the dedicated test character (
AL_TEST_*— "Rustler"), falling back toAL_DEV_*only when the test creds are absent, so it never collides with a human (or another live suite) on the same socket (dev/LOCAL.md). Skips cleanly (not fail) when the stack is down, asserts whenAL_TEST_REQUIRE=1.Live run (actual output, against the running server):
Both pre-existing live tests still pass alongside it (they use the dev character, so all three can run in one
cargo test -- --ignored).Auto-reconnect with backoff (
recovery.rs)ReconnectPolicy— base/max delay, exponential multiplier, jitter, optional max attempts;delay_for(attempt)+attempt_delays(policy, n)(pure, fully unit-tested: sequence grows to the cap, jitter bounded, max attempts respected).ConnectionEnd(inclient.rs) — the pump now distinguishes a localclose()from a server-side drop; that is the signal the recovery loop keys off.RecoveredSession— owns the retry loop: when the inbound stream ends unexpectedly it re-runs the full handshake (T2-1'sreconnect(), which already handles the server's ~250 ms re-auth refusal window after a drop —dc_players,server.js:12266/10886/15810) and republishes the session; a local close stops it.client(),is_connected(),is_reconnecting(), reconnect counters.run_reconnect/ReconnectEvent/ReconnectOutcome— the generic loop, testable with fake stream ends (11 offline policy tests, no live server needed).use_potionactionuse_potion("hp" | "mp")over the server's QUICK potions (node/server.js:11195-11224:+50hp /+100mp, clamped, one sharedplayer.last.potiontimer = 4000 ms,not_ready {ms}while cooling,success_response({used}), theneval pot_timeout(4000)). Registers under place"use", keeps a client-side shared gate (one guard covers the server's one timer — a second drink of either potion is declined locally), surfacesnot_readyas the cooldown, and anything else falls through touse_item(inventory potions take a different path).CharacterCredentialsgainsfrom_test_env/from_env_preferring_test(+AL_TEST_*env constants) for the dedicated test character.Tests
use_potionshared-gate decision, credential helpers. al-client 60 → 77 unit tests.#[ignore]d): the 5-step gate above + the two pre-existing live tests (no regression).Gate
bash rust/dev/check.shgreen: fmt, clippy pedantic -D warnings, all tests. All three live tests run green against the server.Assumptions
AL_TEST_*); Clinker (AL_SDK_*) is reserved for the al-sdk live test running in parallel (T3-2) so the two live suites never share a socket.RecoveredSession;CharacterClient::connectkeeps its plain semantics (T3-3's SDK loop will own the policy choice).use_potion+ the cred helpers uncommitted and the gate test not yet written; the orchestrator committed those, wrotelive_integration_gate.rs, verified it live, and finished the PR.