+
    jHàj�$  ã                   ó’   € R t ^ RIt^ RIt^ RIHtHtHtHtHtH	t	H
t
 RtRtRtRtRR/R ltR	tR
 tR tR tR tR tRR/R ltR tR# )aA  Private terminal-only tombstone queries; never reconstruct executable history.

The authenticated edge supplies the original principal/target/request and frozen
payload. A retired target permits only that exact digest, never fresh admission.
Worker receipt reads additionally require the original private adoption proof.
N)ÚRuntimeStoreErrorÚ_epochÚ_jsonÚ_rowÚ_secret_digestÚ_textÚadmission_fingerprintzgateway.admission.result.v1.zgateway.terminal_admission.v1.zgateway.terminal_identity.v1.zgateway.terminal_worker.v1.Úuser_messagec               ó‚  € \        V 4      p V P                  R4      p\        V\         4      '       g   V # \        V4      pVP                  RR4       VP                  R4      p\        V\        4      '       Ed=   VP                  R4      '       Eg%   VP                  R4      '       Eg   ^ RIHp VP                  R4      p\        V4      \        J dT   ^ Tu;8:  d   \        V4      8  d<   M M8\        W5,          \         4      '       d   W5,          P                  R	4      R
8X  g	   V! W14      pW5^,           R VR&   V^ 8¼  d\   \        W5,          \         4      '       d@   W5,          P                  R4      '       d#   R Uu/ uF  qfW5,          V,          bK  	  upVR&   RVR&   VP                  RR4       W R&   V # u upi )zORetain replay/accounting and current-turn API output, never cumulative history.ÚresultÚtoolsNÚmessagesÚ_compressedÚ_messages_are_turn_suffix)Úreanchor_current_turn_user_idxÚcurrent_turn_user_idxÚroleÚuserÚapi_contentÚ_turn_user_rowT)r   Úcontentr   )
ÚdictÚgetÚ
isinstanceÚpopÚlistÚagent.turn_contextr   ÚtypeÚintÚlen)r   r	   Úvaluer   r   ÚanchorÚks   &$     Ú:/home/ubuntu/.hermes/hermes-agent/hermes_state_terminal.pyÚcompact_resultr$      su  € ä�&‹\€FØ�J‰J�xÓ €EÜ�eœT×"Ò"ØˆÜ�‹K€Eð 
‡I�Iˆg�tÔØ�y‰y˜Ó$€HÜ�(œD×!Ó!ð
 �y‰y˜×'Ó'°·	±	Ð:U×0VÓ0VÝIØ—Y‘YÐ6Ó7ˆFÜ˜“L¤CÓ'¨A°Ö,G¼#¸h»-×,GÜ" 8Õ#3´T×:Ò:¸xÕ?O×?SÑ?SÐTZÓ?[Ð_eÔ?eÙ7¸ÓO�Ø (°!­¨Ð 5ˆE�*ÑØ˜Œ{œz¨(Õ*:¼D×AÒAÀhÕFV×FZÑFZÐ[h×FiÒFiñ LnÓ*nÑKmÀa¨hÕ.>¸qÕ.AÒ+AÑKmÑ*n�Ð&Ñ'ð 26ˆEÐ-Ñ.Ø�I‰IÐ-¨tÔ4Øˆ8ÑØ€Mùò +os   ÆF<Ú_storedc                óœ  a€ \        V \        4      '       g   V # \        V 9   d   / V C\        R^RV \        ,          //C# V P                  R4      p\        V\        4      '       d&   \        VP                  R4      \        4      '       g   V # VP                  R4      \	        VR,          4      upo\        V3R l\        \        S4      ^,
          R
R
4       4       R4      p\        V\        4      '       d*   V'       d"   Ve   SV,          P                  R4      V8X  g   V # / SV,          CRR/CSV&   / V CR/ VCRS/C\        R^R	V//C# )a¸  The stored row keeps the reply once. When the turn's closing assistant message carries
exactly ``final_response``, its ``content`` is stored as null and the row gets
``_stored: {v: 1, reply_ref: <that message's index>}``. Retirement drops ``messages`` and
keeps ``final_response``, so a deleted session's exact retry still has its reply. A result
that already has ``_stored`` is stored whole with that value escaped as ``{v: 1, raw: ...}``.ÚvÚrawr   r   Úfinal_responsec              3   ó¤   <"  € T FE  p\        SV,          \        4      '       g   K"  SV,          P                  R 4      R8X  g   KA  Vx € KG  	  R# 5i)r   Ú	assistantN)r   r   r   )Ú.0Úir   s   & €r#   Ú	<genexpr>Ú encode_result.<locals>.<genexpr>H   s@   øé € ð =Ñ<�qÄ
È8ÐTUÍ;ÔX\×@]”Ø˜a•[—_‘_ VÓ,°Ñ;÷ ’Ó<ùs   ƒA§AÁ
ANr   Ú	reply_reféÿÿÿÿ)	r   r   Ú_STOREDr   r   ÚnextÚranger   Ústr)r   r    ÚreplyÚlastr   s   &   @r#   Úencode_resultr8   :   s7  ø€ ô �fœd×#Ò#ØˆÜ�&ÔØD�&ÐDœ' C¨¨E°6¼'µ?Ð#CÑDÐDØ�J‰J�xÓ €EÜ�eœT×"Ò"¬*°U·Y±Y¸zÓ5JÌD×*QÒ*QØˆØ—i‘iÐ 0Ó1´4¸¸jÕ8IÓ3J€O€Eˆ8Üô =œE¤# h£-°!Õ"3°R¸Ô<ó =Ø>BóD€Dä�uœc×"Ò"§u°Ò1AÀhÈtÅn×FXÑFXÐYbÓFcÐglÔFlØˆØ8˜ �Ð8¨	°4Ñ8€HˆT�NØfˆfÐf�hÐ ? 5Ð ?¨*°hÑ ?ÄÈ3ÐPQÐS^Ð`dÐJeÑfÐfó    c                óz  € \         P                  ! V 4      p\        V\        4      '       d,   \        VP	                  \
        4      ;p\        4      '       g   V# VP                  4       RR08X  d;   \        VR,          4      \        J d!   VR,          ^8X  d   VR,          V\
        &   V# VP	                  R4      VP	                  R4      rC\        V\        4      '       d   VP	                  R4      MRpVP                  4       RR08X  då   \        VR,          4      \        J dË   VR,          ^8X  d½   \        V4      \        J dª   \        V\        4      '       d”   ^ Tu;8:  d   \        V4      8  d|   M V# \        VP	                  R4      \        4      '       dS   \        WT,          \        4      '       d7   WT,          P	                  R4      R	8X  d   WT,          P	                  R
^ 4      e   V# WT,          P                  4        UUu/ uF  w  rgYfR
8X  d
   VR,          MTbK  	  uppWT&   V\
         V# u uppi )zÙDecode a stored result row. Only a row carrying ``encode_result``'s exact envelope is
decoded (to the dict it encoded, key order included); every other row, including all rows
written before it, is returned as stored.r'   r(   r   r0   r   Nr)   r   r+   r   )ÚjsonÚloadsr   r   r   r2   Úkeysr   r   r   r   r5   Úitems)Útextr   Úenveloper    Úrefr   r"   r'   s   &       r#   Úload_resultrB   P   s·  € ô �ZŠZ˜Ó€FÜ�fœd×#Ò#¬:À&Ç*Á*ÌWÓBUÐ6U°hÔW[×+\Ò+\ØˆØ‡}�}ƒ˜3 ˜,Ô&¬4°¸µÓ+>Ä#Ó+EÈ(ÐSVÍ-Ð[\ÔJ\Ø" 5�/ˆŒw‰ØˆØ—‘˜HÓ% x§|¡|°KÓ'@ˆ3Ü(2°5¼$×(?Ò(?ˆu�y‰y˜Ô$ÀT€HØ�M‰M‹O  [Ð1Ô1´d¸8ÀC½=Ó6IÌSÓ6PÐU]Ð^aÕUbÐfgÔUgÜ�S“	œSÓ ¤Z°¼$×%?Ò%?ÀAÈÖD\ÌsÐS[Ë}ÖD\ð ˆô ˜5Ÿ9™9Ð%5Ó6¼×<Ò<ÄÈHÍMÔ[_×A`ÒA`Ø•×!Ñ! &Ó)¨[Ô8¸X½]×=NÑ=NÈyÐZ[Ó=\Ò=dØˆØU]ÕUb×UhÑUhÔUjÔkÑUjÉTÈQ�Q¸	´>˜Ð.Ö/ÀqÒHÑUjÒk€H�MØŒwˆØ€Mùó ls   ÈH7c                 ó:   € \         \        VR V RV/R7      ,           # )Ú	principalÚrequest©Úcanonical_targetÚpayload)ÚIDENTITY_PREFIXr   )Úprincipal_idÚ
session_idÚ
request_ids   &&&r#   Úidentity_keyrM   h   s(   € ÜÔ2ÀJØ˜l¨I°zÐBôDõ Dð Dr9   c                ó    € V P                  R\        R,           V34       Uu. uF   p\        P                  ! V^ ,          4      NK"  	  up# u upi )z«Retired API admissions that carried *request_id*: a deleted session's tombstones, kept for
the exact-retry horizon, still spend its Idempotency-Key for every other target.z‡SELECT value FROM state_meta WHERE key GLOB ? AND json_extract(value, '$.principal_id')='api' AND json_extract(value, '$.request_id')=?Ú*)ÚexecuteÚADMISSION_PREFIXr;   r<   )ÚconnrL   Úrows   && r#   Úterminal_api_admissionsrT   m   sS   € ð +/¯,©,ð	dä	˜CÕ	 Ð,ô+.ó /ñ +. 3ŒD�JŠJ�s˜1•vÖñ +.ñ /ð /ùò /s   ¢&Ac                 ó¨   € V P                  R \        V,           34      P                  4       pV'       d   \        P                  ! V^ ,          4      # R# )ú(SELECT value FROM state_meta WHERE key=?N)rP   rQ   Úfetchoner;   r<   )rR   Úadmission_idÚsaveds   && r#   Úterminal_admissionrZ   v   sB   € Ø�L‰LÐCÜ*¨\Õ9Ð;ó=ß=E¹X»Zð 
ç#(Œ4�:Š:�e˜A•hÓÐ2¨dÐ2r9   ÚintentÚqueuec          
     ó”  € W#V3 F  p\        V4       K  	  \        VR\        P                  ! \	        V4      4      RV/R7      pV P                  4       ;_uu_ 4       p	\        W‘4       ^ RIHp
 V	P                  RW£,           34      P                  4       '       g    RRR4       R# V	P                  R\        W#V4      34      P                  4       pVf   \        R4      h\        V	\        P                  ! V^ ,          4      4      pVR	,          V8w  d   \        R
4      h\        V4      uuRRR4       #   + '       g   i     R# ; i)zãNone means a live target; a retired miss/conflict is a definitive refusal.

This is a read-only identity lookup, not authorization to attach, restore a
route, or write. HTTP authentication/grant checks must precede this query.
Úinputr[   rF   )ÚRETIRED_PREFIXz$SELECT 1 FROM state_meta WHERE key=?NrV   Ú	not_foundÚpayload_digestÚadmission_conflict)r   r   r;   r<   r   Ú	_read_ctxr   Ú hermes_state_mutation_retirementr_   rP   rW   rM   r   rZ   r   )ÚdbÚepochrJ   rK   rL   rH   r[   r    ÚdigestrR   r_   rY   rS   s   &$$$$$$      r#   Úretry_terminal_admissionrh   |   s  € ð ¨JÓ7ˆÜˆeŽñ 8ä"°JØœ$Ÿ*š*¤U¨7£^Ó4°hÀÐGôI€Fà	�‰�Œ˜4ÜˆtÔÝCØ�|‰|ÐBÀ^ÕE`ÐDbÓc×lÑl×nÒnØ÷	 
‰ð
 —‘ÐGÜ*¨<ÀZÓPÐRóTßT\ÑT\ÓT^ð 	àŠ=Ü# KÓ0Ð0Ü  ¤t§z¢z°%¸µ(Ó';Ó<ˆØÐÕ  FÔ*Ü#Ð$8Ó9Ð9Ü�C‹y÷ 
��‹ús   ÁA D6Â'BD6Ä6E	c               óø  a€ \        V4      pV P                  4       ;_uu_ 4       pVP                  R\        V,           34      P	                  4       p	V	f   \        R4      h\        P                  ! V	^ ,          4      p
V
R,          V8w  g%   \        P                  ! V
R,          V4      '       g   \        R4      h\        V4      \        Jg   W:R,          8w  d   \        R4      h\        V3R	 lV
R
,           4       R4      pVf   \        R4      hVR,          V8w  d   \        R4      hVR,          f   \        R4      h\        P                  ! VR,          4      uuRRR4       #   + '       g   i     R# ; i)zIExact retired producer evidence; possession never reactivates the worker.rV   Nr`   rK   Úadoption_digestÚpermission_deniedÚ
generationÚstale_generationc              3   óF   <"  € T F  qR ,          S8X  g   K  Vx € K  	  R# 5i)ÚsequenceN© )r,   Úrro   s   & €r#   r.   Ú*terminal_worker_receipt.<locals>.<genexpr>£   s   øé € ÐSÑ#5˜a¸:½È(Ñ9RŸšÓ#5ùs   ƒ!—
!Úreceiptsra   rb   Úresult_json)r   rc   rP   ÚWORKER_PREFIXrW   r   r;   r<   ÚhmacÚcompare_digestr   r   r3   )re   Úexecution_idrK   rl   ro   Úadoption_secretra   ÚproofrR   rY   ÚworkerÚreceipts   &$$$d$$     r#   Úterminal_worker_receiptr}   •   s0  ø€ ô ˜?Ó+€EØ	�‰�Œ˜4Ø—‘ÐGÜ+¨lÕ:Ð<ó>ß>F¹h»jð 	àŠ=Ü# KÓ0Ð0Ü—’˜E !�HÓ%ˆØ�,Õ :Ô-´T×5HÒ5HÈÐPaÕIbÐdi×5jÒ5jÜ#Ð$7Ó8Ð8Ü�
Ó¤3Ó&¨*¸|Õ8LÔ*LÜ#Ð$6Ó7Ð7ÜÔS 6¨*Ö#5ÓSÐUYÓZˆØŠ?Ü#Ð$6Ó7Ð7ØÐ#Õ$¨Ô6Ü#Ð$8Ó9Ð9Ø�=Õ!Ò)Ü#Ð$6Ó7Ð7Ü�zŠz˜' -Õ0Ó1÷# 
��‹ús   ¥B
E(Â0B-E(Å(E9	)Ú__doc__rv   r;   Úhermes_state_runtimer   r   r   r   r   r   r   ÚRESULT_PREFIXrQ   rI   ru   r$   r2   r8   rB   rM   rT   rZ   rh   r}   rp   r9   r#   Ú<module>r�      sq   ðñó Û ç u× uÑ uà.€Ø3Ð Ø1€Ø-€ð ¨4ô  ðJ €ògò,ò0Dò
/ò3ðÐahô ô22r9   