refactor(sdm): Global pass with refined 'External Only' SDM tags. Pruned redundant internal references and fixed indentation logic in injector. Verified full project compilation.
This commit is contained in:
@@ -3,6 +3,9 @@ from simulation.sim_base import BaseSimulation, run_sim
|
||||
|
||||
class AISettingsSimulation(BaseSimulation):
|
||||
def run(self) -> None:
|
||||
"""
|
||||
[C: simulation/sim_base.py:run_sim, tests/conftest.py:kill_process_tree, tests/conftest.py:live_gui, tests/test_conductor_abort_event.py:test_conductor_abort_event_populated, tests/test_conductor_engine_v2.py:test_conductor_engine_dynamic_parsing_and_execution, tests/test_conductor_engine_v2.py:test_conductor_engine_run_executes_tickets_in_order, tests/test_extended_sims.py:test_ai_settings_sim_live, tests/test_extended_sims.py:test_context_sim_live, tests/test_extended_sims.py:test_execution_sim_live, tests/test_extended_sims.py:test_tools_sim_live, tests/test_external_editor_gui.py:get_vscode_processes, tests/test_external_editor_gui.py:test_vscode_launches_with_diff_view, tests/test_gui_custom_window.py:test_app_window_is_borderless, tests/test_headless_simulation.py:module, tests/test_headless_verification.py:test_headless_verification_error_and_qa_interceptor, tests/test_headless_verification.py:test_headless_verification_full_run, tests/test_mock_gemini_cli.py:run_mock, tests/test_orchestration_logic.py:test_conductor_engine_run, tests/test_parallel_execution.py:test_conductor_engine_pool_integration, tests/test_sim_ai_settings.py:test_ai_settings_simulation_run, tests/test_sim_context.py:test_context_simulation_run, tests/test_sim_execution.py:test_execution_simulation_run, tests/test_sim_tools.py:test_tools_simulation_run]
|
||||
"""
|
||||
print("\n--- Running AI Settings Simulation (Gemini Only) ---")
|
||||
# 1. Verify initial model
|
||||
provider = self.client.get_value("current_provider")
|
||||
@@ -28,4 +31,4 @@ class AISettingsSimulation(BaseSimulation):
|
||||
assert final_model == target_model, f"Expected {target_model}, got {final_model}"
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_sim(AISettingsSimulation)
|
||||
run_sim(AISettingsSimulation)
|
||||
+17
-2
@@ -62,6 +62,9 @@ class BaseSimulation:
|
||||
self.project_path = None
|
||||
|
||||
def setup(self, project_name: str = "SimProject") -> None:
|
||||
"""
|
||||
[C: simulation/sim_execution.py:ExecutionSimulation.setup, tests/test_extended_sims.py:test_ai_settings_sim_live, tests/test_extended_sims.py:test_context_sim_live, tests/test_extended_sims.py:test_execution_sim_live, tests/test_extended_sims.py:test_tools_sim_live, tests/test_sim_base.py:test_base_simulation_setup]
|
||||
"""
|
||||
print("\n[BaseSim] Connecting to GUI...")
|
||||
if not self.client.wait_for_server(timeout=5):
|
||||
raise RuntimeError("Could not connect to GUI. Ensure it is running with --enable-test-hooks")
|
||||
@@ -88,6 +91,9 @@ class BaseSimulation:
|
||||
time.sleep(1.5)
|
||||
|
||||
def teardown(self) -> None:
|
||||
"""
|
||||
[C: tests/test_extended_sims.py:test_ai_settings_sim_live, tests/test_extended_sims.py:test_context_sim_live, tests/test_extended_sims.py:test_execution_sim_live, tests/test_extended_sims.py:test_tools_sim_live]
|
||||
"""
|
||||
if self.project_path and os.path.exists(self.project_path):
|
||||
# We keep it for debugging if it failed, but usually we'd clean up
|
||||
# os.remove(self.project_path)
|
||||
@@ -95,9 +101,15 @@ class BaseSimulation:
|
||||
print("[BaseSim] Teardown complete.")
|
||||
|
||||
def get_value(self, tag: str) -> Any:
|
||||
"""
|
||||
[C: simulation/sim_context.py:ContextSimulation.run, simulation/sim_execution.py:ExecutionSimulation.run, simulation/workflow_sim.py:WorkflowSimulator.run_discussion_turn_async, simulation/workflow_sim.py:WorkflowSimulator.wait_for_ai_response, tests/smoke_status_hook.py:test_status_hook, tests/smoke_status_hook.py:wait_for_value, tests/test_auto_switch_sim.py:test_auto_switch_sim, tests/test_deepseek_infra.py:test_gui_provider_list_via_hooks, tests/test_extended_sims.py:test_ai_settings_sim_live, tests/test_gui2_parity.py:test_gui2_click_hook_works, tests/test_gui2_parity.py:test_gui2_set_value_hook_works, tests/test_rag_phase4_final_verify.py:test_phase4_final_verify, tests/test_rag_phase4_stress.py:test_rag_large_codebase_verification_sim, tests/test_rag_visual_sim.py:test_rag_full_lifecycle_sim, tests/test_rag_visual_sim.py:test_rag_settings_persistence_sim, tests/test_selectable_ui.py:test_selectable_label_stability, tests/test_system_prompt_sim.py:test_system_prompt_sim, tests/test_undo_redo_sim.py:test_undo_redo_context_mutation, tests/test_undo_redo_sim.py:test_undo_redo_discussion_mutation, tests/test_undo_redo_sim.py:test_undo_redo_lifecycle, tests/test_visual_mma.py:test_visual_mma_components, tests/test_workspace_profiles_sim.py:test_workspace_profiles_restoration]
|
||||
"""
|
||||
return self.client.get_value(tag)
|
||||
|
||||
def wait_for_event(self, event_type: str, timeout: int = 5) -> Optional[dict]:
|
||||
"""
|
||||
[C: simulation/sim_execution.py:ExecutionSimulation.run, tests/test_z_negative_flows.py:test_mock_error_result, tests/test_z_negative_flows.py:test_mock_malformed_json, tests/test_z_negative_flows.py:test_mock_timeout]
|
||||
"""
|
||||
return self.client.wait_for_event(event_type, timeout)
|
||||
|
||||
def assert_panel_visible(self, panel_tag: str, msg: str = None) -> None:
|
||||
@@ -115,7 +127,10 @@ class BaseSimulation:
|
||||
return False
|
||||
|
||||
def run_sim(sim_class: type) -> None:
|
||||
"""Helper to run a simulation class standalone."""
|
||||
"""
|
||||
Helper to run a simulation class standalone.
|
||||
[C: simulation/sim_context.py:module, simulation/sim_execution.py:module, simulation/sim_tools.py:module]
|
||||
"""
|
||||
sim = sim_class()
|
||||
try:
|
||||
sim.setup()
|
||||
@@ -127,4 +142,4 @@ def run_sim(sim_class: type) -> None:
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
finally:
|
||||
sim.teardown()
|
||||
sim.teardown()
|
||||
@@ -4,6 +4,9 @@ from simulation.sim_base import BaseSimulation, run_sim
|
||||
|
||||
class ContextSimulation(BaseSimulation):
|
||||
def run(self) -> None:
|
||||
"""
|
||||
[C: tests/conftest.py:kill_process_tree, tests/conftest.py:live_gui, tests/test_conductor_abort_event.py:test_conductor_abort_event_populated, tests/test_conductor_engine_v2.py:test_conductor_engine_dynamic_parsing_and_execution, tests/test_conductor_engine_v2.py:test_conductor_engine_run_executes_tickets_in_order, tests/test_extended_sims.py:test_ai_settings_sim_live, tests/test_extended_sims.py:test_context_sim_live, tests/test_extended_sims.py:test_execution_sim_live, tests/test_extended_sims.py:test_tools_sim_live, tests/test_external_editor_gui.py:get_vscode_processes, tests/test_external_editor_gui.py:test_vscode_launches_with_diff_view, tests/test_gui_custom_window.py:test_app_window_is_borderless, tests/test_headless_simulation.py:module, tests/test_headless_verification.py:test_headless_verification_error_and_qa_interceptor, tests/test_headless_verification.py:test_headless_verification_full_run, tests/test_mock_gemini_cli.py:run_mock, tests/test_orchestration_logic.py:test_conductor_engine_run, tests/test_parallel_execution.py:test_conductor_engine_pool_integration, tests/test_sim_ai_settings.py:test_ai_settings_simulation_run, tests/test_sim_context.py:test_context_simulation_run, tests/test_sim_execution.py:test_execution_simulation_run, tests/test_sim_tools.py:test_tools_simulation_run]
|
||||
"""
|
||||
print("\n--- Running Context & Chat Simulation ---")
|
||||
# 1. Skip Discussion Creation, use 'main'
|
||||
print("[Sim] Using existing 'main' discussion")
|
||||
@@ -70,4 +73,4 @@ class ContextSimulation(BaseSimulation):
|
||||
assert len(chat_entries) == 2, f"Expected exactly 2 chat entries after truncation, found {len(chat_entries)}"
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_sim(ContextSimulation)
|
||||
run_sim(ContextSimulation)
|
||||
@@ -4,11 +4,17 @@ from simulation.sim_base import BaseSimulation, run_sim
|
||||
|
||||
class ExecutionSimulation(BaseSimulation):
|
||||
def setup(self, project_name: str = "SimProject") -> None:
|
||||
"""
|
||||
[C: tests/test_extended_sims.py:test_ai_settings_sim_live, tests/test_extended_sims.py:test_context_sim_live, tests/test_extended_sims.py:test_execution_sim_live, tests/test_extended_sims.py:test_tools_sim_live, tests/test_sim_base.py:test_base_simulation_setup]
|
||||
"""
|
||||
super().setup(project_name)
|
||||
if os.path.exists("hello.ps1"):
|
||||
os.remove("hello.ps1")
|
||||
|
||||
def run(self) -> None:
|
||||
"""
|
||||
[C: tests/conftest.py:kill_process_tree, tests/conftest.py:live_gui, tests/test_conductor_abort_event.py:test_conductor_abort_event_populated, tests/test_conductor_engine_v2.py:test_conductor_engine_dynamic_parsing_and_execution, tests/test_conductor_engine_v2.py:test_conductor_engine_run_executes_tickets_in_order, tests/test_extended_sims.py:test_ai_settings_sim_live, tests/test_extended_sims.py:test_context_sim_live, tests/test_extended_sims.py:test_execution_sim_live, tests/test_extended_sims.py:test_tools_sim_live, tests/test_external_editor_gui.py:get_vscode_processes, tests/test_external_editor_gui.py:test_vscode_launches_with_diff_view, tests/test_gui_custom_window.py:test_app_window_is_borderless, tests/test_headless_simulation.py:module, tests/test_headless_verification.py:test_headless_verification_error_and_qa_interceptor, tests/test_headless_verification.py:test_headless_verification_full_run, tests/test_mock_gemini_cli.py:run_mock, tests/test_orchestration_logic.py:test_conductor_engine_run, tests/test_parallel_execution.py:test_conductor_engine_pool_integration, tests/test_sim_ai_settings.py:test_ai_settings_simulation_run, tests/test_sim_context.py:test_context_simulation_run, tests/test_sim_execution.py:test_execution_simulation_run, tests/test_sim_tools.py:test_tools_simulation_run]
|
||||
"""
|
||||
print("\n--- Running Execution & Modals Simulation ---")
|
||||
# 1. Trigger script generation (Async so we don't block on the wait loop)
|
||||
msg = "Create a hello.ps1 script that prints 'Simulation Test' and execute it."
|
||||
@@ -65,4 +71,4 @@ class ExecutionSimulation(BaseSimulation):
|
||||
print(f"[Sim] Final check: approved {approved_count} scripts.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_sim(ExecutionSimulation)
|
||||
run_sim(ExecutionSimulation)
|
||||
@@ -3,6 +3,9 @@ from simulation.sim_base import BaseSimulation, run_sim
|
||||
|
||||
class ToolsSimulation(BaseSimulation):
|
||||
def run(self) -> None:
|
||||
"""
|
||||
[C: tests/conftest.py:kill_process_tree, tests/conftest.py:live_gui, tests/test_conductor_abort_event.py:test_conductor_abort_event_populated, tests/test_conductor_engine_v2.py:test_conductor_engine_dynamic_parsing_and_execution, tests/test_conductor_engine_v2.py:test_conductor_engine_run_executes_tickets_in_order, tests/test_extended_sims.py:test_ai_settings_sim_live, tests/test_extended_sims.py:test_context_sim_live, tests/test_extended_sims.py:test_execution_sim_live, tests/test_extended_sims.py:test_tools_sim_live, tests/test_external_editor_gui.py:get_vscode_processes, tests/test_external_editor_gui.py:test_vscode_launches_with_diff_view, tests/test_gui_custom_window.py:test_app_window_is_borderless, tests/test_headless_simulation.py:module, tests/test_headless_verification.py:test_headless_verification_error_and_qa_interceptor, tests/test_headless_verification.py:test_headless_verification_full_run, tests/test_mock_gemini_cli.py:run_mock, tests/test_orchestration_logic.py:test_conductor_engine_run, tests/test_parallel_execution.py:test_conductor_engine_pool_integration, tests/test_sim_ai_settings.py:test_ai_settings_simulation_run, tests/test_sim_context.py:test_context_simulation_run, tests/test_sim_execution.py:test_execution_simulation_run, tests/test_sim_tools.py:test_tools_simulation_run]
|
||||
"""
|
||||
print("\n--- Running Tools Simulation ---")
|
||||
# 1. Trigger list_directory tool
|
||||
msg = "List the files in the current directory."
|
||||
@@ -39,4 +42,4 @@ class ToolsSimulation(BaseSimulation):
|
||||
print(f"[Sim] Final AI Response: {last_ai_msg[:100]}...")
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_sim(ToolsSimulation)
|
||||
run_sim(ToolsSimulation)
|
||||
@@ -22,16 +22,25 @@ class UserSimAgent:
|
||||
return max(0.5, min(5.0, delay))
|
||||
|
||||
def wait_to_read(self, text: str) -> None:
|
||||
"""
|
||||
[C: simulation/workflow_sim.py:WorkflowSimulator.wait_for_ai_response]
|
||||
"""
|
||||
if self.enable_delays:
|
||||
delay = self.calculate_reading_delay(text)
|
||||
time.sleep(delay)
|
||||
|
||||
def wait_to_think(self, probability: float = 0.2, min_delay: float = 2.0, max_delay: float = 5.0) -> None:
|
||||
"""
|
||||
[C: simulation/workflow_sim.py:WorkflowSimulator.wait_for_ai_response]
|
||||
"""
|
||||
if self.enable_delays and random.random() < probability:
|
||||
delay = random.uniform(min_delay, max_delay)
|
||||
time.sleep(delay)
|
||||
|
||||
def simulate_typing(self, text: str, jitter_range: tuple[float, float] = (0.01, 0.05), batch_typing: bool = False) -> None:
|
||||
"""
|
||||
[C: simulation/workflow_sim.py:WorkflowSimulator.run_discussion_turn_async]
|
||||
"""
|
||||
if not self.enable_delays:
|
||||
return
|
||||
if batch_typing or self.batch_typing:
|
||||
@@ -50,8 +59,10 @@ class UserSimAgent:
|
||||
|
||||
def generate_response(self, conversation_history: list[dict]) -> str:
|
||||
"""
|
||||
Generates a human-like response based on the conversation history.
|
||||
conversation_history: list of dicts with 'role' and 'content'
|
||||
|
||||
Generates a human-like response based on the conversation history.
|
||||
conversation_history: list of dicts with 'role' and 'content'
|
||||
[C: simulation/workflow_sim.py:WorkflowSimulator.run_discussion_turn_async]
|
||||
"""
|
||||
last_ai_msg = ""
|
||||
for entry in reversed(conversation_history):
|
||||
@@ -67,9 +78,11 @@ class UserSimAgent:
|
||||
|
||||
def perform_action_with_delay(self, action_func: Callable, *args: Any, **kwargs: Any) -> Any:
|
||||
"""
|
||||
Executes an action with a human-like delay if enabled.
|
||||
|
||||
Executes an action with a human-like delay if enabled.
|
||||
[C: tests/test_user_agent.py:test_perform_action_with_delay]
|
||||
"""
|
||||
if self.enable_delays:
|
||||
delay = random.uniform(0.5, 2.0)
|
||||
time.sleep(delay)
|
||||
return action_func(*args, **kwargs)
|
||||
return action_func(*args, **kwargs)
|
||||
@@ -49,6 +49,9 @@ class WorkflowSimulator:
|
||||
self.user_agent = UserSimAgent(hook_client)
|
||||
|
||||
def setup_new_project(self, name: str, git_dir: str, project_path: str = None) -> None:
|
||||
"""
|
||||
[C: tests/test_workflow_sim.py:test_setup_new_project]
|
||||
"""
|
||||
print(f"Setting up new project: {name}")
|
||||
if project_path:
|
||||
self.client.click("btn_project_new_automated", user_data=project_path)
|
||||
@@ -62,6 +65,9 @@ class WorkflowSimulator:
|
||||
self.client.set_value("auto_add_history", True)
|
||||
|
||||
def create_discussion(self, name: str) -> None:
|
||||
"""
|
||||
[C: tests/test_workflow_sim.py:test_discussion_switching]
|
||||
"""
|
||||
print(f"Creating discussion: {name}")
|
||||
self.client.set_value("disc_new_name_input", name)
|
||||
self.client.click("btn_disc_create")
|
||||
@@ -69,6 +75,9 @@ class WorkflowSimulator:
|
||||
time.sleep(2)
|
||||
|
||||
def switch_discussion(self, name: str) -> None:
|
||||
"""
|
||||
[C: tests/test_workflow_sim.py:test_discussion_switching]
|
||||
"""
|
||||
print(f"Switching to discussion: {name}")
|
||||
self.client.select_list_item("disc_listbox", name)
|
||||
time.sleep(1)
|
||||
@@ -81,6 +90,9 @@ class WorkflowSimulator:
|
||||
time.sleep(1)
|
||||
|
||||
def truncate_history(self, pairs: int) -> None:
|
||||
"""
|
||||
[C: tests/test_workflow_sim.py:test_history_truncation]
|
||||
"""
|
||||
print(f"Truncating history to {pairs} pairs")
|
||||
self.client.set_value("disc_truncate_pairs", pairs)
|
||||
self.client.click("btn_disc_truncate")
|
||||
@@ -185,4 +197,4 @@ class WorkflowSimulator:
|
||||
print("\nTimeout waiting for AI")
|
||||
active_disc = self.client.get_value("active_discussion")
|
||||
print(f"[DEBUG] Active discussion in GUI at timeout: {active_disc}")
|
||||
return None
|
||||
return None
|
||||
Reference in New Issue
Block a user