# 24127027/cognieda architecture

> Architecture diagram of the GitHub repository 24127027/cognieda, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/24127027/cognieda
- Repository: https://github.com/24127027/cognieda

## Overview

#### 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: [`src/repositories`](https://github.com/24127027/cognieda/tree/main/src/repositories) (Repositories), [`src/agents/executor/dispatcher.py`](https://github.com/24127027/cognieda/blob/main/src/agents/executor/dispatcher.py) (Capability executor), [`src/repositories/evidence_repository.py`](https://github.com/24127027/cognieda/blob/main/src/repositories/evidence_repository.py) (Evidence repository), [`src/application/orchestrator/planner_commit.py`](https://github.com/24127027/cognieda/blob/main/src/application/orchestrator/planner_commit.py) (Planner commit)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_domain["Research State"]
  node_schemas["FCO schemas<br/>Pydantic schemas"]
  node_artifacts["Artifact references<br/>schema module<br/>[artifacts.py]"]
  node_session_frame["SessionFrame projection<br/>controlled memory<br/>[session_frame.py]"]
end

subgraph group_persistence["Persistence"]
  node_db_init["Database initialization<br/>bootstrap<br/>[init_db.py]"]
  node_sql_models["SQLModel mappings<br/>persistence models<br/>[models.py]"]
  node_db_session[("SQLite engine &amp; sessions<br/>database session<br/>[session.py]")]
  node_repositories["Repositories<br/>repository layer"]
  node_evidence_repo["Evidence repository<br/>append-only repository"]
  node_session_repo["SessionFrame repository<br/>append-only repository"]
end

subgraph group_workflow["Planning &amp; Execution"]
  node_application["Application composition<br/>application package"]
  node_planner["Planner graph<br/>LangGraph planner<br/>[graph.py]"]
  node_planner_ops["Planner operations<br/>operation schema"]
  node_planner_commit["Planner commit<br/>orchestration stage<br/>[planner_commit.py]"]
  node_executor["Capability executor<br/>agent dispatcher<br/>[dispatcher.py]"]
  node_registry["Capability registry<br/>agent registry<br/>[registry.py]"]
end

subgraph group_intake["Data &amp; Tools"]
  node_intake["Dataset loading &amp; validation<br/>data intake<br/>[loaders.py]"]
  node_profiling["Baseline profiling<br/>data profiling<br/>[profiling.py]"]
  node_dvc["DVC adapter boundary<br/>external adapter<br/>[dvc.py]"]
  node_tool_manager["Tool manager<br/>tool boundary<br/>[manager.py]"]
  node_mcp_loader["MCP &amp; skill loader<br/>external tool loader<br/>[loader.py]"]
  node_mcp_config["MCP configuration<br/>tool configuration<br/>[mcp.toml]"]
end

node_cli["CLI placeholder<br/>Python entry point<br/>[main.py]"]

node_cli -.->|"intended startup"| node_application
node_application -->|"initializes"| node_db_init
node_db_init -->|"creates engine"| node_db_session
node_schemas -->|"uses"| node_artifacts
node_schemas -->|"maps to"| node_sql_models
node_db_session -->|"provides sessions"| node_repositories
node_repositories -->|"persists"| node_sql_models
node_evidence_repo -->|"specializes"| node_repositories
node_session_repo -->|"specializes"| node_repositories
node_intake -->|"profiles datasets"| node_profiling
node_profiling -.->|"optional dataset identity"| node_dvc
node_profiling -->|"appends DataProfile"| node_repositories
node_repositories -->|"projects persisted state"| node_session_frame
node_session_frame -->|"planning context"| node_planner
node_planner -->|"emits pending operations"| node_planner_ops
node_planner_ops -.->|"commits intended changes"| node_planner_commit
node_planner_commit -.->|"persists FCOs"| node_repositories
node_planner_commit -->|"dispatches analysis"| node_executor
node_executor -->|"selects capability"| node_registry
node_executor -->|"uses tools"| node_tool_manager
node_tool_manager -.->|"loads external tools"| node_mcp_loader
node_mcp_loader -->|"reads declarations"| node_mcp_config
node_executor -->|"appends Evidence"| node_evidence_repo
node_evidence_repo -->|"evidence informs next frame"| node_session_repo

click node_cli "https://github.com/24127027/cognieda/blob/main/main.py"
click node_application "https://github.com/24127027/cognieda/tree/main/src/application"
click node_db_init "https://github.com/24127027/cognieda/blob/main/src/db/init_db.py"
click node_schemas "https://github.com/24127027/cognieda/tree/main/src/schemas"
click node_artifacts "https://github.com/24127027/cognieda/blob/main/src/schemas/artifacts.py"
click node_sql_models "https://github.com/24127027/cognieda/blob/main/src/db/models.py"
click node_db_session "https://github.com/24127027/cognieda/blob/main/src/db/session.py"
click node_repositories "https://github.com/24127027/cognieda/tree/main/src/repositories"
click node_evidence_repo "https://github.com/24127027/cognieda/blob/main/src/repositories/evidence_repository.py"
click node_intake "https://github.com/24127027/cognieda/blob/main/src/data/loaders.py"
click node_profiling "https://github.com/24127027/cognieda/blob/main/src/data/profiling.py"
click node_dvc "https://github.com/24127027/cognieda/blob/main/src/data/dvc.py"
click node_session_frame "https://github.com/24127027/cognieda/blob/main/src/memory/session_frame.py"
click node_session_repo "https://github.com/24127027/cognieda/blob/main/src/repositories/session_frame_repository.py"
click node_planner "https://github.com/24127027/cognieda/blob/main/src/agents/planner/graph.py"
click node_planner_ops "https://github.com/24127027/cognieda/blob/main/src/schemas/planner_operations.py"
click node_planner_commit "https://github.com/24127027/cognieda/blob/main/src/application/orchestrator/planner_commit.py"
click node_executor "https://github.com/24127027/cognieda/blob/main/src/agents/executor/dispatcher.py"
click node_registry "https://github.com/24127027/cognieda/blob/main/src/agents/executor/registry.py"
click node_tool_manager "https://github.com/24127027/cognieda/blob/main/src/tools/manager.py"
click node_mcp_loader "https://github.com/24127027/cognieda/blob/main/src/tools/mcp/loader.py"
click node_mcp_config "https://github.com/24127027/cognieda/blob/main/config/mcp.toml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_schemas,node_artifacts,node_session_frame toneBlue
class node_db_init,node_sql_models,node_db_session,node_repositories,node_evidence_repo,node_session_repo toneAmber
class node_application,node_planner,node_planner_ops,node_planner_commit,node_executor,node_registry toneMint
class node_intake,node_profiling,node_dvc,node_tool_manager,node_mcp_loader,node_mcp_config toneRose
class node_cli toneNeutral
```

## Components

### Research State

Canonical governed research objects.

- [FCO schemas](https://github.com/24127027/cognieda/tree/main/src/schemas): Pydantic schemas · Defines Objective, DataProfile, Assumption, Task, Hypothesis, Evidence, Discovery, and SessionFrame. · `src/schemas`
- [Artifact references](https://github.com/24127027/cognieda/blob/main/src/schemas/artifacts.py): schema module · `src/schemas/artifacts.py`
- [SessionFrame projection](https://github.com/24127027/cognieda/blob/main/src/memory/session_frame.py): controlled memory · Builds distinct planning and conclusion contexts from persisted state. · `src/memory/session_frame.py`

### Persistence

SQLite storage and append-oriented access.

- [Database initialization](https://github.com/24127027/cognieda/blob/main/src/db/init_db.py): bootstrap · `src/db/init_db.py`
- [SQLModel mappings](https://github.com/24127027/cognieda/blob/main/src/db/models.py): persistence models · Persistent representations of research objects. · `src/db/models.py`
- [SQLite engine & sessions](https://github.com/24127027/cognieda/blob/main/src/db/session.py): database session · Defaults to local SQLite and accepts COGNIEDA_DB_URL. · `src/db/session.py`
- [Repositories](https://github.com/24127027/cognieda/tree/main/src/repositories): repository layer · Thin object-specific reads and append-oriented writes. · `src/repositories`
- [Evidence repository](https://github.com/24127027/cognieda/blob/main/src/repositories/evidence_repository.py): append-only repository · `src/repositories/evidence_repository.py`
- [SessionFrame repository](https://github.com/24127027/cognieda/blob/main/src/repositories/session_frame_repository.py): append-only repository · `src/repositories/session_frame_repository.py`

### Planning & Execution

Intended orchestration pipeline; several stages remain scaffolded.

- [Application composition](https://github.com/24127027/cognieda/tree/main/src/application): application package · Expected runtime composition boundary. · `src/application`
- [Planner graph](https://github.com/24127027/cognieda/blob/main/src/agents/planner/graph.py): LangGraph planner · Named workflow nodes are wired, while most bodies are stubs. · `src/agents/planner/graph.py`
- [Planner operations](https://github.com/24127027/cognieda/blob/main/src/schemas/planner_operations.py): operation schema · Pending planner-operation values; persistence is incomplete. · `src/schemas/planner_operations.py`
- [Planner commit](https://github.com/24127027/cognieda/blob/main/src/application/orchestrator/planner_commit.py): orchestration stage · Intended operation-to-research-state commit boundary. · `src/application/orchestrator/planner_commit.py`
- [Capability executor](https://github.com/24127027/cognieda/blob/main/src/agents/executor/dispatcher.py): agent dispatcher · Dispatches analysis work to registered capabilities. · `src/agents/executor/dispatcher.py`
- [Capability registry](https://github.com/24127027/cognieda/blob/main/src/agents/executor/registry.py): agent 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](https://github.com/24127027/cognieda/blob/main/src/data/loaders.py): data intake · `src/data/loaders.py`
- [Baseline profiling](https://github.com/24127027/cognieda/blob/main/src/data/profiling.py): data profiling · Creates immutable DataProfile records tied to dataset identity. · `src/data/profiling.py`
- [DVC adapter boundary](https://github.com/24127027/cognieda/blob/main/src/data/dvc.py): external adapter · Integration is declared but not executable. · `src/data/dvc.py`
- [Tool manager](https://github.com/24127027/cognieda/blob/main/src/tools/manager.py): tool boundary · Provides builtin dataset and graph tools. · `src/tools/manager.py`
- [MCP & skill loader](https://github.com/24127027/cognieda/blob/main/src/tools/mcp/loader.py): external tool loader · Loads declared MCP-server and skill-package boundaries. · `src/tools/mcp/loader.py`
- [MCP configuration](https://github.com/24127027/cognieda/blob/main/config/mcp.toml): tool configuration · Declares MCP integration surfaces. · `config/mcp.toml`

### Other components

- [CLI placeholder](https://github.com/24127027/cognieda/blob/main/main.py): Python entry point · Nominal entry point; no production interface exists. · `main.py`

## Connections

- 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
