Overview
Loom is built as an Elixir OTP application with a modular, supervised architecture. Each component runs as a process under a supervision tree, ensuring fault tolerance and isolated state management.System Components
The application initializes the following core components in order:Storage Layer
Configuration
Event Broadcasting
session:#{session_id}- Session-specific events (messages, tool execution, status changes)repo:updates- Repository file change notifications
Session Registry
:idle, :thinking, :executing_tool).
LSP Server Management
Repository Intelligence
Session Management
Optional Services
Loom conditionally starts services based on configuration:- File Watcher (
Loom.RepoIntel.Watcher) - OS-level file change monitoring with.gitignoresupport - MCP Server - Model Context Protocol server for external tool integrations
- MCP Clients - Connections to external MCP servers
- Web Endpoint (
LoomWeb.Endpoint) - Phoenix LiveView interface
Architecture Diagram
Process Supervision Strategy
Loom uses a one-for-one supervision strategy:- If a session crashes, only that session restarts
- Other sessions continue running unaffected
- The repo index and config remain stable
- The system maintains high availability
Fault Isolation: Each session runs in its own process. A crash in Session A (e.g., a buggy tool execution) won’t impact Session B.
Startup Flow
Symbol Cache Initialization
Tree-sitter symbol cache is initialized:
Loom.RepoIntel.TreeSitter.init_cache()Data Flow Example
Here’s how a typical user message flows through the system:Configuration System
Loom uses a hybrid configuration approach:Compile-Time Config
File:config/config.exs, config/runtime.exs
Runtime Config
Module:Loom.Config
Stored in ETS for fast access across processes:
State Management
Loom maintains state across several layers:| Layer | Storage | Persistence | Use Case |
|---|---|---|---|
| Session State | GenServer state | Temporary | Active conversation, pending tool calls |
| Database | PostgreSQL | Permanent | Sessions, messages, decision nodes |
| ETS Tables | In-memory | Temporary | File index, symbol cache, config |
| Registry | Registry | Temporary | Session PID lookup, status metadata |
Session state is not persisted between restarts. Only the message history and decision graph are saved to the database. When a session is resumed, it rebuilds its in-memory state from persisted data.
Extension Points
Loom’s architecture supports extension through:- Tools - Add new capabilities via Jido Actions
- MCP Servers - Connect external tools and data sources
- Decision Graph Nodes - Custom node types for domain-specific workflows
- RepoIntel Extractors - New language support for symbol extraction
Performance Characteristics
Concurrency
- Multiple sessions run in parallel - Each session is a separate Erlang process
- Tool execution is synchronous within a session - Tools execute one at a time per session
- File index operations are concurrent - Multiple sessions can read the index simultaneously (ETS read concurrency)
Memory Management
- Context window pruning - Old messages are automatically trimmed to fit model limits
- Symbol cache - Tree-sitter results are cached by file mtime
- Repo map generation - Ranked and budgeted to stay within token limits
Scalability
Loom is designed for single-user, multi-session workflows:- ✅ Run 10s of concurrent sessions on a laptop
- ✅ Handle large repositories (100k+ files) via incremental indexing
- ⚠️ Not designed for multi-tenant SaaS (no auth, isolation, or rate limiting)
Next Steps
Sessions
Learn how sessions manage the agent loop
Decision Graphs
Understand how decisions are tracked and injected
Repo Intelligence
Explore file indexing and symbol extraction
Context Window
See how context is budgeted and managed