66 lines
2.0 KiB
Python
66 lines
2.0 KiB
Python
"""Atomic semantic units for Super Big Brain: tokenless, addressable context."""
|
|
|
|
from enum import Enum
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class AtomicUnitType(str, Enum):
|
|
"""Type of atomic semantic unit."""
|
|
|
|
FACT = "fact"
|
|
INTENT = "intent"
|
|
ASSUMPTION = "assumption"
|
|
CONSTRAINT = "constraint"
|
|
RELATIONSHIP = "relationship"
|
|
QUESTION = "question"
|
|
|
|
|
|
class RelationType(str, Enum):
|
|
"""Type of relation between atomic units."""
|
|
|
|
CAUSAL = "causal"
|
|
TEMPORAL = "temporal"
|
|
LOGICAL = "logical"
|
|
ANALOGICAL = "analogical"
|
|
CONTRADICTS = "contradicts"
|
|
SUPPORTS = "supports"
|
|
|
|
|
|
class AtomicSemanticUnit(BaseModel):
|
|
"""Atomic semantic unit: irreducible fact, intent, assumption, or constraint."""
|
|
|
|
unit_id: str = Field(..., min_length=1, description="Unique identifier")
|
|
content: str = Field(..., min_length=1, description="Unit content")
|
|
type: AtomicUnitType = Field(..., description="Unit type")
|
|
confidence: float = Field(default=1.0, ge=0.0, le=1.0, description="Confidence in [0, 1]")
|
|
parent_id: str | None = Field(default=None, description="Parent unit in decomposition tree")
|
|
source_ref: str | None = Field(default=None, description="Source reference")
|
|
metadata: dict[str, Any] = Field(default_factory=dict)
|
|
|
|
|
|
class SemanticRelation(BaseModel):
|
|
"""Relation between two atomic semantic units."""
|
|
|
|
from_id: str = Field(..., min_length=1)
|
|
to_id: str = Field(..., min_length=1)
|
|
relation_type: RelationType = Field(...)
|
|
|
|
|
|
class DecompositionResult(BaseModel):
|
|
"""Result of recursive decomposition: atomic units and relations."""
|
|
|
|
units: list[AtomicSemanticUnit] = Field(default_factory=list)
|
|
relations: list[SemanticRelation] = Field(default_factory=list)
|
|
depth: int = Field(default=0, ge=0, description="Maximum decomposition depth")
|
|
|
|
|
|
__all__ = [
|
|
"AtomicUnitType",
|
|
"RelationType",
|
|
"AtomicSemanticUnit",
|
|
"SemanticRelation",
|
|
"DecompositionResult",
|
|
]
|