Task 13: fluxer-devserver fixture server (#13) #47
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "task/13-devserver"
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?
Stacked on: task/7-gateway-machine-transport
What this builds
fluxer-devserver: a fixture-backed Fluxer instance on one ephemeral loopback port, for tests and forfluxer --devserver(Task 14).DevServer::spawn(fixtures_dir: &Path, scenario: &str) -> DevServer { instance_url: Url }(panics if the fixtures cannot be loaded) andDevServer::try_spawn(..) -> Result<DevServer, Error>. Dropping the server stops it and its gateway sessions. ConstantsDEMO_LOGIN,DEMO_PASSWORD,MFA_LOGIN,MFA_CODE./api/.well-known/fluxerwith every endpoint rewritten to the server,/auth/login(demo/demo;mfaanswers the MFA fixture),/auth/login/mfa/totp(code000000),/auth/logout,/users/@me,GET /channels/{id}/messages(limit/before/after/around, newest first) over a history generated from the scenario,POST messagesechoing thenonce,typing,ack. Error bodies are{code, message}; a wrong or missing token is a 401./gateway: HELLO 41250 -> IDENTIFY -> READY fromready.json, heartbeat ACKs,compress=zstd-stream(usingfluxer_gateway::compression) or plain text frames, close 4004 for a wrong token, INVALID_SESSIONfalsefor RESUME (sessions are not kept), then the scenario timeline with increasing sequence numbers, and aMESSAGE_CREATEfor every message sent over REST.fixtures/scenarios/basic.toml: 120 generated messages in#general, thenGUILD_CREATE(2 guilds, 6 channels), a three-event typing burst, aMESSAGE_CREATE, aPRESENCE_UPDATE; plays in 3.5 s.fluxer-devserver --fixtures fixtures --scenario basicprints the instance URL and serves until interrupted.How it was tested
crates/fluxer-devserver/tests/scenario.rsdrives the server with the realfluxer-apiandfluxer-gatewaycrates:client_can_login_and_receive_ready_from_devserver,scenario_events_arrive_in_order(names, sequence numbers 1..=7, 2 guilds / 6 channels), plain-JSON gateway, 4004 on a wrong token, the MFA flow, 400/401 rejections, pagination through all 120 messages withbefore/after/around, send -> nonce echo -> gatewayMESSAGE_CREATE-> newest in history, and an unknown scenario being an error. Unit tests cover history generation, the endpoint rewrite and frame unwrapping. The tests were committed failing first.cargo xtask ciis green locally; the binary was smoke-tested with curl.Deviations from the plan
axum:toml(the plan asks for a.tomlscenario but names no parser) and direct use ofhyper/hyper-util, both already in the graph. The WebSocket upgrade is done by hand on axum's connection because axum'swsfeature pulls tungstenite 0.29 next to the workspace's 0.30.spawnkeeps the plan's signature (synchronous, infallible, must be called inside a tokio runtime);try_spawnis the fallible form the binary uses.userofgateway/ready.jsonon both sides, not the user ofrest/login_ok.json/rest/user_me.json: the REST and gateway fixtures describe different accounts, and one session needs one identity. Only the token is taken fromlogin_ok.json.[[messages]]table (channel, count, newest id) for the generated history; the plan only shows[[event]].basicreaches "2 guilds, 6 channels" through itsGUILD_CREATEevent, becauseready.jsonhas the second guild unavailable.Closes #13
🤖 Generated with Claude Code
Independent review: Task 13 (devserver) at
4c00cf1Scope:
git diff e600215..origin/task/13-devserver(11 files). Read cold; implementer notes verified against the code.1. Plan tests - OK.
client_can_login_and_receive_ready_from_devserverandscenario_events_arrive_in_orderexist incrates/fluxer-devserver/tests/scenario.rs, drive the realfluxer-api+fluxer-gatewayagainstDevServer::spawn, and assert discovery pointing at the server, demo login, READY at seq 1 over zstd-stream, ordered timeline with seq 1..=7, 2 guilds / 6 channels. Further tests cover 120 messages in#generalwith pagination, nonce echo + gatewayMESSAGE_CREATE, MFA with000000, 4004 on a wrong token, plain JSON. Failing-test commit precedes the implementation commit.2. Interfaces - OK.
DevServer::spawn(fixtures_dir: &Path, scenario: &str) -> DevServerwithpub instance_url: Url, ephemeral loopback port; all listed endpoints served;/gatewaydoes HELLO (41250, fromhello.json) -> IDENTIFY -> READY fromready.json, then the[[event]]timeline; binary takes--fixtures/--scenarioand prints the URL. Additions (try_spawn,DEMO_LOGIN,DEMO_PASSWORD,MFA_LOGIN,MFA_CODE,[[messages]]) do not conflict with the plan.3. Constraints / invariants - OK. No change to
fluxer-coreorfluxer-ui; no secrets (the only token is the existing placeholder infixtures/rest/login_ok.json); nounwrap/expecton request data in the server; README updated; commit trailers andRefs #13present.4. Review Focus - no item belongs to this task.
5.
cargo xtask ci- green locally in the review worktree (fmt, clippy, deny: advisories/bans/licenses/sources ok, all tests; devserver 4 unit + 9 integration; screenshot step skipped as configured).Findings
Cargo.toml:toml(plusserde_spanned,toml_writer) is new to the lockfile, andhyper/hyper-utilbecome direct dependencies; the plan names onlyaxum. CLAUDE.md says new dependencies come only via a task that names them. A TOML parser is implied bybasic.tomlandcargo denyis green, so not blocking, but Charles should accept this explicitly at merge.tests/scenario.rs: no test asserts HELLOheartbeat_interval == 41250; the value comes fromfixtures/gateway/hello.json(verified by inspection). A one-line assertion would pin the Global Constraint.src/scenario.rs: identity deviation confirmed.login_ok.json/user_me.json("charles") andready.json("charlie") disagree; the server servesready.json's user everywhere anduser_me.jsonis unused by it. Reasonable for this task (fixtures belong to other tasks), but the fixtures should be aligned in afollow-upissue.src/gateway.rs: every new connection replays the whole timeline and RESUME is always answered with INVALID_SESSIONfalse, so a client that reconnects sees typing/presence/GUILD_CREATE again (theMESSAGE_CREATEis deduplicated in history, not on the wire). Fine for Foundation; Task 14 and later UI tests should not assume resume works against the devserver.src/lib.rs:Dropaborts the accept loop and ends gateway sessions, but HTTP connections already accepted byaxum::servekeep being served until the peer closes them. Harmless in tests.src/scenario.rs: a sent message is stored with itsnonce, so laterGET messagesreturns it too, unlike the real server.Verdict: APPROVE - zero blocking findings, local ci green. Remote runners not checked (integrator's job).