vetcheck 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.
vetcheck-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SuperInstance
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.
@@ -0,0 +1,383 @@
1
+ Metadata-Version: 2.4
2
+ Name: vetcheck
3
+ Version: 0.1.0
4
+ Summary: Model health monitoring as veterinary care — regression tests as physical exams, drift detection as weight monitoring, auto-quarantine on critical health breaches.
5
+ Author: SuperInstance
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/SuperInstance/vetcheck
8
+ Project-URL: Repository, https://github.com/SuperInstance/vetcheck
9
+ Keywords: ml,monitoring,model-health,drift-detection,regression-testing,observability
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Testing
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Dynamic: license-file
23
+
24
+ # Vetcheck: Model Health Monitoring as Veterinary Care
25
+
26
+ > Working dogs need regular checkups. So do models.
27
+
28
+ [![Python](https://img.shields.io/python/required-version-toml?toml=pyproject.toml)](https://python.org)
29
+ [![License](https://img.shields.io/github/license/SuperInstance/vetcheck)](LICENSE)
30
+ [![Tests](https://img.shields.io/badge/tests-passing-brightgreen)](tests/)
31
+
32
+ A model that passed regression tests six months ago might silently degrade over time — distribution drift, fine-tuning side effects, dependency changes. Vetcheck treats model health monitoring like veterinary care because in the Working Animal Architecture paradigm, every model is a working animal that needs ongoing supervision to stay fit for duty. Physical exams catch regressions. Weight monitoring catches output drift. Quarantine isolates failures before they reach production.
33
+
34
+ ## What It Does
35
+
36
+ Vetcheck provides three core exams and two lifecycle operations. The **physical exam** runs a full regression test suite against the model, checking vital signs: does it still handle edge cases (temperature), are response times within bounds (heart rate), does it handle load without degradation (blood pressure), do function-calling and structured outputs still work (reflexes)? The result is an `ExamResult` with pass/fail per test and an overall `HealthStatus`.
37
+
38
+ The **weight check** monitors output distribution drift over time. Just as a vet weighs a dog at every visit and flags concerning changes, Vetcheck compares recent output embeddings or distributions to a baseline and flags statistically significant drift. Trends are tracked across checkups — a gradual 5% drift over a month is different from a sudden 20% shift overnight.
39
+
40
+ When a model fails critically, **quarantine** auto-isolates it: traffic is routed elsewhere, alerts fire, and the model stays isolated until a clean physical exam passes. The **health certificate** is a signed attestation that a model is fit for production — it verifies the last physical exam passed, confirms no active quarantine, checks weight stability, and returns a certificate with an expiry date.
41
+
42
+ ## Install
43
+
44
+ ```bash
45
+ pip install vetcheck
46
+ ```
47
+
48
+ For development:
49
+
50
+ ```bash
51
+ git clone https://github.com/SuperInstance/vetcheck.git
52
+ cd vetcheck
53
+ pip install -e ".[dev]"
54
+ ```
55
+
56
+ ## Quick Start
57
+
58
+ ```python
59
+ from vetcheck import VetCheck
60
+
61
+ vet = VetCheck(model_id="llama-3-70b")
62
+
63
+ # Run a full physical — executes regression suite
64
+ report = vet.physical_exam()
65
+ print(report.summary())
66
+ # ════════════════════════════════════════════
67
+ # PHYSICAL EXAM: llama-3-70b
68
+ # Overall: HEALTHY
69
+ # Tests: 47 passed, 3 failed, 0 skipped
70
+ # ════════════════════════════════════════════
71
+
72
+ # Check for weight drift — compares recent outputs to baseline
73
+ drift = vet.weight_check(window=100)
74
+ if drift.significant:
75
+ print(f"⚠ Drift detected: {drift.magnitude:.1%} from baseline")
76
+ print(f" Trend: {drift.trend}") # "increasing", "decreasing", "stable"
77
+ else:
78
+ print("✓ Weight stable")
79
+
80
+ # Quarantine a sick model
81
+ if report.critical_failures > 0:
82
+ vet.quarantine(reason="Critical regression detected")
83
+ print("Model quarantined — traffic routed to backup")
84
+
85
+ # ... after fixes applied ...
86
+
87
+ # Run physical again to verify recovery
88
+ recovery = vet.physical_exam()
89
+ if recovery.passed:
90
+ vet.release()
91
+ print("Model returned to active duty")
92
+
93
+ # Issue a clean bill of health
94
+ cert = vet.health_certificate()
95
+ print(f"Health certificate issued, expires: {cert.expires_at}")
96
+ print(f"Valid: {cert.is_valid()}")
97
+ ```
98
+
99
+ ## Architecture
100
+
101
+ ```
102
+ src/vetcheck/
103
+ ├── __init__.py # VetCheck orchestrator + HealthCertificate
104
+ ├── exam.py # Regression test runner (physical exams)
105
+ │ ├── run_physical_exam()
106
+ │ ├── ExamResult
107
+ │ └── TestCase / TestSuite
108
+ ├── drift.py # Output drift detection (weight monitoring)
109
+ │ ├── check_weight_drift()
110
+ │ ├── DriftReport
111
+ │ └── BaselineDistribution
112
+ └── quarantine.py # Quarantine and release system
113
+ ├── quarantine_model()
114
+ ├── release_model()
115
+ ├── get_quarantine_status()
116
+ └── QuarantineStatus
117
+ ```
118
+
119
+ ### Health States
120
+
121
+ ```
122
+ HEALTHY ──────▶ UNDER_OBSERVATION ──────▶ QUARANTINED
123
+ ▲ │ │
124
+ │ │ │
125
+ └────────────────────┘ │
126
+ release() (clean exam) │
127
+ ▲ │
128
+ └────────────────────────────────────────────┘
129
+ release() (clean exam)
130
+ ```
131
+
132
+ ## API Reference
133
+
134
+ ### `VetCheck`
135
+
136
+ ```python
137
+ class VetCheck:
138
+ def __init__(self, model_id: str, baseline_dir: str = "./baselines")
139
+
140
+ # Exams
141
+ def physical_exam(self, suite: str = "default") -> ExamResult
142
+ def weight_check(self, window: int = 100) -> DriftReport
143
+
144
+ # Lifecycle
145
+ def quarantine(self, reason: str) -> QuarantineStatus
146
+ def release(self) -> bool
147
+ @property
148
+ def is_quarantined(self) -> bool
149
+
150
+ # Certification
151
+ def health_certificate(self, validity_days: int = 7) -> HealthCertificate
152
+ @property
153
+ def health_status(self) -> HealthStatus
154
+ ```
155
+
156
+ ### Result Types
157
+
158
+ ```python
159
+ @dataclass
160
+ class ExamResult:
161
+ model_id: str
162
+ passed: bool
163
+ overall_status: HealthStatus
164
+ tests_passed: int
165
+ tests_failed: int
166
+ critical_failures: int
167
+ duration_seconds: float
168
+ details: list[TestResult]
169
+
170
+ @dataclass
171
+ class DriftReport:
172
+ model_id: str
173
+ significant: bool # statistically significant drift
174
+ magnitude: float # 0.0-1.0
175
+ trend: str # "increasing", "decreasing", "stable"
176
+ window: int # samples compared
177
+ p_value: float # statistical test result
178
+
179
+ @dataclass
180
+ class HealthCertificate:
181
+ model_id: str
182
+ status: HealthStatus
183
+ issued_at: float
184
+ expires_at: float
185
+ last_exam_passed: bool
186
+ weight_stable: bool
187
+ quarantine_active: bool
188
+ notes: str
189
+
190
+ def is_valid(self, now: float | None = None) -> bool
191
+ def to_dict(self) -> dict
192
+ ```
193
+
194
+ ### `HealthStatus`
195
+
196
+ ```python
197
+ class HealthStatus(str, Enum):
198
+ HEALTHY = "healthy"
199
+ UNDER_OBSERVATION = "under_observation"
200
+ QUARANTINED = "quarantined"
201
+ CRITICAL = "critical"
202
+ ```
203
+
204
+ ## The Analogy
205
+
206
+ | Veterinary Care | Vetcheck |
207
+ |-----------------|----------|
208
+ | Physical exam | Regression test suite (`physical_exam`) |
209
+ | Weight monitoring | Output drift detection (`weight_check`) |
210
+ | Quarantine | Auto-isolation on critical health breach |
211
+ | Health certificate | Clearance for production deployment |
212
+ | Vaccination schedule | Periodic exam scheduling |
213
+ | Breed-specific screening | Model-specific test suites |
214
+
215
+ ## Testing
216
+
217
+ ```bash
218
+ pip install -e ".[dev]"
219
+ pytest tests/ -v
220
+
221
+ # Test exam runner
222
+ pytest tests/test_exam.py -v
223
+
224
+ # Test drift detection
225
+ pytest tests/test_drift.py -v
226
+
227
+ # Test quarantine lifecycle
228
+ pytest tests/test_quarantine.py -v
229
+ ```
230
+
231
+ ## Philosophy
232
+
233
+ In animal husbandry, preventative medicine is cheaper than emergency treatment. The same applies to AI systems: catching a regression before it reaches production is dramatically cheaper than responding to an outage. Vetcheck brings the discipline of veterinary preventative care to model operations — regular checkups, early detection, isolation of sick individuals, and structured health certificates before deployment.
234
+
235
+ This is part of [Working Animal Architecture](https://github.com/SuperInstance/AI-Writings) — specifically the health monitoring layer that keeps the kennel (flux registry) populated with animals fit for duty. A model with an expired health certificate shouldn't be in production, just as a working dog that hasn't seen a vet in a year shouldn't be herding sheep.
236
+
237
+ ## Ecosystem
238
+
239
+ | Repo | Role |
240
+ |------|------|
241
+ | **[vetcheck](https://github.com/SuperInstance/vetcheck)** | **This repo** — health monitoring |
242
+ | [shepherds-console](https://github.com/SuperInstance/shepherds-console) | Dashboard (displays vetcheck health status) |
243
+ | [breed-registry](https://github.com/SuperInstance/breed-registry) | Breed selection (uses health certificates) |
244
+ | [lineage-tracker](https://github.com/SuperInstance/lineage-tracker) | Lineage (health data enriches lineage records) |
245
+ | [baton](https://github.com/SuperInstance/baton) | Generational handoff (health informs sunset decisions) |
246
+
247
+
248
+
249
+ ## Integration Patterns
250
+
251
+ ### With Breed Registry: Pre-Deployment Health Check
252
+
253
+ ```python
254
+ from vetcheck import VetCheck
255
+ from breed_registry import select_breed
256
+
257
+ # Select the best model for a task
258
+ recommended = select_breed("code_generation")
259
+ print(f"Recommended: {recommended.recommended}")
260
+
261
+ # Before deploying, verify it's healthy
262
+ vet = VetCheck(model_id=recommended.recommended)
263
+ cert = vet.health_certificate(validity_days=14)
264
+
265
+ if cert.is_valid():
266
+ print(f"✓ {recommended.recommended} is certified healthy — deploy")
267
+ else:
268
+ print(f"✗ {recommended.recommended} failed health check")
269
+ print(f" Falling back to alternatives...")
270
+ for alt in recommended.alternatives:
271
+ alt_vet = VetCheck(model_id=alt.breed)
272
+ alt_cert = alt_vet.health_certificate()
273
+ if alt_cert.is_valid():
274
+ print(f" ✓ {alt.breed} is healthy (score: {alt.score:.1f})")
275
+ break
276
+ ```
277
+
278
+ ### With Lineage Tracker: Regression Source Detection
279
+
280
+ ```python
281
+ from vetcheck import VetCheck
282
+ from lineage_tracker import LineageTracker
283
+
284
+ # Model failed its physical exam
285
+ vet = VetCheck(model_id="prod-model-v7")
286
+ report = vet.physical_exam()
287
+
288
+ if not report.passed:
289
+ # Check if this is a known weakness in the lineage
290
+ tracker = LineageTracker("lineage.json")
291
+ lineage = tracker.get_lineage("prod-model-v7")
292
+
293
+ print("Failed exam. Checking lineage for inherited weaknesses:")
294
+ for gen in lineage:
295
+ model = gen.model
296
+ failed_areas = [t.name for t in report.details if not t.passed]
297
+ for area in failed_areas:
298
+ trait_key = area.lower().replace(" ", "_")
299
+ if model.traits and trait_key in model.traits:
300
+ print(f" Gen {gen.generation} {model.name}: {trait_key}={model.traits[trait_key]}")
301
+
302
+ # If the weakness is inherited, quarantine and recommend retraining
303
+ vet.quarantine(reason=f"Inherited regression: {failed_areas}")
304
+ ```
305
+
306
+ ### Continuous Monitoring with Scheduled Exams
307
+
308
+ ```python
309
+ from vetcheck import VetCheck
310
+ import schedule # pip install schedule
311
+ import time
312
+
313
+ vet = VetCheck(model_id="prod-model-v7", baseline_dir="./baselines")
314
+
315
+ # Daily weight check (lightweight — compares output distributions)
316
+ schedule.every().day.at("06:00").do(lambda: vet.weight_check(window=500))
317
+
318
+ # Weekly physical (full regression suite)
319
+ schedule.every().monday.at("02:00").do(lambda: vet.physical_exam())
320
+
321
+ # Monthly health certificate renewal
322
+ schedule.every(30).days.do(lambda: vet.health_certificate(validity_days=7))
323
+
324
+ # Auto-quarantine on critical failure
325
+ def full_checkup():
326
+ report = vet.physical_exam()
327
+ if report.critical_failures > 0:
328
+ vet.quarantine(reason=f"Auto-quarantine: {report.critical_failures} critical failures")
329
+ # Alert the team
330
+ print(f"🚨 {vet.model_id} QUARANTINED — {report.critical_failures} critical failures")
331
+ return report
332
+
333
+ schedule.every().day.at("12:00").do(full_checkup)
334
+
335
+ # Run the scheduler
336
+ while True:
337
+ schedule.run_pending()
338
+ time.sleep(60)
339
+ ```
340
+
341
+ ### Fleet Health Dashboard
342
+
343
+ ```python
344
+ from vetcheck import VetCheck
345
+ from breed_registry import BreedMatcher
346
+
347
+ matcher = BreedMatcher()
348
+ fleet = ["gpt-4", "claude-3", "llama-3", "glm", "qwen"]
349
+
350
+ print("FLEET HEALTH REPORT")
351
+ print("=" * 60)
352
+
353
+ for model_id in fleet:
354
+ vet = VetCheck(model_id=model_id)
355
+ status = vet.health_status
356
+ quarantined = "🔒 QUARANTINED" if vet.is_quarantined else "🟢 ACTIVE"
357
+
358
+ # Quick weight check
359
+ drift = vet.weight_check(window=100)
360
+ drift_indicator = "📉" if drift.significant else "✓"
361
+
362
+ print(f" {model_id:15s} {status.value:20s} {quarantined} drift:{drift_indicator}")
363
+
364
+ # Recommend breed-specific action
365
+ aptitude = matcher.assess(model_id, "reasoning")
366
+ if status.value == "quarantined":
367
+ alternatives = matcher.select("reasoning").alternatives[:2]
368
+ print(f" → Failover to: {[a.breed for a in alternatives]}")
369
+ ```
370
+
371
+ ## Monitoring Philosophy
372
+
373
+ The veterinary metaphor runs deeper than naming. In real animal husbandry:
374
+
375
+ - **Preventative care is cheaper than emergency treatment.** A daily weight check catches drift before it becomes a regression. A weekly physical catches regressions before they reach users.
376
+ - **Quarantine is not punishment.** It's protection — for the model (no traffic to handle while recovering) and for the system (no degraded output reaching users). The quarantine is lifted the moment a clean physical passes.
377
+ - **Health certificates expire.** A model that was healthy last month might not be healthy today. Certificate expiry isn't bureaucracy — it's the acknowledgment that model health is dynamic, not static.
378
+ - **Breed-specific screening matters.** A Thoroughbred (GPT-4) needs different tests than a Mustang (Llama-3). Custom test suites per breed catch breed-specific failure modes that generic tests miss.
379
+ - **The vet's authority overrides the registry.** A model with the best breed score should not be in production if its health certificate has expired. The registry says what's best on paper; the vet says what's fit for duty right now.
380
+
381
+ ## License
382
+
383
+ MIT — see [LICENSE](LICENSE).