fix(executor): P0.9 double-check stabilité post-transition fenêtre

Bug observé sur replay_sess_56c10222 (2026-05-24 20:14) :
action 11 (clic 'Enregistrer' expected_after='Enregistrer sous')
marquée success=True alors que 2 actions plus tard la fenêtre observée
est 'NoMachine Desktop Viewer'. Le polling post-vérif a probablement
matché brièvement 'Enregistrer sous' puis l'écran a changé sans
qu'on ne revérifie.

Dom : "Le contrat est rompu : Léa passe d'une action à l'autre sans
vérifier que la précédente est bonne. Il faut un contrôle de résultat,
si on ne sait pas on demande."

Patch : juste après le match initial, attendre 0.5s et reverifier
la fenêtre active. Si elle a divergé (race condition, dialog auto-
fermée, focus change OS) → matched=False, le flow strict existant
prend le relais avec wrong_window + needs_human.

Ne touche que les cas où expected_after est défini ET pas de
runtime_dialog géré entre temps (le runtime_dialog est légitime de
changer la fenêtre).

Tag rollback : rollback/pre-P0.9-2026-05-24_2148
This commit is contained in:
Dom
2026-05-24 20:24:46 +02:00
parent a76f3db682
commit ad24d16d83

View File

@@ -1862,6 +1862,23 @@ class ActionExecutorV1:
max_runtime_dialog_handles,
)
continue
# P0.9 — double-check de stabilité post-transition (~0.5s).
# Race condition observée sur replay_sess_56c10222 act 11 :
# la fenêtre attendue ('Enregistrer sous') peut matcher
# brièvement puis disparaître (dialog auto-fermée par un
# clic parasite ultérieur, ou focus change OS). Sans
# double-check, on valide une transition qui n'est plus là.
if matched and expected_after and not runtime_dialog_handled:
time.sleep(0.5)
recheck_info = get_active_window_info()
recheck_title = recheck_info.get("title", "")
if not _matches_expected_window(recheck_title):
logger.warning(
f"P0.9 transition instable : matched '{post_title}' "
f"puis '{recheck_title}' à T+0.5s ≠ '{expected_after}'"
)
matched = False
post_title = recheck_title
if matched:
if runtime_dialog_handled:
result["warning"] = "runtime_dialog_handled_post_verify"