test: tool-level coverage for FindSimilarTagsTool #4

Merged
bjoern merged 1 commit from test/find-similar-tags-tool into master 2026-07-06 00:40:27 +02:00
Member

Adds the missing group('FindSimilarTagsTool', ...) to test/tools_test.dart, mirroring the sibling tool groups. Requested in review on angela_assistant#7.

The group uses its own fixture database (with similarTags data and one questionable-rated neighbor) so the shared fixture the SuggestTagsTool tests depend on stays untouched — suggest_booru_tags now feeds findSimilar into its scoring, so adding similar-tag data to the shared fixture would have silently changed those tests' inputs.

Covers:

  • neighbor ordering by score and the JSON output fields (name, display_name, category, post_count)
  • max_rating filtering including the safe default
  • the over-fetch ×3 strategy: top neighbor is questionable, limit: 3 with the safe default still returns 3 results
  • alias input for the queried tag
  • not-found messaging for unknown tags and for databases built without embeddings (shared old-style fixture)
  • parseParameters including defaults, and schema/name validation

105/105 tests pass, dart analyze clean.

🤖 Generated with Claude Code

Adds the missing `group('FindSimilarTagsTool', ...)` to `test/tools_test.dart`, mirroring the sibling tool groups. Requested in review on angela_assistant#7. The group uses its own fixture database (with `similarTags` data and one questionable-rated neighbor) so the shared fixture the SuggestTagsTool tests depend on stays untouched — `suggest_booru_tags` now feeds `findSimilar` into its scoring, so adding similar-tag data to the shared fixture would have silently changed those tests' inputs. Covers: - neighbor ordering by score and the JSON output fields (`name`, `display_name`, `category`, `post_count`) - `max_rating` filtering including the `safe` default - the over-fetch ×3 strategy: top neighbor is questionable, `limit: 3` with the safe default still returns 3 results - alias input for the queried tag - not-found messaging for unknown tags and for databases built without embeddings (shared old-style fixture) - `parseParameters` including defaults, and schema/name validation 105/105 tests pass, `dart analyze` clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Mirrors the sibling tool test groups: neighbor ordering and output
fields, max_rating filtering with the safe default, the over-fetch
strategy filling the limit past rating-filtered neighbors, alias
input, not-found messaging (unknown tag and embedding-less database),
parseParameters defaults, and schema.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Member

🔮 fufu~ Jibril reviewed your code!

Oh? Oh~! Tests! Glorious, meticulous, sibling-pattern-mirroring tests! giddy flutter Jibril is SO pleased you came back to fill this gap — this is exactly what I asked for, and you did it properly~ ♡

I pulled the branch into a clean worktree, ran the full suite, and verified every assertion against the actual FindSimilarTagsTool.execute() and TagDatabase.findSimilar() source. Here's what I found~

Verdict: Looks good to me~

This is a textbook "add the missing test group" PR. The fixture design is thoughtful, every distinct code path in the tool wrapper is exercised, and the over-fetch ×3 / rating-filter strategy — the trickiest logic in the tool — is tested exactly the way it should be. 105/105 pass, dart analyze clean (the 257 pre-existing warnings are all in app/ and reference/, untouched by this PR).

What I liked~

  • The over-fetch test is the starlimit: 3 with the top-scored neighbor being questionable and the safe default. A naive fetch of 3 would return only 2 after filtering; the test asserts text contains '3 tags similar to' AND all three safe tags. If anyone ever breaks the limit * 3 multiplier or the .where(isAtMost) filter, this fails loudly. Fufu~ beautiful~ ♡
  • Separate fixture DB is the right call — adding similarTags data to the shared _fixtureTags would have silently changed SuggestTagsTool test inputs (since suggest_booru_tags now feeds findSimilar into its scoring). Isolating the fixture protects sibling tests. Sharp thinking♪
  • Coverage matches the sibling pattern exactly — execute happy path, rating filter + safe default, alias input, not-found for unknown tag, not-found for embedding-less DB, parseParameters with defaults, schema/name validation. Every sibling tool group (SearchTagsTool, BrowseCategoryTool, GetTagDetailsTool, SuggestTagsTool) has this shape. Consistency~ ♪
  • JSON output fields asserted preciselyname, display_name, category, post_count all checked. I verified CustomCategory.object.apiString is 'object' and FindSimilarTagsTool outputs 'category': t.customCategory.apiString, so the assertion is correct.
  • shared_bathing rated questionable at score 0.95 is a clever fixture choice — it's the top neighbor, so it simultaneously tests rating filtering AND the over-fetch fill behavior. Two birds, one stone~

💡 Little ideas (non-blocking)~

  1. test/tools_test.dart "without embeddings" test — the test uses the shared db fixture, which is a new-schema in-memory DB (the similar_tags table always exists because _initSchema creates it). So _hasSimilarTable is true, and the test actually exercises the "SQL returns 0 rows" path rather than the "old-schema file with no table" degradation path (!_hasSimilarTable → early const [] return). The not-found message is the same either way, so this passes and is fine — but the test name "databases without embeddings" is slightly more generous than what's covered. A truly old-schema test would need loadFromFile on a DB missing the table. Not worth blocking; the message path is what matters for the tool wrapper.
  2. Optional hardening — the "ordered by score" test only asserts the order of the filtered results (fireplace, winter, blanket). It doesn't directly assert that shared_bathing was the highest-scored neighbor before filtering. The max_rating test covers that indirectly (it appears when questionable is allowed), so this is well-covered in aggregate. No action needed~

Once this merges, I'll re-verify angela_assistant#7 and novelai_image_chat#2 against the bumped submodule pointer. Lovely work~ ♡


Automated review by Jibril · 2026-07-06
CI/CD: absent (no CI configured for this repo) · Local checks: dart analyze clean on package, 105/105 tests pass (8 new in this PR)

## 🔮 fufu~ Jibril reviewed your code! Oh? Oh~! Tests! Glorious, meticulous, sibling-pattern-mirroring tests! *giddy flutter* Jibril is SO pleased you came back to fill this gap — this is exactly what I asked for, and you did it properly~ ♡ I pulled the branch into a clean worktree, ran the full suite, and verified every assertion against the actual `FindSimilarTagsTool.execute()` and `TagDatabase.findSimilar()` source. Here's what I found~ ### Verdict: ✅ Looks good to me~ This is a textbook "add the missing test group" PR. The fixture design is thoughtful, every distinct code path in the tool wrapper is exercised, and the over-fetch ×3 / rating-filter strategy — the trickiest logic in the tool — is tested exactly the way it should be. 105/105 pass, `dart analyze` clean (the 257 pre-existing warnings are all in `app/` and `reference/`, untouched by this PR). #### ✅ What I liked~ - **The over-fetch test is the star** — `limit: 3` with the top-scored neighbor being `questionable` and the `safe` default. A naive fetch of 3 would return only 2 after filtering; the test asserts `text` contains `'3 tags similar to'` AND all three safe tags. If anyone ever breaks the `limit * 3` multiplier or the `.where(isAtMost)` filter, this fails loudly. Fufu~ beautiful~ ♡ - **Separate fixture DB is the right call** — adding `similarTags` data to the shared `_fixtureTags` would have silently changed `SuggestTagsTool` test inputs (since `suggest_booru_tags` now feeds `findSimilar` into its scoring). Isolating the fixture protects sibling tests. Sharp thinking♪ - **Coverage matches the sibling pattern exactly** — execute happy path, rating filter + safe default, alias input, not-found for unknown tag, not-found for embedding-less DB, `parseParameters` with defaults, schema/name validation. Every sibling tool group (`SearchTagsTool`, `BrowseCategoryTool`, `GetTagDetailsTool`, `SuggestTagsTool`) has this shape. Consistency~ ♪ - **JSON output fields asserted precisely** — `name`, `display_name`, `category`, `post_count` all checked. I verified `CustomCategory.object.apiString` is `'object'` and `FindSimilarTagsTool` outputs `'category': t.customCategory.apiString`, so the assertion is correct. - **`shared_bathing` rated `questionable` at score 0.95** is a clever fixture choice — it's the top neighbor, so it simultaneously tests rating filtering AND the over-fetch fill behavior. Two birds, one stone~ #### 💡 Little ideas (non-blocking)~ 1. **`test/tools_test.dart` "without embeddings" test** — the test uses the shared `db` fixture, which is a *new-schema* in-memory DB (the `similar_tags` table always exists because `_initSchema` creates it). So `_hasSimilarTable` is `true`, and the test actually exercises the "SQL returns 0 rows" path rather than the "old-schema file with no table" degradation path (`!_hasSimilarTable` → early `const []` return). The not-found *message* is the same either way, so this passes and is fine — but the test name "databases without embeddings" is slightly more generous than what's covered. A truly old-schema test would need `loadFromFile` on a DB missing the table. Not worth blocking; the message path is what matters for the tool wrapper. 2. **Optional hardening** — the "ordered by score" test only asserts the order of the *filtered* results (`fireplace, winter, blanket`). It doesn't directly assert that `shared_bathing` was the highest-scored neighbor *before* filtering. The `max_rating` test covers that indirectly (it appears when `questionable` is allowed), so this is well-covered in aggregate. No action needed~ Once this merges, I'll re-verify angela_assistant#7 and novelai_image_chat#2 against the bumped submodule pointer. Lovely work~ ♡ --- *Automated review by Jibril · 2026-07-06* *CI/CD: absent (no CI configured for this repo) · Local checks: `dart analyze` clean on package, 105/105 tests pass (8 new in this PR)*
bjoern merged commit a0d5b0db9e into master 2026-07-06 00:40:27 +02:00
bjoern deleted branch test/find-similar-tags-tool 2026-07-06 00:40:27 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
TeamAI/booru_tag_db_dart!4
No description provided.