> ## 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.

# Rules & rulesets

> Define the constraints that guard plan actions, and group them into rulesets.

A **business rule** is a constraint Solya evaluates before a plan action. A **ruleset**
groups rules; one ruleset is your organization's **default** and applies whenever a plan
doesn't specify another.

## Anatomy of a rule

* **Category** — the domain it belongs to: capacity, assortment, ordering, transfer,
  pricing, distribution, or compliance.
* **Enforcement mode** — what happens when it triggers:
  * **Block** — the action is rejected.
  * **Warn** — the action proceeds with a warning.
  * **Log** — the firing is recorded silently.
* **Check level** — what it evaluates: shop, brand, product, variant, inventory item,
  plan, or plan item.
* **Condition** — the test (a threshold or value), backed by live data fetched at
  evaluation time.
* **Scope** — which shops, brands, suppliers, products, variants, or collections it
  applies to. An empty dimension means "all".
* **Validation hooks** — the moments it fires (see below).
* **Violation message** — the message shown when it triggers.
* **Priority** — the evaluation order.

## When rules fire — validation hooks

Rules are attached to **hooks** that fire at specific points per plan type:

| Moment                          | Hooks (per plan type)                                                                                                                                                  |
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Before adding an item           | `RESTOCK_PRE_ADD_ITEM`, `REBALANCE_PRE_ADD_ITEM`, `MARKDOWN_PRE_ADD_ITEM`, `PRE_SEASON_PRE_ADD_ITEM`, `SUPPLIER_RETURN_PRE_ADD_ITEM`, `SUPPLIER_EXCHANGE_PRE_ADD_ITEM` |
| Before validating an item       | `RESTOCK_PRE_VALIDATE_ITEM`, `REBALANCE_PRE_VALIDATE_ITEM`, `MARKDOWN_PRE_VALIDATE_ITEM`, `PRE_SEASON_PRE_VALIDATE_ITEM`                                               |
| Before changing plan status     | `RESTOCK_PRE_CHANGE_STATUS`, `REBALANCE_PRE_CHANGE_STATUS`, `PRE_SEASON_PRE_CHANGE_STATUS`, `SUPPLIER_RETURN_PRE_CHANGE_STATUS`, `SUPPLIER_EXCHANGE_PRE_CHANGE_STATUS` |
| When generating recommendations | `RECOMMENDATION_PRE_GENERATE`                                                                                                                                          |
| On demand                       | `MANUAL_CHECK` (re-evaluate a plan from its validation panel)                                                                                                          |

## Templates

Rather than building rules from scratch, start from a **template** in the catalog —
e.g. max plan value, max items per shop, max quantity per variant, OTB envelope caps,
size-curve deviation, markdown discount/margin guards, and supplier policies. Pick a
template, set its threshold and scope, choose Block or Warn, and assign it to a ruleset.

## Working with rules

<Steps>
  <Step title="Open the Business Center">
    Go to **Intelligence layer → Business Center / Business rulesets**.
  </Step>

  <Step title="Create or pick a ruleset">
    Create a named ruleset (e.g. *Strict Q4*), or edit the default.
  </Step>

  <Step title="Add rules from templates">
    Instantiate templates, set thresholds and scope, and choose the enforcement mode.
  </Step>

  <Step title="Set the default">
    Mark one ruleset as the organization default.
  </Step>

  <Step title="See them in action">
    Blocks and warnings appear in the plan's validation panel as you build plans.
  </Step>
</Steps>

<Note>
  Every rule evaluation is recorded, so you can review which rules fired on a plan and
  why. For the technical model (hooks, enforcement, paradigms, phases, the operations
  layer), see [Business rules engine](/en/developers/business-rules-engine).
</Note>
