# Template versionne des regles administrables.
# Ce fichier decrit un contrat cible pour le futur moteur de regles d'administration.
# Il n'est pas encore branche automatiquement dans le pipeline.
version: 1
defaults:
  review_required_for_activation: true
  environments:
    - test
    - prod
  sections:
    - narrative
    - structured
    - table
rules:
  - id: rule_chuxx_exact_mask
    label: Masquer le sigle CHUXX
    description: Sigle local a masquer dans tous les contextes documentaires.
    type: exact_term
    action: mask
    placeholder: "[MASK]"
    status: active
    match:
      exact_value: CHUXX
    normalization:
      case_insensitive: true
      whole_word: true
      multiline: false
    scope:
      document_families:
        - all
      environments:
        - test
        - prod
      sections:
        - narrative
        - structured
        - table
    governance:
      owner: qualite
      justification: Sigle local considere comme identifiant d'etablissement a masquer.
      created_at: "2026-04-21"
      review_required_for_activation: true
      approved_by: responsable_qualite
      tests:
        required_case_ids:
          - 009_multi_etablissements
          - 001_crh_hospitalisation_complete

  - id: rule_identifier_1234567
    label: Identifier normalise 1234567
    description: Exemple de regle couvrant les variantes N°, No et Numero.
    type: normalized_identifier
    action: mask
    placeholder: "[NDA]"
    status: candidate
    match:
      canonical_value: "1234567"
    normalization:
      case_insensitive: true
      whole_word: true
      multiline: true
      allow_bare_value: true
      accepted_prefixes:
        - "N°"
        - "No"
        - "Numero"
      prefix_value_separators:
        - ""
        - " "
        - ":"
        - " : "
    scope:
      document_families:
        - compte_rendu
        - imagerie
      environments:
        - test
      sections:
        - narrative
        - structured
        - table
    governance:
      owner: qualite
      justification: Cas type demande pour les numeros administratifs variables.
      created_at: "2026-04-21"
      review_required_for_activation: true
      approved_by: null
      tests:
        required_case_ids:
          - 003_consultation_complete
          - 001_crh_hospitalisation_complete

  - id: rule_ipp_context_abc12345
    label: IPP contextuel ABC12345
    description: Exemple de valeur a masquer seulement en contexte de label IPP.
    type: contextual_identifier
    action: mask
    placeholder: "[IPP]"
    status: draft
    match:
      canonical_value: ABC12345
      context_prefixes:
        - IPP
        - I.P.P.
        - "N° Ipp"
      context_separators:
        - ":"
        - " : "
        - "\n"
    normalization:
      case_insensitive: true
      whole_word: true
      multiline: true
    scope:
      document_families:
        - all
      environments:
        - test
      sections:
        - structured
        - table
    governance:
      owner: qualite
      justification: Prototype de regle contextuelle pour identifiants structures.
      created_at: "2026-04-21"
      review_required_for_activation: true
      approved_by: null
      tests:
        required_case_ids:
          - 004_structured_admin_complete

  - id: rule_preserve_classification_internationale
    label: Preserver classification internationale
    description: Protection explicite d'une formulation metier.
    type: preserve_phrase
    action: preserve
    status: active
    match:
      exact_value: classification internationale
    normalization:
      case_insensitive: true
      whole_word: false
      multiline: false
    scope:
      document_families:
        - all
      environments:
        - test
        - prod
      sections:
        - narrative
        - structured
    governance:
      owner: metier
      justification: La formulation doit rester visible pour l'usage controle.
      created_at: "2026-04-21"
      review_required_for_activation: true
      approved_by: responsable_qualite
      tests:
        required_case_ids:
          - 006_trackare_soignants
          - 001_crh_hospitalisation_complete
          - 002_imagerie_complete
