# reticlehq/reticle architecture

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

- Interactive diagram: https://gitdiagram.com/reticlehq/reticle
- Repository: https://github.com/reticlehq/reticle

## Overview

#### Purpose and topology
Reticle is a dev-only, localhost verification layer for AI coding agents. It instruments a running web or desktop app, exposes structured observation/control through MCP and CLI, and returns pass/fail/unknown verdicts with evidence and source attribution. This pnpm/Turbo monorepo separates embedded SDK packages from the local daemon/agent-facing server.
- `packages/core/src/index.ts`
- `packages/server/src/index.ts`
- `packages/browser/src/index.ts`

#### Agent and CLI entry points
`@reticlehq/server` is the operational entry point: its CLI starts/statuses the daemon, initializes projects, and launches an MCP server. MCP tool requests are dispatched into server-side tool, session, flow, and verification subsystems rather than directly controlling the browser.
- `packages/server/src/cli.ts`
- `packages/server/src/mcp/mcp.ts`
- `packages/server/src/tools/tools.ts`

#### In-app instrumentation boundary
The browser SDK runs inside the target app only in development. It installs observers for DOM, network, console, routing, storage, state, and browser behavior; captures actions and snapshots; then streams bounded structured events to the local bridge. This is the principal boundary between the application runtime and Reticle.
- `packages/browser/src/reticle.ts`
- `packages/browser/src/observers/install-all.ts`
- `packages/browser/src/transport/transport.ts`

#### Framework integration and source attribution
Build integrations inject/connect the SDK in supported app runtimes and keep it out of production builds. The React package augments generic browser evidence with React commit/store information and maps DOM targets through React fiber toward source locations. Next and Vite adapters are the common framework-facing integration points.
- `packages/react/src/index.ts`
- `packages/react/src/cdp-reader.ts`
- `packages/vite-plugin/src/index.ts`
- `packages/next/index.cjs`

#### Local bridge, daemon, and session control
A localhost HTTP/WebSocket bridge authenticates paired browser connections, receives browser event streams, and mediates commands. The daemon owns lifecycle, ports, durable local state, heartbeat/idle behavior, multi-project coordination, and session leases; session management maintains command queues, observed state, health, and live-control context.
- `packages/server/src/bridge/bridge.ts`
- `packages/server/src/daemon/daemon.ts`
- `packages/server/src/session/session-manager.ts`

#### Verification pipeline
Agent actions (`navigate`, input, click, query, observe) are executed against a selected session, then events are reconciled in action windows. Predicate evaluation combines network, DOM, state, signal, console, and related evidence; honesty/coverage logic prevents an unobservable or unsettled condition from becoming a silent pass. Verdicts can carry source evidence and consequence diagnostics.
- `packages/server/src/tools/act-tools.ts`
- `packages/server/src/events/predicate-eval.ts`
- `packages/server/src/honesty/honesty.ts`
- `packages/core/src/consequence.ts`

#### Recorded flows, persistence, and execution modes
Flows record actions and assertions, compile/replay them deterministically, support verification/gating and healing proposals, and persist project/run/journal artifacts locally. Browser automation is pooled through Playwright when Reticle needs launched or managed contexts; normally it attaches to an already running instrumented app. Desktop support crosses renderer/main-process or Rust IPC boundaries.
- `packages/server/src/flows/flows.ts`
- `packages/server/src/flows/flow-replay.ts`
- `packages/server/src/project/project-store.ts`
- `packages/server/src/pool/browser-pool.ts`
- `packages/electron/main.cjs`
- `packages/tauri/src/lib.rs`

#### External services and delivery boundaries
Core runtime communication is local: browser-to-daemon transport binds to localhost and data is retained in local stores/journals. Optional cloud sync, telemetry, feedback, licensing, and update checks are isolated server concerns. The repository also ships benchmark apps and end-to-end harnesses that exercise browser, Electron, Tauri, daemon, MCP, replay, and transport-fault paths.
- `packages/server/src/cloud/cloud-sync.ts`
- `packages/server/src/telemetry/telemetry.ts`
- `packages/server/src/license/license.ts`
- `apps/e2e/run.mjs`

Main entry points: [`packages/server/src/daemon/daemon.ts`](https://github.com/reticlehq/reticle/blob/main/packages/server/src/daemon/daemon.ts) (Daemon), [`packages/browser/src/reticle.ts`](https://github.com/reticlehq/reticle/blob/main/packages/browser/src/reticle.ts) (Browser SDK), [`packages/server/src/session/session-manager.ts`](https://github.com/reticlehq/reticle/blob/main/packages/server/src/session/session-manager.ts) (Session manager), [`packages/server/src/bridge/bridge.ts`](https://github.com/reticlehq/reticle/blob/main/packages/server/src/bridge/bridge.ts) (Local bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent["Agent control"]
  node_cli["Server CLI<br/>operational entry<br/>[cli.ts]"]
  node_mcp["MCP server<br/>agent protocol<br/>[mcp.ts]"]
  node_tools["Tool dispatcher<br/>server tools<br/>[tools.ts]"]
end

subgraph group_instrumentation["In-app instrumentation"]
  node_target["Target app runtime<br/>development app"]
  node_browser_sdk["Browser SDK<br/>embedded SDK<br/>[reticle.ts]"]
  node_observers["Observers<br/>browser capture<br/>[install-all.ts]"]
  node_transport["Browser transport<br/>event stream<br/>[transport.ts]"]
end

subgraph group_local["Local runtime"]
  node_bridge{{"Local bridge<br/>HTTP/WebSocket bridge<br/>[bridge.ts]"}}
  node_daemon["Daemon<br/>local coordinator<br/>[daemon.ts]"]
  node_sessions["Session manager<br/>live session control<br/>[session-manager.ts]"]
  node_project_store[("Project store<br/>local persistence<br/>[project-store.ts]")]
  node_browser_pool["Browser pool<br/>Playwright automation<br/>[browser-pool.ts]"]
end

subgraph group_verification["Verification and flows"]
  node_actions["Action tools<br/>session actions<br/>[act-tools.ts]"]
  node_predicate["Predicate evaluation<br/>evidence evaluation<br/>[predicate-eval.ts]"]
  node_honesty["Honesty and coverage<br/>verdict guard<br/>[honesty.ts]"]
  node_consequence["Consequence diagnostics<br/>core evidence model<br/>[consequence.ts]"]
  node_flows["Recorded flows<br/>flow engine<br/>[flow-replay.ts]"]
end

subgraph group_integrations["Integrations"]
  node_framework["Framework adapters<br/>build integration<br/>[index.ts]"]
  node_react["React attribution<br/>React SDK<br/>[cdp-reader.ts]"]
  node_desktop["Desktop adapters<br/>Electron/Tauri IPC<br/>[main.cjs]"]
end

subgraph group_delivery["Optional services and validation"]
  node_cloud["Cloud and telemetry<br/>optional external services<br/>[cloud-sync.ts]"]
  node_e2e["E2E harness<br/>delivery validation<br/>[run.mjs]"]
end

node_cli -->|"manages"| node_daemon
node_cli -->|"launches"| node_mcp
node_mcp -->|"dispatches requests"| node_tools
node_tools -->|"invokes"| node_actions
node_framework -->|"injects/connects"| node_browser_sdk
node_react -->|"augments evidence"| node_browser_sdk
node_browser_sdk -->|"runs in"| node_target
node_browser_sdk -->|"installs"| node_observers
node_observers -->|"emits events"| node_transport
node_transport -->|"localhost stream"| node_bridge
node_daemon -->|"hosts"| node_bridge
node_daemon -->|"coordinates"| node_sessions
node_daemon -->|"persists locally"| node_project_store
node_actions -->|"targets selected session"| node_sessions
node_sessions -->|"queues commands"| node_bridge
node_bridge -->|"mediates control"| node_browser_sdk
node_sessions -->|"supplies action windows"| node_predicate
node_predicate -->|"evaluates verdict safety"| node_honesty
node_honesty -->|"returns evidence diagnostics"| node_consequence
node_flows -->|"replays actions"| node_actions
node_flows -->|"replays assertions"| node_predicate
node_flows -->|"stores runs and journals"| node_project_store
node_browser_pool -.->|"provides managed contexts"| node_sessions
node_desktop -->|"IPC integration"| node_bridge
node_daemon -.->|"optional sync and telemetry"| node_cloud
node_e2e -.->|"validates"| node_daemon

click node_cli "https://github.com/reticlehq/reticle/blob/main/packages/server/src/cli.ts"
click node_mcp "https://github.com/reticlehq/reticle/blob/main/packages/server/src/mcp/mcp.ts"
click node_tools "https://github.com/reticlehq/reticle/blob/main/packages/server/src/tools/tools.ts"
click node_browser_sdk "https://github.com/reticlehq/reticle/blob/main/packages/browser/src/reticle.ts"
click node_observers "https://github.com/reticlehq/reticle/blob/main/packages/browser/src/observers/install-all.ts"
click node_transport "https://github.com/reticlehq/reticle/blob/main/packages/browser/src/transport/transport.ts"
click node_framework "https://github.com/reticlehq/reticle/blob/main/packages/vite-plugin/src/index.ts"
click node_react "https://github.com/reticlehq/reticle/blob/main/packages/react/src/cdp-reader.ts"
click node_bridge "https://github.com/reticlehq/reticle/blob/main/packages/server/src/bridge/bridge.ts"
click node_daemon "https://github.com/reticlehq/reticle/blob/main/packages/server/src/daemon/daemon.ts"
click node_sessions "https://github.com/reticlehq/reticle/blob/main/packages/server/src/session/session-manager.ts"
click node_project_store "https://github.com/reticlehq/reticle/blob/main/packages/server/src/project/project-store.ts"
click node_actions "https://github.com/reticlehq/reticle/blob/main/packages/server/src/tools/act-tools.ts"
click node_predicate "https://github.com/reticlehq/reticle/blob/main/packages/server/src/events/predicate-eval.ts"
click node_honesty "https://github.com/reticlehq/reticle/blob/main/packages/server/src/honesty/honesty.ts"
click node_consequence "https://github.com/reticlehq/reticle/blob/main/packages/core/src/consequence.ts"
click node_flows "https://github.com/reticlehq/reticle/blob/main/packages/server/src/flows/flow-replay.ts"
click node_browser_pool "https://github.com/reticlehq/reticle/blob/main/packages/server/src/pool/browser-pool.ts"
click node_desktop "https://github.com/reticlehq/reticle/blob/main/packages/electron/main.cjs"
click node_cloud "https://github.com/reticlehq/reticle/blob/main/packages/server/src/cloud/cloud-sync.ts"
click node_e2e "https://github.com/reticlehq/reticle/blob/main/apps/e2e/run.mjs"

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_cli,node_mcp,node_tools toneBlue
class node_target,node_browser_sdk,node_observers,node_transport toneAmber
class node_bridge,node_daemon,node_sessions,node_project_store,node_browser_pool toneMint
class node_actions,node_predicate,node_honesty,node_consequence,node_flows toneRose
class node_framework,node_react,node_desktop toneIndigo
class node_cloud,node_e2e toneTeal
```

## Components

### Agent control

- [Server CLI](https://github.com/reticlehq/reticle/blob/main/packages/server/src/cli.ts): operational entry · Starts and manages the local daemon. · `packages/server/src/cli.ts`
- [MCP server](https://github.com/reticlehq/reticle/blob/main/packages/server/src/mcp/mcp.ts): agent protocol · `packages/server/src/mcp/mcp.ts`
- [Tool dispatcher](https://github.com/reticlehq/reticle/blob/main/packages/server/src/tools/tools.ts): server tools · `packages/server/src/tools/tools.ts`

### In-app instrumentation

- **Target app runtime**: development app · The instrumented browser or desktop application.
- [Browser SDK](https://github.com/reticlehq/reticle/blob/main/packages/browser/src/reticle.ts): embedded SDK · Development-only observation and control boundary. · `packages/browser/src/reticle.ts`
- [Observers](https://github.com/reticlehq/reticle/blob/main/packages/browser/src/observers/install-all.ts): browser capture · Captures DOM, network, console, routing, storage, state, and behavior. · `packages/browser/src/observers/install-all.ts`
- [Browser transport](https://github.com/reticlehq/reticle/blob/main/packages/browser/src/transport/transport.ts): event stream · Streams bounded structured events to localhost. · `packages/browser/src/transport/transport.ts`

### Local runtime

- [Local bridge](https://github.com/reticlehq/reticle/blob/main/packages/server/src/bridge/bridge.ts): HTTP/WebSocket bridge · Authenticates browser connections and mediates commands. · `packages/server/src/bridge/bridge.ts`
- [Daemon](https://github.com/reticlehq/reticle/blob/main/packages/server/src/daemon/daemon.ts): local coordinator · Owns lifecycle, ports, heartbeats, and multi-project coordination. · `packages/server/src/daemon/daemon.ts`
- [Session manager](https://github.com/reticlehq/reticle/blob/main/packages/server/src/session/session-manager.ts): live session control · Maintains leases, command queues, observed state, and health. · `packages/server/src/session/session-manager.ts`
- [Project store](https://github.com/reticlehq/reticle/blob/main/packages/server/src/project/project-store.ts): local persistence · Persists project, run, and journal artifacts. · `packages/server/src/project/project-store.ts`
- [Browser pool](https://github.com/reticlehq/reticle/blob/main/packages/server/src/pool/browser-pool.ts): Playwright automation · Provides launched or managed browser contexts when needed. · `packages/server/src/pool/browser-pool.ts`

### Verification and flows

- [Action tools](https://github.com/reticlehq/reticle/blob/main/packages/server/src/tools/act-tools.ts): session actions · Executes navigate, input, click, query, and observe actions. · `packages/server/src/tools/act-tools.ts`
- [Predicate evaluation](https://github.com/reticlehq/reticle/blob/main/packages/server/src/events/predicate-eval.ts): evidence evaluation · Reconciles action windows across captured evidence. · `packages/server/src/events/predicate-eval.ts`
- [Honesty and coverage](https://github.com/reticlehq/reticle/blob/main/packages/server/src/honesty/honesty.ts): verdict guard · Prevents unobservable or unsettled conditions from silently passing. · `packages/server/src/honesty/honesty.ts`
- [Consequence diagnostics](https://github.com/reticlehq/reticle/blob/main/packages/core/src/consequence.ts): core evidence model · Carries source evidence and consequence diagnostics with verdicts. · `packages/core/src/consequence.ts`
- [Recorded flows](https://github.com/reticlehq/reticle/blob/main/packages/server/src/flows/flow-replay.ts): flow engine · Records assertions and deterministically compiles or replays flows. · `packages/server/src/flows/flow-replay.ts`

### Integrations

- [Framework adapters](https://github.com/reticlehq/reticle/blob/main/packages/vite-plugin/src/index.ts): build integration · Vite and Next inject/connect the SDK outside production builds. · `packages/vite-plugin/src/index.ts`
- [React attribution](https://github.com/reticlehq/reticle/blob/main/packages/react/src/cdp-reader.ts): React SDK · Adds commit/store evidence and fiber-to-source mapping. · `packages/react/src/cdp-reader.ts`
- [Desktop adapters](https://github.com/reticlehq/reticle/blob/main/packages/electron/main.cjs): Electron/Tauri IPC · Crosses renderer/main-process or Rust IPC boundaries. · `packages/electron/main.cjs`

### Optional services and validation

- [Cloud and telemetry](https://github.com/reticlehq/reticle/blob/main/packages/server/src/cloud/cloud-sync.ts): optional external services · Isolated sync, telemetry, feedback, licensing, and update concerns. · `packages/server/src/cloud/cloud-sync.ts`
- [E2E harness](https://github.com/reticlehq/reticle/blob/main/apps/e2e/run.mjs): delivery validation · Exercises daemon, MCP, replay, desktop, and transport-fault paths. · `apps/e2e/run.mjs`

## Connections

- Server CLI → Daemon: manages
- Server CLI → MCP server: launches
- MCP server → Tool dispatcher: dispatches requests
- Tool dispatcher → Action tools: invokes
- Framework adapters → Browser SDK: injects/connects
- React attribution → Browser SDK: augments evidence
- Browser SDK → Target app runtime: runs in
- Browser SDK → Observers: installs
- Observers → Browser transport: emits events
- Browser transport → Local bridge: localhost stream
- Daemon → Local bridge: hosts
- Daemon → Session manager: coordinates
- Daemon → Project store: persists locally
- Action tools → Session manager: targets selected session
- Session manager → Local bridge: queues commands
- Local bridge → Browser SDK: mediates control
- Session manager → Predicate evaluation: supplies action windows
- Predicate evaluation → Honesty and coverage: evaluates verdict safety
- Honesty and coverage → Consequence diagnostics: returns evidence diagnostics
- Recorded flows → Action tools: replays actions
- Recorded flows → Predicate evaluation: replays assertions
- Recorded flows → Project store: stores runs and journals
- Browser pool → Session manager: provides managed contexts
- Desktop adapters → Local bridge: IPC integration
- Daemon → Cloud and telemetry: optional sync and telemetry
- E2E harness → Daemon: validates
