Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.kaireonai.com/llms.txt

Use this file to discover all available pages before exploring further.

Inheritance dedupe

Without the flag, getEffectiveRules returns every rule whose scope matches the offer (global, category, subcategory, offer). When two rules share a name (e.g., a global “min_age=18” and an offer-specific “min_age=21”), both flow through. When inheritanceEnabled is on (or ?explainCascade=true is supplied), the resolver collapses duplicates to the most-specific scope per name using the precedence:
offer > subcategory > category > global
The dedupe is implemented by resolveEffectiveRules in lib/qualification/inheritance.ts.

Configuration

{
  "aiAnalyzerSettings": {
    "qualification": {
      "inheritanceEnabled": true
    }
  }
}
Default off — every existing tenant is unchanged. Snapshot regression tests cover the bit-identity guarantee for flag-off paths.

Time-aware windows

Rules can declare a config.timeWindow shape. The resolver evaluates matchesTimeWindow(asOf, window) per rule when the route is called with ?asOf=ISO8601. Rules whose window does not include asOf are filtered out.

Window shape

{
  "timeWindow": {
    "daysOfWeek": [0, 1, 2, 3, 4],
    "startHour": "09:00",
    "endHour": "17:00",
    "from": "2026-04-01",
    "to": "2026-04-30",
    "timezone": "Europe/London",
    "blackoutDates": ["2026-04-25"]
  }
}
All fields optional. Unset fields don’t constrain.

Honest fail-open on malformed windows

When a rule has config.timeWindow set but the value is not a plain object, the filter falls open (the rule is preserved). This matches the existing “rules must work even when storage shape drifts” contract elsewhere in the codebase. Schema validation upstream is the place to enforce strict shape.

explainCascade

?explainCascade=true implies inheritance dedupe and populates cascadeTrace in the response — a per-name list of every candidate that contributed to the dedupe:
{
  "cascadeTrace": {
    "min_age": [
      { "scope": "global", "scopeId": null, "ruleId": "qr-global" },
      { "scope": "offer",  "scopeId": "o1", "ruleId": "qr-offer" }
    ]
  }
}
Useful for compliance UIs that need to render “rule X applies because of category Y” with a full chain.

Snapshot regression

Six new tests in effective-rules-inheritance.test.ts:
  • Default options preserve every matching rule (bit-identical to prior behavior).
  • inheritanceMode: "deduped" collapses duplicates to most-specific scope.
  • explainCascade: true populates cascadeTrace per-name.
  • asOf filters rules whose timeWindow excludes the instant.
  • asOf keeps rules whose timeWindow includes the instant.
  • Malformed timeWindow falls open (preserves the rule).