# SEO Rules Domain

This folder is the single source of truth for SEO Rules business decisions.

Rule of thumb:
- if we are deciding *what is allowed* or *when something should happen*,
  that logic should live in a Domain Policy class here;
- feature/services classes should only execute the flow and delegate decisions.

## Policies

### `Policies/CrawlBudgetPolicy.php`
- Decides crawl-budget thresholds and status (`empty`, `ok`, `warning`, `critical`).
- Uses store-size segments and ratio/absolute URL guards.
- Filter:
  - `fibofilters/seo/crawl_budget_thresholds`

### `Policies/IndexabilityPolicy.php`
- Decides minimum products required for one SEO URL to be indexable.
- Decides maximum expanded range value IDs (range safety guard).
- Filters:
  - `fibofilters/seo/min_products_per_url`
  - `fibofilters/seo/max_range_value_ids`

### `Policies/SitemapPolicy.php`
- Decides sitemap daily publish limit.
- Decides first daily run hour.
- Decides daily batch limits for removals vs additions.
- Decides when sitemap scheduling should be active:
  - has any rules
  - sitemap setting enabled
  - SEO Rules runtime enabled
- Filters:
  - `fibofilters/seo/sitemap/daily_limit`
  - `fibofilters/seo/sitemap/first_run_hour`

### `Policies/SaveGuardPolicy.php`
- Decides if critical crawl-budget save blocking can be bypassed.
- Filter:
  - `fibofilters/seo/crawl_budget_allow_critical_save`

## Current Consumers

- `CrawlBudgetCalculator` -> `CrawlBudgetPolicy`
- `ProductEstimator` -> `IndexabilityPolicy`
- `RangeValueResolver` -> `IndexabilityPolicy`
- `SeoSitemap/BatchPublisher` -> `SitemapPolicy`
- `SeoSitemap/Service` -> `SitemapPolicy`
- `SeoSitemap/Scheduler` -> `SitemapPolicy`
- `API/SEORules` -> `SaveGuardPolicy`
- `API/SettingsController` -> `SaveGuardPolicy`
- `Front/Matcher` -> `Domain/MatchSpec/MatchSpec`
