From c53fdd8560be5e0deddcdf81d2639624ce067503 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sun, 21 Jun 2026 12:27:37 +0200 Subject: [PATCH] feat(trials): stop_trial and clear trials on reset --- tests/test_trials.py | 12 ++++++++++++ tracker.py | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/tests/test_trials.py b/tests/test_trials.py index 2f36c41..f6d807f 100644 --- a/tests/test_trials.py +++ b/tests/test_trials.py @@ -69,3 +69,15 @@ def test_reset_empty_is_noop(tracker): tracker.start_trial("Pack") tracker.reset_trials_for(set()) assert tracker.get_trials()[0]["unused_boot_days"] == 0 + + +def test_stop_trial_removes_row(tracker): + tracker.start_trial("Pack") + tracker.stop_trial("Pack") + assert tracker.get_trials() == [] + + +def test_reset_clears_trials(tracker): + tracker.start_trial("Pack") + tracker.reset() + assert tracker.get_trials() == [] diff --git a/tracker.py b/tracker.py index 0ac5b68..ab09cc6 100644 --- a/tracker.py +++ b/tracker.py @@ -469,6 +469,17 @@ class UsageTracker: finally: conn.close() + def stop_trial(self, package): + """End a trial (package became permanent or was disabled).""" + with self._lock: + self._ensure_db() + conn = self._connect() + try: + conn.execute("DELETE FROM trial_packages WHERE package = ?", (package,)) + conn.commit() + finally: + conn.close() + def reset(self): """Clear all tracked data.""" with self._lock: @@ -478,6 +489,7 @@ class UsageTracker: conn.execute("DELETE FROM node_usage") conn.execute("DELETE FROM prompt_log") conn.execute("DELETE FROM model_usage") + conn.execute("DELETE FROM trial_packages") conn.commit() finally: conn.close()