feat(navigation): Implement 100% autonomous Blank Start architecture; purge heuristics
This commit is contained in:
@@ -76,8 +76,9 @@ def dynamic_e2e_dump_injector(monkeypatch, request):
|
||||
with open(path, "r") as f:
|
||||
return f.read()
|
||||
|
||||
# The current active state XML
|
||||
device_mock._current_active_xml = load_xml(initial_xml)
|
||||
# History stack to allow "back" navigation
|
||||
device_mock._xml_history = [load_xml(initial_xml)]
|
||||
device_mock._current_active_xml = device_mock._xml_history[-1]
|
||||
|
||||
import uuid
|
||||
def _dump_hierarchy_hook():
|
||||
@@ -92,6 +93,13 @@ def dynamic_e2e_dump_injector(monkeypatch, request):
|
||||
|
||||
device_mock.dump_hierarchy.side_effect = _dump_hierarchy_hook
|
||||
|
||||
def _press_hook(key, *args, **kwargs):
|
||||
if key == "back" and len(device_mock._xml_history) > 1:
|
||||
device_mock._xml_history.pop()
|
||||
device_mock._current_active_xml = device_mock._xml_history[-1]
|
||||
clock.animation_target_time = clock.time + 1.5
|
||||
device_mock.press.side_effect = _press_hook
|
||||
|
||||
class DummyEngine:
|
||||
def find_best_node(self, *args, **kwargs):
|
||||
return {"x": 500, "y": 500, "skip": False, "score": 1.0, "source": "e2e_mock"}
|
||||
@@ -103,6 +111,8 @@ def dynamic_e2e_dump_injector(monkeypatch, request):
|
||||
pass
|
||||
|
||||
original_execute = QNavGraph._execute_transition
|
||||
from GramAddict.core.goap import GoalExecutor
|
||||
original_goap_execute = GoalExecutor._execute_action
|
||||
|
||||
def _mock_execute_transition(nav_self, action, zero_engine=None, max_retries=2):
|
||||
if action == 'tap_post_username':
|
||||
@@ -113,7 +123,9 @@ def dynamic_e2e_dump_injector(monkeypatch, request):
|
||||
def _click_hook(obj=None, *args, **kwargs):
|
||||
original_click(obj, *args, **kwargs)
|
||||
if action in state_map:
|
||||
device_mock._current_active_xml = load_xml(state_map[action])
|
||||
new_xml = load_xml(state_map[action])
|
||||
device_mock._xml_history.append(new_xml)
|
||||
device_mock._current_active_xml = new_xml
|
||||
clock.animation_target_time = clock.time + 1.5
|
||||
|
||||
nav_self.device.click = _click_hook
|
||||
@@ -123,8 +135,37 @@ def dynamic_e2e_dump_injector(monkeypatch, request):
|
||||
return success
|
||||
finally:
|
||||
nav_self.device.click = original_click
|
||||
|
||||
def _mock_execute_action(goap_self, action, goal=None):
|
||||
action_key = action.replace(" ", "_")
|
||||
if action_key == 'tap_post_username':
|
||||
return True
|
||||
|
||||
original_click = goap_self.device.click
|
||||
|
||||
def _click_hook(obj=None, *args, **kwargs):
|
||||
original_click(obj, *args, **kwargs)
|
||||
if action_key in state_map:
|
||||
new_xml = load_xml(state_map[action_key])
|
||||
device_mock._xml_history.append(new_xml)
|
||||
device_mock._current_active_xml = new_xml
|
||||
clock.animation_target_time = clock.time + 1.5
|
||||
elif action in state_map:
|
||||
new_xml = load_xml(state_map[action])
|
||||
device_mock._xml_history.append(new_xml)
|
||||
device_mock._current_active_xml = new_xml
|
||||
clock.animation_target_time = clock.time + 1.5
|
||||
|
||||
goap_self.device.click = _click_hook
|
||||
|
||||
try:
|
||||
success = original_goap_execute(goap_self, action, goal=goal)
|
||||
return success
|
||||
finally:
|
||||
goap_self.device.click = original_click
|
||||
|
||||
monkeypatch.setattr(QNavGraph, "_execute_transition", _mock_execute_transition)
|
||||
monkeypatch.setattr(GoalExecutor, "_execute_action", _mock_execute_action)
|
||||
|
||||
return _inject
|
||||
|
||||
|
||||
Reference in New Issue
Block a user