Metadata-Version: 2.4
Name: regression-substrate
Version: 0.1.0
Summary: A statistically rigorous CI gate for AI: treats model outputs as distributions, penalizes unreliable judges, and decides ship / hold / regression.
License: MIT License
        
        Copyright (c) 2026 [Your Name or Organization]
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: ci,evaluation,llm,mlops,regression-testing
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Requires-Dist: scipy>=1.10
Provides-Extra: clustering
Requires-Dist: scikit-learn>=1.2; extra == 'clustering'
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: scikit-learn>=1.2; extra == 'dev'
Provides-Extra: embeddings
Requires-Dist: sentence-transformers>=2.2; extra == 'embeddings'
Provides-Extra: langsmith
Requires-Dist: langsmith>=0.1; extra == 'langsmith'
Description-Content-Type: text/markdown

# regression-substrate

A statistically rigorous CI gate for AI systems. It treats model outputs as
distributions, penalizes unreliable judges, and returns a `SHIP` / `HOLD` /
`REGRESSION` verdict you can block a pull request on.

## Install

```bash
pip install regression-substrate            # core (numpy, scipy)
pip install "regression-substrate[clustering]"   # + auto_cluster (scikit-learn)
pip install "regression-substrate[langsmith]"    # + LangSmith adapter
```

For development (editable install with test dependencies):

```bash
git clone <repo-url>
cd regression-substrate
pip install -e ".[dev]"
```

## CLI (drop into CI)

```bash
regsub --data evals.csv --gold gold.jsonl --version-a v1 --version-b v2 --out out/
# exit 0 = SHIP / SHIP_WITH_FLAGS ; 1 = REGRESSION / HOLD ; 2 = JUDGE_INADMISSIBLE
```

One line in your CI pipeline blocks the PR on a regression.

## Library

```python
from regression_substrate import gate, load_from_csv, Judge

judge = Judge(my_llm_scorer)            # any (input, response) -> [0,1]
cal = judge.calibrate(gold_records)     # -> kappa, error_sd
sa, sb, cids, meta = load_from_csv("evals.csv", "v1", "v2")
decision = gate(sa, sb, cids, judge_error_sd=cal["error_sd"], kappa=cal["kappa"])
print(decision.verdict)
```

## What's inside

| Module | Purpose |
|---|---|
| `diff_engine` | Offline gate: variance components, bootstrap CI, cluster scan, BH/e-BH |
| `ingest` | Loaders (JSONL, CSV), judge harness, auto-clustering |
| `sequential_gate` | Always-valid martingale monitor for continuous deployment |
| `gold` | Rolling gold set, drift detection, forced sampling for labeling |
| `adapters` | Vendor flatteners (LangSmith preset) |
| `otel_exporter` | OTel-aligned span capture path |
| `cli` | The `regsub` console command |

## Running tests

```bash
pip install -e ".[dev]"
pytest
```

See `examples/` for a runnable dataset and `CHANGES.md` for design decisions.
