Skip to content

kuroi.core.rules

rules

Rule sets: declarative detector definitions, partly regex, partly LLM.

Category dataclass

A single detector definition within a rule set.

detection selects between regex matching (with pattern) and LLM delegation (pattern unused). confidence is the level every Finding emitted by this category will carry.

RuleSet dataclass

A named bundle of detector categories loaded from a rule pack YAML.

load_rule_set

load_rule_set(name: str) -> RuleSet

Load a built-in rule set by name. pii aliases to pii-en.

llm_categories

llm_categories(rs: RuleSet) -> tuple[Category, ...]

Subset of categories the LLM is responsible for.

apply_regex_rules

apply_regex_rules(pages: tuple[Page, ...], rs: RuleSet) -> list[Finding]

Apply every regex category in rs against the word-indexed pages.

A regex match that spans multiple words emits one Finding spanning the matched word range. Matches that span 0 words (e.g. a regex matching only inside a single word substring) collapse to that word's index.