···
"Coves/internal/api/handlers/oauth"
"Coves/internal/api/middleware"
"Coves/internal/api/routes"
"Coves/internal/atproto/identity"
"Coves/internal/atproto/jetstream"
"Coves/internal/core/communities"
···
r.Use(rateLimiter.Middleware)
// Initialize identity resolver
+
// IMPORTANT: In dev mode, identity resolution MUST use the same local PLC
+
// directory as DID registration to ensure E2E tests work without hitting
+
// the production plc.directory
identityConfig := identity.DefaultConfig()
+
isDevEnv := os.Getenv("IS_DEV_ENV") == "true"
+
plcDirectoryURL := os.Getenv("PLC_DIRECTORY_URL")
+
if plcDirectoryURL == "" {
+
plcDirectoryURL = "https://plc.directory" // Default to production PLC
+
// In dev mode, use PLC_DIRECTORY_URL for identity resolution
+
// In prod mode, use IDENTITY_PLC_URL if set, otherwise PLC_DIRECTORY_URL
+
identityConfig.PLCURL = plcDirectoryURL
+
log.Printf("🧪 DEV MODE: Identity resolver will use local PLC: %s", plcDirectoryURL)
+
// Production: Allow separate IDENTITY_PLC_URL for read operations
+
if identityPLCURL := os.Getenv("IDENTITY_PLC_URL"); identityPLCURL != "" {
+
identityConfig.PLCURL = identityPLCURL
+
identityConfig.PLCURL = plcDirectoryURL
+
log.Printf("✅ PRODUCTION MODE: Identity resolver using PLC: %s", identityConfig.PLCURL)
if cacheTTL := os.Getenv("IDENTITY_CACHE_TTL"); cacheTTL != "" {
if duration, parseErr := time.ParseDuration(cacheTTL); parseErr == nil {
identityConfig.CacheTTL = duration
···
identityResolver := identity.NewResolver(db, identityConfig)
// Initialize OAuth session store
sessionStore := oauthCore.NewPostgresSessionStore(db)
···
communityRepo := postgresRepo.NewCommunityRepository(db)
+
// V2.0: PDS-managed DID generation
+
// Community DIDs and keys are generated entirely by the PDS
+
// No Coves-side DID generator needed (reserved for future V2.1 hybrid approach)
instanceDID := os.Getenv("INSTANCE_DID")
···
log.Printf("Instance domain: %s (extracted from DID: %s)", instanceDomain, instanceDID)
+
// V2.0: Initialize PDS account provisioner for communities (simplified)
+
// PDS handles all DID and key generation - no Coves-side cryptography needed
+
provisioner := communities.NewPDSAccountProvisioner(instanceDomain, defaultPDS)
+
log.Printf("✅ Community provisioner initialized (PDS-managed keys)")
+
log.Printf(" - Communities will be created at: %s", defaultPDS)
+
log.Printf(" - PDS will generate and manage all DIDs and keys")
+
// Initialize community service (no longer needs didGenerator directly)
+
communityService := communities.NewCommunityService(communityRepo, defaultPDS, instanceDID, instanceDomain, provisioner)
// Authenticate Coves instance with PDS to enable community record writes
// The instance needs a PDS account to write community records it owns