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.
API surface
| Endpoint | Purpose | Wired scaffold |
|---|---|---|
POST /api/v1/scenarios/run | Single scenario; returns ScenarioResult + 95 % CI on value delta. | lib/scenario/shadow-score.ts |
POST /api/v1/scenarios/compare | 2–10 scenarios; ranks by value delta with paired-bootstrap p-values. | lib/scenario/multi-compare.ts |
POST /api/v1/scenarios/distribution | Per-segment offer-share + Gini + KL (W11). | lib/scenario/distribution-simulator.ts |
POST /api/v1/scenarios/value-finder | Pareto sweep over revenue × fairness × coverage (W11). | lib/scenario/value-finder.ts |
POST /api/v1/scenarios/seasonality | Decompose a time-series window into weekly seasonality + trend + residual; optional forward forecast. | lib/scenario/seasonality.ts |
AuditLog rows so DSAR
exports can cite what was simulated.
Run body shape
offerValuesis optional. When absent,valueDeltais computed using score as a proxy for value, and the response setsmeta.valuesUsedProxy: true.maxTracescaps the archive window at 1–20000 rows.seedcontrols the bootstrap PRNG so the CI is reproducible.
Compare body shape
ScenarioResult plus a pValues matrix and a
rank ordering by value delta.
Seasonality body shape
history requires 7+ points. forecast is optional — when omitted,
only the decomposition is returned.
UI
/studio/scenarios ships 5 tabs (W11): Run, Compare, Distribution,
Value Finder, Seasonality. Run is the polished single-scenario form
with bootstrap-CI on value delta. The other four tabs surface raw
JSON request/response panels — operators paste in the body shape, hit
Run, see the structured response. Chart wrappers are roadmap polish.
Distribution Simulator (W11)
POST /api/v1/scenarios/distribution slices archived decisions by a
segment dimension and emits per-segment offer-share, share-delta, Gini
concentration index (0=uniform, 1=winner-take-all), and KL-divergence
(baseline ‖ scenario, nats).
segmentResolver is operator-supplied because there is no
Customer Prisma model — segment data lives in DataSchema-driven
ds_* tables and the operator’s UI / batch driver knows how to hydrate
it. Customers missing from the resolver are skipped honestly; the
meta.tracesScanned + meta.segmentsCovered block reports coverage
so operators see what fraction of the window was attributable.
Value Finder (W11)
POST /api/v1/scenarios/value-finder — Pareto-front sweep over
revenue × fairness × coverage.
rows[] carries per-scenario revenue / fairness / coverage / picks / dominated. paretoFront[] lists non-dominated names. The
recommended field is the Pareto-front member with the highest
geometric mean of normalized axes — a conservative default, never
binding.
Honest limits: fairness is NaN when the archive lacks segments
(returned, not silenced). revenue falls back to score-as-proxy when
offerValues are absent.
Honest limits
- Per-offer business value (margin / expected revenue) is best
supplied by the caller. When missing, the route falls back to score
as a proxy and explicitly flags it in
meta.valuesUsedProxy. - The compare endpoint loads the archive once per call; very wide
windows (
maxTracesnear the cap) on slow Postgres can take 10+s. - The seasonality endpoint does not query the DB for time-series data — the canonical KPI source varies per tenant. Caller supplies the history.