Expand copilot-instructions: code style, module organization, and safety model#17
Draft
Expand copilot-instructions: code style, module organization, and safety model#17
Conversation
Agent-Logs-Url: https://github.com/yungcomputerchair/RustyFusion/sessions/c6eb9969-91f2-4c15-a0f7-feace41a8b84 Co-authored-by: yungcomputerchair <5123173+yungcomputerchair@users.noreply.github.com>
Agent-Logs-Url: https://github.com/yungcomputerchair/RustyFusion/sessions/3dcdf4b6-8a50-40ff-8f00-61dbb78e3473 Co-authored-by: yungcomputerchair <5123173+yungcomputerchair@users.noreply.github.com>
… safety sections Agent-Logs-Url: https://github.com/yungcomputerchair/RustyFusion/sessions/2d2c844b-70af-4a2d-9d4b-078923c6b7c2 Co-authored-by: yungcomputerchair <5123173+yungcomputerchair@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
yungcomputerchair
April 18, 2026 21:42
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The instructions were thin on three topics contributors need to reason about correctly: code style conventions, how modules are structured, and how client input is validated. Also corrects the false claim that there are no unit tests.
Code Style
enums::*,error::*,PacketID::*) and when to use them#[allow(non_snake_case)]patternasfor well-bounded protocol fields,try_into()?for enums or out-of-range valuesModule Organization
src/lib.rs) vs. binary (src/bin/) separation and what belongs wherepub use *re-export pattern (mod ffclient; pub use ffclient::*;)OnceLock/LazyLock(config_get(),tdata_get(),db_get()); mutable game state stays inShardServerState/LoginServerStatemod helpers { … }submodule at bottom of fileSafety — Trust-but-Verify
Documents the four validation layers every packet passes through:
can_send_packet): unknown clients may only send a 3-packet whitelist; all others filtered by direction bitmaskpkt.get()): alignment + size checked before transmute; misaligned data returnsFFError, not UBtry_into()?, slot bounds, target count caps, entity lookups returningFFResult, resource/currency checks,validate_perms()guard on all GM handlerspending_entering_uidsprevent replay and double-enter racesAlso documents why the single
unsafeblock inbytes_to_structis sound and points to thenet/mod.rsunit tests that cover it.Unit Tests
Corrects the erroneous "no unit tests" statement. Tests exist in
util,config,chunk,net/mod,net/crypto,entity/mod, andtabledata.