thought-engine-node / models.py
Kode-Animator's picture
feat: Phase 1 Sovereign Thought Substrate β€” C-THOUGHT-NODE-001
1fce18e
Raw
History Blame Contribute Delete
3.47 kB
"""
Thought Engine Node β€” Pydantic Models
======================================
Contract: C-THOUGHT-NODE-001 (Phase 1 Sovereign Substrate)
Request/Response shapes for the sovereign REST API.
"""
from pydantic import BaseModel, Field
from typing import Optional, List, Any
from enum import Enum
# ── Enums ──────────────────────────────────────────────────────
class ThoughtClass(str, Enum):
HYPOTHESIS = "hypothesis"
OBSERVATION = "observation"
VALIDATION = "validation"
COUNTER_ARGUMENT = "counter_argument"
SYNTHESIS = "synthesis"
DECISION = "decision"
QUESTION = "question"
PROPOSAL = "proposal"
class ThoughtStatus(str, Enum):
OPEN = "open"
PROPOSED = "proposed"
UNDER_REVIEW = "under_review"
ACCEPTED = "accepted"
REJECTED = "rejected"
MERGED = "merged"
SUPERSEDED = "superseded"
class EdgeRelation(str, Enum):
DERIVES_FROM = "derives_from"
SUPPORTS = "supports"
CHALLENGES = "challenges"
REFINES = "refines"
FORKS_FROM = "forks_from"
MERGES_INTO = "merges_into"
BUBBLES_FROM = "bubbles_from"
BUBBLES_INTO = "bubbles_into"
class ReviewAction(str, Enum):
PROPOSE = "propose"
ACCEPT = "accept"
REJECT = "reject"
SUPERSEDE = "supersede"
class SessionStatus(str, Enum):
ACTIVE = "active"
ARCHIVED = "archived"
MERGED = "merged"
# ── Request Bodies ─────────────────────────────────────────────
class CreateSessionReq(BaseModel):
title: Optional[str] = None
initial_thought: str
thought_class: ThoughtClass = ThoughtClass.OBSERVATION
agent_id: str = "system"
class AddThoughtReq(BaseModel):
content: str
thought_class: ThoughtClass = ThoughtClass.OBSERVATION
agent_id: str = "system"
parent_thought_id: Optional[str] = None
confidence: Optional[float] = None
class ForkThoughtReq(BaseModel):
source_thought_id: str
branch_label: str
agent_id: str = "system"
class CreateProposalReq(BaseModel):
parent_thought_id: str
content: str
note: str = ""
agent_id: str = "system"
class ReviewProposalReq(BaseModel):
action: ReviewAction
actor: str = "system"
reason: Optional[str] = None
class SearchReq(BaseModel):
pattern: str
# ── Response Bodies ────────────────────────────────────────────
class SessionInfo(BaseModel):
session_id: str
title: Optional[str]
created_by: str
created_at: str
status: str
root_thought_id: Optional[str]
active_thought_id: Optional[str]
class ThoughtInfo(BaseModel):
thought_id: str
session_id: str
content: str
thought_class: str
origin_agent: str
status: str
confidence: Optional[float]
created_at: str
class EdgeInfo(BaseModel):
edge_id: str
source_id: str
target_id: str
relation: str
class TreeNode(BaseModel):
thought_id: str
content: str
thought_class: str
status: str
origin_agent: str
children: List["TreeNode"] = []