Skip to content

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

  1. Add to the Args struct in ryll/src/config.rs.
  2. Pass through to the relevant code in ryll/src/main.rs or to RyllApp::new in ryll/src/app/mod.rs.

Document the option in configuration: the CLI reference is maintained there, not in the code comments.

Adding a new statistic

  1. Add a variant to the ChannelEvent enum in shakenfist-spice-renderer/src/channels/mod.rs.
  2. Send it from the relevant channel handler in shakenfist-spice-renderer/src/channels/, via self.events.emit(...) — never a bare event_tx. EventSink couples the queue to the repaint wake-up, so a new event cannot forget it and leave the UI stale.
  3. Handle it in process_events() in ryll/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

  1. 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 implements WireType (or ClipboardWireType where the layout depends on negotiated capabilities), with a BoundedReader reader and an infallible writer. It ships with an assert_round_trip test and a test decoding hand-written bytes laid out from spice.proto.
  2. Constants and enums go in shakenfist-spice-protocol/src/constants.rs.
  3. Channel-specific logic goes in shakenfist-spice-renderer/src/channels/*.rs.
  4. 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.
  5. Parsers of untrusted wire input use the BoundedReader in shakenfist-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.

📝 Report an issue with this page