feat: Add FDv2 wire format and protocol handler#177
Conversation
| #[derive(Debug, Deserialize)] | ||
| #[serde(rename_all = "camelCase")] | ||
| pub(super) struct ServerIntentPayload { | ||
| pub(super) intent_code: IntentCode, |
There was a problem hiding this comment.
I think we are missing "reason" here.
| pub(super) version: u64, | ||
| pub(super) kind: String, | ||
| pub(super) key: String, | ||
| pub(super) object: serde_json::Value, |
There was a problem hiding this comment.
What do we think about using serde's raw value? Might save some cycles if we find we need to discard part of the stream.
| pub(super) struct PayloadTransferred { | ||
| pub(super) state: String, | ||
| #[serde(default)] | ||
| pub(super) version: u64, |
There was a problem hiding this comment.
You can remove this. We were never meant to process that version.
| #[derive(Debug, PartialEq, Eq)] | ||
| pub(super) enum Selector { | ||
| Empty, | ||
| Set { state: String, version: u64 }, |
There was a problem hiding this comment.
Means you also won't need this I don't believe.
| Put { | ||
| kind: String, | ||
| key: String, | ||
| version: u64, | ||
| object: serde_json::Value, | ||
| }, |
There was a problem hiding this comment.
Can you do Put(PutObject) and Delete(DeleteObject)?
| } | ||
|
|
||
| #[test] | ||
| fn put_object_keeps_object_as_raw_json() { |
There was a problem hiding this comment.
This isn't ensuring it is still raw bytes, just that it could parse an arbitrary object type. If we go with the raw value, this test will have to change a bit.
| } | ||
|
|
||
| #[test] | ||
| fn payload_transferred_defaults_version_when_absent() { |
There was a problem hiding this comment.
Shouldn't need this test after we remove the version.
Summary
fdv2module:ChangeSet/Selectortypesserde_json::Value; typed deserialization will live in a later translator.Selectorkeeps the deprecatedversionfield alongsidestateGoodbyeandFDv2Erroruse optional fields to tolerate permissively-parsed wire data#[allow(dead_code)]for now: types are covered by unit tests but not yet reachable from the production data path.Note
Low Risk
New code is module-scoped, dead-code gated, and covered by unit tests; it does not alter the live flag data path until integrated.
Overview
Adds a new
fdv2module (registered inlib.rsbehind#[allow(dead_code)]) that is not yet hooked into streaming/polling.wire.rsintroduces serde models for FDv2 SSE payloads (server-intent,put-object,delete-object,payload-transferred,error,goodbye) plus assembledChangeSet/Selectortypes. Put bodies stay as rawserde_json::Value; parsing is permissive (unknown intent codes, optional fields, defaultversionon payload-transferred) to align with the C++ SDK.protocol.rsimplementsFDv2ProtocolHandler, a small state machine that folds those events into full/partial/none change sets, handles errors and goodbye (goodbye always resets even if JSON is partial), and allows further partial cycles after the firstpayload-transferredwithout a new intent. Unit tests cover the main flows and edge cases.Reviewed by Cursor Bugbot for commit dfa473b. Bugbot is set up for automated code reviews on this repo. Configure here.