mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-20 22:52:29 +02:00
Restructure DeltaChannel reconstruction so the hydration path matches pregel's storage axes (blobs + writes) without leaking internal DTOs into the public checkpoint contract. Key changes: * Deleted `DeltaChannelWrites` dataclass and `SEED_UNSET` sentinel. Reconstruction data no longer flows through `Checkpoint.channel_values` as a wrapped DTO — that field now carries a value or `DELTA_SENTINEL`, never a reconstruction shape. * Added private `_ChannelWritesHistory(seed: Any, writes: list[PendingWrite])` NamedTuple as the return type for the new storage-level query. * Added private, experimental `_get_channel_writes_history` / `_aget_channel_writes_history` on `BaseCheckpointSaver` — reference impl via `get_tuple` + `parent_config` walk, overridden on `InMemorySaver` / `PostgresSaver` / `AsyncPostgresSaver` for perf. Fixes a latent migration bug in the base fallback (now inspects ancestor `channel_values` for pre-delta seed). * `DeltaChannel.from_checkpoint(seed)` simplified to two cases (sentinel/MISSING → empty, else → seed). New `replay_writes` method folds `list[PendingWrite]` through the reducer. * Delta hydration consolidated inside `channels_from_checkpoint` via optional `saver` + `config` kwargs (+ async mirror `achannels_from_checkpoint`). All six pregel call sites updated. `get_tuple` no longer patches `channel_values` — removed `_resolve_delta_channels` (memory) and per-tuple reconstruction from `_load_checkpoint_tuple` (postgres sync + async). * Hydration short-circuits on the target's own blob: if `channel_values[k]` is a real value (pre-migration tip, `update_state` result), use it directly. Only walks ancestors when the target holds sentinel or is missing. Fixes a correctness bug where migration-tip and `update_state` values would be lost. * New test_delta_channel_migration.py: 10 scenarios covering BinaryOperatorAggregate → DeltaChannel migration (basic + async, time-travel, fork, `update_state`, tip-of-pre-migration, base-saver fallback parity, cross-thread isolation). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>