
    !<i                     r   U d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZmZm	Z	 d dl
mZmZmZmZmZmZmZmZmZmZmZ d dlZd dlZd dlmZmZ d dlmZ ddlmZ ddlm Z m!Z!m"Z" erdd	l#m$Z$m%Z%  ej&        e'          Z(ej)        e*d
<   edee         f         Z+e,e-e-f         Z. G d de          Z/i Z0e,edef         ej1        f         e*d<   dedef         dej1        fdZ2 G d dej3                  Z4 G d de          Z5 G d de          Z6 G d d          Z7 G d d          Z8dej1        de9fdZ: G d de9ej3                  Z;ed          Z< G d! d"e j=                  Z> G d# d$e>          Z? G d% d&e>          Z@eAe;ef         ZBe,e9eCeB         f         ZDe,e9eDf         ZE G d' d(          ZFdS ))    N)datetime	timedeltatimezone)TYPE_CHECKINGAnyAsyncGenerator	AwaitableCallableHashableLiteralMappingProtocol	TypedDictcast)	propagatetrace)Self   )Logged)
CACHE_SIZEmessage_gettermessage_setter)DocketRedisMessageIDlogger.c                   F    e Zd Zdee         deeez  ez           defdZdS )_schedule_taskkeysargsreturnc                 
   K   d S N )selfr   r   s      /Users/kimhansen/Desktop/03 Workspace/ceo-agents/chl-effectiveness/mcp-servers/whoop/.venv/lib/python3.11/site-packages/docket/execution.py__call__z_schedule_task.__call__)   s      c    N)__name__
__module____qualname__liststrfloatbytesr&   r#   r'   r%   r   r   (   sR        I%)#+*=%>	     r'   r   _signature_cachefunctionr    c                    | t           v r6t          j        t          t                     ddi           t           |          S t	          | dd           }t          |t          j                  r5|t           | <   t          j        t          t                     ddi           |S t          j        |           }|t           | <   t          j        t          t                     ddi           |S )Ncache	signature__signature__)	r/   r   setlengetattr
isinstanceinspect	Signaturer3   )r0   signature_attrr3   s      r%   get_signaturer<   1   s    ###s+,,w.DEEE))X==N.'"344 %3"s+,,w.DEEE!(++I!*XN3'((7K*@AAAr'   c                   4    e Zd ZdZdZ	 dZ	 dZ	 dZ	 dZ	 dZ	dS )	ExecutionStatez$Lifecycle states for task execution.	scheduledqueuedrunning	completedfailed	cancelledN)
r(   r)   r*   __doc__	SCHEDULEDQUEUEDRUNNING	COMPLETEDFAILED	CANCELLEDr#   r'   r%   r>   r>   B   sC        ..ILFSG7I/F I::r'   r>   c                   j    e Zd ZU ed         ed<   eed<   edz  ed<   eed<   edz  ed<   edz  ed<   dS )	ProgressEventprogresstypekeyNcurrenttotalmessage
updated_at)r(   r)   r*   r   __annotations__r,   intr#   r'   r%   rM   rM   X   se         
*
	HHH4ZJJJ4Zd
r'   rM   c                       e Zd ZU ed         ed<   eed<   eed<   eed<   edz  ed<   edz  ed<   edz  ed<   edz  ed	<   dS )

StateEventstaterO   rP   whenNworker
started_atcompleted_aterror)r(   r)   r*   r   rU   r,   r>   r#   r'   r%   rX   rX   a   s         
'
	HHH
III$Jd
*:r'   rX   c                       e Zd ZdZdddeddfdZedddedefd            Zd	e	ddfd
Z
dde	ddfdZdedz  ddfdZddZddZdeeef         ddfdZdeedf         fdZdS )ExecutionProgressa  Manages user-reported progress for a task execution.

    Progress data is stored in Redis hash {docket}:progress:{key} and includes:
    - current: Current progress value (integer)
    - total: Total/target value (integer)
    - message: User-provided status message (string)
    - updated_at: Timestamp of last update (ISO 8601 string)

    This data is ephemeral and deleted when the task completes.
    docketr   rP   r    Nc                 |    || _         || _        |j         d| | _        d| _        d| _        d| _        d| _        dS )zInitialize progress tracker for a specific task.

        Args:
            docket: The docket instance
            key: The task execution key
        
:progress:Nr   )ra   rP   name
_redis_keyrQ   rR   rS   rT   )r$   ra   rP   s      r%   __init__zExecutionProgress.__init__x   sI     #[99C99#'
#'+/r'   c                 V   K    | ||          }|                                  d{V  |S )a  Create and initialize progress tracker by reading from Redis.

        Args:
            docket: The docket instance
            key: The task execution key

        Returns:
            ExecutionProgress instance with attributes populated from Redis
        N)sync)clsra   rP   instances       r%   createzExecutionProgress.create   s>       3vs##mmoor'   rR   c                   K   |dk     rt          d          t          j        t          j                  }|                                }| j                                        4 d{V }|                    | j	        t          |          |d           d{V  ddd          d{V  n# 1 d{V swxY w Y   || _        || _        |                     ||d           d{V  dS )zSet the total/target value for progress tracking.

        Args:
            total: The total number of units to complete. Must be at least 1.
        r   zTotal must be at least 1N)rR   rT   mapping)
ValueErrorr   nowr   utc	isoformatra   redishsetre   r,   rR   rT   _publish)r$   rR   updated_at_dtrT   rs   s        r%   	set_totalzExecutionProgress.set_total   s      1997888 X\22",,..
;$$&& 	 	 	 	 	 	 	%** ZZ",           	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 
'mme:FFGGGGGGGGGGGs   )3B..
B8;B8r   amountc                   K   |dk     rt          d          t          j        t          j                  }|                                }| j                                        4 d{V }|                    | j	        d|           d{V }|
                    | j	        d|           d{V  ddd          d{V  n# 1 d{V swxY w Y   || _        || _        |                     ||d           d{V  dS )zAtomically increment the current progress value.

        Args:
            amount: Amount to increment by. Must be at least 1.
        r   zAmount must be at least 1NrQ   rT   )rQ   rT   )ro   r   rp   r   rq   rr   ra   rs   hincrbyre   rt   rQ   rT   ru   )r$   rx   rv   rT   rs   new_currents         r%   	incrementzExecutionProgress.increment   s      A::8999 X\22",,..
;$$&& 	 	 	 	 	 	 	% %doy& Q QQQQQQQK**        	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 #'mm:NNOOOOOOOOOOOs   )AC  
C
C
rS   c                   K   t          j        t          j                  }|                                }| j                                        4 d{V }|                    | j        ||d           d{V  ddd          d{V  n# 1 d{V swxY w Y   || _	        || _
        |                     ||d           d{V  dS )z{Update the progress status message.

        Args:
            message: Status message describing current progress
        N)rS   rT   rm   )r   rp   r   rq   rr   ra   rs   rt   re   rS   rT   ru   )r$   rS   rv   rT   rs   s        r%   set_messagezExecutionProgress.set_message   sz      !X\22",,..
;$$&& 	 	 	 	 	 	 	%**&",           	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 'mmzJJKKKKKKKKKKKs   &B
BBc                 j  K   | j                                         4 d{V }|                    | j                   d{V }|rt	          |                    dd                    | _        t	          |                    dd                    | _        d|v r|d                                         nd| _	        d|v r,t          j        |d                                                   nd| _        nd| _        d| _        d| _	        d| _        	 ddd          d{V  dS # 1 d{V swxY w Y   dS )	zSynchronize instance attributes with current progress data from Redis.

        Updates self.current, self.total, self.message, and self.updated_at
        with values from Redis. Sets attributes to None if no data exists.
        Ns   current   0s   totals   100s   messages
   updated_atd   )ra   rs   hgetallre   rV   getrQ   rR   decoderS   r   fromisoformatrT   )r$   rs   datas      r%   rh   zExecutionProgress.sync   s      ;$$&& 	' 	' 	' 	' 	' 	' 	'%t77777777D '"488J#=#=>> (F!;!;<<
<F$<N<NtJ/66888TX %,, *4+>+E+E+G+GHHH   $ 
#"&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	's   C,D""
D,/D,c                   K   | j                                         4 d{V }|                    | j                   d{V  ddd          d{V  n# 1 d{V swxY w Y   d| _        d| _        d| _        d| _        dS )zgDelete the progress data from Redis.

        Called internally when task execution completes.
        Nr   )ra   rs   deletere   rQ   rR   rS   rT   )r$   rs   s     r%   r   zExecutionProgress.delete   s     
 ;$$&& 	0 	0 	0 	0 	0 	0 	0%,,t/////////	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 
s   !A
A"Ar   c           	        K   | j         j         d| j         }| j                                         4 d{V }d| j        | j        | j        nd| j        | j        |                    d          d}|                    |t          j
        |                     d{V  ddd          d{V  dS # 1 d{V swxY w Y   dS )zPublish progress update to Redis pub/sub channel.

        Args:
            data: Progress data to publish (partial update)
        rc   NrN   r   rT   rO   rP   rQ   rR   rS   rT   )ra   rd   rP   rs   rQ   rR   rS   r   publishjsondumpsr$   r   channelrs   payloads        r%   ru   zExecutionProgress._publish  sb      [%;;;;;$$&& 	> 	> 	> 	> 	> 	> 	>% #x+/<+C4<<<"hh|44& &G --G)<)<=========	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s   A(B33
B= B=c                z  K   | j         j         d| j         }| j                                         4 d{V }|                                4 d{V }|                    |           d{V  	 |                                2 3 d{V }|d         dk    rt          j        |d                   W V  16 	 |	                    |           d{V  n # |	                    |           d{V  w xY w	 ddd          d{V  n# 1 d{V swxY w Y   ddd          d{V  dS # 1 d{V swxY w Y   dS )a~  Subscribe to progress updates for this task.

        Yields:
            Dict containing progress update events with fields:
            - type: "progress"
            - key: task key
            - current: current progress value
            - total: total/target value (or None)
            - message: status message (or None)
            - updated_at: ISO 8601 timestamp
        rc   NrO   rS   r   )
ra   rd   rP   rs   pubsub	subscribelistenr   loadsunsubscribe)r$   r   rs   r   rS   s        r%   r   zExecutionProgress.subscribe  s      [%;;;;;$$&& 		6 		6 		6 		6 		6 		6 		6%||~~ 6 6 6 6 6 6 6&&w/////////6)/ > > > > > > >g"6?i77"&*WV_"="===== *9
 !,,W5555555555&,,W555555555556 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6 		6sY   D*D0CB5
,C7DC00D4D*
D	D*D	D**
D47D4)r   r    N)r(   r)   r*   rE   r,   rf   classmethodr   rk   rV   rw   r|   r~   rh   r   dictr   ru   r   rM   r   r#   r'   r%   r`   r`   l   su       	 	0x 0c 0d 0 0 0 0 (      [HS HT H H H H2P Pc P$ P P P P0Lt L L L L L,' ' ' '.   >4S> >d > > > >,6t0C!D 6 6 6 6 6 6r'   r`   c                      e Zd ZdZ	 	 d3dddedeedf         d	eeef         d
ede	de
dej        j        dz  deddfdZed4d            Zedefd            Zedeedf         fd            Zedeeef         fd            Zedefd            Zedej        j        dz  fd            Zedefd            ZdefdZe	 d5dddededefd            Zdeeef         fdZdeeee
z  f         fdZdedefdZ defdZ!de"e#j$                 fd Z%	 d6d!ed"d#ddfd$Z&d%eddfd&Z'd7d'edz  ddfd(Z(	 d8d)edz  d'edz  ddfd*Z)ddd+d,e*dz  d-e	dz  defd.Z+d9d/Z,d0eddfd1Z-de.e/e0z  df         fd2Z1dS ):	ExecutionzRepresents a task execution with state management and progress tracking.

    Combines task invocation metadata (function, args, when, etc.) with
    Redis-backed lifecycle state tracking and user-reported progress.
    NFra   r   r0   r   .kwargsrP   rZ   attempttrace_contextredeliveredr    c
                 8   || _         || _        || _        || _        || _        || _        || _        || _        |	| _        t          j
        | _        d | _        d | _        d | _        d | _        d | _        t#          ||          | _        |j         d| | _        d S )Nz:runs:)_docket	_function_args_kwargs_keyrZ   r   _trace_context_redeliveredr>   rF   rY   r[   r\   r]   r^   
result_keyr`   rN   rd   re   )
r$   ra   r0   r   r   rP   rZ   r   r   r   s
             r%   rf   zExecution.__init__7  s     !
	 	+' &4%=
"&+/-1!%
&* ,=VS+I+I $[5555r'   c                     | j         S )zParent docket instance.)r   r$   s    r%   ra   zExecution.docket_       |r'   c                     | j         S )zTask function to execute.)r   r   s    r%   r0   zExecution.functiond  s     ~r'   c                     | j         S )z"Positional arguments for the task.)r   r   s    r%   r   zExecution.argsi  s     zr'   c                     | j         S )zKeyword arguments for the task.)r   r   s    r%   r   zExecution.kwargsn  r   r'   c                     | j         S )zUnique task identifier.)r   r   s    r%   rP   zExecution.keys  s     yr'   c                     | j         S )zOpenTelemetry trace context.)r   r   s    r%   r   zExecution.trace_contexty  s     ""r'   c                     | j         S )z%Whether this message was redelivered.)r   r   s    r%   r   zExecution.redelivered~  s       r'   c                 p   | j                                         | j                                                                        | j        j                                        t          j        | j                  t          j        | j	                  t          | j                                                  dS )N)   key   when   function   args   kwargs   attempt)rP   encoderZ   rr   r0   r(   cloudpickler   r   r   r,   r   r   s    r%   
as_messagezExecution.as_message  s    HOO%%Y((**1133/6688 &ty11"(55DL))0022
 
 	
r'   rS   c                 X  K   |d                                          }|j                            |          x}st          d|d           | ||t	          j        |d                   t	          j        |d                   |d                                          t          j        |d                                                    t          |d                                                    t          j
        |t          	          |
	  	        }|                                 d {V  |S )Nr   zTask function z* is not registered with the current docketr   r   r   r   r   )getter)	ra   r0   r   r   rP   rZ   r   r   r   )r   tasksr   ro   r   r   r   r   rV   r   extractr   rh   )ri   ra   rS   r   function_namer0   rj   s          r%   from_messagezExecution.from_message  s*       ,3355"L,,];;; 	\\\\   3"77#344$WY%788&&(('(8(?(?(A(ABB
+224455#+GNKKK#

 

 

 mmoor'   c                     d| j         j        iS )Ndocket.task)r0   r(   r   s    r%   general_labelszExecution.general_labels  s    t}566r'   c                 f    | j         j        | j        | j                                        | j        dS )N)r   z
docket.keyzdocket.whenzdocket.attempt)r0   r(   rP   rZ   rr   r   r   s    r%   specific_labelszExecution.specific_labels  s4    =1(9..00"l	
 
 	
r'   	parameterc                 r    t          | j                  } |j        | j        i | j        }|j        |         S r"   )r<   r0   bindr   r   	arguments)r$   r   r3   
bound_argss       r%   get_argumentzExecution.get_argument  s9    !$-00	#Y^TY>$+>>
#I..r'   c                    g }| j         j        }t          | j                   }t          j        |          }t          |j                                                  }t          | j	        d t          |                             D ]b\  }}||         }|                    |          x}	r)|                    |	                    |                     M|                    d           c| j                                        D ]b\  }}|                    |          x}	r.|                    | d|	                    |                      J|                    | d           c| dd                    |           d| j         dS )N...=z=...(, z){})r0   r(   r<   r   annotated_parametersr+   
parametersr   	enumerater   r6   r   appendformatr   itemsjoinrP   )
r$   r   r   r3   logged_parametersparameter_namesiargumentparameter_nameloggeds
             r%   	call_reprzExecution.call_repr  s   !	.!$-00	"7	BBy388::;;$TY/E_1E1E/E%FGG 	( 	(KAx,Q/N*..~>>>v (  x!8!89999  ''''(,(9(9(;(; 	: 	:$NH*..~>>>v :  N!N!NV]]85L5L!N!NOOOO  N!8!8!89999GG$))I"6"6GG48GGGGr'   c                     t          j        | j                  }|                                }|j        rt          j        |          gng S r"   )r   get_current_spanr   get_span_contextis_validLink)r$   initiating_spaninitiating_contexts      r%   incoming_span_linkszExecution.incoming_span_links  sI    01CDD,==??3E3NV
-..//TVVr'   replacereschedule_messagezRedisMessageID | Nonec                   K   |                                  }t          j        |t                     | j        }| j        }| j                            |          }|t          j	        t          j                  k    }| j                                        4 d{V }|                    | dd          4 d{V  t          t          |                    d                    }	 |	| j        j        || j                            |          | j        j        | j                            |          | j        | j        j        g|t/          |                                          |rdnd|rdnd|pd	gd
 |                                D                        d{V  ddd          d{V  n# 1 d{V swxY w Y   ddd          d{V  n# 1 d{V swxY w Y   |rRt4          j        | _        |                     t4          j        j        |                                d           d{V  dS |rRt4          j         | _        |                     t4          j         j        |                                d           d{V  dS t4          j        | _        |                     t4          j        j        |                                d           d{V  dS )a\  Schedule this task atomically in Redis.

        This performs an atomic operation that:
        - Adds the task to the stream (immediate) or queue (future)
        - Writes the execution state record
        - Tracks metadata for later cancellation

        Usage patterns:
        - Normal add: schedule(replace=False)
        - Replace existing: schedule(replace=True)
        - Reschedule from stream: schedule(reschedule_message=message_id)
          This atomically acknowledges and deletes the stream message, then
          reschedules the task to the queue. Prevents both task loss and
          duplicate execution when rescheduling tasks (e.g., due to concurrency limits).

        Args:
            replace: If True, replaces any existing task with the same key.
                    If False, raises an error if the task already exists.
            reschedule_message: If provided, atomically acknowledges and deletes
                    this stream message ID before rescheduling the task to the queue.
                    Used when a task needs to be rescheduled from an active stream message.
        )setterNz:lock
   timeouta|  
                            local stream_key = KEYS[1]
                            -- TODO: Remove in next breaking release (v0.14.0) - legacy key locations
                            local known_key = KEYS[2]
                            local parked_key = KEYS[3]
                            local queue_key = KEYS[4]
                            local stream_id_key = KEYS[5]
                            local runs_key = KEYS[6]
                            local worker_group_name = KEYS[7]

                            local task_key = ARGV[1]
                            local when_timestamp = ARGV[2]
                            local is_immediate = ARGV[3] == '1'
                            local replace = ARGV[4] == '1'
                            local reschedule_message_id = ARGV[5]

                            -- Extract message fields from ARGV[6] onwards
                            local message = {}
                            local function_name = nil
                            local args_data = nil
                            local kwargs_data = nil

                            for i = 6, #ARGV, 2 do
                                local field_name = ARGV[i]
                                local field_value = ARGV[i + 1]
                                message[#message + 1] = field_name
                                message[#message + 1] = field_value

                                -- Extract task data fields for runs hash
                                if field_name == 'function' then
                                    function_name = field_value
                                elseif field_name == 'args' then
                                    args_data = field_value
                                elseif field_name == 'kwargs' then
                                    kwargs_data = field_value
                                end
                            end

                            -- Handle rescheduling from stream: atomically ACK message and reschedule to queue
                            -- This prevents both task loss (ACK before reschedule) and duplicate execution
                            -- (reschedule before ACK with slow reschedule causing redelivery)
                            if reschedule_message_id ~= '' then
                                -- Acknowledge and delete the message from the stream
                                redis.call('XACK', stream_key, worker_group_name, reschedule_message_id)
                                redis.call('XDEL', stream_key, reschedule_message_id)

                                -- Park task data for future execution
                                redis.call('HSET', parked_key, unpack(message))

                                -- Add to sorted set queue
                                redis.call('ZADD', queue_key, when_timestamp, task_key)

                                -- Update state in runs hash (clear stream_id since task is no longer in stream)
                                redis.call('HSET', runs_key,
                                    'state', 'scheduled',
                                    'when', when_timestamp,
                                    'function', function_name,
                                    'args', args_data,
                                    'kwargs', kwargs_data
                                )
                                redis.call('HDEL', runs_key, 'stream_id')

                                return 'OK'
                            end

                            -- Handle replacement: cancel existing task if needed
                            if replace then
                                -- Get stream ID from runs hash (check new location first)
                                local existing_message_id = redis.call('HGET', runs_key, 'stream_id')

                                -- TODO: Remove in next breaking release (v0.14.0) - check legacy location
                                if not existing_message_id then
                                    existing_message_id = redis.call('GET', stream_id_key)
                                end

                                if existing_message_id then
                                    redis.call('XDEL', stream_key, existing_message_id)
                                end

                                redis.call('ZREM', queue_key, task_key)
                                redis.call('DEL', parked_key)

                                -- TODO: Remove in next breaking release (v0.14.0) - clean up legacy keys
                                redis.call('DEL', known_key, stream_id_key)

                                -- Note: runs_key is updated below, not deleted
                            else
                                -- Check if task already exists (check new location first, then legacy)
                                local known_exists = redis.call('HEXISTS', runs_key, 'known') == 1
                                if not known_exists then
                                    -- Check if task is currently running (known field deleted at claim time)
                                    local state = redis.call('HGET', runs_key, 'state')
                                    if state == 'running' then
                                        return 'EXISTS'
                                    end
                                    -- TODO: Remove in next breaking release (v0.14.0) - check legacy location
                                    known_exists = redis.call('EXISTS', known_key) == 1
                                end
                                if known_exists then
                                    return 'EXISTS'
                                end
                            end

                            if is_immediate then
                                -- Add to stream for immediate execution
                                local message_id = redis.call('XADD', stream_key, '*', unpack(message))

                                -- Store state and metadata in runs hash
                                redis.call('HSET', runs_key,
                                    'state', 'queued',
                                    'when', when_timestamp,
                                    'known', when_timestamp,
                                    'stream_id', message_id,
                                    'function', function_name,
                                    'args', args_data,
                                    'kwargs', kwargs_data
                                )
                            else
                                -- Park task data for future execution
                                redis.call('HSET', parked_key, unpack(message))

                                -- Add to sorted set queue
                                redis.call('ZADD', queue_key, when_timestamp, task_key)

                                -- Store state and metadata in runs hash
                                redis.call('HSET', runs_key,
                                    'state', 'scheduled',
                                    'when', when_timestamp,
                                    'known', when_timestamp,
                                    'function', function_name,
                                    'args', args_data,
                                    'kwargs', kwargs_data
                                )
                            end

                            return 'OK'
                            10r'   c                 &    g | ]\  }}||fD ]}|S r#   r#   ).0fieldvalueitems       r%   
<listcomp>z&Execution.schedule.<locals>.<listcomp>  sG        ,u).  !% !   r'   r   r   )rY   rZ   )!r   r   injectr   rP   rZ   ra   known_task_keyr   rp   r   rq   rs   lockr   r   register_script
stream_keyparked_task_key	queue_keystream_id_keyre   worker_group_namer,   	timestampr   r>   rF   rY   _publish_stater   rr   rG   )
r$   r   r   rS   rP   rZ   r   is_immediaters   schedule_scripts
             r%   schedulezExecution.schedule  s     2 '+oo&7&78888hy33C88x|HL999;$$&& k	 k	 k	 k	 k	 k	 k	%zz^":":":BzGG i i i i i i i i"&"))H L LO# O#b &o.&33C88-11#665 DNN,,--+4&/C*1c 07           gi i i i i i i i i i i i i i i i i i i i i i i i i i ik	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	 k	\  	'1DJ%%(28$..BRBRSS            		'.DJ%%(/5t~~?O?OPP           (1DJ%%(28$..BRBRSS          s7   !G<C"F0G0
F:	:G=F:	>G
G Gr[   c           	        K   t          j        t          j                  }|                                }| j                                        4 d{V }|                    d          } || j        | j	        j        | j        j
         d| j         | j        j
         d| j         g||g           d{V  ddd          d{V  n# 1 d{V swxY w Y   t          j        | _        || _        || _        d| j	        _        d| j	        _        |                     t          j        j        ||d           d{V  dS )	a  Atomically claim task and transition to RUNNING state.

        This consolidates worker operations when claiming a task into a single
        atomic Lua script that:
        - Sets state to RUNNING with worker name and timestamp
        - Initializes progress tracking (current=0, total=100)
        - Deletes known/stream_id fields to allow task rescheduling
        - Cleans up legacy keys for backwards compatibility

        Args:
            worker: Name of the worker claiming the task
        NaY  
                local runs_key = KEYS[1]
                local progress_key = KEYS[2]
                -- TODO: Remove in next breaking release (v0.14.0) - legacy key locations
                local known_key = KEYS[3]
                local stream_id_key = KEYS[4]

                local worker = ARGV[1]
                local started_at = ARGV[2]

                -- Update execution state to running
                redis.call('HSET', runs_key,
                    'state', 'running',
                    'worker', worker,
                    'started_at', started_at
                )

                -- Initialize progress tracking
                redis.call('HSET', progress_key,
                    'current', '0',
                    'total', '100'
                )

                -- Delete known/stream_id fields to allow task rescheduling
                redis.call('HDEL', runs_key, 'known', 'stream_id')

                -- TODO: Remove in next breaking release (v0.14.0) - legacy key cleanup
                redis.call('DEL', known_key, stream_id_key)

                return 'OK'
                z:known:z:stream-id:r   r   r   )rY   r[   r\   )r   rp   r   rq   rr   ra   rs   r   re   rN   rd   rP   r>   rH   rY   r[   r\   rQ   rR   r  r   )r$   r[   r\   started_at_isors   claim_scripts         r%   claimzExecution.claim  s      \(,//
#--//;$$&& -	 -	 -	 -	 -	 -	 -	% 00" "LH ,OM,{'::::{'>>DH>>	 n-         K-	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	 -	` $+
$ !! !!'/5 , 
 
 	
 	
 	
 	
 	
 	
 	
 	
 	
s   A&C
CCr   c                 $  K   t          j        t          j                                                  }| j                                        4 d{V }t          j        j	        |d}|||d<   |
                    | j        |           d{V  | j        j        rMt          | j        j                                                  }|                    | j        |           d{V  n |                    | j                   d{V  ddd          d{V  n# 1 d{V swxY w Y   t          j        | _        || _        | j                                         d{V  |                     t          j        j	        |d           d{V  dS )a  Mark task as completed successfully.

        Args:
            result_key: Optional key where the task result is stored

        Sets TTL on state data (from docket.execution_ttl), or deletes state
        immediately if execution_ttl is 0. Also deletes progress data.
        NrY   r]   r   rm   )r   rp   r   rq   rr   ra   rs   r>   rI   r   rt   re   execution_ttlrV   total_secondsexpirer   rY   r   rN   r  )r$   r   r]   rs   rn   ttl_secondss         r%   mark_as_completedzExecution.mark_as_completed   sX       |HL11;;==;$$&& 	4 	4 	4 	4 	4 	4 	4%'17 ,' 'G %(2%**          
 {( 4!$+";"I"I"K"KLLll4?K@@@@@@@@@@ll4?333333333!	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4" $-
$m""$$$$$$$$$!!$.4lSS
 
 	
 	
 	
 	
 	
 	
 	
 	
 	
s   B7D
D%(D%r^   c                 D  K   t          j        t          j                                                  }| j                                        4 d{V }t          j        j	        |d}|r||d<   |||d<   |
                    | j        |           d{V  | j        j        rMt          | j        j                                                  }|                    | j        |           d{V  n |                    | j                   d{V  ddd          d{V  n# 1 d{V swxY w Y   t          j        | _        || _        | j                                         d{V  t          j        j	        |d}|r||d<   |                     |           d{V  dS )aE  Mark task as failed.

        Args:
            error: Optional error message describing the failure
            result_key: Optional key where the exception is stored

        Sets TTL on state data (from docket.execution_ttl), or deletes state
        immediately if execution_ttl is 0. Also deletes progress data.
        Nr  r^   r   rm   )r   rp   r   rq   rr   ra   rs   r>   rJ   r   rt   re   r  rV   r  r  r   rY   r   rN   r  )r$   r^   r   r]   rs   rn   r  
state_datas           r%   mark_as_failedzExecution.mark_as_failed$  sZ       |HL11;;==;$$&& 	4 	4 	4 	4 	4 	4 	4%'.4 , G  )#( %(2%**T_g*>>>>>>>>>{( 4!$+";"I"I"K"KLLll4?K@@@@@@@@@@ll4?333333333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4  $*
$m""$$$$$$$$$ $*0(
 

  	("'Jw!!*-----------s   B>D""
D,/D,)r   deadliner   r  c                   K   ||t          d          |!t          j        t          j                  |z   } j        t          j        t          j        fvrd}|Q|t          j        t          j                  z
  	                                }|dk    rt          d j         d          	  fd}t          j         |            |           d{V  n+# t          j
        $ r t          d j         d          w xY w j        t          j        k    r j        r` j        j                             j                   d{V }|r4d|v r0t%          j        |d                   }t)          j        |          }| j        pd	}t/          |           j        r^ j        j                             j                   d{V }|2d|v r.t%          j        |d                   }	t)          j        |	          S dS )
a'  Retrieve the result of this task execution.

        If the execution is not yet complete, this method will wait using
        pub/sub for state updates until completion.

        Args:
            timeout: Optional duration to wait before giving up.
                    If None and deadline is None, waits indefinitely.
            deadline: Optional absolute datetime when to stop waiting.
                     If None and timeout is None, waits indefinitely.

        Returns:
            The result of the task execution, or None if the task returned None.

        Raises:
            ValueError: If both timeout and deadline are provided
            Exception: If the task failed, raises the stored exception
            TimeoutError: If timeout/deadline is reached before execution completes
        Nz(Cannot specify both timeout and deadliner   zTimeout waiting for execution z to completec                     K                                    2 3 d {V } | d         dk    rLt          | d                   }|t          j        t          j        fv r                                 d {V   d S `6 d S )NrO   rY   )r   r>   rI   rJ   rh   )eventrY   r$   s     r%   wait_for_completionz1Execution.get_result.<locals>.wait_for_completion~  s      '+~~'7'7 	& 	& 	& 	& 	& 	& 	&e =G33$25>$B$BE$ . 8 . 5)    
 '+iikk 1 1 1 1 1 1 1 % (8'7'7s   A8r   r   zTask execution failed)ro   r   rp   r   rq   rY   r>   rI   rJ   r  TimeoutErrorrP   asynciowait_forr   ra   result_storager   base64	b64decoder   r   r^   	Exception)
r$   r   r  timeout_secondsr  result_datapickled_exception	exception	error_msgpickled_results
   `         r%   
get_resultzExecution.get_resultN  sb     4 8#7GHHH |HL11G;H :n68MNNN"O#x|HL999-//   #a''&OOOO  
& 
& 
& 
& 
& &':':'<'<oVVVVVVVVVVV'   "KTXKKK   :... $$(K$>$B$B4?$S$SSSSSSS $6[#8#8(.(8V9L(M(M% + 12C D DI#O
=&=II&&& ? 	9 $ : > >t O OOOOOOOK&6[+@+@!'!1+f2E!F!F"(888 ts   /)C (Dc                   K   | j                                         4 d{V }|                    | j                   d{V }|r2|                    d          }|r=t          |t                    r|                                }t          |          | _	        d|v r|d                                         nd| _
        d|v r,t          j        |d                                                   nd| _        d|v r,t          j        |d                                                   nd| _        d|v r|d                                         nd| _        d|v r|d                                         nd| _        n4t          j        | _	        d| _
        d| _        d| _        d| _        d| _        	 ddd          d{V  n# 1 d{V swxY w Y   | j                                         d{V  dS )zSynchronize instance attributes with current execution data from Redis.

        Updates self.state, execution metadata, and progress data from Redis.
        Sets attributes to None if no data exists.
        Ns   states   workers
   started_ats   completed_ats   errors
   result_key)ra   rs   r   re   r   r8   r.   r   r>   rY   r[   r   r   r\   r]   r^   r   rF   rN   rh   )r$   rs   r   state_values       r%   rh   zExecution.sync  s      ;$$&& !	' !	' !	' !	' !	' !	' !	'%t77777777D '"hhx00 =!+u55 ;&1&8&8&:&:!/!<!<DJ ;Dt:K:Kd9o44666QU %,, *4+>+E+E+G+GHHH  '$.. *4+@+G+G+I+IJJJ !
 9AD8H8HT(^22444d
4AT4I4ID'..000t 
 ,5
""&$(!!
"&&C!	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	' !	'H m  """""""""""s   F
F??
G	G	r   c                 2  K   | j         j         d| j         }| j                                         4 d{V }d| j        d|}|                    |t          j        |                     d{V  ddd          d{V  dS # 1 d{V swxY w Y   dS )znPublish state change to Redis pub/sub channel.

        Args:
            data: State data to publish
        :state:NrY   )rO   rP   )ra   rd   rP   rs   r   r   r   r   s        r%   r  zExecution._publish_state  sC      [%88dh88;$$&& 	> 	> 	> 	> 	> 	> 	>%  x  G
 --G)<)<=========	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>s   ;B
BBc           	       K   |                                   d{V  d| j        | j        | j                                        | j        | j        r| j                                        nd| j        r| j                                        nd| j        d}|W V  d| j        | j	        j
        | j	        j        | j	        j        | j	        j        r| j	        j                                        ndd}|W V  | j        j         d| j         }| j        j         d| j         }| j                                        4 d{V }|                                4 d{V }|                    ||           d{V  	 |                                2 3 d{V }|d         d	k    rCt)          j        |d
                   }|d         dk    rt-          |d                   |d<   |W V  W6 	 |                    ||           d{V  n!# |                    ||           d{V  w xY w	 ddd          d{V  n# 1 d{V swxY w Y   ddd          d{V  dS # 1 d{V swxY w Y   dS )a  Subscribe to both state and progress updates for this task.

        Emits the current state as the first event, then subscribes to real-time
        state and progress updates via Redis pub/sub.

        Yields:
            Dict containing state or progress update events with a 'type' field:
            - For state events: type="state", state, worker, timestamps, error
            - For progress events: type="progress", current, total, message, updated_at
        NrY   )rO   rP   rY   rZ   r[   r\   r]   r^   rN   r   r+  rc   rO   rS   r   )rh   rP   rY   rZ   rr   r[   r\   r]   r^   rN   rQ   rR   rS   rT   ra   rd   rs   r   r   r   r   r   r>   r   )	r$   initial_stateprogress_eventstate_channelprogress_channelrs   r   rS   message_datas	            r%   r   zExecution.subscribe  s@      iikk 8ZI''))k9=R$/33555d D-77999Z%
 %
  8},](},}'$-2<<>>>	)
 	)
   ;+>>DH>>"k.DD$(DD;$$&& 	N 	N 	N 	N 	N 	N 	N%||~~ N N N N N N N&&}6FGGGGGGGGGN)/ / / / / / / /g"6?i77+/:gfo+F+FL+F3w>>8F$0$99" 9"W 5 #/.... *9 !,,]<LMMMMMMMMMM&,,]<LMMMMMMMMMMMN N N N N N N N N N N N N N N N N N N N N N N N N N N	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	Ns[   >IH57HG"AH$H5HH5#I5
H?	?IH?	I
I#&I#)NF)r    r   )F)FNr"   )NNr   )2r(   r)   r*   rE   TaskFunctiontupler   r   r,   r   rV   opentelemetrycontextContextboolrf   propertyra   r0   r   r   rP   r   r   Messager   r   r   r   r   r   r   r   r   r+   r   r   r   r  r
  r  r  r   r'  rh   r  r   rX   rM   r   r#   r'   r%   r   r   0  s         ?C!%6 %6%6 %6 CHo	%6
 S#X%6 %6 %6 %6 %,4t;%6 %6 
%6 %6 %6 %6P    X ,    X eCHo    X S#X    X S    X
 #}4<tC # # # X# !T ! ! ! X!
G 
 
 
 
 EJ (/>B	   [.7S 1 7 7 7 7
cCi!8 
 
 
 
/c /c / / / /
H3 H H H H.WT%*%5 W W W W TX^ ^^9P^	^ ^ ^ ^@M
# M
$ M
 M
 M
 M
^"
 "
#* "
 "
 "
 "
 "
J BF(. (.4Z(.47$J(.	(. (. (. (.Z %)$(	Z Z Z T!Z T/	Z
 
Z Z Z Zx*# *# *# *#X> >$ > > > >"<N
]0JD0P!Q <N <N <N <N <N <Nr'   r   r3   c                    ddl m} g }d}| j                                        D ]}t	          |j        |          r|dz  }|j        }|j        |j        urN|j        }t          |d          r|j
        d         }t          |dt          |                    }|j         d| }|j        |j        ur| d|j        }|                    |           |dk    r|                    d           d	                    |          S )
Nr   )
Dependencyr   
__origin__r(   z: z = r   r   )dependenciesr;  r   valuesr8   defaultrd   
annotationemptyhasattr__args__r7   r,   r   r   )r3   r;  r   r=  r   parameter_definitionr@  	type_names           r%   compact_signaturerF  &  s:   ((((((JL)0022 0 0	i'44 	AL(~y66"-Jz<00 4'03

JJHHI&/n#C#C	#C#C IO33&:#T#Ty?P#T#T .////a%   99Z   r'   c                   *    e Zd ZdZdZdZdZdZdZdZ	dS )	Operator==!=>>=<<=betweenN)
r(   r)   r*   EQUAL	NOT_EQUALGREATER_THANGREATER_THAN_OR_EQUAL	LESS_THANLESS_THAN_OR_EQUALBETWEENr#   r'   r%   rH  rH  E  s3        EIL IGGGr'   rH  )rI  rJ  rK  rL  rM  rN  rO  c            
           e Zd ZU ed         ed<   eed<   dedz  dedz  dededdf
d	Zde	fd
Z
ede	dd fd            Zdeeef         fdZdefdZdS )StrikeInstructionstrikerestore	directionoperatorr0   Nr   r   r    c                 >    || _         || _        || _        || _        d S r"   )r0   r   r]  r   )r$   r0   r   r]  r   s        r%   rf   zStrikeInstruction.__init__V  s$     !" 


r'   c                 8   d| j                                         i}| j        r| j                                        |d<   | j        r| j                                        |d<   | j                                        |d<   t          j        | j                  |d<   |S )N	   directionr   	   parameter   operator   value)r\  r   r0   r   r]  r   r   r   )r$   rS   s     r%   r   zStrikeInstruction.as_messageb  s    '3T^5J5J5L5L&M= 	:#'=#7#7#9#9GK > 	<$(N$9$9$;$;GL!#}3355'-dj99r'   rS   c                    t          t          d         |d                                                   }d|v r|d                                         nd }d|v r|d                                         nd }t          t          |d                                                   }t	          j        |d                   }|dk    rt          ||||          S t          ||||          S )NrY  r`  r   ra  rb  rc  rZ  )r   r   r   rH  r   r   StrikeRestore)ri   rS   r\  r0   r   r]  r   s          r%   r   zStrikeInstruction.from_messagel  s    !45w|7L7S7S7U7UVV	4?74J4J7;'..000PT6Bg6M6MGL)00222SW	'+"6"="="?"?@@!'("344  (Ix???8Y%@@@r'   c                     i }| j         r
| j         |d<   | j        r+| j        |d<   | j        |d<   t          | j                  |d<   |S )Nr   zdocket.parameterzdocket.operatorzdocket.valuer0   r   r]  reprr   )r$   labelss     r%   rj  zStrikeInstruction.labelsx  sZ    !#= 	2$(MF=!> 	6)-F%&(,F$%%)$*%5%5F>"r'   c           	      z    | j         pd d| j        pd d| j         d| j        rt          | j                  nd dS )N*r    )rh  r   s    r%   r   zStrikeInstruction.call_repr  sj    }#  ~$  }	  $(>:tDJs  		
r'   )r(   r)   r*   r   rU   rH  r,   r   rf   r9  r   r   r   r   rj  r   r#   r'   r%   rX  rX  R  s        *++++
*
 :
 	

 
 

 
 
 
G     	A7 	A/B 	A 	A 	A [	A
S) 
 
 
 


3 

 

 

 

 

 

r'   rX  c                   *    e Zd ZU dZed         ed<   dS )re  rZ  rY  r\  Nr(   r)   r*   r\  r   rU   r#   r'   r%   re  re    s(         .6Iw*+66666r'   re  c                   *    e Zd ZU dZed         ed<   dS )rf  r[  rY  r\  Nrp  r#   r'   r%   rf  rf    s(         .7Iw*+77777r'   rf  c                       e Zd ZU eed<   eed<   eeege	f                  ed<   ddZ
deege	f         ddfdZdeege	f         ddfd	Zd
ede	fdZd
ede	fdZdededede	fdZdeddfdZdeddfdZdeddfdZdS )
StrikeListtask_strikesparameter_strikes_conditionsr    Nc                 <    i | _         i | _        | j        g| _        d S r"   )rt  ru  !_matches_task_or_parameter_strikerv  r   s    r%   rf   zStrikeList.__init__  s&    !# BCr'   	conditionc                 <    | j                             d|           dS )CAdds a temporary condition that indicates an execution is stricken.r   N)rv  insertr$   ry  s     r%   add_conditionzStrikeList.add_condition  s!    9-----r'   c                 P    || j         usJ | j                            |           dS )r{  N)rx  rv  remover}  s     r%   remove_conditionzStrikeList.remove_condition  s3     FFFFF	*****r'   	executionc                 D    t          fd| j        D                       S )z
        Checks if an execution is stricken based on task, parameter, or temporary
        conditions.

        Returns:
            bool: True if the execution is stricken, False otherwise.
        c              3   .   K   | ]} |          V  d S r"   r#   )r   ry  r  s     r%   	<genexpr>z)StrikeList.is_stricken.<locals>.<genexpr>  s-      JJI99Y''JJJJJJr'   )anyrv  )r$   r  s    `r%   is_strickenzStrikeList.is_stricken  s+     JJJJ9IJJJJJJr'   c                    |j         j        }| j                            |i           }|| j        v r|sdS t	          |j                   }	  |j        |j        i |j                                         n# t          $ r Y dS w xY wi j
        fd|j                                        D             }|                                D ]@\  }}|| j        fD ]1}||vr||         D ]!\  }	}
|                     ||	|
          r   dS "2AdS )NTFc                 .    i | ]\  }}|j         v||S r#   )r   )r   kvr   s      r%   
<dictcomp>z@StrikeList._matches_task_or_parameter_strike.<locals>.<dictcomp>  s7       AqJ000 1000r'   )r0   r(   rt  r   r<   r   r   r   apply_defaults	TypeErrorr   r   ru  	_is_match)r$   r  r   rt  r3   all_argumentsr   r   strike_sourcer]  strike_valuer   s              @r%   rx  z,StrikeList._matches_task_or_parameter_strike  s   !*3 (,,]B??D---l-4!)"455		'L9;KLLJ%%'''' 	 	 	55	
"
   %,2244  
 $1#6#6#8#8 	$ 	$Ix".0F!G $ $M11.;I.F $ $*Hl~~h,GG $#tttt$$	$ us   +A7 7
BBr   r]  r  c                 j   	 |xdk    r ||k    S xdk    r ||k    S xdk    r ||k    S xdk    r ||k    S xdk    r ||k     S xdk    r ||k    S dk    r|\  }}||cxk    o|k    nc S 	 t          d|           # t           t          f$ r# t                              d	|||d
           Y dS w xY w)z1Determines if a value matches a strike condition.rI  rJ  rK  rL  rM  rN  rO  zUnknown operator: z0Incompatible type for strike condition: %r %s %rT)exc_infoF)ro   r  r   warning)r$   r   r]  r  loweruppers         r%   r  zStrikeList._is_match  s/   	TTTT L00TTTT L00SSSS <//TTTT L00SSSS <//TTTT L00YY#/LE5 E2222U22222$%D(%D%DEEEI& 
	 
	 
	 NNB     55
	s7   A> A> A> A> A> A> A> +A> >0B21B2instructionc                 P   	 t          |j                   n7# t          $ r* t                              d|j        |j                   Y d S w xY wt          |t                    r|                     |           d S t          |t                    r| 
                    |           d S d S )Nz-Incompatible type for strike condition: %s %r)hashr   r  r   r  r]  r8   re  _strikerf  _restore)r$   r  s     r%   updatezStrikeList.update  s    	"#### 	 	 	NN?$!  
 FF	 k6** 	'LL%%%%%W-- 	'MM+&&&&&	' 	's    0A
ArZ  c                    |j         r|j        r	 | j        |j                  }n!# t          $ r i x}| j        |j         <   Y nw xY w	 ||j                 }n(# t          $ r t	                      x}||j        <   Y nw xY w|                    |j        |j        f           d S |j         r7	 | j        |j                  }d S # t          $ r i x}| j        |j         <   Y d S w xY w|j        rd	 | j        |j                 }n-# t          $ r  t	                      x}| j        |j        <   Y nw xY w|                    |j        |j        f           d S d S r"   )	r0   r   rt  KeyErrorr5   addr]  r   ru  )r$   rZ  rt  ru  s       r%   r  zStrikeList._strike  s   ? 	Cv/ 	CG#0A G G GDFFt0AAAGK$01A$B!! K K KEHUUJ!L1A$B$B$BK !!6?FL"ABBBBB_ 	CG#0A G G GDFFt0AAAAG  	CU$($:6;K$L!! U U UORuuT!D$:6;K$L$L$LU !!6?FL"ABBBBB	C 	CsE   # A AA "A87A8&B: :CC$C7 7'D! D!r[  c                    |j         r|j        r	 | j        |j                  }n# t          $ r Y d S w xY w	 ||j                 }n,# t          $ r |                    |j        d            Y d S w xY w	 |                    |j        |j        f           n# t          $ r Y nw xY w|s?|                    |j        d            |s$| j                            |j         d            d S d S d S |j         rK	 | j        |j                  }n# t          $ r Y d S w xY w|s"| j                            |j         d            d S d S |j        r|	 | j        |j                 }n# t          $ r Y d S w xY w	 |                    |j        |j        f           n# t          $ r Y nw xY w|s$| j                            |j        d            d S d S d S r"   )	r0   r   rt  r  popr  r]  r   ru  )r$   r[  rt  ru  s       r%   r  zStrikeList._restore-  s    ,	D 1 ,	D#01AB   $01B$C!!     !2D999!(('*:GM)JKKKK    % B  !2D999# B%))'*:DAAAAAB BB B  	D#01AB      >!%%g&6=====> >  	D$($:7;L$M!!   !(('*:GM)JKKKK    % D&**7+<dCCCCC	D 	DD Dse   # 
11A %A,+A,0!B 
BB/D 
DDE 
E"!E"&!F 
FFr   )r(   r)   r*   TaskStrikesrU   ParameterStrikesr+   r
   r   r7  rf   r~  r  r  rx  r   rH  r  rX  r  re  r  rf  r  r#   r'   r%   rs  rs    s        ''''h	{D012222D D D D
.xT0A'B .t . . . .+(I;3D*E +$ + + + +
KY K4 K K K K#9 # # # # #Js h c d    B'"3 ' ' ' ' ' Cf C C C C C8-D -DD -D -D -D -D -D -Dr'   rs  )Gabcr  r  enumr9   r   loggingr   r   r   typingr   r   r   r	   r
   r   r   r   r   r   r   r   opentelemetry.contextr4  r   r   typing_extensionsr   annotationsr   instrumentationr   r   r   ra   r   r   	getLoggerr(   r   LoggerrU   r2  r   r.   r9  r   r/   r:   r<   Enumr>   rM   rX   r`   r   r,   rF  rH  LiteralOperatorABCrX  re  rf  r3  MinimalStriker5   r  r  rs  r#   r'   r%   <module>r     s   




       2 2 2 2 2 2 2 2 2 2                                  * * * * * * * * " " " " " "       G G G G G G G G G G /........**844 4 4 4Ys^+,
ue|
    X    AC $xS)7+<<= B B BHS#X. 73D    "; ; ; ; ;TY ; ; ;,    I          A6 A6 A6 A6 A6 A6 A6 A6HsN sN sN sN sN sN sN sNl!!2 !s ! ! ! !>    sDI    EF<
 <
 <
 <
 <
 <
 <
 <
~7 7 7 7 7 7 7 78 8 8 8 8 8 8 8 h()S//0 3(()|D |D |D |D |D |D |D |D |D |Dr'   