Read READY as a real Fluxer server sends it (partial member users) #192

Manually merged
charles merged 0 commits from fix-live-protocol into main 2026-11-12 05:11:46 +00:00
Owner

Stacked on #189 (fix-altcha-captcha): this branch is based on it so both can be tried together. Merge #189 first.

Problem

After a successful login to a real instance the client showed no guilds, no DMs and "Unknown User": skipping malformed dispatch error=malformed READY dispatch: missing field 'username'. The server deduplicates users in READY: guilds[].members[].user is {"id"} only and the full users are in the top-level users list (session_ready_collect.erl, strip_users_from_guild_members); relationships[] lose their user. Our READY fixture had full users everywhere, so nothing caught it.

Changes

  • fluxer-proto: UserRef (Full(UserPartial) | Id { id }, untagged, round-trips in the form read) for GuildMember::user, Presence::user (the server sends {"id"} in the offline PRESENCE_UPDATE when it drops a friend/group-DM subscription) and GUILD_MEMBER_REMOVE.user (always {"id"}). ReadyPayload::resolve_users() fills references from users/user.
  • Tolerance: every list in ReadyPayload/GuildReadyData is lenient: a malformed entry is dropped with a warn (type + parse error), not the whole READY; a malformed guild object leaves properties: None. This adds tracing (already a workspace dependency) to fluxer-proto, only for that warning.
  • fluxer-core: references add nothing to the user cache; names come from READY.users; a member whose user is unknown is kept and shown as Unknown User.
  • Fixture: fixtures/gateway/ready.json now has the real structure (member user references, users holding every member including the logged-in user, relationships without user, empty guild presences, sessions, version, geoip_country_code, webauthn_credentials), with the same fake identities. The devserver resolves it before choosing message authors. Screenshot goldens are unchanged.
  • Replay check: crates/fluxer-core/tests/replay.rs, skipped unless FLUXER_REPLAY_DIR points at a --record directory. It runs every gateway frame and REST body through the real parsers and the store and reports mismatches by key path and a redacted error only (no values). After READY it checks that guilds, channels, DMs and the user's name reached the store, and prints counts.
  • Captcha: the solver logged the thread count before the cap of 8; it now logs the value it actually uses. Behaviour is unchanged.

Server survey (other dispatches)

I checked the server source (gateway and API): outside READY, only GUILD_MEMBER_REMOVE and the offline PRESENCE_UPDATE carry {"id"} users among the typed dispatches. GUILD_CREATE for a user (only bots get stripped members), GUILD_MEMBER_ADD/UPDATE, message author/mentions, DM recipients and CHANNEL_RECIPIENT_/RELATIONSHIP_ are full. Untyped events that will need the same care when they are modelled: THREAD_MEMBERS_UPDATE (added_members[].presence.user is {"id"}), GUILD_MEMBER_LIST_UPDATE (an offline presence has no user), and message member (never has user). VOICE_STATE member may be null, which is already handled.

Tests

  • Regression: references resolved through users; an unknown member user id is kept; malformed members, channels, users, guilds and guild objects do not drop READY; references in GUILD_MEMBER_REMOVE and PRESENCE_UPDATE; core: members are named from users, an unknown member is kept unnamed, a malformed member does not drop READY.
  • Replay against the real recording (run locally, not committed): every frame and REST body parses; the store gets all guilds, channels and DMs, and the user's name.
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci: all steps pass.

🤖 Generated with Claude Code

Stacked on #189 (`fix-altcha-captcha`): this branch is based on it so both can be tried together. Merge #189 first. ## Problem After a successful login to a real instance the client showed no guilds, no DMs and "Unknown User": `skipping malformed dispatch error=malformed READY dispatch: missing field 'username'`. The server deduplicates users in READY: `guilds[].members[].user` is `{"id"}` only and the full users are in the top-level `users` list (`session_ready_collect.erl`, `strip_users_from_guild_members`); `relationships[]` lose their `user`. Our READY fixture had full users everywhere, so nothing caught it. ## Changes - **fluxer-proto**: `UserRef` (`Full(UserPartial)` | `Id { id }`, untagged, round-trips in the form read) for `GuildMember::user`, `Presence::user` (the server sends `{"id"}` in the offline PRESENCE_UPDATE when it drops a friend/group-DM subscription) and `GUILD_MEMBER_REMOVE.user` (always `{"id"}`). `ReadyPayload::resolve_users()` fills references from `users`/`user`. - **Tolerance**: every list in `ReadyPayload`/`GuildReadyData` is lenient: a malformed entry is dropped with a `warn` (type + parse error), not the whole READY; a malformed guild object leaves `properties: None`. This adds `tracing` (already a workspace dependency) to fluxer-proto, only for that warning. - **fluxer-core**: references add nothing to the user cache; names come from `READY.users`; a member whose user is unknown is kept and shown as Unknown User. - **Fixture**: `fixtures/gateway/ready.json` now has the real structure (member user references, `users` holding every member including the logged-in user, relationships without `user`, empty guild presences, `sessions`, `version`, `geoip_country_code`, `webauthn_credentials`), with the same fake identities. The devserver resolves it before choosing message authors. Screenshot goldens are unchanged. - **Replay check**: `crates/fluxer-core/tests/replay.rs`, skipped unless `FLUXER_REPLAY_DIR` points at a `--record` directory. It runs every gateway frame and REST body through the real parsers and the store and reports mismatches by key path and a redacted error only (no values). After READY it checks that guilds, channels, DMs and the user's name reached the store, and prints counts. - **Captcha**: the solver logged the thread count before the cap of 8; it now logs the value it actually uses. Behaviour is unchanged. ## Server survey (other dispatches) I checked the server source (gateway and API): outside READY, only GUILD_MEMBER_REMOVE and the offline PRESENCE_UPDATE carry `{"id"}` users among the typed dispatches. GUILD_CREATE for a user (only bots get stripped members), GUILD_MEMBER_ADD/UPDATE, message author/mentions, DM recipients and CHANNEL_RECIPIENT_*/RELATIONSHIP_* are full. Untyped events that will need the same care when they are modelled: THREAD_MEMBERS_UPDATE (`added_members[].presence.user` is `{"id"}`), GUILD_MEMBER_LIST_UPDATE (an offline presence has no `user`), and message `member` (never has `user`). VOICE_STATE `member` may be `null`, which is already handled. ## Tests - Regression: references resolved through `users`; an unknown member user id is kept; malformed members, channels, users, guilds and guild objects do not drop READY; references in GUILD_MEMBER_REMOVE and PRESENCE_UPDATE; core: members are named from `users`, an unknown member is kept unnamed, a malformed member does not drop READY. - Replay against the real recording (run locally, not committed): every frame and REST body parses; the store gets all guilds, channels and DMs, and the user's name. - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci`: all steps pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Solve the fork's ALTCHA captcha in fluxer-api
All checks were successful
ci / Linux (x86_64) (push) Successful in 16m3s
ci / Windows (x64) (push) Successful in 16m12s
d281e073da
A 400 CAPTCHA_REQUIRED / INVALID_CAPTCHA carrying an ALTCHA v2 challenge
is now solved by the client (PBKDF2-HMAC-SHA-256 over nonce || counter_be32,
counters from 0 until the key starts with keyPrefix) and the same request is
sent again with X-Captcha-Token, at most twice per request, as the web
app's CaptchaInterceptor does for every request. The search runs in
spawn_blocking on up to 8 threads, bounded by 60 s and the challenge's
expiry, and stops when the request is dropped. The token is byte for byte
the web client's encoding.

ApiError::CaptchaRequired is left for captchas the client cannot solve
(unknown provider, malformed challenge, timeout, both solutions refused);
INVALID_CAPTCHA maps to it instead of a plain 400 that the core read as
wrong credentials. The login screen's message says so.

Test vector fixtures/captcha/altcha_login.json was produced by the fork's
own AltchaProvider; the API tests run against a mock that verifies tokens
the way the fork does. Adds ring (already in the graph via rustls) as a
direct dependency of fluxer-api.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`threads` was logged before the cap of 8 (the web app's MAX_SOLVER_WORKERS)
that `solve` applies, so a 32-core machine logged threads=32 while 8 ran.
Clamp before logging; behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read READY as a real Fluxer server sends it
All checks were successful
ci / Linux (x86_64) (push) Successful in 14m30s
ci / Windows (x64) (push) Successful in 15m57s
3bf4ee7931
The server deduplicates users in READY: guilds[].members[].user is
{"id"} only and the full users are in the top-level `users` list
(session_ready_collect.erl). fluxer-proto required a full user on every
member, so a real READY failed to parse as a whole and the client showed
no guilds, no DMs and "Unknown User".

- fluxer-proto: `UserRef` (full user or `{"id"}` reference) for
  GuildMember::user, Presence::user (the offline PRESENCE_UPDATE sent when
  a friend/group-DM subscription is dropped) and GUILD_MEMBER_REMOVE's
  user (always a reference). `ReadyPayload::resolve_users()` fills the
  references from `users` and `user`.
- Every list of ReadyPayload / GuildReadyData is read leniently: a
  malformed entry is dropped with a warning instead of losing the
  session; a malformed guild object leaves `properties: None`. Adds
  `tracing` to fluxer-proto for that warning.
- fluxer-core: members and presences that are references add nothing to
  the user cache; names come from READY.users, unknown users show as
  Unknown User.
- fixtures/gateway/ready.json now has the real structure (member user
  references, `users` with every member, relationships without `user`,
  empty guild presences, sessions/version/...), with the same fake
  identities. The devserver resolves it before indexing message authors.
- tests/replay.rs in fluxer-core: with FLUXER_REPLAY_DIR set, replays a
  --record recording through the parsers and the store and reports
  mismatches by key path and redacted error only; skipped otherwise.
- Regression tests: references resolved via `users`, an unknown member
  user id kept, malformed members/channels/users/guilds dropped without
  failing READY, references in GUILD_MEMBER_REMOVE and PRESENCE_UPDATE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
charles manually merged commit 421838b9e4 into main 2026-11-12 05:11:46 +00:00
Sign in to join this conversation.
No description provided.