Fixes:
1. Rewrote run_competitive_benchmark.py to test BOTH capabilities:
- Telepathic (JSON element extraction)
- Brain (Free-text action extraction with format_json=False)
2. Normalizes scores by averaging per-scenario (fixes score inflation
where models with more scenarios tested scored higher but were marked unsuitable).
3. Added 4 new brain_action scenarios to ensure the 'think=false' code path
is actively benchmarked going forward.
4. Added test_benchmark_integrity.py to lock in scenario format rules.
5. Cleared stale llm_benchmarks.json data to force clean re-evaluations.
ROOT CAUSE: qwen3.5 (reasoning model) returns response='' with thinking
block containing all reasoning. llm_provider.py line 352 silently
substituted the thinking block as the response via:
content = raw_response or raw_thinking or ''
The Brain then extracted random actions from the reasoning text.
FIXES:
1. llm_provider.py: Conditional thinking isolation
- format_json=True (SAE/perception): thinking fallback preserved
- format_json=False (Brain): thinking NEVER substituted
- Added think=false for Ollama free-text calls to force direct response
2. planner.py: No-Op Guard strips tab actions that navigate to
the current screen (e.g. 'tap profile tab' on OWN_PROFILE)
3. test_brain_live.py: Stochastic testing (5 runs, 60% min valid)
to handle non-deterministic LLM behavior reliably
4. tests/integration/test_llm_provider_pipeline.py: NEW test layer
mocking at HTTP level (requests.post) to exercise the FULL
llm_provider → Brain pipeline. This would have caught the
thinking substitution bug from day one.
Suite: 168 passed, 0 failed
- Add permanent mock ban guard in root conftest.py that fails any test
importing unittest.mock at COLLECTION TIME (before execution)
- Add 8 brain output contract tests reproducing the exact production bug:
LLM thinks 'press back' but parser extracts 'tap messages tab' from
the <think> block
- Add UI change noise threshold (MIN_UI_CHANGE_BYTES=50) to prevent
false-positive 'ui_changed' from 1-byte XML diffs (timestamps/whitespace)
- Verify planner correctly strips masked actions from Brain prompt
- Added strict TDD coverage for all autonomous changes.
- Implemented GrowthBrain.get_current_goal to select high-level objectives.
- Replaced procedural orchestrator with GoalExecutor in bot_flow.
- Purged hardcoded resource-ids in dm_engine in favor of ScreenIdentity.
- Removed regex parsing in unfollow_engine in favor of telepathic semantic extraction.
- Fixed get_plugin_config AttributeError in MockConfigs and FakeConfig
- Adjusted test_carousel_zero_percent to assert on can_activate
- Explicitly delete missing mock config args in E2E tests for getattr coverage
ROOT CAUSE: The bot was systematically sabotaging its own navigation.
The HD Map planned correct 2-step routes (Home→Profile→FollowList),
but _execute_action() validated each INTERMEDIATE step against the
FINAL goal. Step 1 (tap profile tab → OWN_PROFILE) got rejected
because the goal said 'following', triggering aversive learning
that permanently burned the only valid route.
SIX COMPOUNDING FIXES:
1. SSOT Consolidation (_is_goal_achieved):
Replaced 12-line hardcoded if-chain with ScreenTopology.goal_to_target_screen().
Single source of truth for all goal→screen mappings.
2. Step-Aware Navigation Validation (_execute_action):
Replaced goal_screen_map keyword-scan with
ScreenTopology.expected_screen_for_action(action, pre_action_screen).
Now validates: 'did this step land where IT should?' not 'did I reach my goal yet?'
3. Topology Guard (aversive learning):
ScreenTopology.is_structural_action() prevents burning HD Map actions.
VLM may fail to find the element, but the route itself is structurally valid.
4. Fast-Path Threshold Fix (telepathic_engine):
100% match threshold now applies only to NAV_TAB_KEYWORDS (actual tabs),
not NAV_ZONE_BYPASS_KEYWORDS. 'tap following list' was blocked because
'following' triggered the tab threshold on a non-tab action.
5. navigate_to_screen SSOT:
Replaced 8-entry goal_map dict with ScreenTopology.screen_name_to_goal().
6. QNavGraph Name Map Dedup:
Replaced 2 inline screen_name_map/name_to_screen dicts with
ScreenTopology.SCREEN_NAME_MAP reverse lookups.
Before: 4 competing goal→screen mappings. Self-sabotage loop.
After: 1 SSOT. Step-aware validation. Topology-protected routing.
141 unit tests pass. Zero regressions.
FUNDAMENTAL ARCHITECTURE OVERHAUL:
1. ScreenTopology HD Map (NEW):
Pure-data BFS pathfinding between Instagram screens.
Zero runtime dependencies. The GOAP planner's GPS.
Knows: HOME_FEED → tap profile tab → OWN_PROFILE → tap following list → FOLLOW_LIST
2. Graph-Aware GOAP Planning:
GoalPlanner._plan_navigation() now consults ScreenTopology FIRST.
From HOME_FEED, goal 'open following list' returns 'tap profile tab'
(intermediate hop) instead of blind 'open following list' (impossible).
Autonomous discovery and Qdrant knowledge kept as fallbacks.
3. NAV Keyword Split:
NAV_INTENT_KEYWORDS → NAV_ZONE_BYPASS_KEYWORDS + NAV_TAB_KEYWORDS
Ends the Structural Guard civil war where 'following' was both
'allowed in nav zone' AND 'must be at bottom' simultaneously.
4. QNavGraph Deduplication:
_find_path() delegates to ScreenTopology.find_route() (SSOT).
core_nodes seed generated from ScreenTopology.TRANSITIONS.
115 unit tests pass. Zero regressions.
Root cause: VLM Structural Guard enforced 'must be at bottom' for ALL
NAV_INTENT_KEYWORDS including 'following'/'follower'. But these are
profile stats at Y≈246 (top of screen), not nav tabs. The inner
_structural_sanity_check correctly checks for 'tab' in intent before
enforcing bottom-zone requirement — the VLM guard was inconsistent.
Fix 1: Align VLM guard with inner guard — only enforce bottom-zone
requirement for intents explicitly containing 'tab'.
Fix 2: Add back-press circuit breaker (MAX_CONSECUTIVE_BACK=3). If GOAP
presses back 3 times on the same screen without any transition,
abort immediately to prevent exiting Instagram entirely.
95 unit tests pass.
- Extract NAV_INTENT_KEYWORDS constant (DRY) with 'direct message', 'inbox',
'dm', 'notification', 'heart icon' to fix structural guard self-sabotage
where 'tap direct message icon inbox' was rejected as non-nav intent
- Add goal-achieved pre-check in GOAP _execute_recalled_path to skip
stale paths when the bot is already on the target screen
- Add already-there detection in _execute_action to prevent false unlearning
when navigation produces no UI change because goal is already met
- Implement 3-tier ad escape cascade: normal skip -> double scroll -> GOAP
force-navigate to HomeFeed after 6+ consecutive ad cycles
- 92 unit tests pass, 223/224 integration tests pass (1 pre-existing flaky)
- Fixed a bug where `humanized_scroll(is_skip=True)` could trigger random 'Doomscroll Corrections' (scrolling backwards) or 'reading pauses'.
- This caused the Anti-Stuck loop for ads to fail because the aggressive skip would occasionally just pause or scroll back into the ad.
- Added strict TDD coverage in `test_physics_humanized.py` to verify `is_skip` generates strictly forward gestures without pauses.
- Hardened `NavigationKnowledge` and `TelepathicEngine` to prevent premature blacklisting on high-latency grid taps by returning `None` (inconclusive) when grid markers are still present.
- Updated `_execute_action` in `goap.py` to respect inconclusive verification states and avoid polluting the blacklist.
- Refined `Adaptive Snap` in `timing.py` to detect `ProgressBar` loading spinners, extending timeouts for slow connections.
- Prevented brittle Adaptive Snap `wobble` routines from firing while the bot is still trapped on the Explore Grid.
- Stabilized Qdrant collections by converting destructive delete-only wipes into safe `wipe_collection` routines that instantly recreate the index.
- Maintained 100% TDD pass-rate by aligning E2E grid navigation tests with the new inconclusive states.
- implemented self-healing unlearn for Qdrant false positives
- centralized testing logic in conftest
- documented core rules, ai standards, and goap philosophy
- purged old dev scratchpads
- Separated obstacle detection from feed marker validation
- Prevented blind BACK button presses when markers are missing mid-scroll
- Added TDD verification for feed navigation stability
- Cleaned up debug artifacts and temporary test output
Summary of work:
- Resolved mass SystemExit: 2 failures by hardening Config against pytest CLI args.
- Fixed state leakage in test suite by implementing aggressive cache wiping in conftest.py.
- Fixed TypeErrors and UnboundLocalErrors in TelepathicEngine and bot_flow.
- Aligned MockTelepathicEngine signatures to resolve Mock Drift.
- Achieved 100% pass rate across 498 tests.