
    j                     Z   d Z ddlZddlZddlmZmZmZmZmZ ddl	m
Z
 ddlmZmZmZmZ  ej                   e      Z e       Z ej*                  d      Z ej*                  d      Z ej*                  d      Zd	Zd
Z ej*                  d      Z ej*                  d      Z ej*                  d      Z ej*                  d      ZdZde de!de"de!fdZ#de!de$de$de%de&f
dZ'dee!ef   dee&e!f   fdZ(dee!ef   dee&e!f   fdZ)de!de*de!de%fdZ+dd d!e d"e d#eeee!ef         ddfd$Z,y)%u  G4.6 Wave A3 RC-E+RC-H — visible_entities ⊃ C##/C##O## contract validator.

ID coverage primary + dynamic entity_canon.name secondary (RO-2 강화):

- Source 1 Primary (ID coverage):
    - Forward: visible_entities 안 character base C## 모두 t2i_prompt 에
      C## 또는 C##O## 로 등장해야 함 (RC-E 핵심 — descriptor only 차단).
    - Reverse: t2i_prompt 안 사용된 ID 가 visible_entities 안에 있어야 함.
- Source 2 Secondary (dynamic entity_canon.name diagnostic):
    - prebuild name map (main thread 에서 entity_canon project_id +
      entity_type='character' scoped query) 사용 — entity_canon.name token 이
      t2i_prompt 에 등장하면 그 specific entity 의 ID candidates (base +
      모든 allowed outlook composite) 가 same sentence + ±60 char window
      안에 있어야 pass.
    - 다른 visible C## 가 window 안에 있어도 specific 매칭 안 되면 reject
      (RO-23 false-positive 차단).
- Source 3a (Phase 4 fix iter 3): render_prompt_card.asset_requirements
    .required_refs[] kind-dispatched validation:
    - kind ∈ {character, character_outlook}: format check + visible_entities
      base membership.
    - kind = background: id format is chain_bg snake_case (entity regex 금지) —
      cross-field equality vs render_prompt_card.background_binding
      (mode == background_ref_attached + bg_id == id). reverse direction also
      enforced: ref_attached binding without a matching background entry
      raises (producer-drift fail-fast).
    - kind ∈ {prop, location}: id format only (P##/L##); membership against
      visible_entities is intentionally NOT enforced today (producer does not
      emit these kinds — see in-line comment in dispatch).
    - unknown kind: AppError fail-fast.
- Source 3b: render_prompt_card.id_policy.allowed_outlook_pairs[].
    character_id (legacy fallback: base_id / composite_id) → visible_entities.

Codex iter 1 B1 carry — ThreadPool worker 안 SQLAlchemy session race 회피.
caller 가 main thread 에서 prebuild 한 `name_by_short_id` map 을 인자로
전달. validator 안에서 db query 0.

A-prime binding:

- module 안에 nationality / ethnicity / 작품 고유명사 token (frozenset/tuple/
  list/regex literal) 0건 — `feedback_no_scenario_keywords.md` (RC-C carry).
- Source 1 의 ID regex `\bC\d{2,3}(?:O\d{2,3})?\b` 만 사용 (semantic
  keyword frozenset 금지와 충돌하지 않음 — universal ID structure parsing).
- Source 2 의 entity_canon.name 은 prebuild map (project_id scoped) — 다른
  nationality / 시나리오 자동 적용.

PRO-4: required field 부재 / 타입 mismatch 시 fail-fast — silent `or []`/`or {}`
패턴 금지 (`feedback_no_silent_fallback.md`). optional field (description /
shot_index 등 non-contract) 만 nullable 허용.
    N)AnyDictListOptionalTuple)AppError)derive_visible_subject_ids'get_subject_reference_policy_or_default(normalize_subject_reference_policy_itemspolicy_to_id_usage_rulez\b(C\d{2,3}(?:O\d{2,3})?)\bz
^O\d{2,3}$z^C\d{2,3}O\d{2,3}$<   u   .!?
。z
^C\d{2,3}$z
^P\d{2,3}$z
^L\d{2,3}$background_ref_attacheddkeyexpected_type
shot_labelc                     | j                  |t              }|t        u rt        d| d| dd      t        ||      s7t        d| d| d|j                   d	t        |      j                   d
d      |S )uC   PRO-4 — required field 부재 / 타입 mismatch fail-fast helper.2step.scene_detail.contract_violation_missing_fieldz (PRO-4): required field 'zI' missing in shot. Fix: scene_detail step output must include this field.  codemessagestatus_code/step.scene_detail.contract_violation_field_typez (PRO-4): field 'z
' must be z, got .)get_MISSINGr   
isinstance__name__type)r   r   r   r   values        Y/Users/manta/Documents/Projects/TheRoad-I1/backend/app/core/visible_entities_validator.py_require_fieldr#   U   s    EE#x EE,8 >I J 
 	
 e]+B,/uJ ))*&e1E1E0FaI 
 	
 L    promptname_posname_lenentity_id_candidatesreturnc                 J   t        d|t        z
        }t        t        |       ||z   t        z         }| || }t        j                  |      D ]T  }|j                  d      }||vr||j                         z   }	t        |	|g      \  }
}| |
| }t        d |D              rT y y)uz  RO-23 + RO-27 — name_pos 기준 ±60 char window + sentence boundary
    + specific entity ID 매칭. window 안에 검사 중인 name 의 specific entity
    의 ID (C## 또는 C##O##) 가 있어야만 True.

    핵심 (RO-23 false-positive 차단): 다른 visible C## 가 window 안에 있어도,
    검사 중인 name 의 specific entity 의 ID 가 아니면 reject.
    r   c              3   ,   K   | ]  }|t         v   y w)N)_SENTENCE_BOUNDARY_CHARS).0chs     r"   	<genexpr>z0_entity_specific_id_in_window.<locals>.<genexpr>   s     @"r--s   TF)
max_ANCHOR_WINDOWminlen_ENTITY_ID_PATTERNfinditergroupstartsortedany)r%   r&   r'   r(   r7   endwindow_textmsid
id_abs_posabbetweens                r"   _entity_specific_id_in_windowrB   m   s     8n,-E
c&k8h.?
@Cs#K((5ggaj**QWWY&
z8,-11+@@@ 6 r$   rpcc                     | j                  d      }t        |t              r'|j                  d      }t        |t              r|dk(  ryy)uP   Area B/G4 보존 — render_strategy.mode == 'partial_focus' 면 forward 면제.render_strategymodepartial_focus)Tz'render_strategy.mode == 'partial_focus'F )r   r   dictstr)rC   rsrF   s      r"   %_is_forward_exempt_by_render_strategyrM      sA     
"	#B"dvvf~dC T_%<Br$   c                    | j                  d      }t        |t              sy|j                  dt              }|t        u ryt        |t              rO|j                  dt              }|du ry|du s|t        u ryt	        dd	t        |      j                   d
|d      t	        ddt        |      j                   d
|d      )ub  Area C 보존 — id_policy.reproduction_surface_rule.applies == True 면 면제.

    Critical 2 (review fix-up 2026-05-12) — sentinel 기반 분기:
      1) field absent → fall-through (legacy/stale card compat).
      2) field present + dict + applies bool → 4-branch logic.
      3) field present + non-dict → fail-fast (Gate 4 정합).
    	id_policyrH   reproduction_surface_ruleappliesT)Tz)reproduction_surface_rule.applies == TrueFz>visible_entities_validator.reproduction_surface_rule_malformedz4reproduction_surface_rule.applies must be bool, got z (z).)r   r   z6reproduction_surface_rule must be dict or absent, got )r   r   rJ   r   r   r    r   )rC   rO   reprorQ   s       r"   /_is_forward_exempt_by_reproduction_surface_rulerS      s     $Ii&MM5x@E%))Ix0d?Dew(2QG}--.b2?
 	
 M;''(5)27 r$   base_idallowed_outlook_pairsc           	      6   | h}|D ]  }t        |t              s|j                  d      xs> |j                  d      xs+ |j                  d      xs dj                  d      d   xs d}|| k7  rl|j                  d      }|r=t        j                  |      st        d| d| d	|d
      |j                  |       |j                  d      }|st        j                  |      st        d| d| d|d
      |j                  |  |         |S )u4  base C## + 그 base 의 모든 allowed C##O## composite ID set.

    Pair 에서 candidate 도출 우선순위:
      1. `composite_id` (C##O## 형식) 있으면 직접 추가 (가장 신뢰).
      2. 없으면 `character_id` (또는 `base_id`) + `outlook_id` 합성.
         단 `outlook_id` 는 O## short id (e.g., "O11", "O123") 형태 강제.

    Why: production 데이터에서 outlook_id 가 short id (O##) 또는 UUID 둘 다
    가능. composite_id 가 있으면 그쪽이 truth (UUID outlook 도 정확 식별).
    composite_id 가 없을 때만 outlook_id 가 O## short id 라는 가정 — UUID /
    다른 형태면 fail-fast (silent absorb 금지).

    Raises:
        AppError: composite_id 가 C##O## 형식 위반 또는 (composite_id 부재 시)
            outlook_id 가 O## 형식 위반.
    character_idrT   composite_idrI   Or   z8step.scene_detail.contract_violation_composite_id_formatz&: allowed_outlook_pairs.composite_id 'z-' must match C##O## (2-3 digits each). entry=r   r   
outlook_idz6step.scene_detail.contract_violation_outlook_id_formatz$: allowed_outlook_pairs.outlook_id 'u   ' must match O## short id (O followed by 2-3 digits). composite_id 부재 시 outlook_id 만으로 candidate 합성 — UUID / 다른 형태는 명시적으로 composite_id 필드로 표현하세요. entry=)	r   rJ   r   split_COMPOSITE_IDmatchr   add_OUTLOOK_ID_SHORT)rT   rU   r   
candidatespairchar_idrX   rZ   s           r"   _outlook_id_candidates_for_baserc      s`   & J%$%HH^$ xx	"(.B55c:1= 	 	 gxx/ &&|4S%, '(> *!!%* !$  NN<(XXl+
 &&z2M!l #"| $E FJH	N  
 
 	':,/0U &V r$   )audit_warningsshotname_by_short_idrd   c                  ;< | j                  d      }| j                  d      xs | j                  d      }d| d| <t        | dt        <      }t        |      }t	        |      }t        | dt        <      }|st        d< d	d
      t        | dt        <      }	t        d|	j                  dt              idt        <      }
t        d|	j                  dt              idt        <      }|j                  dt              }|t        u rt        d< dd
      t        |t              st        d< dd
      |D ]  }t        |t              st        d< dd
      |j                  d      xs> |j                  d      xs+ |j                  d      xs dj                  d      d   xs d}|st        d< d|d
      |j                  dt              }|t        u rt        d< d |d
      t        |t              rt        d!< d"t        |      j                   d#|d
       |D ci c]  }||v r||   r|||    }}t        |      D ]
  \  }}t        |t              st        d$< d%d
      |j                  d&t              }|t        u st        |t              st        d'< d(d
      t        t        j                  |            }|D ch c]  }|j                  d      d    }}|D ]@  }|j                  d      d   |vst        d)< d*| d+| d, d-t!        |       d.
d
       |j                  d/t              }|t        u rt        d0< d1d
      t#        ||d2< d3| d45      }|D ch c]  t%        fd6|D              r }}||z
  }|rt'        |	      \  }}t)        |	      \  }}|r#t*        j-                  d7<||t!        |             n|r#t*        j-                  d7<||t!        |             nvt!        |      D ]h  t/        |d2< d3| d48      } t1        | j2                        }!|!j4                  s:t        d9< d:| d;d<| j2                  d=t!        |       d>
d
       t!        |      D ]  t/        |d2< d3| d48      } t1        | j2                        }!|v }"|!j6                  r&|"s$t        d?< d:| d;d<| j2                  d@d
      |!j8                  r&|"r$t        dA< d:| d;d<| j2                  dBd
      |!j:                  s|"rt        dC< d:| d;d<| j2                  dDd
        t        |      D ]  \  }}|d&   }|j=                         }#|j?                         D ]  \  }$}%|%rtA        |%jC                               dEk  r%tE        |$|<      }&|%j=                         }'d}(	 |#jG                  |'|(      })|)dFk(  r]tI        ||)tA        |'      |&      sfdG<||$|%t!        |&      |)tJ        dH}*||jM                  |*       n:ddIl'}+|+jQ                  t              jS                  dJ<|%|$t!        |&      tJ               |)tA        |'      z   }(  |
j                  dKt              },|,t        u rt        d< dLd
      t        |,t              st        dM< dNd
      g }-|,D ]V  }.t        |.t              st        dO< dPd
      dQ|.vrt        dR< dSd
      |.dQ   }/|.j                  dTd      }0t        |/t              s)t        dU< dVt        |/      j                   d#|.d
      |/st        dR< dW|.d
      t        |0t              s)t        dX< dYt        |0      j                   d#|.d
      |0dZk(  rQtT        jW                  |/      st        d[< d\|/d]|.d
      |/|vst        d^< d_|/ d`t!        |       d.d
      |0dak(  rhtX        jW                  |/      st        d[< db|/dc|.d
      |/j                  d      d   |vsxt        d^< dd|/ d`t!        |       de d>d
      |0dfk(  r-tZ        jW                  |/      rt        d[< dg|/dh|.d
      |0dik(  r-t\        jW                  |/      rt        d[< dj|/dk|.d
      |0dlk(  r?|.j                  dm      } | dnk7  rt        do< dp| d#|.d
      |-jM                  |/       Ct        dq< dr|0ds|.d
       |,D 1cg c]M  }1t        |1t              r;|1j                  dT      dfk(  r'|1j                  dQ      sn|1j                  dQ      xs dO }2}1|2rjdtj_                  du |D              }3|2D 4cg c]1  }4ta        jb                  dvta        jd                  |4       dv|3      s|43 }5}4|5rt        dw< dx|5 dyd
      |	j                  dzt              ;d{t        d|t        f;<fd}}6|-r |6d~      }7|7j                  d      }8|7j                  d      }9|8tf        k7  rt        d< d|- d|8dtf        dd
      t        |9t              r|9st        d< dtf        d|9dd
      |-D ]  }/|/|9k7  s	t        d< d|/d|9dd
       nt        ;t              rq;j                  d      tf        k(  rY;j                  d      }9t        |9t              r|9st        d< dtf        d|9dd
      t        d< dtf        d|9dd
      |D ]  }t        |t              st        d< dd
      |j                  d      xs> |j                  d      xs+ |j                  d      xs dj                  d      d   xs dst        d< d|d
      |j                  dt              }:|:t        u rt        d< d|d
      t        |:t              s't        d!< dt        |:      j                   d>d
      |vst        d< d d`t!        |       d.d
       yIc c}w c c}w c c}w c c}1w c c}4w )u  ID coverage primary + dynamic entity_canon.name secondary.

    silent bypass 없음 (RO-15 + PRO-4) — required field 모두 _MISSING fail-fast.

    Codex iter 1 B1 carry — db / project_id 인자 제거. caller (detail_steps
    `_post_process` 또는 ctx-aware test) 가 main thread 에서 prebuild 한
    `name_by_short_id` map 을 전달. ThreadPool worker 안 SQLAlchemy session
    race 회피.

    Args:
        shot: scene_detail step 결과의 단일 shot dict (visible_entities,
            t2i_variations, render_prompt_card 포함).
        name_by_short_id: short_id (e.g., "C08") → entity_canon.name. ctx
            level 에서 prebuild — entity_type='character' 만 포함.
    scene_index_shot_index
shot_indexS_Shotvisible_entitiest2i_variationsz.step.scene_detail.contract_violation_empty_t2iz] (PRO-4): t2i_variations is empty. scene_detail must produce at least one variation per shot.r   r   render_prompt_cardasset_requirementsrO   rU   r   uY    (PRO-10): id_policy.allowed_outlook_pairs missing — required field per RO-16 contract.z7step.scene_detail.contract_violation_outlook_pairs_typez7 (PRO-4): id_policy.allowed_outlook_pairs must be list.z6step.scene_detail.contract_violation_outlook_pair_typez3 (PRO-4): allowed_outlook_pairs entry must be dict.rW   rT   rX   rI   rY   r   z7step.scene_detail.contract_violation_outlook_pair_no_idzn (Codex I3 + PRO-13): allowed_outlook_pairs entry missing all of character_id / base_id / composite_id. entry=rZ   z?step.scene_detail.contract_violation_outlook_pair_no_outlook_idzT (Codex I3 + PRO-13): allowed_outlook_pairs entry missing 'outlook_id' field. entry=zAstep.scene_detail.contract_violation_outlook_pair_outlook_id_typez2 (Codex I3 + PRO-13): outlook_id must be str, got z. entry=z3step.scene_detail.contract_violation_variation_typez, (PRO-4): t2i_variations entry must be dict.
t2i_promptz5step.scene_detail.contract_violation_variation_promptz< (PRO-4): t2i_variations[].t2i_prompt missing or non-string.z3step.scene_detail.contract_violation_id_not_visiblez" (Source 1, RO-2): t2i_variations[z].t2i_prompt uses 'z' (base=z) but visible_entities=z does not include it.subject_reference_policyz/step.contract_violation.id_policy.field_missingzM (Area #1): card.id_policy missing required field 'subject_reference_policy'.z
validator:z.variation[])visible_subject_idswherec              3   F   K   | ]  }|j                   d         yw)rY   N)
startswith)r-   r=   bases     r"   r/   z5validate_visible_entities_contract.<locals>.<genexpr>  s!     B#3>>TF!*-s   !uF   %s (Source 1 forward exempt, variation %d): %s — missing %s allowed.)ru   zMstep.scene_detail.contract_violation.subject_reference_policy.base_id_missingz (variation z): subject z policy=z@ requires base C## in t2i_prompt, but missing. visible_entities=r   zPstep.scene_detail.contract_violation.subject_reference_policy.outlook_id_missingz4 requires outlook C##O## but only base form present.zOstep.scene_detail.contract_violation.subject_reference_policy.outlook_forbiddenz5 forbids outlook C##O## but prompt uses outlook form.zOstep.scene_detail.contract_violation.subject_reference_policy.base_id_forbiddenz/ forbids bare C## but prompt uses bare id form.   z:step.scene_detail.audit_warning_entity_name_no_specific_id)r   r   variation_indexrT   entity_namer(   	match_posanchor_windowNu   validate_visible_entities_contract audit: %s entity_canon.name=%r base=%s — no specific ID (candidates=%r) within ±%d window (Source 2 downgraded to audit, see W20F2).required_refsuh    (PRO-12): asset_requirements.required_refs missing — required field. 빈 list 가능, missing 불가.z7step.scene_detail.contract_violation_required_refs_typez9 (PRO-12): asset_requirements.required_refs must be list.z6step.scene_detail.contract_violation_required_ref_typez+ (PRO-4): required_refs entry must be dict.idz7step.scene_detail.contract_violation_required_ref_no_idz+ (PRO-4): required_refs entry missing 'id'.kindz9step.scene_detail.contract_violation_required_ref_id_typez7 (Codex I1): required_refs entry 'id' must be str, got z4 (PRO-4): required_refs entry has empty 'id'. entry=z;step.scene_detail.contract_violation_required_ref_kind_typez9 (Codex I1): required_refs entry 'kind' must be str, got 	characterz;step.scene_detail.contract_violation_required_ref_id_formatz+ (Phase 4 fix iter 3): kind='character' id=z$ must match C## (2-3 digits). entry=z=step.scene_detail.contract_violation_required_ref_not_visiblezF (Source 3a, RO-2): asset_requirements.required_refs has character id=z but visible_entities=character_outlookz3 (Phase 4 fix iter 3): kind='character_outlook' id=z, must match C##O## (2-3 digits each). entry=zN (Source 3a, RO-2): asset_requirements.required_refs has character_outlook id=z does not include base=propz& (Phase 4 fix iter 3): kind='prop' id=z$ must match P## (2-3 digits). entry=locationz* (Phase 4 fix iter 3): kind='location' id=z$ must match L## (2-3 digits). entry=
backgroundpolicyrequiredzCstep.scene_detail.contract_violation_required_ref_background_policyza (Phase 4 fix iter 4 M1): kind='background' required_refs entry must have policy='required', got z>step.scene_detail.contract_violation_required_ref_unknown_kindz0 (Phase 4 fix iter 3): required_refs entry kind=zZ not in supported kinds (character, character_outlook, prop, location, background). entry=
c              3   f   K   | ])  }t        |t              r|j                  d       xs d + yw)rq   rI   N)r   rJ   r   )r-   vs     r"   r/   z5validate_visible_entities_contract.<locals>.<genexpr>  s2      )
1?A!T" UU< &B&s   /1z\bz@step.scene_detail.contract_violation_prop_p_id_missing_in_promptuI    (PRO-13): required prop P## not in any t2i_variation prompt — missing=u/   . Tier 1 fail-fast — scene_detail step retry.background_binding
label_kindr)   c           
          t         u rt        d d|  dd      t        t              s*t        d d|  dt	              j
                   d	d      S )
Nr   u    (Phase 4 fix iter 3 — z): required_refs has a kind='background' entry but render_prompt_card.background_binding is missing. The card producer must emit background_binding alongside any background required_ref so cross-field equality can be checked.r   r   r   u    (PRO-4 — z;): render_prompt_card.background_binding must be dict, got r   )r   r   r   rJ   r    r   )r   bb_topr   s    r"   _bb_dict_or_raisez=validate_visible_entities_contract.<locals>._bb_dict_or_raise:  s    XI!l";J< H& '    &$'F!l,zl ;OF|,,-Q0    r$   forwardrF   bg_idzJstep.scene_detail.contract_violation_required_ref_background_mode_mismatchzV (Phase 4 fix iter 3): asset_requirements.required_refs has kind='background' entries z but background_binding.mode=u    ≠ zH. background ref is only valid when the binding is in ref-attached mode.zEstep.scene_detail.contract_violation_background_binding_bg_id_invalidz2 (Phase 4 fix iter 4 M3): background_binding.mode=z but bg_id=zy is missing / empty / non-string. Producer must populate bg_id whenever required_refs contains a kind='background' entry.zHstep.scene_detail.contract_violation_required_ref_background_id_mismatchzQ (Phase 4 fix iter 3): asset_requirements.required_refs has kind='background' id=z but background_binding.bg_id=zO. The two fields must be identical (chain_bg id is the single source of truth).u>    (Phase 4 fix iter 4 M3 — reverse): background_binding.mode=z! is missing / empty / non-string.zDstep.scene_detail.contract_violation_required_ref_background_missingz2 (Phase 4 fix iter 4 B1): background_binding.mode=z with bg_id=u    but asset_requirements.required_refs contains no kind='background' entry. Producer drift — when the binding is ref-attached, the matching background ref must be present in required_refs (one source of truth).zc (PRO-13): allowed_outlook_pairs entry missing all of character_id / base_id / composite_id. entry=zI (PRO-13): allowed_outlook_pairs entry missing 'outlook_id' field. entry=z' (PRO-13): outlook_id must be str, got z=step.scene_detail.contract_violation_outlook_pair_not_visiblezF (Source 3b, RO-16): id_policy.allowed_outlook_pairs has character_id=)4r   r#   listsetr	   r   rJ   r   r   r[   rK   r    r   	enumerater4   findallr8   r   r9   rM   rS   loggerdebugr
   r   r   base_requiredoutlook_requiredoutlook_forbiddenbase_forbiddenloweritemsr3   striprc   findrB   r1   appendlogging	getLoggerwarning_CHAR_REF_ID_PATTERNr]   _OUTLOOK_REF_ID_PATTERN_PROP_REF_ID_PATTERN_LOCATION_REF_ID_PATTERNjoinresearchescape_BG_MODE_REF_ATTACHED)=re   rf   rd   	scene_idxshot_idxvisible_listvisiblevisible_basesrn   rC   	asset_reqrO   rU   ra   _shape_base_shape_outlookr=   base_to_namevidx	variationr%   used_ids
used_bases	srp_array
policy_maprx   used_outlook_for_basemissing_bases	exempt_rs	reason_rs
exempt_rep
reason_repr   rulehas_outlookprompt_lowerrT   nameentity_id_cands
name_loweroffsetposwarning_payload_loggingr   background_ref_idsrefridr   entry_patch_a_required_props_patch_a_all_promptspid_patch_a_missingr   bbbb_modebb_bg_idrZ   r   r   s=                            `                                 @@r"   "validate_visible_entities_contractr   
  s   * 'Ixx&@$((<*@HYKuXJ/J!$(:D*ML,G.|<M#D*:D*MNA, @ A 
 	
 3T:
FC	sww';XFGdJI 	cggk845T:I
 &MM*A8L(E, 5 6 
 	
 +T2J!l"YZ
 	
 &$%M%,&YZ  HH^$ xx	"(.B55c:1= 	 	 N!l #!H&    ,9X%V!l #??ChH    .#.X!l #/889$K   E &` ! C""'7'< 	c""    %^4i)T*J%,&RS 
 |X6XZ%<L!l #% &    )11&9:3;<8CciinQ'8
<C99S>!$D=(N%,&H O,,/5 ?,,27O+<<QS !$  " MM"<hG	 F!l #8 9    > -zl+dV1=

 #!
"BBB " 	 !
 &
2#H#M Iy?D #J
 .i1F
 .j&2G #=1DD"D *:,k$qIF 36==AD))&!K $.,l4&#'((6==2C D44:7O3DA!G
 ),  2, :&D<D":,k$qAF +6==9D"77K$$[F &,l4&D8 L""(--!2 367 !$  %%+E &,l4&D8 L""(--!2 389 !$  "";E &,l4&D8 L""(--!2 3IJ !$ K 'O 5~ %^4i<(||~)//1MGT3tzz|,q0=.
O JF"''
F;"94CZ/
9 '1+/#*'+060G%()7'O &1&--o>2 **84<<? 'g"?3^ s:.A  2	 5\ MM/8<M E, C D 
 	
 mT*J!l"[\
 	
6 %'#t$M%,&QR  s?N%,&QR 
 $iwwvr"#s#P!l #  $S	 2 238C7D    N!l # G%    $$R!l #  $T
 3 34HSGE    ;'--c2V%, '!W$HQ !$  -'X%, 'MMPE R006w/@@UW !$  ((*005V%, '!W %!!$) !$  99S>!$D=(X%, '!U"88I J((,vQ0
 !$	 	 V^ (--c2V%, '!W$HQ !$  Z ,11#6V%, '!W$HQ !$  \! WWX&F#^%, 'P!*HSG5 !$  %%c*U!l # 8 $ G%
  	 	M n #"EeT"IIf'YYt_	 
4	B	"   #yy )
1?)
  

 3
2C99299S>"2"57KL 2 	 
 W!l #88H7I JDE   . WW)84Fc d 4 y)&&.66'?++a!l #C)**Gk'<&? @NO  
 
 8S)h\!l #//D.G H%L ):;  
 
 &Chc%, 'BBE I44<< @%& !$
 
 & 	64 JJv"77 ::g&8S)h\!l #//D.G H%L(IK    W, ++@*C D! %JK 
 	
 &$%M%,&YZ  HH^$ xx	"(.B55c:1= 	 	 N!l #KKO(T    XXlH5
!V!l #115:    *c*X!l #
+445Q8    }$T!l #HHLv N,,27O+<<QS   U &y2 =H!
d

s   <q-(q2q7Aq<56r)-__doc__r   r   typingr   r   r   r   r   app.core.errorsr   !app.core.subject_reference_policyr	   r
   r   r   r   r   r   objectr   compiler4   r_   r\   r1   r,   r   r   r   r   r   rJ   rK   r    r#   intr   boolrB   rM   rS   r   rc   r    r$   r"   <module>r      s  0b  	 3 3 $  
		8	$8RZZ >? BJJ}- 

01%  "rzz-0 $"**%:; !rzz-0 %2::m4 1 d  T s 0  	
 
R		c3h	
49	#	c3h#
49#L??)-?;>??L 6:	E
EE T$sCx.12	E
 
Er$   