Ë
    áß²jµ  ã                  ód   — d Z ddlmZ ddlZddlmZ  ej                  e«      Zdd„Z	d	d„Z
d
d„Zy)a  Best-effort accessors for the single-writer stream fence.

The fence lives on ``AIAgent`` (``_claim_stream_writer`` / ``_stream_writer_is_current``) but is
used from other streaming modules. Calling it directly would turn an *additive* safety net into a
fatal AttributeError on a partially-updated checkout, hot-reloaded gateway, duck-typed agent, or
test double (a cron job died this way). The fence may only drop a *provably* superseded stream,
never the sole writer, so when it is unavailable or raises the degradation is "no fence".
é    )ÚannotationsN)ÚAnyc                ó(   — t        | dt        dd«      S )zvClaim the delta sink for this stream attempt; ``0`` (never fenced) when the agent lacks the fence or the claim raised.Ú_claim_stream_writerr   z!claim failed; proceeding unfenced)Ú_fence_callÚint)Úagents    ú?/home/ubuntu/.hermes/hermes-agent/agent/stream_single_writer.pyÚclaim_stream_writerr      s   € ä�uÐ4´c¸1Ð>aÓbÐbó    c                ó0   — |syt        | dt        dd|«      S )zwTrue when ``token`` is still the active writer; a falsy token or a fence-less agent cannot prove supersession, so True.TÚ_stream_writer_is_currentz,is_current check failed; treating as current)r   Úbool)r	   Útokens     r
   Ústream_writer_is_currentr      s    € áØÜ�uÐ9¼4ÀÐGuÐw|Ó}Ð}r   c                óž   — t        | |d«      }t        |«      r	  | ||Ž «      S |S # t        $ r t        j	                  d|d¬«       Y |S w xY w)zdCall ``agent.<name>(*args)`` when it exists; ``fallback`` when missing or raising (logged at debug).Nzstream single-writer: %sT)Úexc_info)ÚgetattrÚcallableÚ	ExceptionÚloggerÚdebug)r	   ÚnameÚcastÚfallbackÚfailure_noteÚargsÚfns          r
   r   r      s]   € ä	�˜˜dÓ	#€BÜ�„|ð	RÙ™˜D˜	“?Ð"ð €Oøô ò 	RÜ�L‰LÐ3°\ÈDˆLÕQØ€Oð	Rús   š
' §!AÁA)r	   r   Úreturnr   )r	   r   r   r   r   r   )r	   r   r   Ústrr   r    )Ú__doc__Ú
__future__r   ÚloggingÚtypingr   Ú	getLoggerÚ__name__r   r   r   r   © r   r
   ú<module>r(      s8   ðñõ #ã Ý à	ˆ×	Ñ	˜8Ó	$€ócó
~ôr   