Skip to content

feat: Add FDv2 source manager#298

Open
kinyoklion wants to merge 1 commit into
mainfrom
rlamb/sdk-2186/fdv2-source-manager
Open

feat: Add FDv2 source manager#298
kinyoklion wants to merge 1 commit into
mainfrom
rlamb/sdk-2186/fdv2-source-manager

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Jun 10, 2026

Copy link
Copy Markdown
Member

What this adds

The source manager tracks which FDv2 data source is active and handles source transitions for the orchestrator (a later PR). Nothing consumes it yet, so behavior is unchanged.

It manages two tiers with different lifecycles:

  • Initializers run once each, in order, and exhaust: each call to nextInitializer closes the previous active source and produces the next one until the list runs out. The orchestrator uses this to bring the SDK to a usable state from cache or a poll.
  • Synchronizer slots cycle rather than exhaust: nextAvailableSynchronizer scans forward from the current position with wrap-around, skipping blocked slots. A slot is blocked after a terminal error (blockCurrentSynchronizer), the scan position resets to the primary for recovery (resetSynchronizerIndex), and recreateCurrentSynchronizer produces a fresh instance of the current slot without advancing — used when a source must drop its connection and re-establish it (goodbye, restart).

isPrimarySynchronizer and availableSynchronizerCount feed the fallback/recovery condition selection (#297).

FDv1 fallback slots start blocked and are only activated by a server fallback directive: engageFdv1Fallback makes the FDv1 slots available and blocks the FDv2 tier, disabling it rather than removing it so the configuration survives for a later recovery to FDv2.

Every transition closes the previously active source, and close shuts the manager down so no further sources can be created.

Testing

Unit tests cover initializer ordering and exhaustion, synchronizer cycling with wrap-around, blocked-slot skipping, the all-blocked case, recovery reset, in-place re-creation, FDv1 fallback engagement (FDv2 tier disabled, FDv1 tier activated), and that close prevents further source creation and closes the active source.

SDK-2186


Note

Low Risk
New isolated module with tests only; no integration into existing data source paths until a follow-up PR.

Overview
Adds a new FDv2 SourceManager (plus SynchronizerSlot / slot state) that will drive orchestrator source transitions. It is not wired in yet, so runtime behavior is unchanged.

Initializers are advanced sequentially via nextInitializer() (each step closes the prior active source) until the factory list is exhausted. Synchronizers live in slots that rotate with nextAvailableSynchronizer() (forward scan with wrap, skip blocked slots). Recovery helpers include blockCurrentSynchronizer(), resetSynchronizerIndex(), and recreateCurrentSynchronizer() for reconnect without changing slot. engageFdv1Fallback() blocks FDv2 slots and unblocks FDv1 fallback slots (which start blocked). Exposes isPrimarySynchronizer, availableSynchronizerCount, and hasFdv1Fallback for later fallback logic.

Unit tests cover ordering, cycling, blocking, FDv1 engagement, recreate, and shutdown.

Reviewed by Cursor Bugbot for commit 1716d97. Bugbot is set up for automated code reviews on this repo. Configure here.

Tracks the initializer and synchronizer lifecycle for the FDv2
orchestrator: initializers run once each in order; synchronizer slots
cycle with wrap-around, can be blocked after terminal errors,
re-created in place for reconnects, and reset to the primary for
recovery. FDv1 fallback slots start blocked and are activated by a
server fallback directive, disabling the FDv2 tier. Nothing consumes
this yet.
@kinyoklion

Copy link
Copy Markdown
Member Author

bugbot review

@kinyoklion

Copy link
Copy Markdown
Member Author

bugbot review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

1 issue from previous review remains unresolved.

Fix All in Cursor

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 1716d97. Configure here.

@kinyoklion kinyoklion marked this pull request as ready for review June 10, 2026 23:26
@kinyoklion kinyoklion requested a review from a team as a code owner June 10, 2026 23:26
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