Connect your application¶
Configure a comparison¶
The shipped examples/compare/evaluation.toml uses this structure. Data paths
are relative to the TOML file; store arguments are relative to the working directory.
schema_version = 1
evalset = "validation.jsonl"
discovery = "discovery.jsonl"
group_key = "customer"
taxonomy = "taxonomy.json"
[pipeline]
kind = "reference"
k = 1
[objective]
metric = "accuracy"
max_right_to_wrong = 0
max_right_to_wrong_cost = 0
[objective.min_slice_metric]
authorization = 1.0
[objective.min_slice_cases]
authorization = 1
compare exits 0 when all requirements pass, 1 when an edit fails a
requirement, and 2 for invalid input or an unevaluable gate. Empty evaluations,
missing required slices, insufficient slice samples, and non-finite primary
metrics cannot pass. --json - writes only JSON to standard output.
objective.metric supports accuracy (higher is better) and
weighted_error_cost (lower is better). min_primary_delta is the required
improvement in the selected direction and defaults to zero. min_slice_metric
sets floors; max_slice_metric sets ceilings, useful for error cost.
max_right_to_wrong_cost caps the total cost of newly broken cases even when
overall accuracy improves. max_right_to_wrong_frac caps newly broken cases as
a fraction of all evaluation cases. Error costs are caller-supplied weights,
not API spending estimates.
The reference pipeline uses hashing and majority vote. It accepts k,
dimension, scope_aware, and fallback. To evaluate your production pipeline,
set kind = "custom" and factory = "your_package.adapters:build" under
[pipeline]. The installed Python factory receives the [pipeline.options]
table and returns storecheck.Pipeline(run, identity). The synchronous run
callable receives a Query and either a Store or external Snapshot, and returns
Prediction(label, evidence, trace). It owns the whole application: hybrid search,
filters, fusion, reranking, context formatting, and classification. Storecheck
calls it once per case per revision and never reuses a prediction.
Query exposes text, scope, and metadata, without the reference label, cost, or
evaluation slice tags. Metadata must contain only runtime inputs. Prediction
retains the actual final evidence as ordered Row objects; its optional JSON
trace can record scores, formatted context, or provider revisions. If evidence
is unavailable, an empty tuple is allowed and outcome comparison still works,
but the report cannot explain retrieval changes.
Include code, model, prompt, retrieval settings, and sampling settings in the nonsecret pipeline identity. Read credentials from the application’s environment. A custom factory executes Python code from that module. Application errors abort the run; they are not scored as successes or silently retried.
Gate an edit in Python¶
from storecheck import (
Case,
EmbeddingRetriever,
EvalSet,
HashingEmbedder,
MajorityVoteDecider,
Objective,
Pipeline,
Prediction,
Row,
Store,
compare_stores,
)
baseline = Store([Row("password rejected", "authentication", id="login")])
candidate = baseline.edit("login", label="billing")
cases = EvalSet([Case("login-case", "password rejected", "authentication")])
retriever = EmbeddingRetriever(HashingEmbedder(), k=1)
decider = MajorityVoteDecider()
def application(query, snapshot):
rows = retriever.retrieve(query.text, snapshot, scope=query.scope)
return Prediction(decider.decide(query.text, rows), tuple(rows))
report = compare_stores(
baseline,
candidate,
cases,
pipeline=Pipeline(
application,
{"retriever": "hashing-bow-v2:1024:k1", "decider": "majority-v1"},
),
objective=Objective(max_right_to_wrong=0),
)
print(report.summary())
assert report.exit_code == 1
compare_stores() returns the same ComparisonReport as the CLI. Use
to_dict() to inspect it and to_json(path) to save it. Custom primary metrics
are supported through Objective; include their configuration in
pipeline.identity["metric"]. The lower-level RegressionCheck and
storecheck.testing.assert_clean() remain available for collected check reports.