+
    jHàjŽ8  ã                   óÐ   € R t ^ RIt^ RIHt ^ RIHt ^ RIHtHtH	t	H
t
HtHtHtHtHtHt ]! 0 Rm4      t]! 0 Rm4      tR tR tR tR tR	 tR
 tR tR tR tR tR tR tR t R# )a{  Steer and Edit of a still-queued admission: ``prompt.steer_queued`` / ``prompt.replace_queued``.

Both consume the queued row inside one owner write transaction, so it can never also run as its own
queued turn, and a retry replays the recorded outcome. There is no reorder verb: one FIFO per session.

A steer is a TRANSFER to the running claim, not an outcome: the row goes queued -> terminal
``steering`` bound to the claim's generation, and settles with that claim (``steered`` once the claim
completes with the text delivered, ``interrupted`` otherwise; queued again in its own FIFO place when
the text never reached the claim's agent). The fence is ``authority.steer_transfers``, changed only
under the session's ``event_stream.lock`` (the lock the drain clears ``executing`` under): no storage
write ever waits under that lock, which loop-side receipts, attaches and publication take.
N)Úasdict)Úpartial)
ÚSTEERINGÚRuntimeStoreErrorÚcheck_replaced_inputÚfind_session_admissionÚget_session_admissionÚreplacement_bindingÚretire_replaced_inputÚrevert_steer_inputÚsteer_replayedÚsteer_session_inputc                 óF   € R \        \        V 4      R\        \        V 4      /# )zprompt.steer_queuedzprompt.replace_queued)r   Ústeer_queuedÚreplace_queued)Ú
connections   &ÚD/home/ubuntu/.hermes/hermes-agent/gateway/session_queued_controls.pyÚhandlersr   !   s&   € Ø!¤7¬<¸Ó#DØ#¤W¬^¸ZÓ%HðJð Jó    c                ó$  € V P                   pW9  d^   V P                  P                  4       ;_uu_ 4       pVP                  RV34      P	                  4       pRRR4       Xf   R# V^ ,          W!&   W!,          \
        9   #   + '       g   i     L0; i)a  The session's frozen launch source (a local session's row records it) names a local surface.
Callers hold the stream lock: one plain read per session, cached (``get_session`` flushes token
counts, a write). Under WAL it takes the lock-free reader pool, as ``_pending_rows`` does there.z&SELECT source FROM sessions WHERE id=?NF)Úlaunch_sourcesÚdbÚ	_read_ctxÚexecuteÚfetchoneÚ_INTERACTIVE_SOURCES)Ú	authorityÚ
session_idÚsourcesÚconnÚfounds   &&   r   Ú_interactiver!   &   sw   € ð ×&Ñ&€GØÔ Ø�\‰\×#Ñ#×%Ô%¨Ø—L‘LÐ!IÈJÈ=ÓY×bÑbÓdˆE÷ &àŠ=ÙØ# A�hˆÑØÕÔ"6Ñ6Ð6÷ &×%ús   µ"A?Á?B	c                ó°  € VP                  R4      ;'       g    / pVP                  R4      pVP                  R4      R8w  g�   \        V4      \        ,
          '       gt   \        V\        4      '       d^   VP                  4       '       dH   VP                  R4      ;'       g    / P                  R4      R8X  g   \        WR,          4      '       g   . # R	R
.# )z„The queued-row verbs this owner serves for ``row``: a client shows only these (an older owner
lists none, so its clients show none).ÚpayloadÚtextÚstatusÚqueuedÚ
display_v1ÚkindÚhiddenÚtarget_session_idÚsteerÚreplace)ÚgetÚsetÚ
_TEXT_ONLYÚ
isinstanceÚstrÚstripr!   )r   Úrowr#   r$   s   &&  r   Úqueued_controlsr4   4   s©   € ð �g‰g�iÓ ×&Ð& B€GØ�;‰;�vÓ€DØ�‰�Ó˜XÔ%¬¨W«¼
×)BÔ)BÌ*ÐUYÔ[^×J_ÒJ_Ðgk×gqÑgq×gsÒgsØ—‘˜LÓ)×/Ð/¨R×4Ñ4°VÓ<ÀÔHÜ 	Ð/BÕ+C×DÒDØˆ	Ø�YÐÐr   c                ó’  € V P                  V4       Uu/ uF  q"R,          VbK  	  ppV P                  P                  VP                  4      pVe
   V^,          MR FH  p\	        V P
                  VR7      pVf   K   VR,          R8X  g   K0  VR,          \        8X  g   KD  W#V&   KJ  	  \        VP                  4       R R7      # u upi )	a  The pending rows a viewer is shown, plus each queued admission in transfer to the running
claim: listed ``started`` and ``steering``, because it may still go back to its queue place, and a
client must not retire an admission it no longer sees. The caller holds the stream lock.Úadmission_id©r6   r%   ÚterminalÚoutcomec                 ó   € V R ,          # )Úseq© )r3   s   &r   Ú<lambda>Úpending_rows.<locals>.<lambda>J   s   € °°U¶r   )Úkeyr<   )	Ú_pending_rowsÚsteer_transfersr-   r   r   r   r   ÚsortedÚvalues)r   Úrefr3   ÚrowsÚentryr6   s   &&    r   Úpending_rowsrG   @   s¯   € ð 1:×0GÑ0GÈÔ0LÓMÑ0L¨�Õ Ò$Ñ0L€DÐMØ×%Ñ%×)Ñ)¨#¯.©.Ó9€EØ$)Ò$5˜˜až¸2Ò=ˆÜ# I§L¡L¸|ÔLˆØŒ?˜s 8�}°
Ö:¸sÀ9½~ÔQYÖ?YØ!$�Óñ >ô �$—+‘+“-Ñ%;Ô<Ð<ùò Ns   ”Cc              ƒ   ó°   "  € V P                   P                  V P                  W4      G R j  x€L
 pV\        V P                   P                  VR7      3#  L'5i)Nr7   )r   ÚreceiptÚactorr   r   )r   rD   r6   rI   s   &&& r   Ú_queuedrK   M   sL   é € Ø×(Ñ(×0Ñ0°×1AÑ1AÀ3ÓU×U€GØÔ)¨*×*>Ñ*>×*AÑ*AÐP\Ô]Ð]Ð]ñ Vùs   ‚*A¬A­(Ac                óœ  € V P                   P                  V4      pVe   V^ ,          V8w  d   R# V P                  P                  VR4      w  rEWB8X  d   \        VRR4      MRpV^,          P	                  4        F>  w  rxV'       g   K  \        V4      '       g   K"  V! V4      '       g   K2  RV^,          V&   K@  	  \        V^,          4      # )a  ``{admission_id: delivered}`` handed to this claim; the caller holds the stream lock. Read by
the claim's settlement after its execution returned, when no transfer can still be delivered.
The agent settles each one by its ticket (the admission id), never by its text: one no drain of
the turn consumed (still buffered, or dropped unread) reads undelivered and goes back to its queue.NÚwithdraw_steerF©NN)rA   r-   ÚadoptedÚgetattrÚitemsÚcallableÚdict)	r   r   Ú
generationrF   Úadopted_generationÚagentÚwithdrawr6   Ú	delivereds	   &&&      r   rA   rA   R   s¯   € ð
 ×%Ñ%×)Ñ)¨*Ó5€EØ‚}˜˜a� JÔ.ÙØ )× 1Ñ 1× 5Ñ 5°jÀ,Ó OÑÐØ9KÔ9YŒw�uÐ.°Ô5Ð_c€HØ#(¨¥8§>¡>Ö#3Ñˆß‰9œ (×+Ô+±¸×0FÔ0FØ%*ˆE�!�H�\Ó"ñ $4ô ��a•‹>Ðr   c                ó¶   € V P                   P                  V4      pVe   V^ ,          V8w  d   V/ 3;q@P                   V&   V^,          P                  VR4       R# )z;``{admission_id: delivered}`` for the claim ``generation``.NF)rA   r-   Ú
setdefault©r   r   rT   r6   rF   s   &&&& r   Ú	_registerr\   b   sT   € à×%Ñ%×)Ñ)¨*Ó5€EØ‚}˜˜a� JÔ.Ø9CÀRÐ8HÐHˆ×)Ñ)¨*Ñ5Ø	ˆ!…H×Ñ˜ eÖ,r   c                 ó¸   € V P                   P                  V4      pVe;   V^ ,          V8X  d+   V^,          P                  V4      RJ d   V^,          V R # R # R # R # )NF)rA   r-   r[   s   &&&& r   Ú_unregisterr^   j   sV   € Ø×%Ñ%×)Ñ)¨*Ó5€EØÒ˜U 1�X¨Ô3¸¸a½¿¹À\Ó8RÐV[Ó8[Ø�!�H�\Ò"ñ 9\Ñ3Ñr   c                óÊ   € V P                   P                  VR4      w  r4W28w  g=   V P                  P                  V4      V8w  g   \        \	        VRR4      4      '       g   R# V# )z»The agent the running claim adopted, while that claim still executes. None before adoption (a
latched text would be dropped if construction then failed) and for a turn with no steer seam.Nr+   rN   )rO   r-   Ú	executingrR   rP   )r   r   rT   rU   rV   s   &&&  r   Ú_receiving_agentra   p   s[   € ð !*× 1Ñ 1× 5Ñ 5°jÀ,Ó OÑÐØÔ(¨I×,?Ñ,?×,CÑ,CÀJÓ,OÐS]Ô,]ÜœG E¨7°DÓ9×:Ò:ÙØ€Lr   c                óŽ  € V P                   P                  V4      pVe,   V^ ,          V8w  g   WF^,          9  g   \        WV4      VJd   R# V^,          V,          '       gU   \        \	        VRR4      4      p\        V'       d   VP                  WTR7      MVP                  V4      4      V^,          V&   V^,          V,          # )z»Hand the committed text to the claim's agent; the caller holds the stream lock. False once the
claim stopped executing (its settlement then decides the row) or its agent refused the text.NFrM   )Úticket)rA   r-   ra   rR   rP   Úboolr+   )r   r   rT   rV   r6   r$   rF   Úticketeds   &&&&&&  r   Ú_deliverrf   z   s§   € ð ×%Ñ%×)Ñ)¨*Ó5€EØŠ˜˜q� ZÔ/°<ÈQÅxÔ3OÜ 	°zÓBÈ%ÓOÙØ��8�L×!Ô!äœG EÐ+;¸TÓBÓCˆÜ!%×PX e§k¡k°$ kÔ&LÐ^c×^iÑ^iÐjnÓ^oÓ!pˆˆa��ÑØ��8�LÕ!Ð!r   c              ƒ   óô  "  € V P                   VR ,          rCVP                  V P                  VR4       \        WV4      G Rj  x€L
 w  rV\	        V4      '       d®   VR,          \
        8X  d‘   VP                  VP                  ,          P                  P                  ;_uu_ 4        \        W1P                  VR,          4      pVe.   \        W1P                  VR,          WtVR,          R,          4       RRR4       \        V4      # VP                  R8w  d   \        R4      hR	\        W64      9  d   \        R
4      hVP!                  V4      pVP"                  R8w  d   \        R4      hVP$                  VR,          R,          VP                  VP                  ,          rºp	VP                  pVP                  P                  ;_uu_ 4        \        W<V	4      pVf   \        RR RR7      h\'        W<W”4       RRR4       ^ RIHp  V! V\-        \.        VP0                  VP2                  WIR7      4      G Rj  x€L
 w  rïT'       dè   TP                  P                  ;_uu_ 4        \        Y<T	XYJ4      pRRR4       X'       gš   T! T\-        \6        TP0                  TP2                  YIR7      4      G Rj  x€L
  TP                  P                  ;_uu_ 4        \5        Y<Y”4       RRR4       TP9                  T4       TP;                  T4       \        RR RR7      hTP9                  T4       \        TP=                  T4      4      #  EL  + '       g   i     EL`; i  + '       g   i     ELp; i EL;  \         dI    TP                  P                  ;_uu_ 4        \5        Y<Y”4       RRR4       h   + '       g   i     h ; ii ; i  + '       g   i     ELa; i EL+  + '       g   i     EL; i5i)r6   zsession:controlNr9   rT   r#   r$   r&   Úadmission_startedr+   Úunsupported_controlÚrunningÚsession_idleÚsteer_unavailablez1the running turn has no agent to take a steer yet)ÚfieldÚdetail)Útracked_write)Úepochr6   rT   z2the running turn ended before the steer reached it)r   Ú	authorizerJ   rK   r   r   Úsessionsr   Úevent_streamÚlockra   rf   r   r%   r   r4   Ú_handleÚexecution_stateÚexecution_generationr\   Úgateway.session_runtime_workersro   r   r   r   rp   r^   r   Ú_publish_pendingÚ	_scheduleÚ_receipt)r   rD   Úparamsr   r6   rI   r3   rV   ÚhandlerT   r$   Úliver   ro   Ú	committedÚfreshrX   s   &&&              r   r   r   ˆ   s:  é € Ø(×2Ñ2°F¸>Õ4Jˆ|Ø×Ñ˜
×(Ñ(¨#Ð/@ÔAÜ  °,Ó?×?�L€GÜ�c×ÒØˆy�>œXÔ%à×#Ñ# C§N¡NÕ3×@Ñ@×E×EÓEÜ(¨·N±NÀCÈÕDUÓV�ØÒ$Ü˜Y¯©¸¸LÕ8IÈ5Ð`cÐdmÕ`nÐouÕ`vÔw÷ Fô �g‹ÐØ‡~�~˜Ô!ÜÐ 3Ó4Ð4Ø”o iÓ5Ô5ÜÐ 5Ó6Ð6Ø×Ñ˜sÓ#€FØ×Ñ Ô*Ü Ó/Ð/Ø#×8Ñ8¸#¸i½.ÈÕ:PÐR[×RdÑRdÐeh×esÑesÕRt�d€JØ—‘€JØ	×	Ñ	×	×	Ó	Ü  ¸
ÓCˆØŠ=ä#Ð$7¸~Ø+^ô`ð `ä�)¨ÔB÷ 
 õ >ð	á!.¨y¼'Ü §¡°Y·_±_ÐS_ô;xó "y÷ yÑˆ	÷ Ø×Ñ×#×#Ó#Ü  ¸
ÀEÈ<Ó^ˆI÷ $çá 	¬7Ô3EÀyÇ|Á|Ð[d×[jÑ[jØ@Lô,eó f÷ fð fà×"Ñ"×'×'Ó'Ü˜I°:ÔL÷ (à×&Ñ& sÔ+Ø×Ñ Ô$Ü#Ð$7¸~Ø+_ôað aà×"Ñ" 3Ô'Ü�)×$Ñ$ YÓ/Ó0Ð0òe @÷ F×EÐEú÷ 
 ×	Ð	úòyøäô ð ×Ñ×#×#Ó#Ü˜	¨zÔH÷ $à÷ $Ö#àúðú÷ $×#Ð#úòfç'×'Ð'üsÐ   ‚AO8ÁM	ÁA"O8Â&AMÃ5CO8Ç+M Ç9O8È1M7 È9M4È:M7 É O8ÉO8É&OÉ5O8Ê1O8Ê6O!Ê7"O8ËO$Ë&A$O8ÍM	Í	O8Í M1	Í+	O8Í4M7 Í7)O
Î N6Î-	O
Î6OÏ	O
Ï
O8ÏO	Ï
O8Ï$O5	Ï/	O8c                óŒ  € V P                   P                  VP                  4      pV P                  P                  VP                  4      pVe   Ve   V^ ,          V8w  d   R# VP                  P
                  ;_uu_ 4        V P                  P                  VP                  R4       RRR4       V^,           Fc  p\        V P                  VR7      pVf   K   VR,          R8X  g   K0  VR,          R	9   g   K@  T P                  YVR,          R8X  d   RMRR7       Ke  	  V P                  V4       R#   + '       g   i     L“; i)
z»After the claim's settlement: each admission it carried publishes the outcome it settled to
(``steered``, or ``cancelled`` for an interrupted transfer, as a turn's completion reports it).Nr7   r%   r8   r9   ÚsteeredÚ	cancelled)r9   )r‚   Úinterrupted)rr   r-   r   rA   rs   rt   Úpopr   r   Ú_settle_cancelledry   )r   rD   rT   r~   rF   r6   r3   s   &&&    r   Úpublish_transfersr‡   À   sü   € ð ×Ñ×!Ñ! #§.¡.Ó1€DØ×%Ñ%×)Ñ)¨#¯.©.Ó9€EØ‚|�u’}¨¨a­°JÔ(>ÙØ	×	Ñ	×	×	Ó	Ø×!Ñ!×%Ñ% c§n¡n°dÔ;÷ 
 à˜aŸ˜ˆÜ# I§L¡L¸|ÔLˆØŒ?˜s 8�}°
Ö:¸sÀ9½~ÐQkÖ?kØ×'Ñ'¨Ø=@À½^ÈyÔ=X±	Ð^ið (ö kñ !ð
 ×Ñ˜sÖ#÷ 
 ×	ús   Â'D3Ä3E	c              ƒ  óô  "  € V P                   V P                  VR,          rTpT P                  YP                  4        UUu/ uF  w  rgVR8w  g   K  WgbK  	  upp4      p\	        WV4      G Rj  x€L
 w  rš\
        P                  ! \        VP                  VP                  VP                  VP                  R7      G Rj  x€L
 pVfT   V	P                  R8w  d   \        R4      hR\        W:4      9  d   \        R4      hVP                  P!                  V4       M(V	P                  V	P"                  3R8w  d   \        R4      h\%        VP                  VP                  VP                  4      p VP'                  WHV P(                  R	J \+        \,        W\R
7      \+        \.        W\R
7      R7      G Rj  x€L
 p\1        VP                  VR7      pWSP                  9   d*   VR,          VR,          3R8X  d   VP3                  W4       M)VR,          R8X  d   VP                  P5                  V4       ^ RIHp \
        P                  ! WóP                  V4      G Rj  x€L
  \;        V4      # u uppi  EL EL³ LÃ  \1        TP                  TR7      pYSP                  9   d*   TR,          TR,          3R8X  d   TP3                  Y4       i TR,          R8X  d   TP                  P5                  T4       i i ; i Lœ5i)ay  Cancel the queued admission and admit the edit at the FIFO tail under a new identity, in one
write. The replacement is bound to the admission it retired: an exact retry (same old admission,
same new ``submission_id``) answers the same new admission; any other old admission under that
``submission_id`` is ``admission_conflict``, decided inside the admission's own transaction.r6   N)Úprincipal_idr   Ú
request_idr&   rh   r,   ri   Úadmission_conflictT)r6   Úbinding)Úqueue_while_restartingÚ_authorize_writeÚ_replay_guardr7   r%   r9   )Úrelease_admission_media)r8   rƒ   )r   rJ   Ú
submissionrQ   rK   ÚasyncioÚ	to_threadr   r   Úsubjectr   rŠ   r%   r   r4   Úcancel_obligationsÚaddr9   r	   ÚsubmitÚ	_operatorr   r
   r   r   r†   ÚdiscardÚgateway.session_ingress_mediar�   r   )r   rD   r|   r   rJ   Úold_idr?   ÚvalueÚrequestrI   r3   ÚreplacementrŒ   ÚadmittedÚoldr�   s   &&&             r   r   r   Ñ   s�  é € ð
  *×3Ñ3°Z×5EÑ5EÀvÈnÕG]�f€IØ×#Ñ# CÇ|Á|Ä~Ô)oÁ~¹¸ÐY\Ð`nÑYn¬*¨#ª*Á~Ò)oÓp€GÜ  °&Ó9×9�L€GÜ×)Ò)Ô*@À)Ç,Á,Ð]b×]jÑ]jØ58·^±^ÐPW×PbÑPbôd÷ d€KàÒØ�>‰>˜XÔ%Ü#Ð$7Ó8Ð8ØœO¨IÓ;Ô;Ü#Ð$9Ó:Ð:Ø×$Ñ$×(Ñ(¨Õ0Ø
�.‰.˜'Ÿ/™/Ð	*Ð.GÔ	GÜÐ 4Ó5Ð5Ü! %§-¡-°·±À×ASÑASÓT€Gð	9Ø"×)Ñ)¨%ÐQ[×QeÑQeÐimÐQmÜ;BÔCXÐgmÔ;Ü8?Ô@TÐciÔ8{ð *ó }÷ }ˆô $ I§L¡L¸vÔFˆØ×1Ñ1Ô1°s¸8µ}ÀcÈ)ÅnÐ6UÐYrÔ6rØ×'Ñ'¨Õ4Ø��]˜hÔ&Ø×(Ñ(×0Ñ0°Ô8ÝEÜ
×
Ò
Ð3·\±\À6Ó
J×JÐJÜ�(ÓÐùó3 *pÚ9òdñ}øô $ I§L¡L¸vÔFˆØ×1Ñ1Ô1°s¸8µ}ÀcÈ)ÅnÐ6UÐYrÔ6rØ×'Ñ'¨Õ4Ø��]˜hÔ&Ø×(Ñ(×0Ñ0°Õ8ð 'úñ Kùsp   ‚?K8ÁI)ÁI)ÁK8Á.I/Á/AK8Â?I2Ã B.K8Å/AI7 Æ1I5Æ2I7 Æ6B#K8ÉK6ÉK8É2K8É5I7 É7A<K3Ë3K8>   r$   r'   Ú
surface_v1Úlocal_operator_v1>   ÚacpÚcliÚguiÚtuiÚdesktop)!Ú__doc__r’   Údataclassesr   Ú	functoolsr   Úhermes_state_runtimer   r   r   r   r   r	   r
   r   r   r   Ú	frozensetr/   r   r   r!   r4   rG   rK   rA   r\   r^   ra   rf   r   r‡   r   r<   r   r   Ú<module>r­      sƒ   ðñó Ý Ý ÷÷ ÷ ñ ÒPÓQ€
ñ !Ò!HÓIÐ òJò
7ò	 ò
=ò^ò
ò -ò#òò"ò51òp$ô"r   