<commit_before>######
Policy
######

The nmeta policy configures how nmeta works with data plane traffic.
This includes traffic classification rules, what classifiers are used,
in what order and what actions are taken.

The policy is designed as a tree with many first level branches and only
a shallow depth.

***************
Policy Location
***************

Nmeta ships with a default policy in the YAML file:

.. code-block:: text

  ~/nmeta/nmeta/config/main_policy.yaml

Do not edit the default policy as it will be overwritten by nmeta
updates.

Create Your Own Policy
======================

Create your own policy by copying the default file to this location:

.. code-block:: text

  ~/nmeta/nmeta/config/user/main_policy.yaml

(note the user directory)

If a main_policy.yaml file is present in the user directory it will completely
override the default policy. Note that a user-defined main policy file will
not be part of the git distribution, as it is excluded in the .gitignore file.

*****************************
Traffic Classification Branch
*****************************

The traffic classification policy is based off a root key *tc_rules*.
This root contains a *ruleset* name (only one ruleset supported at this
stage), which in turn contains one or more *rules*.

Rules
=====

Rules are an ordered list (denoted by preceding dash). Each rule contains:

  Comment
    A *comment* to describe the purpose of the rule (optional). A
    comment must start with the attribute *comment:* and any single-line string
    can follow

  Match Type
    A *match_type* is one of:
      - any. Match if any of the conditions in the rule match.
      - all. Match only if all of the conditions in the rule match.
      - none. Match only if none of the conditions in the rule match.

  Conditions List
    A list that contains one or more
    *condition* stanzas that each contain a match type and one or more
    classifiers.

  Actions
    A single *actions* stanza that contains one or more actions

Example simple traffic classification policy with a single rule:

.. image:: images/simple_tc_policy.png

A condition contains:

- A match type, which is one of:
      - any. Match if any of the conditions in the rule match.<commit_msg>doc updates<commit_after>######
Policy
######

The nmeta policy configures how nmeta works with data plane traffic.
This includes traffic classification rules, what classifiers are used,
in what order and what actions are taken.

The policy is designed as a tree with many first level branches and only
a shallow depth.

***************
Policy Location
***************

Nmeta ships with a default policy in the YAML file:

.. code-block:: text

  ~/nmeta/nmeta/config/main_policy.yaml

Do not edit the default policy as it will be overwritten by nmeta
updates.

Create Your Own Policy
======================

Create your own policy by copying the default file to this location:

.. code-block:: text

  ~/nmeta/nmeta/config/user/main_policy.yaml

(note the user directory)

If a main_policy.yaml file is present in the user directory it will completely
override the default policy. Note that a user-defined main policy file will
not be part of the git distribution, as it is excluded in the .gitignore file.

*****************************
Traffic Classification Branch
*****************************

The traffic classification policy is based off a root key *tc_rules*.
This root contains a *ruleset* name (only one ruleset supported at this
stage), which in turn contains one or more *rules*.

Rules
=====

Rules are an ordered list (denoted by preceding dash). Each rule contains:

  Comment
    A *comment* to describe the purpose of the rule (optional). A
    comment must start with the attribute *comment:* and any single-line string
    can follow

  Match Type
    A *match_type* is one of:

      any

        Match if any of the conditions in the rule match

      all

        Match only if all of the conditions in the rule match

      none

        Match only if none of the conditions in the rule match

  Conditions List
    A list that contains one or more
    *condition* stanzas that each contain a match type and one or more
    classifiers.

  Actions
    A single *actions* stanza that contains one or more actions

Example simple traffic classification policy with a single rule:

.. image:: images/simple_tc_policy.png

A condition contains:

- A match type, which is one of:
      - any. Match if any of the conditions in the rule match.
{'fraction_non_alphanumeric': 0.0973824312333629, 'fraction_numerical': 0.0, 'mean_word_length': 3.6484536082474226, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '212550', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1121, 'n_words': 638}