feat(p1): persist workflows and semantic learning artifacts

This commit is contained in:
Dom
2026-06-02 16:20:38 +02:00
parent 7a1a5cb6fd
commit 86b3c8f7e7
21 changed files with 3816 additions and 31 deletions

View File

@@ -68,6 +68,10 @@ def test_memory_lookup_keeps_learned_visual_coords_with_window_capture(monkeypat
target_spec={
"by_text": "Enregistrer",
"by_role": "yolo",
"context_hints": {
"expected_window_before": "*test Bloc-notes",
"interaction": "toolbar_save_button",
},
"window_capture": {
"click_relative": [860, 634],
"window_size": [1920, 1116],
@@ -81,6 +85,71 @@ def test_memory_lookup_keeps_learned_visual_coords_with_window_capture(monkeypat
assert result["y_pct"] == 0.578125
def test_memory_lookup_skips_window_transition_even_if_record_exists(monkeypatch):
fp = SimpleNamespace(
bbox=(0.5, 0.8, 0.0, 0.0),
etype="grounding_vlm",
confidence=0.85,
)
monkeypatch.setattr(replay_memory, "get_memory_store", lambda: _DummyStore(fp))
result = replay_memory.memory_lookup(
window_title="*test Bloc-notes",
target_spec={
"by_text": "Enregistrer",
"by_role": "button",
"context_hints": {
"expected_window_before": "*test Bloc-notes",
"expected_window_after": "Enregistrer sous",
"requires_window_transition": True,
},
},
)
assert result is None
def test_memory_lookup_rejects_generic_button_without_context(monkeypatch):
fp = SimpleNamespace(
bbox=(0.5, 0.8, 0.0, 0.0),
etype="grounding_vlm",
confidence=0.85,
)
monkeypatch.setattr(replay_memory, "get_memory_store", lambda: _DummyStore(fp))
result = replay_memory.memory_lookup(
window_title="*test Bloc-notes",
target_spec={"by_text": "Enregistrer", "by_role": "button"},
)
assert result is None
def test_memory_lookup_allows_generic_button_with_context(monkeypatch):
fp = SimpleNamespace(
bbox=(0.5, 0.8, 0.0, 0.0),
etype="grounding_vlm",
confidence=0.85,
)
monkeypatch.setattr(replay_memory, "get_memory_store", lambda: _DummyStore(fp))
result = replay_memory.memory_lookup(
window_title="Enregistrer sous",
target_spec={
"by_text": "Enregistrer",
"by_role": "button",
"window_title": "Enregistrer sous",
"context_hints": {
"expected_window_before": "Enregistrer sous",
"interaction": "save_dialog_primary_button",
},
},
)
assert result is not None
assert result["method"] == "memory_grounding_vlm"
def test_target_spec_hash_distinguishes_same_text_with_different_spatial_hints(tmp_path):
store = TargetMemoryStore(base_path=str(tmp_path / "learning"))