> ## Documentation Index
> Fetch the complete documentation index at: https://docs.10et.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Architecture

> How TENET's components fit together — CLI, platform, storage, and agent harness

TENET is a collection of components that work together to create a learning system for AI agents.

## System Overview

<Card>
  **Your Project** → **Context Hub** → **Agents** → **Eval** → **Training** → **Policy Head** → better agents tomorrow
</Card>

| Layer             | Components                                             |
| ----------------- | ------------------------------------------------------ |
| **CLI**           | init, setup, peter, train, eval, ide, deploy           |
| **Context Hub**   | Memory DB, Event Bus, Indexer (port 4360)              |
| **Agent Harness** | Peter Parker, RL agents, worktree isolation            |
| **Learning**      | Training buffer, policy head (14M params), build evals |
| **Platform**      | Dashboard, auth, cloud agents, team features           |
| **Mesh**          | Subway P2P for agent coordination                      |

## Components

### CLI

The entry point. All commands go through `tenet`:

| Command        | Purpose                            |
| -------------- | ---------------------------------- |
| `tenet`        | Launch Pi with TENET extensions    |
| `tenet init`   | Scaffold a new project             |
| `tenet setup`  | Auto-detect metrics, create agents |
| `tenet peter`  | Agent orchestrator                 |
| `tenet train`  | Train policy head                  |
| `tenet eval`   | Run evals, check scores            |
| `tenet ide`    | Terminal workspace                 |
| `tenet deploy` | Deploy to platform                 |

### Context Hub

The central coordination daemon. Runs locally on port 4360.

* **Memory database** — SQLite with indexed memories, semantic embeddings, graph edges
* **Event bus** — MAP (Multiplayer Agent Protocol) events for agent coordination
* **Periodic indexer** — Indexes journal entries every 60s, code headers every 5 min
* **API server** — REST endpoints for memory, events, context, eval

### Agent Harness

Autonomous improvement agents that run in isolated git worktrees.

**The loop:**

<Steps>
  <Step title="Eval before">
    Measure the baseline metric (coverage, quality, speed)
  </Step>

  <Step title="Agent changes code">
    In an isolated worktree — main branch is never touched
  </Step>

  <Step title="Eval after">
    Measure again. Did the metric improve?
  </Step>

  <Step title="Keep or revert">
    Score improved → advance branch, create PR. Regressed → `git reset --hard`
  </Step>

  <Step title="Record tuple">
    (state, action, reward) → training buffer. Policy head learns.
  </Step>
</Steps>

### Storage Layer

Everything is files in your repo:

| Component       | Format | Location                       |
| --------------- | ------ | ------------------------------ |
| Journals        | JSONL  | `.tenet/journal/*.jsonl`       |
| Training buffer | JSONL  | `.tenet/training-buffer.jsonl` |
| Agent configs   | TOML   | `.tenet/agents/*.toml`         |
| Memory          | SQLite | `.tenet/memory.db`             |
| Eval results    | JSONL  | `.tenet/eval.jsonl`            |
| Policy weights  | JSON   | `.tenet/checkpoints/`          |
| Flows           | YAML   | `.tenet/flows/*.yaml`          |
| Config          | JSON   | `.tenet/config.json`           |

### Platform (Cloud)

Optional hosted services for dashboard, auth, cloud agents, and team features.

| API                   | Purpose                |
| --------------------- | ---------------------- |
| `/api/tenet/memory/*` | Cloud memory sync      |
| `/api/tenet/train`    | Remote training        |
| `/api/tenet/policy`   | Policy inference       |
| `/api/tenet/tuples`   | Tuple upload           |
| `/api/agents/*`       | Cloud agent management |
| `/api/sessions/*`     | Session tracking       |

### Subway Mesh

P2P agent coordination. Agents discover each other, send messages, broadcast events across machines.

| Agent           | Role                                          |
| --------------- | --------------------------------------------- |
| Your Pi session | Coding agent with TENET tools                 |
| `browser.relay` | Terminal browser with DOM access              |
| Other sessions  | Parallel agents on same or different machines |

## Data Flow

<Steps>
  <Step title="Session produces data">
    Agent sessions write journal entries and training tuples
  </Step>

  <Step title="Hub indexes everything">
    Context Hub indexes journals, code headers, embeddings
  </Step>

  <Step title="Policy head trains">
    Training buffer feeds the policy head — learns what works
  </Step>

  <Step title="Peter Parker orchestrates">
    Picks best next experiment based on policy predictions
  </Step>

  <Step title="Agents improve overnight">
    Run in worktrees, eval-gated, auto-PR on improvement
  </Step>
</Steps>
