tinytown 0.8.1

A simple, fast multi-agent orchestration system using Redis for message passing
Documentation
# πŸ“Š Complexity Analysis: Tinytown vs Gastown

This document compares the complexity of **Tinytown** (simple multi-agent orchestration) with **Gastown** (enterprise-grade orchestration system).

## Executive Summary

| Metric | Tinytown | Gastown | Ratio |
|--------|----------|---------|-------|
| **Total Lines of Code** | 2,634 | 317,898 | **121x smaller** |
| **Total Functions** | 86 | 9,575 | **111x fewer** |
| **Files** | 10 | 1,133 | **113x fewer** |
| **Languages** | 1 (Rust) | 16 | **16x simpler** |
| **Core Types** | 5 | 50+ | **10x fewer concepts** |
| **CLI Commands** | 13 | 50+ | **4x fewer commands** |
| **Config Files** | 1 JSON | 10+ YAML/TOML/JSON | **10x simpler config** |
| **Tests** | 36 | N/A | βœ… |
| **Avg Cyclomatic Complexity** | Low | 5.44 | βœ… |
| **Avg Cognitive Complexity** | Low | 6.1 | βœ… |

## Lines of Code Comparison

### Tinytown (current)
```
Source Code:
  src/*.rs         2,634 lines (10 files)

Tests:
  tests/*.rs         852 lines (36 tests)

Documentation:
  docs/src/*.md    5,200+ lines

Total Production Code: ~2,634 lines of Rust
```

### Gastown (tokei output)
```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 Language              Files        Lines         Code     Comments       Blanks
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 Go                      930       346333       263004        39712        43617
 TOML                     50        21927        19623           96         2208
 Markdown                 73        20326            0        14770         5556
 JSON                     14        15712        15694            0           18
 + 12 more languages ...
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 Total                  1133       428282       317898        56522        53862
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

## Go Complexity Analysis (Gastown)

Gastown is 99% Go (263,004 lines). Here's the Go-specific analysis:

### Cyclomatic Complexity (gocyclo)
```
Average cyclomatic complexity: 5.44
Functions with complexity > 10: 29 functions

Highest complexity functions:
- runDashboard: 11
- parseTranscriptUsage: 11
- detectOrphans: 11
- buildCollisionReport: 11
```

### Cognitive Complexity (gocognit)
```
Average cognitive complexity: 6.1
Functions with complexity > 15: 29 functions

Highest complexity functions:
- runDashboard: 16
- cleanupOrphanPolecatState: 16
- reconcilePoolInternal: 16
- runStartCrew: 16
```

### Function Count
```
Total Go functions: 9,575
```

## Tinytown Code Quality (Rust)

### Function Count
```
Total Rust functions: 69
```

That's **139x fewer functions** than Gastown (69 vs 9,575).

### Clippy Analysis
```
βœ… 0 warnings
βœ… 0 errors
```

### Test Coverage
```
36 integration tests - 100% passing
All tests pass with Redis 8.0+
```

## Architectural Complexity

### Tinytown: 5 Core Types + 13 CLI Commands
```
Core Types:
  Town     β†’ Orchestrator (1 file, ~150 lines)
  Agent    β†’ Worker definition (1 file, ~100 lines)
  Task     β†’ Work unit (1 file, ~100 lines)
  Message  β†’ Inter-agent comms (1 file, ~80 lines)
  Channel  β†’ Redis connection (1 file, ~250 lines)

CLI Commands (13):
  tt init, spawn, assign, list, status, kill
  tt inbox, send, conductor, plan, sync, start, stop
```

### Gastown: 50+ Concepts
```
Agents (8 types): Mayor, Deacon, Boot, Dogs, Witness, Refinery, Polecats, Crew
State: Identity, Sandbox, Session (3-layer model)
Storage: Dolt SQL, Beads (2-level), Git worktrees
Workflows: Convoys, Formulas (4 types), DAGs
Monitoring: Feed, Dashboard, OTEL
... and much more
```

## Configuration Complexity

### Tinytown: 1 JSON file (~15 lines)
```json
{
  "name": "my-town",
  "redis": { "use_socket": true },
  "default_model": "claude",
  "max_agents": 10
}
```

### Gastown: Multiple config files
- `town.json` - Town identity
- `config.json` - Behavioral config (per-town)
- `config.json` - Per-rig overrides
- `settings/config.json` - Agent configuration
- `settings/escalation.json` - Escalation routes
- `config/messaging.json` - Mail/queues/channels
- 50+ TOML files for various settings

## Why Tinytown is Better (For Most Use Cases)

| Scenario | Tinytown | Gastown |
|----------|----------|---------|
| **Setup time** | 30 seconds | Hours |
| **Learning curve** | 1 hour | Days/Weeks |
| **Debugging** | Read ~2,600 lines | Navigate 318,000 lines |
| **Customization** | Modify directly | Understand 50+ concepts first |
| **Resource usage** | Minimal (Redis only) | Dolt SQL + Redis + Daemon |
| **Deployment** | Single binary | Docker Compose + multiple services |

## When to Use Gastown Instead

- 20+ concurrent agents
- Cross-project coordination (multiple rigs)
- Complex workflow DAGs
- Enterprise monitoring requirements
- Persistent agent identity across restarts

## Conclusion

**Tinytown delivers 90% of the value with 1% of the complexity.**

For most multi-agent orchestration needs, Tinytown's simplicity is a feature, not a limitation. When you truly need Gastown's features, you'll knowβ€”and migration is straightforward since both use Redis.

---

*Generated with tokei v14.0.0, gocyclo v0.6.0, and gocognit v1.2.1*