This comprehensive refactoring addresses critical architectural issues: IMPORT CYCLE RESOLUTION: • pkg/crypto ↔ pkg/slurp/roles: Created pkg/security/access_levels.go • pkg/ucxl → pkg/dht: Created pkg/storage/interfaces.go • pkg/slurp/leader → pkg/election → pkg/slurp/storage: Moved types to pkg/election/interfaces.go MODULE PATH MIGRATION: • Changed from github.com/anthonyrawlins/bzzz to chorus.services/bzzz • Updated all import statements across 115+ files • Maintains compatibility while removing personal GitHub account dependency TYPE SYSTEM IMPROVEMENTS: • Resolved duplicate type declarations in crypto package • Added missing type definitions (RoleStatus, TimeRestrictions, KeyStatus, KeyRotationResult) • Proper interface segregation to prevent future cycles ARCHITECTURAL BENEFITS: • Build now progresses past structural issues to normal dependency resolution • Cleaner separation of concerns between packages • Eliminates circular dependencies that prevented compilation • Establishes foundation for scalable codebase growth 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
79 lines
1.9 KiB
Go
79 lines
1.9 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
|
|
"chorus.services/bzzz/pkg/dht"
|
|
"chorus.services/bzzz/pkg/ucxl"
|
|
)
|
|
|
|
func main() {
|
|
fmt.Println("Testing BZZZ Mock Implementation...")
|
|
|
|
// Test Mock DHT
|
|
ctx := context.Background()
|
|
mockDHT := dht.NewMockDHT()
|
|
|
|
// Test basic operations
|
|
key := "test-key"
|
|
value := []byte("test-value")
|
|
|
|
err := mockDHT.PutValue(ctx, key, value)
|
|
if err != nil {
|
|
log.Fatalf("Failed to put value: %v", err)
|
|
}
|
|
|
|
retrieved, err := mockDHT.GetValue(ctx, key)
|
|
if err != nil {
|
|
log.Fatalf("Failed to get value: %v", err)
|
|
}
|
|
|
|
if string(retrieved) != string(value) {
|
|
log.Fatalf("Retrieved value doesn't match: got %s, want %s", retrieved, value)
|
|
}
|
|
|
|
fmt.Println("✓ Mock DHT: Put/Get operations working")
|
|
|
|
// Test UCXL address parsing
|
|
addresses := []string{
|
|
"ucxl://agent-001:coordinator@bzzz:config/",
|
|
"ucxl://*:*@*:*/*^/",
|
|
"ucxl://test:role@project:task/path*~/",
|
|
}
|
|
|
|
for _, addr := range addresses {
|
|
parsed, err := ucxl.ParseUCXLAddress(addr)
|
|
if err != nil {
|
|
log.Fatalf("Failed to parse UCXL address %s: %v", addr, err)
|
|
}
|
|
|
|
if parsed.Raw != addr {
|
|
log.Fatalf("Parsed address doesn't match original: got %s, want %s", parsed.Raw, addr)
|
|
}
|
|
|
|
// Test round-trip
|
|
regenerated, err := ucxl.GenerateUCXLAddress(
|
|
parsed.Agent, parsed.Role, parsed.Project, parsed.Task, parsed.Path, parsed.Temporal,
|
|
)
|
|
if err != nil {
|
|
log.Fatalf("Failed to generate UCXL address: %v", err)
|
|
}
|
|
|
|
// Parse again to ensure consistency
|
|
_, err = ucxl.ParseUCXLAddress(regenerated)
|
|
if err != nil {
|
|
log.Fatalf("Failed to parse regenerated UCXL address: %v", err)
|
|
}
|
|
}
|
|
|
|
fmt.Println("✓ UCXL Parser: Address parsing and generation working")
|
|
|
|
// Test stats
|
|
stats := mockDHT.GetStats()
|
|
fmt.Printf("✓ Mock DHT Stats: %d keys, %d peers, %v latency\n",
|
|
stats.TotalKeys, stats.TotalPeers, stats.Latency)
|
|
|
|
fmt.Println("\n🎉 BZZZ Mock Implementation: All tests passed!")
|
|
} |