Description
The current negation system has three separate rule types and an implicit priority chain in negate():
NegationDefaultWithRule (replace with fixed string)
NegationDefaultWhenRule (use default form)
NegationSubRule (regex substitution)
swap_negation() (fallback)
These are three different Pydantic models, three fields on HConfigDriverRules, and the precedence is encoded in method ordering rather than being explicit.
Proposed Change
Unify into a single rule type:
class NegationStrategy(Enum):
REPLACE = auto() # was negate_with
DEFAULT = auto() # was negation_default_when
REGEX_SUB = auto() # was negation_sub
class NegationRule(BaseModel):
match_rules: tuple[MatchRule, ...]
strategy: NegationStrategy
value: str = "" # replacement text or regex pattern
replace: str = "" # for REGEX_SUB strategy
Single negation_rules field on HConfigDriverRules. First matching rule wins.
Benefits
- Collapses three rule types and three driver fields into one
- Precedence is explicit (list order) rather than implicit (method ordering)
- Easier to understand and extend
Breaking Change
Yes — all existing negate_with, negation_default_when, and negation_sub rules must be migrated.
Description
The current negation system has three separate rule types and an implicit priority chain in
negate():NegationDefaultWithRule(replace with fixed string)NegationDefaultWhenRule(usedefaultform)NegationSubRule(regex substitution)swap_negation()(fallback)These are three different Pydantic models, three fields on
HConfigDriverRules, and the precedence is encoded in method ordering rather than being explicit.Proposed Change
Unify into a single rule type:
Single
negation_rulesfield onHConfigDriverRules. First matching rule wins.Benefits
Breaking Change
Yes — all existing
negate_with,negation_default_when, andnegation_subrules must be migrated.