Extending ryll¶
Step-by-step recipes for the changes that touch several crates at once. Each one lists the places a change has to land for the feature to be complete, in the order they are easiest to write, plus the conventions that are easy to get wrong at each step.
These recipes say where code goes. For why the crates are split the way they are see key design decisions, and for the crate map itself see ARCHITECTURE.md.
Adding a new CLI option¶
- Add to the
Argsstruct inryll/src/config.rs. - Pass through to the relevant code in
ryll/src/main.rsor toRyllApp::newinryll/src/app/mod.rs.
Document the option in configuration: the CLI reference is maintained there, not in the code comments.
Adding a new statistic¶
- Add a variant to the
ChannelEventenum inshakenfist-spice-renderer/src/channels/mod.rs. - Send it from the relevant channel handler in
shakenfist-spice-renderer/src/channels/, viaself.events.emit(...)— never a bareevent_tx.EventSinkcouples the queue to the repaint wake-up, so a new event cannot forget it and leave the UI stale. - Handle it in
process_events()inryll/src/app/events.rs.
Whether a new concern should be a ChannelEvent variant at all, or a
trait the channel writes to, is a judgement call the
AGENTS.md
convention on ChannelEvent versus a trait settles. What each
statistic then means to a reader is in
diagnostics.
Modifying protocol handling¶
- Message definitions go in the
shakenfist-spice-protocol/src/messages/module, one submodule per channel (common,main,display,cursor,inputs,playback,vd_agent). A new type implementsWireType(orClipboardWireTypewhere the layout depends on negotiated capabilities), with aBoundedReaderreader and an infallible writer. It ships with anassert_round_triptest and a test decoding hand-written bytes laid out fromspice.proto. - Constants and enums go in
shakenfist-spice-protocol/src/constants.rs. - Channel-specific logic goes in
shakenfist-spice-renderer/src/channels/*.rs. - Link handshake and auth live in
shakenfist-spice-protocol/src/link.rs— both the client role (perform_link,perform_auth,encrypt_password) and the server/proxy role (read_link_mess,send_link_reply,read_auth_ticket,send_auth_result,generate_ticket_keypair,decrypt_password). The kerbside SPICE proxy rewrite consumes the server role, so the server half is not dead code. - Parsers of untrusted wire input use the
BoundedReaderinshakenfist-spice-protocol/src/reader.rs(bounds- and overflow-checked, panic-free) rather than ad-hoc slicing.
What a new parser owes the rest of the tree¶
The parsing rules in step 5 are not style preferences; each one closes a class of bug the SPICE server is in a position to trigger. The normative statements are in STYLEGUIDE.md, under the section names given here.
| Concern | Rule | STYLEGUIDE.md section |
|---|---|---|
| Framing | Channel read loops frame messages with a ReceiveBuffer and MAX_MESSAGE_BODY, never by hand |
"Message framing" |
| Allocation | Image decoders size output buffers with limits::rgba_len |
"Dimension safety" |
| In-range nonsense | A wire field parsing cannot refuse — any count or rate whose every bit pattern is in range — is checked where it is stored into channel state | "Server-chosen values" |
| Display | Text the server chose is sanitised in its accessor | "Server-supplied text" |
New link and message parsers should also ship with a fuzz target
under shakenfist-spice-protocol/fuzz/. Two open issues track the
backlog there: ryll#135 broadens coverage, and
ryll#136 retrofits existing parsers onto BoundedReader.
Helper tooling¶
tools/pcap-inspect.py, tools/web-smoke.sh and
examples/control-socket-demo.py support all three recipes above and
are documented in development.