fix(chart): hide component status_history in chart view

Flapping components (e.g. DIMM CPU0_C2D1 with 13 transitions) stretched
table rows across several screens. The same journal events are already in
Event Logs, matched by component_ref. The Reanimator export keeps the field.

ADL-073.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mikhail ChusavitinandClaude Opus 5.5 committed 2026-09-28 13:18:58 +03:00
1 parent 2ce60280c3
commit ab53914d0a
3 files changed
+104

No files matched your search

+20
View File
@@ -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.
+49
View File
@@ -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")
}
}
+35
View File
@@ -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 {