# normalize-rules-config

Shared rule configuration types (`RulesConfig`, `RuleOverride`, `SarifTool`, `Severity`, `PathFilter`, `WalkConfig`) used by all normalize rule engines.

Loaded from `[rules]` in `.normalize/config.toml`. Per-rule overrides under `[rules.rule."rule-id"]` (legacy `[rules."rule-id"]` still parsed with a stderr deprecation warning), external SARIF tools under `[[rules.sarif-tools]]`. `Severity` enum covers Error, Warning, Info, and Hint. `RuleOverride` includes generic fields (`severity`, `enabled`, `allow`, `tags`) and rule-specific fields — `filenames` (a `Vec<String>` accepted as a single string or list, used by `stale-summary`/`missing-summary` to configure which doc filenames are checked) and `paths` (a `Vec<String>` accepted as a single string or list, used by `stale-summary`/`missing-summary` to scope coverage to matching directory globs; empty means check everywhere). Both `filenames` and `paths` use the same `deserialize_one_or_many` helper. `PathFilter` holds compiled `--only`/`--exclude` glob patterns for pre-walk file filtering — built once in the service layer and threaded to each rule engine. `WalkConfig` controls directory walking behavior: `ignore_files` (which gitignore-format files to respect, default `[".gitignore"]`) and `exclude` (gitignore-style patterns to always skip, default `[".git"]`). `exclude` patterns use full gitignore syntax — basename-only patterns (e.g. `node_modules`, `worktrees`) match at any depth, slash-anchored patterns (e.g. `**/target/`, `crates/foo/build/`) match relative to the project root. Compiled via `compiled_excludes(root)` returning an `ignore::gitignore::Gitignore` matcher; `is_excluded_path(root, rel, is_dir)` is a one-shot convenience. Loaded from `[walk]` in `.normalize/config.toml` and threaded to all file walkers. `SarifTool` holds `name`, `command`, and optional `watch` (glob patterns) fields. When `watch` is set, `run_sarif_tools` caches the tool's output in the SQLite findings cache keyed by the max mtime of matching files, skipping the tool on warm runs where nothing changed. Used by:
- `normalize-syntax-rules` — syntax (tree-sitter) rule loader
- `normalize-facts-rules-interpret` — Datalog fact rule loader
- `normalize-native-rules` — native rule checks (walk filtering)
- `normalize-rules` — unified rule orchestration
