Skip to content

fix: Close the final initializer on exhaustion; document the source manager contract#304

Merged
kinyoklion merged 1 commit into
mainfrom
rlamb/sdk-2186/fdv2-source-manager-fixes
Jun 12, 2026
Merged

fix: Close the final initializer on exhaustion; document the source manager contract#304
kinyoklion merged 1 commit into
mainfrom
rlamb/sdk-2186/fdv2-source-manager-fixes

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Jun 11, 2026

Copy link
Copy Markdown
Member

What this changes

Two small behavior hardenings and an explicit statement of the source manager's API contract.

  • Initializer exhaustion closes the final initializer. Every other transition closes the previous source when the next one is activated, but the exhaustion path returned null with the last initializer still active. When no synchronizer activation follows, that initializer (and its HTTP client) was held until shutdown. A terminal null now leaves no source running.
  • engageFdv1Fallback() is a no-op when no FDv1 fallback slot is configured. Blocking every slot without unblocking a fallback would leave nothing to activate. The orchestration layer checks before engaging; the guard makes the operation safe regardless of the caller.
  • hasFdv1FallbackConfigured replaces hasFdv1Fallback to make clear it reports configuration, not engagement state.

The documented contract

The class docs now state the assumptions the manager operates under, so they are visible at the API surface rather than implicit in the call sites:

  • The manager assumes a single, sequential driver. At most one source is active at a time: activating a source closes the previous one, exhaustion closes the final initializer, and close closes whatever remains.
  • The synchronizer scan cursor doubles as the active-slot pointer. From an activation (nextAvailableSynchronizer / recreateCurrentSynchronizer) until the next cursor mutation (resetSynchronizerIndex / engageFdv1Fallback), the cursor identifies the running synchronizer's slot — isPrimarySynchronizer and blockCurrentSynchronizer read it and are only meaningful inside that window. After mutating the cursor, a new synchronizer must be activated before consulting either. The driver satisfies this by construction: both reads happen strictly between an activation and the run's outcome being decided, and cursor mutations happen only after the outcome is decided.

Testing

New tests pin the exhaustion close (a terminal null leaves no source running) and the fallback-engagement guard (engaging with no configured FDv1 slot leaves the slot list untouched). Full package suite passes.

SDK-2186

@kinyoklion kinyoklion marked this pull request as ready for review June 12, 2026 16:32
@kinyoklion kinyoklion requested a review from a team as a code owner June 12, 2026 16:32
@kinyoklion kinyoklion marked this pull request as draft June 12, 2026 20:30
@kinyoklion kinyoklion force-pushed the rlamb/sdk-2186/fdv2-source-manager-fixes branch from d7b99a0 to f0e7b5c Compare June 12, 2026 20:30
@kinyoklion kinyoklion changed the title fix: Separate the FDv2 source manager scan cursor from the active slot fix: Close the final initializer on exhaustion; document the source manager contract Jun 12, 2026
/// activate. The active source keeps running until the next
/// activation closes it.
void engageFdv1Fallback() {
if (!hasFdv1FallbackConfigured) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

In practice we may not make this possible.

@kinyoklion kinyoklion marked this pull request as ready for review June 12, 2026 20:42
@kinyoklion kinyoklion merged commit b20c35e into main Jun 12, 2026
6 checks passed
@kinyoklion kinyoklion deleted the rlamb/sdk-2186/fdv2-source-manager-fixes branch June 12, 2026 21:00
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.

2 participants