mistrial 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mistrial might be problematic. Click here for more details.

Files changed (47) hide show
  1. mistrial-0.2.0/.github/ISSUE_TEMPLATE/bug_report.md +23 -0
  2. mistrial-0.2.0/.github/ISSUE_TEMPLATE/feature_request.md +13 -0
  3. mistrial-0.2.0/.github/workflows/ci.yml +33 -0
  4. mistrial-0.2.0/.gitignore +12 -0
  5. mistrial-0.2.0/CHANGELOG.md +55 -0
  6. mistrial-0.2.0/CONTRIBUTING.md +51 -0
  7. mistrial-0.2.0/LICENSE +21 -0
  8. mistrial-0.2.0/PKG-INFO +463 -0
  9. mistrial-0.2.0/README.md +434 -0
  10. mistrial-0.2.0/SECURITY.md +26 -0
  11. mistrial-0.2.0/action.yml +129 -0
  12. mistrial-0.2.0/docs/COMPARISON.md +79 -0
  13. mistrial-0.2.0/docs/LAUNCH.md +124 -0
  14. mistrial-0.2.0/docs/PLAN.md +50 -0
  15. mistrial-0.2.0/docs/demo.gif +0 -0
  16. mistrial-0.2.0/docs/demo.tape +79 -0
  17. mistrial-0.2.0/docs/explainer/SCRIPT.md +36 -0
  18. mistrial-0.2.0/docs/explainer/explainer.html +359 -0
  19. mistrial-0.2.0/docs/explainer/frames.mjs +35 -0
  20. mistrial-0.2.0/docs/explainer-poster.png +0 -0
  21. mistrial-0.2.0/docs/img/compare.png +0 -0
  22. mistrial-0.2.0/docs/img/how.png +0 -0
  23. mistrial-0.2.0/docs/img/problem.png +0 -0
  24. mistrial-0.2.0/docs/img/results.png +0 -0
  25. mistrial-0.2.0/docs/report.png +0 -0
  26. mistrial-0.2.0/examples/cases.jsonl +20 -0
  27. mistrial-0.2.0/examples/my_evals.py +14 -0
  28. mistrial-0.2.0/examples/tricky.jsonl +32 -0
  29. mistrial-0.2.0/pyproject.toml +47 -0
  30. mistrial-0.2.0/src/mistrial/__init__.py +7 -0
  31. mistrial-0.2.0/src/mistrial/cache.py +61 -0
  32. mistrial-0.2.0/src/mistrial/cases.py +130 -0
  33. mistrial-0.2.0/src/mistrial/cli.py +453 -0
  34. mistrial-0.2.0/src/mistrial/data/demo_cases.jsonl +20 -0
  35. mistrial-0.2.0/src/mistrial/judges.py +571 -0
  36. mistrial-0.2.0/src/mistrial/probes.py +411 -0
  37. mistrial-0.2.0/src/mistrial/prompts.py +136 -0
  38. mistrial-0.2.0/src/mistrial/report.py +604 -0
  39. mistrial-0.2.0/src/mistrial/runner.py +170 -0
  40. mistrial-0.2.0/src/mistrial/stats.py +555 -0
  41. mistrial-0.2.0/tests/test_cases.py +45 -0
  42. mistrial-0.2.0/tests/test_cli.py +52 -0
  43. mistrial-0.2.0/tests/test_features.py +339 -0
  44. mistrial-0.2.0/tests/test_llm_adapters.py +138 -0
  45. mistrial-0.2.0/tests/test_providers.py +111 -0
  46. mistrial-0.2.0/tests/test_runner.py +122 -0
  47. mistrial-0.2.0/tests/test_stats.py +139 -0
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: Bug report
3
+ about: Something gave the wrong result or crashed
4
+ labels: bug
5
+ ---
6
+
7
+ **Command you ran**
8
+
9
+ ```bash
10
+ mistrial run ...
11
+ ```
12
+
13
+ **What happened**
14
+
15
+ Paste the output or traceback.
16
+
17
+ **What you expected**
18
+
19
+ **Environment**
20
+
21
+ - mistrial version (`mistrial --version`):
22
+ - Python version:
23
+ - OS:
@@ -0,0 +1,13 @@
1
+ ---
2
+ name: Feature request
3
+ about: A metric, adapter, loader or report change
4
+ labels: enhancement
5
+ ---
6
+
7
+ **What you want to do**
8
+
9
+ **What you do today instead**
10
+
11
+ **If it is a new metric**
12
+
13
+ Link to the formula or paper and, if you can, a small worked example with the expected number.
@@ -0,0 +1,33 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12", "3.13"]
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: actions/setup-python@v5
18
+ with:
19
+ python-version: ${{ matrix.python-version }}
20
+ - run: python -m pip install -e ".[dev]"
21
+ - run: python -m pytest -q
22
+ - name: demo smoke test
23
+ run: |
24
+ mistrial demo --runs 5 --html none --out-dir /tmp/jf --adaptive --stabilize 3 --pass-mark 0.55
25
+ mistrial rubric-check examples/cases.jsonl -j demo:steady --out-dir /tmp/jf -q
26
+ run=$(ls /tmp/jf/runs/2*.json | head -1)
27
+ mistrial gate-risk "$run" --pass-mark 0.5
28
+ mistrial migrate "$run" --pass-mark 0.6
29
+ mistrial escalate "$run" --out /tmp/jf/needs-human.csv
30
+ mistrial sentinel baseline "$run" --out /tmp/jf/base.json
31
+ mistrial report "$run" --html none --markdown /tmp/jf/card.md
32
+ - name: build
33
+ run: python -m pip install -q build twine && python -m build -q && python -m twine check dist/*
@@ -0,0 +1,12 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ dist/
5
+ build/
6
+ *.egg-info/
7
+ .pytest_cache/
8
+ .mistrial/
9
+ report.html
10
+ report.json
11
+ .DS_Store
12
+ docs/*.mp4
@@ -0,0 +1,55 @@
1
+ # Changelog
2
+
3
+ All notable changes to mistrial are recorded here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses [Semantic Versioning](https://semver.org/).
4
+
5
+ ## [Unreleased]
6
+
7
+ Nothing yet.
8
+
9
+ ## [0.2.0] - 2026-10-26
10
+
11
+ First public release. Ten additions over 0.1.0, each answering a documented way LLM judges go wrong in production.
12
+
13
+ ### Added
14
+ - **Rubric sensitivity** (`mistrial rubric-check`): run the judge under three rewordings of the rubric that mean the same thing, report the share of verdicts that change and Krippendorff's alpha across wordings. Built-in rewordings for `correctness` and `quality`; bring your own with `--variant`.
15
+ - **Rubric reversal** (same command): ask with the criterion flipped and check that verdicts invert. Reports the cases where the judge gave the same answer to "is it correct?" and "is it incorrect?".
16
+ - **Gate false-alarm rate** (`--pass-mark` on `run`/`report`, and `mistrial gate-risk`): how often your CI gate would go red with nothing changed, by re-sampling each case's observed verdicts; plus a safe mark and the runs per case that bring the rate under 5%.
17
+ - **Judge migration** (`mistrial migrate`): old judge vs new judge on the same cases, with your pass mark translated to the new judge and a per-case cutoff mapped by quantile.
18
+ - **Sentinel** (`mistrial sentinel baseline` / `check`): freeze a run on anchor cases, re-judge fresh on a schedule, exit 2 on JUDGE_DRIFT. Design credit: judge-drift-sentinel.
19
+ - **Parser audit**: every LLM verdict keeps the raw reply and how it was read (strict JSON, fenced, embedded in prose, no verdict). The card shows the counts and examples.
20
+ - **Adaptive re-ask** (`--adaptive`): two runs everywhere, extra runs only where the two disagreed. The card reports the calls skipped.
21
+ - **Escalation** (`mistrial escalate`): a CSV of the cases a human should look at, with a column for their verdict; `--langsmith-dataset` pushes them to LangSmith.
22
+ - **Stabilized evaluator** (`--stabilize K` and `mistrial.stabilize()`): the judge wrapped in a K-sample majority vote with the same evaluator signature, measured next to the raw one.
23
+ - **GitHub Action** (`action.yml`): runs the card in CI, posts it as a PR comment, uploads the HTML report, fails the job on a gate. `--markdown` writes the same card anywhere.
24
+ - `examples/tricky.jsonl`: 32 labeled cases built to be hard to judge (hedges, rounding, unit conversions, extra details, equivalent code). The bundled `examples/cases.jsonl` stays as the easy set.
25
+ - `mistrial demo` says up front that its three judges are fake and flaky on purpose.
26
+ - `docs/img/compare.png`, a feature comparison against judgecheck, judgebench, Assay, judge-drift-sentinel and LangSmith/promptfoo, and a "Standing on shoulders" README section with the papers and repos this builds on.
27
+ - Judges for every OpenAI-compatible provider: `gemini:`, `groq:`, `mistral:`, `deepseek:`, `xai:`, `together:`, `openrouter:`, `ollama:` (local, no key) and `custom:` with `MISTRIAL_BASE_URL`. `<PROVIDER>_BASE_URL` overrides any base URL. `mistrial providers` lists them.
28
+ - An 88 second animated explainer video (`docs/explainer.mp4`, not committed) rendered from `docs/explainer/explainer.html`: the problem, why it slips through, the command, the real numbers, the fix. Narration script and re-render steps in `docs/explainer/SCRIPT.md`.
29
+
30
+ ### Changed
31
+ - The project is called **mistrial**. Package, command, env vars (`MISTRIAL_BASE_URL`, `MISTRIAL_API_KEY`) and the `.mistrial/` directory all follow. It was briefly called judgeflake before any release.
32
+ - README, demo GIF and report screenshot now show real, current OpenAI judges (`gpt-5.4-nano`, `gpt-5.4-mini`, `gpt-5.5`) instead of the fake `demo` judges. The numbers in the README come from 480 live calls made on 2026-10-25.
33
+ - README opens with the problem, why nothing catches it today, and what mistrial does, with three diagrams in `docs/img/`.
34
+ - Saved runs are format version 2 (adds `adaptive`, `calls_saved`, and `text`/`parse` per verdict). Version 1 files still load.
35
+
36
+ ## [0.1.0] - 2026-10-25
37
+
38
+ First tagged version, never published.
39
+
40
+ ### Added
41
+ - `mistrial run`: run one or more judges over a cases file N times and print the reliability card.
42
+ - Judges: `openai:<model>`, `anthropic:<model>`, any Python `module:function` with the LangSmith / openevals signature, and deterministic `demo` judges.
43
+ - Cases from JSONL, JSON or CSV with common field aliases and an optional human `label`.
44
+ - Metrics: self-agreement, flip rate, per-case disagreement, pairwise percent agreement and Cohen's kappa, Krippendorff's alpha (nominal and interval, missing values allowed), accuracy and kappa against human labels.
45
+ - Built-in rubrics `correctness` and `quality`, or a prompt file.
46
+ - Terminal card, single-file HTML report (light and dark), JSON report.
47
+ - On-disk response cache with `--fresh` to bypass it.
48
+ - `mistrial compare` for drift between two saved runs.
49
+ - CI gates: `--min-self-agreement`, `--max-flip-rate`, `--min-agreement`.
50
+ - `mistrial demo`: three fake judges on twenty bundled cases, no API key.
51
+ - `mistrial report` to re-render a saved run and `mistrial rubrics` to list rubrics.
52
+
53
+ [Unreleased]: https://github.com/hemanth1999k/mistrial/compare/v0.2.0...HEAD
54
+ [0.2.0]: https://github.com/hemanth1999k/mistrial/compare/v0.1.0...v0.2.0
55
+ [0.1.0]: https://github.com/hemanth1999k/mistrial/releases/tag/v0.1.0
@@ -0,0 +1,51 @@
1
+ # Contributing
2
+
3
+ Thanks for looking. mistrial is small on purpose, so most contributions are quick.
4
+
5
+ ## Setup
6
+
7
+ ```bash
8
+ git clone https://github.com/hemanth1999k/mistrial.git
9
+ cd mistrial
10
+ python3 -m venv .venv && .venv/bin/pip install -e ".[dev]"
11
+ .venv/bin/pytest -q
12
+ .venv/bin/mistrial demo
13
+ ```
14
+
15
+ Python 3.10 or newer. No API key is needed for the tests or the demo; the OpenAI and Anthropic adapters are tested against a fake HTTP server.
16
+
17
+ ## What is welcome
18
+
19
+ - Bug reports with the command you ran and the output you got.
20
+ - Adapters for other providers. Follow `LLMJudge._openai` in `src/mistrial/judges.py`: plain `httpx`, retries on 429 and 5xx, one JSON verdict out.
21
+ - Rubrics. Add to `RUBRICS` in `src/mistrial/prompts.py` with a one-line description.
22
+ - Loaders for other case formats, in `src/mistrial/cases.py`.
23
+ - Report improvements, in `src/mistrial/report.py`. Keep it one file with no external assets.
24
+
25
+ ## Rules for metrics
26
+
27
+ A new number on the card needs all three:
28
+
29
+ 1. A published formula, cited in the docstring.
30
+ 2. A test in `tests/test_stats.py` against a known example from the literature or a hand-computed case.
31
+ 3. A line in the README table saying what it means and what it does not mean.
32
+
33
+ No invented scores and no letter grades. The card shows numbers and a one-line reading of them.
34
+
35
+ ## Pull requests
36
+
37
+ - One change per PR, with a test.
38
+ - Run `pytest -q` and `mistrial demo --runs 3 --html none` before opening it.
39
+ - Add a line under `[Unreleased]` in `CHANGELOG.md`.
40
+ - Keep the PR description short: what changed and why.
41
+
42
+ ## The demo GIF
43
+
44
+ `docs/demo.gif` is rendered from `docs/demo.tape` with [VHS](https://github.com/charmbracelet/vhs): `brew install vhs && vhs docs/demo.tape`. Re-render it when the card's layout changes.
45
+
46
+ ## Releasing (maintainers)
47
+
48
+ 1. Bump `version` in `pyproject.toml`, move `[Unreleased]` entries under the new version in `CHANGELOG.md`.
49
+ 2. `git tag v0.x.y && git push --tags`.
50
+ 3. `python -m build && python -m twine upload dist/*`.
51
+ 4. Create the GitHub release from the tag with the changelog section as notes.
mistrial-0.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hemanth Dhanasekaran
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.