# yulliwasameur/linera architecture

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

- Interactive diagram: https://gitdiagram.com/yulliwasameur/linera
- Repository: https://github.com/yulliwasameur/linera

## Overview

LinEra is both a lineage-aware cryptographic-erasure library for LLM-agent memory and a research workflow evaluating memory writing, replay, forgetting, and QA. The main path builds conversation memories, replays them through storage backends with lineage, then measures retrieval and post-forgetting answers; a mem0 adapter is a separate integration branch. Source-index references and README statements support the connections shown; unsampled implementation details are not inferred.

Main entry points: [`lf/store.py`](https://github.com/yulliwasameur/linera/blob/main/lf/store.py) (Encrypted SQLite Store), [`lf/keydag.py`](https://github.com/yulliwasameur/linera/blob/main/lf/keydag.py) (Lineage Key DAG), [`agent/memory.py`](https://github.com/yulliwasameur/linera/blob/main/agent/memory.py) (Memory Backends), [`agent/build_log.py`](https://github.com/yulliwasameur/linera/blob/main/agent/build_log.py) (LLM Memory Writer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Memory Experiments"]
  node_writer["LLM Memory Writer<br/>[build_log.py]"]
  node_window_writer["Window Writer<br/>[build_window.py]"]
  node_lme_writer["LongMemEval Writer<br/>[build_lme.py]"]
  node_shared_models["LLM and Embedder<br/>[common.py]"]
  node_replay["Memory Replay<br/>[replay.py]"]
end

subgraph group_storage["Memory Backends"]
  node_memory_api["Memory Backends<br/>[memory.py]"]
  node_baseline["Baseline Stores<br/>[stores.py]"]
  node_lineage["Lineage Capture<br/>[lineage.py]"]
  node_store[("Encrypted SQLite Store<br/>[store.py]")]
  node_vector_index[("Encrypted Vector Index<br/>[vindex.py]")]
  node_mem0["mem0 Adapter<br/>[mem0_linera.py]"]
end

subgraph group_crypto["Erasure Primitives"]
  node_keydag["Lineage Key DAG<br/>[keydag.py]"]
  node_pprf["Puncturable PRF<br/>[pprf.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_qa["Post-Forget QA<br/>[qa.py]"]
  node_mem0_eval["mem0 Case Study<br/>[mem0_e2e.py]"]
  node_canary_eval["Canary Evaluation<br/>[canary.py]"]
  node_scale_eval["Scale and Radius<br/>[scale.py]"]
  node_paper_outputs["Paper Tables and Figures<br/>[make_tables.py]"]
end

node_researcher(("Researcher"))
node_benchmarks["Conversation Data"]

node_researcher -->|"runs phase A"| node_writer
node_benchmarks -->|"provides sessions"| node_writer
node_writer -->|"uses models"| node_shared_models
node_window_writer -->|"uses models"| node_shared_models
node_lme_writer -->|"uses models"| node_shared_models
node_lme_writer -->|"reuses writer"| node_writer
node_replay -->|"uses embeddings"| node_shared_models
node_replay -->|"writes and forgets"| node_memory_api
node_memory_api -->|"stores objects"| node_store
node_memory_api -->|"indexes vectors"| node_vector_index
node_memory_api -->|"uses lineage keys"| node_keydag
node_memory_api -->|"uses puncturing"| node_pprf
node_baseline -->|"uses puncturing"| node_pprf
node_store -->|"derives object keys"| node_keydag
node_store -->|"initializes PRF"| node_pprf
node_keydag -->|"evaluates and punctures"| node_pprf
node_vector_index -->|"derives shard keys"| node_keydag
node_mem0 -->|"stores memories"| node_store
node_mem0 -->|"indexes memories"| node_vector_index
node_mem0 -->|"uses lineage keys"| node_keydag
node_qa -->|"uses models"| node_shared_models
node_qa -->|"uses replay records"| node_replay
node_qa -->|"reuses writer formats"| node_writer
node_mem0_eval -->|"evaluates adapter"| node_mem0
node_canary_eval -->|"tests forgetting"| node_store
node_canary_eval -->|"tests lineage"| node_lineage
node_canary_eval -->|"compares baselines"| node_baseline
node_scale_eval -->|"measures storage"| node_store
node_scale_eval -->|"measures indexing"| node_vector_index
node_scale_eval -->|"measures derivation"| node_keydag
node_researcher -->|"runs QA"| node_qa
node_researcher -->|"runs case study"| node_mem0_eval
node_researcher -->|"generates paper results"| node_paper_outputs

click node_writer "https://github.com/yulliwasameur/linera/blob/main/agent/build_log.py"
click node_window_writer "https://github.com/yulliwasameur/linera/blob/main/agent/build_window.py"
click node_lme_writer "https://github.com/yulliwasameur/linera/blob/main/agent/build_lme.py"
click node_shared_models "https://github.com/yulliwasameur/linera/blob/main/agent/common.py"
click node_replay "https://github.com/yulliwasameur/linera/blob/main/agent/replay.py"
click node_qa "https://github.com/yulliwasameur/linera/blob/main/agent/qa.py"
click node_memory_api "https://github.com/yulliwasameur/linera/blob/main/agent/memory.py"
click node_baseline "https://github.com/yulliwasameur/linera/blob/main/baselines/stores.py"
click node_lineage "https://github.com/yulliwasameur/linera/blob/main/lf/lineage.py"
click node_store "https://github.com/yulliwasameur/linera/blob/main/lf/store.py"
click node_vector_index "https://github.com/yulliwasameur/linera/blob/main/lf/vindex.py"
click node_keydag "https://github.com/yulliwasameur/linera/blob/main/lf/keydag.py"
click node_pprf "https://github.com/yulliwasameur/linera/blob/main/lf/pprf.py"
click node_mem0 "https://github.com/yulliwasameur/linera/blob/main/integrations/mem0_linera.py"
click node_mem0_eval "https://github.com/yulliwasameur/linera/blob/main/eval/mem0_e2e.py"
click node_canary_eval "https://github.com/yulliwasameur/linera/blob/main/eval/canary.py"
click node_scale_eval "https://github.com/yulliwasameur/linera/blob/main/eval/scale.py"
click node_paper_outputs "https://github.com/yulliwasameur/linera/blob/main/eval/make_tables.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_writer,node_window_writer,node_lme_writer,node_shared_models,node_replay toneBlue
class node_memory_api,node_baseline,node_lineage,node_store,node_vector_index,node_mem0 toneAmber
class node_keydag,node_pprf toneMint
class node_qa,node_mem0_eval,node_canary_eval,node_scale_eval,node_paper_outputs toneRose
class node_researcher,node_benchmarks toneIndigo
```

## Components

### Memory Experiments

- [LLM Memory Writer](https://github.com/yulliwasameur/linera/blob/main/agent/build_log.py): `agent/build_log.py`
- [Window Writer](https://github.com/yulliwasameur/linera/blob/main/agent/build_window.py): `agent/build_window.py`
- [LongMemEval Writer](https://github.com/yulliwasameur/linera/blob/main/agent/build_lme.py): `agent/build_lme.py`
- [LLM and Embedder](https://github.com/yulliwasameur/linera/blob/main/agent/common.py): `agent/common.py`
- [Memory Replay](https://github.com/yulliwasameur/linera/blob/main/agent/replay.py): `agent/replay.py`

### Memory Backends

- [Memory Backends](https://github.com/yulliwasameur/linera/blob/main/agent/memory.py): `agent/memory.py`
- [Baseline Stores](https://github.com/yulliwasameur/linera/blob/main/baselines/stores.py): `baselines/stores.py`
- [Lineage Capture](https://github.com/yulliwasameur/linera/blob/main/lf/lineage.py): `lf/lineage.py`
- [Encrypted SQLite Store](https://github.com/yulliwasameur/linera/blob/main/lf/store.py): `lf/store.py`
- [Encrypted Vector Index](https://github.com/yulliwasameur/linera/blob/main/lf/vindex.py): `lf/vindex.py`
- [mem0 Adapter](https://github.com/yulliwasameur/linera/blob/main/integrations/mem0_linera.py): `integrations/mem0_linera.py`

### Erasure Primitives

- [Lineage Key DAG](https://github.com/yulliwasameur/linera/blob/main/lf/keydag.py): `lf/keydag.py`
- [Puncturable PRF](https://github.com/yulliwasameur/linera/blob/main/lf/pprf.py): `lf/pprf.py`

### Evaluation

- [Post-Forget QA](https://github.com/yulliwasameur/linera/blob/main/agent/qa.py): `agent/qa.py`
- [mem0 Case Study](https://github.com/yulliwasameur/linera/blob/main/eval/mem0_e2e.py): `eval/mem0_e2e.py`
- [Canary Evaluation](https://github.com/yulliwasameur/linera/blob/main/eval/canary.py): `eval/canary.py`
- [Scale and Radius](https://github.com/yulliwasameur/linera/blob/main/eval/scale.py): `eval/scale.py`
- [Paper Tables and Figures](https://github.com/yulliwasameur/linera/blob/main/eval/make_tables.py): `eval/make_tables.py`

### Other components

- **Researcher**
- **Conversation Data**

## Connections

- Researcher → LLM Memory Writer: runs phase A (evidence: `README.md`)
- Conversation Data → LLM Memory Writer: provides sessions (evidence: `README.md`)
- LLM Memory Writer → LLM and Embedder: uses models (evidence: `agent/build_log.py`)
- Window Writer → LLM and Embedder: uses models (evidence: `agent/build_window.py`)
- LongMemEval Writer → LLM and Embedder: uses models (evidence: `agent/build_lme.py`)
- LongMemEval Writer → LLM Memory Writer: reuses writer (evidence: `agent/build_lme.py`)
- Memory Replay → LLM and Embedder: uses embeddings (evidence: `agent/replay.py`)
- Memory Replay → Memory Backends: writes and forgets (evidence: `agent/replay.py`)
- Memory Backends → Encrypted SQLite Store: stores objects (evidence: `agent/memory.py`)
- Memory Backends → Encrypted Vector Index: indexes vectors (evidence: `agent/memory.py`)
- Memory Backends → Lineage Key DAG: uses lineage keys (evidence: `agent/memory.py`)
- Memory Backends → Puncturable PRF: uses puncturing (evidence: `agent/memory.py`)
- Baseline Stores → Puncturable PRF: uses puncturing (evidence: `baselines/stores.py`)
- Encrypted SQLite Store → Lineage Key DAG: derives object keys (evidence: `lf/store.py`)
- Encrypted SQLite Store → Puncturable PRF: initializes PRF (evidence: `lf/store.py`)
- Lineage Key DAG → Puncturable PRF: evaluates and punctures (evidence: `lf/keydag.py`)
- Encrypted Vector Index → Lineage Key DAG: derives shard keys (evidence: `lf/vindex.py`)
- mem0 Adapter → Encrypted SQLite Store: stores memories (evidence: `integrations/mem0_linera.py`)
- mem0 Adapter → Encrypted Vector Index: indexes memories (evidence: `integrations/mem0_linera.py`)
- mem0 Adapter → Lineage Key DAG: uses lineage keys (evidence: `integrations/mem0_linera.py`)
- Post-Forget QA → LLM and Embedder: uses models (evidence: `agent/qa.py`)
- Post-Forget QA → Memory Replay: uses replay records (evidence: `agent/qa.py`)
- Post-Forget QA → LLM Memory Writer: reuses writer formats (evidence: `agent/qa.py`)
- mem0 Case Study → mem0 Adapter: evaluates adapter (evidence: `eval/mem0_e2e.py`)
- Canary Evaluation → Encrypted SQLite Store: tests forgetting (evidence: `eval/canary.py`)
- Canary Evaluation → Lineage Capture: tests lineage (evidence: `eval/canary.py`)
- Canary Evaluation → Baseline Stores: compares baselines (evidence: `eval/canary.py`)
- Scale and Radius → Encrypted SQLite Store: measures storage (evidence: `eval/scale.py`)
- Scale and Radius → Encrypted Vector Index: measures indexing (evidence: `eval/scale.py`)
- Scale and Radius → Lineage Key DAG: measures derivation (evidence: `eval/scale.py`)
- Researcher → Post-Forget QA: runs QA (evidence: `README.md`)
- Researcher → mem0 Case Study: runs case study (evidence: `README.md`)
- Researcher → Paper Tables and Figures: generates paper results (evidence: `README.md`)
