Skip to content

chore: Add async contract-test service for FDv1 - #481

Merged
jsonbailey merged 5 commits into
mainfrom
jb/sdk-2868/async-contract-tests
Aug 12, 2026
Merged

chore: Add async contract-test service for FDv1#481
jsonbailey merged 5 commits into
mainfrom
jb/sdk-2868/async-contract-tests

Conversation

@jsonbailey

@jsonbailey jsonbailey commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the async contract-test service so the SDK contract-test harness can exercise AsyncLDClient. Covers FDv1 (streaming / polling / LDD), hooks, and migration handlers.

What's included

  • contract-tests/async_service.py — async client entity + Flask routes for the contract-test harness (FDv1 config, evaluation, hooks, migrations).
  • contract-tests/hook.py — hook test support shared by the service.

Held back for a later PR (FDv2)

FDv2 support is deferred to PR 11. The dataSystem (FDv2) branch in AsyncClientEntity.start() (which lazily imported datasourcev2.async_polling / async_streaming) is not included here — it now raises NotImplementedError("FDv2 (dataSystem) is not yet supported in the async contract-test service"). The FDv1 streaming / polling / LDD paths, hooks, and migration handlers are unchanged.

Verification

  • async_service.py and hook.py import cleanly (no reference to any held-back datasourcev2.async_* module).
  • pycodestyle and isort --check --atomic clean on both files (the repo's mypy lint target runs on ldclient only, not contract-tests).

Note

Overview
Adds a parallel async contract-test harness so the shared SDK contract suite can drive AsyncLDClient instead of the sync client. async_service.py exposes the same HTTP surface (status capabilities, create client, per-client commands, teardown) via aiohttp, backed by AsyncClientEntity.

AsyncClientEntity maps harness configuration to AsyncConfig for FDv1 paths: streaming, polling, LDD, events, big segments, and evaluation hooks registered with add_hook() before start(). dataSystem (FDv2) is explicitly rejected with NotImplementedError until a follow-up PR. Command handlers cover evaluation, all-flags state, events, contexts, big-segment status, migrations (AsyncMigratorBuilder with asyncio.to_thread for callback HTTP), and flag / flag-value change listeners.

Supporting pieces: AsyncBigSegmentStoreFixture (async HTTP callbacks to the harness), AsyncListenerRegistry (bridges sync tracker callbacks to async HTTP posts), and AsyncPostingHook in hook.py (async hook stages with asyncio.to_thread for requests.post).

The sync client_entity.py migration callback is updated from Result.error to Result.fail to match the Result API used by migrators.

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

@jsonbailey
jsonbailey requested a review from a team as a code owner August 5, 2026 22:26
Comment thread contract-tests/async_service.py Outdated
Comment thread contract-tests/async_service.py Outdated
@jsonbailey jsonbailey changed the title feat: Add async contract-test service for FDv1 chore: Add async contract-test service for FDv1 Aug 5, 2026
@jsonbailey
jsonbailey marked this pull request as draft August 5, 2026 23:08
@jsonbailey
jsonbailey force-pushed the jb/sdk-2867/async-client branch from 491115e to bcd5bdd Compare August 11, 2026 19:17
Base automatically changed from jb/sdk-2867/async-client to main August 12, 2026 18:08
Drop capabilities the FDv1-only async service cannot satisfy: the
persistent-data-store-* entries (no async persistent feature store
exists; the sync store cannot be awaited), fdv1-fallback (an FDv2
dataSystem feature that raises NotImplementedError), and the
unrecognized 'async' entry. Remove the now-dead persistentDataStore
handling and the _create_persistent_store helper, plus the unused
_set_optional_time / _set_optional_value helpers and Callable import.

Also close a partially-started client before returning 500 so it does
not leak tasks or sessions, and align the migrator build-failure shape
with the sync service (return 200 with the error string instead of
raising).
@jsonbailey
jsonbailey force-pushed the jb/sdk-2868/async-contract-tests branch from 7709980 to 9f0466a Compare August 12, 2026 18:13
@jsonbailey
jsonbailey marked this pull request as ready for review August 12, 2026 19:54

@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.

Cursor Bugbot has reviewed your changes using default effort 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 40b5a79. Configure here.

Comment thread contract-tests/async_client_entity.py Outdated
@jsonbailey
jsonbailey merged commit bd7be90 into main Aug 12, 2026
24 of 25 checks passed
@jsonbailey
jsonbailey deleted the jb/sdk-2868/async-contract-tests branch August 12, 2026 21:15
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