feat(grounding): vérification titre OCR post-action (non-bloquante)

TitleVerifier (core/grounding/title_verifier.py) :
- Crop 45px barre de titre → OCR → compare avant/après (~280ms)
- Titres < 3 chars ignorés (bruit OCR sur VM)
- Non-bloquant : échec = warning, pas stop

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dom
2026-04-26 03:22:50 +02:00
parent 90007cc7c1
commit cc64439738
2 changed files with 178 additions and 0 deletions

View File

@@ -1313,6 +1313,26 @@ Règles:
# Stocker le pHash post-action pour le réflexe check du step suivant
self._last_post_phash = post.phash
# --- 4b. Vérification titre OCR (non-bloquante, ~120ms) ---
_action_type = step.get('action_type', '')
if _action_type in ('double_click_anchor', 'click_anchor') and pre.screenshot and post.screenshot:
try:
from core.grounding.title_verifier import TitleVerifier
_tv = TitleVerifier()
_tv_result = _tv.verify_action(pre.screenshot, post.screenshot, _action_type)
if not _tv_result['success']:
print(f"⚠️ [ORA/titre] {_tv_result['reason']} → retry")
# Retry : recliquer
time.sleep(0.5)
self.act(decision, step)
time.sleep(0.3)
post = self.observe()
self._last_post_phash = post.phash
elif _tv_result['changed']:
print(f"✅ [ORA/titre] '{_tv_result['title_after'][:40]}'")
except Exception as _tv_err:
print(f"⚠️ [ORA/titre] Erreur: {_tv_err}")
# --- 5. Vérifier ---
verification = self.verify(pre, post, decision)