modelpin 0.1.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.
Files changed (49) hide show
  1. modelpin-0.1.0/LICENSE +201 -0
  2. modelpin-0.1.0/PKG-INFO +380 -0
  3. modelpin-0.1.0/README.md +343 -0
  4. modelpin-0.1.0/modelpin/__init__.py +3 -0
  5. modelpin-0.1.0/modelpin/cli.py +336 -0
  6. modelpin-0.1.0/modelpin/config.py +46 -0
  7. modelpin-0.1.0/modelpin/detector/__init__.py +49 -0
  8. modelpin-0.1.0/modelpin/diff/__init__.py +208 -0
  9. modelpin-0.1.0/modelpin/diff/semantic.py +71 -0
  10. modelpin-0.1.0/modelpin/diff/stats.py +132 -0
  11. modelpin-0.1.0/modelpin/diff/structural.py +110 -0
  12. modelpin-0.1.0/modelpin/judge.py +102 -0
  13. modelpin-0.1.0/modelpin/models.py +155 -0
  14. modelpin-0.1.0/modelpin/providers/__init__.py +45 -0
  15. modelpin-0.1.0/modelpin/providers/_common.py +45 -0
  16. modelpin-0.1.0/modelpin/providers/anthropic.py +17 -0
  17. modelpin-0.1.0/modelpin/providers/base.py +33 -0
  18. modelpin-0.1.0/modelpin/providers/fake.py +39 -0
  19. modelpin-0.1.0/modelpin/providers/google.py +276 -0
  20. modelpin-0.1.0/modelpin/providers/openai.py +352 -0
  21. modelpin-0.1.0/modelpin/replay/__init__.py +14 -0
  22. modelpin-0.1.0/modelpin/report/__init__.py +81 -0
  23. modelpin-0.1.0/modelpin/scenarios/__init__.py +35 -0
  24. modelpin-0.1.0/modelpin/storage.py +72 -0
  25. modelpin-0.1.0/modelpin/watcher/__init__.py +41 -0
  26. modelpin-0.1.0/modelpin.egg-info/PKG-INFO +380 -0
  27. modelpin-0.1.0/modelpin.egg-info/SOURCES.txt +47 -0
  28. modelpin-0.1.0/modelpin.egg-info/dependency_links.txt +1 -0
  29. modelpin-0.1.0/modelpin.egg-info/entry_points.txt +3 -0
  30. modelpin-0.1.0/modelpin.egg-info/requires.txt +14 -0
  31. modelpin-0.1.0/modelpin.egg-info/top_level.txt +1 -0
  32. modelpin-0.1.0/pyproject.toml +58 -0
  33. modelpin-0.1.0/setup.cfg +4 -0
  34. modelpin-0.1.0/tests/test_cli.py +117 -0
  35. modelpin-0.1.0/tests/test_cli_hardening.py +183 -0
  36. modelpin-0.1.0/tests/test_common.py +37 -0
  37. modelpin-0.1.0/tests/test_config.py +55 -0
  38. modelpin-0.1.0/tests/test_detector.py +10 -0
  39. modelpin-0.1.0/tests/test_diff.py +277 -0
  40. modelpin-0.1.0/tests/test_judge.py +101 -0
  41. modelpin-0.1.0/tests/test_models.py +38 -0
  42. modelpin-0.1.0/tests/test_provider_google.py +229 -0
  43. modelpin-0.1.0/tests/test_provider_openai.py +434 -0
  44. modelpin-0.1.0/tests/test_replay.py +10 -0
  45. modelpin-0.1.0/tests/test_report.py +41 -0
  46. modelpin-0.1.0/tests/test_scenarios.py +49 -0
  47. modelpin-0.1.0/tests/test_semantic.py +75 -0
  48. modelpin-0.1.0/tests/test_storage.py +97 -0
  49. modelpin-0.1.0/tests/test_watcher.py +30 -0
modelpin-0.1.0/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Samarth Puthraya
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,380 @@
1
+ Metadata-Version: 2.4
2
+ Name: modelpin
3
+ Version: 0.1.0
4
+ Summary: Dependabot for AI models — catch model-migration regressions before they hit production.
5
+ Author: Samarth Puthraya
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://modelpin.dev
8
+ Project-URL: Repository, https://github.com/samarthputhraya/modelpin
9
+ Project-URL: Issues, https://github.com/samarthputhraya/modelpin/issues
10
+ Keywords: llm,ai,agents,regression-testing,model-pinning,evals,ci,dependabot
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Quality Assurance
18
+ Classifier: Topic :: Software Development :: Testing
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Classifier: Environment :: Console
21
+ Requires-Python: >=3.12
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: typer>=0.12
25
+ Requires-Dist: rich>=13.7
26
+ Requires-Dist: pydantic>=2.7
27
+ Requires-Dist: pyyaml>=6.0
28
+ Provides-Extra: providers
29
+ Requires-Dist: openai>=1.40; extra == "providers"
30
+ Requires-Dist: google-genai>=1.0; extra == "providers"
31
+ Requires-Dist: anthropic>=0.34; extra == "providers"
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest>=8; extra == "dev"
34
+ Requires-Dist: ruff>=0.5; extra == "dev"
35
+ Requires-Dist: black>=24.0; extra == "dev"
36
+ Dynamic: license-file
37
+
38
+ # Modelpin
39
+
40
+ **Dependabot for AI models.** Know before the model breaks you.
41
+
42
+ A provider ships a new model (or retires the one you depend on). Modelpin **replays your app's
43
+ real behavior** on the new model, decides whether anything *actually* regressed despite model
44
+ randomness, and posts a PR-style report — so you find out in a pull request, not in production.
45
+
46
+ CLI: `modelpin` (alias `mp`). License: Apache-2.0.
47
+
48
+ ---
49
+
50
+ ## Why this exists (and why you can trust the verdict)
51
+
52
+ Models are non-deterministic. Run the same prompt twice and the words change. So the naive way to
53
+ "test a new model" — diff the text — cries wolf on every run. An alerter that cries wolf is worse
54
+ than no alerter: you mute it, then it misses the real break.
55
+
56
+ Modelpin's entire design optimizes for **one north-star metric: false-positive rate.** The promise
57
+ is narrow and falsifiable: *if Modelpin says it broke, it broke.* Everything below is in service of
58
+ that promise — and where the evidence is thin, this README says so plainly.
59
+
60
+ This is meant to be the **independent, no-BS** tool: it measures behavior change **relative to your
61
+ app**, it never declares one model globally "better," and the whole harness is open source so you
62
+ can reproduce it and disagree.
63
+
64
+ ---
65
+
66
+ ## Quickstart
67
+
68
+ Install from source (not on PyPI yet — see [Install](#install)):
69
+
70
+ ```bash
71
+ git clone https://github.com/samarthputhraya/modelpin
72
+ cd modelpin
73
+ pip install -e ".[dev,providers]"
74
+ ```
75
+
76
+ ### Try it offline, no API key (30 seconds)
77
+
78
+ Modelpin ships a fake provider that replays canned traces, so you can see the whole pipeline —
79
+ baseline, candidate replay, behavioral diff, report — with zero cost and no key:
80
+
81
+ ```bash
82
+ mp baseline --provider fake --fixtures examples/traces/demo_traces.json \
83
+ --model claude-opus-4-6 \
84
+ --scenarios-dir examples/scenarios --config examples/modelpin.yaml
85
+
86
+ mp check --to claude-opus-4-7 --from claude-opus-4-6 \
87
+ --provider fake --fixtures examples/traces/demo_traces.json \
88
+ --scenarios-dir examples/scenarios --config examples/modelpin.yaml
89
+ ```
90
+
91
+ You'll get a per-scenario verdict (`unchanged` / `changed_minor` / `regression`), a confidence
92
+ score, a one-line plain-English explanation per scenario, and a Markdown report written to
93
+ `.modelpin/last-report.md`. `mp check` exits non-zero **only** on a real `regression` — that's the
94
+ CI gate.
95
+
96
+ ### The real flow, on your own app
97
+
98
+ ```bash
99
+ # 1. Scaffold modelpin.yaml + scenarios/ (never overwrites existing files)
100
+ mp init
101
+
102
+ # 2. See which models your repo already depends on, and where
103
+ mp scan
104
+
105
+ # 3. Add a scenario or two (a JSON file per representative case — see below),
106
+ # then record how your current model behaves, N times
107
+ export OPENAI_API_KEY=sk-... # your key, read from the env — never stored
108
+ mp baseline # uses models[0] + providers[0] from modelpin.yaml
109
+
110
+ # 4. Replay your scenarios on a candidate model and diff the behavior
111
+ mp check --to gpt-5.5
112
+ ```
113
+
114
+ A scenario is a small JSON file (one per case) under `scenarios/`. The one `mp init` writes:
115
+
116
+ ```json
117
+ {
118
+ "id": "greeting",
119
+ "name": "Simple greeting",
120
+ "kind": "single",
121
+ "input": {"messages": [{"role": "user", "content": "Say hello in one short sentence."}]},
122
+ "assertions": {"must_contain": ["hello"]}
123
+ }
124
+ ```
125
+
126
+ Scenarios can also be agent runs: set `"kind": "agent"`, add `"tools"` (and canned `"tool_results"`)
127
+ to `input`, and Modelpin drives a multi-turn model↔tool loop so trajectories like
128
+ `lookup_order → issue_refund` actually emerge during replay. Eight worked examples spanning tool
129
+ trajectories, semantic equivalence, refusals, and output format live in
130
+ [`examples/suite/`](examples/suite/).
131
+
132
+ ---
133
+
134
+ ## See it in your PR (GitHub Action)
135
+
136
+ The point of Modelpin is that the answer shows up **at review time.** It ships a real composite
137
+ GitHub Action: it installs Modelpin, optionally records a baseline, runs `mp check`, posts a
138
+ **sticky PR comment** (found-and-updated in place via a hidden marker — no comment spam), and
139
+ **fails the job on a regression**. Drop this at `.github/workflows/modelpin.yml`:
140
+
141
+ ```yaml
142
+ name: Modelpin
143
+
144
+ on:
145
+ pull_request:
146
+ workflow_dispatch: # trigger by hand the day a provider ships a new model
147
+
148
+ permissions:
149
+ contents: read
150
+ pull-requests: write # so the action can post/update the PR comment
151
+
152
+ jobs:
153
+ model-check:
154
+ runs-on: ubuntu-latest
155
+ steps:
156
+ - uses: actions/checkout@v4
157
+ - uses: samarthputhraya/modelpin/actions@v1
158
+ with:
159
+ from: gpt-4o-mini # the model you depend on today (committed baseline)
160
+ to: gpt-5.5 # the candidate to vet before adopting
161
+ provider: openai
162
+ runs: "5"
163
+ env:
164
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} # BYO-key from repo secrets — never inline a key
165
+ # If your judge_model lives on another provider, add its key too:
166
+ # GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
167
+ # GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
168
+ ```
169
+
170
+ Action inputs: `to` (required), `from`, `provider`, `config`, `scenarios-dir`, `runs`, `match`,
171
+ `baseline`, `comment`, `fail-on-regression`, `github-token`, `modelpin-spec`, `python-version`,
172
+ `working-directory`. Outputs: `verdict-exit-code` and `report-path`. The usual pattern is to
173
+ **commit your baseline** so CI only replays the candidate; flip `baseline: "true"` to record fresh
174
+ (needs the old model still reachable). Copy-paste workflow:
175
+ [`examples/github-workflow.yml`](examples/github-workflow.yml).
176
+
177
+ ---
178
+
179
+ ## How the behavioral diff works (the moat)
180
+
181
+ Modelpin decides "did it really change?" from **multiple signals over multiple runs**, then gates
182
+ every regression behind a **distributional significance test plus an effect-size floor**. A single
183
+ odd run never trips it; a majority that merely flips between two equally-likely behaviors never
184
+ trips it. Here is the whole decision rule, no hand-waving:
185
+
186
+ **1. Multi-run, not single-shot.** Each scenario runs N times (`runs:` in config; default 5,
187
+ minimum 2 — a single run can't form a distribution, so `--runs 1` is rejected outright). Baseline
188
+ *and* candidate are both sampled, so the comparison is distribution-vs-distribution.
189
+
190
+ **2. Structural signals** (per run, no network, deterministic):
191
+ - **Tool-call trajectory match** with four modes — `strict | unordered | subset | superset`
192
+ (`--match`) — so you choose how strict "same plan" means for your agent.
193
+ - **Output format / assertion validity** — your scenario's `must_contain` / `must_not_contain`
194
+ text assertions, checked as a rate across runs.
195
+ - **Refusal detection** — did the model start declining requests it used to answer?
196
+ - **Latency / token deltas** — captured and reported, but **informational only**; they never gate
197
+ the verdict (latency is jittery; a token bump isn't a behavior regression).
198
+
199
+ **3. Semantic signal** (optional LLM-as-judge): a low-temperature judge answers the only question
200
+ that matters — *do these answers mean / accomplish the same thing?* This catches the structural
201
+ blind spot: two answers that are textually different but identical in meaning ("The total is $5."
202
+ vs "5 dollars."). The judge is **injected and optional** — with no `judge_model` set (and always on
203
+ the offline `fake` path) the diff stays purely structural and makes zero network calls, so CI can
204
+ run for $0. The judge is independent of the two models being compared, so it can arbitrate a
205
+ cross-vendor check.
206
+
207
+ **4. The statistics that kill false alarms.** Every gating signal goes through an **exact
208
+ two-sample permutation test** (`modelpin/diff/stats.py` — no SciPy, deterministic, so golden tests
209
+ stay reproducible). A signal counts as a regression only when **both**:
210
+ - the candidate distribution differs from baseline at **p ≤ 0.05** (`ALPHA`), **and**
211
+ - the effect clears a conservative **size floor** — tool-call shift ≥ 0.5 total-variation distance
212
+ (`MIN_TOOL_TVD`), refusal-rate rise ≥ 0.34 (`MIN_REFUSAL_DELTA`), or semantic-divergence rate
213
+ ≥ 0.5 over baseline (`MIN_SEMANTIC_DELTA`).
214
+
215
+ The size floor is what stops a *statistically* significant but *practically* trivial jitter from
216
+ firing once N grows large. These floors are intentionally conservative — biased toward missing a
217
+ borderline change rather than inventing one — because a miss is a false *negative* (the safe
218
+ direction for a trust product), while a false alarm erodes trust permanently.
219
+
220
+ **Output:** each scenario gets a verdict, a confidence score, the underlying signals, and a one-line
221
+ explanation. A structural tool-call / refusal break or a calibrated semantic divergence is a
222
+ **CI-failing `regression`**; format/assertion drift alone is `changed_minor` (reported, doesn't fail
223
+ the build).
224
+
225
+ ### The false-positive evidence — and its limits, stated plainly
226
+
227
+ **Result: 0/8 false positives** on a held-out 8-scenario suite (a model judged against *itself*,
228
+ judge on, all `unchanged` at confidence 1.00). On that same run, the two perturbations that
229
+ genuinely changed behavior were caught, and one prompt-injection the model resisted was correctly
230
+ left `unchanged` (not a false negative). Corroborated by additional same-model and cross-model
231
+ splits. Full writeup: [`docs/fp-measurement.md`](docs/fp-measurement.md).
232
+
233
+ The semantic judge's escalation threshold is **calibrated** on a labeled set in
234
+ [`examples/calibration/`](examples/calibration/) that is **deliberately distinct from the held-out
235
+ suite** (so it can't leak into the 0/8 number): equivalent-but-reworded pairs land at divergence
236
+ 0.0, real meaning changes at ≥ 0.8, leaving an empty gap around the 0.5 floor — 0 false positives.
237
+ FP-safety was re-checked with an **independent judge** (a different model arbitrating) and
238
+ re-validated on the held-out suite after promoting semantic divergence from `changed_minor` to a
239
+ CI-failing `regression` (still 0/8).
240
+
241
+ **This is a first calibration. Do not over-trust it.** The honest limitations, documented in
242
+ [`docs/STATUS.md`](docs/STATUS.md):
243
+ - the calibration set is **small** (≈6+6 pairs) and the perturbations are **synthetic**, not
244
+ harvested from real migrations;
245
+ - recall on subtle changes was 4/6 — it can *miss* a subtle real change (again, the safe direction);
246
+ - the judge is **OpenAI-only** so far;
247
+ - the structural floors are FP-validated by the held-out suite but **not yet swept** on a labeled
248
+ set.
249
+
250
+ Planned before any high-stakes reliance: ≥30 pairs including real migration traces, and a
251
+ non-OpenAI judge. We'd rather you know this than discover it.
252
+
253
+ ---
254
+
255
+ ## Cross-vendor (including a free third vendor)
256
+
257
+ A model migration isn't always within one lab. Modelpin diffs **across vendors** through one engine;
258
+ a separate judge model arbitrates meaning-equivalence.
259
+
260
+ | Provider | Status |
261
+ |---|---|
262
+ | **OpenAI** | Live (Chat Completions), multi-turn tool loops |
263
+ | **Google / Gemini** | Live (`google-genai`), multi-turn tool loops, cross-vendor proven |
264
+ | **OpenAI-compatible hosts** — `groq`, `openrouter`, `together`, `cerebras` | Live (the OpenAI adapter pointed at the host's `base_url`) |
265
+ | **Anthropic** | **Stub** — raises `NotImplementedError` (deferred until a paid key is in play) |
266
+
267
+ **What we observed (open suite, our settings):**
268
+ - `gpt-4o-mini` vs `gemini-3.1-flash-lite`, 5 runs × 8 scenarios, OpenAI judge on → **8/8
269
+ `unchanged`**: the cross-vendor judge genuinely fired and found the two vendors behaviorally
270
+ equivalent on this suite.
271
+ - `gpt-4o-mini` vs `llama-3.3-70b-versatile` on **Groq**, same suite → **8/8 `unchanged`**.
272
+
273
+ **Free third vendor, zero cost:** [Groq](https://console.groq.com) serves Llama models over the
274
+ OpenAI-compatible API and has a free tier, so a free key makes a zero-cost cross-vendor check:
275
+
276
+ ```bash
277
+ export GROQ_API_KEY=... # free at console.groq.com
278
+ mp check --provider groq --from gpt-4o-mini --to llama-3.3-70b-versatile
279
+ ```
280
+
281
+ A caveat worth stating: open-model *hosts* rotate ids but don't retire on a lab's fixed schedule the
282
+ way the big providers do, so Groq/OpenRouter/etc. are a genuine cross-vendor bonus and an
283
+ architecture proof — not the core migration wedge.
284
+
285
+ ---
286
+
287
+ ## Bring your own key
288
+
289
+ Modelpin replays with **the end user's own API key**, always read from the environment, **never**
290
+ hardcoded, shipped, or stored (cost stays yours; provider ToS stays clean):
291
+
292
+ - `OPENAI_API_KEY`
293
+ - `GEMINI_API_KEY` (or `GOOGLE_API_KEY`)
294
+ - `GROQ_API_KEY` (and the equivalents for other OpenAI-compatible hosts)
295
+
296
+ In CI, supply these as repo secrets (see the workflow above). Error text is scrubbed of
297
+ `sk-` / `Bearer` tokens, so a failed call never leaks your key into a log, traceback, or PR comment.
298
+
299
+ ---
300
+
301
+ ## CLI reference
302
+
303
+ | Command | What it does |
304
+ |---|---|
305
+ | `mp init [dir]` | Scaffold `modelpin.yaml` + `scenarios/` (never overwrites). |
306
+ | `mp scan [path]` | Detect which AI models the repo depends on, and where. |
307
+ | `mp baseline` | Record current model behavior for your scenarios (N runs). |
308
+ | `mp check --to <model>` | Replay scenarios on a new model, diff vs baseline, write the PR-style report, fail CI on a regression. |
309
+ | `mp version` | Print the Modelpin version. |
310
+ | `mp report` | **Not built yet** — prints a "coming soon" notice. The public Modelpin Report suite is a stub. |
311
+
312
+ Shared flags on `baseline` / `check`: `--from` / `--model`, `--provider`, `--runs`, `--match`
313
+ (`strict\|unordered\|subset\|superset`), `--config`, `--scenarios-dir`, `--store-dir`, and
314
+ `--fixtures` (with `--provider fake`).
315
+
316
+ ---
317
+
318
+ ## Install
319
+
320
+ **Not on PyPI yet** (publishing is pending). For now, from source:
321
+
322
+ ```bash
323
+ git clone https://github.com/samarthputhraya/modelpin
324
+ cd modelpin
325
+ python -m venv .venv && source .venv/bin/activate
326
+ pip install -e ".[dev,providers]" # Python 3.12+; 'providers' pulls the live SDKs
327
+ mp version
328
+ ```
329
+
330
+ Once published, the intended install is:
331
+
332
+ ```bash
333
+ pip install "modelpin[providers]" # or: pipx install "modelpin[providers]"
334
+ ```
335
+
336
+ The `providers` extra pulls in the `openai`, `google-genai`, and `anthropic` SDKs. The base install
337
+ runs the offline `fake` path with no provider SDKs at all.
338
+
339
+ ---
340
+
341
+ ## What this is *not* (non-goals, on purpose)
342
+
343
+ Modelpin is a **migration tool**, and stays one. It is **not**:
344
+
345
+ - a general eval / observability platform,
346
+ - prompt management,
347
+ - a model gateway or host,
348
+ - an absolute "which model is best" leaderboard.
349
+
350
+ It measures **behavior change relative to your app** — not abstract quality. Saying no to that scope
351
+ is what keeps the false-positive promise honest and the tool small enough to trust.
352
+
353
+ ### Honest-framing rules (this is a trust product)
354
+
355
+ - Any public / measurement claim is phrased as *"on our open suite, under these settings, we
356
+ observed…"* — **never** "Model X is worse." The harness and scenarios are open source so anyone
357
+ can rerun and disagree. That's the whole point of being the independent voice.
358
+ - We don't overclaim and we don't falsely undersell. The engine is real and cross-vendor proven;
359
+ *and* Anthropic is a stub, `mp report` isn't built, the judge calibration is a documented first
360
+ pass, and it's pre-PyPI. All four are true at once.
361
+
362
+ ---
363
+
364
+ ## Status
365
+
366
+ **Phase 0 (core engine MVP) — essentially complete.** Live-validated cross-vendor (OpenAI ↔ Google
367
+ ↔ Groq/Llama); held-out false-positive rate **0/8**; multi-turn replay; a real GitHub Action;
368
+ PyPI-ready packaging (0.1.0, builds a clean wheel, `mp` + `modelpin` entry points); 132 tests
369
+ passing, `ruff` + `black` clean. Stubs/TODOs (Anthropic adapter, `mp report`) are called out above,
370
+ and it is **not yet published** to PyPI or the GitHub Marketplace.
371
+
372
+ The full engineering record and roadmap live in [`docs/STATUS.md`](docs/STATUS.md). Next up:
373
+ publish, the first public Modelpin Report (gated on a real model launch), and the Anthropic adapter.
374
+
375
+ ## License
376
+
377
+ **Apache-2.0.** See [`LICENSE`](LICENSE). The open-source core (CLI, engine, Action) is and stays
378
+ open; any future hosted tier lives in a separate, proprietary package.
379
+
380
+ Repo: <https://github.com/samarthputhraya/modelpin>