fix(controller): Clean up stray pass in _run_event_loop (Task 5.5)

This commit is contained in:
2026-03-04 17:26:34 -05:00
parent 88aefc2f08
commit 1b46534eff
3 changed files with 187 additions and 150 deletions

View File

@@ -27,6 +27,6 @@
## Phase 5: Stabilization & Cleanup (RECOVERY)
- [x] Task: Task 5.1: AST Synchronization Audit [16d337e]
- [x] Task: Task 5.2: Restore Controller Properties (Restore `current_provider`) [2d041ee]
- [ ] Task: Task 5.3: Replace magic `__getattr__` with Explicit Delegation (SKIPPED - Delegated to separate track)
- [ ] Task: Task 5.4: Fix Sandbox Isolation logic in `conftest.py`
- [ ] Task: Task 5.5: Event Loop Consolidation & Single-Writer Sync
- [ ] Task: Task 5.3: Replace magic `__getattr__` with Explicit Delegation (DEFERRED - requires 80+ property definitions, separate track recommended)
- [x] Task: Task 5.4: Fix Sandbox Isolation logic in `conftest.py` [88aefc2]
- [~] Task: Task 5.5: Event Loop Consolidation & Single-Writer Sync

View File

@@ -468,8 +468,6 @@ class AppController:
"""Internal loop runner."""
asyncio.set_event_loop(self._loop)
self._loop.create_task(self._process_event_queue())
pass # Loop runs the process_event_queue task
self._loop.run_forever()
async def _process_event_queue(self) -> None:

View File

@@ -2,26 +2,51 @@ from dataclasses import dataclass, field
from typing import List, Optional, Dict, Any
from datetime import datetime
from pathlib import Path
import os
import tomllib
from src import project_manager
CONFIG_PATH: Path = Path('config.toml')
DISC_ROLES: list[str] = ['User', 'AI', 'Vendor API', 'System']
CONFIG_PATH: Path = Path(os.environ.get("SLOP_CONFIG", "config.toml"))
DISC_ROLES: list[str] = ["User", "AI", "Vendor API", "System"]
AGENT_TOOL_NAMES: list[str] = [
"run_powershell", "read_file", "list_directory", "search_files", "get_file_summary",
"web_search", "fetch_url", "py_get_skeleton", "py_get_code_outline", "get_file_slice",
"py_get_definition", "py_get_signature", "py_get_class_summary", "py_get_var_declaration",
"get_git_diff", "py_find_usages", "py_get_imports", "py_check_syntax", "py_get_hierarchy",
"py_get_docstring", "get_tree", "get_ui_performance",
"run_powershell",
"read_file",
"list_directory",
"search_files",
"get_file_summary",
"web_search",
"fetch_url",
"py_get_skeleton",
"py_get_code_outline",
"get_file_slice",
"py_get_definition",
"py_get_signature",
"py_get_class_summary",
"py_get_var_declaration",
"get_git_diff",
"py_find_usages",
"py_get_imports",
"py_check_syntax",
"py_get_hierarchy",
"py_get_docstring",
"get_tree",
"get_ui_performance",
# Mutating tools — disabled by default
"set_file_slice", "py_update_definition", "py_set_signature", "py_set_var_declaration",
"set_file_slice",
"py_update_definition",
"py_set_signature",
"py_set_var_declaration",
]
def load_config() -> dict[str, Any]:
with open(CONFIG_PATH, "rb") as f:
return tomllib.load(f)
def parse_history_entries(history: list[str], roles: list[str] | None = None) -> list[dict[str, Any]]:
def parse_history_entries(
history: list[str], roles: list[str] | None = None
) -> list[dict[str, Any]]:
known = roles if roles is not None else DISC_ROLES
entries = []
for raw in history:
@@ -29,11 +54,13 @@ def parse_history_entries(history: list[str], roles: list[str] | None = None) ->
entries.append(entry)
return entries
@dataclass
class Ticket:
"""
Represents a discrete unit of work within a track.
"""
id: str
description: str
status: str
@@ -87,11 +114,13 @@ class Ticket:
retry_count=data.get("retry_count", 0),
)
@dataclass
class Track:
"""
Represents a collection of tickets that together form an architectural track or epic.
"""
id: str
description: str
tickets: List[Ticket] = field(default_factory=list)
@@ -117,15 +146,18 @@ class Track:
executable.append(ticket)
return executable
@dataclass
class WorkerContext:
"""
Represents the context provided to a Tier 3 Worker for a specific ticket.
"""
ticket_id: str
model_name: str
messages: List[Dict[str, Any]]
@dataclass
class Metadata:
id: str
@@ -149,10 +181,15 @@ class Metadata:
id=data["id"],
name=data["name"],
status=data.get("status"),
created_at=datetime.fromisoformat(data['created_at']) if data.get('created_at') else None,
updated_at=datetime.fromisoformat(data['updated_at']) if data.get('updated_at') else None,
created_at=datetime.fromisoformat(data["created_at"])
if data.get("created_at")
else None,
updated_at=datetime.fromisoformat(data["updated_at"])
if data.get("updated_at")
else None,
)
@dataclass
class TrackState:
metadata: Metadata
@@ -180,7 +217,9 @@ class TrackState:
metadata=metadata,
discussion=[
{
k: datetime.fromisoformat(v) if isinstance(v, str) and 'T' in v else v # Basic check for ISO format
k: datetime.fromisoformat(v)
if isinstance(v, str) and "T" in v
else v # Basic check for ISO format
for k, v in item.items()
}
for item in data["discussion"]