System architecture
Longshot’s architecture is built for massive parallelism and stateless execution. This page explains each component and how they interact.High-level architecture
Core components
Root planner
Location:packages/orchestrator/src/planner.ts
Purpose: Iterative LLM-driven task generation with continuous conversation and delta optimization.
Key responsibilities:
- Analyzes user request + repository state (SPEC.md, FEATURES.json, file tree)
- Creates granular tasks with descriptions, scope, acceptance criteria
- Maintains a continuous Pi agent session across planning iterations
- Adapts based on worker handoffs (minimum 3 handoffs trigger replan)
- Injects external tasks (conflict fixes, reconciler fixes)
previousFileTree: File tree sent in last promptpreviousFeaturesHash: Hash of FEATURES.json contentpreviousDecisionsHash: Hash of DECISIONS.md content
Subplanner
Location:packages/orchestrator/src/subplanner.ts
Purpose: Recursive task decomposer that breaks large tasks into worker-sized units.
Configuration:
Worker pool
Location:packages/orchestrator/src/worker-pool.ts
Purpose: Ephemeral sandbox spawner that creates Modal sandboxes for task execution.
Architecture: No persistent pool — each task spawns a fresh sandbox:
Merge queue
Location:packages/orchestrator/src/merge-queue.ts
Purpose: Serial merge pipeline with priority ordering, conflict retry, and automatic rebasing.
Queue structure:
-
Fast-forward (default for single-file changes):
-
Rebase (preserves linear history):
-
Merge commit (fallback):
Reconciler
Location:packages/orchestrator/src/reconciler.ts
Purpose: Periodic build and test reconciliation with LLM-generated fix tasks.
Sweep interval: Adaptive (1min when errors detected → 5min when green)
Sweep logic:
Monitor
Location:packages/orchestrator/src/monitor.ts
Purpose: Real-time metrics collection and snapshot generation.
Metrics tracked:
Package structure
Longshot is organized as a TypeScript monorepo with Python CLI wrapper:Stateless design
Longshot’s architecture is radically stateless:Workers
Ephemeral sandboxes — create, execute, terminate. No persistent pool, no session management.
State storage
Git is the only source of truth. Repository structure + branches = current state.
Orchestrator
Runs locally. No database, no Redis, no persistent queue. All state in memory.
Execution
Cloud sandboxes (Modal). Workers run remotely, orchestrator coordinates locally.
- No operational complexity: No databases, queues, or persistent services to manage
- Fault tolerance: Workers can fail independently without affecting others
- Cost efficiency: Sandboxes only run during task execution
- Audit trail: Git history provides complete execution audit
Next steps
How it works
Follow a request through the execution flow step-by-step
Configuration
Configure workers, LLM endpoints, and sandbox resources