Skip to content

docs: add ADR 0010 to disable default polling for static-context providers#69

Open
jonathannorris wants to merge 5 commits intomainfrom
adr/event-driven-refresh
Open

docs: add ADR 0010 to disable default polling for static-context providers#69
jonathannorris wants to merge 5 commits intomainfrom
adr/event-driven-refresh

Conversation

@jonathannorris
Copy link
Copy Markdown
Member

Summary

  • Proposes disabling default timer-based polling for static-context providers
  • Providers should re-fetch on initialization, context change, app foreground / page visibility, and SSE push
  • Timer-based polling remains available as opt-in but defaults to disabled

Motivation

Current OFREP static-context providers poll on a fixed timer by default (JS: 30s, Swift: 30s, Kotlin: 5min). This breaks sticky bucketing expectations and wastes resources on mobile. The majority of vendor SDKs (DevCycle, LaunchDarkly, Statsig, Eppo) do not use timer-based polling as the default client-side refresh mechanism.

See the vendor comparison table in the issue for details.

Notes

  • This supersedes the default polling behavior in ADR-0005 for static-context providers only. ADR-0005 remains valid for the polling mechanism itself and for server-side providers.
  • Designed to work alongside ADR-0008 (SSE) and ADR-0009 (local persistence / cache-first initialization).
  • Open questions around foreground refresh cooldown duration and migration path for existing applications.

Related Issues

Closes #68

@jonathannorris jonathannorris requested a review from a team as a code owner March 19, 2026 21:24
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant change to how static-context providers refresh feature flag evaluations. It proposes disabling default timer-based polling in favor of event-driven mechanisms, such as initialization, context changes, app foreground/page visibility, and Server-Sent Events (SSE) pushes. This aims to enhance sticky bucketing consistency, reduce resource consumption on client devices, and align the OpenFeature Protocol with common practices observed in leading vendor SDKs.

Highlights

  • Default Polling Disabled: Timer-based polling is now disabled by default for static-context providers to prevent sticky bucketing issues and improve resource efficiency on client devices.
  • Event-Driven Refresh: Providers will now re-fetch bulk evaluations based on event-driven triggers: initialization, context changes, app foreground/page visibility, and Server-Sent Events (SSE) push events.
  • Opt-in Polling: Timer-based polling remains available as an opt-in configuration, with the default poll interval set to disabled (0 or negative value) for applications that explicitly require it.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces ADR 0010, which proposes to disable default timer-based polling for static-context providers in favor of event-driven updates. This is a well-reasoned and detailed proposal that aligns with common industry practices. My review includes a few suggestions to improve the accuracy and completeness of the ADR: correcting a potentially broken link to another ADR, fixing an incorrect API name for watchOS foreground detection, and recommending that a more concrete migration strategy for the proposed breaking change be included directly in the ADR.

Copy link
Copy Markdown
Member

@toddbaert toddbaert left a comment

Choose a reason for hiding this comment

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

I'm good with this, but interested in what @beeme1mr @lukas-reining @thomaspoignant think.

Copy link
Copy Markdown
Member

@lukas-reining lukas-reining left a comment

Choose a reason for hiding this comment

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

Approving with some comments.


Timer-based polling is problematic for static-context providers for two reasons:

1. **Sticky bucketing** — polling causes flag values to change mid-session, breaking the expectation that a user sees consistent behavior throughout a session. Most platforms expect feature flag bucketing to remain sticky for a user's whole session. Changing flag values mid-session can cause UI flicker, inconsistent experiences, and breaks experiment integrity.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why does polling change the bucketing?
Wouldn't we assume the bucketing to be consistent throughout all reloads of an app during the experiment? The polling is noting else than a reload to me.

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.

While bucketing is generally deterministic, there are cases where time-based rules (commonly used in rollouts) would get triggered by polling where they would generally stay consistent between sessions if polling wasn't used. With 30s polling, those changes get picked up mid-session while the user is actively using the app, which can cause the experience to shift unexpectedly. With foreground-only refresh, changes are picked up at a natural transition point when the user returns to the app. SSE-based pushes as discussed in ADR-0008 would also trigger changes, but those are explicit server-initiated notifications rather than the client blindly re-fetching on a timer.


2. **Context change** — when `onContextChange` is invoked (e.g., user switch, logout), the provider re-fetches bulk evaluations for the new context. This is already handled by existing provider implementations.

3. **App foreground / page visibility** — when the application returns from the background or the page becomes visible, the provider should re-fetch bulk evaluations. This ensures values are fresh when the user returns without requiring continuous polling.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would't this bring back the flickering described above?
First the old values would be there until the request has finished.

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.

yea there's still a potential for the values to change on foreground, but in most real-world cases it's very unlikely there is any change when the app is foregrounded since feature flag changes are fairly infrequent. The difference is also that it happens at a natural transition point when the user returns to the app rather than unpredictably while they're actively using it. Users already expect the app to refresh when they come back to it. With polling, the values can change mid-interaction which is more disruptive.

… providers

Replace default timer-based polling with trigger-based refresh (initialization, context change, app foreground, SSE push). Closes #68.

Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
… ADR 0010

Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
@jonathannorris jonathannorris force-pushed the adr/event-driven-refresh branch from 4f82864 to c987f3d Compare April 14, 2026 14:06
Breaking provider change is acceptable since OFREP providers are all sub-v1.

Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
…R 0010

Foreground re-fetch cooldown is unnecessary since ETag/304 handles redundant requests.

Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
@jonathannorris jonathannorris requested a review from Copilot April 14, 2026 21:01
@jonathannorris
Copy link
Copy Markdown
Member Author

/gemini review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Architecture Decision Record (ADR) documenting a shift away from default timer-based polling for OFREP static-context providers, favoring event-driven refresh (init/context change/foreground/SSE), while keeping polling as opt-in.

Changes:

  • Introduces ADR-0010 specifying that default timer polling should be disabled for static-context providers.
  • Defines recommended event-driven refresh triggers (initialization, context change, foreground/visibility, SSE push).
  • Documents interactions with SSE (changeDetection modes) and conditional refresh via ETag.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


Static-context providers should not poll on a fixed timer by default. Instead, providers should re-fetch bulk evaluations based on event-driven triggers:

1. **Initialization** — as defined in [ADR-0009](0009-localStorageForStaticContextProviders.md), providers fetch bulk evaluations during initialization (or load from cache and refresh in the background).

4. **SSE push** — when an SSE `refetchEvaluation` event is received (as defined in [ADR-0008](0008-sse-for-bulk-evaluation-changes.md)), the provider re-fetches bulk evaluations. This provides real-time updates when the server supports it.

Timer-based polling should remain available as an opt-in configuration for applications that want it, but the default poll interval should be disabled (0 or negative value).
- `polling`: Opt-in timer-based polling for applications that want it. When this mode is selected, the provider should still re-fetch on foreground in addition to polling.
- `none`: No background refresh. Rely solely on initialization and `onContextChange` calls.

This ADR changes the behavior within the `sse` default mode: instead of falling back to timer-based polling when SSE is unavailable, the provider relies on foreground refresh and explicit context change triggers. Timer-based polling is only used when explicitly configured via the `polling` mode.
Comment on lines +68 to +69
All re-fetch triggers (foreground, SSE push, context change, opt-in polling) should use the stored `ETag` with `If-None-Match` for bandwidth efficiency, except when performing a full unconditional re-fetch after SSE inactivity (as specified in [ADR-0008](0008-sse-for-bulk-evaluation-changes.md)).

- Foreground detection should be implemented behind a platform abstraction so it can be tested and swapped
- The existing `pollInterval` configuration should default to `0` (disabled) instead of the current positive values (JS: 30000ms, Swift: 30s, Kotlin: 5min). Applications can opt into polling by setting a positive value.
- This ADR supersedes the default polling behavior established in [ADR-0005](0005-polling-for-bulk-evaluation-changes.md) for static-context providers only. ADR-0005 remains valid for the polling protocol mechanism itself and for dynamic-context (server-side) providers.
- Providers should emit `PROVIDER_CONFIGURATION_CHANGED` when a foreground re-fetch returns updated flag values

- [ADR-0005: Polling for bulk evaluation changes](0005-polling-for-bulk-evaluation-changes.md)
- [ADR-0008: SSE for bulk evaluation changes](0008-sse-for-bulk-evaluation-changes.md)
- [ADR-0009: Local storage for static-context providers](0009-localStorageForStaticContextProviders.md)
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces ADR-0010, which proposes disabling default timer-based polling for static-context providers in favor of event-driven triggers such as application foregrounding and SSE. The review feedback identifies a contradiction regarding 'unconditional' re-fetches when SSE is unavailable, which conflicts with the ETag revalidation strategy, and notes an inconsistency in event naming compared to existing project guidelines.


On foreground, if the provider has an active SSE connection, no re-fetch is needed as the SSE connection handles change detection. If the SSE connection was closed during inactivity (as described in [ADR-0008](0008-sse-for-bulk-evaluation-changes.md)), the provider should reconnect and perform a full unconditional re-fetch.

If SSE is not configured or not supported by the server, the provider should re-fetch on foreground unconditionally.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The term 'unconditionally' here contradicts the 'ETag revalidation' section on line 68. If SSE is not supported, the foreground trigger should still use conditional requests (ETag) to save bandwidth, as it is not subject to the 'SSE inactivity' exception defined in ADR-0008.

Suggested change
If SSE is not configured or not supported by the server, the provider should re-fetch on foreground unconditionally.
If SSE is not configured or not supported by the server, the provider should re-fetch on foreground.

- Foreground detection should be implemented behind a platform abstraction so it can be tested and swapped
- The existing `pollInterval` configuration should default to `0` (disabled) instead of the current positive values (JS: 30000ms, Swift: 30s, Kotlin: 5min). Applications can opt into polling by setting a positive value.
- This ADR supersedes the default polling behavior established in [ADR-0005](0005-polling-for-bulk-evaluation-changes.md) for static-context providers only. ADR-0005 remains valid for the polling protocol mechanism itself and for dynamic-context (server-side) providers.
- Providers should emit `PROVIDER_CONFIGURATION_CHANGED` when a foreground re-fetch returns updated flag values
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The event name PROVIDER_CONFIGURATION_CHANGED is inconsistent with the existing documentation in guideline/static-context-provider.md (line 83), which uses ConfigurationChanged. While PROVIDER_CONFIGURATION_CHANGED is the official OpenFeature specification constant, it is better to maintain consistency with the other guidelines in this repository.

Suggested change
- Providers should emit `PROVIDER_CONFIGURATION_CHANGED` when a foreground re-fetch returns updated flag values
- Providers should emit `ConfigurationChanged` when a foreground re-fetch returns updated flag values

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.

Disable Default Polling for OFREP Static-Context Providers

4 participants