feat: Add async migration support - #470
Merged
Merged
Conversation
jsonbailey
force-pushed
the
jb/sdk-2767/async-migrations
branch
from
July 27, 2026 22:01
abe7dac to
c735e0e
Compare
Contributor
Author
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit c735e0e. Configure here.
jsonbailey
force-pushed
the
jb/sdk-2767/async-migrations
branch
from
July 29, 2026 19:31
c735e0e to
ec7746a
Compare
…ic base Drop _MigrationConfigBase and give MigrationConfig and AsyncMigrationConfig their own bodies. The shared base saved only a few trivial passthrough properties while adding generic indirection, and full duplication matches how Config/AsyncConfig are handled. MigrationConfig reverts to its pre-async standalone form.
Give MigratorBuilder and AsyncMigratorBuilder their own read_execution_order/ track_latency/track_errors methods instead of sharing a base for three trivial property setters. MigratorBuilder and types.py revert to their pre-async form.
jsonbailey
marked this pull request as ready for review
July 30, 2026 21:59
kinyoklion
reviewed
Jul 31, 2026
kinyoklion
reviewed
Jul 31, 2026
kinyoklion
reviewed
Jul 31, 2026
Move track_migration_op into a finally so a write cancelled mid-operation still emits its migration op event. The CancelledError propagates and no WriteResult is returned, but the event now records which origins were written, so a partial write is reported rather than lost. Reads are left as-is: a cancelled read has no side effect and loses its consistency measurement, so a partial read event carries no useful signal.
On an early cancel (before any origin write completes) OpTracker.build returned "no origins were invoked" and the client logged a spurious error. Guard the write finally with OpTracker.has_invocations so the event is only emitted when at least one origin ran. Drop the now-redundant finally comment.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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 ef02557. Configure here.
Replace the has_invocations guard with a warning logged when a migration write is cancelled before completion, and call track_migration_op unconditionally. A cancelled dual write is a torn write worth surfacing, and the warning is co-located with the client's build error on an early cancel. Revert the now-unused OpTracker.has_invocations accessor.
kinyoklion
approved these changes
Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds the async migration surface for the async Python SDK —
AsyncMigrator,AsyncMigratorBuilder,AsyncMigrationConfig, and theAsyncMigratorFntype — inldclient/migrations/async_migrator.py, eagerly exported fromldclient/migrations/__init__.py(import-cheap: asyncio stdlib only, no aiohttp).Also carries the migration config/builder dedup shared by the sync and async surfaces:
types.pygains_MigrationConfigBase[_MigratorFnT](Generic) and_MigratorBuilderBase(fluent-setter mixin), andmigrator.py'sMigratorBuilderis re-based onto that mixin. These are behavior-preserving refactors of already-released sync code.The public async classes carry experimental
.. caution::blocks.Self-contained: depends only on already-merged foundation work. The
AsyncLDClient/Contextreferences areTYPE_CHECKING-only (annotations kept lazy viafrom __future__ import annotations); no runtime import of any not-yet-merged async module.No CHANGELOG or version changes (handled at release).
Tracked internally: SDK-2767
Note
Medium Risk
New experimental migration execution path affects dual-origin reads/writes and telemetry during flag-driven cutovers; behavior is well-tested but not production-stable per API warnings.
Overview
Adds an experimental async migration API for the async Python SDK, mirroring the sync migrator’s stage-driven read/write behavior with coroutine-based old/new handlers.
New surface in
async_migrator.py:AsyncMigrator/AsyncMigratorImpl,AsyncMigratorBuilder,AsyncMigrationConfig,AsyncMigratorFn, andAsyncExecutor. Reads honorExecutionOrder(parallel, serial, random) viaasyncio.gatherand optional consistency checks; writes run authoritative-first and skip the second origin on authoritative failure.migration_variationis awaited;track_migration_opstays synchronous. Write cancellation logs a warning, still emits migration telemetry infinally, and propagatesCancelledErrorwithout undoing a completed authoritative write.ldclient/migrations/__init__.pyre-exports the new types.test_async_migrator.pyadds broad pytest coverage (builder validation, payloads, tracking, consistency, execution order, cancellation) using aFakeAsyncClient.Reviewed by Cursor Bugbot for commit d35a24c. Bugbot is set up for automated code reviews on this repo. Configure here.