""" Result dataclasses for probing operations. These structures capture what we learn about each term. """ from dataclasses import dataclass, field from typing import List, Optional, Literal from datetime import datetime from enum import Enum class EchoType(str, Enum): """Classification of echo probe responses.""" EXPANDS = "EXPANDS" # Real depth - adds new information CONFIRMS = "CONFIRMS" # Shallow but solid - reinforces without adding CIRCULAR = "CIRCULAR" # Surface only - returns to original term DIVERGENT = "DIVERGENT" # Wrong direction - unrelated tangent COLLAPSE = "COLLAPSE" # Nothing there - incoherent or empty class ReadinessLevel(str, Enum): """Readiness classification for curriculum design.""" HIGH = "HIGH" # Ready for state machine / direct training MEDIUM = "MEDIUM" # Needs scaffolding / bridging concepts LOW = "LOW" # Requires foundational work first @dataclass class SurfaceProbeResult: """Result from a surface probe (single word → completions).""" term: str completions: List[str] hit_eos_count: int # How many completions ended with EOS avg_tokens: float # Average completion length # Optional analysis coherence_score: Optional[float] = None # 0-1, how related are completions timestamp: datetime = field(default_factory=datetime.now) @dataclass class EchoProbeResult: """Result from an echo probe (iterative depth measurement).""" term: str rounds: int chain: List[str] # The sequence of prompts/completions echo_types: List[EchoType] # Classification of each round # Derived metrics depth: int = 0 # How many EXPANDS before plateau timestamp: datetime = field(default_factory=datetime.now) @dataclass class ReadinessResult: """Combined analysis for curriculum readiness.""" term: str level: ReadinessLevel action: str # Recommended curriculum action # Supporting evidence surface: Optional[SurfaceProbeResult] = None echo: Optional[EchoProbeResult] = None # Reasoning reasoning: str = "" timestamp: datetime = field(default_factory=datetime.now) def to_dict(self) -> dict: """Convert to JSON-serializable dict.""" return { "term": self.term, "readiness": { "level": self.level.value, "action": self.action, "reasoning": self.reasoning, }, "surface": { "completions": self.surface.completions if self.surface else [], "coherence": self.surface.coherence_score if self.surface else None, "hit_eos_count": self.surface.hit_eos_count if self.surface else 0, } if self.surface else None, "echo": { "depth": self.echo.depth if self.echo else 0, "types": [t.value for t in self.echo.echo_types] if self.echo else [], "chain": self.echo.chain if self.echo else [], } if self.echo else None, "timestamp": self.timestamp.isoformat(), }