Docs Query language

Query language and API

Three verbs cover the surface — insert events, ask for top causes, and give feedback.

Three verbs cover the surface: insert events, ask for top causes, and give feedback.

HQL

REGISTER EFFECT bloating KERNEL lognormal(median => 2.5h, sigma => 0.6)
  PRIORS (beans => (3,1), dairy => (2,1));
 
INSERT EVENT meal FOR me AT '2026-10-19 19:30'
  FEATURES (beans, onion, cheese) WEIGHT 1.5;
 
TOP 3 CAUSES OF bloating FOR me AT now() WITHIN 12h EXPLAIN;
 
-- one effect across several entities (scores comparable once calibrated)
TOP 3 CAUSES OF latency_spike FOR checkout, payments, search AT now() EXPLAIN;
 
FEEDBACK bloating FOR me AT '2026-10-19 22:45' CONFIRMED evt_0042;
 
-- code changes: likely culprit PRs, and pre-merge risk of an open PR
TOP 3 CAUSES OF error_spike FOR checkout AT now() EXPLAIN;
RISK OF incident FOR checkout FEATURES migration, review:fast WEIGHT 1.2 EXPLAIN;
 
CALIBRATION OF bloating BINS 10;

Library API

The same operations as a library call:

db.register_effect("bloating", kernel=LogNormalKernel(median=2.5*3600, sigma=0.6),
                   priors={"beans": (3, 1), "dairy": (2, 1)})
db.insert(entity="me", time=t, type="meal", features={"beans", "onion"}, weight=1.5)
for c in db.top_causes(entity="me", effect="bloating", at=now, k=3, explain=True):
    print(c.event, c.score, c.explanation)
db.feedback(entity="me", effect_type="bloating", at_time=now, confirmed_event_id=c.event.id)
 
# domain knowledge, dose, groups, calibration, privacy
db.add_rule("dispute", "small transaction", lambda e: e.attrs.get("amount", 0) < 10, 0.3)
db.register_event_type("meal", weight=lambda a: a.get("portion", 1.0))
db.top_causes_group(["checkout", "payments"], "latency_spike", at=now, k=3)
db.calibration_report("bloating", bins=10)
db.feature_risk("incident", {"migration", "review:fast"}, entity="checkout", weight=1.2)
db.forget_entity("me", scrub_global=True)

Priority heaps

Priority uses get a simpler surface: PUSH, PEEK, POP on a named forward-decay heap with a half-life.