How 24127027/cognieda works
Purpose and Entry Points
CogniEDA is a Python 3.12+ governed research-state system: it records analytical objects and their provenance so conclusions remain traceable to datasets, methods, parameters, evidence, and validity scope. The nominal CLI entry point is currently a placeholder at main.py; there is no production API/service. Runtime composition is expected to begin with database initialization and application orchestration, represented by src/db/init_db.py and src/application/.
Canonical Research-State Model
The domain is centered on eight Pydantic first-class objects: Objective, DataProfile, Assumption, Task, Hypothesis, Evidence, Discovery, and SessionFrame. Schemas establish typed object boundaries, enums, artifact references, and planner-operation values. SQLModel mappings provide persistence representations. Core paths: src/schemas/, src/schemas/artifacts.py, src/db/models.py.
Persistence and Provenance Boundary
SQLite is the default local graph-store backend (.local/cognieda_graph.sqlite3, overridable with COGNIEDA_DB_URL). Database session/engine code is isolated from thin repositories, which mediate object-specific reads and append-oriented writes. DataProfile, Evidence, Discovery, and SessionFrame have append-only repository surfaces, preserving research history rather than replacing conclusions. Paths: src/db/session.py, src/repositories/, src/repositories/evidence_repository.py.
Data Intake, Validation, and Profiling
Datasets enter through loaders and validation, then baseline profiling creates immutable DataProfile records tied to dataset paths and optionally DVC identity. DVC is deliberately an adapter boundary; executable integration is not implemented. Profiles may also be mirrored as tracked artifacts. Paths: src/data/loaders.py, src/data/profiling.py, src/data/dvc.py.
Session Memory and Context Projection
SessionFrame is the controlled memory boundary rather than unbounded chat history. Builders project persisted research state into distinct planning and conclusion contexts, enforcing local context-type safety and separating what a planner may use from what supports conclusions. Graph-level retrieval policy remains unimplemented. Paths: src/memory/session_frame.py, src/repositories/session_frame_repository.py, docs/architecture/memory-model.md.
Agent Planning and Execution
LangGraph scaffolding separates planning from capability-based execution. The planner graph defines named nodes and workflow wiring, but most node bodies are stubs. Executor dispatch selects registered capabilities and includes graph-miner and hypothesis-analyst agent graphs. LLM access is isolated behind an agent module. Paths: src/agents/planner/graph.py, src/agents/executor/dispatcher.py, src/agents/executor/registry.py.
Tools and External Integration
Tools are managed behind a common manager with builtin dataset/graph tools and loader boundaries for MCP servers and skill packages. Configuration declares agent, MCP, and skill surfaces, while external service behavior is not yet established by the current implementation. Paths: src/tools/manager.py, src/tools/mcp/loader.py, config/mcp.toml.
Control Flow and Implementation Gaps
Intended flow is: user question becomes a Task; planner consumes a SessionFrame and emits pending operations; operations are committed to persisted FCOs; executor runs analysis; generated outputs become Evidence; evidence-backed conclusions become Discovery; a new SessionFrame captures the state. Important missing stages are operation-before-commit persistence, full AnalysisFrame/ExecutionRun/PlannerOperation/cache records, executable DVC, and a production-facing interface. Paths: src/application/orchestrator/planner_commit.py, src/schemas/planner_operations.py, docs/architecture/planner-workflow.md.
Main entry points: repositories Repositories · dispatcher.py Capability executor · evidence_repository.py Evidence repository · planner_commit.py Planner commit
Components 22
Research State
Canonical governed research objects.
- FCO schemas · Defines Objective, DataProfile, Assumption, Task, Hypothesis, Evidence, Discovery, and SessionFrame.
src/schemas - Artifact references
src/schemas/artifacts.py - SessionFrame projection · Builds distinct planning and conclusion contexts from persisted state.
src/memory/session_frame.py
Persistence
SQLite storage and append-oriented access.
- Database initialization
src/db/init_db.py - SQLModel mappings · Persistent representations of research objects.
src/db/models.py - SQLite engine & sessions · Defaults to local SQLite and accepts COGNIEDA_DB_URL.
src/db/session.py - Repositories · Thin object-specific reads and append-oriented writes.
src/repositories - Evidence repository
src/repositories/evidence_repository.py - SessionFrame repository
src/repositories/session_frame_repository.py
Planning & Execution
Intended orchestration pipeline; several stages remain scaffolded.
- Application composition · Expected runtime composition boundary.
src/application - Planner graph · Named workflow nodes are wired, while most bodies are stubs.
src/agents/planner/graph.py - Planner operations · Pending planner-operation values; persistence is incomplete.
src/schemas/planner_operations.py - Planner commit · Intended operation-to-research-state commit boundary.
src/application/orchestrator/planner_commit.py - Capability executor · Dispatches analysis work to registered capabilities.
src/agents/executor/dispatcher.py - Capability registry · Registers graph-miner and hypothesis-analyst agent graphs.
src/agents/executor/registry.py
Data & Tools
Dataset intake, profiling, and capability boundaries.
- Dataset loading & validation
src/data/loaders.py - Baseline profiling · Creates immutable DataProfile records tied to dataset identity.
src/data/profiling.py - DVC adapter boundary · Integration is declared but not executable.
src/data/dvc.py - Tool manager · Provides builtin dataset and graph tools.
src/tools/manager.py - MCP & skill loader · Loads declared MCP-server and skill-package boundaries.
src/tools/mcp/loader.py - MCP configuration · Declares MCP integration surfaces.
config/mcp.toml
Other components
- CLI placeholder · Nominal entry point; no production interface exists.
main.py
Connections 24
- CLI placeholder → Application composition: intended startup
- Application composition → Database initialization: initializes
- Database initialization → SQLite engine & sessions: creates engine
- FCO schemas → Artifact references: uses
- FCO schemas → SQLModel mappings: maps to
- SQLite engine & sessions → Repositories: provides sessions
- Repositories → SQLModel mappings: persists
- Evidence repository → Repositories: specializes
- SessionFrame repository → Repositories: specializes
- Dataset loading & validation → Baseline profiling: profiles datasets
- Baseline profiling → DVC adapter boundary: optional dataset identity
- Baseline profiling → Repositories: appends DataProfile
- Repositories → SessionFrame projection: projects persisted state
- SessionFrame projection → Planner graph: planning context
- Planner graph → Planner operations: emits pending operations
- Planner operations → Planner commit: commits intended changes
- Planner commit → Repositories: persists FCOs
- Planner commit → Capability executor: dispatches analysis
- Capability executor → Capability registry: selects capability
- Capability executor → Tool manager: uses tools
- Tool manager → MCP & skill loader: loads external tools
- MCP & skill loader → MCP configuration: reads declarations
- Capability executor → Evidence repository: appends Evidence
- Evidence repository → SessionFrame repository: evidence informs next frame