ó
    ýÞ jè  ã                  ój   • S r SSKJr  SSKJr  SSKJr  \(       a  SSKJr  SSK	J
r
Jr   " S S5      rg	)
z@Replay state for subgraph checkpoint loading during time-travel.é    )Úannotations)ÚTYPE_CHECKING)ÚNS_END)ÚRunnableConfig)ÚBaseCheckpointSaverÚCheckpointTuplec                  ód   • \ rS rSrSrSrS
S jrSS jr        SS jr        SS jr	Sr
g	)ÚReplayStateé   a¿  Tracks which subgraphs have already loaded their pre-replay checkpoint.

During a parent replay, each subgraph's first invocation should restore the
checkpoint from before the replay point. Subsequent invocations of the same
subgraph (e.g. in a loop) should use normal checkpoint loading so they pick
up freshly created checkpoints.

The single `ReplayState` instance is shared by reference across all derived
configs within one parent execution.
)Úcheckpoint_idÚ_visited_nsc                ó.   • Xl         [        5       U l        g )N)r   Úsetr   )Úselfr   s     ÚU/var/www/html/gaurav/venv/lib/python3.13/site-packages/langgraph/_internal/_replay.pyÚ__init__ÚReplayState.__init__   s   € Ø*Ôô &)£UˆÕó    c                ó¤   • [         U;   a  UR                  [         S5      S   OUnX R                  ;   a  gU R                  R                  U5        g)zêReturn True the first time a subgraph namespace is seen.

The task-id suffix is stripped so that the same logical subgraph
(e.g. ``"sub_node"``) is recognized across loop iterations even
though each iteration has a different task id.
é   r   FT)r   Úrsplitr   Úadd)r   Úcheckpoint_nsÚ	stable_nss      r   Ú_is_first_visitÚReplayState._is_first_visit"   sS   € ô ˜Ó&ð × Ñ ¤¨Ó+¨AÒ.àð 	ð
 ×(Ñ(Ó(ØØ×Ñ×Ñ˜YÔ'Ør   c                ó¢   • U R                  U5      (       a)  UR                  USSU R                  00SS9 H  nUs  $    gUR                  U5      $ )a$  Load the right checkpoint for a subgraph during replay.

On the first call for a given subgraph namespace, returns the latest
checkpoint created *before* the replay point. On subsequent calls
(e.g. the same subgraph in a later loop iteration), falls back to
normal latest-checkpoint loading.
Úconfigurabler   r   ©ÚbeforeÚlimitN)r   Úlistr   Ú	get_tuple©r   r   ÚcheckpointerÚcheckpoint_configÚsaveds        r   Úget_checkpointÚReplayState.get_checkpoint4   sf   € ð ×Ñ ×.Ñ.Ø%×*Ñ*Ø!Ø&¨¸$×:LÑ:LÐ(MÐNØð +ó �ð
 ’ñð Ø×%Ñ%Ð&7Ó8Ð8r   c              ƒ  óÌ   #   • U R                  U5      (       a,  UR                  USSU R                  00SS9  Sh  v•N nUs  $ UR                  U5      I Sh  v•N $  N!
 g N7f)z"Async version of `get_checkpoint`.r   r   r   r   N)r   Úalistr   Ú
aget_tupler$   s        r   Úaget_checkpointÚReplayState.aget_checkpointK   sy   é € ð ×Ñ ×.Ñ.Ø+×1Ñ1Ø!Ø&¨¸$×:LÑ:LÐ(MÐNØð  2ñ  ÷ �eð
 ’à!×,Ñ,Ð->Ó?×?Ð?ñð  ð Ù?ùs2   ‚6A$¸A ¼A½A Á A$ÁA"ÁA$ÁA Á A$)r   r   N)r   ÚstrÚreturnÚNone)r   r/   r0   Úbool)r   r/   r%   r   r&   r   r0   zCheckpointTuple | None)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú	__slots__r   r   r(   r-   Ú__static_attributes__© r   r   r
   r
      ss   † ñ	ð 1€Iô+ôð$9àð9ð *ð9ð *ð	9ð
 
 ô9ð.@àð@ð *ð@ð *ð	@ð
 
 ÷@r   r
   N)r7   Ú
__future__r   Útypingr   Úlanggraph._internal._constantsr   Úlangchain_core.runnablesr   Úlanggraph.checkpoint.baser   r   r
   r:   r   r   Ú<module>r@      s(   ðÙ Få "å  å 1æÝ7ßN÷L@ò L@r   