From 3280fa1f13b57d6622acc989f90f1c7116b0cbc9 Mon Sep 17 00:00:00 2001 From: ibrog Date: Thu, 17 Sep 2026 15:34:46 +0300 Subject: [PATCH] fix(schedule): preserve temporary cadence on partial update Generated-with: Codex --- promptpilot/db.py | 5 ++++- tests/test_schedule_series.py | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/promptpilot/db.py b/promptpilot/db.py index 276c2c6..d01abf7 100644 --- a/promptpilot/db.py +++ b/promptpilot/db.py @@ -1023,7 +1023,10 @@ def update_series(series_id: int, fields: dict) -> bool: return False if "temporary_until" in fields and isinstance(fields["temporary_until"], datetime): fields["temporary_until"] = _to_utc_iso(fields["temporary_until"]) - if fields.get("temporary_recurrence") is None: + # Only an explicit clear ends a temporary cadence. Partial PATCHes such as + # a priority change must leave the active boost and its empty-run limit intact. + if ("temporary_recurrence" in fields + and fields["temporary_recurrence"] is None): fields.setdefault("temporary_until", None) fields.setdefault("temporary_empty_limit", None) fields["temporary_empty_count"] = 0 diff --git a/tests/test_schedule_series.py b/tests/test_schedule_series.py index d1c0ed8..91241ef 100644 --- a/tests/test_schedule_series.py +++ b/tests/test_schedule_series.py @@ -187,6 +187,22 @@ def test_event_only_policy_clears_previous_temporary_boost(isolated_db): assert result["temporary_empty_count"] == 0 +def test_unrelated_series_update_preserves_temporary_boost(isolated_db): + task = isolated_db.create_task(TaskCreate( + prompt="ExampleProject - TRIAGE", recurrence="30m")) + assert isolated_db.update_series(task.series_id, { + "temporary_recurrence": "15m", "temporary_empty_limit": 2, + }) + + assert isolated_db.update_series(task.series_id, {"priority": 4}) + + result = isolated_db.get_series(task.series_id) + assert result["priority"] == 4 + assert result["temporary_recurrence"] == "15m" + assert result["temporary_empty_limit"] == 2 + assert result["temporary_empty_count"] == 0 + + def test_adaptive_cadence_rejects_stale_profile_revision_guard(isolated_db): task = isolated_db.create_task(TaskCreate( prompt="ExampleProject - FIX", recurrence="30m"))