Skip blank package keywords — Implementation Plan
Goal: Pedido de pacote Ano Novo não deve selecionar pacote Natal só porque keywords/selected têm string vazia ("" in text é True em Python).
Task: TICKET-108702
Handoff: 108702
Spec: none — root cause isolada no matcher
Architecture: exact_match_package faz containment de selected vs name/keywords. String vazia é substring de qualquer texto, então keyword "" (ou selected "") marca qualquer pacote. Corrigir no matcher: ignorar termos blank após _normalize. Não mudar fuzzy threshold nem fallback “list all”.
Tech: Python 3.12, pytest unit tests existentes em tests/test_unit/test_packages_tool_fuzzy_match.py
Test layout: pipenv run pytest tests/test_unit/... (reuse venv se necessário)
Cheap-first:
- Contra código: só limpar keywords no Control deste hotel — barato, não fecha o bug sistêmico.
- Preferido: skip blank no matcher (1 função + testes).
- Fora de escopo agora: substring frouxa de “pacote” em todos os nomes (outro sintoma).
Global Constraints:
- TDD red → green
- Sem commit/push
- Patch mínimo em
exact_match_package(+ helper se precisar) - Execute inline; review obrigatório no fim
Task 1: Ignore blank keywords/selected in exact match
Files:
- Modify:
src/tools/packages_tool.py - Test:
tests/test_unit/test_packages_tool_fuzzy_match.py
Interfaces:
- Consumes:
pkg_name,pkg_keywords,selected_packages - Produces:
(found: bool, matched_terms: list[str])— blank keywords nunca causam match; blank selected ignorados
Acceptance:
exact_match_package("Pacote Natal", [""], ["ano novo"])→ Falseexact_match_package("Pacote Natal", ["natal", ""], ["ano novo"])→ Falseexact_match_package("Pacote Natal", [""], [""])→ Falseexact_match_package("Pacote Natal", ["natal"], ["natal"])→ True (regressão)exact_match_package("Pacote Ano Novo", [], ["ano novo"])→ True (name match intacto)
TDD:
- Red: add unit tests above; expect fail on empty-kw case
- Green: skip normalized-blank selected and keywords in
exact_match_package - Verify:
pipenv run pytest tests/test_unit/test_packages_tool_fuzzy_match.py -q(or existing venv python -m pytest) - Expected: all pass
Risk: mech