+
    „WÝjf  ã                  óR  a € 0 t $ R t^ RIHt ^ RIt^ RIt^ RIHt ^ RIH	t	H
t
 ^ RIHt ]P                  ! ]4      t]! 4       tR]R&   / tR]R	&   R
RRRRR/tRtRtRtRtR R ltR R ltRR/R R lltRR/R R lltR R lt ! R  R!]4      tR" R# lt R$ R% lt!R& R' lt"R( R) lt#R# )*a±  What Hermes does when an existing ``config.yaml`` cannot be read or parsed.

Readers fail open (``{}`` / defaults / last-known-good) so a broken file never takes the process
down; this module makes that fallback loud (one warning per file signature, a ``corrupt`` backup),
remembers the failure for :func:`get_active_config_parse_failure`, and marks every fallback as a
:class:`FailedConfigRead` so the writers refuse to persist it.
)ÚannotationsN)ÚPath)ÚAnyÚOptional)Úfile_signatureÚsetÚ_CONFIG_PARSE_WARNEDÚdictÚ_CONFIG_PARSE_FAILURESzlast-known-goodzqHermes is running on the settings it loaded before the edit until it is fixed, so recent changes are not applied.zlast-known-good-backupzbHermes is running on your last good settings until it is fixed, so recent changes are not applied.zrefuse-writez7Nothing was written, so the existing file is preserved.zdHermes is running on default settings until it is fixed, so none of your saved settings are applied.zOOpen it with `hermes config edit`, fix {where}, then run `hermes config check`.z0Fix the file permissions or move it aside first.z„Fix it with `hermes config edit` and check with `hermes config check`, or copy the newest good file from {backups} over config.yaml.c               ó    € V ^8„  d   QhRRRR/# ©é   ÚexcÚ	ExceptionÚreturnÚstr© )Úformats   "ÚQC:\Users\johnn\AppData\Local\hermes\hermes-agent\hermes_cli\config_read_errors.pyÚ__annotate__r   +   s   € ÷ ?ñ ?˜ið ?¨Cñ ?ó    c                ó¨   € \        V RR4      ;'       g    \        V RR4      p\        VRR4      p\        V\        4      '       d   RV^,            2# R# )z@``"line 12"`` from a PyYAML problem mark (1-based), else ``""``.Úproblem_markNÚcontext_markÚlinezline Ú )ÚgetattrÚ
isinstanceÚint)r   Úmarkr   s   &  r   Ú_yaml_error_locationr    +   sQ   € ä�3˜¨Ó-×SÐS´¸¸nÈdÓ1S€DÜ�4˜ Ó&€DÜ!+¨D´#×!6Ò!6ˆU�4˜!•8�*ÐÐ>¸BÐ>r   c               ó    € V ^8„  d   QhRRRR/# r   r   )r   s   "r   r   r   2   s   € ÷ "ñ "˜Yð "¨3ñ "r   c                ó¢   € \        V RR4      pV'       d   T M\        V 4      P                  4       pRP                  VP	                  4       4      # )zQSingle-line ``Details:`` text: the PyYAML problem, or the exception's first line.ÚproblemNÚ )r   r   ÚstripÚjoinÚsplit)r   r#   Útexts   &  r   Ú_yaml_error_detailsr)   2   s;   € ä�c˜9 dÓ+€Gß"ˆg‰Y¬¨C«¯©Ó(8€DØ�8‰8�D—J‘J“LÓ!Ð!r   ÚfallbackÚdefaultsc               ó(   € V ^8„  d   QhRRRRRRRR/# )r   Úconfig_pathr   r   r   r*   r   r   r   )r   s   "r   r   r   9   s0   € ÷ 	eñ 	e¨Tð 	e¸	ð 	eÐPSð 	eÐehñ 	er   c               ó  € \        V4      pV'       d   RV 2MRp\        P                  V\        4      p\	        V\
        4      '       d   RV  RV R\        V4       2# \        P                  T;'       g    RR7      pRV  RV R	V RV 2# )
z´User copy for an unparseable config.yaml: what happened, what Hermes is doing, how to fix.
Only the problem line/column is printed; the raw PyYAML text goes to a ``Details:`` line.z at r   úYour settings file (z) could not be read. r$   zthe problem)Úwherez) has a formatting errorz. )	r    Ú_PARSE_FAILURE_FALLBACK_MSGÚgetÚ_PARSE_FAILURE_DEFAULTS_MSGr   ÚOSErrorÚ_read_error_fixÚ_PARSE_FAILURE_REPAIR_MSGr   )r-   r   r*   r0   ÚatÚfallback_msgÚrepairs   &&$    r   Úformat_config_parse_failurer:   9   sž   € ô ! Ó%€Eß ˆ4�ˆw‰ b€BÜ.×2Ñ2°8Ô=XÓY€LÜ�#”w×ÒØ% k ]Ð2GÈÀ~ÐUVÔWfÐgjÓWkÐVlÐmÐmÜ&×-Ñ-°E×4JÐ4J¸]Ð-ÓK€FØ! + Ð.FÀrÀdÈ"È\ÈNÐZ[Ð\bÐ[cÐdÐdr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   r-   r   r   r   r*   r   r   ÚNoner   )r   s   "r   r   r   E   s,   € ÷ ñ ØðØ%ðØ47ðØIMñr   c               ó¬  €  V P                  4       p\        V4      p\        V 4      .VO5p. VO\        V4      N5\        \        V 4      &   V\
        9   d   R# \
        P                  V4       ^ RIHp \        V\        4      '       d   RMV! V R4      p\        WVR7      pVe   VRV R2,          p\        P                  RV\        V4      4        \        P                  P!                  RV R	\        V4       R
24       \        P                  P#                  4        R#   \         d    \        T 4      ^ ^ ^ ^ 3p Lôi ; i  \$         d     R# i ; i)u¢  Surface a config.yaml parse failure to log and stderr (once per file signature).
Silent fallback to ``DEFAULT_CONFIG`` drops every user override, so this must be loud.

``fallback`` selects the message wording: ``"defaults"`` (fresh process, nothing else to serve) or
``"last-known-good"`` (in-process retention of the previously loaded config â€” see the codex#31188 port
in ``hermes_cli.config._load_config_impl``).
N)Úbackup_configÚcorrupt)r*   z( A copy of the broken file was saved to Ú.z%s Details: %su   âš ï¸�  hermes config: z
    Details: Ú
)Ústatr   r   r
   r4   r   ÚaddÚhermes_cli.config_backupsr>   r   r:   ÚloggerÚwarningr)   ÚsysÚstderrÚwriteÚflushr   )	r-   r   r*   ÚstÚsigÚkeyr>   Úbackup_pathÚmsgs	   &&$      r   Ú_warn_config_parse_failurerP   E   s?  € ð-Ø×ÑÓˆÜ˜RÓ ˆÜ�;ÓÐ& #Ñ&ˆØ3C°SÐ3C¼#¸c»(Ñ3CÔœs ;Ó/Ñ0ð Ô"Ô"ÙÜ×Ñ˜SÔ!Ý7ä$ S¬'×2Ò2‘$¹ÀkÐS\Ó8]€KÜ
% kÀÔ
J€CØÒØÐ9¸+¸ÀaÐHÕHˆÜ
‡N�NÐ# SÔ*=¸cÓ*BÔCðÜ�
‰
×ÑÐ2°3°%°ÔGZÐ[^ÓG_ÐF`Ð`bÐcÔdÜ�
‰
×ÑÖøô ô -Ü�;Ó  A q¨!Ð,Šð-ûô ô Úðús%   ‚A
D# ÃAE Ä#EÅ EÅEÅEc               ó   € V ^8„  d   QhRR/# )r   r   zOptional[str]r   )r   s   "r   r   r   f   s   € ÷ 	ñ 	¨ñ 	r   c                 óÒ   € ^ RI Hp   \        \        V ! 4       ;p4      ,          pVP	                  4       p\        V4      VR,          8X  d
   V^,          # R#   \         d     R# i ; i)z¤Return the recorded parse error while the ACTIVE config.yaml is still byte-identical
(mtime_ns + size + ino + ctime_ns) to the file that failed to parse; else None.)Úget_config_path:Né   NN)Úhermes_cli.configrS   r
   r   rB   r   r   )rS   ÚpathÚrecordrK   s       r   Úget_active_config_parse_failurerX   f   s_   € õ 2ðÜ'¬±OÓ4EÐ,E¨DÓ(FÕGˆØ�Y‰Y‹[ˆÜ*¨2Ó.°&¸µ*Ô<ˆv�a�yÐFÀ$ÐFøÜô Úðús   ˆAA ÁA ÁA&Á%A&c                  ó6   a € ] tR t^rtRtRR V 3R llltRtV ;t# )ÚFailedConfigReaduà  The fail-open fallback a config reader serves when an existing config.yaml could not be read
or parsed (``{}``, defaults or last-known-good). Readers use it like any dict; ``save_config`` /
``atomic_config_write`` refuse to persist it. The writer merges by deletion, so saving a fallback
after one transient EMFILE/EIO replaced the whole file with the fallback plus the caller's edit.
A dict subclass so the refusal survives the loadâ†’mutateâ†’save round trip at every call site.c               ó    € V ^8„  d   QhRRRR/# )r   Údatar   Úerrorr   r   )r   s   "r   r   ÚFailedConfigRead.__annotate__y   s   € ÷  ñ  ˜Sð  °ñ  r   c               	ó2   <€ \         SV `  V4       W n        R # )N)ÚsuperÚ__init__Ú
read_error)Úselfr\   r]   Ú	__class__s   &&$€r   ra   ÚFailedConfigRead.__init__y   s   ø€ Ü‰Ñ˜ÔØŽr   )rb   )r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ra   Ú__static_attributes__Ú__classcell__)rd   s   @r   rZ   rZ   r   s   ø† ñg÷ ÷  ð  r   rZ   c               ó    € V ^8„  d   QhRRRR/# )r   r   r4   r   r   r   )r   s   "r   r   r   ~   s   € ÷ Eñ E˜ð E Sñ Er   c                ó>   € \        V \        4      '       d   \        # R # )z9Try again; run `hermes config check` if it keeps failing.)r   ÚPermissionErrorÚ
_FIX_PERMS)r   s   &r   r5   r5   ~   s    € Ü# C¬×9Ò9Œ:ð EØCðEr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   r-   r   r\   r   r   r<   r   )r   s   "r   r   r   ƒ   s&   € ÷ fñ f Tð f°ð f¸ñ fr   c           	     óø   € \        V\        4      '       g   R# VP                  p\        V\        4      '       d   \	        V RV\        V4      4      h\	        V RV\        P                  \        4       R7      4      h)zWRefuse to save a fallback; only a read error is worth retrying, bad YAML needs an edit.Nzcould not be readzhas a formatting error)Úbackups)	r   rZ   rb   r4   Ú_refuse_overwriter5   Ú	_FIX_YAMLr   Ú_backups_dir_display)r-   r\   r   s   && r   Ú_refuse_failed_readrw   ƒ   sl   € ä�dÔ,×-Ò-ÙØ
�/‰/€CÜ�#”w×ÒÜ Ð-@À#ÄÐWZÓG[Ó\Ð\Ü
ØÐ-¨s´I×4DÑ4DÔMaÓMcÐ4DÓ4dófð fr   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
r   r-   r   Úreasonr   r   r   Úfixr   ÚRuntimeErrorr   )r   s   "r   r   r   Ž   s0   € ÷ 0ñ 0 4ð 0°ð 0¸9ð 0È3ð 0ÐS_ñ 0r   c                ó|   € \        V4      pV'       d   RV R2MRp\        RV  RV V RV R\        V4       2	4      # )z[Error for a write that must not replace an existing config.yaml. Plain lead + ``Details:``.z (Ú)r   r/   z) z , so this change was not saved. z
 Details: )r    r{   r)   )r-   ry   r   rz   r0   r7   s   &&&&  r   rt   rt   Ž   sZ   € ä  Ó%€Eßˆ2ˆeˆW�A‰ R€BÜØ
˜{˜m¨2¨f¨X°b°TÐ9YÐZ]ÐY^ð _Ü'¨Ó,Ð-ð	/ó0ð 0r   c               ó   € V ^8„  d   QhRR/# )r   r   r   r   )r   s   "r   r   r   —   s   € ÷ 6ñ 6˜cñ 6r   c                 ó"   € ^ RI Hp  V ! 4        R2# )é    ©Údisplay_hermes_homez/backups/config/)Úhermes_constantsr‚   r�   s    r   rv   rv   —   s   € Ý4Ù!Ó#Ð$Ð$4Ð5Ð5r   )$Ú__conditional_annotations__rj   Ú
__future__r   ÚloggingrG   Úpathlibr   Útypingr   r   Úutilsr   Ú	getLoggerrf   rE   r   r   Ú__annotations__r
   r1   r3   r6   rp   ru   r    r)   r:   rP   rX   r	   rZ   r5   rw   rt   rv   )r„   s   @r   Ú<module>rŒ      sÜ   øðôõ #ã Û 
Ý ß  å  à	×	Ò	˜8Ó	$€ñ  ›EÐ �cÓ !ð  "Ð ˜Ó !ð ð  KØð  CØÐMðOÐ ð
 kð àmÐ Ø?€
ð,ð 
õ
?õ"ð	eÐV`÷ 	eðØ:D÷õB	ô	 �tô 	 õEõ
fõ0÷6r   