Rule priority and resolution
How Shelfie picks which rule applies to a product
When Shelfie analyses a product, it must pick exactly one rule to determine the product's thresholds and auto-action. The resolution algorithm is deterministic.
Algorithm
For a given product P:
- Find candidates — every active rule whose scope matches P
- Pick highest priority — sort candidates by
priority(descending). Highest wins. - Tie-break by createdAt — if two rules have the same priority, the older one wins.
- Fallback — if no scoped rule matches, the catch-all rule applies.
Default priorities
Scope-type defaults are designed so specific overrides general:
| Scope type | Default priority |
|---|---|
| product | 100 |
| tag | 80 |
| collection | 60 |
| product_type | 40 |
| vendor | 20 |
| category | 15 |
| sku_prefix | 10 |
| location | 5 |
| catch-all | 0 |
Overriding priority
You can set any rule's priority to any integer. Use this when default behaviour doesn't match your intent.
Example: archive overrides clearance
You have two rules both scoped to tag: ss24:
SS24 Clearance(priority 80) — 40% markdown on dead productsSS24 Archive(priority 90) — archive products 30 days after clearance
Without override they'd tie at 80 (both tag scope). Bumping Archive to priority 90 ensures it wins when both match.
Inspecting which rule matched
On the dashboard at-risk table, the Rule column shows the matched rule name for each product. Filter by rule to see all products that resolved to it.