Task 3: fluxer-proto REST wire models + hand-authored fixtures (#3) #35
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "task/3-proto-rest-models"
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?
What this builds
fluxer_proto::models(also re-exported at the crate root): the hand-written REST wire models of Task 3, with the names and fields of the plan's Interfaces block, and 13 hand-authored fixtures infixtures/rest.UserPartial,UserPrivate,Guild,Role,GuildMember,Channel,PermissionOverwrite,Message,MessageReference,ReadState,Presence,UserSettings,WellKnown,Endpoints,LoginResponse,AuthToken.LoginRequest,MfaTotpRequest,MessagesQuery,SendMessageRequest,EditMessageRequest.null, and are left out when written back at their default. Fields the schema marks.nullable()are written asnull.Message::referenced_messageis the doubleOptionthe plan asks for.@example.test.How it was tested
crates/fluxer-proto/tests/models_roundtrip.rs, 14 tests, written first and seen failing (first commit):every_rest_fixture_roundtrips: fixture → model → JSON must equal the fixture exactly, minus the paths inIGNORED_FIELDS. An ignore entry that matches nothing fails the test, and so does a fixture file that is not in the table.message_referenced_message_absent_vs_nullandunknown_fields_are_ignored(an unknown field is injected into every typed object of every fixture).LoginResponsevariants,ReadStateandPresence(which have no fixture in this task), theUserSettingsaccessors and the request bodies.cargo xtask cipasses locally on Linux. I did not wait for the Forgejo runners.Deviations from the plan
WellKnown::api_code_version: the plan types itString, but the server sends a JSON integer (z.number().int()inInstanceSchemas.ts). The field stays aStringso the interface is unchanged; it is read from an integer or a string and written back as an integer when it is one. A plainStringwould have failed on every real discovery document.AuthTokenandLoginRequestimplementDebugby hand instead of deriving it, so the token and the password are redacted. The plan says to deriveDebugon everything; the trait is still there.IGNORED_FIELDShas 41 entries, which is more than "small": 14 for the discovery document, 13 for the private user, 11 for the guild, 3 for the voice channel. The alternative was fixtures that leave out fields the server always sends. Say if you prefer leaner fixtures.UserSettings::guild_positions()is implemented as specified, butguild_positionsappears only in the fork's settings request schema, not inUserSettingsResponse. Against the real server it may always return an empty list. Task 9 should check where the guild order really comes from.MessageReferenceandEndpointsfield lists (the plan names the types only),GuildMemberwith all 12 schema fields,ReadState::versionasOption<u64>(a decimal string on the wire),UserPrivate::partial()andFrom<UserPrivate> for UserPartial,DefaultforUserSettings.crates/fluxer-proto/src/lib.rs(module declaration and re-exports; Task 4 edits the same lines) and the crateREADME.md.For the reviewer
nullfor them. A recorded server response with"topic": nullparses, but is written back without the key.Presence::statusreads a missing ornullstatus asOffline.Guildrequiresid,nameandowner_id. An unavailable-guild stub ({id, unavailable}) will not parse asGuild; Task 4 needs its own shape for that.Closes #3
🤖 Generated with Claude Code
Independent review: Task 3 (proto-rest-models) at
7f384d7Verdict: APPROVE (0 blocking, 4 minor). Local
cargo xtask ciin a clean review worktree: all steps passed (screenshot tests skipped,FLUXER_SCREENSHOT_TESTSnot set). Remote runners not checked.Checked:
every_rest_fixture_roundtrips,message_referenced_message_absent_vs_nullandunknown_fields_are_ignoredexist incrates/fluxer-proto/tests/models_roundtrip.rsand assert what the plan says (strict structural equality minusIGNORED_FIELDS; stale ignore entries fail; absent / null / populated all covered and null survives a round-trip; unknown fields injected into every typed object of all 13 fixtures). All 13 fixtures in the Files list exist andevery_fixture_file_is_coveredties the directory to the table.Channel::r#type,PermissionOverwrite::kindas"type",Option<Option<Box<Message>>>,MessagesQuery::limit: u8, the untaggedLoginResponse::{Ok(AuthToken), Mfa{..}},UserSettings::{guild_positions, theme},WellKnown/Endpoints. All re-exported fromfluxer_proto::modelsand the crate root.unwrap/expect/indexing in non-test code; malformed input is anErr; unknown enum values are preserved. Fixtures hold no secrets: the token is an obvious placeholder (flx_FIXTURE...), the email isexample.test.ErrforLoginResponse(not a panic) is tested, which Task 6 relies on.AuthSchemas.ts,MessageResponseSchemas.ts,GuildRoleSchemas.ts,GuildMemberSchemas.ts,ChannelSchemas.ts,GuildResponseSchemas.ts,InstanceSchemas.ts. The implementer's deviation notes are accurate (api_code_versionisz.number().int();guild_positionsonly appears inUserRequestSchemas.ts).Findings:
crates/fluxer-proto/src/models/auth.rs:AuthTokenandLoginRequestimplementDebugby hand instead ofderive(Debug). The trait is still there, so consumers are unaffected, and redaction is the safer choice; the plan's Interfaces line should be amended. Note that both still deriveSerialize, so callers must not log their JSON form.crates/fluxer-proto/src/models/auth.rs:LoginResponseis untagged, so any failure reports only "data did not match any variant". Task 6 has to classify error and captcha bodies from the HTTP status and body before trying this type; it cannot get a useful message from the serde error.crates/fluxer-proto/src/models/settings.rs:guild_positions()reads a key that the fork only defines in the settings request schema. It may always be empty against the real server; Task 9 must verify guild ordering against a real READY payload and not assume this accessor works.crates/fluxer-proto/tests/models_roundtrip.rs:IGNORED_FIELDShas 41 entries against the plan's "keep that map small". Each is a field the server really sends and each entry is checked for staleness, so this is acceptable; the alternative (thinner fixtures) would be worse.Notes for dependent tasks (not findings):
Guildrequiresid,name,owner_id, so an unavailable-guild stub does not parse asGuild(Task 4 needs its own shape);crates/fluxer-proto/src/lib.rswill conflict trivially with Task 4'smod/re-export lines.fluxer-protogateway envelope, opcodes, events (#4) #36fluxer-protogateway envelope, opcodes, events (#4) #36