Models & DTOs
Core Pydantic models used across the ChaosCypher library. These are pure data transfer objects with no ORM or framework dependencies.
chaoscypher_core.models
Core models for chaoscypher-engine.
Pure Pydantic models (no SQLModel coupling) for use across the engine. These models define the data structures for nodes, edges, templates, suggestions, and other entities.
class BatchEmbedResult
Result from LLMProvider.batch_embed().
Bases: BaseModel
Attributes:
embeddings:list[list[float]]failed:intmodel_configprovider:strtotal:int
class ChunkingResult
Result from Engine.chunk_document().
Contains metadata about the chunking operation including source ID
and chunk counts. Use the source_id to pass to subsequent pipeline
stages like engine.index_source() or engine.commit().
Bases: BaseModel
Attributes:
analysis_depth:strmodel_configsource_id:strtotal_groups:inttotal_small_chunks:int
class ChunksResult
Result from ChunkingService.create_chunks().
Contains the actual chunks and groups produced by the chunking service,
plus summary counts. Returned by ChunkingService.create_chunks() and
accepted by ChunkingService.store_chunks().
Bases: BaseModel
Attributes:
chunks_filtered:inthierarchical_groups:list[dict[str, Any]]model_configsmall_chunks:list[dict[str, Any]]total_groups:inttotal_original_chunks:inttotal_original_groups:inttotal_small_chunks:int
class DatabaseInfo
Database metadata.
Returned by DatabaseProtocol.get_database() and used across core, cortex, and CLI packages. Contains the union of fields needed by all consumers.
Bases: BaseModel
Methods:
from_path(name: str, path: str, app_db_filename: str = 'app.db') -> DatabaseInfo
Create DatabaseInfo from a database directory path.
Inspects the database file on disk to populate exists, size,
and last_modified.
Args: name: Database name. path: Path to the database directory. app_db_filename: Database filename inside the directory.
| Parameter | Type | Description |
|---|---|---|
name | str | |
path | str | |
app_db_filename | str |
Attributes:
created_at:datetime | Nonedescription:str | Noneexists:boollast_modified:datetime | Nonemodel_configname:strpath:strsize:int
class DatabaseStats
Database statistics returned by Engine.get_stats().
Bases: BaseModel
Attributes:
data_dir:strdatabase_name:stredges:intmodel_confignodes:inttemplates:int
class Edge
Graph edge (relationship) - complete version for engine use.
Includes all fields needed by GraphRepository including timestamps.
Bases: BaseModel
Attributes:
created_at:datetimeid:strlabel:strmodel_configproperties:dict[str, Any]source_node_id:strtarget_node_id:strtemplate_id:strupdated_at:datetime
class EdgeCreate
Edge creation data.
Used when creating new edges via GraphRepository.create_edge()
Bases: BaseModel
Attributes:
label:strmodel_configproperties:dict[str, Any]source_id:str | Nonesource_node_id:strtarget_node_id:strtemplate_id:str
class EdgeUpdate
Edge update data.
Used when updating existing edges via GraphRepository.update_edge() All fields are optional - only provided fields will be updated.
Bases: BaseModel
Attributes:
label:str | Nonemodel_configproperties:dict[str, Any] | None
class EdgeWithNodes
Edge with hydrated source and target node objects.
Returned by GraphRepository.list_edges(with_nodes=True) to eliminate
the O(N) get_node()-in-a-loop antipattern. Both endpoint nodes are
batch-loaded in a single IN-query and attached here so callers can access
edge.source_node.label without issuing additional round trips.
Example::
edges = graph_repo.list_edges(with_nodes=True) for edge in edges: print(f"{edge.source_node.label} → {edge.target_node.label}")
Bases: Edge
Attributes:
model_configsource_node:Node | Nonetarget_node:Node | None
class EmbedResult
Result from LLMProvider.embed().
Bases: BaseModel
Attributes:
embedding:list[float]model_configprovider:strusage:TokenUsage | None
class EngineSearchResult
Individual search result from Engine.search().
Bases: BaseModel
Attributes:
content:str | Noneid:strlabel:strmodel_configresult_type:strscore:floatsnippet:str— Best text preview regardless of result type.
Returns content for chunks (with label fallback), label for nodes.
source:str | Nonetemplate_id:str | None
class ExtractionResult
Result from ChunkingService.process() standalone extraction.
Contains extracted entities, relationships, and domain detection metadata.
Use model_dump_json() for JSON output or attribute access for fields.
Example:
result = await ChunkingService().process(text) print(result.domain, result.domain_confidence) print(result.model_dump_json(indent=2))
Bases: BaseModel
Attributes:
cached_embeddings:list[Any]chunk_ids:list[list[str]]domain:strdomain_confidence:floatentities:list[dict[str, Any]]filtering_log:dict[str, Any] | Nonemodel_configrelationships:list[dict[str, Any]]
class HealthReport
Combined health report from LLMProvider.check_health().
Bases: BaseModel
Attributes:
chat:HealthResultmodel_config
class HealthResult
Health check result for a single provider.
Bases: BaseModel
Attributes:
embedding_dimensions:int | Noneerror:str | Nonemodel:str | Nonemodel_configprovider:str | Noneresponse_time_ms:int | Nonestatus:str
class IndexingResult
Result from Engine.index_source().
Bases: BaseModel
Attributes:
chunks_count:intembedding_dimensions:intembedding_model:strmodel_config
class LLMChatResponse
Response from LLMProvider.chat().
Bases: BaseModel
Attributes:
content:strinstance_id:str | Noneis_stream:boolmodel_configprovider:strstream:Any | Nonethinking:str | Nonetool_calls:list[dict[str, Any]] | Noneusage:TokenUsage | None
class Node
Graph node (entity) - complete version for engine use.
Includes all fields needed by GraphRepository including timestamps.
Bases: BaseModel
Attributes:
created_at:datetimeembedding:list[float] | Noneid:strlabel:strmodel_configposition:NodePosition | Noneproperties:dict[str, Any]source_id:str | Nonetemplate_id:strupdated_at:datetime
class NodeCreate
Node creation data.
Used when creating new nodes in the graph via GraphRepository.create_node()
Bases: BaseModel
Attributes:
embedding:list[float] | Nonelabel:strmodel_configposition:NodePosition | Noneproperties:dict[str, Any]source_id:str | Nonetemplate_id:str
class NodePosition
Position of a node in graph canvas (optional, for UI).
Bases: BaseModel
Attributes:
model_configx:floaty:float
class NodeUpdate
Node update data.
Used when updating existing nodes via GraphRepository.update_node() All fields are optional - only provided fields will be updated.
Bases: BaseModel
Attributes:
embedding:list[float] | Nonelabel:str | Nonemodel_configposition:NodePosition | Noneproperties:dict[str, Any] | None
class PaginatedResult
Paginated result from Engine list operations.
Wraps a list of domain models with pagination metadata.
Items in data are typed domain models (Node, Edge, or Template),
not raw dicts.
Example: result = engine.list_nodes(page=1, page_size=20) for node in result.data: print(node.label) print(f"Page {result.page} of {result.total_pages}")
Bases: BaseModel
Attributes:
data:list[Any]has_next:boolhas_prev:boolpage:intpage_size:inttotal:inttotal_pages:int
class ProcessingResult
Result from Engine.process_document() and Engine.add_document().
Bases: BaseModel
Attributes:
edges:list[str]model_confignodes:list[str]source_id:strtemplates:list[str]
class PropertyDefinition
Definition of a property type in a template.
Bases: BaseModel
Attributes:
allowed_node_types:list[str] | Nonedefault_value:Any | Nonedescription:str | Nonedisplay_name:strenum_values:list[str] | Nonemodel_configname:strproperty_type:PropertyTyperequired:boolvalidation_pattern:str | None
class PropertyType
Types of properties that can be attached to nodes/edges.
Bases: StrEnum
Attributes:
BOOLEANDATEDATETIMEEMAILENUMFLOATINTEGERJSONNODE_REFERENCENODE_REFERENCE_LISTSTRINGTEXTURL
class RebuildResult
Result from Engine.rebuild_indexes().
Bases: BaseModel
Attributes:
chunks_indexed:intmodel_confignodes_with_embeddings:inttotal_nodes:int
class Source
Unified source document model - from upload through committed.
Single model representing a document throughout its entire lifecycle: upload → indexing → extraction → commit to graph.
Bases: BaseModel
Attributes:
chunk_count:intcommit_completed_at:datetime | Nonecommit_edges_created:intcommit_nodes_created:intcreated_at:datetimedatabase_name:strembedding_model:str | Noneenabled:boolerror_message:str | Noneextraction_completed_at:datetime | Noneextraction_depth:str | Noneextraction_entities_count:intextraction_relationships_count:intextraction_results:dict[str, Any] | Nonefile_size:int | Nonefile_type:str | Nonefilename:strfilepath:str | Noneid:strindexing_completed_at:datetime | Nonemodel_configorigin_url:str | Nonesource_type:str | Nonestatus:strtitle:str | Noneupdated_at:datetimeuser_metadata:dict[str, Any] | None
class SourceErrorStage
Stage at which a source's pipeline failed.
Single source of truth for the error_stage column on SourceRow.
Values match the strings written by _apply_failure,
mark_source_exhausted, and fail_url_fetch today, so this
enum requires no data migration.
The Cortex retry endpoint compares error_stage to these values
to decide which lifecycle status to reset to. The Cortex abort path
translates the in-flight SourceStatus (e.g. EXTRACTING) to the
matching SourceErrorStage (e.g. EXTRACTION) before persisting.
Bases: StrEnum
Attributes:
COMMITEXTRACTIONINDEXINGRECOVERY_EXHAUSTEDURL_FETCH
class SourceStatus
Source processing lifecycle statuses.
Bases: StrEnum
Attributes:
COMMITTEDCOMMITTINGERROREXTRACTEDEXTRACTINGINDEXEDINDEXINGMCP_EXTRACTINGPENDING
class StepToolType
Type of tool used in a workflow step.
Bases: StrEnum
Attributes:
SYSTEM_TOOLUSER_TOOLWORKFLOW
class Template
Node or edge template definition - complete version for engine use.
Includes property definitions, system flag, and timestamps.
Bases: BaseModel
Attributes:
color:str | Nonecreated_at:datetimedescription:str | Noneicon:str | Noneid:stris_system:boolmodel_configname:strproperties:list[PropertyDefinition]source_id:str | Nonetemplate_type:strupdated_at:datetime
class TemplateCreate
Template creation data.
Used when creating new templates via GraphRepository.create_template()
Bases: BaseModel
Attributes:
color:str | Nonedescription:str | Noneicon:str | Nonemodel_configname:strproperties:list[PropertyDefinition]source_id:str | Nonetemplate_type:str
class TemplateUpdate
Template update data.
Used when updating existing templates via GraphRepository.update_template() All fields are optional - only provided fields will be updated.
Bases: BaseModel
Attributes:
color:str | Nonedescription:str | Noneembedding:list[float] | Noneembedding_dimensions:int | Noneembedding_model:str | Noneicon:str | Nonemodel_configname:str | Noneproperties:list[PropertyDefinition] | None
class TokenUsage
Token usage statistics from an LLM call.
Bases: BaseModel
Attributes:
cost_usd:float | Noneinput_tokens:intmodel_configoutput_tokens:inttotal_tokens:int
class ToolResult
Result from LLMProvider.execute_tool().
Bases: BaseModel
Attributes:
model_configresult:Anytool_name:str
class UserPrincipal
Normalized user principal for ACL checks.
Accepts dict, object, or None at service boundaries; service code only ever sees this dataclass.
Attributes:
id:int | Noneis_admin:bool