+
    „WÝjÃ!  ã            
       ó¨   € R t ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 Rt
R tR tR	 tR
 tR tR tR tR tR]R]R]R]R]/tRtRR ltR tR tR# )zLOptimistic preparation snapshots revalidated inside the receipt transaction.N)ÚPOLICY_PREFIX)Úvalidate_local_lineage)Úrequire_target_advanceable)ÚRuntimeStoreErrorzgateway.deferred_pick.v1.c                 óT  € VP                  R \        V,           34      P                  4       pVf   \        R4      h\        P
                  ! V^ ,          4      p\        W4      p\        W\        W%04      4       VP                  RV34      P                  4       ^ ,          pRVRVRV/# )ú(SELECT value FROM state_meta WHERE key=?Úruntime_coordination_requiredz0SELECT runtime_revision FROM sessions WHERE id=?ÚreceiptÚtargetÚtarget_revision)	Úexecuter   Úfetchoner   ÚjsonÚloadsr   r   Úlist)ÚdbÚconnÚ
session_idÚrowÚsavedr
   Úrevisions   &&&    ÚRC:\Users\johnn\AppData\Local\hermes\hermes-agent\hermes_state_mutation_prepared.pyÚlocal_snapshotr      sœ   € Ø
�,‰,ÐAÄMÐT^ÕD^ÐC`Ó
a×
jÑ
jÓ
l€CØ
‚{ÜÐ ?Ó@Ð@Ü�JŠJ�s˜1•vÓ€EÜ# DÓ0€FÜ˜r¬¨zÐ.BÓ)CÔDØ�|‰|ÐNÐQWÐPYÓZ×cÑcÓeÐfgÕh€HØ�u˜h¨Ð0AÀ8ÐLÐLó    c                 óž   € \        V\        4      '       d   R V9  d   \        R4      h\        WV4      pWCR ,          8w  d   \        R4      hV# )Úsnapshotr   Úrevision_conflict)Ú
isinstanceÚdictr   r   )r   r   r   ÚpreparedÚcurrents   &&&& r   Úvalidate_preparedr!      sJ   € Ü�h¤×%Ò%¨¸8Ô)CÜÐ ?Ó@Ð@Ü˜R zÓ2€GØ˜:Õ&Ô&ÜÐ 3Ó4Ð4Ø€Nr   c                ó  € ^ RI Hp \        WW#4      pVR,          pVR,          VR&   VP                  RV! V4      \        V,           34       VP                  RV34       VP                  RV34      P                  4       ^ ,          pWW3# )zXWrite the prepared policy over the snapshot it was derived from and bump the generation.©Ú_jsonr	   Úpolicyz)UPDATE state_meta SET value=? WHERE key=?zFUPDATE sessions SET runtime_generation=runtime_generation+1 WHERE id=?ú2SELECT runtime_generation FROM sessions WHERE id=?)Úhermes_state_runtimer$   r!   r   r   r   )r   r   r   r   r$   r   r   Ú
generations   &&&&    r   Ú_commit_policyr)       s‡   € å*Ü  ¨:Ó@€HØ�YÕ€EØ˜xÕ(€Eˆ(�OØ‡L�LÐ<¹uÀU»|Ì]Ð]gÕMgÐ>hÔiØ‡L�LÐYÐ\fÐ[hÔiØ—‘ÐRÐU_ÐTaÓb×kÑkÓmÐnoÕp€JØÐÐr   c                 ó  € ^ RI Hp \        WW$4      w  rgVR,          R,          p\        P                  ! VR,          R,          4      R,          p	VR,          p
VP                  RV
34      P                  4       p\        P                  ! V^ ,          ;'       g    R4      pV	R,          VR&   VP                  R	W…! V4      V
34       VP                  R
\        V,           34       W*0RVRV	R,          RV/RV9   d   RVR,          /C3# / C3# )é    r#   r%   ÚmodelÚconfig_jsonr
   z,SELECT model_config FROM sessions WHERE id=?z{}Úproviderz5UPDATE sessions SET model=?,model_config=? WHERE id=?z"DELETE FROM state_meta WHERE key=?Úexecution_generationÚ	reasoningÚeffort)r'   r$   r)   r   r   r   r   ÚDEFERRED_PICK_PREFIX)r   r   r   Úpayloadr   r$   r   r(   r,   Úconfigr
   r   Úmodel_configs   &&&&&        r   Úmodel_in_transactionr6   ,   s   € Ý*Ü)¨"°JÓIÑ€HØ�XÕ˜wÕ'€EÜ�ZŠZ˜ Õ*¨=Õ9Ó:¸7ÕC€FØ�hÕ€Fð �,‰,ÐEÈÀyÓ
Q×
ZÑ
ZÓ
\€CÜ—:’:˜c !�fŸn˜n¨Ó-€LØ% jÕ1€L�ÑØ‡L�LÐHÈ5ÐRWÐXdÓReÐgmÐJnÔoà‡L�LÐ5Ô8LÈzÕ8YÐ7[Ô\ØÐ '¨5°*¸fÀZÕ>PÐRhÐjtð "jØITÐX_ÔI_ h°¸Õ0DÐ%Eð"jð jð jØegð"jð jð jr   c                 óL   € \        WW$4      w  rVW%R ,          0RVR,          RV/3# )r
   r1   r/   ©r)   ©r   r   r   r3   r   r   r(   s   &&&&&  r   Úreasoning_in_transactionr:   >   s4   € Ü)¨"°JÓIÑ€HØ Õ*Ð+¨h¸ÀÕ8IÐKaÐcmÐ-nÐnÐnr   c           
     ó¼  € ^ RI Hp \        WW$4      w  rgVR,          R,          VR,          r˜\        \        P                  . V! W4      OVR,          N4      4      p
TP                  RV
 Uu. uF*  q¸V	R,          ;'       g    RV	R	,          ;'       g    RV3NK,  	  up4       W&R,          0RTRV	R,          ;'       g    RR
V	R	,          ;'       g    RRV/3# u upi )zãThe policy (execution cwd + TERMINAL_CWD) and every row of the conversation move together:
the sidebar groups by the row's cwd/git identity, which a move REPLACES (main's update_session_cwd
with replace_git_meta), never merges.)Úlocal_conversation_idsr%   ÚcwdÚgitr
   zƒUPDATE sessions SET cwd=?, git_branch=?, git_repo_root=?, git_metadata_generation=COALESCE(git_metadata_generation, 0)+1 WHERE id=?ÚbranchNÚrootÚgit_repo_rootr/   )Úhermes_state_localr<   r)   r   r   ÚfromkeysÚexecutemany)r   r   r   r3   r   r<   r   r(   r=   r>   ÚrowsÚsids   &&&&&       r   Úworkspace_in_transactionrG   C   sï   € õ :Ü)¨"°JÓIÑ€HØ˜Õ! %Õ(¨(°5­/ˆÜ”—‘Ð]Ñ 6°tÓ HÐ]È(ÐS[ÕJ\Ð]Ó^Ó_€DØ×Ñð aáX\Ó]ÑX\ÐQT˜C �M×1Ð1¨T°3°vµ;×3FÐ3FÀ$ÈÓLÑX\Ñ]ô_ð  Õ*Ð+¨e°S¸(ÀCÈÅM×DYÐDYÐUYØ.=¸sÀ6½{×?RÐ?RÈdÐTjÐlvð.xð xð xùò ^s   Á,C
ÂC
Â	C
c                 ó^   € \        WW$4      w  rVW%R ,          0RVR,          RVR,          RV/3# )r
   Útools_changedÚmcp_serversr/   r8   r9   s   &&&&&  r   Úeditor_mcp_in_transactionrK   R   sG   € Ü)¨"°JÓIÑ€HØ Õ*Ð+¨o¸xÈÕ?XØ.;¸XÀmÕ=TÐVlÐnxð.zð zð zr   c                 óL   € \        WW$4      w  rVW%R ,          0RVR,          RV/3# )r
   Úedit_approval_policyr%   r/   r8   r9   s   &&&&&  r   Úedit_policy_in_transactionrN   X   s=   € Ü)¨"°JÓIÑ€HØ Õ*Ð+Ð.DÀgÈhÕFWØ.DÀjð.Rð Rð Rr   r,   r0   Ú	workspaceÚ
editor_mcpÚedit_policyzMFROM state_meta WHERE key GLOB 'gateway.mutation.v1.*' AND json_valid(value) c                ó2  € Vf   RMRpT P                  R\        ,           R,           V,           V.Vf   R	MV3O54       Uu0 uF  qD^ ,          kK  	  ppV P                  R\        V,           34      P                  4       pVf   V# R\        P
                  ! V^ ,          4      ;p9   d   V\        VR,          4      ,          # V P                  R\        ,           R,           V34      P                  4       pV'       d   V\        V .VO5!  ,          # T# u upi )
a0  The policy edits (``model``, ``reasoning``, ``workspace``) a ``session.mutate`` committed for *session_id* (below
revision *before*): their receipts (kept for exact retries, also past deletion) are the durable record of
the user's pick. A deferred ``/model`` (``status: deferred``) is only a request until a turn boundary
applies it under a receipt of its own, so it is no pick. A branch copied its parent's policy, picks
included, under its own id: its local receipt's ``picks``; a branch stored before that field has its
parent's as they stood at its branch.Ú z/ AND json_extract(value, '$.result.revision')<?z:SELECT DISTINCT json_extract(value, '$.result.operation') zÌAND json_extract(value, '$.result.operation') IN ('model', 'reasoning', 'workspace') AND COALESCE(json_extract(value, '$.result.status'), '') != 'deferred' AND json_extract(value, '$.result.session_id')=?r   Úpicksz\SELECT json_extract(value, '$.result.session_id'), json_extract(value, '$.result.revision') zpAND json_extract(value, '$.result.operation')='branch' AND json_extract(value, '$.result.branched_session_id')=?© )r   Ú	_RECEIPTSr   r   r   r   ÚsetÚpicks_on)	r   r   ÚbeforeÚboundr   Úpickedr   r	   Úbrancheds	   &&&      r   rX   rX   f   s5  € ð ’.‰BÐ&W€EØ $§¡ØDÄyÕPð	;õ	;ð >Cõ	Cð FPÐDxÐY_ÒYgÑSUÐntÐmvÑDxô	!zó {ñ !z˜�!�fˆfñ !z€Fð {ð
 �L‰LÐCÄmÐV`ÕF`ÐEbÓc×lÑlÓn€EØ‚}ØˆØœdŸjšj¨¨q­Ó2Ð2�7Ô3Øœ˜G GÕ,Ó-Õ-Ð-à�|‰|ØfÔirÕrð	Dõ	DàFPÀ]óT÷ U]ÑT\ÓT^ð ÷ 2:ˆ6”H˜TÐ- HÓ-Õ-ÐE¸vÐEùò{s   ÁDc                 ó†   € V P                  4       ;_uu_ 4       p\        W!4      uuR R R 4       #   + '       g   i     R # ; i©N)Ú	_read_ctxrX   )r   r   r   s   && r   Úpolicy_picksr`   €   s#   € Ø	�‰�Œ˜4Ü˜Ó)÷ 
��‹ús	   ™/¯A 	c               óf   a aaaaaaa€ ^ RI Ho ^ RIHo VV VVVVVV3R lpS P	                  V4      # )z¿The owner's config refresh of an idle session: *new* replaces exactly *old* at *generation* (a
concurrent mutation or turn wins) and opens the next policy generation. Returns that generation.)Úrequire_idle)Ú_epochc           	      ó@  <€ S! V S4       \        SV S
4      pS	! SV \        S
VR ,          04      4       V P                  RS
34      P                  4       pVR,          R,          S8w  g   Ve   V^ ,          S8w  d   \	        R4      h\        SV S
RVRS/4      ^,          # )r
   r&   r	   r%   r   r   )r   r   r   r   r   r)   )r   r   r    rc   r   Úepochr(   ÚnewÚoldrb   r   s   &  €€€€€€€€r   ÚwriteÚ&commit_refreshed_policy.<locals>.write‹   s£   ø€ Ùˆt�UÔÜ! " d¨JÓ7ˆÙ�R˜œt Z°¸(Õ1CÐ$DÓEÔFØ—,‘,ÐSÐV`ÐUbÓc×lÑlÓnˆØ�IÕ˜xÕ(¨CÔ/°7²?ÀgÈaÅjÐT^ÔF^Ü#Ð$7Ó8Ð8Ü˜b $¨
°ZÀÈ8ÐUXÐ4YÓZÐ[\Õ]Ð]r   )Úhermes_state_mutation_guardsrb   r'   rc   Ú_execute_write)	r   re   r   rg   rf   r(   rh   rc   rb   s	   fddddd @@r   Úcommit_refreshed_policyrl   …   s*   ÿ€ õ :Ý+÷^ô ^ð ×Ñ˜UÓ#Ð#r   r^   )Ú__doc__r   rB   r   Úhermes_state_local_lineager   rj   r   r'   r   r2   r   r!   r)   r6   r:   rG   rK   rN   ÚPOLICY_HANDLERSrV   rX   r`   rl   rU   r   r   Ú<module>rp      sŠ   ðÙ RÛ Ý ,Ý =Ý CÝ 2ð 3Ð òMòò	 òjò$oò
xòzòRð Ð0°+Ð?WØÐ 8¸,ÐHaØ Ð"<ð>€ð
 \€	ôFò4*ô
$r   