+
    jHàj³  ã                  ó¬   € R t ^ RIHt ^ RIHt ^ RIt^ RIt]P                  ! ]4      t	R t
R R ltR R ltR	 R
 ltR R ltR R ltRR/R R lltR# )zÉIn-session context growth for the managed llama.cpp runtime.

Scope guard: only a server THIS process supervises grows. Detected external servers and
other-process supervisors keep their own policies.
)Úannotations)ÚsuppressNc                 ó*   € ^ RI Hp  V ! 4       R,          # )é    ©Úruntimes_rootzwindow_overrides.json)Ú!hermes_cli.local_runtime.binariesr   r   s    ÚD/home/ubuntu/.hermes/hermes-agent/hermes_cli/local_runtime/growth.pyÚwindow_overrides_pathr
      s   € Ý?á‹?Ð4Õ4Ð4ó    c               ó   € V ^8„  d   QhRR/# )é   ÚreturnÚdict© )Úformats   "r	   Ú__annotate__r      s   € ÷ ñ ˜tñ r   c                 óB  €  \        \        4       RR7      ;_uu_ 4       p \        P                  ! V 4      pRRR4       XP	                  4        UUu/ uF  w  r#\        V4      \        V4      bK  	  upp#   + '       g   i     LG; iu uppi   \         d    / u # i ; i)z<model_id -> granted window (int). Empty on any read problem.z	utf-8-sig©ÚencodingN)Úopenr
   ÚjsonÚloadÚitemsÚstrÚintÚ	Exception)ÚfhÚdataÚkÚvs       r	   Úload_window_overridesr!      sv   € ðÜÔ'Ó)°K×@Õ@ÀBÜ—9’9˜R“=ˆD÷ Aà+/¯:©:¬<Ô8©<¡4 1”�A“œ˜A›’©<Ò8Ð8÷ A×@üã8øÜô ØŠ	ðús3   ‚B ŸA5¶B Á BÁ1B Á5B	Â B ÂBÂBc               ó    € V ^8„  d   QhRRRR/# )r   Ú	overridesr   r   ÚNoner   )r   s   "r	   r   r       s   € ÷ Gñ G ð G¨ñ Gr   c                ó¦   € \        4       pVP                  P                  R R R7       VP                  \        P
                  ! V ^R7      RR7       R# )T)ÚparentsÚexist_ok)Úindentzutf-8r   N)r
   ÚparentÚmkdirÚ
write_textr   Údumps)r#   Úpaths   & r	   Ú_write_overridesr.       s<   € Ü Ó"€DØ‡K�K×Ñ˜d¨TÐÔ2Ø‡O�O”D—J’J˜y°Ô3¸g€OÖFr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úmodel_idr   Úwindowr   r   r$   r   )r   s   "r	   r   r   &   s!   € ÷  ñ   3ð  °ð  ¸ñ  r   c                óJ   € \        4       p\        V4      W &   \        V4       R # ©N)r!   r   r.   )r0   r1   r#   s   && r	   Úsave_window_overrider4   &   s   € Ü%Ó'€IÜ˜f›+€IÑÜ�YÖr   c               ó    € V ^8„  d   QhRRRR/# )r   r0   r   r   r$   r   )r   s   "r	   r   r   ,   s   € ÷ $ñ $ Cð $¨Dñ $r   c                óD   € \        4       pW9   d   W \        V4       R# R# )z7Drop a model's growth state (delete/re-download paths).N)r!   r.   )r0   r#   s   & r	   Úclear_window_overrider7   ,   s#   € ä%Ó'€IØÔØÐÜ˜Ö#ñ r   c               ó    € V ^8„  d   QhRRRR/# )r   Úbase_urlr   r   Úboolr   )r   s   "r	   r   r   4   s   € ÷ ñ  #ð ¨$ñ r   c           	     ó,  € \        \        4      ;_uu_ 4        ^ RIHp V! 4       pVRJ;'       dG    T ;'       g    RP	                  R4      \        VP                  RR4      4      P	                  R4      8H  uuRRR4       #   + '       g   i     R# ; i)zETrue when base_url is the server this process's state file points at.)Ú_state_endpointNÚ Ú/r9   F)r   r   Ú!hermes_cli.local_runtime.endpointr<   Úrstripr   Úget)r9   r<   Ústates   &  r	   Úis_managed_endpointrC   4   su   € ä	”)×	Õ	ÝEáÓ!ˆØ˜DÐ ÷ Xð XØ�^ˆ^˜×#Ñ# CÓ(¬C°·	±	¸*ÀbÓ0IÓ,J×,QÑ,QÐRUÓ,VÑV÷ 
×	×	Ñ	ñ ús   ˜"B»<BÂB	Úmeasured_decode_tok_sc               ó0   € V ^8„  d   QhRRRRRRRRRRR	R
/# )r   r0   r   r9   Úsession_tokensr   Úcurrent_windowrD   zfloat | Noner   z
int | Noner   )r   s   "r	   r   r   ?   sA   € ÷ Qñ Q ð Q°#ð QÀsð QØ&)ðQà-9ðQàEOñQr   c          
     ó®  a a€ ^ RI HpHpHpHp ^ RIHp	 ^ RIHp
H	p ^ RI
HoHp ^ RIHp ^ RIHpHpHp V! 4       pVe   \'        V4      '       g   R# \)        V V3R lV! 4        4       R4      pVf   R#  V! V! V4      4      p TP3                  S 4      pT! RR7      pT	! T
! TT4      TTTTTRR7      pTP6                  R8w  g   TP8                  '       g/   \.        P1                  RS TP6                  TP:                  4       R# T! 4       P=                  S 4      pTRJ;'       d)    TP>                  ;'       g    / P=                  R4      R8H  pT! TTTTR7      ;'       g    ^ pT! TTR7      pT! TT\A        4       TP8                  TR7      pTe.   TPB                  '       g   TPD                  TP8                  8  d   \.        P1                  RS 4       R# \.        PG                  RS TP:                  4       \I        S TP8                  4       T! 4       '       g   \.        PK                  RS 4       R# T! 4       P=                  S 4      pTe   TPD                  TP8                  8  d   \.        PK                  RS 4       R# TPD                  #   \*        \,        3 d#   p\.        P1                  R	S T4        Rp?R# Rp?ii ; i  \4         d    R
p EL=i ; i)uZ  One growth evaluation + execution. Returns the NEW window when the ladder granted a bigger
one, else None (hold / compress / not ours).

The caller sits at a request boundary by construction (the pre-API compression gate), so
re-prefill growth is safe at any call: the next request rebuilds server state in the larger
window â€” nothing rewinds.
)Ú_launch_budgetÚget_supervisorÚrefresh_local_runtimeÚstaged_models)Úgrowth_decision)Ú	as_loadedÚprofile_from_gguf)Úmodel_id_from_stemÚread_gguf_header)Úprobe_budget)Úpreset_for_modelÚread_preset_decisionsÚresident_footprintNc              3  óZ   <"  € T F   pS! VP                   4      S8X  g   K  Vx € K"  	  R # 5ir3   )Ústem)Ú.0Úpr0   rP   s   & €€r	   Ú	<genexpr>Ú$maybe_grow_window.<locals>.<genexpr>V   s$   øé € ÐV™O�qÑ/AÀ!Ç&Á&Ó/IÈXÑ/U—’›Oùs   ƒ+¡
+z$growth skip %s: unreadable gguf (%s)FT)Úplanning)rG   rF   rD   Úserver_idleÚoccupancy_confirmedÚgrowzgrowth %s: %s (%s)z	spec-typezdraft-dflash)Údrafting)Ú	own_bytes)Úrequested_windowÚlivezGgrowth %s: the next rung does not fit beside other programs' GPU memoryzcontext growth %s: %sz6growth %s: server refresh failed; compression proceedsz>growth %s: refreshed preset did not grant the requested window)&Ú"hermes_cli.local_runtime.bootstraprI   rJ   rK   rL   Ú'hermes_cli.local_runtime.context_policyrM   Ú"hermes_cli.local_runtime.estimatorrN   rO   Úhermes_cli.local_runtime.ggufrP   rQ   Ú!hermes_cli.local_runtime.hardwarerR   Ú hermes_cli.local_runtime.presetsrS   rT   rU   rC   ÚnextÚ
ValueErrorÚOSErrorÚloggerÚdebugÚis_idler   ÚactionÚnext_windowÚreasonrA   ÚkeysÚsetÚrefusalr1   Úinfor4   Úwarning)r0   r9   rF   rG   rD   rI   rJ   rK   rL   rM   rN   rO   rQ   rR   rS   rT   rU   ÚsupÚggufÚprofileÚexcr]   ÚbudgetÚdecisionÚrunningr`   ra   rc   ÚplanÚmaterializedrP   s   f$$$$                         @r	   Úmaybe_grow_windowr�   ?   s{  ù€ ÷Nó NåGßOßRÝ>÷Eñ Eñ Ó
€CØ
‚{Ô-¨h×7Ò7ÙäÕV™MœOÓVÐX\Ó]€DØ‚|ÙðÙ#Ñ$4°TÓ$:Ó;ˆð
Ø—k‘k (Ó+ˆñ  4Ô(€FÙñ 	�'˜6Ó" FØ%Ø%Ø3Øð !ô€Hð ‡�˜&Ô ¨×(<×(<Ð(<Ü�‰Ð)¨8°X·_±_ÀhÇoÁoÔVÙñ
 $Ó%×)Ñ)¨(Ó3€GØ˜dÐ"×^Ð^¨¯©×(:Ð(:¸×'?Ñ'?ÀÓ'LÐP^Ñ'^€HÙ" 4¨°È(ÔS×XÐXÐWX€IÙ˜&¨IÔ6€DÙ˜D &¬#«%À(×BVÑBVÐ]aÔb€DØ‚|�t—|—|�| t§{¡{°X×5IÑ5IÔ'IÜ�‰Ð^Øô	áä
‡K�KÐ'¨°8·?±?ÔCÜ˜ 8×#7Ñ#7Ô8Ù ×"Ò"ô 	�‰ÐOÐQYÔZÙÙ(Ó*×.Ñ.¨xÓ8€LØÒ˜|×2Ñ2°X×5IÑ5IÔIÜ�‰ÐWÐYaÔbÙØ×ÑÐøôi œÐ ô Ü�‰Ð;¸XÀsÔKÝûðûô ô Ø‹ðús*   Á6J ÂK ÊK ÊJ;Ê;K ËKËK)Ú__doc__Ú
__future__r   Ú
contextlibr   r   ÚloggingÚ	getLoggerÚ__name__rm   r
   r!   r.   r4   r7   rC   r�   r   r   r	   Ú<module>rˆ      s\   ðñõ #å Û Û à	×	Ò	˜8Ó	$€ò5õõGõ õ$õðQà<@÷Qñ Qr   