Resolve import cycles and migrate to chorus.services module path

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>
This commit is contained in:
anthonyrawlins
2025-08-17 10:04:25 +10:00
parent e9252ccddc
commit d96c931a29
115 changed files with 1010 additions and 534 deletions

View File

@@ -11,10 +11,10 @@ import (
// HybridConfig manages feature flags and configuration for Phase 2 hybrid mode
type HybridConfig struct {
// DHT Configuration
DHT DHTConfig `json:"dht" yaml:"dht"`
DHT HybridDHTConfig `json:"dht" yaml:"dht"`
// UCXL Configuration
UCXL UCXLConfig `json:"ucxl" yaml:"ucxl"`
UCXL HybridUCXLConfig `json:"ucxl" yaml:"ucxl"`
// Discovery Configuration
Discovery DiscoveryConfig `json:"discovery" yaml:"discovery"`
@@ -23,7 +23,7 @@ type HybridConfig struct {
Monitoring MonitoringConfig `json:"monitoring" yaml:"monitoring"`
}
type DHTConfig struct {
type HybridDHTConfig struct {
Backend string `env:"BZZZ_DHT_BACKEND" default:"mock" json:"backend" yaml:"backend"`
BootstrapNodes []string `env:"BZZZ_DHT_BOOTSTRAP_NODES" json:"bootstrap_nodes" yaml:"bootstrap_nodes"`
FallbackOnError bool `env:"BZZZ_FALLBACK_ON_ERROR" default:"true" json:"fallback_on_error" yaml:"fallback_on_error"`
@@ -33,7 +33,7 @@ type DHTConfig struct {
OperationTimeout time.Duration `env:"BZZZ_DHT_OPERATION_TIMEOUT" default:"10s" json:"operation_timeout" yaml:"operation_timeout"`
}
type UCXLConfig struct {
type HybridUCXLConfig struct {
CacheEnabled bool `env:"BZZZ_UCXL_CACHE_ENABLED" default:"true" json:"cache_enabled" yaml:"cache_enabled"`
CacheTTL time.Duration `env:"BZZZ_UCXL_CACHE_TTL" default:"5m" json:"cache_ttl" yaml:"cache_ttl"`
UseDistributed bool `env:"BZZZ_UCXL_USE_DISTRIBUTED" default:"false" json:"use_distributed" yaml:"use_distributed"`
@@ -59,7 +59,7 @@ func LoadHybridConfig() (*HybridConfig, error) {
config := &HybridConfig{}
// Load DHT configuration
config.DHT = DHTConfig{
config.DHT = HybridDHTConfig{
Backend: getEnvString("BZZZ_DHT_BACKEND", "mock"),
BootstrapNodes: getEnvStringSlice("BZZZ_DHT_BOOTSTRAP_NODES", []string{}),
FallbackOnError: getEnvBool("BZZZ_FALLBACK_ON_ERROR", true),
@@ -70,7 +70,7 @@ func LoadHybridConfig() (*HybridConfig, error) {
}
// Load UCXL configuration
config.UCXL = UCXLConfig{
config.UCXL = HybridUCXLConfig{
CacheEnabled: getEnvBool("BZZZ_UCXL_CACHE_ENABLED", true),
CacheTTL: getEnvDuration("BZZZ_UCXL_CACHE_TTL", 5*time.Minute),
UseDistributed: getEnvBool("BZZZ_UCXL_USE_DISTRIBUTED", false),
@@ -105,7 +105,7 @@ func LoadHybridConfig() (*HybridConfig, error) {
func (c *HybridConfig) Validate() error {
// Validate DHT backend
validBackends := []string{"mock", "real", "hybrid"}
if !contains(validBackends, c.DHT.Backend) {
if !hybridContains(validBackends, c.DHT.Backend) {
return fmt.Errorf("invalid DHT backend '%s', must be one of: %v", c.DHT.Backend, validBackends)
}
@@ -192,7 +192,7 @@ func getEnvStringSlice(key string, defaultValue []string) []string {
return defaultValue
}
func contains(slice []string, item string) bool {
func hybridContains(slice []string, item string) bool {
for _, s := range slice {
if s == item {
return true
@@ -231,7 +231,7 @@ func (w *ConfigWatcher) Events() <-chan ConfigurationChangeEvent {
// UpdateDHTBackend changes the DHT backend at runtime
func (w *ConfigWatcher) UpdateDHTBackend(backend string) error {
validBackends := []string{"mock", "real", "hybrid"}
if !contains(validBackends, backend) {
if !hybridContains(validBackends, backend) {
return fmt.Errorf("invalid DHT backend '%s'", backend)
}