The definitive navigation document for future coding agents
This document is your compass to the POLLN codebase. Read this first to understand where everything is and how it connects.
POLLN = Pattern-Organized Large Language Network
A system for decomposing LLMs into tiles - visible, inspectable, improvable AI components.
Traditional LLM: Black Box → Output
SMP Approach: [Tile] → [Tile] → [Tile] → Output
↑ ↑ ↑
visible inspectable improvable
polln/
│
├── src/ # ALL SOURCE CODE
│ ├── core/ # FOUNDATION - Read src/core/README.md
│ │ ├── types.ts # START HERE - All type definitions
│ │ ├── agent.ts # BaseAgent abstract class
│ │ ├── colony.ts # Colony manager
│ │ ├── dreaming.ts # Dream optimization
│ │ ├── worldmodel.ts # Predictive model
│ │ ├── kvanchor.ts # KV-Cache system
│ │ └── ... (many more) # See src/core/README.md
│ │
│ ├── agents/ # SPECIALIZED AGENTS - Read src/agents/README.md
│ │ ├── research.ts # ResearchAgent
│ │ ├── code.ts # CodeAgent
│ │ └── analysis.ts # AnalysisAgent
│ │
│ ├── coordination/ # STIGMERGY - Read src/coordination/README.md
│ │ └── stigmergy.ts # Pheromone coordination
│ │
│ ├── spreadsheet/ # SPREADSHEET SYSTEM
│ │ ├── tiles/ # Tiles - Read src/spreadsheet/tiles/README.md
│ │ ├── cells/ # Cells - Read src/spreadsheet/cells/README.md
│ │ └── backend/ # Backend - Read src/spreadsheet/backend/README.md
│ │
│ ├── api/ # WEBSOCKET API - Read src/api/README.md
│ ├── cli/ # CLI TOOL - Read src/cli/README.md
│ ├── benchmarking/ # BENCHMARKS - Read src/benchmarking/README.md
│ └── backup/ # BACKUP SYSTEM - Read src/backup/README.md
│
├── docs/ # DOCUMENTATION
│ └── research/smp-paper/ # SMP RESEARCH - Read docs/research/smp-paper/README.md
│
├── simulations/ # SIMULATIONS - Read simulations/README.md
│ ├── math/ # Mathematical simulations
│ ├── physics/ # Physics simulations
│ └── novel/ # Novel research simulations
│
└── scripts/ # UTILITY SCRIPTS
- Read this file (CODE_GUIDE.md) - You're doing it now
- Read CLAUDE.md - Project context and mission
- Read src/core/types.ts - All type definitions
- Read src/core/README.md - Core system overview
- Pick a subsystem - tiles, agents, coordination
- Identify the file - Use grep or search
- Read the directory README - Each folder has one
- Check tests - Look in
__tests__/subdirectories - Understand dependencies - What else uses this code?
- Find similar features - Pattern match existing code
- Read the subsystem README - Understand the domain
- Check types.ts - Add new types there
- Write tests first - In corresponding
__tests__/
The fundamental unit of intelligence.
// A Tile is a tuple:
Tile = (I, O, f, c, τ)
// I = Input schema
// O = Output schema
// f = discriminate function
// c = confidence function
// τ = trace functionSee: src/spreadsheet/tiles/README.md
Autonomous reasoning units that use tiles.
// Agent hierarchy:
BaseAgent (abstract)
├── TaskAgent (EPHEMERAL) - Born, execute, die
├── RoleAgent (ROLE) - Long-running, stateful
└── CoreAgent (CORE) - Always-on, criticalSee: src/core/README.md and src/agents/README.md
Collections of agents managed together.
Colony {
agents: Map<string, AgentState>
registerAgent(config)
unregisterAgent(id)
getStats()
}See: src/core/colony.ts
Caching system for LLM contexts.
// Anchors cache reusable context
KVAnchor {
prefix: string
kvCache: cachedState
embedding: number[]
}See: src/core/kvanchor.ts
Coordination through environmental signals.
// Pheromone types
PATHWAY - "Good path found"
RESOURCE - "Useful data here"
DANGER - "Avoid this"
NEST - "Central point"
RECRUIT - "Help needed"See: src/coordination/README.md
All important types are in src/core/types.ts:
// Agent configuration
interface AgentConfig {
id: string;
typeId: string;
categoryId: string;
modelFamily: string;
inputTopics: string[];
outputTopic: string;
}
// Agent runtime state
interface AgentState {
id: string;
status: 'dormant' | 'active' | 'hibernating' | 'error';
valueFunction: number; // Success rate 0-1
successCount: number;
failureCount: number;
}
// Agent-to-agent communication
interface A2APackage<T> {
id: string;
senderId: string;
receiverId: string;
type: string;
payload: T;
parentIds: string[]; // Causal chain
privacyLevel: PrivacyLevel;
layer: SubsumptionLayer;
}
// Privacy levels
enum PrivacyLevel {
PUBLIC = 'PUBLIC',
COLONY = 'COLONY',
PRIVATE = 'PRIVATE'
}
// Subsumption layers (Rodney Brooks architecture)
enum SubsumptionLayer {
SAFETY = 'SAFETY', // Immediate, hardwired
REFLEX = 'REFLEX', // Fast, cached
HABITUAL = 'HABITUAL', // Learned routines
DELIBERATE = 'DELIBERATE' // Planning, reasoning
}import { TaskAgent } from './core/agents';
const agent = new TaskAgent({
id: 'task-001',
typeId: 'sentiment',
categoryId: 'nlp',
modelFamily: 'smallml',
inputTopics: ['text'],
outputTopic: 'sentiment'
});
await agent.initialize();
const result = await agent.process(input);
await agent.shutdown();import { TileChain } from './spreadsheet/tiles/core/TileChain';
const chain = new TileChain()
.pipe(tokenizerTile)
.pipe(sentimentTile)
.pipe(confidenceTile);
const result = await chain.execute(input);import { KVAnchorPool } from './core/kvanchor';
const pool = new KVAnchorPool({ maxSize: 1000 });
const anchor = pool.createAnchor({
prefix: 'system-prompt',
kvCache: cachedState
});import { Stigmergy, PheromoneType } from './coordination';
const stigmergy = new Stigmergy();
// Leave a trail
stigmergy.deposit({
type: PheromoneType.PATHWAY,
sourceId: 'agent-001',
position: { taskType: 'sentiment' }
});
// Follow trails
const trails = stigmergy.sense({ taskType: 'sentiment' });npm test# Core tests
npm test -- --testPathPattern=core
# Tile tests
npm test -- --testPathPattern=tiles
# Agent tests
npm test -- --testPathPattern=agentsEach module has tests in __tests__/:
src/
├── core/
│ └── __tests__/
│ ├── agents.test.ts
│ ├── colony.test.ts
│ └── ...
├── agents/
│ └── __tests__/
│ └── research.test.ts
└── spreadsheet/tiles/
└── tests/
└── integration.test.ts
Current status: 82 errors remaining
Most errors are in:
src/spreadsheet/ui/- React components- Feature flag panel
To fix:
# Check errors
npx tsc --noEmit
# Fix specific file
# Edit the file based on error message| File | Purpose | Lines |
|---|---|---|
src/core/types.ts |
ALL type definitions | ~200 |
src/core/agent.ts |
BaseAgent class | ~150 |
src/core/colony.ts |
Colony manager | ~200 |
src/spreadsheet/tiles/core/Tile.ts |
Tile interface | ~100 |
src/coordination/stigmergy.ts |
Pheromone system | ~300 |
┌─────────────────────────────────────────────────────────────────────┐
│ USER │
│ │ │
│ ▼ │
│ ┌─────────────┐ │
│ │ API │ WebSocket / REST │
│ └─────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────┐ │
│ │ Colony │ Agent Collection │
│ └─────────────┘ │
│ │ │
│ ┌──────────────────┼──────────────────┐ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Agents │ │ Tiles │ │ Coordination│ │
│ │ (reasoning) │ │ (compute) │ │ (stigmergy) │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │ │ │ │
│ └──────────────────┼──────────────────┘ │
│ ▼ │
│ ┌─────────────┐ │
│ │ KV-Cache │ Context reuse │
│ └─────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────┐ │
│ │ World Model │ Predictions │
│ └─────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────┐ │
│ │ Dreaming │ Offline optimization │
│ └─────────────┘ │
└─────────────────────────────────────────────────────────────────────┘
- Explore: Pick a subsystem and read its README
- Build: Fix TypeScript errors or add features
- Test: Run tests to verify your changes
- Document: Update READMEs if you change behavior
Part of POLLN - Pattern-Organized Large Language Network SuperInstance.AI | MIT License
Last Updated: 2026-03-10