feat(orchestrator): wire GoalDecomposer into bot_flow.py

Replace the old dual-path orchestrator (abstract goals vs legacy desires)
with unified GoalDecomposer-driven task routing:

1. GoalDecomposer reads mission.strategy + plugins config
2. Generates weighted Task objects (verb, target_screen, budget)
3. GrowthBrain.select_task() picks one probabilistically
4. Selected Task's target_screen routes through existing nav_graph
5. Feed loops + PluginRegistry handle the actual interactions

The abstract goals path (goal_executor.achieve('Nurture community'))
that caused infinite scrolling is now eliminated entirely.

Legacy desire fallback preserved for configs without plugins.

22/22 tests passing.
This commit is contained in:
2026-04-29 17:20:04 +02:00
parent b6846ab0fe
commit 0e43996ccd
3 changed files with 161 additions and 59 deletions

View File

@@ -1,23 +1,30 @@
def test_bot_flow_prioritizes_goals_over_desires():
def test_bot_flow_uses_goal_decomposer_not_abstract_goals():
"""
Test that when goals are present in config, the bot uses GoalExecutor
instead of the legacy desire mapping.
This should fail (RED) before we refactor bot_flow.py.
Test that bot_flow.py uses GoalDecomposer for task-based navigation
instead of the abstract goals string system.
The old system passed abstract strings like "Nurture my community"
to GoalExecutor.achieve() — which caused endless scrolling because
the LLM had no semantic bridge to concrete plugin actions.
The new system:
1. GoalDecomposer reads mission + plugins → generates concrete Tasks
2. GrowthBrain.select_task() picks a Task with weighted random
3. The Task's target_screen routes through nav_graph to feed loops
"""
# We won't run the whole start_bot (it's massive),
# we'll just test the core orchestrator loop extraction if we can,
# or we can test the behavior by mocking the device and config.
# Actually, a better way is to test that the goal string is passed to achieve.
# Since we can't easily mock the massive `start_bot`, we will test the
# conceptual behavior by just ensuring the code in bot_flow contains
# GoalExecutor.achieve logic.
# Let's import the file and check for GoalExecutor usage
with open("GramAddict/core/bot_flow.py", "r") as f:
content = f.read()
# This assertion will fail (RED) because GoalExecutor is not in the original bot_flow.py
assert "GoalExecutor" in content, "bot_flow.py does not use GoalExecutor for autonomous goals"
assert "goal_executor.achieve(current_goal)" in content, "bot_flow.py does not execute goals autonomously"
# New system MUST be present
assert "GoalDecomposer" in content, "bot_flow.py must use GoalDecomposer"
assert "select_task" in content, "bot_flow.py must use GrowthBrain.select_task()"
assert "available_tasks" in content, "bot_flow.py must generate available_tasks"
# Old abstract goals path MUST be gone
assert "goal_executor.achieve(current_goal)" not in content, (
"bot_flow.py still uses old abstract goal_executor.achieve()! "
"This causes endless scrolling."
)
assert 'getattr(configs.args, "goals"' not in content, (
"bot_flow.py still reads abstract goals from config!"
)