Skip to content

feat: add FDv2 protocol foundation types and state machine#253

Open
kinyoklion wants to merge 10 commits intomainfrom
SDK-2182/fdv2-protocol-foundation
Open

feat: add FDv2 protocol foundation types and state machine#253
kinyoklion wants to merge 10 commits intomainfrom
SDK-2182/fdv2-protocol-foundation

Conversation

@kinyoklion
Copy link
Copy Markdown
Member

@kinyoklion kinyoklion commented Apr 15, 2026

Adds the base FDv2 protocol types and the protocol handler.

Introduces the core FDv2 wire protocol types, protocol handler state
machine, source result types, flag eval mapper, async queue, and
selector. Pure library code with no SDK integration — existing
behavior is unchanged.

New files in packages/common_client/lib/src/data_sources/fdv2/:
- fdv2_protocol_types.dart: wire protocol event types and deserialization
- fdv2_protocol_handler.dart: protocol state machine
- fdv2_payload.dart: Payload and Update data types
- fdv2_source_result.dart: sealed ChangeSetResult/StatusResult types
- fdv2_flag_eval_mapper.dart: FDv2 updates to ItemDescriptor conversion
- async_queue.dart: async producer/consumer queue
- selector.dart: opaque selector value type
@kinyoklion
Copy link
Copy Markdown
Member Author

bugbot review

put-object and delete-object with unrecognized kinds were silently
accumulated into payloads instead of being ignored. Fix the processor
lookup to return early when no processor is registered, and add a
kind check to delete-object. Update tests to verify updates are
excluded from emitted payloads, not just that the method returns
ActionNone. Remove unused dart:async import.
@kinyoklion
Copy link
Copy Markdown
Member Author

bugbot review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cec5ebb. Configure here.

AsyncQueue is a JavaScript pattern. Dart's StreamController/Stream is
the idiomatic equivalent and is already used by the existing FDv1
data sources in this codebase. Future FDv2 data sources will use
StreamController<FDv2SourceResult> instead.
A selector represents both the opaque state string (sent as the basis
query parameter) and the payload version. The version is not currently
used but is part of the protocol and needed for future features.
Selector is now non-nullable on Payload, defaulting to Selector.empty.
An empty selector (empty state string) means no known state, removing
the need for null checks. The factory constructor is replaced with a
plain const constructor since there is no null-coalescing logic needed.
Avoid abbreviations in Dart enum values. The wire values ('xfer-full',
'xfer-changes') are unchanged.
Files inside the fdv2/ directory don't need the fdv2_ prefix.
Renames: fdv2_payload.dart → payload.dart, fdv2_protocol_handler.dart
→ protocol_handler.dart, fdv2_protocol_types.dart → protocol_types.dart,
fdv2_source_result.dart → source_result.dart,
fdv2_flag_eval_mapper.dart → flag_eval_mapper.dart. Test files follow
the same pattern.
Nothing imports fdv2.dart. Dart consumers import specific files
directly.
The null (unknown) intentCode branch in _processServerIntent did not
clear _tempUpdates, allowing accumulated updates from a prior transfer
to leak into the next emitted payload. Now clears _tempUpdates to
match the behavior of all recognized intent code branches.
@kinyoklion kinyoklion marked this pull request as ready for review April 17, 2026 00:31
@kinyoklion kinyoklion requested a review from a team as a code owner April 17, 2026 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant