refactor(ml): drop dead tagger/suggestion settings + columns (#1199)
CI / lint (push) Successful in 3s
CI / frontend-build (push) Successful in 18s
CI / backend-lint-and-test (push) Successful in 27s
CI / integration (push) Successful in 3m31s

Hygiene follow-up to the Camie retirement (#1189) — these were left inert to
bound that change; nothing reads them now. Migration 0068 drops:
- ml_settings: tagger_store_floor, tagger_model_version, suggestion_threshold_
  character/general (already dead pre-retirement — scoring uses per-head
  thresholds), video_min_tag_frames (only the deleted video-prediction
  aggregator used it).
- image_record: tagger_model_version (no writer), centroid_scores (dead JSON
  cache, no reader).

Also: ml_admin _EDITABLE/GET/_validate pruned (dropped the store-floor invariant
+ video_min_tag_frames check); MLThresholdSliders trimmed to a video-embedding
card (interval + max frames only); importer no longer resets the dropped cols;
download_models drops the Camie fetch; stale CASCADE comments in cleanup_service
no longer name the removed tables. Tests updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ttrj5P7upUTueSfoJcxEqa
This commit is contained in:
2026-06-30 13:41:25 -04:00
parent 3d97667f5b
commit bc6d43d3f2
11 changed files with 146 additions and 260 deletions
+14 -41
View File
@@ -19,19 +19,18 @@ async def test_get_and_patch_settings(client):
resp = await client.get("/api/ml/settings")
assert resp.status_code == 200
body = await resp.get_json()
# Default raised 0.50 → 0.70 on 2026-06-02 (alembic 0033) — 0.50
# was too noisy in practice. The 0.70 default keeps the rail
# signal-rich without hiding everything like the original 0.95.
assert body["suggestion_threshold_general"] == pytest.approx(0.70)
# Retired threshold columns must not appear in the payload.
assert "suggestion_threshold_artist" not in body
assert "suggestion_threshold_copyright" not in body
assert body["head_min_positives"] == 8
# Retired tagger/suggestion-threshold columns are gone from the payload
# (Camie retirement #1189/#1199).
assert "suggestion_threshold_general" not in body
assert "tagger_store_floor" not in body
assert "tagger_model_version" not in body
resp = await client.patch(
"/api/ml/settings", json={"suggestion_threshold_general": 0.90}
"/api/ml/settings", json={"head_min_positives": 12}
)
assert resp.status_code == 200
assert (await resp.get_json())["suggestion_threshold_general"] == pytest.approx(0.90)
assert (await resp.get_json())["head_min_positives"] == 12
@pytest.mark.asyncio
@@ -55,55 +54,29 @@ async def test_embedder_model_settable_and_empty_rejected(client):
@pytest.mark.asyncio
async def test_tagger_store_floor_default_and_patch(client):
body = await (await client.get("/api/ml/settings")).get_json()
assert body["tagger_store_floor"] == pytest.approx(0.70)
resp = await client.patch("/api/ml/settings", json={"tagger_store_floor": 0.6})
assert resp.status_code == 200
assert (await resp.get_json())["tagger_store_floor"] == pytest.approx(0.6)
@pytest.mark.asyncio
async def test_suggestion_threshold_below_store_floor_rejected(client):
# Invariant (#764): a category threshold can't sit below the store floor —
# nothing below the floor is stored, so the gap would surface nothing.
# Floor defaults to 0.70; pushing general down to 0.50 must 400.
resp = await client.patch(
"/api/ml/settings", json={"suggestion_threshold_general": 0.50}
)
assert resp.status_code == 400
assert "tagger_store_floor" in (await resp.get_json())["error"]
@pytest.mark.asyncio
async def test_video_tagging_settings_default_and_patch(client):
"""#747: video cadence/noise knobs are exposed + patchable."""
async def test_video_settings_default_and_patch(client):
"""#747: video frame-sampling knobs are exposed + patchable."""
body = await (await client.get("/api/ml/settings")).get_json()
assert body["video_frame_interval_seconds"] == pytest.approx(4.0)
assert body["video_max_frames"] == 64
assert body["video_min_tag_frames"] == 3
resp = await client.patch(
"/api/ml/settings",
json={"video_frame_interval_seconds": 5, "video_max_frames": 40,
"video_min_tag_frames": 4},
json={"video_frame_interval_seconds": 5, "video_max_frames": 40},
)
assert resp.status_code == 200
out = await resp.get_json()
assert out["video_frame_interval_seconds"] == pytest.approx(5.0)
assert out["video_max_frames"] == 40
assert out["video_min_tag_frames"] == 4
@pytest.mark.asyncio
async def test_video_min_tag_frames_above_max_rejected(client):
async def test_video_max_frames_below_one_rejected(client):
resp = await client.patch(
"/api/ml/settings",
json={"video_max_frames": 10, "video_min_tag_frames": 20},
"/api/ml/settings", json={"video_max_frames": 0},
)
assert resp.status_code == 400
assert "video_min_tag_frames" in (await resp.get_json())["error"]
assert "video_max_frames" in (await resp.get_json())["error"]
@pytest.mark.asyncio