fix(review): harden write-back, confirmation gate, and edge cases

- write-back: call upsert_tag inside _apply_tag's try so a tag-create failure
  is caught per-asset and apply_all no longer aborts mid-batch (was P1)
- write-back: surface _pipeline/processed write failures in the result instead
  of discarding them (was reported as success)
- ui: add title to the high confidence badge so approve-high-confidence's
  pre-action count is non-zero; confirm() before single-cluster apply
- core: Store context manager; close DB connection even if a route raises;
  guard split_cluster against a first-member boundary (empty cluster); add
  writeback_log lookup index
- ingest: split thumbnail download/write error handling and clean up the
  .tmp file on a write failure
- tests: upsert/processed write-failure regression tests + split-guard test
This commit is contained in:
2026-06-27 17:54:38 +02:00
parent d67b677b6a
commit ae093881fa
8 changed files with 89 additions and 17 deletions
+11
View File
@@ -97,3 +97,14 @@ def test_writeback_log_idempotency(tmp_path):
s.log_writeback("b", "trip", "Venice", "error:boom")
assert s.already_applied("b", "trip", "Venice") is False # only ok counts
s.close()
def test_split_cluster_rejects_first_member_boundary(tmp_path):
import pytest
s = _seed(tmp_path)
cid = s.insert_cluster(Cluster(start_at="2019-06-01", end_at="2019-06-03",
suggested_name="Trip"), _members(["a", "b", "c"]))
with pytest.raises(ValueError):
s.split_cluster(cid, "a") # boundary == first member -> empty left
assert s.get_cluster(cid).status != "split" # original untouched on rejection
s.close()