From 2bd831fa2b8cb657317ee9612c1d2393b852f1f0 Mon Sep 17 00:00:00 2001 From: Haobo Gu Date: Fri, 7 Aug 2026 17:08:51 +0800 Subject: [PATCH 1/2] test(rynk): freeze every row in the frame snapshot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `wire_frames.snap` dropped every row behind a feature so that any `rynk` feature set would render the same file — which left `GetBleStatus`, `SwitchBleProfile`, `ClearBleProfile`, `GetBatteryStatus`, `GetPeripheralStatus` and `BatteryStatusChange` with no frozen bytes at all. Gate the test on `host` instead, the feature superset, so the file is generated once and holds every row. Regenerate with `--features host`. `GetLayout` was missing for a different reason — never listed, though it is neither gated nor bulk — so freeze it and its `LayoutChunk` payload too. The frame helper follows the test behind `host`, and the battery row in `wire_values.snap` now reuses the shared exemplar rather than rebuilding an identical value, so neither is dead weight on a `rynk`-only build. Also states the two compatibility rules the reference left open: appending a `RynkError` variant is a `minor` bump (an old host can't decode the new tag and reports a generic failure), and `0.x` is pre-release, so the protocol stays at `0.1` while it is unpublished. --- .../main/docs/development/rynk_protocol.md | 2 + .../protocol/rynk/snapshots/wire_frames.snap | 155 ++++++++++-------- .../protocol/rynk/snapshots/wire_values.snap | 4 +- rmk-types/src/protocol/rynk/tests.rs | 101 ++++++++++-- 4 files changed, 177 insertions(+), 85 deletions(-) diff --git a/docs/docs/main/docs/development/rynk_protocol.md b/docs/docs/main/docs/development/rynk_protocol.md index 4f765947a..3705c8603 100644 --- a/docs/docs/main/docs/development/rynk_protocol.md +++ b/docs/docs/main/docs/development/rynk_protocol.md @@ -89,4 +89,6 @@ Topics are best-effort pushes; the `Get*` endpoints above mirror their payloads - `GetVersion` (`0x0001`) and its `Result` reply are frozen across all versions. - Within a major version, adding a CMD or topic is a `minor` bump: old firmware answers `UnknownCmd`, old hosts ignore unknown topics. +- Appending a `RynkError` variant is also a `minor` bump: an old host fails to decode the new tag and must surface it as a generic failure. - Reshaping an existing request/response — including appending a field — is a `major` bump. +- `0.x` is pre-release and not covered by the rules above: while the protocol is unpublished it stays at `0.1`, whole command segments included. diff --git a/rmk-types/src/protocol/rynk/snapshots/wire_frames.snap b/rmk-types/src/protocol/rynk/snapshots/wire_frames.snap index ff7ed6bdf..6d3213605 100644 --- a/rmk-types/src/protocol/rynk/snapshots/wire_frames.snap +++ b/rmk-types/src/protocol/rynk/snapshots/wire_frames.snap @@ -4,76 +4,89 @@ # payload, COBS-encoded with a trailing 0x00 delimiter — one per protocol message; the # label names the decoded payload (`()` = empty). A diff means the header, a CMD number, # or a message frame changed. If intentional, bump ProtocolVersion::CURRENT and regenerate: -# UPDATE_SNAPSHOTS=1 cargo test -p rmk-types --features rynk wire_frames +# UPDATE_SNAPSHOTS=1 cargo test -p rmk-types --features host wire_frames # Format: