+
    „WÝj  ã                  óÆ   a € 0 t $ R t^ RIHt ^ RIt^ RIHt ^ RIHtH	t	H
t
Ht ^ RIHt ^ RIHt ^ RIHt ^ RIHt / tR	]R
&   / tR]R&   R R ltR R ltRRR/R R llltR# )uƒ  The effective USER config: config.yaml + managed overlay + ``${VAR}`` expansion, no defaults.

``load_config()`` merges ``DEFAULT_CONFIG`` first, which is wrong for readers that treat a
missing key as "unset" (the gateway's presence-sensitive env bridge, ``cfg == {}`` sentinels,
cron model pinning) â€” so nine surfaces used to hand-roll raw-read â†’ overlay â†’ expand in
differing orders and none of them replayed the model-key canonicalization or the last-known-good
recovery ``load_config()`` gained. This module is that one primitive.

Order matches ``_load_config_impl``: the user layer is expanded BEFORE the managed overlay so a
managed ``${VAR}`` resolves against the process environment only (``apply_managed_overlay``
expands it) and can never be re-resolved through a profile's secret scope
(docs/design/managed-scope.md Â§4.1). ``read_user_config_raw`` stays the write-back primitive.
)ÚannotationsN)ÚPath)ÚAnyÚDictÚOptionalÚTuple)Úconfig)Úmanaged_scope)Ú_warn_config_parse_failure)Úfast_safe_loadzdict[str, dict[str, Any]]Ú_LAST_GOOD_USER_RAWzdict[str, tuple[Any, ...]]Ú_EFFECTIVE_CACHEc               ó    € V ^8„  d   QhRRRR/# )é   Úrawúdict[str, Any]Úreturn© )Úformats   "ÚOC:\Users\johnn\AppData\Local\hermes\hermes-agent\hermes_cli\config_effective.pyÚ__annotate__r   !   s   € ÷ Zñ Z�Nð Z ~ñ Zó    c                óî   € \         P                  ! V 4      p\        P                  ! \	        V\
        4      '       d   TM/ 4      p\         P                  ! \	        V\
        4      '       d   V4      # / 4      # ©N)Ú_configÚ_expand_env_varsr	   Úapply_managed_overlayÚ
isinstanceÚdictÚ_normalize_root_model_keys)r   ÚexpandedÚmergeds   &  r   Ú
_effectiver"   !   sX   € Ü×'Ò'¨Ó,€HÜ×0Ò0¼ZÈÔRV×=WÒ=W±Ð]_Ó`€FÜ×-Ò-¼
À6Ì4×8PÒ8P¨fÓYÐYÐVXÓYÐYr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   Úconfig_pathr   Úpath_keyÚstrÚexcÚ	Exceptionr   r   r   )r   s   "r   r   r   '   s(   € ÷ 
9ñ 
9 4ð 
9°3ð 
9¸Yð 
9È>ñ 
9r   c                ó¶   € \         P                  V4      pRpVf   ^ RIHp V! V 4      pRp\	        YVe   TMRR7       Ve   \
        P                  ! V4      # / # )z«Last-known-good raw user mapping after a parse failure: this process's last good parse,
else the newest ``good`` copy in backups/config/, else ``{}`` (warned as defaults).zlast-known-good)Úload_newest_good_backupzlast-known-good-backupÚdefaults)Úfallback)r   ÚgetÚhermes_cli.config_backupsr*   r
   ÚcopyÚdeepcopy)r$   r%   r'   r   r,   r*   s   &&&   r   Ú_recover_user_rawr1   '   sY   € ô ×
!Ñ
! (Ó
+€CØ €HØ
‚{ÝEÙ% kÓ2ˆØ+ˆÜ˜{ÀcÂo¹(Ð[eÕfØ!$¢Œ4�=Š=˜ÓÐ8°bÐ8r   Úfail_closedFc               ó$   € V ^8„  d   QhRRRRRR/# )r   r$   zOptional[Path]r2   Úboolr   r   r   )r   s   "r   r   r   4   s(   € ÷ @ñ @¨Nð @ÐSWð @Ðdrñ @r   c          	     óÂ  € ^ RI Hp V! 4       pVe   \        V4      # V f   \        P                  ! 4       p \        V 4      p\        P                  ;_uu_ 4        \        P                  ! V 4      w  rV\        P                  V4      pVež   Veš   VR,          V8X  dŒ   \        ;QJ d1    R V^	,          P                  4        4       F  '       d   K   RM&	  RM"! R V^	,          P                  4        4       4      '       d(   \        P                  ! V^,          4      uuRRR4       # / pRp	\        P                  P                  V4      p
Ve[   V
eW   V
R,          V8X  dI   \        P                  ! V
^,          4      p\        P!                  V\        P                  ! V4      4       MºVe·    \#        V RR	7      ;_uu_ 4       p\%        V4      pRRR4       \'        X\(        4      '       d   TM/ p. VO\        P                  ! V4      N5\        P                  V&   \        P                  ! V4      \        V&   V \        P                  ! 4       8X  d   ^ R
IHp V! V R4       \        P2                  ! V4      p\4        P6                  ! 4       pV'       d   \        P2                  ! VV4       \        V4      pVe.   V	'       g&   . VO\        P                  ! V4      NVN5\        V&   M\        P9                  VR4       VuuRRR4       #   + '       g   i     ELE; i  \.         d!   pT'       d   h \1        YT4      Rr˜ Rp?LâRp?ii ; i  + '       g   i     R# ; i)u2  User ``config.yaml`` â†’ ``${VAR}`` expansion â†’ managed overlay â†’ model-key canonicalization.
NO ``DEFAULT_CONFIG`` merge: a key absent from the file (and from the managed layer) is absent
here, so ``{}`` sentinels and presence-sensitive bridges keep working. An absent file is an
empty user layer (the managed layer still applies). Returns a fresh deepcopy.

Broken YAML: ``fail_closed=True`` raises the parse error (for callers that keep their own
last-good state); otherwise the last successfully parsed user file â€” in-process first, then
the newest ``backups/config/*.good.*`` copy â€” is served through the same pipeline, so a
mid-edit torn write never silently drops user overrides (same contract as ``load_config``).
Cached on the user + managed file signatures and the values of every referenced env var.)Úworker_config_snapshotN:Né   Nc              3  óX   "  € T F   w  r\         P                  ! V4      V8H  x € K"  	  R # 5ir   )r   Ú_env_ref_lookup)Ú.0ÚkÚvs   &  r   Ú	<genexpr>Ú-load_user_config_effective.<locals>.<genexpr>M   s$   é € ÐQÑ?P±t°q”7×*Ò*¨1Ó-°Ö2Ó?Pùs   ‚(*FT:Né   Nz	utf-8-sig)Úencoding)Úbackup_configÚgood)Úagent.safe_worker_policyr6   r"   r   Úget_config_pathr&   Ú_CONFIG_LOCKÚ_load_config_cache_sigr   r-   ÚallÚitemsr/   r0   Ú_RAW_CONFIG_CACHEr   Ú
setdefaultÚopenr   r   r   r.   rA   r(   r1   Ú_env_ref_snapshotr	   Úload_managed_configÚpop)r$   r2   r6   Úsnapshotr%   Úuser_sigÚ	cache_sigÚcachedr   Ú	recoveredÚraw_hitÚfÚloadedrA   r'   Úenv_snapshotÚmanagedÚ	effectives   &$                r   Úload_user_config_effectiverZ   4   s�  € õ @ñ &Ó'€HØÒÜ˜(Ó#Ð#ØÒÜ×-Ò-Ó/ˆÜ�;Ó€HÜ	×	×	Ó	Ü%×<Ò<¸[ÓIÑˆÜ!×%Ñ% hÓ/ˆØÒ )Ò"7¸FÀ2½JÈ)Ô<Sß‹sÑQ¸vÀa½y¿¹Ô?PÓQ�s�sŠsÑQ¸vÀa½y¿¹Ô?PÓQ×QÒQÜ—}’} V¨A¥YÓ/÷ 
Ò	ð !ˆØˆ	Ü×+Ñ+×/Ñ/°Ó9ˆØÒ GÒ$7¸GÀB½KÈ8Ô<SÜ—-’- ¨¥
Ó+ˆCÜ×*Ñ*¨8´T·]²]À3Ó5GÕHØÒ!ð7Ü˜+°×<Õ<ÀÜ+¨AÓ.�F÷ =ô !+¨6´4× 8Ò 8‘f¸b�Ø6U¸Ð6UÄ$Ç-Â-ÐPSÓBTÑ6U”×)Ñ)¨(Ñ3Ü04·²¸cÓ0BÔ# HÑ-ð ¤'×"9Ò"9Ó";Ô;ÝGÙ! +¨vÔ6ä×0Ò0°Ó5ˆÜ×3Ò3Ó5ˆßÜ×%Ò% g¨|Ô<Ü˜s“Oˆ	ð Ò ¯Ø)]¨9Ð)]´d·m²mÀIÓ6NÐ)]ÐP\Ñ)]Ô˜XÒ&ä× Ñ  ¨4Ô0Ø÷W 
Ò	÷ =×<Ð<ûäô UßØÜ!2°;È#Ó!NÐPT•YûðUú÷# 
×	Ð	úsu   ÁAMÂ(&MÃ/MÄMÄ(BMÆ.LÇL	ÇLÇB>MÊ-MË<MÌLÌ	LÌM
Ì*MÍ MÍM
Í
MÍM	r   )Ú__conditional_annotations__Ú__doc__Ú
__future__r   r/   Úpathlibr   Útypingr   r   r   r   Ú
hermes_clir   r   r	   Úhermes_cli.config_read_errorsr
   Úutilsr   r   Ú__annotations__r   r"   r1   rZ   )r[   s   @r   Ú<module>rd      sb   øðôõ #ã Ý ß -Ó -å (Ý $Ý DÝ  ð 24Ð Ð.Ó 3à/1Ð Ð,Ó 1õZõ
9ñ@ÐZ_÷ @ò @r   