Skip to content

Architecture

unohee edited this page Apr 16, 2026 · 1 revision

Architecture

System Overview

                         ┌──────────────────────────┐
                         │       Linear API          │
                         │   (issues, state, memory) │
                         └─────────────┬────────────┘
                                       │
                 ┌─────────────────────┼─────────────────────┐
                 │                     │                     │
                 v                     v                     v
  ┌──────────────────┐  ┌──────────────────┐  ┌──────────────────┐
  │ AutonomousRunner │  │  DecisionEngine  │  │  TaskScheduler   │
  │ (heartbeat loop) │─>│  (scope guard)   │─>│  (queue + slots) │
  └────────┬─────────┘  └──────────────────┘  └────────┬─────────┘
           │                                            │
           v                                            v
  ┌──────────────────────────────────────────────────────────────┐
  │                      PairPipeline                            │
  │  ┌────────┐   ┌──────────┐   ┌────────┐   ┌─────────────┐  │
  │  │ Worker │──>│ Reviewer │──>│ Tester │──>│ Documenter  │  │
  │  │(Adapter│<──│(Adapter) │   │(Adapter│   │  (Adapter)  │  │
  │  └───┬────┘   └──────────┘   └────────┘   └─────────────┘  │
  │      │  ↕ StuckDetector                                      │
  │  ┌───┴────────────────────────────────────────────────────┐  │
  │  │ Adapters: Claude | Codex | GPT | Local (Ollama/LMS)   │  │
  │  └────────────────────────────────────────────────────────┘  │
  └──────────────────────────────────────────────────────────────┘
           │                     │                     │
           v                     v                     v
  ┌──────────────┐  ┌──────────────────┐  ┌──────────────────┐
  │  Discord Bot │  │  Memory (LanceDB │  │  Knowledge Graph │
  │  (commands)  │  │  + Xenova E5)    │  │  (code analysis) │
  └──────────────┘  └──────────────────┘  └────────┬─────────┘
                                                    │
                                           ┌────────┴─────────┐
                                           │  Code Registry   │
                                           │  (SQLite + FTS5) │
                                           │  + BS Detector   │
                                           └──────────────────┘

Pipeline Flow

Linear (Todo/In Progress)
  → Fetch assigned issues
  → DecisionEngine filters & prioritizes
  → Resolve project path via projectMapper
  → PairPipeline.run()
    → Draft Analyzer (Haiku: intent + codebase state)
    → Worker generates code (via adapter)
    → Reviewer evaluates (APPROVE / REVISE / REJECT)
    → Loop up to N iterations
    → Optional: Tester → Documenter stages
  → Update Linear issue state (Done / Blocked)
  → Report to Discord
  → Save to cognitive memory

Core Components

AutonomousRunner

Cron-driven heartbeat loop that:

  1. Fetches Linear issues assigned to the team
  2. Filters through DecisionEngine (scope, priority, rate limits)
  3. Dispatches tasks to PairPipeline
  4. Reports results to Discord and updates Linear

DecisionEngine

Guards against:

  • Out-of-scope tasks
  • Rate limit violations (5-hour rolling window)
  • Too many concurrent tasks
  • Tasks on non-allowed projects

PairPipeline

The core execution unit. Configurable stages:

Stage Role Description
Worker Code generation Writes code to solve the task
Reviewer Quality check APPROVE, REVISE (with feedback), or REJECT
Tester Test execution Runs test suite, reports failures
Documenter Documentation Updates docs for changed code
Auditor Security audit Scans for security issues

Each stage uses an Adapter (Claude, Codex, GPT, or Local) and can have its own model configuration.

Draft Analyzer

Pre-analysis step using a cheap model (Haiku) before the main pipeline:

  • Classifies task intent
  • Collects Code Registry state for affected files
  • Runs Knowledge Graph impact analysis
  • Result is shared with Planner and Worker to avoid redundant searches

StuckDetector

Monitors Worker iterations for:

  • Repeating the same error
  • No progress between iterations
  • Token budget exhaustion

Triggers escalation to a more capable model or halts the pipeline.


Adapter Model

All adapters implement the CliAdapter interface:

interface CliAdapter {
  name: AdapterName;              // 'claude' | 'codex' | 'gpt' | 'local'
  run(options: CliRunOptions): Promise<CliResult>;
  isAvailable(): Promise<boolean>;
}
Adapter Execution Method Auth
Claude Claude Code CLI (claude -p) CLI auth
Codex OpenAI Codex CLI (codex exec) CLI auth
GPT OpenAI API (HTTP fetch) + agentic tool loop OAuth PKCE
Local Local server API (HTTP fetch) + agentic tool loop None

GPT and Local adapters use an agentic tool loop: they can call read_file, write_file, edit_file, search_files, and bash tools autonomously until the task is complete.


Project Structure

src/
├── index.ts                 # Entry point
├── cli.ts                   # CLI command definitions
├── cli/                     # CLI subcommand handlers
├── core/                    # Config, service lifecycle, types, event hub
├── adapters/                # CLI provider adapters + agentic loop
│   ├── claude.ts            # Claude Code CLI adapter
│   ├── codex.ts             # OpenAI Codex CLI adapter
│   ├── gpt.ts               # OpenAI GPT API adapter
│   ├── local.ts             # Local model adapter (Ollama/LMStudio/llama.cpp)
│   ├── agenticLoop.ts       # Agentic tool loop engine
│   └── tools.ts             # Tool definitions + executor
├── agents/                  # Worker, reviewer, tester, documenter, auditor
│   ├── pairPipeline.ts      # Worker → Reviewer → Tester → Documenter pipeline
│   ├── draftAnalyzer.ts     # Haiku-based pre-analysis
│   ├── agentBus.ts          # Inter-agent message bus
│   └── cliStreamParser.ts   # Claude CLI output parser
├── orchestration/           # Decision engine, task parser, scheduler
├── automation/              # Autonomous runner, cron scheduler, PR processor
├── memory/                  # LanceDB + Xenova embeddings cognitive memory
├── knowledge/               # Code knowledge graph (scanner, analyzer, graph)
├── registry/                # Code entity registry, BS detector, entity scanner
├── issues/                  # Local issue tracker (SQLite + GraphQL + Kanban UI)
├── discord/                 # Bot core, command handlers, pair session UI
├── linear/                  # Linear SDK wrapper, project updater
├── github/                  # GitHub CLI wrapper for CI monitoring
├── support/                 # Web dashboard, planner, rollback, git tools
├── locale/                  # i18n (en/ko) with prompt templates
└── __tests__/               # Vitest test suite

Tech Stack

Category Technology
Runtime Node.js 22+ (ESM)
Language TypeScript (strict mode)
Build tsc
Agent Execution Claude Code, OpenAI GPT/Codex, Ollama/LMStudio/llama.cpp
Local DB better-sqlite3 (WAL mode, FTS5)
Task Management Linear SDK
Communication Discord.js 14
Vector DB LanceDB + Apache Arrow
Embeddings Xenova/transformers (multilingual-e5-base, 768D)
Scheduling Croner
Config YAML + Zod validation
Linting oxlint
Testing Vitest

Clone this wiki locally