snapshot: WIP 5j replay reliability (B1 watchdog + dialog handlers + grounding drift)
Snapshot avant correction du blocage relance Léa (3 incidents 24h: SSH refusé, polls morts ×2). Point de rollback stable. Contenu: - agent_v1/core/executor.py: 5 patchs dialog handling (saveas drift, close_tab hotkey fallback, confirm_save Unicode apostrophe, foreground dialog recontextualization, runtime_dialog in-loop) + helpers normalize_window_hint, requires_post_verify_window_transition - agent_v1/core/grounding.py: garde drift template fix (fallback_x/y plumbed) - server_v1/replay_watchdog.py (NEW): orphan watchdog B1, scan 10s timeout 30s - server_v1/api_stream.py: dispatched_action plumbing, watchdog lifespan, metrics endpoint - server_v1/replay_engine.py: _schedule_retry préserve original_action + dispatched_action - stream_processor.py: gardes _infer_tab_switch_target (no false switch_tab on save_as dialog open) + _attach_expected_window_before - tests/integration: test_replay_watchdog.py (8 cas), test_stream_processor.py - tests/unit: test_executor_verify_window_guard.py (start_button, close_tab, runtime_dialog, post_verify, transition fallbacks) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
46
tests/unit/test_grounding_engine.py
Normal file
46
tests/unit/test_grounding_engine.py
Normal file
@@ -0,0 +1,46 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
ROOT = Path(__file__).parent.parent.parent
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from agent_v0.agent_v1.core.grounding import GroundingEngine # noqa: E402
|
||||
|
||||
|
||||
def test_template_strategy_passes_fallback_coords_to_anchor_drift_guard():
|
||||
executor = MagicMock()
|
||||
executor._template_match_anchor = MagicMock(
|
||||
return_value={
|
||||
"resolved": True,
|
||||
"x_pct": 0.7,
|
||||
"y_pct": 0.35,
|
||||
"score": 0.95,
|
||||
}
|
||||
)
|
||||
|
||||
engine = GroundingEngine(executor)
|
||||
target_spec = {"anchor_image_base64": "abc123"}
|
||||
|
||||
result = engine._try_strategy(
|
||||
"template",
|
||||
server_url="",
|
||||
screenshot_b64="shot",
|
||||
target_spec=target_spec,
|
||||
fallback_x=0.708594,
|
||||
fallback_y=0.35,
|
||||
screen_width=2560,
|
||||
screen_height=1600,
|
||||
)
|
||||
|
||||
assert result.found is True
|
||||
executor._template_match_anchor.assert_called_once_with(
|
||||
"shot",
|
||||
"abc123",
|
||||
2560,
|
||||
1600,
|
||||
fallback_x_pct=0.708594,
|
||||
fallback_y_pct=0.35,
|
||||
)
|
||||
Reference in New Issue
Block a user