chore: Extract shared sans-I/O cores from sync data paths by jsonbailey · Pull Request #450 · launchdarkly/python-server-sdk · GitHub
Skip to content

chore: Extract shared sans-I/O cores from sync data paths#450

Open
jsonbailey wants to merge 1 commit into
mainfrom
jb/sdk-2602/core-extraction
Open

chore: Extract shared sans-I/O cores from sync data paths#450
jsonbailey wants to merge 1 commit into
mainfrom
jb/sdk-2602/core-extraction

Conversation

@jsonbailey

@jsonbailey jsonbailey commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

What

Extracts the shared, I/O-free ("sans-I/O") logic out of three sync data paths into dedicated _core modules that both the existing sync code and the future async siblings build on:

  • ldclient/impl/client_core.py — environment-metadata construction, plugin-hook collection, and the secure-mode HMAC helper, lifted out of LDClient.
  • ldclient/impl/datasystem/fdv2_core.py — the FDv2 status providers (DataSourceStatusProviderImpl, DataStoreStatusProviderImpl), the persistent-store wrapper (FeatureStoreClientWrapper), and the ConditionDirective enum.
  • ldclient/impl/events/event_processor_core.py — the shared event wrapper/output types (DebugEvent, IndexEvent, EventOutputFormatter, EventBuffer, FlushPayload).

The sync modules (client.py, impl/events/event_processor.py, impl/datasystem/fdv2.py) now import and route through these cores. fdv2.py re-exports the moved names (via __all__) so existing import paths such as from ldclient.impl.datasystem.fdv2 import FeatureStoreClientWrapper continue to resolve unchanged.

CONTRIBUTING.md gains a short sync/async parity note describing the _core convention.

Why

Part of the async Python SDK epic (SDK-60). Pulling this shared logic into _core modules lets the sync and async client implementations share identical, I/O-free behavior instead of duplicating it. This PR contains only the extraction and the sync routing; the async siblings and async packaging land in separate slices.

Parity

This is a pure refactor — sync behavior must remain byte-for-byte identical to main. The extracted functions/classes are moved verbatim (the only mechanical change is self._config becoming an explicit config parameter in client_core). This warrants a careful sync-behavior review to confirm no behavioral drift slipped in.

Validation

  • uv run pytest ldclient/testing — 1012 passed, 197 skipped (DB/YAML skips only)
  • uv run mypy ldclient — Success: no issues found in 165 source files
  • uv run isort --check ldclient — clean

Refs SDK-2602 (epic SDK-60).


Note

Medium Risk
Large mechanical moves across client startup, FDv2 persistence monitoring, and event formatting; behavior is intended to be identical but warrants careful sync regression review.

Overview
Pulls shared, I/O-free logic into three _core modules so sync and future async clients can reuse the same code, and wires the existing sync paths through them.

client_core.py holds environment metadata, plugin hook collection, and secure_mode_hash; LDClient now calls these instead of private methods.

fdv2_core.py holds FDv2 status providers, FeatureStoreClientWrapper, and ConditionDirective; fdv2.py imports them and re-exports via __all__ so existing import paths stay valid.

event_processor_core.py holds EventBuffer, EventOutputFormatter, and related event wrapper types; the sync event processor imports from there.

CONTRIBUTING.md documents the sync/async _core convention and parity expectations.

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

@jsonbailey jsonbailey force-pushed the jb/sdk-2602/core-extraction branch from 8906a2a to 6cc7d23 Compare June 25, 2026 20:39
@jsonbailey jsonbailey marked this pull request as ready for review June 25, 2026 20:53
@jsonbailey jsonbailey requested a review from a team as a code owner June 25, 2026 20:53
@jsonbailey jsonbailey changed the title refactor: Extract shared sans-I/O cores from sync data paths chore: Extract shared sans-I/O cores from sync data paths Jun 25, 2026
@jsonbailey jsonbailey force-pushed the jb/sdk-2602/core-extraction branch from 6cc7d23 to a3d1f1b Compare June 25, 2026 22:23
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