Daily use 2: proto relationships, invites, guild membership, read-state ack, reports, profile details (#487) #537

Closed
charles wants to merge 0 commits from dailyuse-2-proto-relationships-invites-reports into dailyuse
Owner

What was built

fluxer-proto types and server-shaped fixtures for Daily use Task 2 (Task 3 merged in), names as the plan's Interfaces block:

  • Relationships: FriendRequestByTag, RelationshipPut ({} accept, block() = {type: 2}), RelationshipNickname; Relationship.{share_voice_activity, friend_shares_voice_activity}.
  • Error codes: new fluxer_proto::errors. ApiErrorBody { code, message, errors } with has_code (it also checks the nested validation codes, e.g. errors::validation::CANNOT_LEAVE_GUILD_AS_OWNER), plus &str constants for every code spec §3.5/§3.6/§3.8/§3.9/§3.12 maps (API_ERROR_CODES).
  • Invites: InviteResponse with InviteType::{Guild, GroupDm, Unknown(u8)}, InviteGuild, InviteChannel (+ recipients) and a lenient guild and inviter; InviteMetadata (flattened); ChannelInviteCreate::default() = {max_age: 604800, max_uses: 0, temporary: false}; Endpoints.invite.
  • Guilds: GuildCreateRequest, LeaveGuildQuery, LeaveGroupQuery, MemberVoicePatch with mute/deaf/move_to/disconnect builders (a disconnect writes channel_id: null).
  • Read state: ReadStatesAck (batches() makes requests of 1–100 entries), ReadStateAckEntry, AckBody.
  • Reports: ReportFlow, ReportScreen (is_info()), ReportOption, ReportChecklist(Item), ReportOutcome with ReportOutcomeType::Unknown(String), ReportNotice, ReportSubmission/ReportStep, the legacy MessageReport, and ReportResponse. All of these are lenient.
  • Profiles: typed connected_accounts: Option<Vec<ConnectedAccount>> (an unreadable entry is dropped), UserNote, UserNotes, and GatewayEvent::UserNoteUpdate { id, note }.
  • Forward one attachment: MessageReferenceRequest.{attachment_ids, embed_indices}, left out when empty. The struct is no longer Copy.

Each fixture's commit message names the server file and line it is copied from (a61ef0b).

How it was tested

  • Plan tests in tests/{social,invites,report,profile_full}.rs, including the proptests arbitrary_invite_json_never_panics and arbitrary_report_flow_json_never_panics.
  • Every new REST fixture is in models_roundtrip.rs, both the round-trip and the unknown-field checks.
  • spec_contract.rs has new contracts (Error, GuildPartialResponse, ChannelPartialResponse, the ReportFlow* schemas, ConnectionResponse, and the profile with connections) and spec_contract_daily_use_types, which checks the request bodies, both branches of the invite union, the metadata, and the leave query parameters.
  • FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci is green locally. No display tests are involved.

Deviations

  • fluxer-core (outside the Files list) is touched minimally because MessageReferenceRequest lost Copy and gained two fields: three builders now fill the new fields or clone, messages.rs uses as_ref(), and three tests were updated to match.
  • Endpoints.invite is Option<String>, not Option<Url>, consistent with the other endpoints.
  • InviteChannel.icon is kept for the interface, but the server's ChannelPartialResponse never sends it (ChannelMappers.ts:247-253). recipients is added because group DM invites carry it.
  • CANNOT_LEAVE_GUILD_AS_OWNER is a validation code (ValidationErrorCodes.ts:25), nested in an INVALID_FORM_BODY answer, not an APIErrorCode. It lives in errors::validation.
  • Extras from spec §5 that are not in the plan's Interfaces block: LeaveGuildQuery, LeaveGroupQuery, ReportResponse, ApiErrorBody, and the gateway fixture user_note_update.json.
  • invite_unknown.json is the server's UNKNOWN_INVITE 404 body. The unknown invite type is tested inline.
  • report_flow_message.json is a trimmed but consistent walk of the real message flow (5 screens and 1 notice, with the original English copy).

Closes #487

🤖 Generated with Claude Code

## What was built `fluxer-proto` types and server-shaped fixtures for Daily use Task 2 (Task 3 merged in), names as the plan's Interfaces block: - **Relationships**: `FriendRequestByTag`, `RelationshipPut` (`{}` accept, `block()` = `{type: 2}`), `RelationshipNickname`; `Relationship.{share_voice_activity, friend_shares_voice_activity}`. - **Error codes**: new `fluxer_proto::errors`. `ApiErrorBody { code, message, errors }` with `has_code` (it also checks the nested validation codes, e.g. `errors::validation::CANNOT_LEAVE_GUILD_AS_OWNER`), plus `&str` constants for every code spec §3.5/§3.6/§3.8/§3.9/§3.12 maps (`API_ERROR_CODES`). - **Invites**: `InviteResponse` with `InviteType::{Guild, GroupDm, Unknown(u8)}`, `InviteGuild`, `InviteChannel` (+ `recipients`) and a lenient guild and inviter; `InviteMetadata` (flattened); `ChannelInviteCreate::default()` = `{max_age: 604800, max_uses: 0, temporary: false}`; `Endpoints.invite`. - **Guilds**: `GuildCreateRequest`, `LeaveGuildQuery`, `LeaveGroupQuery`, `MemberVoicePatch` with `mute`/`deaf`/`move_to`/`disconnect` builders (a disconnect writes `channel_id: null`). - **Read state**: `ReadStatesAck` (`batches()` makes requests of 1–100 entries), `ReadStateAckEntry`, `AckBody`. - **Reports**: `ReportFlow`, `ReportScreen` (`is_info()`), `ReportOption`, `ReportChecklist(Item)`, `ReportOutcome` with `ReportOutcomeType::Unknown(String)`, `ReportNotice`, `ReportSubmission`/`ReportStep`, the legacy `MessageReport`, and `ReportResponse`. All of these are lenient. - **Profiles**: typed `connected_accounts: Option<Vec<ConnectedAccount>>` (an unreadable entry is dropped), `UserNote`, `UserNotes`, and `GatewayEvent::UserNoteUpdate { id, note }`. - **Forward one attachment**: `MessageReferenceRequest.{attachment_ids, embed_indices}`, left out when empty. The struct is no longer `Copy`. Each fixture's commit message names the server file and line it is copied from (a61ef0b). ## How it was tested - Plan tests in `tests/{social,invites,report,profile_full}.rs`, including the proptests `arbitrary_invite_json_never_panics` and `arbitrary_report_flow_json_never_panics`. - Every new REST fixture is in `models_roundtrip.rs`, both the round-trip and the unknown-field checks. - `spec_contract.rs` has new contracts (Error, GuildPartialResponse, ChannelPartialResponse, the ReportFlow* schemas, ConnectionResponse, and the profile with connections) and `spec_contract_daily_use_types`, which checks the request bodies, both branches of the invite union, the metadata, and the leave query parameters. - `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` is green locally. No display tests are involved. ## Deviations - `fluxer-core` (outside the Files list) is touched minimally because `MessageReferenceRequest` lost `Copy` and gained two fields: three builders now fill the new fields or clone, `messages.rs` uses `as_ref()`, and three tests were updated to match. - `Endpoints.invite` is `Option<String>`, not `Option<Url>`, consistent with the other endpoints. - `InviteChannel.icon` is kept for the interface, but the server's `ChannelPartialResponse` never sends it (`ChannelMappers.ts:247-253`). `recipients` is added because group DM invites carry it. - `CANNOT_LEAVE_GUILD_AS_OWNER` is a *validation* code (`ValidationErrorCodes.ts:25`), nested in an `INVALID_FORM_BODY` answer, not an `APIErrorCode`. It lives in `errors::validation`. - Extras from spec §5 that are not in the plan's Interfaces block: `LeaveGuildQuery`, `LeaveGroupQuery`, `ReportResponse`, `ApiErrorBody`, and the gateway fixture `user_note_update.json`. - `invite_unknown.json` is the server's `UNKNOWN_INVITE` 404 body. The unknown invite *type* is tested inline. - `report_flow_message.json` is a trimmed but consistent walk of the real message flow (5 screens and 1 notice, with the original English copy). Closes #487 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Fork ba98441b4 sources, each fixture copied from the server's shape:
- relationship_add_by_tag.json: FriendRequestByTagRequest as the client sends it
  (fluxer_app/src/features/relationship/commands/RelationshipCommands.ts:33)
- relationship_errors.json: FluxerError.toJSON {code, message}
  (packages/errors/src/FluxerError.ts:50-56; messages from errors i18n weblate/messages.json)
- invite_guild.json, invite_group_dm.json, invite_metadata.json:
  fluxer_api/src/api/invite/InviteModel.ts:43-174 (mapInviteTo*Response), guild from
  fluxer_api/src/api/guild/GuildModel.ts:29-52, channel from ChannelMappers.ts:247-253
- invite_unknown.json: UnknownInviteError body (unknown_entities.unknown_invite)
- guild_create.json: mapGuildToGuildResponse, fluxer_api/src/api/guild/GuildModel.ts:54-80
- read_states_ack.json: ReadStateAckRequest,
  packages/schema/src/domains/channel/ChannelRequestSchemas.ts:440-452
- member_voice_patch.json: GuildMemberUpdateRequest voice fields,
  packages/schema/src/domains/guild/GuildRequestSchemas.ts:157-166
- report_flow_message.json: getReportFlowResponse / renderScreen,
  fluxer_api/src/api/report/flows/ReportFlowRegistry.ts:136-210, a trimmed walk of the
  message flow of ReportFlowScreens.ts:60-460 with the English copy of content_i18n
- report_submission.json: ReportFlowMessageSubmissionRequest,
  packages/schema/src/domains/report/ReportFlowSchemas.ts:129-149
- profile_connections.json: ConnectionResponse in the profile,
  fluxer_api/src/api/user/services/UserAccountRequestService.ts:400-441,
  fluxer_api/src/api/connection/ConnectionMappers.ts:6-15
- user_note.json, user_notes.json: UserNoteResponse / UserNotesRecordResponse,
  packages/schema/src/domains/user/UserResponseSchemas.ts:705-713
- gateway/user_note_update.json: fluxer_api/src/api/user/services/UserAccountUpdatePropagator.ts:35-42

Refs #487

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Daily use Task 2 (Task 3 merged in): FriendRequestByTag, RelationshipPut,
RelationshipNickname and the voice-activity flags of Relationship; API error
bodies and codes (fluxer_proto::errors); InviteResponse/InviteMetadata,
ChannelInviteCreate, Endpoints::invite; GuildCreateRequest, leave queries,
MemberVoicePatch; ReadStatesAck and AckBody; the report flow, submission and
legacy report; typed connected accounts, user notes and USER_NOTE_UPDATE;
MessageReferenceRequest.attachment_ids/embed_indices (no longer Copy, so
fluxer-core's three builders and their tests clone or fill the new fields).

Refs #487

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Independent review: Daily use 2 (f2de7cd..2763b5f)

Plan tests (1): all 20 named tests exist (social.rs, invites.rs, report.rs, profile_full.rs) and assert what the plan says: 1-100 ack batching (250 entries give 100/100/50, none gives no request), channel_id: null kept as disconnect on read-back, InviteType::Unknown(7) and ReportOutcomeType::Unknown("appeal") round-trip, locale and item_ids skipped when None, a bad connected account is dropped, USER_NOTE_UPDATE is typed (moved out of UNTYPED_IN_FOUNDATION), forward ids are skipped when empty. Both proptests are present and also re-parse what they write.

Interfaces (2): every name in the Task 2 Interfaces block exists with the field names and shapes written there. Only deviation: Endpoints.invite is Option<String>, not Option<Url> (see minor 1). MessageReferenceRequest lost Copy. The fluxer-core callers were updated mechanically (field fill, .clone(), .as_ref()), with no behaviour change.

Invariants (3): fluxer-core gains no dependency and no I/O. The fixture commit a61ef0b names a server file and line for every fixture. The fixtures contain no tokens, signed URLs or paths. Unknown or garbage input is lenient where the card or flow can survive it (guild, inviter, checklist, options, screens, notices, errors) and is a parse error, never a panic, elsewhere.

Parity spot-checks (4), all match the fork:

  • ReportFlowSchemas.ts:66-149: field set, nullability, steps 1-16, item_ids 1-32, locale optional.
  • ReportScreen::is_info is the same rule as getReportFlowScreenKind (ReportFlowWalk.ts:24-28: checklist first, then next_screen_id).
  • InviteModel.ts: the guild invite carries presence_count, the group DM invite does not and has channel.recipients[{username}], expires_at is always sent and null when it never expires; ChannelMappers.ts:247 partial channel is {id,name,type}.
  • GuildRequestSchemas.ts:157-166 mute/deaf/channel_id nullish/connection_id 1-32.
  • ChannelRequestSchemas.ts:441-452 ack entries.
  • UserAccountUpdatePropagator.ts:35-42 {id, note}.
  • ApiErrorCodes.ts values equal their names, and CANNOT_LEAVE_GUILD_AS_OWNER is in ValidationErrorCodes.ts:25. error_codes_match_server also checks every constant against the vendored APIErrorCode enum.
  • The report_flow_message.json ids (root_message, private_info, dislike, doxxing, profile_parts) are in ReportFlowScreens.ts.

IGNORED_FIELDS (as the implementer asked): the invite_guild/invite_metadata entries list only the guild partial's banner, size, embed-splash, alignment and badge fields, and guild_create lists only fields Guild does not model (a superset of guild.json's list). All of these are fields the server sends and no daily-use task reads, so nothing is hidden. The new CONTRACTS entries and spec_contract_daily_use_types check request bodies against the schema's properties and required list, and check the invite union against both branches.

Review Focus 7 (5): covered by arbitrary_invite_json_never_panics (it also mutates a real answer, so parsing gets past code and channel) and arbitrary_report_flow_json_never_panics. Unknown invite type and unknown outcome type are kept.

CI (6): FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in the review worktree: all steps passed (exit 0).

Findings

  1. minor: Endpoints.invite is Option<String> where the plan says Option<Url>. This matches the sibling endpoint fields (upload_relay etc.), and the implementer flagged it. Tasks 16a and 16b should build on the String.
  2. minor: Relationship.friend_shares_voice_activity reads as false when absent, but the server's mapper writes inverse?.shareVoiceActivity ?? true (UserMappers.ts:392). It is always sent over REST, so this only matters when a payload omits it. Whoever builds Active Now should not read an absent flag as "not sharing".
  3. minor / note: InviteChannel.icon is not on the server's ChannelPartialResponse. It is marked not_in_spec and harmless.

Verdict: APPROVED. No blocking findings; local CI is green.

## Independent review: Daily use 2 (f2de7cd..2763b5f) **Plan tests (1):** all 20 named tests exist (`social.rs`, `invites.rs`, `report.rs`, `profile_full.rs`) and assert what the plan says: 1-100 ack batching (250 entries give 100/100/50, none gives no request), `channel_id: null` kept as disconnect on read-back, `InviteType::Unknown(7)` and `ReportOutcomeType::Unknown("appeal")` round-trip, locale and `item_ids` skipped when None, a bad connected account is dropped, `USER_NOTE_UPDATE` is typed (moved out of `UNTYPED_IN_FOUNDATION`), forward ids are skipped when empty. Both proptests are present and also re-parse what they write. **Interfaces (2):** every name in the Task 2 Interfaces block exists with the field names and shapes written there. Only deviation: `Endpoints.invite` is `Option<String>`, not `Option<Url>` (see minor 1). `MessageReferenceRequest` lost `Copy`. The fluxer-core callers were updated mechanically (field fill, `.clone()`, `.as_ref()`), with no behaviour change. **Invariants (3):** fluxer-core gains no dependency and no I/O. The fixture commit a61ef0b names a server file and line for every fixture. The fixtures contain no tokens, signed URLs or paths. Unknown or garbage input is lenient where the card or flow can survive it (guild, inviter, checklist, options, screens, notices, `errors`) and is a parse error, never a panic, elsewhere. **Parity spot-checks (4), all match the fork:** - `ReportFlowSchemas.ts:66-149`: field set, nullability, steps 1-16, item_ids 1-32, locale optional. - `ReportScreen::is_info` is the same rule as `getReportFlowScreenKind` (`ReportFlowWalk.ts:24-28`: checklist first, then next_screen_id). - `InviteModel.ts`: the guild invite carries `presence_count`, the group DM invite does not and has `channel.recipients[{username}]`, `expires_at` is always sent and null when it never expires; `ChannelMappers.ts:247` partial channel is `{id,name,type}`. - `GuildRequestSchemas.ts:157-166` mute/deaf/channel_id nullish/connection_id 1-32. - `ChannelRequestSchemas.ts:441-452` ack entries. - `UserAccountUpdatePropagator.ts:35-42` `{id, note}`. - `ApiErrorCodes.ts` values equal their names, and `CANNOT_LEAVE_GUILD_AS_OWNER` is in `ValidationErrorCodes.ts:25`. `error_codes_match_server` also checks every constant against the vendored `APIErrorCode` enum. - The `report_flow_message.json` ids (`root_message`, `private_info`, `dislike`, `doxxing`, `profile_parts`) are in `ReportFlowScreens.ts`. **IGNORED_FIELDS (as the implementer asked):** the `invite_guild`/`invite_metadata` entries list only the guild partial's banner, size, embed-splash, alignment and badge fields, and `guild_create` lists only fields `Guild` does not model (a superset of `guild.json`'s list). All of these are fields the server sends and no daily-use task reads, so nothing is hidden. The new `CONTRACTS` entries and `spec_contract_daily_use_types` check request bodies against the schema's properties and required list, and check the invite union against both branches. **Review Focus 7 (5):** covered by `arbitrary_invite_json_never_panics` (it also mutates a real answer, so parsing gets past `code` and `channel`) and `arbitrary_report_flow_json_never_panics`. Unknown invite type and unknown outcome type are kept. **CI (6):** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in the review worktree: **all steps passed** (exit 0). ### Findings 1. **minor**: `Endpoints.invite` is `Option<String>` where the plan says `Option<Url>`. This matches the sibling endpoint fields (`upload_relay` etc.), and the implementer flagged it. Tasks 16a and 16b should build on the `String`. 2. **minor**: `Relationship.friend_shares_voice_activity` reads as `false` when absent, but the server's mapper writes `inverse?.shareVoiceActivity ?? true` (`UserMappers.ts:392`). It is always sent over REST, so this only matters when a payload omits it. Whoever builds Active Now should not read an absent flag as "not sharing". 3. **minor / note**: `InviteChannel.icon` is not on the server's `ChannelPartialResponse`. It is marked `not_in_spec` and harmless. **Verdict: APPROVED.** No blocking findings; local CI is green.
Author
Owner

Merged into dailyuse at 863726f (combined merge of the first twelve Daily use tasks).

Merged into `dailyuse` at 863726f (combined merge of the first twelve Daily use tasks).
charles closed this pull request 2026-11-14 13:03:54 +00:00

Pull request closed

Sign in to join this conversation.
No description provided.