Skip to content

Bug FIx: Issue Changes After Validation#35

Open
shekhar316 wants to merge 6 commits intocausaai:poc-mar26from
shekhar316:temp1
Open

Bug FIx: Issue Changes After Validation#35
shekhar316 wants to merge 6 commits intocausaai:poc-mar26from
shekhar316:temp1

Conversation

@shekhar316
Copy link
Copy Markdown
Member

@shekhar316 shekhar316 commented Mar 30, 2026

This PR fixes the issues -

That RCA issue was changed after validation step.

This PR is based on PR#33 and PR#34

Summary by Sourcery

Refine RCA analysis pipeline to extract structured fields from LLM output, store a partial RCA report before validation, and present a new side‑by‑side RCA overview UI, while simplifying evidence/logs tabs and extending the report model accordingly.

New Features:

  • Add structured parsing of RCA output for severity, supporting evidence bullets, observable symptoms, affected services, key evidence, and supported logs.
  • Introduce partial RCA report storage to surface RCA results in the UI before validation completes.
  • Implement a new side‑by‑side RCA overview layout and badges styling for highlights, root cause, symptoms, and supporting evidence.

Bug Fixes:

  • Ensure the final RCA issue text remains consistent by reusing the original RCA output after validation instead of replacing it with validation-derived content.

Enhancements:

  • Improve GC pause detector prompts to assess OOM risk and provide more actionable explanations.
  • Update dashboard table issue titles to prefer the high-level issue when present.
  • Refine RCA assertion and evidence examples to use generic container placeholders instead of concrete names for clarity.

shekhar316 and others added 6 commits March 30, 2026 13:35
Signed-off-by: Shekhar Saxena <shekhar.saxena@ibm.com>
Signed-off-by: bharathappali <abharath@redhat.com>
Signed-off-by: bharathappali <abharath@redhat.com>
Signed-off-by: Shekhar Saxena <shekhar.saxena@ibm.com>
Signed-off-by: Shekhar Saxena <shekhar.saxena@ibm.com>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Mar 30, 2026

Reviewer's Guide

Implements structured RCA output parsing and partial report storage to prevent RCA issue text from changing after validation, and updates the UI to present a new side‑by‑side RCA overview with severity/evidence metadata and simplified evidence/logs tabs.

Sequence diagram for RCA analysis with partial report storage and validation

sequenceDiagram
    actor User
    participant DashboardUI
    participant AnalysisTrackingService
    participant RcaOrchestrator
    participant RootCauseAnalyst
    participant ValidationPipeline as Validation_and_Assertion_Components

    User->>DashboardUI: Start analysis for pod
    DashboardUI->>AnalysisTrackingService: createSession
    AnalysisTrackingService-->>DashboardUI: sessionId

    DashboardUI->>RcaOrchestrator: runAnalysisInternal(sessionId, namespace, podName)

    RcaOrchestrator->>AnalysisTrackingService: recordStageStart(sessionId, rca_analysis)
    RcaOrchestrator->>AnalysisTrackingService: updateStatus(ANALYZING_RCA)

    RcaOrchestrator->>RootCauseAnalyst: analyzeRootCause(anomalyType, llmContext)
    RootCauseAnalyst-->>RcaOrchestrator: rcaOutput

    RcaOrchestrator->>RcaOrchestrator: extractRootCauseTitle(rcaOutput)
    RcaOrchestrator->>RcaOrchestrator: extractRootCause(rcaOutput)
    RcaOrchestrator->>RcaOrchestrator: extractKeyEvidence(rcaOutput)
    RcaOrchestrator->>RcaOrchestrator: extractSupportedLogs(rcaOutput)
    RcaOrchestrator->>RcaOrchestrator: extractSeverity(rcaOutput)
    RcaOrchestrator->>RcaOrchestrator: extractSupportingEvidenceBullets(rcaOutput)
    RcaOrchestrator->>RcaOrchestrator: extractObservableSymptoms(rcaOutput)
    RcaOrchestrator->>RcaOrchestrator: extractAffectedServices(rcaOutput)

    RcaOrchestrator->>RcaOrchestrator: build partialReport (Map)
    RcaOrchestrator->>RcaOrchestrator: map partialReport JSON to RcaReport

    RcaOrchestrator->>AnalysisTrackingService: storePartialReport(sessionId, partialRcaReport)
    AnalysisTrackingService-->>RcaOrchestrator: ack

    AnalysisTrackingService-->>DashboardUI: websocket update with partial RcaReport
    DashboardUI->>DashboardUI: render RCA overview grid

    RcaOrchestrator->>AnalysisTrackingService: recordStageEnd(sessionId, rca_analysis)

    RcaOrchestrator->>AnalysisTrackingService: recordStageStart(sessionId, validation)
    RcaOrchestrator->>AnalysisTrackingService: updateStatus(VALIDATING)

    RcaOrchestrator->>ValidationPipeline: run validation and evidence matching
    ValidationPipeline-->>RcaOrchestrator: finalAssertions, finalDecision, finalStatus

    RcaOrchestrator->>RcaOrchestrator: reuse evidence, supportedLogs, severity, bullets, symptoms, affectedServices
    RcaOrchestrator->>RcaOrchestrator: build finalReport (Map)
    RcaOrchestrator->>RcaOrchestrator: map finalReport JSON to RcaReport

    RcaOrchestrator->>AnalysisTrackingService: markCompleted(sessionId, finalRcaReport)
    AnalysisTrackingService-->>DashboardUI: websocket update with final RcaReport
    DashboardUI->>DashboardUI: update RCA overview and evidence sections
Loading

Class diagram for updated RCA reporting and analysis components

classDiagram
    class RcaOrchestrator {
        -ObjectMapper mapper
        +void runAnalysisInternal(String sessionId, String namespace, String podName)
        -String extractRootCauseTitle(String rcaOutput)
        -String extractRootCause(String rcaOutput)
        -List~String~ extractSupportedLogs(String rcaOutput)
        -String extractKeyEvidence(String rcaOutput)
        -String extractSeverity(String rcaOutput)
        -List~String~ extractSupportingEvidenceBullets(String rcaOutput)
        -List~String~ extractObservableSymptoms(String rcaOutput)
        -List~String~ extractAffectedServices(String rcaOutput)
        -String parseGcAnomalyType(String raw)
        -String extractAnomalyExplanation(String rawResponse)
        -String extractGcExplanation(String rawResponse)
    }

    class AnalysisTrackingService {
        -RcaAnalysisSessionRepository repository
        +boolean storeArtifacts(String sessionId, CollectedArtifacts artifacts)
        +boolean storePartialReport(String sessionId, RcaReport report)
        +boolean markCompleted(String sessionId, RcaReport report)
        +void recordStageStart(String sessionId, String stage)
        +void recordStageEnd(String sessionId, String stage)
        +void updateStatus(String sessionId, AnalysisStatus status, String message)
    }

    class RcaReport {
        +String title
        +String issue
        +String highLevelIssue
        +String subLevelIssue
        +String evidence
        +List~String~ supportedLogs
        +List~String~ validationChecks
        +List~AssertionItem~ assertions
        +FinalDecision finalDecision
        +String severity
        +String confidenceLevel
        +List~String~ supportingEvidenceBullets
        +List~String~ observableSymptoms
        +List~String~ affectedServices
        +RcaReport()
    }

    class RootCauseAnalyst {
        <<interface>>
        +String analyzeRootCause(String anomalyType, String llmContext)
    }

    class GcPauseDetector {
        <<interface>>
        +String detectGcPause(String summarizedLogs)
    }

    class EvidenceMatcherAgent {
        <<interface>>
        +String matchEvidence(String rootCause, String logs)
    }

    class RcaAssertionExtractor {
        <<interface>>
        +String extractAssertions(String rootCause)
    }

    RcaOrchestrator --> RootCauseAnalyst : uses
    RcaOrchestrator --> GcPauseDetector : uses
    RcaOrchestrator --> AnalysisTrackingService : uses
    AnalysisTrackingService --> RcaReport : stores
    RcaOrchestrator --> RcaReport : builds
    RcaOrchestrator --> EvidenceMatcherAgent : uses
    RcaOrchestrator --> RcaAssertionExtractor : uses
Loading

File-Level Changes

Change Details Files
Parse richer structured fields from the RCA analyst output and keep the RCA issue text stable across validation.
  • Replace direct assignment of GC detection output to subLevelIssue with a dedicated extractGcExplanation helper that parses explanations from GC responses.
  • After rootCauseAnalyst.analyzeRootCause, parse key evidence, supported logs, severity, supporting evidence bullets, observable symptoms, and affected services using new extractor methods.
  • Build a partial RcaReport map from the RCA output (title, highLevelIssue, subLevelIssue, issue, evidence, supportedLogs, severity, supportingEvidenceBullets, observableSymptoms, affectedServices) and serialize/deserialize it into an RcaReport instance.
  • Use extractRootCause(rcaOutput) consistently for the final 'issue' field instead of the previously derived issue variable, and stop rebuilding evidence/supportedLogs from validation matchedLogs.
  • Augment the final report with severity, confidenceLevel (mapped from validation finalStatus), supportingEvidenceBullets, observableSymptoms, and affectedServices.
src/main/java/com/causa/rca/service/RcaOrchestrator.java
Add helper methods to extract structured RCA metadata (severity, evidence, logs, symptoms, services, GC explanation) from plain-text LLM output.
  • Loosen the ROOT_CAUSE regex to tolerate spaces/underscores and additional preceding sections like SUPPORTING_EVIDENCE.
  • Introduce extractSupportedLogs to parse the SUPPORTED_LOGS section, handle variations in header formatting, skip placeholder text, and strip bullets/indices.
  • Introduce extractKeyEvidence to retrieve the KEY_EVIDENCE section or return default messages when missing.
  • Introduce extractSeverity to read a single-line SEVERITY field, normalizing to High/Medium/Low with a Medium default.
  • Introduce extractSupportingEvidenceBullets, extractObservableSymptoms, and extractAffectedServices to parse their respective sections with bullet and comma handling and logging of extracted results.
  • Add extractGcExplanation to derive a human-readable GC explanation from GC detector output via EXPLANATION sections or text after anomaly tokens.
src/main/java/com/causa/rca/service/RcaOrchestrator.java
Persist partial RCA reports between analysis and validation so the UI can show stable RCA content earlier.
  • Add storePartialReport to AnalysisTrackingService to upsert a partial RcaReport on a session after RCA analysis but before validation completes, logging warnings for missing sessions.
  • Invoke trackingService.storePartialReport immediately after generating the partial report in RcaOrchestrator.
  • Update trackingService.updateStatus calls to reflect RCA analysis and validation phases with human-readable messages.
src/main/java/com/causa/rca/service/AnalysisTrackingService.java
src/main/java/com/causa/rca/service/RcaOrchestrator.java
Extend the RCA report model and LLM contracts to carry structured severity/evidence/symptom/service information and GC pause explanations.
  • Add severity, confidenceLevel, supportingEvidenceBullets, observableSymptoms, and affectedServices fields to RcaReport for richer UI display.
  • Update the RootCauseAnalyst prompt contract to require a SEVERITY field, structured SUPPORTING_EVIDENCE, OBSERVABLE_SYMPTOMS, AFFECTED_SERVICES, and stricter output rules with no markdown.
  • Enhance the GcPauseDetector system prompt to consider OOM risk context, require structured EXPLANATION content tied to OOM risk, and define clearer GC_PAUSE vs NO_GC_ISSUE criteria.
  • Adjust EvidenceMatcherAgent and RcaAssertionExtractor prompt examples to use a placeholder container name instead of a concrete one for generalization.
src/main/java/com/causa/rca/model/RcaReport.java
src/main/java/com/causa/rca/ai/RootCauseAnalyst.java
src/main/java/com/causa/rca/ai/GcPauseDetector.java
src/main/java/com/causa/rca/ai/EvidenceMatcherAgent.java
src/main/java/com/causa/rca/ai/RcaAssertionExtractor.java
Redesign the analysis details UI to use a side‑by‑side RCA overview and simplify the evidence/logs presentation.
  • Replace the previous RCA tabset (RCA Issue / High Level Anomaly / Detailed Issues) with a two-column layout: a left Highlights card showing the highLevelIssue and a right Root Cause Analysis card showing issue and subLevelIssue, using new CSS card styles.
  • Simplify the Evidence tab by removing sub-tabs and rendering an Evidence section (using report.evidence) plus a Supported Logs section that bulletizes each log line or shows a fallback message when none exist.
  • Update hidden clipboard copy elements for evidence and supported logs to match the new layout and IDs.
  • Add extensive CSS for .rca-overview-grid, RCA cards, badges, blue/orange boxes, lists, and evidence/symptom/evidence UI elements to support the redesigned layout.
src/main/resources/templates/analysisDetails.html
src/main/resources/META-INF/resources/css/dashboard.css
Adjust dashboard list behavior to prioritize the high-level anomaly summary as the issue title.
  • Change the dashboard table row title resolution so it prefers analysis.report.highLevelIssue, falling back to report.title or a generic 'Issue detected' label.
src/main/resources/META-INF/resources/js/dashboard.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • In analysisDetails.html the Evidence tab section headers and content appear swapped: the section titled "Supported Logs" renders {session.report.evidence} while the section titled "Evidence" renders the supported logs list, which is likely confusing and should be corrected so labels match their content.
  • The new RCA parsing helpers in RcaOrchestrator (e.g., extractSupportedLogs, extractKeyEvidence, extractSupportingEvidenceBullets, etc.) rely on double-newline or specific header patterns as section delimiters; consider relaxing these regex lookaheads to also handle headers that appear after a single newline or with minor formatting differences to make the extraction more robust to LLM output variability.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `analysisDetails.html` the Evidence tab section headers and content appear swapped: the section titled "Supported Logs" renders `{session.report.evidence}` while the section titled "Evidence" renders the supported logs list, which is likely confusing and should be corrected so labels match their content.
- The new RCA parsing helpers in `RcaOrchestrator` (e.g., `extractSupportedLogs`, `extractKeyEvidence`, `extractSupportingEvidenceBullets`, etc.) rely on double-newline or specific header patterns as section delimiters; consider relaxing these regex lookaheads to also handle headers that appear after a single newline or with minor formatting differences to make the extraction more robust to LLM output variability.

## Individual Comments

### Comment 1
<location path="src/main/resources/templates/analysisDetails.html" line_range="250-253" />
<code_context>
-                <div id="supported-logs-text" style="display:none;">{#for log in session.report.supportedLogs}{log}
-                    {/for}</div>
+            <!-- Evidence Section -->
+            <section class="details-section">
+                <div class="section-header">
+                    <h2 class="section-title">
+                        <span>Supported Logs</span>
+                        <button class="btn-copy-icon" onclick="copySection('evidence-section')" title="Copy Evidence">📋</button>
+                    </h2>
</code_context>
<issue_to_address>
**issue (bug_risk):** Evidence section heading and content are mismatched and the copy button targets a non-existent element id.

This section is titled "Supported Logs" but renders `session.report.evidence`, and the copy button calls `copySection('evidence-section')` even though this `<section>` no longer has that id. This will confuse users and break copy-to-clipboard. Please either align the heading with the evidence content and restore `id="evidence-section"`, or update the copySection target to match the actual DOM id you intend to copy from.
</issue_to_address>

### Comment 2
<location path="src/main/resources/templates/analysisDetails.html" line_range="262-267" />
<code_context>

-                <!-- Evidence Section -->
-                <section class="details-section">
+            <!-- Supported Logs Section -->
+            {#if session.report.supportedLogs && !session.report.supportedLogs.isEmpty()}
+                <section class="details-section" id="supported-logs-section">
                     <div class="section-header">
                         <h2 class="section-title">
                             <span>Evidence</span>
-                            <button class="btn-copy-icon" onclick="copySection('evidence-section')" title="Copy Evidence">📋</button>
+                            <button class="btn-copy-icon" onclick="copySection('supported-logs-section')" title="Copy Supported Logs">📋</button>
</code_context>
<issue_to_address>
**issue:** Supported logs section is labeled "Evidence", which inverts the two evidence-related headings.

This section’s heading says “Evidence” but the content is the supported logs list. Together with the previous section (where “Supported Logs” shows the evidence text), the headings appear swapped. Please swap/align the titles so “Evidence” contains the explanation and “Supported Logs” contains the logs to avoid UI confusion.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +250 to +253
<section class="details-section">
<div class="section-header">
<h2 class="section-title">
<span>Supported Logs</span>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Evidence section heading and content are mismatched and the copy button targets a non-existent element id.

This section is titled "Supported Logs" but renders session.report.evidence, and the copy button calls copySection('evidence-section') even though this <section> no longer has that id. This will confuse users and break copy-to-clipboard. Please either align the heading with the evidence content and restore id="evidence-section", or update the copySection target to match the actual DOM id you intend to copy from.

Comment on lines +262 to 267
<!-- Supported Logs Section -->
{#if session.report.supportedLogs && !session.report.supportedLogs.isEmpty()}
<section class="details-section" id="supported-logs-section">
<div class="section-header">
<h2 class="section-title">
<span>Evidence</span>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Supported logs section is labeled "Evidence", which inverts the two evidence-related headings.

This section’s heading says “Evidence” but the content is the supported logs list. Together with the previous section (where “Supported Logs” shows the evidence text), the headings appear swapped. Please swap/align the titles so “Evidence” contains the explanation and “Supported Logs” contains the logs to avoid UI confusion.

@shekhar316
Copy link
Copy Markdown
Member Author

@dinogun could we please review this and merge it into the poc-mar26 branch? Thanks.
This PR is dependent on PR#33 and PR#34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants