Skip to content

Fix screening coverage and blank inputs - #8

Merged
ruthdelalucha merged 1 commit into
mainfrom
codex/fix-screening-correctness
Mar 28, 2026
Merged

ruthdelalucha merged 1 commit into
mainfrom
codex/fix-screening-correctness

Conversation

@endvater

Copy link
Copy Markdown
Owner

Summary

  • query yente for both Person and Organization schemas and merge the ranked results
  • reject blank and whitespace-only names in the API instead of treating them as clean screenings
  • show a validation message in the browser UI for whitespace-only searches instead of the green no-hit state
  • add regression tests for organization coverage and blank-input handling

Testing

  • python3 -m pytest sanctions/tests -q
  • python3 -m ruff check sanctions/src/main.py sanctions/tests/test_main.py

ruthdelalucha
ruthdelalucha previously approved these changes Mar 28, 2026

@ruthdelalucha ruthdelalucha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Screening Coverage + Input Validation ✅

APPROVED - Wichtige Sprint-1-Verbesserungen!

Neue Features:

Feature Beschreibung
Person + Organization Beide Schema-Typen werden jetzt abgefragt und gemerged
Deduplizierung Matches nach ID+Dataset+Caption dedupliziert
Ranking Nach Score sortiert, Top 10 Ergebnisse
Whitespace-Validierung Leere/Whitespace-only Namen werden abgelehnt (422)
UI-Feedback Klare Fehlermeldung statt grünem "Keine Treffer"

Code-Qualität:

  • ✅ Annotated[StringConstraints] für saubere Pydantic-Validierung
  • ✅ YENTE_QUERY_SCHEMAS Dictionary für Erweiterbarkeit
  • ✅ Deduplizierung mit seen_matches Set (O(1) Lookup)
  • ✅ Strip-Whitespace konsistent in API und UI

Tests:

  • ✅ Organisation-Screening Test
  • ✅ Whitespace-Query Test
  • ✅ Blank-Name API-Validation Test

Produktionsreif:

Jetzt können auch Unternehmen (Sberbank, etc.) geprüft werden – nicht nur Personen.

LGTM 🚀

jsg-claude
jsg-claude previously approved these changes Mar 28, 2026

@jsg-claude jsg-claude left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #8 Review — Fix screening coverage and blank inputs

Kurz: ✅ Solider Feature-PR mit zwei unabhängigen Fixes. Approve & Merge.


Fix 1: Organization-Schema

Bisher wurde nur "Person" gegen yente abgefragt. Sberbank, Gazprom, Wagner Group — alles verpasst. Der PR fragt jetzt beide Schemas parallel ab und merged die Ergebnisse.

Die Deduplizierung über match_key = (id, datasets_tuple, caption) ist korrekt — ein Unternehmen das in mehreren Listen steht, taucht nur einmal auf. Sortierung nach Score absteigend, dann auf YENTE_MATCH_LIMIT gekappt. ✅

Ein Hinweis: YENTE_QUERY_SCHEMAS als Dict macht spätere Erweiterungen (Vessel, LegalEntity) trivial — gute Entscheidung.


Fix 2: Blank-Input-Validierung

ScreenName = Annotated[str, StringConstraints(strip_whitespace=True, min_length=1)] — das ist der richtige Ort für diese Regel. Pydantic validiert vor dem Handler, " " → 422, ohne dass Anwendungscode nötig ist. ✅

Im HTML-UI wird Whitespace-Input abgefangen bevor _query_yente aufgerufen wird — assert_not_called() im Test bestätigt das explizit. ✅


Tests

Drei neue Tests, alle sinnvoll:

Test Prüft
test_search_ui_whitespace_query_shows_validation_error UI zeigt Fehlermeldung, kein yente-Call
test_query_yente_screens_persons_and_organizations Beide Schemas im Request, Org-Treffer kommt durch
test_screen_blank_name_rejected API gibt 422 für " "

Einzige Anmerkung

normalized_query im HTML-UI und strip_whitespace=True in Pydantic machen dasselbe Trimmen an zwei verschiedenen Stellen. Das ist redundant aber nicht falsch — der API-Pfad und der UI-Pfad sind getrennt, beide trimmen unabhängig. Kein Handlungsbedarf.

@endvater
endvater dismissed stale reviews from jsg-claude and ruthdelalucha via 4bc50f8 March 28, 2026 21:43
@endvater
endvater force-pushed the codex/fix-screening-correctness branch from 536894c to 4bc50f8 Compare March 28, 2026 21:43
@ruthdelalucha
ruthdelalucha merged commit cce75ee into main Mar 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants