> ## Documentation Index
> Fetch the complete documentation index at: https://docs.solya.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Tagging rules — runs & examples

> How tag evaluation runs apply rules, what they record, and a complete annotated rule.

## Tag evaluation runs

Tags are (re)computed by a **tag evaluation run** — manual, scheduled, or via API. A run
evaluates the active rules (or a specific subset), then **creates** assignments for newly
matching entities and **removes** assignments that no longer match.

| Field         | Meaning                                                                     |
| ------------- | --------------------------------------------------------------------------- |
| `status`      | `PENDING → RUNNING → SUCCESS / FAILED`.                                     |
| `triggerType` | `MANUAL`, `SCHEDULED`, or `API`.                                            |
| `ruleIds`     | The rules to evaluate (null = all active rules).                            |
| `stats`       | `{ rulesEvaluated, assignmentsCreated, assignmentsRemoved, durationMs }`.   |
| `logs`        | Structured entries (`DEBUG`/`INFO`/`WARN`/`ERROR`), capped at 5000 per run. |

Because a run reconciles assignments (adds **and** removes), tags stay in sync with your
data over time — an entity that stops matching loses the tag on the next run.

## Complete example

*Tag inventory items projected to run out within 7 days.*

```json theme={null}
{
  "name": "Auto-tag: Stockout in 7 days",
  "tagId": "<resolved-uuid>",
  "conditions": {
    "operator": "AND",
    "rules": [
      {
        "type": "METRIC",
        "metricId": "<days-of-stock-metric-uuid>",
        "conditionOperator": "LOWER_OR_EQUAL",
        "thresholdValue": 7,
        "periodFilter": null
      }
    ]
  },
  "scope": { "entityType": "INVENTORY_ITEM" },
  "isActive": true
}
```

**What to notice**

* A single **metric** condition (`days of stock ≤ 7`) under an `AND` group.
* Scope is just `entityType: INVENTORY_ITEM` — no brand/taxonomy restriction, no
  propagation (defaults to entity-only).
* On each evaluation run, matching inventory items receive the tag; items that recover
  (more than 7 days of stock) lose it.

A second, mixed example — *new-season menswear that sold 50+ units last month*:

```json theme={null}
{
  "conditions": {
    "operator": "AND",
    "rules": [
      { "type": "METRIC", "metricId": "<gross-sales-qty>", "conditionOperator": "GREATER_OR_EQUAL", "thresholdValue": 50, "periodFilter": { "type": "LAST_30_DAYS" } },
      { "type": "COLUMN", "columnId": "dim_products.gender_full_path_1", "columnOperator": "STARTS_WITH", "value": "M" }
    ]
  },
  "scope": { "entityType": "PRODUCT", "propagationMode": "CASCADE_DOWN" }
}
```

Here a metric and a column condition combine, and `CASCADE_DOWN` propagates the tag from
each matching product to its variants.

<Note>
  Once entities are tagged, point [alerts](/en/signals/alerts) and
  [workflow triggers](/en/developers/workflows/triggers) at those tags to monitor or
  automate against them.
</Note>
