bbsbot 2026-03-22
Bust exit logic, combat_surrender login fixes, cyclomatic complexity reduction, control-stream codec
122 files · 13,527+ · 9,739-

Bust detection: exit on bust threshold and infinite move cycles

3 files changed
  • game_loop.py Added bust threshold detection — raises BustExitError after BUST_STREAK_THRESHOLD + BUST_EXIT_TURNS (50 total) zero-delta turns with credits below threshold
  • loop_guards.py Added infinite move cycle detection logic
  • loop_handlers.py Updated loop handlers for bust exit path
  • When a bot accumulates a zero-delta streak (no credits gained) exceeding BUST_STREAK_THRESHOLD + BUST_EXIT_TURNS (50 total turns) with credits below the bust threshold, the game loop raises BustExitError, marks the account as bust in the store, and exits. The SwarmManager respawns a fresh agent for the account. instantiate behavioral
    2 files
    • game_loop.py
    • loop_guards.py

Enable bust_respawn by default in SwarmManager

1 file changed
  • ops.py bust_respawn now defaults to True in SwarmManager
  • bust_respawn enabled by default so busted accounts are automatically respawned with a fresh agent without manual intervention. baseline behavioral
    1 file
    • ops.py

combat_surrender handling in login phases 1 and 3

2 files changed
  • phases.py Added combat_surrender detection in phase 1 — when the 'Surrender your previous session? (Y/N)' prompt appears during initial login (TWGS session takeover), answers Y
  • phases_p3.py New module: phase 3 prompt-id fallback helpers extracted from phases.py to satisfy file-size limits; includes combat_surrender handling for phase 3
  • TWGS shows ‘Surrender your previous session? (Y/N)’ during login when the account is still connected. This was previously handled only in phase 3; now also handled in phase 1 where it occurs during the initial session takeover flow. remediate behavioral
    2 files
    • phases.py
    • phases_p3.py

Split update.py: extract TW2002-specific update logic

3 files changed
  • update_tw2002.py New module (389 lines): TW2002-specific bot update logic extracted from update.py to satisfy 600-line LOC limit
  • update.py Reduced by extracting TW2002 code; delegates to update_tw2002.py
  • status.py Status consolidation
  • update.py split: TW2002-specific update path extracted to update_tw2002.py, keeping both files under the 600-line module size limit. Also trimmed session_manager.py by refactoring repeated patterns. decouple internal
    2 files
    • update_tw2002.py
    • update.py

Control-stream codec in WebSocket dashboard and worker bridge

3 files changed
  • dashboard.js Implemented control-stream codec for WebSocket message framing in the browser dashboard
  • session.py Updated session to use control-stream codec
  • generic_io.py Updated IO layer for codec integration
  • Dashboard WebSocket and worker bridge now use the control-stream binary codec for framing, aligning bbsbot with the undef-terminal protocol. TermBridge._send_snapshot overridden to use session.snapshot(). instantiate behavioral
    2 files
    • dashboard.js
    • session.py

Cyclomatic complexity reduction to rank B

40 files changed
  • orchestration.py Major refactoring to reduce complexity
  • layers.py Complexity reduction
  • sequence.py Complexity reduction
  • parsing_logic.py Complexity reduction
  • bot_navigation.py Complexity reduction
  • recovery.py Complexity reduction
  • loop_handlers.py Complexity reduction
  • loop_guards.py Complexity reduction
  • decision_maker.py Complexity reduction
  • control_basic.py Complexity reduction
  • heuristics.py Complexity reduction
  • fast_check.py Complexity reduction
  • renderer.py Complexity reduction
  • trigger.py Complexity reduction
  • advisor.py Complexity reduction
  • anomaly_detectors.py Complexity reduction
  • loop_state.py Complexity reduction
  • loop_action_selection.py Complexity reduction
  • loop_menu_recovery.py Complexity reduction
  • guard_logic.py Complexity reduction
  • prompt_handlers.py Complexity reduction
  • screen.py Complexity reduction
  • state_bridge.py Complexity reduction
  • cargo_ledger.py Complexity reduction
  • executor_trade.py Complexity reduction
  • executor_warp.py Complexity reduction
  • guard_core.py Complexity reduction
  • guard_decision.py Complexity reduction
  • strategy_core.py Complexity reduction
  • strategy_goals.py Complexity reduction
  • strategy_interventions.py Complexity reduction
  • goals.py Complexity reduction
  • prompts.py Complexity reduction
  • parser.py Complexity reduction
  • validator.py Complexity reduction
  • feedback_loop.py Complexity reduction
  • strategy_core.py Complexity reduction
  • opportunity_finder.py Complexity reduction
  • exploration.py Complexity reduction
  • base.py Complexity reduction
  • Full codebase pass to reduce cyclomatic complexity to rank B across all modules. Pre-existing ruff lint violations fixed as part of the same pass. Large functions extracted into helpers; nested conditions flattened; repeated patterns consolidated. decouple internal
    3 files
    • orchestration.py
    • layers.py
    • sequence.py

Compile rules helper and worker/session fixes

30 files changed
  • __init__.py Extracted _compile_rules() helper with re.error handling; docstring added
  • session_manager.py Added release_by_agent() alias in AccountPoolStore
  • account_pool_store.py release_by_agent alias; consistency fixes
  • cli_swarm.py Added --agent-id as alias for --bot-id in worker CLI
  • managed_bot_runtime.py Updated managed bot runtime
  • session_manager.py Trimmed by refactoring repeated patterns
  • resume.py Resume handling updates
  • connection.py Connection handling updates
  • character.py Character state updates
  • utils.py Login utility updates
  • mcp_context.py MCP context updates
  • control_manager.py MCP control manager updates
  • tools_core.py MCP tools core updates
  • mcp_tools_goals.py Goals tool updates
  • mcp_tools_intervention.py Intervention tool updates
  • mcp_tools_session.py Session tool updates
  • manager_plugin.py Manager plugin updates
  • mcp_context.py MCP context updates
  • knowledge.py Knowledge base updates
  • tradewars.py Addon updates
  • debug_screens.py Debug screen updates
  • autotune.py Autotune updates
  • combat.py Combat handling updates
  • constants.py Added constants
  • __init__.py Package updates
  • utils.py Trade utility updates
  • __init__.py Game module updates
  • settings_diff.py Settings diff updates
  • tedit_manager.py TEdit manager updates
  • generate_diagrams.py Diagram generation script updates
  • _compile_rules() helper extracted with re.error handling for invalid regex patterns. –agent-id accepted as alias for –bot-id. release_by_agent() alias added to AccountPoolStore for consistency. remediate internal
    3 files
    • __init__.py
    • cli_swarm.py
    • account_pool_store.py

Dashboard fix: CONNECTING status and dot recovery

1 file changed
  • dashboard.js New bots now show CONNECTING status before first update; spinner dot now recovers after update errors
  • Dashboard renders CONNECTING for newly registered bots instead of blank/undefined status. The status dot is reset after any update error so it doesn’t stay in an error state permanently. remediate behavioral
    1 file
    • dashboard.js

Test coverage additions

7 files changed
  • test_bbs_session_targeting.py 13 new MCP session targeting tests
  • test_account_pool_store.py 7 new account pool store tests
  • test_session_manager.py 50-line updates to session manager tests
  • test_engine.py 30-line learning engine tests
  • test_loop_guards.py Updated loop guard tests
  • test_no_interaction_backoff.py 48-line backoff tests
  • uv.lock Lockfile update
  • Added tests for concurrent reuse race (verifies exactly one transport connect), MCP session targeting, account pool store release_by_agent, invalid regex patterns in _compile_rules, and summary credentials. qualify internal
    3 files
    • test_bbs_session_targeting.py
    • test_account_pool_store.py
    • test_session_manager.py