Loom Architecture
System Overview
Core Components
1. Orchestrator
The main loop that drives the orchestration:- Gets ready tasks from Beads
- Scores and ranks them
- Claims the top task
- Delegates work to agents
- Closes completed tasks
- Repeats until interrupted
internal/orchestrator/orchestrator.go
2. Task Scorer
Implements AI-driven task prioritization:- Blocking impact: Tasks that unblock others
- Priority level: P0/P1 tasks get boosted
- Staleness: Tasks open too long
- Failure history: Previously failed tasks penalized
internal/scorer/scorer.go
3. Hook Engine
Manages lifecycle hooks that inject behavior at key points:| Hook | When |
|---|---|
pre-prompt | Before LLM processes prompt |
pre-tool-call | Before tool execution |
post-tool-call | After tool execution |
post-response | After agent response |
on-error | On task failure |
on-claim | On task claim |
pre-close | Before task close |
on-block | When task becomes blocked |
internal/hooks/engine.go
4. Multi-Agent Coordinator
Enables safe parallel work:- File-level locking
- Conflict detection
- Lock expiration
- Automatic cleanup
internal/coordinator/coordinator.go
5. Retrospective Store
Captures learning from sessions:- Task completion/failure tracking
- Pattern extraction
- Global knowledge sharing
- Failure history for scoring
internal/retrospective/store.go
6. Memory Manager
Intelligent context management:- Tracks context usage
- Triggers compaction at threshold
- Importance-weighted retention
- Preserves critical context
internal/memory/manager.go
7. Safety Guard
Protects against dangerous operations:- Blocks destructive commands (rm -rf, git push βforce)
- Requires confirmation for risky operations
- Maintains approval cache
- Configurable patterns
internal/safety/guard.go
8. Beads Client
CLI wrapper for Beads commands:bd ready --json- Get ready tasksbd show <id> --json- Get task detailsbd update <id> --claim- Claim taskbd close <id>- Close taskbd compact- Run compaction
internal/beadsclient/client.go