Skip to content
SlateGitOrgPublic

About

Root-cause search for a card authorisation-rate drop that splits mix from rate exactly and finds the dimension combination at fault by exhaustive deviance search, benchmarked on 30 planted incidents.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

rootcube

CI

rootcube

rootcube finds the cause of a drop in card authorisation rate. It splits the day's change exactly into a traffic-mix part and a rate part, then searches every combination of up to three dimensions (issuer, network, card type, merchant category, country, 3-D Secure flow) for the cuboid whose decline count is furthest above its baseline, using a closed-form Poisson likelihood gain and a threshold corrected for overdispersion and for the number of cuboids searched. It is benchmarked against 30 planted incidents on seeded synthetic data, including mix-only days where the right answer is "no rate fault". All data in this repository is synthetic.

The problem

A payment processor's merchant-operations team watches the authorisation rate every day. When it drops, say from 91.2% to 89.9%, analysts slice dashboards one dimension at a time for hours. Two things make that slow and error-prone:

  • The cause is usually a combination, for example one issuer's debit cards on challenge-flow 3-D Secure. A one-dimension breakdown blames whichever large value contains the fault (the whole issuer, or all debit cards), and the escalation to an issuer or an acquirer goes to the wrong place.
  • Often there is no fault at all. A flash sale that shifts traffic toward prepaid cards lowers the overall rate while every card type still approves exactly as before. Nobody separates mix from rate before escalating.

How it works

flowchart TD
    A["Baseline leaf-days<br/>14 days, 6 dimensions"] --> B["Main-effects logistic model<br/>statsmodels GLM, binomial"]
    B --> C["Empirical-Bayes shrinkage<br/>prior strength k by moments"]
    A --> D["Overdispersion phi<br/>Pearson chi-square / df"]
    C --> E["Exact split of the change<br/>mix part + rate part"]
    T["Incident day leaf table"] --> E
    C --> F["Exhaustive cuboid search<br/>41 groupbys, depth 1 to 3"]
    D --> F
    T --> F
    F --> G["Nesting rule<br/>parent versus child"]
    G --> H["Greedy additive selection<br/>up to 3 causes, rescale, rerun"]
    E --> I["explain report"]
    H --> I
    J["Planted incidents<br/>single, pair, triple, double, mix"] --> K["bench<br/>search versus naive"]
    I --> K
Loading
  1. Baseline (rootcube.baseline). A main-effects logistic model is fitted to the 14-day leaf totals. Each leaf's observed rate is shrunk toward its model prediction p by a beta-binomial prior, (approvals + k p) / (attempts + k), with k from the method of moments on the leaf-level Pearson statistic. phi is the Pearson chi-square over its degrees of freedom for leaf-day decline counts on the baseline days.
  2. Split (rootcube.split). With A the day's attempts, mix = sum(attempts x baseline leaf rate) / A - baseline overall rate and rate = (approvals - expected approvals) / A. They add up to the observed change exactly.
  3. Search (rootcube.search). A leaf expects E = attempts x (1 - baseline rate) declines. For every cuboid with 1, 2 or 3 fixed dimensions the observed declines D give a multiplier m = D / E and the gain G = D ln(D/E) - (D - E). A cuboid qualifies when 2G / phi exceeds the chi-square(1) quantile at 0.01 / (cuboids tested), it has at least 1,500 attempts and its excess is at least 0.05 percentage points of the day's attempts. A nesting rule picks between a parent and a child, and up to three causes are chosen greedily, rescaling each chosen cuboid's leaves by its multiplier before the search reruns.
  4. Incidents and benchmark (rootcube.incidents, rootcube.bench). A fresh day is drawn from the baseline process and an incident is planted. The search and a naive method (blame the one dimension value with the largest rate drop) are scored against the planted truth.

Quick start

python -m venv .venv && . .venv/bin/activate
pip install -c requirements-lock.txt -e ".[dev]"   # pinned versions, as in CI

rootcube generate --seed 5 --out data/        # 14 baseline days + 1 incident day (about 18 MB of CSV)
rootcube explain --data data/ --day 2026-03-15
rootcube explain --data data/ --day 2026-03-15 --json
rootcube bench --incidents 30 --normal-days 10 --seed 5
rootcube report --out out/                    # writes out/report.md
pytest -q

generate --incident takes single, pair (default), triple, double or mix. data/truth.json holds the planted incident type and its true cuboids.

Example output

rootcube generate --seed 5 --out data/ plants a pair fault (issuer_03 credit cards, decline probability x1.93). Then rootcube explain --data data/ --day 2026-03-15:

Day 2026-03-15   attempts 200,000
Authorisation rate  87.97% -> 87.16%  (-0.81 pp)
  mix part  -0.02 pp
  rate part -0.79 pp
Overdispersion phi 1.000   prior strength k 464

Ranked causes (974 cuboids searched, first threshold 19.5)
1. issuer=issuer_03 AND card_type=credit
   attempts 12,820  baseline rate 86.78%  today 74.00%
   excess declines 1,638  (104.3% of the rate deficit)
   multiplier 1.97  G 616.2  2G/phi 1,232.4 > 19.5

The share above 100% is sampling noise: the rate deficit also contains the binomial noise of the other 187,000 attempts.

rootcube bench --incidents 30 --normal-days 10 --seed 5:

type         incidents  search exact  naive exact
single       6          6/6           6/6
pair         6          6/6           0/6
triple       6          6/6           0/6
double       6          5/6           0/6
mix          6          6/6           0/6
fault total  24         23/24         6/24

False alarms on normal days: 0/10
  (the naive method always names a value, so it has no alarm threshold)
Lowest mix share of the change on mix incidents: 85.1%

"Exact" means the reported set of cuboids equals the planted set. On mix incidents the planted set is empty, so the search is exact only when it reports no cause. The naive method matches only the single incidents. The one miss on seed 5 is a double whose two faults are both on credit cards: the search reports both true cuboids and also the parent card_type=credit.

The same CLI reproduces the other seeds (for s in 6 7 8 9; do rootcube bench --seed $s; done, about 20 seconds each). Four more seeds, 24 planted faults each, 96 in all:

seed fault total single pair triple double lowest mix share
6 21/24 6/6 5/6 6/6 4/6 63.4%
7 23/24 6/6 6/6 6/6 5/6 80.4%
8 21/24 6/6 6/6 5/6 4/6 82.7%
9 24/24 6/6 6/6 6/6 6/6 87.3%

That is 89 of 96 exact, with no false alarms on any seed's 10 normal days and the naive method at 6/24 on every seed. Across seeds 5 to 9 there are 8 misses in 120 faults. The 5-to-9 totals by type are 30/30 single, 29/30 pair, 29/30 triple and 24/30 double. Seed 6 also has one mix incident whose mix share of the change is 63.4%, under the 80% bar, though it still reports no cause. Seeds 6 and 8 land under the 21-of-24 bar. The benchmark tests run seeds 5 and 9 so one draw does not carry the acceptance thresholds.

Design decisions

  • Exhaustive search instead of pruning. There are 41 dimension subsets of size 1 to 3 and each is one bincount over about 20,100 non-empty leaves a day, so a whole search costs milliseconds. For a single faulty cuboid the gain is maximised exactly at that cuboid: by convexity of x ln x, a parent dilutes the multiplier and a child covers only part of the excess. Heuristic pruning would add risk for no speed gain at this size. The cost grows with the number of leaves times 41 per round, so a book with many more dimensions would need pruning.
  • Bonferroni over every cuboid tested. The threshold is chi2.isf(0.01 / M, 1), where M is the number of cuboids with at least 1,500 attempts in that round (about 1,000 on this data), not the 41 groupbys. Testing a thousand cuboids at the uncorrected level would raise an alarm on most clean days. The correction costs power only for small effects: on seed 5 every planted fault has a statistic of at least 365 against a threshold near 19.5.
  • Nesting rule over a pure maximum-gain pick. A parent that merely dilutes a fault in one child is dropped when the parent's remainder (its leaves outside the child) shows no excess, and a child is dropped when the remainder does show excess. The weakness is that the remainder test is a 5% test: a large parent's remainder shows spurious excess about 2.5% of the time, which is where the occasional miss comes from. Two faults under a common parent (for example two issuers' credit cards) can surface the parent, as in the seed-5 miss. The benchmark's double incidents are two plain disjoint faults drawn from single dimensions and issuer x card type pairs, so some of them do share a parent. The shared-parent cases are included in every figure above; rootcube bench prints only counts, so the README makes no claim about how the other misses are composed.
  • phi is floored at 1. On this data the pooled Pearson ratio is 0.83, below the Poisson value, because decline counts are binomial and mostly tiny. Dividing by a phi below 1 would make the search more liberal than the Poisson model on large cuboids, where day noise and baseline error add variance back. Baseline.pearson_phi keeps the raw ratio.
  • Shrinkage toward a main-effects model. A leaf with 40 baseline attempts and 30 approvals would look like a 75% leaf and produce a spurious fault. The empirical-Bayes rate stays near the model prediction in proportion to how little data the leaf has (k is about 460 here, so a 40-attempt leaf keeps about 8% of its own rate). The main-effects model does not capture interactions, so a genuine interaction in the baseline would show up as a standing excess; the stable leaf effect in the synthetic data is the only departure from additivity.
  • Mix-versus-rate first. The split is arithmetic, not a model, so mix + rate equals the observed change to floating-point precision (tested to 1e-12 on every benchmark day). A day whose change is mostly mix reports "no rate fault" instead of a cause.
  • Mix incidents alternate their traffic shift. rootcube generate --incident mix passes the seed as the variant, so an even seed scales prepaid traffic by 2.5 and an odd seed scales the worst country's traffic by 2.0. The benchmark alternates the same two shifts by incident index instead.
  • Cause figures after the first pick. In the second and third greedy round base rate and excess declines are measured against expected declines already rescaled by the earlier picks, so a cause that overlaps an earlier pick reports a base rate that includes the earlier multiplier.
  • Where the synthetic book differs from a typical brief. The overall approval rate is about 88%, not 91%. Planted faults are capped (at most 25% of the day's attempts and excess declines of at most 2% of the day's attempts) so no incident is the whole book. The search tests only cuboids with at least 1,500 attempts, so the family size is about 1,000 rather than 41.

Testing

83 tests, all offline and deterministic, run with pytest -q (about 60 seconds). They include the hand-computed 2 x 2 fixture (change -0.05, mix 0, rate -0.05, top cause A=a2 AND B=b2 with G = 300 ln 3 - 200 = 129.584), the mix fixture (change -0.0375, all mix), 200 seeded noise-free cubes that check both the convexity claim and the nesting rule, the shrinkage case, and the benchmark thresholds on seeds 5 and 9 (at least 21 of 24 fault incidents matched, every mix incident reported as no cause with at least 80% of the change from mix, naive at most 8 of 24, at most one false alarm on 10 normal days). CLI tests strip ANSI codes and run with COLUMNS=80. Dependencies carry upper bounds in pyproject.toml and exact versions are pinned in requirements-lock.txt (regenerate with uv pip compile pyproject.toml --extra dev --universal --python-version 3.12 -o requirements-lock.txt); CI installs with that file as constraints because benchmark outcomes depend on numeric library versions and the test suite treats warnings as errors.

ruff check . && ruff format --check . && pytest -q

Project layout

src/rootcube/
  schema.py      the six dimensions and their values
  world.py       seeded generator of leaf-days (logits, traffic, faults)
  incidents.py   planted incidents: single, pair, triple, double, mix
  baseline.py    GLM, empirical-Bayes shrinkage, overdispersion
  split.py       exact mix / rate split
  search.py      exhaustive deviance search, nesting rule, greedy selection
  naive.py       the one-dimension baseline method
  explain.py     explanation object and text / JSON output
  bench.py       benchmark against planted truth
  report.py      Markdown report
  cli.py         typer commands: generate, explain, bench, report
tests/           pytest suite
.github/workflows/ci.yml

License

MIT. See LICENSE.

About

Root-cause search for a card authorisation-rate drop that splits mix from rate exactly and finds the dimension combination at fault by exhaustive deviance search, benchmarked on 30 planted incidents.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages