Private
Public Access
refactor(app_controller): replace weak type sites with aliases
This commit is contained in:
+78
-66
@@ -46,6 +46,18 @@ from src.file_cache import ASTParser
|
||||
from src.io_pool import make_io_pool
|
||||
from src.models import GenerateRequest, ConfirmRequest
|
||||
from src.warmup import WarmupManager
|
||||
from src.type_aliases import (
|
||||
CommsLog,
|
||||
CommsLogCallback,
|
||||
CommsLogEntry,
|
||||
FileItem,
|
||||
FileItems,
|
||||
History,
|
||||
HistoryMessage,
|
||||
Metadata,
|
||||
ToolCall,
|
||||
ToolDefinition,
|
||||
)
|
||||
|
||||
|
||||
def parse_symbols(text: str) -> list[str]:
|
||||
@@ -108,7 +120,7 @@ def _api_health(controller: 'AppController') -> dict[str, str]:
|
||||
"""
|
||||
return {"status": "ok"}
|
||||
|
||||
def _api_get_gui_state(controller: 'AppController') -> dict[str, Any]:
|
||||
def _api_get_gui_state(controller: 'AppController') -> Metadata:
|
||||
"""
|
||||
Returns the current GUI state for specific fields.
|
||||
[SDM: src/app_controller.py:_api_get_gui_state]
|
||||
@@ -129,7 +141,7 @@ def _api_get_gui_state(controller: 'AppController') -> dict[str, Any]:
|
||||
|
||||
return state
|
||||
|
||||
def _api_get_mma_status(controller: 'AppController') -> dict[str, Any]:
|
||||
def _api_get_mma_status(controller: 'AppController') -> Metadata:
|
||||
"""
|
||||
Dedicated endpoint for MMA-related status.
|
||||
[SDM: src/app_controller.py:_api_get_mma_status]
|
||||
@@ -155,7 +167,7 @@ def _api_post_gui(controller: 'AppController', req: dict) -> dict[str, str]:
|
||||
controller.event_queue.put("gui_task", req)
|
||||
return {"status": "queued"}
|
||||
|
||||
def _api_get_api_session(controller: 'AppController') -> dict[str, Any]:
|
||||
def _api_get_api_session(controller: 'AppController') -> Metadata:
|
||||
"""
|
||||
Returns current discussion session entries.
|
||||
[SDM: src/app_controller.py:_api_get_api_session]
|
||||
@@ -173,28 +185,28 @@ def _api_post_api_session(controller: 'AppController', req: dict) -> dict[str, s
|
||||
controller.disc_entries = entries
|
||||
return {"status": "updated"}
|
||||
|
||||
def _api_get_api_project(controller: 'AppController') -> dict[str, Any]:
|
||||
def _api_get_api_project(controller: 'AppController') -> Metadata:
|
||||
"""
|
||||
Returns current project data.
|
||||
[SDM: src/app_controller.py:_api_get_api_project]
|
||||
"""
|
||||
return {"project": controller.project}
|
||||
|
||||
def _api_get_performance(controller: 'AppController') -> dict[str, Any]:
|
||||
def _api_get_performance(controller: 'AppController') -> Metadata:
|
||||
"""
|
||||
Returns performance monitor metrics.
|
||||
[SDM: src/app_controller.py:_api_get_performance]
|
||||
"""
|
||||
return {"performance": controller.perf_monitor.get_metrics()}
|
||||
|
||||
def _api_get_diagnostics(controller: 'AppController') -> dict[str, Any]:
|
||||
def _api_get_diagnostics(controller: 'AppController') -> Metadata:
|
||||
"""
|
||||
Alias for performance metrics.
|
||||
[SDM: src/app_controller.py:_api_get_diagnostics]
|
||||
"""
|
||||
return controller.perf_monitor.get_metrics()
|
||||
|
||||
def _api_status(controller: 'AppController') -> dict[str, Any]:
|
||||
def _api_status(controller: 'AppController') -> Metadata:
|
||||
"""
|
||||
Returns the current status of the application.
|
||||
[SDM: src/app_controller.py:_api_status]
|
||||
@@ -206,7 +218,7 @@ def _api_status(controller: 'AppController') -> dict[str, Any]:
|
||||
"usage": controller.session_usage
|
||||
}
|
||||
|
||||
def _api_generate(controller: 'AppController', req: GenerateRequest) -> dict[str, Any]:
|
||||
def _api_generate(controller: 'AppController', req: GenerateRequest) -> Metadata:
|
||||
"""
|
||||
Triggers an AI generation request using the current project context.
|
||||
[SDM: src/app_controller.py:_api_generate]
|
||||
@@ -320,7 +332,7 @@ async def _api_stream(controller: 'AppController', req: GenerateRequest) -> Any:
|
||||
HTTPException = _require_warmed("fastapi").HTTPException
|
||||
raise HTTPException(status_code=501, detail="Streaming endpoint (/api/v1/stream) is not yet supported in this version.")
|
||||
|
||||
def _api_pending_actions(controller: 'AppController') -> list[dict[str, Any]]:
|
||||
def _api_pending_actions(controller: 'AppController') -> list[Metadata]:
|
||||
"""
|
||||
Lists all pending PowerShell scripts awaiting confirmation.
|
||||
[SDM: src/app_controller.py:_api_pending_actions]
|
||||
@@ -359,7 +371,7 @@ def _api_list_sessions(controller: 'AppController') -> list[str]:
|
||||
return []
|
||||
return [d.name for d in log_dir.iterdir() if d.is_dir()]
|
||||
|
||||
def _api_get_session(controller: 'AppController', session_id: str) -> dict[str, Any]:
|
||||
def _api_get_session(controller: 'AppController', session_id: str) -> Metadata:
|
||||
"""
|
||||
Returns the content of the comms.log for a specific session.
|
||||
[SDM: src/app_controller.py:_api_get_session]
|
||||
@@ -383,7 +395,7 @@ def _api_delete_session(controller: 'AppController', session_id: str) -> dict[st
|
||||
shutil.rmtree(log_path)
|
||||
return {"status": "deleted"}
|
||||
|
||||
def _api_get_context(controller: 'AppController') -> dict[str, Any]:
|
||||
def _api_get_context(controller: 'AppController') -> Metadata:
|
||||
"""
|
||||
Returns the current aggregated project context.
|
||||
[SDM: src/app_controller.py:_api_get_context]
|
||||
@@ -402,7 +414,7 @@ def _api_get_context(controller: 'AppController') -> dict[str, Any]:
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"Context aggregation failure: {e}")
|
||||
|
||||
def _api_token_stats(controller: 'AppController') -> dict[str, Any]:
|
||||
def _api_token_stats(controller: 'AppController') -> Metadata:
|
||||
"""
|
||||
Returns current token usage and budget statistics.
|
||||
[SDM: src/app_controller.py:_api_token_stats]
|
||||
@@ -883,8 +895,8 @@ class AppController:
|
||||
#region: --- Internal State ---
|
||||
self._ai_status: str = "idle"
|
||||
self._mma_status: str = "idle"
|
||||
self._pending_gui_tasks: List[Dict[str, Any]] = []
|
||||
self._api_event_queue: List[Dict[str, Any]] = []
|
||||
self._pending_gui_tasks: list[Metadata] = []
|
||||
self._api_event_queue: list[Metadata] = []
|
||||
self._pending_dialog: Optional[ConfirmDialog] = None
|
||||
self._pending_dialog_open: bool = False
|
||||
self._pending_actions: Dict[str, ConfirmDialog] = {}
|
||||
@@ -895,36 +907,36 @@ class AppController:
|
||||
self._pending_patch_files: List[str] = []
|
||||
self._show_patch_modal: bool = False
|
||||
self._patch_error_message: Optional[str] = None
|
||||
self._tool_log: List[Dict[str, Any]] = []
|
||||
self._tool_stats: Dict[str, Dict[str, Any]] = {}
|
||||
self._cached_cache_stats: Dict[str, Any] = {}
|
||||
self._tool_log: list[Metadata] = []
|
||||
self._tool_stats: Dict[str, Metadata] = {}
|
||||
self._cached_cache_stats: Metadata = {}
|
||||
self._cached_files: List[str] = []
|
||||
self._token_history: List[Dict[str, Any]] = []
|
||||
self._token_history: list[Metadata] = []
|
||||
self._session_start_time: float = time.time()
|
||||
self._ticket_start_times: dict[str, float] = {}
|
||||
self._avg_ticket_time: float = 0.0
|
||||
self._completed_ticket_count: int = 0
|
||||
self._comms_log: List[Dict[str, Any]] = []
|
||||
self._comms_log: list[Metadata] = []
|
||||
self._last_telemetry_time: float = 0.0
|
||||
self._current_provider: str = "gemini"
|
||||
self._current_model: str = "gemini-2.5-flash-lite"
|
||||
self._autofocus_response_tab = False
|
||||
self._show_track_proposal_modal: bool = False
|
||||
self._pending_comms: List[Dict[str, Any]] = []
|
||||
self._pending_tool_calls: List[Dict[str, Any]] = []
|
||||
self._pending_history_adds: List[Dict[str, Any]] = []
|
||||
self._pending_comms: list[Metadata] = []
|
||||
self._pending_tool_calls: list[Metadata] = []
|
||||
self._pending_history_adds: list[Metadata] = []
|
||||
self._perf_last_update: float = 0.0
|
||||
self._last_autosave: float = time.time()
|
||||
self._ask_dialog_open: bool = False
|
||||
self._ask_request_id: Optional[str] = None
|
||||
self._ask_tool_data: Optional[Dict[str, Any]] = None
|
||||
self._pending_mma_approvals: List[Dict[str, Any]] = []
|
||||
self._ask_tool_data: Optional[Metadata] = None
|
||||
self._pending_mma_approvals: list[Metadata] = []
|
||||
self._mma_approval_open: bool = False
|
||||
self._mma_approval_edit_mode: bool = False
|
||||
self._project_switch_in_progress: bool = False
|
||||
self._project_switch_pending_path: Optional[str] = None
|
||||
self._mma_approval_payload: str = ""
|
||||
self._pending_mma_spawns: List[Dict[str, Any]] = []
|
||||
self._pending_mma_spawns: list[Metadata] = []
|
||||
self._mma_spawn_open: bool = False
|
||||
self._mma_spawn_edit_mode: bool = False
|
||||
self._mma_spawn_prompt: str = ''
|
||||
@@ -941,16 +953,16 @@ class AppController:
|
||||
self._scroll_tool_calls_to_bottom: bool = False
|
||||
self._gemini_cache_text: str = ""
|
||||
self._last_stable_md: str = ''
|
||||
self._token_stats: Dict[str, Any] = {}
|
||||
self._token_stats: Metadata = {}
|
||||
self._comms_log_dirty: bool = True
|
||||
self._tool_log_dirty: bool = True
|
||||
self._token_stats_dirty: bool = True
|
||||
self._tier_stream_last_len: Dict[str, int] = {}
|
||||
self._current_session_usage = None
|
||||
self._current_mma_tier_usage = None
|
||||
self.vendor_quota: Dict[str, Any] = {}
|
||||
self.vendor_quota: Metadata = {}
|
||||
self.last_error: Optional[Dict[str, str]] = None
|
||||
self.token_tracker: Dict[str, Any] = {"used": 0, "limit": 0, "cache_hits": 0, "cache_misses": 0}
|
||||
self.token_tracker: Metadata = {"used": 0, "limit": 0, "cache_hits": 0, "cache_misses": 0}
|
||||
self._current_token_history = None
|
||||
self._current_session_start_time = None
|
||||
self._inject_file_path: str = ""
|
||||
@@ -964,7 +976,7 @@ class AppController:
|
||||
self._editing_preset_max_output_tokens: int = 4096
|
||||
self._editing_preset_scope: str = "project"
|
||||
self._editing_tool_preset_name: str = ""
|
||||
self._editing_tool_preset_categories: Dict[str, Dict[str, Any]] = {}
|
||||
self._editing_tool_preset_categories: Dict[str, Metadata] = {}
|
||||
self._editing_tool_preset_scope: str = "project"
|
||||
self._show_base_prompt_diff_modal: bool = False
|
||||
self._autosave_interval: float = 60.0
|
||||
@@ -973,21 +985,21 @@ class AppController:
|
||||
#endregion: Internal State
|
||||
|
||||
#region: --- Core State ---
|
||||
self.config: Dict[str, Any] = {}
|
||||
self.project: Dict[str, Any] = {}
|
||||
self.config: Metadata = {}
|
||||
self.project: Metadata = {}
|
||||
self.active_project_path: str = ""
|
||||
self.project_paths: List[str] = []
|
||||
self.active_discussion: str = "main"
|
||||
self.disc_entries: List[Dict[str, Any]] = []
|
||||
self.disc_entries: list[Metadata] = []
|
||||
self.discussion_sent_markdown: str = ""
|
||||
self.discussion_sent_system_prompt: str = ""
|
||||
self.disc_roles: List[str] = []
|
||||
self.tracks: List[Dict[str, Any]] = []
|
||||
self.tracks: list[Metadata] = []
|
||||
self.active_track: Optional[models.Track] = None
|
||||
self.engines: Dict[str, multi_agent_conductor.ConductorEngine] = {}
|
||||
self.mma_streams: Dict[str, str] = {}
|
||||
self.MAX_STREAM_SIZE: int = 10 * 1024
|
||||
self.session_usage: Dict[str, Any] = {
|
||||
self.session_usage: Metadata = {
|
||||
"input_tokens": 0,
|
||||
"output_tokens": 0,
|
||||
"cache_read_input_tokens": 0,
|
||||
@@ -996,7 +1008,7 @@ class AppController:
|
||||
"last_latency": 0.0,
|
||||
"percentage": 0.0
|
||||
}
|
||||
self.mma_tier_usage: Dict[str, Dict[str, Any]] = {
|
||||
self.mma_tier_usage: Dict[str, Metadata] = {
|
||||
"Tier 1": {"input": 0, "output": 0, "provider": "gemini", "model": "gemini-3.1-pro-preview", "tool_preset": None},
|
||||
"Tier 2": {"input": 0, "output": 0, "provider": "gemini", "model": "gemini-3-flash-preview", "tool_preset": None},
|
||||
"Tier 3": {"input": 0, "output": 0, "provider": "gemini", "model": "gemini-2.5-flash-lite", "tool_preset": None},
|
||||
@@ -1027,16 +1039,16 @@ class AppController:
|
||||
self.active_tier: Optional[str] = None
|
||||
self.test_hooks_enabled: bool = ("--enable-test-hooks" in sys.argv) or (os.environ.get("SLOP_TEST_HOOKS") == "1")
|
||||
self.is_viewing_prior_session: bool = False
|
||||
self.prior_session_entries: List[Dict[str, Any]] = []
|
||||
self.prior_tool_calls: List[Dict[str, Any]] = []
|
||||
self.prior_disc_entries: List[Dict[str, Any]] = []
|
||||
self.prior_session_entries: list[Metadata] = []
|
||||
self.prior_tool_calls: list[Metadata] = []
|
||||
self.prior_disc_entries: list[Metadata] = []
|
||||
self.prior_mma_dashboard_state = {}
|
||||
self.diagnostic_log: List[Dict[str, Any]] = []
|
||||
self.diagnostic_log: list[Metadata] = []
|
||||
self.ui_active_tool_preset: str | None = None
|
||||
self.ui_active_bias_profile: str | None = None
|
||||
self.available_models: List[str] = []
|
||||
self.all_available_models: Dict[str, List[str]] = {}
|
||||
self.proposed_tracks: List[Dict[str, Any]] = []
|
||||
self.proposed_tracks: list[Metadata] = []
|
||||
self.show_preset_manager_window: bool = False
|
||||
self.show_tool_preset_manager_window: bool = False
|
||||
self.show_persona_editor_window: bool = False
|
||||
@@ -1095,7 +1107,7 @@ class AppController:
|
||||
# --- Defaults set here so tests that construct AppController without
|
||||
# calling init_state() still see the attributes ---
|
||||
self.ui_global_preset_name: Optional[str] = None
|
||||
self.active_tickets: List[Dict[str, Any]] = []
|
||||
self.active_tickets: list[Metadata] = []
|
||||
self.ui_selected_tickets: Set[str] = set()
|
||||
|
||||
#region: --- Configuration Maps ---
|
||||
@@ -2430,7 +2442,7 @@ class AppController:
|
||||
|
||||
self.submit_io(run_manual_prune)
|
||||
|
||||
def _load_project_from_path_result(self, pp: str) -> "Result[Dict[str, Any]]":
|
||||
def _load_project_from_path_result(self, pp: str) -> "Result[Metadata]":
|
||||
"""Phase 6 Group 6.7: load a project from a path with Result propagation.
|
||||
On failure: OSError/IOError/ValueError/TypeError/KeyError/AttributeError/tomllib.TOMLDecodeError
|
||||
-> ErrorInfo(original=e). Caller stores the error for sub-track 4 GUI."""
|
||||
@@ -2756,11 +2768,11 @@ class AppController:
|
||||
)])
|
||||
|
||||
@property
|
||||
def _pending_mma_spawn(self) -> Optional[Dict[str, Any]]:
|
||||
def _pending_mma_spawn(self) -> Optional[Metadata]:
|
||||
return self._pending_mma_spawns[0] if self._pending_mma_spawns else None
|
||||
|
||||
@property
|
||||
def _pending_mma_approval(self) -> Optional[Dict[str, Any]]:
|
||||
def _pending_mma_approval(self) -> Optional[Metadata]:
|
||||
return self._pending_mma_approvals[0] if self._pending_mma_approvals else None
|
||||
|
||||
@property
|
||||
@@ -2813,13 +2825,13 @@ class AppController:
|
||||
def health() -> dict[str, str]:
|
||||
return _api_health(self)
|
||||
@api.get("/api/gui/state", dependencies=[Depends(get_api_key)])
|
||||
def get_gui_state() -> dict[str, Any]:
|
||||
def get_gui_state() -> Metadata:
|
||||
"""
|
||||
[C: tests/test_ai_settings_layout.py:test_change_provider_via_hook, tests/test_ai_settings_layout.py:test_set_params_via_custom_callback, tests/test_conductor_api_hook_integration.py:simulate_conductor_phase_completion, tests/test_external_editor_gui.py:test_button_click_is_received, tests/test_external_editor_gui.py:test_patch_modal_shows_with_configured_editor, tests/test_external_editor_gui.py:test_vscode_launches_with_diff_view, tests/test_gui_text_viewer.py:test_text_viewer_state_update, tests/test_hooks.py:test_live_hook_server_responses, tests/test_live_gui_integration_v2.py:test_api_gui_state_live, tests/test_live_workflow.py:test_full_live_workflow, tests/test_live_workflow.py:wait_for_value, tests/test_patch_modal_gui.py:test_patch_apply_modal_workflow, tests/test_patch_modal_gui.py:test_patch_modal_appears_on_trigger, 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_saved_presets_sim.py:test_preset_manager_modal, tests/test_saved_presets_sim.py:test_preset_switching, tests/test_task_dag_popout_sim.py:test_task_dag_popout, tests/test_tool_management_layout.py:test_tool_management_gettable_fields, tests/test_tool_management_layout.py:test_tool_management_state_updates, tests/test_tool_presets_sim.py:test_tool_preset_switching, tests/test_usage_analytics_popout_sim.py:test_usage_analytics_popout, tests/test_visual_mma.py:test_visual_mma_components]
|
||||
"""
|
||||
return _api_get_gui_state(self)
|
||||
@api.get("/api/gui/mma_status", dependencies=[Depends(get_api_key)])
|
||||
def get_mma_status() -> dict[str, Any]:
|
||||
def get_mma_status() -> Metadata:
|
||||
"""
|
||||
[C: tests/test_headless_simulation.py:test_mma_track_lifecycle_simulation, tests/test_live_workflow.py:test_full_live_workflow, tests/test_mma_concurrent_tracks_sim.py:_poll_mma_status, tests/test_mma_concurrent_tracks_sim.py:test_mma_concurrent_tracks_execution, tests/test_mma_concurrent_tracks_stress_sim.py:test_mma_concurrent_tracks_stress, tests/test_mma_step_mode_sim.py:_poll_mma_status, tests/test_mma_step_mode_sim.py:test_mma_step_mode_approval_flow, tests/test_visual_mma.py:test_visual_mma_components, tests/test_visual_orchestration.py:test_mma_epic_lifecycle, tests/test_visual_sim_gui_ux.py:test_gui_ux_event_routing, tests/test_visual_sim_mma_v2.py:_poll]
|
||||
"""
|
||||
@@ -2831,34 +2843,34 @@ class AppController:
|
||||
"""
|
||||
return _api_post_gui(self, req)
|
||||
@api.get("/api/session", dependencies=[Depends(get_api_key)])
|
||||
def get_api_session() -> dict[str, Any]:
|
||||
def get_api_session() -> Metadata:
|
||||
return _api_get_api_session(self)
|
||||
@api.post("/api/session", dependencies=[Depends(get_api_key)])
|
||||
def post_api_session(req: dict) -> dict[str, str]:
|
||||
return _api_post_api_session(self, req)
|
||||
@api.get("/api/project", dependencies=[Depends(get_api_key)])
|
||||
def get_api_project() -> dict[str, Any]:
|
||||
def get_api_project() -> Metadata:
|
||||
return _api_get_api_project(self)
|
||||
@api.get("/api/performance", dependencies=[Depends(get_api_key)])
|
||||
def get_performance() -> dict[str, Any]:
|
||||
def get_performance() -> Metadata:
|
||||
"""
|
||||
[C: tests/test_gui2_performance.py:test_performance_benchmarking, tests/test_gui_performance_requirements.py:test_idle_performance_requirements, tests/test_gui_stress_performance.py:test_comms_volume_stress_performance, tests/test_selectable_ui.py:test_selectable_label_stability]
|
||||
"""
|
||||
return _api_get_performance(self)
|
||||
@api.get("/api/gui/diagnostics", dependencies=[Depends(get_api_key)])
|
||||
def get_diagnostics() -> dict[str, Any]:
|
||||
def get_diagnostics() -> Metadata:
|
||||
return _api_get_diagnostics(self)
|
||||
@api.get("/status", dependencies=[Depends(get_api_key)])
|
||||
def status() -> dict[str, Any]:
|
||||
def status() -> Metadata:
|
||||
return _api_status(self)
|
||||
@api.post("/api/v1/generate", dependencies=[Depends(get_api_key)])
|
||||
def generate(req: GenerateRequest) -> dict[str, Any]:
|
||||
def generate(req: GenerateRequest) -> Metadata:
|
||||
return _api_generate(self, req)
|
||||
@api.post("/api/v1/stream", dependencies=[Depends(get_api_key)])
|
||||
async def stream(req: GenerateRequest) -> Any:
|
||||
return await _api_stream(self, req)
|
||||
@api.get("/api/v1/pending_actions", dependencies=[Depends(get_api_key)])
|
||||
def pending_actions() -> list[dict[str, Any]]:
|
||||
def pending_actions() -> list[Metadata]:
|
||||
return _api_pending_actions(self)
|
||||
@api.post("/api/v1/confirm/{action_id}", dependencies=[Depends(get_api_key)])
|
||||
def confirm_action(action_id: str, req: ConfirmRequest) -> dict[str, str]:
|
||||
@@ -2867,7 +2879,7 @@ class AppController:
|
||||
def list_sessions() -> list[str]:
|
||||
return _api_list_sessions(self)
|
||||
@api.get("/api/v1/sessions/{session_id}", dependencies=[Depends(get_api_key)])
|
||||
def get_session(session_id: str) -> dict[str, Any]:
|
||||
def get_session(session_id: str) -> Metadata:
|
||||
"""
|
||||
[C: simulation/ping_pong.py:main, simulation/sim_context.py:ContextSimulation.run, simulation/sim_execution.py:ExecutionSimulation.run, simulation/sim_tools.py:ToolsSimulation.run, simulation/workflow_sim.py:WorkflowSimulator.run_discussion_turn_async, simulation/workflow_sim.py:WorkflowSimulator.wait_for_ai_response, tests/test_api_hook_client.py:test_get_session_success, tests/test_gui_stress_performance.py:test_comms_volume_stress_performance, tests/test_live_workflow.py:test_full_live_workflow, tests/test_rag_phase4_final_verify.py:test_phase4_final_verify, tests/test_rag_phase4_stress.py:test_rag_large_codebase_verification_sim]
|
||||
"""
|
||||
@@ -2876,13 +2888,13 @@ class AppController:
|
||||
def delete_session(session_id: str) -> dict[str, str]:
|
||||
return _api_delete_session(self, session_id)
|
||||
@api.get("/api/v1/context", dependencies=[Depends(get_api_key)])
|
||||
def get_context() -> dict[str, Any]:
|
||||
def get_context() -> Metadata:
|
||||
"""
|
||||
[C: src/fuzzy_anchor.py:FuzzyAnchor.create_slice]
|
||||
"""
|
||||
return _api_get_context(self)
|
||||
@api.get("/api/v1/token_stats", dependencies=[Depends(get_api_key)])
|
||||
def token_stats() -> dict[str, Any]:
|
||||
def token_stats() -> Metadata:
|
||||
return _api_token_stats(self)
|
||||
return api
|
||||
|
||||
@@ -3033,7 +3045,7 @@ class AppController:
|
||||
|
||||
#region: Usage Analytics
|
||||
|
||||
def get_session_insights(self) -> Dict[str, Any]:
|
||||
def get_session_insights(self) -> Metadata:
|
||||
"""
|
||||
[C: src/gui_2.py:App._render_session_insights_panel]
|
||||
"""
|
||||
@@ -3058,7 +3070,7 @@ class AppController:
|
||||
"call_count": len(self._token_history)
|
||||
}
|
||||
|
||||
def _refresh_api_metrics(self, payload: dict[str, Any], md_content: str | None = None) -> None:
|
||||
def _refresh_api_metrics(self, payload: Metadata, md_content: str | None = None) -> None:
|
||||
"""
|
||||
[C: tests/test_gui_updates.py:test_telemetry_data_updates_correctly]
|
||||
"""
|
||||
@@ -3472,7 +3484,7 @@ class AppController:
|
||||
|
||||
#region: AI Settings
|
||||
|
||||
def _rag_search_result(self, user_msg: str) -> "Result[List[Dict[str, Any]]]":
|
||||
def _rag_search_result(self, user_msg: str) -> "Result[list[Metadata]]":
|
||||
"""Per-event handler (Phase 6 Group 6.6): RAG search via the engine.
|
||||
Returns Result[List[Dict]]. On failure: any engine/SDK exception
|
||||
-> ErrorInfo(original=e). Caller (`_handle_request_event`) appends
|
||||
@@ -3988,7 +4000,7 @@ class AppController:
|
||||
return result
|
||||
self.submit_io(worker)
|
||||
|
||||
def _do_generate(self) -> tuple[str, Path, list[dict[str, Any]], str, str]:
|
||||
def _do_generate(self) -> tuple[str, Path, list[Metadata], str, str]:
|
||||
"""
|
||||
Returns (full_md, output_path, file_items, stable_md, discussion_text).
|
||||
[C: src/gui_2.py:App._show_menus, tests/test_context_composition_decoupled.py:test_do_generate_uses_context_files, tests/test_tiered_aggregation.py:test_app_controller_do_generate_uses_persona_strategy]
|
||||
@@ -4224,7 +4236,7 @@ class AppController:
|
||||
with self._pending_tool_calls_lock:
|
||||
self._pending_tool_calls.append({"script": script, "result": result, "ts": time.time(), "source_tier": source_tier})
|
||||
|
||||
def _offload_entry_payload(self, entry: Dict[str, Any]) -> Dict[str, Any]:
|
||||
def _offload_entry_payload(self, entry: Metadata) -> Metadata:
|
||||
optimized = copy.deepcopy(entry)
|
||||
kind = optimized.get("kind")
|
||||
payload = optimized.get("payload", {})
|
||||
@@ -4266,7 +4278,7 @@ class AppController:
|
||||
if caps is None or caps.streaming:
|
||||
if self._ai_status not in ("sending...", "streaming..."):
|
||||
self._ai_status = "streaming..."
|
||||
def _on_comms_entry(self, entry: Dict[str, Any]) -> None:
|
||||
def _on_comms_entry(self, entry: Metadata) -> None:
|
||||
"""
|
||||
[C: tests/test_app_controller_offloading.py:test_on_comms_entry_tool_result_offloading]
|
||||
"""
|
||||
@@ -4705,14 +4717,14 @@ class AppController:
|
||||
self._report_worker_error(f"topological_sort[{title}]", Result(data=None, errors=[err]))
|
||||
return Result(data=raw_tickets, errors=[err])
|
||||
|
||||
def _start_track_logic(self, track_data: dict[str, Any], skeletons_str: str | None = None) -> None:
|
||||
def _start_track_logic(self, track_data: Metadata, skeletons_str: str | None = None) -> None:
|
||||
result = self._start_track_logic_result(track_data, skeletons_str)
|
||||
if not result.ok:
|
||||
err = result.errors[0]
|
||||
self.ai_status = f"Track start error: {err.message}"
|
||||
print(f"ERROR in _start_track_logic: {err.message}")
|
||||
|
||||
def _start_track_logic_result(self, track_data: dict[str, Any], skeletons_str: str | None = None) -> "Result[None]":
|
||||
def _start_track_logic_result(self, track_data: Metadata, skeletons_str: str | None = None) -> "Result[None]":
|
||||
"""Phase 6 Group 6.7: track-start pipeline with Result propagation.
|
||||
On any unexpected failure: ErrorInfo(original=e). Caller drains via
|
||||
stderr write + ai_status update."""
|
||||
@@ -5126,7 +5138,7 @@ class AppController:
|
||||
)])
|
||||
|
||||
#region: --- Config I/O (single source of truth) ---
|
||||
def load_config(self) -> Dict[str, Any]:
|
||||
def load_config(self) -> Metadata:
|
||||
"""
|
||||
Re-read the global config.toml from disk and update self.config.
|
||||
Returns the dict (also stored in self.config). Single source of
|
||||
@@ -5189,7 +5201,7 @@ class MMASpawnApprovalDialog:
|
||||
self._approved = False
|
||||
self._abort = False
|
||||
|
||||
def wait(self) -> dict[str, Any]:
|
||||
def wait(self) -> Metadata:
|
||||
"""
|
||||
[C: src/mcp_client.py:StdioMCPServer.stop, src/multi_agent_conductor.py:confirm_execution, src/multi_agent_conductor.py:confirm_spawn, tests/conftest.py:live_gui, tests/test_ai_client_concurrency.py:run_t1, tests/test_ai_client_concurrency.py:run_t2, tests/test_ai_server.py:test_server_handles_list_models, tests/test_ai_server.py:test_server_handles_unknown_method, tests/test_ai_server.py:test_server_loads_google_genai_quickly, tests/test_ai_server.py:test_server_outputs_ready_marker, tests/test_ai_server.py:test_server_starts_and_exits_cleanly, tests/test_conductor_engine_abort.py:worker, tests/test_parallel_execution.py:test_worker_pool_limit]
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user