
    ci
                     &   U d Z ddlZddlZej                  j	                  ej                  j                  ej                  j                  e            ddd      ZddhZ	ddd	Z
eed
<   defdZdededdfdZdedefdZdedefdZdedefdZy)u   
gate_config_loader.py — gate-config.json 중앙 설정 로더

경로: __file__ 기준으로 ../config/gate-config.json 계산.
캐싱 없음: 매 호출마다 파일을 읽어 즉시 설정 변경 반영.
    Nz..configzgate-config.jsonwarnfailF)enabledmode_DEFAULT_GATEreturnc                  >   t         j                  j                  t              } 	 t	        | dd      5 }t        j                  |      }ddd       |S # 1 sw Y   S xY w# t        $ r t        d|        t
        j                  $ r}t        d|       d}~ww xY w)uY   gate-config.json 전체를 파싱해 반환. 파일 없거나 JSON 오류 시 ValueError.rzutf-8)encodingNu4   gate-config.json 파일을 찾을 수 없습니다: u%   gate-config.json JSON 파싱 오류: )
ospathnormpath_CONFIG_PATHopenjsonloadFileNotFoundError
ValueErrorJSONDecodeError)config_pathfdataes       //home/jay/workspace/utils/gate_config_loader.py	_load_rawr      s    ''""<0K

+sW5 	 99Q<D	  K	  K  
B;-P
 	
  
3A37
 	

s4   A  A	A  AA  A   )B	BB	gate_namegate_cfgc           	          d|v r:t        |d   t              s't        d|  dt        |d         j                        d|v r |d   t
        vrt        d|  d|d         yy)uC   개별 게이트 설정의 구조를 검증. 위반 시 ValueError.r   u   게이트 'u7   '의 enabled 필드는 bool 타입이어야 합니다: r   u=   '의 mode 필드는 'warn' 또는 'fail'이어야 합니다: N)
isinstanceboolr   type__name___VALID_MODES)r   r   s     r   _validate_gater%   (   s    H(9-t4i[(_+,558:  F</i[(eF#&(  0     c                     t               }|j                  di       }|j                  |       }|t        t              S t	        | |       t        |      S )u   
    gate-config.json에서 특정 게이트 설정을 dict로 반환.
    존재하지 않는 게이트 → {"enabled": False, "mode": "warn"} 반환.
    gates)r   getdictr   r%   )r   r   r(   r   s       r   load_gate_configr+   8   sN    
 ;D((7B'Eyy#HM""9h'>r&   c                 N    t        |       }t        |j                  dd            S )uL   
    게이트 활성화 여부 반환.
    없는 게이트 → False.
    r   F)r+   r!   r)   r   cfgs     r   is_gate_enabledr/   F   s$    
 9
%C	5)**r&   c                 <    t        |       }|j                  dd      S )uR   
    게이트 모드("warn"/"fail") 반환.
    없는 게이트 → "warn".
    r   r   )r+   r)   r-   s     r   get_gate_moder1   O   s    
 9
%C7766""r&   )__doc__r   r   r   joindirnameabspath__file__r   r$   r   r*   __annotations__r   strr%   r+   r!   r/   r1    r&   r   <module>r:      s     	ww||GGOOBGGOOH-.	 "'8t 84 "c T d    +s +t +#S #S #r&   