diff --git a/bible-local/10-decisions.md b/bible-local/10-decisions.md index 0fb72f5..4ad81ef 100644 --- a/bible-local/10-decisions.md +++ b/bible-local/10-decisions.md @@ -2130,3 +2130,23 @@ events use source `BMC`. timeline under v2.13; contract change requested in `docs/reanimator-contract-request-installed-at.md`, follow-up in BACKLOG `[installed_at]`. + +## ADL-073 — Chart view hides component status_history + +**Date:** 2026-09-28 +**Context:** Inspur/Lenovo parsers fill component `status_history` from the BMC +journal (IDL/SEL Assert/Deassert). In the embedded chart view a flapping DIMM +(CPU0_C2D1, 13 transitions) rendered every entry as `changed_at/details/status` +lines, stretching the memory table row across several screens. The same +journal events are already in Event Logs with `component_ref` = the component's +sensor name (for DIMMs, the slot). + +**Decision:** `GET /chart/current` removes `status_history` from every +`hardware` component before rendering. The Reanimator export (JSON download, +upload to Reanimator) keeps `status_history` unchanged. The chart submodule is +not modified. + +**Consequences:** +- The component's transition timeline is read from Event Logs filtered by + `component_ref`. +- `status`, `status_changed_at`, and `error_description` stay in the tables. diff --git a/internal/server/chart_view_test.go b/internal/server/chart_view_test.go index 3f10461..0c08312 100644 --- a/internal/server/chart_view_test.go +++ b/internal/server/chart_view_test.go @@ -70,3 +70,52 @@ func TestHandleChartCurrent_RendersEmptyViewerWithoutResult(t *testing.T) { t.Fatalf("expected empty chart viewer, got %q", body) } } + +func TestHandleChartCurrent_HidesComponentStatusHistory(t *testing.T) { + changedAt := time.Date(2026, 8, 12, 7, 33, 0, 0, time.UTC) + s := New(Config{}) + s.SetResult(&models.AnalysisResult{ + SourceType: models.SourceTypeArchive, + Filename: "example.zip", + CollectedAt: time.Date(2026, 8, 12, 12, 0, 0, 0, time.UTC), + Hardware: &models.HardwareConfig{ + BoardInfo: models.BoardInfo{ProductName: "SYS-TEST", SerialNumber: "SN123"}, + Memory: []models.MemoryDIMM{ + { + Slot: "CPU0_C2D1", + Present: true, + SizeMB: 65536, + SerialNumber: "SN-DIMM", + Status: "Warning", + StatusHistory: []models.StatusHistoryEntry{ + {Status: "Warning", ChangedAt: changedAt, Details: "history-only details"}, + }, + }, + }, + }, + }) + + exported, err := currentReanimatorSnapshotBytes(s.GetResult()) + if err != nil { + t.Fatalf("currentReanimatorSnapshotBytes() error = %v", err) + } + if !strings.Contains(string(exported), "status_history") { + t.Fatalf("expected export snapshot to keep status_history") + } + + req := httptest.NewRequest(http.MethodGet, "/chart/current", nil) + rec := httptest.NewRecorder() + + s.mux.ServeHTTP(rec, req) + + if rec.Code != http.StatusOK { + t.Fatalf("expected 200, got %d: %s", rec.Code, rec.Body.String()) + } + body := rec.Body.String() + if !strings.Contains(body, "CPU0_C2D1") { + t.Fatalf("expected DIMM row in chart, got %q", body) + } + if strings.Contains(body, "status_history") || strings.Contains(body, "history-only details") { + t.Fatalf("expected status_history hidden from chart view") + } +} diff --git a/internal/server/handlers.go b/internal/server/handlers.go index 98b0da3..c7a8752 100644 --- a/internal/server/handlers.go +++ b/internal/server/handlers.go @@ -85,6 +85,11 @@ func (s *Server) handleChartCurrent(w http.ResponseWriter, r *http.Request) { s.htmlError(w, "failed to build reanimator snapshot: "+err.Error(), http.StatusInternalServerError) return } + snapshotBytes, err = stripChartStatusHistory(snapshotBytes) + if err != nil { + s.htmlError(w, "failed to build reanimator snapshot: "+err.Error(), http.StatusInternalServerError) + return + } opts := chartviewer.RenderOptions{} if nt, nb := privacyNotice(result.PrivacyScan); nt != "" { @@ -179,6 +184,36 @@ func currentReanimatorSnapshotBytes(result *models.AnalysisResult) ([]byte, erro return buf.Bytes(), nil } +// stripChartStatusHistory drops component status_history from the snapshot +// shown in the chart view (ADL-073). The same transitions are in event_logs, +// matched to the component by component_ref. The export keeps the field. +func stripChartStatusHistory(snapshot []byte) ([]byte, error) { + var root map[string]any + if err := json.Unmarshal(snapshot, &root); err != nil { + return nil, err + } + hardware, ok := root["hardware"].(map[string]any) + if !ok { + return snapshot, nil + } + for key, section := range hardware { + if key == "event_logs" { + continue + } + switch typed := section.(type) { + case map[string]any: + delete(typed, "status_history") + case []any: + for _, item := range typed { + if component, ok := item.(map[string]any); ok { + delete(component, "status_history") + } + } + } + } + return json.Marshal(root) +} + func chartTitle(result *models.AnalysisResult) string { const fallback = "LOGPile Reanimator Viewer" if result == nil {