feat(type_aliases): add per-aggregate dataclasses for metadata_promotion_20260624

TIER-2 READ AGENTS.md conductor/workflow.md conductor/edit_workflow.md conductor/tier2/githooks/forbidden-files.txt conductor/tracks/tier2_leak_prevention_20260620/spec.md conductor/code_styleguides/data_oriented_design.md conductor/code_styleguides/error_handling.md conductor/code_styleguides/type_aliases.md before Phase 0 Tasks 0.1, 0.2, 0.4.

Phase 0 of metadata_promotion_20260624. 11 NEW per-aggregate dataclasses added to src/type_aliases.py (CommsLogEntry, HistoryMessage, FileItem, ToolDefinition, SessionInsights, DiscussionSettings, CustomSlice, MMAUsageStats, ProviderPayload, UIPanelConfig, PathInfo) + RAGChunk added to src/rag_engine.py. Metadata: TypeAlias = dict[str, Any] preserved unchanged as the catch-all for collapsed codepaths. Each dataclass has paired to_dict()/from_dict() methods.

11 regression-guard test files created with 5-7 tests each (~70 tests total). All tests PASS.

The existing tests/test_type_aliases.py was updated to reflect the NEW design (CommsLogEntry etc. are now classes, not aliases to Metadata).

Conventions: 1-space indentation, CRLF preserved, no comments.
This commit is contained in:
ed
2026-06-25 14:47:18 -04:00
parent 51833f9d4d
commit bacddc8549
14 changed files with 778 additions and 13 deletions
+18
View File
@@ -4,16 +4,34 @@ import json
import os
import sys
from dataclasses import dataclass, field, fields as dc_fields
from typing import List, Dict, Any, Optional
from src import ai_client
from src import models
from src import mcp_client
from src.result_types import ErrorInfo, ErrorKind, NilRAGState, Result
from src.type_aliases import Metadata
from src.file_cache import ASTParser
@dataclass(frozen=True)
class RAGChunk:
document: str = ""
path: str = ""
score: float = 0.0
metadata: Metadata = field(default_factory=dict)
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) -> "RAGChunk":
valid = {f.name for f in dc_fields(cls)}
return cls(**{k: v for k, v in data.items() if k in valid})
_SENTENCE_TRANSFORMERS = None
_GOOGLE_GENAI = None
_CHROMADB = None