Skip to content

Scope 16 / Phase 2: Extend Priority 7 routing — HighOutlierDensity KNN trigger and TailAsymmetry SkewSeverity upgrade #234

Description

@DEVunderdog

Parent

#105

What to build

Extend the Priority 7 distribution shape routing in _strategy_router.py with two new Scope 16 signals. Both apply only to non-BoundedDiscrete columns (BoundedDiscrete routing is handled inside its own Priority 3 gate).

TailAsymmetryTag severity upgrade

Before evaluating the Priority 7 distribution shape condition, compute an effective SkewSeverity:

  • When NumericStats.tail_asymmetry_tag is TailAsymmetryTag.RightHeavy or TailAsymmetryTag.LeftHeavy, upgrade the effective SkewSeverity by one level (e.g. Moderate → High, High → Severe). Severe stays Severe.
  • The stored NumericStats.skewness_severity is not modified — the upgrade is ephemeral, used only within this routing call.
  • When tail_asymmetry_tag is Symmetric or None, effective severity equals stored severity.

NumericFlag.HighOutlierDensity as independent KNN trigger

Add NumericFlag.HighOutlierDensity as an independent escalation condition in the Priority 7 Minor/Moderate distribution shape gate, alongside KurtosisTag.Leptokurtic and SkewSeverity.Severe. A column at Minor or Moderate severity that has HighOutlierDensity set escalates to KNN (subject to size guards → Median fallback), regardless of its kurtosis tag or skewness.

Signal recording

When either signal triggers a routing change, append a diagnostic string to ColumnImputationRecord.signals:

  • Tail asymmetry upgrade: "tail_asymmetry_right_heavy: effective_skew_severity upgraded from {stored} to {effective}" or the left_heavy variant
  • Outlier density escalation: "high_outlier_density: escalated to KNN"

Acceptance criteria

  • A column with SkewSeverity.Moderate and TailAsymmetryTag.RightHeavy routes to KNN (same as Severe) — ColumnImputationRecord.strategy == ImputationStrategy.KNN
  • A column with SkewSeverity.Normal and TailAsymmetryTag.RightHeavy routes to KNN (upgraded from Normal to Moderate triggers distribution shape escalation path for Moderate+tail)
  • NumericStats.skewness_severity is unchanged after routing — stored severity is not mutated
  • A column with NumericFlag.HighOutlierDensity at Minor MCAR severity escalates to KNN, not Mean or Median
  • A Mesokurtic column with HighOutlierDensity escalates to KNN (flag fires independently of kurtosis)
  • ColumnImputationRecord.signals records the triggering signal for both mechanisms
  • A column with TailAsymmetryTag.Symmetric and no HighOutlierDensity follows existing routing unchanged (regression test)
  • All existing strategy router tests pass (no regressions)

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions