+
    jHàj)"  ã                   óö   € R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
 ]P                  ! ]4      tRR/R R lltRRRR/R	 R
 ll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/R R lltR# )z•Durable serve/dashboard restart reminders (manual serves, and unit-owned ones the update could not
restart), independent of gateway restart receipts.N)ÚPath)Úget_hermes_homeÚrequire_aliveFc                ó<   € V ^8„  d   QhR\         R\        R\        /# )é   Úruntimer   Úreturn©ÚdictÚbool)Úformats   "ÚH/home/ubuntu/.hermes/hermes-agent/hermes_cli/update_serve_obligations.pyÚ__annotate__r      s&   € ÷ Cñ C¤ð C¼ð CÌñ Có    c               óð   € V P                  R4      R	9  g-   V P                  R4      R8w  g   V P                  R4      R8w  d   R# \        V P                  R4      \        4      '       g   R# \        WR7      # )
zJTransfer an identified manual runtime to its own durable restart reminder.ÚkindÚ
supervisorúmanual-serveÚrestart_viazrespawn-argvFÚdetail)r   ©ÚserveÚ	dashboard)ÚgetÚ
isinstancer
   Ú_defer_identified)r   r   s   &$r   Údefer_manual_server      sq   € à‡{�{�6ÓÐ"8Ô8¸G¿K¹KÈÓ<UÐYgÔ<gÐkr×kvÑkvð  xEó  lFð  JXô  lXÙÜ�g—k‘k (Ó+¬T×2Ò2ÙÜ˜WÔBÐBr   Úextrac                óV   € V ^8„  d   QhR\         R\         R,          R\        R\        /# )r   r   r   Nr   r   r	   )r   s   "r   r   r      s.   € ÷ ñ œtð ¬t°d­{ð ÔRVð Ôcgñ r   c          
     ó†  € ^ RI Hp V P                  R4      V R,          P                  R4      rT\        V4      \        Jg   V^ 8:  d   R# \        V4      \        \
        39   ;'       d$    \        P                  ! V4      ;'       d    V^ 8„  pV'       g   V'       * ;'       d    V! VR4      RJ #  V! WE4      pV'       d	   VRJd   R# VRJ d   R# \        RV R,          R	V P                  R	R
4      RVRV/T;'       g    / C4       R#   \        \        \        3 d"   p\        P                  RT4        Rp?R# Rp?ii ; i)z¾Shared tail of the manual and unit deferrals: True when the incarnation is gone or its reminder
(plus *extra* fields) was filed; False while it is still owed and nothing durable was written.©Ú_pid_alive_matchesÚpidr   Úcreate_timeFNTr   ÚprofileÚunknownz/Could not preserve serve restart obligation: %s)Úhermes_cli.process_identityr!   r   ÚtypeÚintÚfloatÚmathÚisfiniteÚ_write_reminderÚOSErrorÚ
ValueErrorÚ	TypeErrorÚloggerÚdebug)	r   r   r   r!   r"   ÚcreatedÚ
identifiedÚaliveÚexcs	   &$$      r   r   r      s"  € õ ?à—;‘;˜uÓ% w¨xÕ'8×'<Ñ'<¸]Ó'KˆÜˆCƒyœÓ˜s aœxÙÜ�g“¤3¬ ,Ñ.×YÐY´4·=²=ÀÓ3I×YÐYÈgÐXYÉk€Jßð !Ô ×KÐKÑ%7¸¸TÓ%BÀeÐ%KÐKðÙ" 3Ó0ˆß˜U¨$Ó.ÙØ�E‹>ÙÜ˜ ¨¥°)¸W¿[¹[ÈÐT]Ó=^Ð`eÐgjØ&¨ðBØ49·K°K¸RðBô 	CáøÜ”Z¤Ð+ô Ü�‰ÐFÈÔLÝûðús*   Â1D	 Ã	D	 Ã-D	 Ã?D	 Ä	E ÄD;Ä;E c                ó(   € V ^8„  d   QhR\         RR/# )r   Úrowr   N)r
   )r   s   "r   r   r   5   s   € ÷ .ñ .œð . $ñ .r   c                óˆ  € \        4       R,          pVP                  RRR7       WR,           R\        V R,          4      P                  4        R2,          pRp \        P
                  ! R	R
VRR7      ;_uu_ 4       p\        VP                  4      p\        P                  ! W4       VP                  4        \        P                  ! VP                  4       4       RRR4       \        P                  ! W24       Ve   VP                  RR7       R# R#   + '       g   i     L@; i  Te   TP                  RR7       i i ; i)z¡Persist one reminder row, one immutable file per incarnation (no read/merge/write races
between CLI startups). Raises OSError/ValueError/TypeError to the caller.Úserve_restart_pendingT)ÚparentsÚexist_okr"   Ú-r#   z.jsonNÚwzutf-8F)ÚmodeÚencodingÚdirÚdelete©Ú
missing_ok)r   Úmkdirr)   ÚhexÚtempfileÚNamedTemporaryFiler   ÚnameÚjsonÚdumpÚflushÚosÚfsyncÚfilenoÚreplaceÚunlink)r7   Ú	directoryÚtargetÚ	temporaryÚhandles   &    r   r,   r,   5   s  € ô  Ó!Ð$;Õ;€IØ‡O�O˜D¨4€OÔ0Ø �J˜< q¬¨s°=Õ/AÓ)B×)FÑ)FÓ)HÐ(IÈÐOÕO€FØ€Ið	.Ü×(Ò(¨c¸GÈÐ[`×aÕaÐekÜ˜VŸ[™[Ó)ˆIÜ�IŠI�cÔ"Ø�L‰LŒNÜ�HŠH�V—]‘]“_Ô%÷	 bô
 	�
Š
�9Ô%àÒ Ø×Ñ¨ÐÖ-ñ !÷ b×aûð Ò Ø×Ñ¨ÐÕ-ð !ús%   Á"D( Á=A DÃD( ÄD%	Ä D( Ä(Ec                ó0   € V ^8„  d   QhR\         R\        /# ©r   r7   r   ©Úobjectr   )r   s   "r   r   r   H   s   € ÷ añ aœ6ð a¤dñ ar   c                ó2  € \        V \        4      ;'       d�    V P                  R4      R9   ;'       de    V P                  R4      R8H  ;'       dI    \        V P                  R4      \        4      ;'       d"    \        V R,          P                  R4      4      # )z]A serve/dashboard row whose systemd unit owns it (MainPID), with the unit recorded (#141021).r   r   Úsystemdr   Úsystemd_unitr   )r   r
   r   r   ©r7   s   &r   Úis_unit_serve_rowr]   H   s‘   € ä�sœDÓ!÷ `ð ` c§g¡g¨f£oÐ9OÑ&O÷ `ð `ÐTW×T[ÑT[Ð\hÓTiÐmvÑTv÷ `ð `Ü˜3Ÿ7™7 8Ó,¬dÓ3÷`ð `Ü8<¸SÀ½]×=NÑ=NÈ~Ó=^Ó8_ðar   c                ó0   € V ^8„  d   QhR\         R\        /# rV   rW   )r   s   "r   r   r   N   s   € ÷ yñ yœð y¤Dñ yr   c                ó¸   € \        V 4      ;'       gI    \        V \        4      ;'       d1    V P                  R4      R9   ;'       d    V P                  R4      R8H  # )zSRows the receipt-backed reminder flow carries: manual serves and unit-owned serves.r   r   r   r   )r]   r   r
   r   r\   s   &r   Úis_reminder_rowr`   N   sW   € ä˜SÓ!÷ yð yÜ�3œÓ×wÐw #§'¡'¨&£/Ð5KÑ"K×wÐwÐPS×PWÑPWÐXdÓPeÐiwÑPwðyr   c                ó0   € V ^8„  d   QhR\         R\        /# )r   r   r   r	   )r   s   "r   r   r   T   s   € ÷ iñ iœdð i¤tñ ir   c           
     ó°   € ^ RI Hp \        V 4      '       g   R# V R,          p\        V RV! \	        VR,          4      VP                  R4      4      /R7      # )a?  The unit-owned twin of :func:`defer_manual_serve`: file a durable reminder carrying the unit's
restart command for a pre-update incarnation that is still alive. A unit-owned row moved off the
manual-serve reminder when it was classified ``systemd`` (#141021), and the fleet obligation names
only gateways, so without this a unit the update could not restart (no root, an aborted run,
``--no-gateway-restart``) is never mentioned again. True when the row is discharged (process gone)
or the reminder was filed; False when it is still owed and nothing durable could be written.)Ú_systemd_restart_commandsFr   Úrestartr[   Úsystemd_scope)r   )Úhermes_cli.main_dashboardrc   r]   r   Ústrr   )r   rc   r   s   &  r   Údefer_unit_serverh   T   sX   € õ Dä˜W×%Ò%ÙØ�XÕ€FÜ˜WØÑ,¬S°¸Õ1GÓ-HÈ&Ï*É*ÐUdÓJeÓfð-hô ið ir   c                óF   € V ^8„  d   QhR\         R\        \         ,          /# )r   Úreceiptr   )r
   Úlist)r   s   "r   r   r   d   s   € ÷ ñ ¬$ð ´4¼µ:ñ r   c                óü  € V P                  R4      ;'       g    / p\        VP                  R4      ;'       g    . 4      \        V P                  R4      ;'       g    . 4      ,           pT\        V P                  R4      ;'       g    . 4      ,          p. pV F`  p\        V4      '       g   K  \        V4      '       d   \	        V4      M
\        V4      pV'       d   KG  WC9  g   KO  VP                  V4       Kb  	  V# )a•  Return transfers still owed so receipt rotation cannot discard failed writes.

Covers manual serves and unit-owned serves (:func:`is_reminder_row`); the name predates the latter.
``carried_manual_serves`` is the durable running record's copy of the previous receipt's rows
(update_receipt.begin): read it too, or the warning vanishes while an update runs and after a
run killed before its ``plan`` stage.
ÚplanÚruntimesÚpending_manual_servesÚcarried_manual_serves)r   rk   r`   r]   rh   r   Úappend)rj   rm   ÚrowsÚpendingr7   Údeferreds   &     r   Úretain_receipt_manual_servesru   d   sË   € ð �;‰;�vÓ×$Ð$ "€DÜ�—‘˜Ó$×*Ð*¨Ó+¬d°7·;±;Ð?VÓ3W×3]Ð3]Ð[]Ó.^Õ^€DØŒD�—‘Ð4Ó5×;Ð;¸Ó<Õ<€DØ€GÛˆÜ˜s×#Ò#ÙÜ,=¸c×,BÒ,BÔ# CÔ(ÔHZÐ[^ÓH_ˆß‰x˜CÖ.Ø�N‰N˜3Öñ ð €Nr   ÚstartupÚpending_manualc                óX   € V ^8„  d   QhR\         R\        \        ,          R,          RR/# )r   rv   rw   Nr   )r   rk   r
   )r   s   "r   r   r   y   s1   € ÷ %jñ %j¬4ð %jÌÌdÍÐVZÕIZð %jÐfjñ %jr   c                ó(  € ^ RI HpHp ^ RIHp ^ RIHp V '       d   \        P                  M\        P                  pVf   \        V! 4       ;'       g    / 4      pV EF   p\        V4      p\        RVR,           RVP                  RR	4       R
VP                  RR	4       RV'       d   RMR R2	VR7       \        VP                  R4      \        4      '       d   VP                  R4      M/ p	V'       dA   V! \!        V	R,          4      V	P                  R4      4      p
\        RV! V
4       2VR7       KÚ  \#        V	P                  R4      4      \$        \&        39   d   \        RVR7       EK  \        RVR7       EK#  	  \)        4       R,          p\+        VP-                  R4      4       EF  p \.        P0                  ! VP3                  RR7      4      pV! VR,          VR,          4      RJ d   VP5                  RR7       KZ  VP                  R4      p\        V\6        4      '       dM   V'       dE   \        RVR,           RVR,           R
VR,           R 2VR7       \        RV! V4       2VR7       KÍ  \        RVR,           RVR,           R
VR,           R!2VR7       \        R"VR7       EK	  	  R#   \8        \:        \<        \>        3 d=   p\@        PC                  R#YÎ4       \        R$TPD                   2TR7        Rp?EK_  Rp?ii ; i)%ziWarn about manual debt independently of gateway evidence; optionally reuse a snapshot's failed transfers.)Ú_format_restart_commandsrc   r    )Úread_latest_receiptNu     âš  r   z [r$   r%   z] pid r"   z: ÚunitÚmanualzT restart reminder could not be saved; restart remains pending in the update receipt.)Úfiler   r[   re   z    Restart its unit: r#   zu    Ask its owner to relaunch `hermes serve` / `hermes dashboard`; check reminder storage permissions and free space.zÔ    This host could not read the process creation time, so no durable reminder could be filed; ask its owner to relaunch `hermes serve` / `hermes dashboard`, and the warning clears once the pid is confirmed gone.r9   z*.jsonz	utf-8-sig)r?   FTrB   rd   zK: unit restart still pending; this process may still serve pre-update code.zM: manual restart still pending; this process may still serve pre-update code.zi    Ask its owner to relaunch `hermes serve` / `hermes dashboard` (reconnect Desktop for an SSH backend).z2Could not reconcile manual serve obligation %s: %su;     âš  Manual serve restart reminder could not be verified: )#rf   rz   rc   r&   r!   Úhermes_cli.update_receiptr{   ÚsysÚstderrÚstdoutru   r]   Úprintr   r   r
   rg   r'   r(   r)   r   ÚsortedÚglobrI   ÚloadsÚ	read_textrP   rk   r-   r.   ÚKeyErrorr/   r0   r1   rH   )rv   rw   rz   rc   r!   r{   Ústreamr7   Úunit_rowr   ÚcommandsrQ   Úpathrd   r5   s   $$             r   Úwarn_pending_manual_servesr�   y   sê  € ç]Ý>Ý=ç"ŒS�ZŠZ¬¯
©
€FØÒÜ5Ñ6IÓ6K×6QÐ6QÈrÓRˆÜˆÜ$ SÓ)ˆÜ��s˜6•{�m 2 c§g¡g¨i¸Ó&CÐ%DÀFÈ3Ï7É7ÐSXÐZcÓKdÐJeÐeg×rzÑhnð  AIð  hJð  J^ð  _ð  flõ  	mÜ&0°·±¸Ó1BÄD×&IÒ&I�—‘˜Ô"ÈrˆßÙ0´°V¸NÕ5KÓ1LÈfÏjÉjÐYhÓNiÓjˆHÜÐ*Ñ+CÀHÓ+MÐ*NÐOÐV\×]Ü�&—*‘*˜]Ó+Ó,´´e°Ô<Üð  Jð  QW÷  Xð  Xô ð  ið  pv÷  wð  wñ ô  Ó!Ð$;Õ;€IÜ�y—~‘~ hÓ/×0ˆð	jÜ—*’*˜TŸ^™^°[˜^ÓAÓBˆCÙ! # e¥*¨c°-Õ.@ÓAÀUÓJØ—‘ t�Ô,ÙØ—g‘g˜iÓ(ˆGÜ˜'¤4×(Ò(¯WÜ˜˜s 6�{˜m¨2¨c°)­nÐ-=¸VÀCÈÅJÀ<ð  P[ð  \ð  ciõ  jÜÐ.Ñ/GÈÓ/PÐ.QÐRÐY_Õ`ÙÜ�F˜3˜v�;˜- r¨#¨i­.Ð)9¸ÀÀEÅ
¸|ð  LYð  Zð  agõ  hÜÐ}ð  EK÷  Lð  Ló 1øô œ¤X¬yÐ9ô 	jÜ�L‰LÐMÈtÔYÜÐOÐPT×PYÑPYÈ{Ð[Ðbh×iÔiûð	jús,   Æ2AJ:È.J:È6AJ:É:9J:Ê:LË0LÌL)Ú__doc__rI   Úloggingr*   rL   r€   rF   Úpathlibr   Úhermes_constantsr   Ú	getLoggerÚ__name__r0   r   r   r,   r]   r`   rh   ru   r�   © r   r   Ú<module>r•      s�   ðñ6ó Û Û Û 	Û 
Û Ý å ,à	×	Ò	˜8Ó	$€ðC¸u÷ Cð¸Tð ÐY^÷ õ6.õ&aõyõiõ ð*%j°%ð %jÐ]a÷ %jñ %jr   