refactor(tags): unify suggestion source — one canonical DB-tag dropdown, drop dead raw/alias machinery (#154)
Every tag suggestion is a canonical DB tag now (tagging-v2 #114: heads + CCIP score EXISTING concept tags). The pre-heads apparatus for model-predicted tags that didn't exist in the DB — creates_new_tag / raw_name / via_alias, the /suggestions/alias endpoint + add_alias_and_accept, AliasPickerDialog, and the store's aliasAccept/removeAlias — was dead and is removed. The type-to-add dropdown was TWO row sources (server autocomplete + the image's ML suggestions) merged with a dedup that dropped the %-bearing suggestion row when the debounced server hit landed — the operator's "confidence % flickers then vanishes". Now it's ONE list of DB-tag matches, each annotated with the model's confidence (join by canonical_tag_id) when the tag was scored for this image. No dedup, no flicker; picking a suggested tag still records acceptance via TagPanel.findPending. Single per-image fetch: score_image now reports above_threshold per row (computed vs the head's own suggest cut, separate from the inclusion floor), so the rail makes ONE min=0 request and derives the panel (above_threshold) and the dropdown (all, text-filtered) client-side — the two /suggestions calls collapse to one. Manual "Create 'X' as <kind>" (novel typed names) is unchanged; the alias table + tag-side alias admin + auto-apply alias matching are untouched. Tests: gate/serializer assertions updated (above_threshold; dropped dead-field + alias-endpoint checks); frontend spec seeds via the single load and covers the byCategory/aboveByCategory split. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CgZP9v2otxVJymiYsnVuMy
This commit is contained in:
@@ -62,9 +62,8 @@ async def test_head_suggestion_surfaces_for_matching_image(db):
|
||||
s = general[0]
|
||||
assert s.canonical_tag_id == tag.id
|
||||
assert s.source == "head"
|
||||
assert s.creates_new_tag is False
|
||||
assert s.via_alias is False and s.raw_name is None
|
||||
assert s.score > 0.5
|
||||
assert s.above_threshold is True # ~0.73 clears the 0.5 suggest cut
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -109,7 +108,10 @@ async def test_threshold_override_surfaces_below_cut(db):
|
||||
svc = SuggestionService(db)
|
||||
assert svc and not (await svc.for_image(img.id)).by_category.get("general")
|
||||
flooded = await svc.for_image(img.id, threshold_override=0.0)
|
||||
assert any(s.canonical_tag_id == tag.id for s in flooded.by_category["general"])
|
||||
s = next(s for s in flooded.by_category["general"] if s.canonical_tag_id == tag.id)
|
||||
# Included by the floor, but flagged below its own cut (0.5 < 0.6) — this is
|
||||
# what lets the dropdown show it while the panel hides it.
|
||||
assert s.above_threshold is False
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@@ -281,6 +283,7 @@ async def test_ccip_character_surfaces_in_rail(db):
|
||||
if c.canonical_tag_id == raven.id
|
||||
)
|
||||
assert m.source == "ccip"
|
||||
assert m.above_threshold is True # CCIP only returns matches above its cut
|
||||
|
||||
|
||||
# --- #1206 Step 4: on-demand grounding for ALREADY-APPLIED tag chips ---------
|
||||
|
||||
Reference in New Issue
Block a user