diff --git a/.gitignore b/.gitignore index 3695860b..7a14de72 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,7 @@ reports/ # Typescript .env + +# Pipeline artifacts and worktrees +.artifacts/ +.worktrees/ diff --git a/control-plane/.DS_Store b/control-plane/.DS_Store deleted file mode 100644 index ea68bea5..00000000 Binary files a/control-plane/.DS_Store and /dev/null differ diff --git a/control-plane/internal/.DS_Store b/control-plane/internal/.DS_Store deleted file mode 100644 index f8e4a1ab..00000000 Binary files a/control-plane/internal/.DS_Store and /dev/null differ diff --git a/control-plane/internal/handlers/memory.go b/control-plane/internal/handlers/memory.go index 6fec02ae..fc0257fa 100644 --- a/control-plane/internal/handlers/memory.go +++ b/control-plane/internal/handlers/memory.go @@ -61,11 +61,11 @@ type ErrorResponse struct { func SetMemoryHandler(storageProvider MemoryStorage) gin.HandlerFunc { return func(c *gin.Context) { ctx := c.Request.Context() - logger.Logger.Debug().Msg("🔍 MEMORY_HANDLER_DEBUG: SetMemoryHandler called") + logger.Logger.Debug().Str("operation", "set_memory").Str("handler", "SetMemoryHandler").Msg("handler invoked") var req SetMemoryRequest if err := c.ShouldBindJSON(&req); err != nil { - logger.Logger.Debug().Err(err).Msg("🔍 MEMORY_HANDLER_DEBUG: JSON binding failed") + logger.Logger.Debug().Err(err).Str("operation", "bind_request").Msg("failed to bind JSON request") c.JSON(http.StatusBadRequest, ErrorResponse{ Error: "invalid_request", Message: err.Error(), @@ -73,23 +73,23 @@ func SetMemoryHandler(storageProvider MemoryStorage) gin.HandlerFunc { }) return } - logger.Logger.Debug().Msgf("🔍 MEMORY_HANDLER_DEBUG: Request parsed successfully: key=%s", req.Key) + logger.Logger.Debug().Str("operation", "parse_request").Str("key", req.Key).Msg("request parsed") scope, scopeID := resolveScope(c, req.Scope) - logger.Logger.Debug().Msgf("🔍 MEMORY_HANDLER_DEBUG: Scope resolved: scope=%s, scopeID=%s", scope, scopeID) + logger.Logger.Debug().Str("operation", "resolve_scope").Str("scope", scope).Str("scope_id", scopeID).Msg("scope resolved") // Get existing memory value for event publishing - logger.Logger.Debug().Msg("🔍 MEMORY_HANDLER_DEBUG: Getting existing memory value...") + logger.Logger.Debug().Str("operation", "get_existing").Str("key", req.Key).Msg("retrieving existing memory value") var previousData json.RawMessage if existingMemory, err := storageProvider.GetMemory(ctx, scope, scopeID, req.Key); err == nil { previousData = existingMemory.Data } - logger.Logger.Debug().Msg("🔍 MEMORY_HANDLER_DEBUG: Existing memory check completed") + logger.Logger.Debug().Str("operation", "get_existing").Bool("exists", previousData != nil).Msg("existing memory check completed") - logger.Logger.Debug().Msg("🔍 MEMORY_HANDLER_DEBUG: Marshaling data to JSON...") + logger.Logger.Debug().Str("operation", "marshal_data").Str("key", req.Key).Msg("marshaling data to JSON") dataJSON, err := marshalDataWithLogging(req.Data, "memory_data") if err != nil { - logger.Logger.Error().Err(err).Msg("❌ MEMORY_MARSHAL_ERROR: Failed to marshal memory data") + logger.Logger.Error().Err(err).Str("operation", "marshal").Str("key", req.Key).Msg("failed to marshal memory data") c.JSON(http.StatusBadRequest, ErrorResponse{ Error: "marshal_error", Message: err.Error(), @@ -97,7 +97,7 @@ func SetMemoryHandler(storageProvider MemoryStorage) gin.HandlerFunc { }) return } - logger.Logger.Debug().Msgf("🔍 MEMORY_HANDLER_DEBUG: JSON marshaling successful, length: %d", len(dataJSON)) + logger.Logger.Debug().Str("operation", "marshal_data").Int("size_bytes", len(dataJSON)).Msg("data marshaled successfully") now := time.Now() memory := &types.Memory{ @@ -108,11 +108,11 @@ func SetMemoryHandler(storageProvider MemoryStorage) gin.HandlerFunc { CreatedAt: now, UpdatedAt: now, } - logger.Logger.Debug().Msg("🔍 MEMORY_HANDLER_DEBUG: Memory object created") + logger.Logger.Debug().Str("operation", "create_memory_object").Str("key", req.Key).Msg("memory object created") - logger.Logger.Debug().Msg("🔍 MEMORY_HANDLER_DEBUG: Calling storageProvider.SetMemory...") + logger.Logger.Debug().Str("operation", "store_memory").Str("key", req.Key).Msg("storing memory to backend") if err := storageProvider.SetMemory(ctx, memory); err != nil { - logger.Logger.Debug().Err(err).Msg("🔍 MEMORY_HANDLER_DEBUG: SetMemory failed") + logger.Logger.Debug().Err(err).Str("operation", "store_memory").Str("key", req.Key).Msg("failed to store memory") c.JSON(http.StatusInternalServerError, ErrorResponse{ Error: "storage_error", Message: err.Error(), @@ -120,10 +120,10 @@ func SetMemoryHandler(storageProvider MemoryStorage) gin.HandlerFunc { }) return } - logger.Logger.Debug().Msg("🔍 MEMORY_HANDLER_DEBUG: SetMemory completed successfully") + logger.Logger.Debug().Str("operation", "store_memory").Str("key", req.Key).Msg("memory stored successfully") // Publish memory change event - logger.Logger.Debug().Msg("🔍 MEMORY_HANDLER_DEBUG: Creating memory change event...") + logger.Logger.Debug().Str("operation", "create_event").Str("action", "set").Str("key", req.Key).Msg("creating memory change event") event := &types.MemoryChangeEvent{ Type: "memory_change", Scope: scope, @@ -140,18 +140,18 @@ func SetMemoryHandler(storageProvider MemoryStorage) gin.HandlerFunc { } // Store event (don't fail the request if event storage fails) - logger.Logger.Debug().Msg("🔍 MEMORY_HANDLER_DEBUG: Storing event...") + logger.Logger.Debug().Str("operation", "store_event").Str("key", req.Key).Msg("storing memory change event") if err := storageProvider.StoreEvent(ctx, event); err != nil { // Log error but continue logger.Logger.Warn().Err(err).Msg("Warning: Failed to store memory change event") } else if err := storageProvider.PublishMemoryChange(ctx, *event); err != nil { logger.Logger.Warn().Err(err).Msg("Warning: Failed to publish memory change event") } - logger.Logger.Debug().Msg("🔍 MEMORY_HANDLER_DEBUG: Event storage completed") + logger.Logger.Debug().Str("operation", "store_event").Str("key", req.Key).Msg("event storage completed") - logger.Logger.Debug().Msg("🔍 MEMORY_HANDLER_DEBUG: Sending response...") + logger.Logger.Debug().Str("operation", "send_response").Str("key", req.Key).Msg("sending response") c.JSON(http.StatusOK, memory) - logger.Logger.Debug().Msg("🔍 MEMORY_HANDLER_DEBUG: Response sent successfully") + logger.Logger.Debug().Str("operation", "send_response").Str("key", req.Key).Msg("response sent") } } diff --git a/control-plane/internal/handlers/utils.go b/control-plane/internal/handlers/utils.go index 86d443cc..7826d6dd 100644 --- a/control-plane/internal/handlers/utils.go +++ b/control-plane/internal/handlers/utils.go @@ -10,20 +10,20 @@ import ( // marshalDataWithLogging marshals data to JSON with proper error handling and logging func marshalDataWithLogging(data interface{}, fieldName string) ([]byte, error) { if data == nil { - logger.Logger.Debug().Msgf("🔍 MARSHAL_DEBUG: %s is nil, returning null", fieldName) + logger.Logger.Debug().Str("operation", "marshal").Str("field_name", fieldName).Bool("is_nil", true).Msg("field is nil") return []byte("null"), nil } // Log the type and content of data being marshaled - logger.Logger.Debug().Msgf("🔍 MARSHAL_DEBUG: Marshaling %s (type: %T)", fieldName, data) + logger.Logger.Debug().Str("operation", "marshal").Str("field_name", fieldName).Str("type", fmt.Sprintf("%T", data)).Msg("marshaling field") // Attempt to marshal with detailed error reporting jsonData, err := json.Marshal(data) if err != nil { - logger.Logger.Error().Err(err).Msgf("❌ MARSHAL_ERROR: Failed to marshal %s (type: %T): %v", fieldName, data, data) + logger.Logger.Error().Err(err).Str("operation", "marshal").Str("field_name", fieldName).Str("type", fmt.Sprintf("%T", data)).Msg("failed to marshal field") return nil, fmt.Errorf("failed to marshal %s: %w", fieldName, err) } - logger.Logger.Debug().Msgf("✅ MARSHAL_SUCCESS: Successfully marshaled %s (%d bytes): %s", fieldName, len(jsonData), string(jsonData)) + logger.Logger.Debug().Str("operation", "marshal").Str("field_name", fieldName).Int("size_bytes", len(jsonData)).Msg("field marshaled successfully") return jsonData, nil } diff --git a/control-plane/internal/storage/.DS_Store b/control-plane/internal/storage/.DS_Store deleted file mode 100644 index 5008ddfc..00000000 Binary files a/control-plane/internal/storage/.DS_Store and /dev/null differ diff --git a/control-plane/web/.DS_Store b/control-plane/web/.DS_Store deleted file mode 100644 index 0adee3f0..00000000 Binary files a/control-plane/web/.DS_Store and /dev/null differ