Private
Public Access
0
0

fix(type_aliases): point ToolCall alias to openai_schemas.ToolCall, remove duplicate FileItem

src/type_aliases.py had two exact anti-patterns the user flagged:

1. Line 91: 'ToolCall: TypeAlias = Metadata' -- the dict alias the user
   called out as 'the exact bad pattern'. Now points to the canonical
   @dataclass(frozen=True, slots=True) class ToolCall in openai_schemas.py.

2. Lines 53-69: duplicate FileItem dataclass with 8 fields (path, content,
   view_mode, summary, skeleton, annotations, tags) that conflicted with
   the canonical models.FileItem (10 fields: path, auto_aggregate,
   force_full, view_mode, selected, ast_signatures, ast_definitions,
   ast_mask, custom_slices, injected_at). Two FileItem types was the
   'FileItem is duplicated in TWO places' blocker. Duplicate removed;
   FileItem now aliases models.FileItem.

state.toml updated to honest state: status='active', current_phase=0,
phases 2-10 marked 'not_done', 3 of 5 blockers fixed in this commit,
2 blockers (RAG return type, tool builders dicts) remain open with
followup tracks planned.

The 5 files that import ToolCall from src.type_aliases
(aggregate/ai_client/api_hook_client/app_controller/models) only use it
as a type annotation -- no constructor calls, no .from_dict() calls.
Safe to fix the alias.
This commit is contained in:
2026-06-25 19:24:42 -04:00
parent bd299f089b
commit b4bd772d67
2 changed files with 77 additions and 90 deletions
+2 -20
View File
@@ -50,25 +50,7 @@ class HistoryMessage:
History: TypeAlias = list[HistoryMessage]
@dataclass(frozen=True)
class FileItem:
path: str = ""
content: str = ""
view_mode: str = "full"
summary: str = ""
skeleton: str = ""
annotations: Metadata = field(default_factory=dict)
tags: list = field(default_factory=list)
def to_dict(self) -> Metadata:
return {f.name: getattr(self, f.name) for f in dc_fields(self)}
@classmethod
def from_dict(cls, data: Metadata) -> "FileItem":
valid = {f.name for f in dc_fields(cls)}
return cls(**{k: v for k, v in data.items() if k in valid})
FileItem: TypeAlias = "models.FileItem"
FileItems: TypeAlias = list[FileItem]
@@ -88,7 +70,7 @@ class ToolDefinition:
return cls(**{k: v for k, v in data.items() if k in valid})
ToolCall: TypeAlias = Metadata
ToolCall: TypeAlias = "openai_schemas.ToolCall"
@dataclass(frozen=True)