+
    „WÝjÙ  ã                   ó`   € R t ^ RItR tR tR tRR/tRtR tR	 tR
 t	R t
R tR tR tR tR# )zVWorker exclusion follows the logical conversation and its physical transcript lineage.Nc                 ó²  € ^ RI Hp ^ RIHp ^ RIHp ^ RIHp ^ RIH	p W! W4      0pV P                  RV34      P                  4       pV'       d£   VR,          '       d”   V P                  RW(R,          ,           34      P                  4       p	V	eb   V\        P                  ! V	^ ,          4      P                  R	VR,          .4      9   d(   VP                  VR,          V! WR,          4      04       \!        V4      p
\#        V4       F?  pV! W
4       Uu. uF  qÌV9  g   K  VNK  	  p
pV
'       g   Vu # VP                  V
4       KA  	  V! R
4      hu upi )é    )ÚPOLICY_PREFIX)Úlocal_physical_target)Ú_expand_compression_lineage_ids)Ú
_CHAIN_CAP)ÚRuntimeStoreErrorz'SELECT chat_id FROM sessions WHERE id=?Úchat_idz(SELECT value FROM state_meta WHERE key=?ÚlineageÚstorage_unavailable)Úhermes_state_localr   Úhermes_state_local_lineager   Úhermes_state_sessionsr   Úhermes_state_compressionr   Úhermes_state_runtimer   ÚexecuteÚfetchoneÚjsonÚloadsÚgetÚupdateÚlistÚrange)ÚconnÚ
session_idr   r   r   r   r   ÚtargetsÚrowÚsavedÚfrontierÚ_Úsids   &&           ÚPC:\Users\johnn\AppData\Local\hermes\hermes-agent\hermes_state_runtime_workers.pyÚruntime_lineager"      s!  € Ý0Ý@ÝEÝ3Ý6ØÐ0°ÓBÐC€GØ
�,‰,Ð@À:À-Ó
P×
YÑ
YÓ
[€Cß
ˆs�9�~Œ~Ø—‘ÐGÈ-Ð^gÕZhÕJhÐIjÓk×tÑtÓvˆØÒ ¬t¯zªz¸%À½(Ó/C×/GÑ/GÈ	ÐTWÐXaÕTbÐScÓ/dÔ!dØ�N‰N˜C 	�NÑ,AÀ$ÈIÍÓ,WÐXÔYÜ�G‹}€HÜ�:ÖˆÙ#BÀ4Ô#RÓiÑ#R˜CÐahÑVh—C�CÑ#RˆÐißØŠNØ�‰�xÖ ñ	 ñ
 Ð1Ó
2Ð2ùò	 js   ÄEÄ#Ec                 óª   € V P                  R \        P                  ! \        \	        W4      4      4      34       Uu0 uF  q"^ ,          kK  	  up# u upi )z“SELECT DISTINCT status FROM worker_executions WHERE session_id IN (SELECT value FROM json_each(?)) AND status IN ('registered','running','unknown'))r   r   ÚdumpsÚsortedr"   )r   r   r   s   && r!   Úworker_statesr&      s[   € à"Ÿl™lð	;Ü=A¿ZºZÌÌÐ_cÓOpÓHqÓ=rÐ<tôvó wñ v�s��FˆFñ vñ wð wùò ws   ¼Ac                ó¬   € V FM  pV P                  RV34      P                  4       pV F#  w  pV P                  RV34       \        W4       K%  	  KO  	  R# )a
  An explicit reset revokes unlinked unknown compute; it never replays its side effects.

Admission-linked work still requires its own Discard receipt. A running/registered worker
remains a hard reset refusal, and transaction rollback preserves all fences on refusal.
z�SELECT execution_id FROM worker_executions WHERE session_id=? AND status='unknown' AND execution_id NOT LIKE 'admission-worker:%'úCUPDATE worker_executions SET status='terminal' WHERE execution_id=?N)r   ÚfetchallÚcompact_terminal_receipts)r   Úsession_idsr    ÚorphansÚexecution_ids   &&   r!   Údiscard_orphan_workers_on_resetr.   !   s\   € ó ˆØ—,‘,ð  PØRUÐQWóYßYaÑYaÓYcð 	ã&‰Oˆ\Ø�L‰LÐ^ÐamÐ`oÔpÜ% dÖ9ó  'ó ó    ÚretiredTz/child:c           	     ój   € \        W P                  R\        V4      4      P                  4       4       R# )zøA child never outlives the execution that reserved it: every live descendant goes terminal
with it, its read receipts shrink and its open session row is ended. A late child write is
then refused ``stale_generation`` like any write after retirement.zuSELECT execution_id,session_id FROM worker_executions WHERE execution_id>=? AND execution_id<? AND status!='terminal'N)Ú_retire_childrenr   Údescendant_ranger)   ©r   r-   s   &&r!   Úretire_child_executionsr5   5   s.   € ô �TŸ<™<ð )jä(8¸Ó(FóHçHPÉË
öTr/   c                óJ   € V \         ,           V \         RR ,           R,           3# )z°``(low, high)`` bounds every descendant id of ``execution_id`` on the primary key index
(';' sorts right after the separator's ':'), so a no-child finish costs one index probe.NÚ;éÿÿÿÿ)ÚCHILD_SEPARATOR)r-   s   &r!   r3   r3   >   s&   € ð œ/Õ)¨<¼/È#È2Ð:NÕ+NÐQTÕ+TÐTÐTr/   c                óZ   € \        W P                  RV34      P                  4       4       R# )zšOwner restart: a child dies with its worker, which dies with its owner, so it is never
adoptable; only its root execution can be recovered as ``unknown``.zrSELECT execution_id,session_id FROM worker_executions WHERE kind='child' AND status!='terminal' AND owner_epoch!=?N)r2   r   r)   )r   Úepochs   &&r!   Úretire_stale_childrenr<   D   s.   € ô �TŸ<™<ð )TØV[ÐU]ó_ß_gÑ_gÓ_iökr/   c                 ón   € V F.  w  r#V P                  R V34       \        W4       \        W4       K0  	  R# )r(   N)r   Ú_compactÚ_end_child_row)r   ÚrowsÚchildÚ_session_ids   &&  r!   r2   r2   K   s2   € Û"ÑˆØ�‰ÐZÐ]bÐ\dÔeÜ�ÔÜ�tÖ#ó #r/   c                 óR   € ^ RI pV P                  RVP                  4       V34       R# )r   Nz•UPDATE sessions SET ended_at=?,end_reason='agent_close' WHERE ended_at IS NULL AND id=(SELECT session_id FROM worker_executions WHERE execution_id=?))Útimer   )r   r-   rD   s   && r!   r?   r?   R   s*   € ÛØ‡L�Lð ZØ\`×\eÑ\eÓ\gÐiuÐ[vöxr/   c                ób   € \        W4       \        W4       \        V9   d   \        W4       R# R# )a‡  Every terminal transition calls this, so it also retires the execution's delegated children.
Once an execution is terminal its read receipts are dead weight: a ``compression.history``
read stores the whole transcript and a context read a full session row, so keeping them leaves
one full-history copy per managed turn and ``state.db`` grows quadratically. They shrink to a
marker in the closing transaction (an exact late replay is refused ``stale_generation``, as
after retirement); ``payload_digest`` stays, so a late duplicate with other content still
conflicts. Mutation acknowledgements (counts, row annotations, assignments) stay replayable.N)r5   r>   r9   r?   r4   s   &&r!   r*   r*   X   s+   € ô ˜DÔ/ÜˆTÔ Ü˜,Ô&ô 	�tÖ*ñ 'r/   c                 ó^   € V P                  R \        P                  ! \        4      V34       R# )zÃUPDATE worker_receipts SET result_json=? WHERE execution_id=? AND json_valid(result_json) AND (json_type(result_json, '$.messages') IS NOT NULL OR json_type(result_json, '$.session') IS NOT NULL)N)r   r   r$   ÚRETIRED_RECEIPTr4   s   &&r!   r>   r>   h   s'   € Ø‡L�Lð Gô —*’*œ_Ó-¨|Ð<ö>r/   c                 ó<   € \         P                  ! V 4      \        8H  # )N)r   r   rG   )Úresult_jsons   &r!   Úretired_receiptrJ   o   s   € Ü�:Š:�kÓ"¤oÑ5Ð5r/   )Ú__doc__r   r"   r&   r.   rG   r9   r5   r3   r<   r2   r?   r*   r>   rJ   © r/   r!   Ú<module>rM      sZ   ðÙ \Û ò3ò*wò:ð ˜dÐ#€ð €òTòUòkò$òxò+ò >ô6r/   