Integrating Cartographer as a static-linked CGo dependency transforms CKB from a symbol-level indexer into a "Total Code Intelligence Engine" that understands both microscopic (symbols) and macroscopic (architecture) code structure.
- Problem: CKB sends full source to LLMs (5,000+ tokens/file)
- Solution: Cartographer's skeleton extraction (200-500 tokens/file)
- Impact: 5x faster AI responses, significantly lower LLM costs
- Applies to: All 80+ MCP tools that send code to AI
- Layer Enforcement: Prevents violations like UI → DB direct access via layers.toml
- Health Monitoring: Continuous 0-100 architectural health score
- God Module Detection: Identifies overly connected components early
- Impact Prediction: Forecasts architectural consequences of changes before they're made
- Codebase Mapping: 14x faster (0.15s vs 2.1s per 1000 files)
- Impact Analysis: 19x faster (45ms vs 850ms per query)
- Architectural Health Check: New capability (120ms/query)
CKB Go Code → [CGo Bridge] → Cartographer Static Library (libcartographer.a)
↓
[Rust: petgraph + regex + layers.toml]
- Build Cartographer:
cargo build --releasefor each platform - Link Static Library: Go compiler links
libcartographer.aduring standardgo build - Distribute: Single
ckbbinary per platform via existing npm packages - No Runtime Dependencies: Zero IPC, no services to manage
cartographer_map_project- Full dependency graphcartographer_health- Architectural health score and metricscartographer_check_layers- Validate against layers.toml configcartographer_simulate_change- Predict impact of modifying a modulecartographer_skeleton_map- Token-optimized view for LLMscartographer_module_context- Single module + dependencies
// NEW: Layer violation check
violations, err := cartographer.CheckLayers(repoPath, ".cartographer/layers.toml")
if len(violations) > 0 {
return fmt.Errorf("ARCHITECTURAL VIOLATION: %v", violations)
}
// NEW: Health impact analysis
healthBefore, _ := cartographer.Health(repoPath)
// Apply changes in sandbox...
healthAfter, _ := cartographer.Health(repoPoint)
if healthAfter.HealthScore < healthBefore.HealthScore - 10 {
return fmt.Errorf("PR degrades health by %.1f points",
healthBefore.HealthScore - healthAfter.HealthScore)
}// Example: get_module_context - now token efficient
func GetModuleContext(ctx context.Context, req *GetModuleContextRequest) (*GetModuleContextResponse, error) {
// USE CARTOGRAPHER'S SKELETON INSTEAD OF FULL SOURCE
skel, err := cartographer.SkeletonMap(req.Path, "standard")
// ... get impact analysis ...
return &GetModuleContextResponse{
Skeleton: skel, // 90% fewer tokens sent to LLM
Impact: impact, // Predictive analysis
}, nil
}- FFI Complexity: Simple JSON-over-string interface
- Memory Management: Clear ownership (caller frees Rust-allocated strings)
- Build Complexity: Already solving cross-compilation for npm packages
- Failure Mode: Build-time error if Cartographer fails (clear and early)
- Development Effort: ~2-3 weeks (wiring integration points)
- Performance Gain: 5-20x for key operations
- Feature Gain: 3+ unique capabilities
- User Impact: Immediate (faster AI, better code quality)
No existing tool offers this combination:
- LSIF/SCIP tools: Symbol-level only, no architecture
- LSP-based tools: Symbol-level only, slow for large codebases
- Architecture tools: Manual diagrams, not code-coupled
- Git-based analysis: Historical coupling, not predictive
CKB + Cartographer becomes the only tool that:
- Understands every symbol (like traditional tools)
- Understands architectural layers and dependencies (unique)
- Provides token-efficient context for AI tools (critical for LLMs)
- Predicts impact before changes are made (preventive)
- Enforces architectural rules automatically (governance)
This integration is a qualitative leap in CKB's capabilities. By combining symbol-level precision with architectural awareness, CKB becomes indispensable for:
- AI-assisted development: Efficient, accurate context for LLMs
- Architectural integrity: Prevents decay, enforces intentional design
- Developer productivity: Catches issues before code review
- Technical excellence: Makes architectural health a first-class metric
The result is a tool that doesn't just analyze code—it understands and helps maintain the intent behind the code.