# threefish-ai/negentropy architecture

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

- Interactive diagram: https://gitdiagram.com/threefish-ai/negentropy
- Repository: https://github.com/threefish-ai/negentropy

## Overview

Negentropy is a self-evolving agent system: a scheduling core dispatches work to orthogonal faculties, with documented pipelines for knowledge acquisition, problem solving, and value delivery. A typical knowledge workflow accepts a document, extracts and indexes it, then supports retrieval and knowledge management; agents can also use persistent memory and sandboxed execution. The repository includes separate Cognizes and Perceives applications alongside the main backend and UI. Major capabilities are represented from the README and source index; unsampled implementation details and inter-service wiring are not assumed.

Main entry points: [`apps/negentropy/src/negentropy/agents`](https://github.com/threefish-ai/negentropy/tree/master/apps/negentropy/src/negentropy/agents) (Five faculties), [`apps/negentropy/src/negentropy/engine`](https://github.com/threefish-ai/negentropy/tree/master/apps/negentropy/src/negentropy/engine) (Scheduling core), [`apps/negentropy/src/negentropy/knowledge/routes/pipelines.py`](https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy/src/negentropy/knowledge/routes/pipelines.py) (Knowledge API), [`apps/negentropy/src/negentropy/knowledge/lifecycle/corpus_engine.py`](https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy/src/negentropy/knowledge/lifecycle/corpus_engine.py) (Corpus lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Agent orchestration"]
  node_root["Scheduling core"]
  node_faculties{{"Five faculties"}}
  node_pipelines["Standard pipelines"]
end

subgraph group_knowledge["Knowledge lifecycle"]
  node_perceives["Content extraction"]
  node_corpus["Corpus lifecycle<br/>[corpus_engine.py]"]
  node_knowledge_api["Knowledge API<br/>[pipelines.py]"]
  node_retrieval["Search and retrieval<br/>[repository.py]"]
  node_knowledge_graph["Knowledge graph<br/>[service.py]"]
end

subgraph group_cognition["Memory and reasoning"]
  node_memory["Dynamic memory"]
  node_rag["RAG pipeline<br/>[rag_pipeline.py]"]
  node_sandbox["Code sandbox"]
  node_evolution["Prompt evolution<br/>[memory_pipeline.py]"]
end

subgraph group_interfaces["User interfaces"]
  node_chat_ui["Agent UI"]
  node_knowledge_ui["Knowledge UI<br/>[knowledge-api.ts]"]
  node_wiki["Knowledge wiki"]
end

subgraph group_platform["Runtime services"]
  node_database[("PostgreSQL<br/>[storage.py]")]
  node_observability["Observability<br/>[logging.py]"]
end

node_user(("User"))
node_llm{{"LLM provider"}}

node_user -->|"starts task"| node_chat_ui
node_chat_ui -.->|"submits intent"| node_root
node_root -->|"dispatches work"| node_faculties
node_root -->|"offers workflows"| node_pipelines
node_pipelines -->|"acquires knowledge"| node_perceives
node_perceives -.->|"extracts content"| node_corpus
node_knowledge_api -.->|"manages runs"| node_corpus
node_knowledge_ui -->|"calls API"| node_knowledge_api
node_knowledge_api -->|"reads and writes"| node_database
node_corpus -->|"assesses corpus"| node_database
node_retrieval -.->|"supports search"| node_knowledge_graph
node_faculties -.->|"uses memory"| node_memory
node_faculties -->|"executes code"| node_sandbox
node_faculties -.->|"requests inference"| node_llm
node_rag -->|"stores vectors"| node_database
node_rag -->|"generates answers"| node_llm
node_evolution -->|"proposes prompts"| node_llm
node_faculties -.->|"evolves prompts"| node_evolution
node_wiki -.->|"presents knowledge"| node_knowledge_api
node_root -.->|"records activity"| node_observability

click node_root "https://github.com/threefish-ai/negentropy/tree/master/apps/negentropy/src/negentropy/engine"
click node_faculties "https://github.com/threefish-ai/negentropy/tree/master/apps/negentropy/src/negentropy/agents"
click node_pipelines "https://github.com/threefish-ai/negentropy/tree/master/apps/negentropy/src/negentropy/engine"
click node_perceives "https://github.com/threefish-ai/negentropy/tree/master/apps/negentropy-perceives/src/negentropy/perceives"
click node_corpus "https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy/src/negentropy/knowledge/lifecycle/corpus_engine.py"
click node_knowledge_api "https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy/src/negentropy/knowledge/routes/pipelines.py"
click node_retrieval "https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy/src/negentropy/knowledge/retrieval/repository.py"
click node_knowledge_graph "https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy/src/negentropy/knowledge/graph/service.py"
click node_memory "https://github.com/threefish-ai/negentropy/blob/master/apps/cognizes/src/cognizes/engine/hippocampus/retention_manager.py"
click node_rag "https://github.com/threefish-ai/negentropy/blob/master/apps/cognizes/src/cognizes/engine/perception/rag_pipeline.py"
click node_sandbox "https://github.com/threefish-ai/negentropy/tree/master/apps/cognizes/src/cognizes/adapters/postgres/sandbox"
click node_evolution "https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy/src/negentropy/engine/evolution/handlers/memory_pipeline.py"
click node_chat_ui "https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy-ui/features/session/hooks/useSessionService.ts"
click node_knowledge_ui "https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy-ui/features/knowledge/utils/knowledge-api.ts"
click node_wiki "https://github.com/threefish-ai/negentropy/tree/master/apps/negentropy-wiki/src/app"
click node_database "https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy/src/negentropy/models/storage.py"
click node_observability "https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy/src/negentropy/config/logging.py"

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_root,node_faculties,node_pipelines,node_user toneBlue
class node_perceives,node_corpus,node_knowledge_api,node_retrieval,node_knowledge_graph toneAmber
class node_memory,node_rag,node_sandbox,node_evolution toneMint
class node_chat_ui,node_knowledge_ui,node_wiki toneRose
class node_database,node_observability,node_llm toneIndigo
```

## Components

### Agent orchestration

- [Scheduling core](https://github.com/threefish-ai/negentropy/tree/master/apps/negentropy/src/negentropy/engine): `apps/negentropy/src/negentropy/engine`
- [Five faculties](https://github.com/threefish-ai/negentropy/tree/master/apps/negentropy/src/negentropy/agents): `apps/negentropy/src/negentropy/agents`
- [Standard pipelines](https://github.com/threefish-ai/negentropy/tree/master/apps/negentropy/src/negentropy/engine): `apps/negentropy/src/negentropy/engine`

### Knowledge lifecycle

- [Content extraction](https://github.com/threefish-ai/negentropy/tree/master/apps/negentropy-perceives/src/negentropy/perceives): `apps/negentropy-perceives/src/negentropy/perceives`
- [Corpus lifecycle](https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy/src/negentropy/knowledge/lifecycle/corpus_engine.py): `apps/negentropy/src/negentropy/knowledge/lifecycle/corpus_engine.py`
- [Knowledge API](https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy/src/negentropy/knowledge/routes/pipelines.py): `apps/negentropy/src/negentropy/knowledge/routes/pipelines.py`
- [Search and retrieval](https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy/src/negentropy/knowledge/retrieval/repository.py): `apps/negentropy/src/negentropy/knowledge/retrieval/repository.py`
- [Knowledge graph](https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy/src/negentropy/knowledge/graph/service.py): `apps/negentropy/src/negentropy/knowledge/graph/service.py`

### Memory and reasoning

- [Dynamic memory](https://github.com/threefish-ai/negentropy/blob/master/apps/cognizes/src/cognizes/engine/hippocampus/retention_manager.py): `apps/cognizes/src/cognizes/engine/hippocampus/retention_manager.py`
- [RAG pipeline](https://github.com/threefish-ai/negentropy/blob/master/apps/cognizes/src/cognizes/engine/perception/rag_pipeline.py): `apps/cognizes/src/cognizes/engine/perception/rag_pipeline.py`
- [Code sandbox](https://github.com/threefish-ai/negentropy/tree/master/apps/cognizes/src/cognizes/adapters/postgres/sandbox): `apps/cognizes/src/cognizes/adapters/postgres/sandbox`
- [Prompt evolution](https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy/src/negentropy/engine/evolution/handlers/memory_pipeline.py): `apps/negentropy/src/negentropy/engine/evolution/handlers/memory_pipeline.py`

### User interfaces

- [Agent UI](https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy-ui/features/session/hooks/useSessionService.ts): `apps/negentropy-ui/features/session/hooks/useSessionService.ts`
- [Knowledge UI](https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy-ui/features/knowledge/utils/knowledge-api.ts): `apps/negentropy-ui/features/knowledge/utils/knowledge-api.ts`
- [Knowledge wiki](https://github.com/threefish-ai/negentropy/tree/master/apps/negentropy-wiki/src/app): `apps/negentropy-wiki/src/app`

### Runtime services

- [PostgreSQL](https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy/src/negentropy/models/storage.py): `apps/negentropy/src/negentropy/models/storage.py`
- [Observability](https://github.com/threefish-ai/negentropy/blob/master/apps/negentropy/src/negentropy/config/logging.py): `apps/negentropy/src/negentropy/config/logging.py`

### Other components

- **User**
- **LLM provider**

## Connections

- User → Agent UI: starts task (evidence: `README.md`)
- Agent UI → Scheduling core: submits intent
- Scheduling core → Five faculties: dispatches work (evidence: `README.md`)
- Scheduling core → Standard pipelines: offers workflows (evidence: `README.md`)
- Standard pipelines → Content extraction: acquires knowledge (evidence: `README.md`)
- Content extraction → Corpus lifecycle: extracts content
- Knowledge API → Corpus lifecycle: manages runs
- Knowledge UI → Knowledge API: calls API
- Knowledge API → PostgreSQL: reads and writes (evidence: `apps/negentropy/src/negentropy/knowledge/routes/pipelines.py`)
- Corpus lifecycle → PostgreSQL: assesses corpus (evidence: `apps/negentropy/src/negentropy/knowledge/lifecycle/corpus_engine.py`)
- Search and retrieval → Knowledge graph: supports search
- Five faculties → Dynamic memory: uses memory
- Five faculties → Code sandbox: executes code (evidence: `README.md`)
- Five faculties → LLM provider: requests inference
- RAG pipeline → PostgreSQL: stores vectors (evidence: `apps/cognizes/src/cognizes/engine/perception/rag_pipeline.py`)
- RAG pipeline → LLM provider: generates answers (evidence: `apps/cognizes/src/cognizes/engine/perception/rag_pipeline.py`)
- Prompt evolution → LLM provider: proposes prompts (evidence: `apps/negentropy/src/negentropy/engine/evolution/handlers/memory_pipeline.py`)
- Five faculties → Prompt evolution: evolves prompts
- Knowledge wiki → Knowledge API: presents knowledge
- Scheduling core → Observability: records activity
